Browse code

fix for hardcoded fields - fix for selecting other author in Add to serie

Jimmi08 authored on 2020/07/20 11:47:11
Showing 1 changed files
... ...
@@ -258,8 +258,8 @@ if($add == "stories") {
258 258
 		list($title, $owner) = dbrow($series);	
259 259
 		$output .= "<div class='sectionheader'>"._SERIES.": ".stripslashes($title)."</div>";
260 260
 		if(($admin || USERUID == $owner ) && isset($_GET['stories']) && $_GET['stories'] == "others") {
261
-			if($let == _OTHER) $letter= "author.penname REGEXP '^[^a-z]'";
262
-			else $letter = "author.penname LIKE '$let%'";
261
+			if($let == _OTHER) $letter= _PENNAMEFIELD." REGEXP '^[^a-z]'";
262
+			else $letter = _PENNAMEFIELD." LIKE '$let%'";
263 263
 			$pagelink = "series.php?action=$action&amp;add=stories&amp;stories=others&amp;seriesid=$seriesid&amp;";
264 264
 			$authorlink = "<a href=\"series.php?action=$action&amp;add=stories&amp;seriesid=$seriesid&amp;stories=";
265 265
 			$countquery = _MEMBERCOUNT." WHERE ap.stories > 0".(isset($letter) ? " AND $letter" : "");
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,378 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// Copyright (c) 2005-07 by Tammy Keefer
4
+// Valid HTML 4.01 Transitional 
5
+// Based on eFiction 1.1
6
+// Copyright (C) 2003 by Rebecca Smallwood.
7
+// http://efiction.sourceforge.net/
8
+// ----------------------------------------------------------------------
9
+// LICENSE
10
+//
11
+// This program is free software; you can redistribute it and/or
12
+// modify it under the terms of the GNU General Public License (GPL)
13
+// as published by the Free Software Foundation; either version 2
14
+// of the License, or (at your option) any later version.
15
+//
16
+// This program is distributed in the hope that it will be useful,
17
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
+// GNU General Public License for more details.
20
+//
21
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
22
+// ----------------------------------------------------------------------
23
+
24
+//Begin basic page setup
25
+$current = "series";
26
+if($_GET['action'] == "add" || $_GET['action'] == "edit") $displayform = 1;
27
+
28
+include ("header.php");
29
+//make a new TemplatePower object
30
+if(file_exists("$skindir/default.tpl")) $tpl = new TemplatePower( "$skindir/default.tpl" );
31
+else $tpl = new TemplatePower("default_tpls/default.tpl");
32
+if(file_exists("$skindir/listings.tpl")) $tpl->assignInclude( "listings", "./$skindir/listings.tpl" );
33
+else $tpl->assignInclude( "listings", "./default_tpls/listings.tpl" );
34
+$tpl->assignInclude( "header", "./$skindir/header.tpl" );
35
+$tpl->assignInclude( "footer", "./$skindir/footer.tpl" );
36
+
37
+include("includes/pagesetup.php");
38
+$seriesid = isset($_GET['seriesid']) && isNumber($_GET['seriesid']) ? $_GET['seriesid'] : false;
39
+$showlist = true;
40
+$inorder = isset($_GET['inorder']) && isNumber($_GET['inorder']) ? $_GET['inorder'] : false;
41
+$add = isset($_GET['add']) ? $_GET['add'] : false;
42
+
43
+// before doing anything else check if the visitor is logged in.  If they are, check if they're an admin.  If not, check that they're 
44
+// trying to edit/delete/etc. their own stuff then get the penname 
45
+if(!isMEMBER) accessDenied( );
46
+
47
+if(isADMIN && uLEVEL < 3) $admin = 1;
48
+else $admin = 0;
49
+if(isADMIN && uLEVEL == 3) {
50
+	list($admincats) = dbrow(dbquery("SELECT categories FROM ".TABLEPREFIX."fanfiction_authorprefs WHERE uid = '".USERUID."'"));
51
+	if(isset($seriesid)) {
52
+		$series = dbquery("SELECT uid, isopen, catid from ".TABLEPREFIX."fanfiction_series WHERE seriesid='$seriesid' LIMIT 1");
53
+		list($owner, $seriesopen, $catid) = dbrow($series);
54
+		if(uLEVEL == 3 && $admincats != 0) {
55
+			$seriescats = explode(",", $catid);
56
+			$adcats = explode(",", $admincats);
57
+			foreach($seriescats as $cat) {
58
+				if(in_array($cat, $adcats)) $admin = 1;
59
+			}
60
+		}
61
+	}
62
+}
63
+if(!$allowseries && !$admin) accessDenied( );
64
+if($allowseries == 1 && !$admin) {
65
+	list($count) = dbrow(dbquery("SELECT COUNT(sid) FROM ".TABLEPREFIX."fanfiction_stories WHERE uid = '".USERUID."'"));
66
+	if($count == 0) accessDenied( );
67
+}
68
+
69
+if($action == "validate") {
70
+	$inorder = isset($_GET['inorder']) && isNumber($_GET['inorder']) ? $_GET['inorder'] : 0;
71
+	$valid = dbquery("UPDATE ".TABLEPREFIX."fanfiction_inseries SET confirmed = 1 WHERE seriesid = '$seriesid' AND inorder = '$inorder' LIMIT 1");
72
+	if($valid) {
73
+		$output .= write_message(_ACTIONSUCCESSFUL);
74
+		$showlist = true;
75
+	}
76
+}
77
+
78
+if($add == "series" || ($action == "add" && !$add) || $action == "edit") {
79
+	if(isset($_GET['cat']) && !empty($_GET['cat'])) $cat = $_GET['cat'];
80
+	else $cat = -1;
81
+	$isopen = isset($_GET['isopen']) ? $_GET['isopen'] : 0;
82
+
83
+	if(isset($_POST['submit'])) {
84
+		$title = addslashes(escapestring(strip_tags($_POST['title'], $allowed_tags)));
85
+		$summary = addslashes(escapestring(descript(strip_tags($_POST["summary"], $allowed_tags))));
86
+		$category = isset($_POST['catid']) ? explode(",", $_POST['catid']) : array();
87
+		$category = array_filter($category, "isNumber");
88
+		if($category) $category = implode(",", $category);
89
+		else $category = "";
90
+		$open = isset($_POST['open']) && isNumber($_POST['open']) ? $_POST['open'] : 0;
91
+		$characters = isset($_POST['charid']) ? $_POST['charid'] : array();
92
+		$characters = array_filter($characters, "isNumber");
93
+		if($characters) $charid = implode(",", $characters);
94
+		else $charid = "";
95
+		$classes = array( );
96
+		foreach($classtypelist as $type => $cinfo) {
97
+			if(isset($_POST["classes_".$type])) {
98
+				$opts = is_array($_POST["classes_".$type]) ? array_filter($_POST["classes_".$type], "isNumber") : array( );
99
+				$classes = array_merge($opts, $classes);
100
+			}
101
+		}
102
+		$classes = implode(",", $classes);
103
+		if(!empty($_POST['uid']) && isNumber($_POST['uid'])) $owner = $_POST['uid'];
104
+		else $owner = USERUID;
105
+		if($title == "" || $summary == "") {
106
+			$output .= write_error(_REQUIREDINFO);
107
+		}
108
+		else if(find_naughty($title) || find_naughty($summary)) {
109
+			$output .= write_error(_NAUGHTYWORDS);
110
+		}				
111
+		else {
112
+			$title = replace_naughty($title);
113
+			$summary = replace_naughty($summary);
114
+			if($action == "edit") {
115
+				$seriesid = $_POST['seriesid'];
116
+				dbquery("UPDATE ".TABLEPREFIX."fanfiction_series SET title = '$title', summary ='$summary', catid = '$category', isopen = '$open', characters = '$charid', classes = '$classes' WHERE seriesid = '$seriesid'");
117
+				$codequery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'editseries'");
118
+				while($code = dbassoc($codequery)) {
119
+					eval($code['code_text']);
120
+				}
121
+				if($logging && $admin) {
122
+					$seriesinfo = dbquery("SELECT title, uid FROM ".TABLEPREFIX."fanfiction_series WHERE seriesid = '$seriesid'");
123
+					list($title, $uid) = dbrow($seriesinfo);
124
+					if($uid != USERUID) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`) VALUES('".escapestring(sprintf(_LOG_ADMIN_EDIT_SERIES, USERPENNAME, USERUID, $title, $seriesid))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'ED')");
125
+				}
126
+				$output = write_message(_ACTIONSUCCESSFUL."<br />"._BACK2ACCT);
127
+			}
128
+			else {
129
+				dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_series (title, summary, catid, isopen, uid, characters, classes) VALUES('$title', '$summary', '$category', '$open', '$owner', '$charid', '$classes')");
130
+				$seriesid = dbinsertid();
131
+				dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET series = series + 1");
132
+				$codequery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'addseries'");
133
+				while($code = dbassoc($codequery)) {
134
+					eval($code['code_text']);
135
+				}
136
+				$add = "stories";
137
+				unset($_POST['submit']);
138
+			}
139
+		}
140
+	}
141
+	else {
142
+	$output = "<div id=\"pagetitle\">".($action == "edit" ? _EDITSERIES : $add == "stories" ? _ADD2SERIES : _ADDSERIES)."</div>
143
+<form METHOD=\"POST\" style='width: 90%; margin: 0 auto;' name=\"form\" action=\"series.php?action=$action&amp;add=".(!empty($add) ? $add : "series").(!empty($seriesid) ? "&amp;seriesid=$seriesid" : "")."\">";
144
+	if($action == "edit" && !isset($POST['submit'])) {
145
+		$seriesquery = dbquery(_SERIESQUERY." AND seriesid = '$seriesid' LIMIT 1");
146
+		$series = dbassoc($seriesquery);
147
+		$series = array_map("stripslashes", $series);
148
+		$owner = $series['uid'];
149
+		$output .= "<input type=\"hidden\" name=\"seriesid\" value=\"$seriesid\">";
150
+	}
151
+	else $series = array("uid" => 0, "title" => "", "summary" => "");
152
+	$output .= "<div>";
153
+	if($admin) {
154
+		$authorquery = dbquery("SELECT "._PENNAMEFIELD." as penname, "._UIDFIELD." as uid FROM "._AUTHORTABLE." ORDER BY penname");
155
+		$output .= "<label for=\"uid=\">"._AUTHOR.":</label> <select name=\"uid\" id=\"uid\">";
156
+		while($authorresult = dbassoc($authorquery)) {	
157
+			$output .= "<option value=\"".$authorresult['uid']."\"".((USERUID == $authorresult['uid'] && !$seriesid) || (is_array($series) && $series['uid'] == $authorresult['uid']) ? " selected" : "").">".$authorresult['penname']."</option>";
158
+		}
159
+		$output .= "</select><font color=\"red\">*</font><br />";
160
+	}
161
+	$output .= "<label for=\"title\">"._TITLE.":</label> <font color=\"red\">*</font> <input  type=\"text\" class=\"textbox=\" name=\"title\" id=\"title\" value=\"".(isset($series) ? htmlentities($series['title']) : "")."\"  maxlength=\"200\" size=\"60\"><input type=\"hidden\" value=\"".(isset($series) ? $series['uid'] : "")."\"><br />
162
+		<label for=\"summary\">"._SUMMARY.":</label><font color=\"red\">*</font><br /><textarea rows=\"6\" id=\"summary\" name=\"summary\" cols=\"58\">".(isset($series) ? $series['summary'] : "")."</textarea><br />";
163
+	if($tinyMCE) 
164
+		$output .= "<div class='tinytoggle'><input type='checkbox' name='toggle' onclick=\"toogleEditorMode('summary');\" checked><label for='toggle'>"._TINYMCETOGGLE."</label></div>";
165
+	if(!$multiplecats) $output .= "<input type=\"hidden\" name=\"catid[]\" id=\"catid\" value=\"1\">";
166
+	else {	
167
+		$catid = isset($series['catid']) ? explode(",", $series['catid']) : array( );
168
+		include("includes/categories.php");
169
+		$output .= "<input type=\"hidden\" name=\"formname\" value=\"series\">";
170
+	}
171
+	if(count($charlist) > 0) {
172
+		$output .= "<div style=\"float: left; width: 99%;\"><div style=\"float: left; padding: 5px; width: 47%;\"><label for=\"charid\">"._CHARACTERS.":</label> <br /><select size=\"5\" style=\"width: 99%;\" name=\"charid[]\" id=\"charid\" multiple>";
173
+		$chars = isset($series['characters']) ? explode(",", $series['characters']) : array( );
174
+		$catid[] = -1;
175
+		foreach($charlist as $char => $vars) {
176
+			if(is_array($catid) && in_array($vars['catid'], $catid)) $output .= "<option value=\"$char\"".(in_array($char, $chars) ? " selected" : "").">".$vars['name']."</option>";
177
+		}
178
+		$output .= "</select></div>";
179
+	}
180
+	$classes = isset($series['classes']) ? explode(",", $series['classes']) : array( );
181
+	foreach($classtypelist as $type => $typevars) {
182
+		$output .= "<div style=\"float: left; padding: 5px; width: 47%;\"><label for=\"classes_{$type}\">{$typevars['title']}:</label><br /><select size=\"5\" style=\"width: 99%;\" name=\"classes_{$type}[]\" id=\"$type\" multiple>";
183
+		foreach($classlist as $c => $vars) {
184
+			if($vars['type'] == $type) $output .= "<option value=\"$c\"".(in_array($c, $classes) ? " selected" : "").">".$vars['name']."</option>";
185
+		}
186
+		$output .= "</select></div>";
187
+	}
188
+	$isopen = isset($series['isopen']) ? $series['isopen'] : 0;
189
+	$output .= "<div style=\"clear:left;\">&nbsp;</div></div><label for=\"open\">"._SERIESTYPE.":</label> <select id=\"open\" name=\"open\">
190
+			<option value=\"2\"".($isopen == "2" ? " selected" : "").">"._OPEN."</option>
191
+			<option value=\"1\"".($isopen == "1" ? " selected" : "").">"._MODERATED."</option>
192
+			<option value=\"0\"".(!$isopen ? " selected" : "").">"._CLOSED."</option>
193
+		</select><div style=\"margin: 1em;\">"._OPENNOTE."</div>";
194
+	$codequery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'seriesform'");
195
+	while($code = dbassoc($codequery)) {
196
+		eval($code['code_text']);
197
+	}
198
+	$output .= "<div style=\"text-align: center;\"><input type=\"submit\" class=\"submit\" name=\"submit\" value=\""._SUBMIT."\"></div></div></form>";
199
+	if($action == "add") {
200
+		$output .= "<center>"._SERIESNOTE."</center>";
201
+		$showlist = false;
202
+	}
203
+}
204
+}
205
+if($add == "stories") {
206
+	if(isset($seriesid) && isset($_POST['submit'])) {
207
+		if(!$seriesid) accessDenied( );
208
+		list($owner, $isopen, $title) = dbrow(dbquery("SELECT uid, isopen, title FROM ".TABLEPREFIX."fanfiction_series WHERE seriesid = '$seriesid' LIMIT 1"));
209
+		$seriescount = dbquery("SELECT count(seriesid) FROM ".TABLEPREFIX."fanfiction_inseries WHERE seriesid = '$seriesid'");
210
+		list($count) = dbrow($seriescount);
211
+		$seriesitems = dbquery("SELECT sid, subseriesid FROM ".TABLEPREFIX."fanfiction_inseries WHERE seriesid = '$seriesid'");
212
+		while($item = dbassoc($seriesitems)) {
213
+			if($item['sid']) $items[] = $item['sid'];
214
+			if($item['subseriesid']) $subs[] = $item['subseriesid'];
215
+		}
216
+		if($admin || USERUID == $owner || $isopen == 2 ) $confirmed = 1;
217
+		else {
218
+			$confirmed = 0;
219
+			include("includes/emailer.php");
220
+			$seriesMail = sprintf(_NEWSERIESITEMS, stripslashes($title));
221
+			$subject = sprintf("_SERIESITEMSSUBS", stripslashes($title));
222
+			$mailInfo = dbassoc(dbquery("SELECT "._PENNAMEFIELD." as penname, "._EMAILFIELD." as email FROM "._AUTHORTABLE." WHERE "._UIDFIELD." = '$owner' LIMIT 1"));
223
+			sendemail($mailInfo['penname'], $mailInfo['email'], $sitename, $siteemail, $subject, $seriesMail, "html");
224
+		}
225
+		if(!empty($_POST["sid"])) {
226
+			foreach($_POST["sid"] as $story) {
227
+				if(!isNumber($story)) continue;
228
+				if(!isset($items) || !is_array($items) || !in_array($story, $items)) {
229
+					$count++;
230
+					$validate = dbquery("SELECT validated FROM ".TABLEPREFIX."fanfiction_stories WHERE sid = '$story' LIMIT 1");
231
+					list($valid) = dbrow($validate);
232
+					if($valid) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_inseries (seriesid, sid, inorder, confirmed) VALUES('$seriesid', '$story', '$count', '$confirmed')");
233
+				}
234
+			}
235
+		}
236
+		$seriescount = dbquery("SELECT count(seriesid) FROM ".TABLEPREFIX."fanfiction_inseries WHERE seriesid = '$seriesid'");
237
+		list($count) = dbrow($seriescount);
238
+		if(!empty($_POST["subseriesid"])) {
239
+			foreach($_POST["subseriesid"] as $subseries) {
240
+				if(!isNumber($subseries)) continue;
241
+				if(!isset($subs) || !in_array($subseries, $subs)) {
242
+					$count++;
243
+					dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_inseries (seriesid, subseriesid, inorder) VALUES('$seriesid', '$subseries', '$count')");
244
+				}
245
+			}
246
+		}
247
+		$numstories = count(storiesInSeries($seriesid));
248
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_series SET numstories = '$numstories' WHERE seriesid = $seriesid LIMIT 1");
249
+		seriesreview($seriesid);
250
+		$showlist = true;
251
+		$output .= write_message(_ACTIONSUCCESSFUL);
252
+	}
253
+	else {
254
+		$output = "<div id=\"pagetitle\">".($action == "edit" ? _EDITSERIES : $add == "stories" ? _ADD2SERIES : _ADDSERIES)."</div>
255
+			<form METHOD=\"POST\" style='width: 90%; margin: 0 auto;' name=\"form\" action=\"series.php?action=$action&amp;add=".(!empty($add) ? $add : "series").(!empty($seriesid) ? "&amp;seriesid=$seriesid" : "")."\">";
256
+		$output .= "<input type=\"hidden\" name=\"seriesid\" value=\"$seriesid\">";
257
+		$series = dbquery("SELECT title, uid, isopen FROM ".TABLEPREFIX."fanfiction_series WHERE seriesid = '$seriesid' LIMIT 1");
258
+		list($title, $owner) = dbrow($series);	
259
+		$output .= "<div class='sectionheader'>"._SERIES.": ".stripslashes($title)."</div>";
260
+		if(($admin || USERUID == $owner ) && isset($_GET['stories']) && $_GET['stories'] == "others") {
261
+			if($let == _OTHER) $letter= "author.penname REGEXP '^[^a-z]'";
262
+			else $letter = "author.penname LIKE '$let%'";
263
+			$pagelink = "series.php?action=$action&amp;add=stories&amp;stories=others&amp;seriesid=$seriesid&amp;";
264
+			$authorlink = "<a href=\"series.php?action=$action&amp;add=stories&amp;seriesid=$seriesid&amp;stories=";
265
+			$countquery = _MEMBERCOUNT." WHERE ap.stories > 0".(isset($letter) ? " AND $letter" : "");
266
+			$authorquery = _MEMBERLIST." WHERE ap.stories > 0".(isset($letter) ? " AND $letter" : "");
267
+			include("includes/members_list.php");
268
+			$showlist = false;
269
+		}
270
+		else {
271
+			$stories = dbquery("SELECT title, sid FROM ".TABLEPREFIX."fanfiction_stories WHERE validated > 0 AND uid = '".(isset($_GET["stories"]) && isNumber($_GET['stories']) ? $_GET["stories"] : USERUID)."' ORDER BY title ASC");
272
+			$seriesstories = dbquery("SELECT sid FROM ".TABLEPREFIX."fanfiction_inseries WHERE seriesid = '$seriesid'");
273
+			while($story = dbassoc($seriesstories)) {
274
+				$selectedstories["$story[sid]"] = 1;
275
+			}
276
+			if($admin || USERUID == $owner) $output .= "<div style=\"text-align: center;\"><a href=\"series.php?action=$action&amp;add=$add&amp;stories=others&amp;seriesid=$seriesid\">"._CHOOSEAUTHOR."</a></div>";
277
+			$output .= "<table style=\"width: 500px; margin: 0 auto;\" class=\"tblborder\"><tr><th class=\"tblborder\">"._STORIES."</th></tr>";
278
+			$numstories = 0;
279
+			while($story = dbassoc($stories)) {
280
+				if(!empty($selectedstories[$story['sid']])) continue;
281
+				$output .= "<tr><td><input type=\"checkbox\" class=\"checkbox\" value=\"".$story['sid']."\" name=\"sid[]\">".stripslashes($story['title'])."</td></tr>";
282
+				$numstories++;
283
+			}
284
+			if($numstories  == 0) $output .= "<tr><td align=\"center\">"._NORESULTS."</td></tr>";
285
+			$series2 = dbquery("SELECT title, seriesid FROM ".TABLEPREFIX."fanfiction_series WHERE uid = '".(isset($_GET['stories']) && isNumber($_GET['stories']) ? $_GET['stories'] : USERUID)."' ORDER BY title ASC");
286
+			$output .= "<tr><th class=\"tblborder\">"._SERIES."</th></tr>";
287
+			$numseries = 0;
288
+			while($series = dbassoc($series2)) {
289
+				if($series['seriesid'] != $seriesid) {
290
+					$output .= "<tr><td><input type=\"checkbox\" class=\"checkbox\" value=\"".$series['seriesid']."\" name=\"subseriesid[]\">".stripslashes($series['title'])."</td></tr>";
291
+					$numseries++;
292
+				}
293
+			}
294
+			if($numseries < 1) $output .= "<tr><td align=\"center\">"._NORESULTS."</td></tr>";
295
+			$output .="</table><p style=\"text-align: center;\">"._SERIESNOTE2."<br /><input type=\"submit\" class=\"button\" name=\"submit\" value=\"submit\"></p></form>";
296
+			$showlist = false;
297
+		}		
298
+	}
299
+}
300
+if($action == "delete") {
301
+	global $seriesid;
302
+
303
+	$confirmed = isset($_GET["confirmed"]) ? $_GET['confirmed'] : false;
304
+	$output = "<div id=\"pagetitle\">".(!empty($inorder) ? _REMOVEFROM : _DELETESERIES)."</div>";
305
+
306
+	if($confirmed == "no") {
307
+		$output .=  write_message(_ACTIONCANCELLED);
308
+	}
309
+	else if($confirmed == "yes" && $seriesid) {
310
+		if(!empty($inorder)) {
311
+			$info = dbquery("SELECT inorder, subseriesid, sid FROM ".TABLEPREFIX."fanfiction_inseries WHERE seriesid = '$seriesid' AND inorder = '$inorder' LIMIT 1");
312
+			list($inorder, $subseriesid, $sid) = dbrow($info);
313
+			$countquery = dbquery("SELECT count(seriesid) FROM ".TABLEPREFIX."fanfiction_inseries WHERE seriesid = '$seriesid'");
314
+			list($count) = dbrow($countquery);
315
+			dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_inseries WHERE seriesid = '$seriesid' AND ".($sid ? "sid = '$sid'" : "subseriesid = '$subseriesid'"). " LIMIT 1");
316
+			if($inorder < $count) dbquery("UPDATE ".TABLEPREFIX."fanfiction_inseries SET inorder = (inorder - 1) WHERE seriesid = '$seriesid' AND inorder > '$inorder'");
317
+			$output .= write_message(_ACTIONSUCCESSFUL);
318
+			$showlist = true;
319
+		}
320
+		else {
321
+
322
+			$seriesinfo = dbquery("SELECT title, uid FROM ".TABLEPREFIX."fanfiction_series WHERE seriesid = '$seriesid'");
323
+			list($title, $uid) = dbrow($seriesinfo);
324
+			include("includes/deletefunctions.php");
325
+			deleteSeries($seriesid);
326
+			$output .= write_message(_ACTIONSUCCESSFUL);
327
+			if($admin || USERUID == $uid) $showlist = true;
328
+			$seriesid = false;
329
+		}
330
+	}
331
+	else {
332
+		$output .= write_message((!empty($inorder) ? _CONFIRMREMOVE : _CONFIRMDELETE)."<br /><br />[ <a href=\"series.php?action=delete&amp;confirmed=yes&amp;seriesid=$seriesid".(!empty($inorder) ? "&amp;inorder=$inorder" : "")."\">"._YES."</a> | 
333
+			<a href=\"series.php?action=delete&amp;confirmed=no\">"._NO."</a> ]");
334
+		$showlist = false;
335
+	}
336
+}
337
+if($showlist) {
338
+	$go = isset($_GET['go']) ? $_GET['go'] : false;
339
+	if($go != "" && $seriesid != "") {
340
+		if(!empty($_GET['sid']) && isNumber($_GET['sid'])) $sid = $_GET["sid"];
341
+		if(!empty($_GET['subseriesid']) && isNumber($_GET['subseriesid'])) $subseriesid = $_GET["subseriesid"];
342
+		if(isset($inorder) && (isset($sid) || isset($subseriesid))) {
343
+			if($go == "up") $oneabove = $inorder - 1;
344
+			else $oneabove = $inorder + 1;
345
+			if($oneabove >= 1) {
346
+				dbquery("UPDATE ".TABLEPREFIX."fanfiction_inseries SET inorder = '$inorder' WHERE inorder = '$oneabove' AND seriesid = '$seriesid'");
347
+				dbquery("UPDATE ".TABLEPREFIX."fanfiction_inseries SET inorder = '$oneabove' WHERE ".(isset($sid) ? "sid = '$sid'" : "subseriesid = '$subseriesid'")." AND seriesid = '$seriesid'");	
348
+			}
349
+		}
350
+	}
351
+	if(empty($action) || $action == "manage") $output .= "<div id=\"pagetitle\">"._MANAGESERIES."</div>";
352
+	if($seriesid) {
353
+		list($owner, $isopen) = dbrow(dbquery("SELECT uid,isopen FROM ".TABLEPREFIX."fanfiction_series WHERE seriesid = '$seriesid' LIMIT 1"));
354
+		$result = dbquery("SELECT series.seriesid AS mainid, series.inorder, confirmed, series.sid, series.subseriesid, stories.title AS storytitle, sub.title AS subtitle FROM ".TABLEPREFIX."fanfiction_inseries AS series LEFT JOIN ".TABLEPREFIX."fanfiction_stories AS stories ON ( series.sid = stories.sid ) LEFT JOIN ".TABLEPREFIX."fanfiction_series AS sub ON ( sub.seriesid = series.subseriesid ) WHERE series.seriesid = '$seriesid' ORDER BY series.inorder");
355
+		$output .= "<table style=\"margin: 1em auto;\" cellpadding=\"0\" class=\"tblborder\">
356
+			<tr><th class=\"tblborder\">"._TITLE."</th><th class=\"tblborder\" width=\"26\">"._ORDER."</th><th class=\"tblborder\">"._OPTIONS."</th></tr>";
357
+		$rows = dbnumrows($result);
358
+		while($series = dbassoc($result)) {
359
+			$output .= "<tr><td class=\"tblborder\"><a href=\"".($series['subseriesid'] == 0 ? "viewstory.php?sid=".$series['sid']."\">".stripslashes($series['storytitle']) : "viewseries.php?seriesid=$series[subseriesid]\">".stripslashes($series['subtitle']))."</a></td>
360
+				<td class=\"tblborder\" align=\"center\">".($series['inorder'] == $rows ? "" : "<a href=\"series.php?action=manage&amp;go=down&amp;inorder=".$series['inorder']."&amp;".($series['sid'] ? "sid=".$series['sid'] : "subseriesid=".$series['subseriesid'])."&amp;seriesid=$seriesid\"><img src=\"images/arrowdown.gif\" align=\"right\" border=\"0\" width=\"13\" height=\"18\" alt=\""._DOWN."\"></a>").
361
+				($series['inorder'] == 1 ? "&nbsp;" : "<a href=\"series.php?action=manage&amp;go=up&amp;inorder=$series[inorder]&amp;".($series['sid'] ? "sid=".$series['sid'] : "subseriesid=".$series['subseriesid'])."&amp;seriesid=$seriesid\"><img src=\"images/arrowup.gif\" border=\"0\" width=\"13\" height=\"18\" align=\"left\" alt=\""._UP."\"></a>")."</td>
362
+				<td class=\"tblborder\">".($owner == USERUID || $admin ? "<a href=\"series.php?action=delete&amp;seriesid=$seriesid&amp;inorder=".$series['inorder']."\">"._REMOVE."</a>" : "&nbsp;").($isopen == 1 && empty($series['confirmed']) && USERUID == $owner ? " | <a href=\"series.php?action=validate&amp;seriesid=$seriesid&amp;inorder=".$series['inorder']."\">"._VALIDATE."</a>" : "")."</td></tr>";
363
+		}
364
+		$output .= "<tr><td colspan=\"3\" align=\"center\"><a href=\"series.php?action=add&amp;add=stories&amp;seriesid=$seriesid\">"._ADD2SERIES."</a></td></tr></table>";
365
+	}
366
+	else {
367
+		$result = dbquery("SELECT * from ".TABLEPREFIX."fanfiction_series WHERE uid = '".USERUID."' ORDER BY title");
368
+		$output .= "<table style=\"margin: 0 auto;\" cellpadding=\"0\" cellspacing=\"0\" class=\"tblborder\">
369
+			<tr><th class=\"tblborder\">"._TITLE."</th><th class=\"tblborder\">"._OPTIONS."</th></tr>";
370
+		while($series = dbassoc($result)) {
371
+			$output .= "<tr><td class=\"tblborder\"><a href=\"viewseries.php?seriesid=".$series['seriesid']."\">".stripslashes($series['title'])."</a></td><td class=\"tblborder\"><a href=\"series.php?action=add&amp;add=stories&amp;seriesid=".$series['seriesid']."\">"._ADD2SERIES."</a> | <a href=\"series.php?action=edit&amp;seriesid=$series[seriesid]\">"._EDIT."</a> | <a href=\"series.php?action=delete&amp;seriesid=$series[seriesid]\">"._DELETE."</a></td></tr>";
372
+		}
373
+		$output .= "<tr><td colspan='2' align='center' class=\"tblborder\"><a href='series.php?action=add'>"._ADDSERIES."</a></td></tr></table>";
374
+	}
375
+}
376
+$tpl->assign("output", $output);
377
+$tpl->printToScreen( );
378
+?>
0 379
\ No newline at end of file