Browse code

Initial uplad w/ php7 fixes

Rainer Volkrodt authored on 2016/03/12 15:54:02
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,420 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// Copyright (c) 2007 by Tammy Keefer
4
+// Based on eFiction 1.1
5
+// Copyright (C) 2003 by Rebecca Smallwood.
6
+// http://efiction.sourceforge.net/
7
+// ----------------------------------------------------------------------
8
+// LICENSE
9
+//
10
+// This program is free software; you can redistribute it and/or
11
+// modify it under the terms of the GNU General Public License (GPL)
12
+// as published by the Free Software Foundation; either version 2
13
+// of the License, or (at your option) any later version.
14
+//
15
+// This program is distributed in the hope that it will be useful,
16
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
+// GNU General Public License for more details.
19
+//
20
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
21
+// ----------------------------------------------------------------------
22
+
23
+//Begin basic page setup
24
+
25
+$current = "reviews";
26
+include ("header.php");
27
+
28
+//make a new TemplatePower object
29
+if(file_exists("$skindir/reviews.tpl")) $tpl = new TemplatePower( "$skindir/reviews.tpl" );
30
+else $tpl = new TemplatePower("default_tpls/reviews.tpl");
31
+if(file_exists("$skindir/reviewblock.tpl")) $tpl->assignInclude("reviewsblock", "$skindir/reviewblock.tpl" );
32
+else $tpl->assignInclude("reviewsblock", "default_tpls/reviewblock.tpl");
33
+$tpl->assignInclude( "header", "./$skindir/header.tpl" );
34
+$tpl->assignInclude( "footer", "./$skindir/footer.tpl" );
35
+
36
+//let TemplatePower do its thing, parsing etc.
37
+$tpl->prepare();
38
+
39
+include("includes/pagesetup.php");
40
+
41
+$reviewid = isset($_REQUEST['reviewid']) ? $_REQUEST['reviewid'] : false;
42
+if(!isNumber($reviewid)) unset($reviewid);
43
+$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : false;
44
+$item = isset($_REQUEST['item']) ? $_REQUEST['item'] : false;
45
+if(!isNumber($item)) unset($item);
46
+
47
+if($action == "delete") {
48
+	if(isADMIN && uLEVEL <= 3) $notauthor = 1;
49
+	$query = dbquery("SELECT item, chapid, type, review, rating, uid FROM ".TABLEPREFIX."fanfiction_reviews WHERE reviewid = '$reviewid' LIMIT 1");
50
+	list($item, $chapid, $type, $review, $rating, $reviewuid) = dbrow($query);
51
+	if($reviewuid == USERUID) $notauthor = 1;
52
+	if($type == "SE") $query2 = "SELECT uid FROM ".TABLEPREFIX."fanfiction_series WHERE seriesid = '$item' LIMIT 1";
53
+	if($type == "ST") $query2 = "SELECT uid FROM ".TABLEPREFIX."fanfiction_stories WHERE sid = '$item' LIMIT 1";
54
+	else {
55
+		$revauthor = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'revauthor'");
56
+		while($code = dbassoc($revauthor)) {
57
+			eval($code['code_text']);
58
+		}
59
+	}
60
+	$authorquery = dbquery($query2);
61
+	list($author) = dbrow($authorquery);
62
+	if($author != USERUID && !$notauthor && ($revdelete < 2 || ($revdelete == 1 && $reviewuid))) accessDenied( );
63
+	$delete = isset($_GET['delete']) ? $_GET['delete'] : false;
64
+	$output .= "<div id=\"pagetitle\">"._DELETEREVIEW."</div>";
65
+	if($delete == "yes") {
66
+		if($type == "ST") {
67
+			$query = dbquery("SELECT uid FROM ".TABLEPREFIX."fanfiction_stories WHERE sid = $item LIMIT 1");
68
+			
69
+			list($author) = dbrow($query);
70
+			if($review != "No Review") {
71
+				dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET reviews = (reviews - 1) WHERE sid = '$item'");
72
+				dbquery("UPDATE ".TABLEPREFIX."fanfiction_chapters SET reviews = (reviews - 1) WHERE chapid = '$chapid'");
73
+			}
74
+			$count =  dbquery("SELECT AVG(rating) as totalcount FROM ".TABLEPREFIX."fanfiction_reviews WHERE item = '$item' AND type='ST' AND rating != '-1'");
75
+			list($totalcount) = dbrow($count);
76
+			if($totalcount) dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET rating = '".round($totalcount)."' WHERE sid = '$item'");
77
+			$count2 =  dbquery("SELECT AVG(rating) as totalcount FROM ".TABLEPREFIX."fanfiction_reviews WHERE chapid = '$chapid' AND rating != '-1'");
78
+			list($totalcount) = dbrow($count2);
79
+			if($totalcount) dbquery("UPDATE ".TABLEPREFIX."fanfiction_chapters SET rating = '".round($totalcount)."' WHERE chapid = '$chapid'");
80
+			$series = dbquery("SELECT seriesid FROM ".TABLEPREFIX."fanfiction_inseries WHERE sid = '$item'");
81
+			if(dbnumrows($series)) {
82
+				while($thisseries = dbassoc($series)) {
83
+					seriesreview($thisseries);
84
+				}
85
+			}
86
+		}
87
+		if($type == "SE") {
88
+			if($review != "No Review") dbquery("UPDATE ".TABLEPREFIX."fanfiction_series SET reviews = (reviews - 1) WHERE seriesid = '$item'");
89
+			seriesreview($item);
90
+		}
91
+		else {
92
+			$revdelete = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'revdelete'");
93
+			while($code = dbassoc($revdelete)) {
94
+				eval($code['code_text']);
95
+			}
96
+		}
97
+		if($review != "No Review") {
98
+			dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET reviews = reviews - 1");
99
+			list($count) = dbrow(dbquery("SELECT COUNT(DISTINCT uid) FROM ".TABLEPREFIX."fanfiction_reviews WHERE review != 'No Review' AND uid != 0"));
100
+			dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET reviewers = '$count'");
101
+		}
102
+		dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_reviews WHERE reviewid = '$reviewid'");
103
+		
104
+		$output .= write_message(_ACTIONSUCCESSFUL.(isset($back) ? $back : ""));
105
+	}
106
+	else if ($delete == "no") {
107
+		$output .= write_message(_ACTIONCANCELLED);
108
+	}
109
+	else {
110
+		$output .= write_message(_CONFIRMDELETE."<BR><BR>
111
+			[ <a href=\"reviews.php?action=delete&amp;delete=yes&amp;reviewid=$reviewid\">"._YES."</a> | <a href=\"reviews.php?action=delete&amp;delete=no&amp;reviewid=$reviewid\">"._NO."</a> ]");
112
+	}
113
+}
114
+else if($action == "edit" || $action == "add") {
115
+	if(isset($_GET['next']) && isNumber($_GET['next'])) $nextchapter = $_GET['next'];
116
+	if(!isMEMBER && !$anonreviews) accessDenied( );
117
+	if(!isset($chapid) && $type == "ST") { 
118
+		$chapquery = dbquery("SELECT chapid FROM ".TABLEPREFIX."fanfiction_chapters WHERE sid = '$item' AND inorder = '1' LIMIT 1");
119
+		list($chapid) = dbrow($chapquery);
120
+	}
121
+	$tpl->assign("pagetitle", "<div id =\"pagetitle\">"._REVIEW."</div>");
122
+	if(isset($_POST['submit'])) {
123
+		$reviewer = isset($_POST['reviewer']) ? escapestring(descript(strip_tags($_POST['reviewer'], $allowed_tags))) : "";
124
+		$review = format_story(strip_tags(descript($_POST['review']), $allowed_tags));
125
+		$review = escapestring($review);
126
+		$rating = isset($_POST['rating']) && isNumber($_POST['rating']) ? $_POST['rating'] : -1;
127
+		if(!$review) $review = "No Review";
128
+		if(!$reviewer && $action != "edit") $reviewer = _ANONYMOUS;
129
+		if(isMEMBER) $reviewer = USERPENNAME;
130
+		if(!$rateonly && $review == "No Review") $output .= write_error(_MISSINGINFO2);
131
+		else if($captcha && !isMEMBER && !captcha_confirm()) $output .= write_error(_CAPTCHAFAIL);
132
+		else if($review == "No Review" && $_POST['rating'] == "-1") $output .= write_error(_MISSINGINFO);
133
+		else if(find_naughty($reviewer)) $output .= write_error(_NAUGHTYWORDS);
134
+		else if($action == "add" && (!$type || !$item)) $output .= write_error(_ERROR);
135
+		else {
136
+			$output .= write_message(_REVTHANKYOU);
137
+			if($action == "edit") {
138
+				$update = dbquery("UPDATE ".TABLEPREFIX."fanfiction_reviews SET review = '$review', rating = '$rating' WHERE reviewid = '$reviewid' LIMIT 1");
139
+				$info = dbquery("SELECT item, type, chapid FROM ".TABLEPREFIX."fanfiction_reviews WHERE reviewid = '$reviewid' LIMIT 1");
140
+				list($item, $type, $chapid) = dbrow($info);
141
+			}
142
+			else if($type == "ST") {
143
+				if(isset($_POST['chapid']) && isNumber($_POST['chapid'])) $chapid = $_POST['chapid'];
144
+				dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_reviews (item, type, reviewer, review, rating, date, uid, chapid) VALUES ('$item', 'ST', '$reviewer', '$review', '$rating', now(), '".(USERUID && isNumber(USERUID) ? USERUID : 0)."', '$chapid')");
145
+				$count =  dbquery("SELECT AVG(rating) as totalcount FROM ".TABLEPREFIX."fanfiction_reviews WHERE item = '$item' AND type = 'ST' AND rating != '-1'");
146
+				list($totalcount) = dbrow($count);
147
+				if($totalcount) $update = dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET rating = '".round($totalcount)."' WHERE sid = '$item'");
148
+				unset($totalcount);
149
+				$count2 = dbquery("SELECT AVG(rating) as totalcount FROM ".TABLEPREFIX."fanfiction_reviews WHERE chapid = '$chapid' AND rating != '-1'");
150
+				list($totalcount) = dbrow($count2);
151
+				if($totalcount) $update = dbquery("UPDATE ".TABLEPREFIX."fanfiction_chapters SET rating = '".round($totalcount)."' WHERE chapid = '$chapid'");
152
+				if($review != "No Review") {
153
+					dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET reviews = (reviews + 1) WHERE sid = '$item'");
154
+					dbquery("UPDATE ".TABLEPREFIX."fanfiction_chapters SET reviews = (reviews + 1) WHERE chapid = '$chapid'");
155
+				}
156
+				$series = dbquery("SELECT seriesid FROM ".TABLEPREFIX."fanfiction_inseries WHERE sid = '$item'");
157
+				if(dbnumrows($series)) {
158
+					while($s = dbassoc($series)) {
159
+						seriesreview($s['seriesid']);
160
+					}
161
+				}
162
+				$output .= write_message("<a href=\"viewstory.php?sid=$item".(isset($_GET['next']) ? "&amp;chapter=".$_GET['next'] : "")."\">"._BACKTOSTORY."</a></center>");
163
+
164
+				$uidquery = dbquery("SELECT uid,title, coauthors FROM ".TABLEPREFIX."fanfiction_stories WHERE sid = '$item'");
165
+				list($author, $title, $coauthors) = dbrow($uidquery);
166
+				if($coauthors) {
167
+					$coauthors = array( );
168
+					$coQuery = dbquery("SELECT uid FROM ".TABLEPREFIX."fanfiction_coauthors WHERE sid = '$item'");
169
+					while($c = dbassoc($coQuery)) {
170
+						$coauthors[] = $c['uid'];
171
+					}
172
+				}
173
+			}
174
+			else if($type == "SE"){
175
+				dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_reviews (item, type, reviewer, review, rating, date, uid) VALUES ('$item', 'SE', '$reviewer', '$review', '$rating', now(), '".(USERUID && isNumber(USERUID) ? USERUID : 0)."')");
176
+				$thisseries = $item;
177
+				seriesreview($item);
178
+				$uidquery = dbquery("SELECT uid as uid,title FROM ".TABLEPREFIX."fanfiction_series WHERE seriesid = '$item'");
179
+				list($author, $title) = dbrow($uidquery);
180
+
181
+			}
182
+			else {
183
+				$revadd = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'revadd'");
184
+				while($code = dbassoc($revadd)) {
185
+					eval($code['code_text']);
186
+				}
187
+			}
188
+			if($review != "No Review" && $action == "add") {
189
+				$mailquery= dbquery("SELECT ap.newreviews,"._EMAILFIELD." as email, "._PENNAMEFIELD." as penname FROM "._AUTHORTABLE." LEFT JOIN ".TABLEPREFIX."fanfiction_authorprefs as ap ON ap.uid = "._UIDFIELD." WHERE "._UIDFIELD." = '$author' ".(!empty($coauthors) ? " OR ".findclause(_UIDFIELD, $coauthors) : ""));
190
+				while($mail = dbassoc($mailquery)) {
191
+					if($mail['newreviews']) {
192
+						include_once("includes/emailer.php");
193
+						$subject = _REVEMAIL1.$title;
194
+						$mailtext = sprintf(_REVEMAIL2, "type=$type&amp;item=$item");
195
+						$result = sendemail($mail['penname'], $mail['email'], $sitename, $siteemail, $subject, $mailtext, "html");
196
+					}
197
+				}
198
+				dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET reviews = reviews + 1");
199
+				list($count) = dbrow(dbquery("SELECT COUNT(DISTINCT uid) FROM ".TABLEPREFIX."fanfiction_reviews WHERE review != 'No Review' AND uid != 0"));
200
+				dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET reviewers = '$count'");
201
+			}
202
+			if($logging && !USERUID) {
203
+				if($type == "ST") {
204
+					$storyquery = dbquery("SELECT s.title, s.uid, s.rid, s.sid FROM ".TABLEPREFIX."fanfiction_stories as s WHERE s.sid = '$item' LIMIT 1");
205
+					$story = dbassoc($storyquery);
206
+					$title = "<a href=\"viewstory.php?sid=$item\">".stripslashes($story['title'])."</a>";
207
+					$authoruid = $story['uid'];
208
+				}
209
+				else if($type == "SE") {
210
+					$storyquery = dbquery("SELECT title, uid FROM ".TABLEPREFIX."fanfiction_series WHERE seriesid = '$item' LIMIT 1");
211
+					list($title, $authoruid) = dbrow($storyquery);
212
+					$titletext = $title;
213
+					$title = "<a href=\"viewseries.php?seriesid=$item\">".stripslashes($title)."</a>";	
214
+				}
215
+				else { 
216
+					$titlequery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'revtitle'");
217
+					while($code = dbassoc($titlequery)) {
218
+						eval($code['code_text']);
219
+					}
220
+				}
221
+				$reviewname = $reviewer."(".$_SERVER['REMOTE_ADDR'].")";
222
+				if($action == "add") dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`) VALUES('".escapestring(sprintf(_LOG_REVIEW, $reviewname, truncate_text($review), $title))."', '0', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'RE')");
223
+				else dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`) VALUES('".escapestring(sprintf(_LOG_EDIT_REVIEW, USERPENNAME, USERUID, $title, $reviewid))."', '0', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'RE')");
224
+			}
225
+		}
226
+	}
227
+	else {
228
+		if(!$anonreviews && !USERPENNAME) accessDenied( );
229
+		else {
230
+			if($action == "edit") {
231
+				$result = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_reviews WHERE reviewid = '$reviewid' LIMIT 1");
232
+				$review = dbassoc($result);
233
+			}
234
+			include("includes/reviewform.php");
235
+			$output .= $form;
236
+		}
237
+	}
238
+}
239
+else {
240
+	$query = "";
241
+	if(empty($reviewid) && empty($type)) accessDenied( );
242
+	if(!empty($reviewid) && empty($type)) {
243
+		list($type, $item) = dbrow(dbquery("SELECT type, item FROM ".TABLEPREFIX."fanfiction_reviews WHERE reviewid = '$reviewid' LIMIT 1"));
244
+	}
245
+	if($type == "ST") {
246
+		$storyquery = dbquery("SELECT s.title, s.uid, s.rid, s.sid, s.coauthors FROM ".TABLEPREFIX."fanfiction_stories as s WHERE s.sid = '$item' LIMIT 1");
247
+		$story = dbassoc($storyquery);
248
+		$title = title_link($story);
249
+		$authoruid = $story['uid'];
250
+		if(!empty($story['coauthors'])) {
251
+			$colist = dbquery("SELECT uid FROM ".TABLEPREFIX."fanfiction_coauthors WHERE sid = '$item'");
252
+			while($c = dbassoc($colist)) {
253
+				$coauthors[] = $c['uid'];
254
+			}
255
+		}
256
+	}
257
+	else if($type == "SE") {
258
+		$storyquery = dbquery("SELECT title, uid FROM ".TABLEPREFIX."fanfiction_series WHERE seriesid = '$item' LIMIT 1");
259
+		list($title, $authoruid) = dbrow($storyquery);
260
+		$titletext = $title;
261
+		$title = "<a href=\"series.php?seriesid=$item\">".stripslashes($title)."</a>";
262
+	}
263
+	else { 
264
+		$titlequery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'revtitle'");
265
+		while($code = dbassoc($titlequery)) {
266
+			eval($code['code_text']);
267
+		}
268
+	}
269
+	$tpl->assign("pagetitle", "<div id=\"pagetitle\">"._REVIEWSFOR." $title</div>");
270
+	if($type == "SE") {
271
+		$jumpmenu = "";
272
+		$stinseries = dbquery("SELECT sid, subseriesid, inorder FROM ".TABLEPREFIX."fanfiction_inseries WHERE seriesid = '$item'");
273
+		$scount = dbnumrows($stinseries);
274
+		if($scount) {
275
+			$subs = array( );
276
+			$stories = array( );
277
+			while($i = dbassoc($stinseries)) {
278
+				if($i['subseriesid']) {
279
+					$subs[$i['inorder']] = $i['subseriesid'];
280
+					$serieslist[] = $i['subseriesid'];
281
+				}
282
+				else {
283
+					$stories[$i['inorder']] = $i['sid'];
284
+					$storieslist[] = $i['sid'];
285
+				}
286
+			}
287
+			if(count($subs) > 0) {
288
+				$subsquery = dbquery(_SERIESQUERY." AND FIND_IN_SET(seriesid, '".implode(",", $subs)."') > 0");
289
+				while($sub = dbassoc($subsquery)) {
290
+					$inlist[array_search($sub['seriesid'], $subs)] = $sub;
291
+				}
292
+			}
293
+			if(count($stories)) {
294
+				$seriesstoryquery = dbquery(_STORYQUERY." AND FIND_IN_SET(sid, '".implode(",", $stories)."') > 0");
295
+				while($story = dbassoc($seriesstoryquery)) {
296
+					$inlist[array_search($story['sid'], $stories)] = $story;
297
+				}
298
+			}
299
+			if(is_array($inlist)) ksort($inlist);
300
+			$jumpmenu = "<form name=\"jump\" action=\"\">";
301
+			$jumpmenu .= "<select name=\"sid\" onChange=\"if (this.selectedIndex >0) window.location=this.options[this.selectedIndex].value\">";
302
+			$jumpmenu .= "<option value=\"reviews.php?type=SE&amp;item=$item\">"._VIEWALLREVIEWS."</option>";
303
+			foreach($inlist as $x => $st) {
304
+				$jumpmenu .= "<option value=\"reviews.php?type=".(isset($st['sid']) ? "ST&amp;item=".$st['sid'] : "SE&amp;item=".$st['seriesid'])."\">"._REVIEWSFOR." ".$st['title']."</option>";
305
+				if(!empty($st['sid'])) $storylist[] = $st['sid'];
306
+				else if(!empty($st['subseriesid'])) $serieslist[] = $st['subseriesid'];
307
+			}
308
+			$jumpmenu .= "</select></form>";
309
+		}
310
+		$tpl->assign("jumpmenu", $jumpmenu );
311
+		$query = "SELECT review.reviewid, review.respond, review.review, review.uid, review.reviewer, review.rating, UNIX_TIMESTAMP(review.date) as date, series.title as seriestitle, stories.title as title FROM ".TABLEPREFIX."fanfiction_reviews as review LEFT JOIN ".TABLEPREFIX."fanfiction_series as series ON review.item = series.seriesid AND review.type = 'SE' LEFT JOIN ".TABLEPREFIX."fanfiction_stories as stories ON stories.sid = review.item AND review.type ='ST' WHERE 
312
+			((series.seriesid = '$item' AND series.seriesid = review.item AND review.type = 'SE')".
313
+			(isset($storylist) ? " OR (FIND_IN_SET(review.item, '".(implode(",", $storieslist))."') > 0 AND review.type = 'ST')" : "").
314
+			(isset($serieslist) ? " OR (FIND_IN_SET(item, '".(implode(",", $serieslist))."') > 0 AND type = 'SE')" : "").
315
+			") AND review.review != 'No Review'";
316
+		$count =  "SELECT count(reviewid) FROM ".TABLEPREFIX."fanfiction_reviews WHERE item = '$item' AND type = 'SE' AND review != 'No Review'";
317
+
318
+	}
319
+	else if($type == "ST") {
320
+		if(isset($chapid))  {
321
+			$query = "SELECT review.reviewid, review.respond, review.review, review.uid, review.reviewer, review.rating, UNIX_TIMESTAMP(date) as date, chapter.title as title, chapter.inorder as inorder FROM ".TABLEPREFIX."fanfiction_reviews as review, ".TABLEPREFIX."fanfiction_chapters as chapter WHERE chapter.chapid = '$chapid' AND chapter.chapid = review.chapid AND review.review != 'No Review' ";
322
+			$count =  "SELECT count(reviewid) FROM ".TABLEPREFIX."fanfiction_reviews as review WHERE chapid = '$chapid' AND review != 'No Review'";
323
+		}
324
+		else  {
325
+			$query = "SELECT review.reviewid, review.respond, review.review, review.uid, review.reviewer, review.rating, UNIX_TIMESTAMP(review.date) as date, chapter.title as title, chapter.inorder as inorder FROM ".TABLEPREFIX."fanfiction_reviews as review, ".TABLEPREFIX."fanfiction_chapters as chapter WHERE chapter.sid = '$item' AND chapter.chapid = review.chapid AND review.review != 'No Review' AND review.type = 'ST'";
326
+			$count = "SELECT count(reviewid) FROM ".TABLEPREFIX."fanfiction_reviews as review WHERE item = '$item' AND review != 'No Review' AND type = 'ST'";
327
+		}
328
+		$jumpmenu = "<form name=\"jump\" action=\"\">";
329
+		$jumpmenu .= "<select name=\"sid\" onChange=\"window.location=this.options[this.selectedIndex].value\">";
330
+		$jumpmenu .= "<option value=\"reviews.php?type=ST&amp;item=".$story['sid'].(isset($_GET['unresponded']) ? "&amp;unresponded=1" : "")."\"";
331
+		if(!isset($chapid))
332
+			$jumpmenu .= " selected";
333
+		$jumpmenu .= ">"._VIEWALLREVIEWS."</option>";
334
+		$chapquery = dbquery("SELECT inorder, title, chapid, sid FROM ".TABLEPREFIX."fanfiction_chapters WHERE sid = '".$story['sid']."' ORDER BY inorder ASC");
335
+		while($chapters = dbassoc($chapquery)) {
336
+			$jumpmenu .= "<option value=\"reviews.php?chapid=".$chapters['chapid'].(isset($_GET['unresponded']) ? "&amp;unresponded=1" : "")."&amp;type=ST&amp;item=$item\"";
337
+	
338
+			if(isset($chapid) && $chapid == $chapters['chapid'])
339
+				$jumpmenu .= " selected";
340
+
341
+			$jumpmenu .= ">"._REVIEWSFOR." ".$chapters['inorder'].". ".$chapters['title']."</option>\n";
342
+		}
343
+		$jumpmenu .= "</select></form>";
344
+
345
+		$tpl->assign("jumpmenu", $jumpmenu );
346
+	}
347
+	else {
348
+		$reviewquery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'revqueries'");
349
+		while($code = dbassoc($reviewquery)) {
350
+			eval($code['code_text']);
351
+		}
352
+	}
353
+	if(isset($_GET['unresponded'])) {
354
+		$query .= "AND review.respond = '0' ";
355
+		$count .= "AND review.respond = '0' ";
356
+	}
357
+	if(!empty($reviewid)) {
358
+		$query .= " AND review.reviewid = '$reviewid' ";
359
+		$count .= " AND review.reviewid = '$reviewid' ";
360
+	}
361
+	$query .= "ORDER BY review.reviewid DESC LIMIT $offset,$itemsperpage";
362
+	$query = dbquery($query);
363
+	$count = dbquery($count);
364
+
365
+	list($numrows)= dbrow($count);
366
+	$counter = 0;
367
+	while($reviews = dbassoc($query))
368
+	{
369
+		$adminlink = "";
370
+		if(isADMIN && uLEVEL < 4) $adminlink = "<span class='label'>"._ADMINOPTIONS.": </span> [<a href=\"reviews.php?action=edit&amp;reviewid=".$reviews['reviewid']."\">"._EDIT."</a>]";
371
+		if( (isADMIN && uLEVEL < 4) || (USERUID && USERUID == $reviews['uid'])) $adminlink .= " [<a href=\"reviews.php?action=delete&amp;reviewid=".$reviews['reviewid']."\">"._DELETE."</a>]";
372
+		if($reviews['uid']) {
373
+			if(USERUID == $authoruid && $revdelete == 2 && !isADMIN) $adminlink .= " [<a href=\"reviews.php?action=delete&amp;reviewid=".$reviews['reviewid']."\">"._DELETE."</a>]";
374
+			$reviewer = "<a href=\"viewuser.php?uid=".$reviews['uid']."\">".$reviews['reviewer']."</a>";
375
+			$member = _SIGNED;
376
+		}
377
+		else {
378
+			if(USERUID == $authoruid && $revdelete && !isADMIN) $adminlink .= " [<a href=\"reviews.php?action=delete&amp;reviewid=".$reviews['reviewid']."\">"._DELETE."</a>]";
379
+			$reviewer = $reviews['reviewer'];
380
+			$member = _ANONYMOUS;
381
+		}
382
+		if(empty($reviews['respond']) && (USERUID == $authoruid || (isset($coauthors) && in_array(USERUID, $coauthors)))) $adminlink .= " [<a href=\"user.php?action=revres&amp;reviewid=".$reviews['reviewid']."\">"._RESPOND."</a>]";
383
+		$tpl->newBlock("reviewsblock");
384
+		$tpl->assign("reviewer"   , $reviewer );
385
+		$tpl->assign("reportthis", "[<a href=\""._BASEDIR."contact.php?action=report&amp;url=reviews.php?reviewid=".$reviews['reviewid']."\">"._REPORTTHIS."</a>]");
386
+		$tpl->assign("review"   , stripslashes($reviews['review']));
387
+		$tpl->assign("reviewdate", date("$dateformat $timeformat", $reviews['date']) );
388
+		$tpl->assign("rating", ratingpics($reviews['rating']) );
389
+		$tpl->assign("member", $member );
390
+		$tpl->assign("chapter", (!empty($reviews['title']) ? stripslashes($reviews['title']) : (!empty($reviews['seriestitle']) ? stripslashes($reviews['seriestitle']) : _NONE)) );
391
+		if(isset($reviews['inorder'])) $tpl->assign("chapternumber", $reviews['inorder'] );
392
+		if(!empty($adminlink)) $tpl->assign("adminoptions", "<div class=\"adminoptions\">$adminlink</div>");
393
+		$tpl->assign("oddeven", ($counter % 2 ? "odd" : "even"));
394
+		$counter++;
395
+	}
396
+	$tpl->gotoBlock( "_ROOT" );
397
+
398
+	if ($numrows > $itemsperpage) 
399
+		$tpl->assign("reviewpagelinks", build_pagelinks("reviews.php?type=$type&amp;item=$item&amp;".(!empty($chapid) ? "chapid=$chapid&amp;" : "").(isset($_GET['unresponded']) ? "unresponded=1&amp;" : ""), $numrows, $offset));
400
+	else if($numrows == 0) $tpl->assign("reviewpagelinks", write_message(_NORESULTS));
401
+	if(isMEMBER || $anonreviews)
402
+		$reviewslink = "<a href=\"reviews.php?action=add&amp;type=$type&amp;item=$item".(isset($chapid) ? "&amp;chapid=".$chapid : "")."\">"._SUBMITREVIEW."</a>";
403
+	else
404
+		$reviewslink = write_message(sprintf(_LOGINTOREVIEW, strtolower($pagelinks['login']['link']), strtolower($pagelinks['register']['link'])));
405
+	$tpl->assign("reviewslink", $reviewslink);
406
+	$form = "";
407
+	if($reviewsallowed) {
408
+		if(isMEMBER || $anonreviews) {
409
+			$item = $item;
410
+			$type = $type;
411
+			include("includes/reviewform.php");
412
+		}
413
+		else $form = write_message(sprintf(_LOGINTOREVIEW, strtolower($pagelinks['login']['link']), strtolower($pagelinks['register']['link'])));
414
+	}
415
+	$tpl->assign("reviewform", $form);
416
+
417
+}
418
+$tpl->assign("output", $output);
419
+$tpl->printToScreen( );
420
+?>
0 421
\ No newline at end of file