-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsuggest_removed.php
More file actions
348 lines (285 loc) · 11.8 KB
/
suggest_removed.php
File metadata and controls
348 lines (285 loc) · 11.8 KB
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
<?
include("includes/evoltSQL.php");
include("includes/evoltDisplayFunctions.php");
if ($HTTP_POST_VARS["suggest"] && $HTTP_POST_VARS["remember"]) {
// set cookies containing name and email if requested
setcookie ("author", stripslashes($HTTP_POST_VARS["author"]),time()+60*60*24*365);
setcookie ("email", stripslashes($HTTP_POST_VARS["email"]),time()+60*60*24*365);
}
elseif ($HTTP_POST_VARS["suggest"] && !$HTTP_POST_VARS["remember"]) {
// otherwise delete the cookies
setcookie ("author");
setcookie ("email");
}
include("includes/suggest_header.php");
$db = new MySQL;
$dblink = $db->init();
function showform($errors="") {
global $HTTP_POST_VARS;
global $HTTP_GET_VARS;
global $HTTP_COOKIE_VARS;
global $db;
// get categories from database
$sql = "select CatID,CatName from Categories where CatApproved='1' order by CatName";
$categories = $db->select($sql);
// get form variables sent to the form
if ($HTTP_POST_VARS) {
// from a previous form submission
$url = trim(htmlspecialchars(stripslashes($HTTP_POST_VARS["url"])));
$title = trim(htmlspecialchars(stripslashes($HTTP_POST_VARS["title"])));
$author = trim(htmlspecialchars(stripslashes($HTTP_POST_VARS["author"])));
$email = trim(htmlspecialchars(stripslashes($HTTP_POST_VARS["email"])));
$desc = trim(htmlspecialchars(stripslashes($HTTP_POST_VARS["desc"])));
if ($HTTP_POST_VARS["remember"] == 1) {
$isticked = " checked";
}
else {
$isticked = "";
}
}
elseif($HTTP_GET_VARS) {
// from the bookmarklet
$url = trim(htmlspecialchars(stripslashes($HTTP_GET_VARS["url"])));
$title = trim(htmlspecialchars(stripslashes($HTTP_GET_VARS["title"])));
$author = trim(htmlspecialchars(stripslashes($HTTP_GET_VARS["author"])));
$email = trim(htmlspecialchars(stripslashes($HTTP_GET_VARS["email"])));
$desc = trim(htmlspecialchars(stripslashes($HTTP_GET_VARS["desc"])));
if($HTTP_COOKIE_VARS["author"] OR $HTTP_COOKIE_VARS["email"]) {
$isticked = " checked";
}
else {
$isticked = "";
}
}
// if author and email aren't set, check cookies for values
if (empty($author)) {
// from the cookies
$author = trim(htmlspecialchars(stripslashes($HTTP_COOKIE_VARS["author"])));
}
if (empty($email)) {
// from the cookies
$email = trim(htmlspecialchars(stripslashes($HTTP_COOKIE_VARS["email"])));
}
print "<form action=\"$PHP_SELF\" method=\"post\">";
print "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">";
print "<tr><td> </td><td>\n";
if (!empty($errors)) {
print "One or more fields have not been completed correctly. Please make the necessary alterations then try again.";
}
else {
print "Add a link to the evolt.org web design and development directory:\n";
}
print "<br><br>\n";
print "Required fields are indicated with <strong>[square brackets]</strong>";
print "<br><br>\n";
print "</td></tr>\n";
if (@in_array("no_url",$errors)) {
print "<tr><td> </td><td>\n";
print "<strong>You must enter a url:</strong>";
print "</td></tr>\n";
}
print "<tr><td align=\"right\"><strong>[URL:]</strong></td><td><input name=\"url\" size=\"40\" VALUE=\"$url\"></td></tr>";
if (@in_array("no_title",$errors)) {
print "<tr><td> </td><td>\n";
print "<strong>You must enter a title:</strong>";
print "</td></tr>\n";
}
print "<tr><td align=\"right\"><strong>[Title:]</strong></td><td><input name=\"title\" size=\"40\" value=\"$title\"></td></tr>";
print "<tr><td align=\"right\" valign=\"top\"><strong>Description:</strong></td><td><textarea name=\"desc\" rows=\"3\" cols=\"40\">$desc</textarea></td></tr>";
print "<tr><td> </td><td>\n";
print "<small><strong>Tip:</strong> In most browsers, any text selected will appear in the description field.</small>\n";
print "</td></tr>\n";
if (@in_array("no_cat",$errors)) {
print "<tr><td> </td><td>\n";
print "<strong>You must select at least one category to submit this link to.</strong>";
print "</td></tr>\n";
}
print "<tr><td align=\"right\" valign=\"top\"><strong>[Categories:]</strong></td><td>";
print "<small>(To select more than one hold down the control key while clicking)</small>\n<br>\n";
print "<select name=\"CatID[]\" size=\"8\" multiple>\n";
foreach ($categories as $category) {
print " <option value=\"";
print $category["CatID"];
print "\"";
if (@in_array($category["CatID"],$HTTP_POST_VARS["CatID"])) {
print " selected";
}
print ">";
print $category["CatName"];
print "</option>\n";
}
print "</select>\n";
print "</td></tr>";
print "<tr><td align=\"right\"><strong>Your Name:</strong></td><td><input name=\"author\" size=\"40\" value=\"$author\"></td></tr>";
print "<tr><td align=\"right\"><strong>Your Email:</strong></td><td><input name=\"email\" size=\"40\" value=\"$email\"></td></tr>";
print "<tr><td align=\"right\" valign=\"top\"><strong>Save Name:</strong></td><td>\n";
print "<input type=\"checkbox\" name=\"remember\" value=\"1\"$isticked><br>\n";
print "<small>(Uses cookies to remember your name and email address for next time)</small>\n";
print "</td></tr>\n";
print "<tr><td></td><td><input type=\"submit\" name=\"suggest\" value=\"Submit Resource\"></td></tr>";
print "</table>";
print "</form>";
}
function validateform() {
global $PHP_SELF;
global $HTTP_POST_VARS;
// make sure they have entered a title
if (!$HTTP_POST_VARS["title"]) {
$errors[] = "no_title";
}
// make sure they have entered a url
if (!$HTTP_POST_VARS["url"]) {
$errors[] = "no_url";
}
// make sure they have selected at least one category
if (!$HTTP_POST_VARS["CatID"]) {
$errors[] = "no_cat";
}
// return validation results
if ($errors) {
return array (FALSE,$errors);
}
else {
return array (TRUE,$errors);
}
}
function showresults() {
global $db;
global $PHP_SELF;
global $HTTP_POST_VARS;
$CatID = $HTTP_POST_VARS["CatID"];
$url = trim(htmlspecialchars(stripslashes($HTTP_POST_VARS["url"])));
$title = trim(htmlspecialchars(stripslashes($HTTP_POST_VARS["title"])));
$author = trim(htmlspecialchars(stripslashes($HTTP_POST_VARS["author"])));
$email = trim(htmlspecialchars(stripslashes($HTTP_POST_VARS["email"])));
$desc = trim(htmlspecialchars(stripslashes($HTTP_POST_VARS["desc"])));
$SubmitDate = time();
// escape quotes for database
$esc_title = addslashes($title);
$esc_author = addslashes($author);
$esc_desc =addslashes($desc);
// echo "testing, ignore this: " . $esc_title;
foreach ($CatID as $Cat) {
$sql = "SELECT CatName FROM Categories WHERE CatID='$Cat'";
$getCatNames = $db->select($sql);
$CatName[] = $getCatNames[0]["CatName"];
}
// insert link into links table
$sql = "INSERT INTO Links ";
$sql .= "(Url,LinkName,Description,SubmitName,SubmitEmail,SubmitDate,Approved,Important) ";
$sql .= "values ";
$sql .= "('$url','$esc_title','$esc_desc','$esc_author','$email',$SubmitDate,'0','0') ";
// $results = $db->insert($sql);
// Commented out insert as theforum has voted to close deo to
// new content
// Martin Burns 23 October 2006
// insert link into CatLinks table (once for each category)
foreach ($CatID as $category) {
$sql2 = "INSERT INTO LinkCats ";
$sql2 .= "(LinkID,CatID) ";
$sql2 .= "values ";
$sql2 .= "('$results','$category') ";
//$results2 = $db->insert($sql2);
// Commented out insert as theforum has voted to close deo to
// new content
// Martin Burns 23 October 2006
}
// if database insert is successful, print success page and email admin
if ($results) {
print "<p>\n";
print "Your link has been submitted to the directory admin for review.\n";
print "</p>\n";
print "<p>\n";
print "You submitted the following information:";
print "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">";
print "<tr><td align=\"right\" valign=\"top\"><strong>Categories:</strong></td><td>";
print implode (" and ", $CatName);
print "</td></tr>";
print "<tr><td align=\"right\"><strong>Title:</strong></td><td>$title</td></tr>";
print "<tr><td align=\"right\"><strong>URL:</strong></td><td>$url</td></tr>";
print "<tr><td align=\"right\" valign=\"top\"><strong>Description:</strong></td><td><div style=\"white-space: pre;\">$desc</div></td></tr>";
print "<tr><td align=\"right\"><strong>Your Name:</strong></td><td>$esc_author</td></tr>";
print "<tr><td align=\"right\"><strong>Your Email:</strong></td><td>$email</td></tr>";
print "</table>";
print "<p>\n";
print "Thank you for your contribution!\n";
print "</p>\n";
mail("content@lists.evolt.org","New d.e.o. link!","A new link has been submitted to the evolt directory (using the bookmarklet).\n\nTo view/approve it go here:\n\nhttp://dir.evolt.org/manage/viewlinks.php?LinkID=$results\n","From:d.e.o. Robot <nobody@leo.evolt.org>");
print "<script language=\"JavaScript\" type=\"text/javascript\">\n";
print "<!--\n";
print "document.write('<a href=\"javascript:self.close();\">Close this window</a>');\n";
print "setTimeout(\"self.close();\",5000);\n";
print "//-->\n";
print "</script>\n\n";
}
// if database insert failed, email info to admin instead
else {
# $recipient = "content@lists.evolt.org";
$recipient = "dmah@shaw.ca";
$subject = "d.e.o. link submission [FAILED INSERT]";
$headers = "From: $author <$email>\n";
$message = "$author has just submitted a link to the evolt directory, but the entry could not be inserted.\n\n";
$message .= "This is what they sent:\n\n";
$message .= "Categories: " . implode (" and ", $CatName) . "\n";
$message .= "Title: " . $title . "\n";
$message .= "URL: " . $url . "\n";
$message .= "Description: " . $desc . "\n";
$message .= "Author: " . $author . "\n";
$message .= "Email: " . $email . "\n\n";
$message .= "The SQL statements needed to insert and approve this entry is given below:\n\n";
$message .= "INSERT INTO Links ";
$message .= "(Url,LinkName,Description,SubmitName,SubmitEmail,SubmitDate,Approved,Important) ";
$message .= "values ";
$message .= "('$url','$esc_title','$esc_desc','$esc_author','$email',$SubmitDate,'0','0')\n";
foreach ($CatID as $category) {
$message .= "INSERT INTO LinkCats ";
$message .= "(LinkID,CatID) ";
$message .= "values ";
$message .= "('$results','$category') \n";
}
$message .= "\nRemember to put the auto increment ID in instead of [LINK_ID] when adding to LinkCats table.\n\n";
$message .= "Have a nice day!\n\n";
// mail message to admin
mail($recipient,$subject,$message,$headers);
print "<p>\n";
print "Your link has been submitted to the directory admin for review.\n";
print "</p>\n";
print "<p>\n";
print "You submitted the following information:";
print "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">";
print "<tr><td align=\"right\" valign=\"top\"><strong>Categories:</strong></td><td>";
print implode (" and ", $CatName);
print "</td></tr>";
print "<tr><td align=\"right\"><strong>Title:</strong></td><td>$title</td></tr>";
print "<tr><td align=\"right\"><strong>URL:</strong></td><td>$url</td></tr>";
print "<tr><td align=\"right\" valign=\"top\"><strong>Description:</strong></td><td><div style=\"white-space: pre;\">$desc</div></td></tr>";
print "<tr><td align=\"right\"><strong>Your Name:</strong></td><td>$author</td></tr>";
print "<tr><td align=\"right\"><strong>Your Email:</strong></td><td>$email</td></tr>";
print "</table>";
print "<p>\n";
print "Thank you for your contribution!\n";
print "</p>\n";
print "<script language=\"JavaScript\" type=\"text/javascript\">\n";
print "<!--\n";
print "document.write('<a href=\"javascript:self.close();\">Close this window</a>');\n";
print "setTimeout(\"self.close();\",5000);\n";
print "//-->\n";
print "</script>\n\n";
}
}
if ($HTTP_POST_VARS["suggest"]) {
// validate the submitted data
list ($is_valid,$errors) = validateform();
if ($is_valid) {
// display results page
showresults();
}
else {
showform($errors);
}
}
else {
showform();
}
include("includes/suggest_footer.php");
?>