-
Notifications
You must be signed in to change notification settings - Fork 1
/
output_fns.php
259 lines (242 loc) · 6.42 KB
/
output_fns.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<?php
function do_html_header($title)
{
// print an HTML header
?>
<html>
<head>
<title><?php echo $title;?></title>
<style>
body { font-family: Arial, Helvetica, sans-serif; font-size: 13px }
li, td { font-family: Arial, Helvetica, sans-serif; font-size: 13px }
hr { color: #3333cc; width=300; text-align=left}
a { color: #000000 }
</style>
</head>
<body>
<img src="bookmark.gif" alt="PHPbookmark logo" border=0
align=left valign=bottom height = 55 width = 57 />
<h1> PHPbookmark</h1>
<hr />
<?php
if($title)
do_html_heading($title);
}
function do_html_footer()
{
// print an HTML footer
?>
</body>
</html>
<?php
}
function do_html_heading($heading)
{
// print heading
?>
<h2><?php echo $heading;?></h2>
<?php
}
function do_html_URL($url, $name)
{
// output URL as link and br
?>
<br /><a href="<?php echo $url;?>"><?php echo $name;?></a><br />
<?php
}
function display_site_info()
{
// display some marketing info
?>
<ul>
<li>Store your bookmarks online with us!</li>
<li>See what other users use!</li>
<li>Share your favorite links with others!</li>
</ul>
<?php
}
function display_login_form()
{
?>
<a href='register_form.php'>Not a member?</a>
<form method='post' action='member.php'>
<table bgcolor='#cccccc'>
<tr>
<td colspan=2>Members log in here:</td>
<tr>
<td>Username:</td>
<td><input type='text' name='username'></td></tr>
<tr>
<td>Password:</td>
<td><input type='password' name='passwd'></td></tr>
<tr>
<td colspan=2 align='center'>
<input type='submit' value='Log in'></td></tr>
<tr>
<td colspan=2><a href='forgot_form.php'>Forgot your password?</a></td>
</tr>
</table></form>
<?php
}
function display_registration_form()
{
?>
<form method='post' action='register_new.php'>
<table bgcolor='#cccccc'>
<tr>
<td>Email address:</td>
<td><input type='text' name='email' size=30 maxlength=100></td></tr>
<tr>
<td>Preferred username <br />(max 16 chars):</td>
<td valign='top'><input type='text' name='username'
size=16 maxlength=16></td></tr>
<tr>
<td>Password <br />(between 6 and 16 chars):</td>
<td valign='top'><input type='password' name='passwd'
size=16 maxlength=16></td></tr>
<tr>
<td>Confirm password:</td>
<td><input type='password' name='passwd2' size=16 maxlength=16></td></tr>
<tr>
<td colspan=2 align='center'>
<input type='submit' value='Register'></td></tr>
</table></form>
<?php
}
function display_user_urls($url_array)
{
// display the table of URLs
// set global variable, so we can test later if this is on the page
global $bm_table;
$bm_table = true;
?>
<br />
<form name='bm_table' action='delete_bms.php' method='post'>
<table width=300 cellpadding=2 cellspacing=0>
<?php
$color = "#cccccc";
echo "<tr bgcolor='$color'><td><strong>Bookmark</strong></td>";
echo "<td><strong>Delete?</strong></td></tr>";
if (is_array($url_array) && count($url_array)>0)
{
foreach ($url_array as $url)
{
if ($color == "#cccccc")
$color = "#ffffff";
else
$color = "#cccccc";
// remember to call htmlspecialchars() when we are displaying user data
echo "<tr bgcolor='$color'><td><a href=\"$url\">".htmlspecialchars($url)."</a></td>";
echo "<td><input type='checkbox' name=\"del_me[]\"
value=\"$url\"></td>";
echo "</tr>";
}
}
else
echo "<tr><td>No bookmarks on record</td></tr>";
?>
</table>
</form>
<?php
}
function display_user_menu()
{
// display the menu options on this page
?>
<hr />
<a href="member.php">Home</a> |
<a href="add_bm_form.php">Add BM</a> |
<?php
// only offer the delete option if bookmark table is on this page
global $bm_table;
if($bm_table==true)
echo "<a href='#' onClick='bm_table.submit();'>Delete BM</a> | ";
else
echo "<font color='#cccccc'>Delete BM</font> | ";
?>
<a href="change_passwd_form.php">Change password</a>
<br />
<a href="recommend.php">Recommend URLs to me</a> |
<a href="logout.php">Logout</a>
<hr />
<?php
}
function display_add_bm_form()
{
// display the form for people to ener a new bookmark in
?>
<form name='bm_table' action='add_bms.php' method='post'>
<table width=250 cellpadding=2 cellspacing=0 bgcolor='#cccccc'>
<tr><td>New BM:</td><td><input type='text' name='new_url' value="http://"
size=30 maxlength=255></td></tr>
<tr><td colspan=2 align='center'><input type='submit' value='Add bookmark'></td></tr>
</table>
</form>
<?php
}
function display_password_form()
{
// display html change password form
?>
<br />
<form action='change_passwd.php' method='post'>
<table width=250 cellpadding=2 cellspacing=0 bgcolor='#cccccc'>
<tr><td>Old password:</td>
<td><input type='password' name='old_passwd' size=16 maxlength=16></td>
</tr>
<tr><td>New password:</td>
<td><input type='password' name='new_passwd' size=16 maxlength=16></td>
</tr>
<tr><td>Repeat new password:</td>
<td><input type='password' name='new_passwd2' size=16 maxlength=16></td>
</tr>
<tr><td colspan=2 align='center'><input type='submit' value='Change password'>
</td></tr>
</table>
<br />
<?php
};
function display_forgot_form()
{
// display HTML form to reset and email password
?>
<br />
<form action='forgot_passwd.php' method='post'>
<table width=250 cellpadding=2 cellspacing=0 bgcolor='#cccccc'>
<tr><td>Enter your username</td>
<td><input type='text' name='username' size=16 maxlength=16></td>
</tr>
<tr><td colspan=2 align='center'><input type='submit' value='Change password'>
</td></tr>
</table>
<br />
<?php
};
function display_recommended_urls($url_array)
{
// similar output to display_user_urls
// instead of displaying the users bookmarks, display recomendation
?>
<br />
<table width=300 cellpadding=2 cellspacing=0>
<?php
$color = "#cccccc";
echo "<tr bgcolor=$color><td><strong>Recommendations</strong></td></tr>";
if (is_array($url_array) && count($url_array)>0)
{
foreach ($url_array as $url)
{
if ($color == "#cccccc")
$color = "#ffffff";
else
$color = "#cccccc";
echo "<tr bgcolor='$color'><td><a href=\"$url\">".htmlspecialchars($url)."</a></td></tr>";
}
}
else
echo "<tr><td>No recommendations for you today.</td></tr>";
?>
</table>
<?php
};
?>