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,235 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// eFiction 3.0
4
+// Copyright (c) 2007 by Tammy Keefer
5
+// Valid HTML 4.01 Transitional
6
+// Based on eFiction 1.1
7
+// Copyright (C) 2003 by Rebecca Smallwood.
8
+// http://efiction.sourceforge.net/
9
+// ----------------------------------------------------------------------
10
+// LICENSE
11
+//
12
+// This program is free software; you can redistribute it and/or
13
+// modify it under the terms of the GNU General Public License (GPL)
14
+// as published by the Free Software Foundation; either version 2
15
+// of the License, or (at your option) any later version.
16
+//
17
+// This program is distributed in the hope that it will be useful,
18
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+// GNU General Public License for more details.
21
+//
22
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
23
+// ----------------------------------------------------------------------
24
+
25
+if(!defined("_CHARSET")) exit( );
26
+
27
+function build_cat_row($thiscat, $thiscatinfo) {
28
+	global $catlist, $oddeven, $onpic, $down, $up;
29
+	$space = "";
30
+	if($thiscatinfo['leveldown'] % 2) $class = "odd";
31
+	else $class = "even";
32
+	for($count = 0; $count < $thiscatinfo['leveldown']; $count++) {
33
+		$space .= "&nbsp;&nbsp;&nbsp;";
34
+	}
35
+	$output = "<tr id='catid_".$thiscat."' ".($thiscatinfo['leveldown'] > 0 ? "style='display: none;'" : "")." class='$class'>\n\t<td class='tblborder'>".$space;
36
+	$subs = ""; $downlink = "&nbsp;"; $uplink = "&nbsp;";
37
+	$$thiscat = $catlist;
38
+	foreach($$thiscat as $cat => $catinfo) {
39
+		if($catinfo['pid'] == $thiscatinfo['pid'] && $thiscatinfo['order'] > $catinfo['order']) $uplink = "<a href=\"admin.php?action=categories&go=up&displayorder=".$thiscatinfo['order']."&parentcatid=".$thiscatinfo['pid']."\">$up</a>";
40
+		if($catinfo['pid'] == $thiscatinfo['pid'] && $thiscatinfo['order'] < $catinfo['order']) $downlink = "<a href=\"admin.php?action=categories&go=down&displayorder=".$thiscatinfo['order']."&parentcatid=".$thiscatinfo['pid']."\">$down</a>";
41
+		if($catinfo['pid'] == $thiscat) $subs .= build_cat_row($cat, $catinfo);
42
+	}
43
+	if($subs) $output .= "<img onclick=\"javascript:displayCatRows('$thiscat')\" name='c_$thiscat' alt='on' src='".($onpic ? $onpic : "images/row_on.gif")."'> ";
44
+	$output .= $thiscatinfo['name']."</td>\n
45
+	<td class='tblborder'>$downlink</td>\n
46
+	<td class='tblborder' width=\"13\">$uplink</td>\n
47
+	<td class='tblborder'><a href=\"admin.php?action=categories&cat=$thiscat\">"._EDIT."</a> | <a href=\"admin.php?action=categories&delete=$thiscat\">"._DELETE."</a> 
48
+			| <span class='label'>"._ADD.":</span> $space <a href=\"admin.php?action=categories&cat=new&subof=$thiscat\">"._SUBCATEGORY."</a>, <a href=\"admin.php?action=characters&do=addform&catid=$thiscat\">"._CHARACTERS."</a>,  <a href=\"admin.php?action=admins&category=$thiscat\">"._ADMINS."</a></td>\r\n</tr>$subs";
49
+	return $output;
50
+}
51
+
52
+function relevelcategory($cat, $leveldown) {
53
+	global $action;
54
+
55
+	$subs = dbquery("SELECT catid FROM ".TABLEPREFIX."fanfiction_categories WHERE parentcatid = '$cat'");
56
+	if(dbnumrows($subs)) {
57
+		while($sub = dbassoc($subs)) {relevelcategory($sub[catid], $leveldown + 1); }
58
+	}
59
+	dbquery("UPDATE ".TABLEPREFIX."fanfiction_categories SET leveldown = $leveldown WHERE catid = '$cat'");
60
+}
61
+
62
+
63
+	$showlist = 1;
64
+	$output .= "<div id=\"pagetitle\">"._CATEGORIES." </div>";
65
+	if(isset($_GET['catcounts'])) 
66
+		$output .= catcounts( );
67
+	if(isset($_GET["delete"]) && isNumber($_GET["delete"])) {
68
+		$catid = $_GET["delete"];
69
+		$confirm = isset($_GET['confirm']) ? $_GET['confirm'] : false;
70
+		if($confirm == "yes") {
71
+			$result = dbquery("SELECT displayorder,leveldown, parentcatid FROM ".TABLEPREFIX."fanfiction_categories WHERE catid = '$catid'");
72
+			$cat = dbassoc($result);
73
+			dbquery("UPDATE ".TABLEPREFIX."fanfiction_categories SET displayorder = (displayorder - '1') WHERE displayorder > '$cat[displayorder]' AND parentcatid = '$cat[parentcatid]'");
74
+			dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_categories WHERE catid = '$catid'");
75
+			dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_categories WHERE parentcatid = '$catid'");
76
+			$stories = dbquery("SELECT title,sid, catid FROM ".TABLEPREFIX."fanfiction_stories WHERE FIND_IN_SET(catid, '$catid')");
77
+			while($story = dbassoc($stories)) {
78
+				$cats = explode(",", $story[catid]);
79
+				if(count($cats) == 1) $newcat = "-1";
80
+				else $newcat = implode(",", array_dif($cats, array($catid)));
81
+				dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET catid = '$newcat' WHERE sid = '$story[sid]' LIMIT 1");					
82
+			}
83
+			$code = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'delcategory'");
84
+			while($c = dbassoc($code)) {
85
+				eval($c['code_text']);
86
+			}
87
+			$output .= write_message(_ACTIONSUCCESSFUL);
88
+		}
89
+		else if ($confirm == "no") {
90
+			$output .= write_message(_ACTIONCANCELLED);
91
+		}
92
+		else {
93
+			$showlist = 0;
94
+			$output .= write_message(_CONFIRMDELETE."<br /><br />
95
+[ <a href=\"admin.php?action=categories&delete=$catid&confirm=yes\">"._YES."</a> | <a href=\"admin.php?action=categories&delete=$catid&confirm=no\">"._NO."</a> ]");
96
+		}
97
+	}
98
+	if (isset($_POST["submit"]) && !isset($_GET['catcounts'])) {
99
+		if(isset($_POST['catid']) && $_POST['parentcatid'] == $_POST['catid']) {
100
+			$output .= write_error(_ACTIONCANCELLED." "._CATERROR);
101
+			$tpl->assign( "output", $output );
102
+			$tpl->printToScreen();
103
+			dbclose( );
104
+			exit( );
105
+		}
106
+		if($_POST['parentcatid'] != "-1") 	{
107
+			$parentquery = dbquery("SELECT leveldown FROM ".TABLEPREFIX."fanfiction_categories WHERE catid = '$_POST[parentcatid]'");
108
+			$parentresult = dbassoc($parentquery);
109
+			$leveldown = $parentresult['leveldown'] + 1;
110
+		}
111
+		else $leveldown = 0;
112
+		$locked = (isset($_POST['locked']) && $_POST['locked'] == "on" ? "1" : "0");
113
+
114
+		$displayorder = (isNumber($_POST['orderafter']) ? $_POST['orderafter'] : 0) + 1;
115
+		if($_GET["cat"] == "new") { 
116
+			$query = dbquery("UPDATE ".TABLEPREFIX."fanfiction_categories SET displayorder = (displayorder + 1) WHERE displayorder > '".$_POST['orderafter']."' AND leveldown = '$leveldown' AND parentcatid ='".$_POST['parentcatid']."'");
117
+			$catresult = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_categories (category, parentcatid, description, locked, image, leveldown, displayorder) VALUES ('".addslashes(descript(strip_tags(trim($_POST['category']))))."', '".$_POST['parentcatid']."', '".addslashes(descript($_POST['description']))."', '$locked', '".$_POST['image']."', '$leveldown', '$displayorder')");
118
+		}
119
+		else {
120
+			$oldinfo = dbquery("SELECT displayorder, parentcatid, leveldown FROM ".TABLEPREFIX."fanfiction_categories WHERE catid = '$_GET[cat]' LIMIT 1");
121
+			list($oldorder, $oldparent, $oldleveldown) = dbrow($oldinfo);
122
+			$catresult = "UPDATE ".TABLEPREFIX."fanfiction_categories SET category = '".addslashes(descript($_POST['category']))."', description = '".addslashes(descript($_POST['description']))."', locked = '$locked', parentcatid = '".$_POST['parentcatid']."', image = '".$_POST['image']."', leveldown = '$leveldown', displayorder = '$displayorder' WHERE catid = '".$_POST['catid']."'";
123
+			if($oldparent == $_POST['parentcatid']) {
124
+				if($oldorder && $oldorder < $displayorder) {
125
+					dbquery("UPDATE ".TABLEPREFIX."fanfiction_categories SET displayorder = displayorder - 1 WHERE displayorder > $oldorder AND displayorder < $displayorder");
126
+					dbquery("UPDATE ".TABLEPREFIX."fanfiction_categories SET displayorder = $displayorder - 1 WHERE catid = '".$_GET['cat']."'");
127
+				}
128
+				if($oldorder > $displayorder) {
129
+					dbquery("UPDATE ".TABLEPREFIX."fanfiction_categories SET displayorder = displayorder + 1 WHERE displayorder >= $displayorder AND displayorder < $oldorder");
130
+					dbquery("UPDATE ".TABLEPREFIX."fanfiction_categories SET displayorder = $displayorder WHERE catid = '".$_GET['cat']."'");
131
+				}
132
+			} 
133
+			else {
134
+				if($oldleveldown != $leveldown) relevelcategory($_GET['cat'], $leveldown);
135
+				dbquery("UPDATE ".TABLEPREFIX."fanfiction_categories SET displayorder = displayorder -1 WHERE displayorder > $oldorder AND parentcatid = '$oldparent'");
136
+				dbquery("UPDATE ".TABLEPREFIX."fanfiction_categories SET displayorder = displayorder + 1 WHERE displayorder > '".$_POST['orderafter']."' AND parentcatid = '".$_POST['parentcatid']."'");
137
+			}
138
+			$success = dbquery($catresult);
139
+		}
140
+		$selectA = "SELECT category, catid FROM ".TABLEPREFIX."fanfiction_categories WHERE parentcatid = -1 ORDER BY displayorder";
141
+		$resultA = dbquery($selectA);
142
+		$countA = 1;
143
+		while($cat = dbassoc($resultA)) {
144
+			$count = 1;
145
+			if($cat['parentcatid'] = -1) {
146
+				dbquery("UPDATE ".TABLEPREFIX."fanfiction_categories SET displayorder = $countA WHERE catid = $cat[catid]");
147
+				$countA++;
148
+			}
149
+			$selectB = "SELECT category, catid FROM ".TABLEPREFIX."fanfiction_categories WHERE parentcatid = '$cat[catid]' ORDER BY displayorder";
150
+			$resultB = dbquery($selectB);
151
+			while($sub = dbassoc($resultB)) {
152
+				dbquery("UPDATE ".TABLEPREFIX."fanfiction_categories SET displayorder = $count WHERE catid = $sub[catid]");
153
+				$count++;
154
+			}
155
+		}
156
+		$showlist = false;
157
+		$output .= write_message(_ACTIONSUCCESSFUL."<br /><br />"."<a href='admin.php?action=categories'>"._CONTINUE."</a>");
158
+	}
159
+	else {
160
+		if(isset($_GET["go"])) {
161
+			$displayorder = $_GET["displayorder"];
162
+			$oneabove =  ($_GET["go"] == "up" ?  $displayorder -1 : $displayorder + 1);
163
+			dbquery("UPDATE ".TABLEPREFIX."fanfiction_categories SET displayorder = '-1' WHERE displayorder = '$displayorder' AND parentcatid = '".$_GET['parentcatid']."'");
164
+			dbquery("UPDATE ".TABLEPREFIX."fanfiction_categories SET displayorder = '$displayorder' WHERE displayorder = '$oneabove' AND parentcatid = '".$_GET['parentcatid']."'");
165
+			dbquery("UPDATE ".TABLEPREFIX."fanfiction_categories SET displayorder = '$oneabove' WHERE displayorder = '-1' AND parentcatid = '".$_GET['parentcatid']."'");
166
+			$catlist = array( );
167
+			$catresults = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_categories ORDER BY leveldown, displayorder");
168
+			while($cat = dbassoc($catresults)) {
169
+				$catlist[$cat['catid']] = array("name" => stripslashes($cat['category']), "pid" => $cat['parentcatid'], "order" => $cat['displayorder'], "locked" => $cat['locked'], "leveldown" => $cat['leveldown']);
170
+			}
171
+		}
172
+
173
+		if(isset($_GET["cat"])) {
174
+			$subof = isset($_GET['subof']) ? $_GET['subof'] : -1;
175
+			$after = isset($_GET['after']) ? $_GET['after'] : false;
176
+			$cat = isset($_GET['cat']) ? $_GET['cat'] : "new";
177
+			$new = isNumber($cat) ? false : true;
178
+			if(isNumber($cat)) {
179
+				$query = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_categories WHERE catid='$cat' LIMIT 1");
180
+				$cat1 = dbassoc($query);
181
+				$subof  = $cat1['parentcatid'];
182
+				$after = $cat1['displayorder'] -1;
183
+			}
184
+			$showlist = 0;	
185
+			$output .= "<div style='width: 100%;'><div  id=\"settingsform\"><form method='POST' enctype='multipart/form-data' name='form' action='admin.php?action=categories".($cat ? "&cat=$cat" : "")."'>
186
+				<div class='sectionheader'>".(!$new ? _EDITCAT : _NEWCAT)."</div>
187
+				<div><label for='parentcatid'>"._CATLEVEL.": </label>
188
+				<select name='parentcatid' id='parentcatid' onchange=\"setCategoryForm(this);\"><option value='-1'>"._TOPLEVEL."</option>";
189
+			if(count($catlist) > 0) {
190
+				$opt2 = "";
191
+				foreach($catlist as $c=> $cinfo) {
192
+					if($subof == $cinfo['pid'] || $subof == $c) 
193
+						$output .= "<option value='$c'".($subof == $c ? " selected" : "").">".$cinfo['name']."</option>";
194
+					if($subof == $cinfo['pid'] || (!$subof && $cinfo['pid'] == -1))
195
+						$opt2 .= "<option value='".$cinfo['order']."'".($after == $cinfo['order'] ? " selected" : "").">".$cinfo['name']."</option>";
196
+				}
197
+			}
198
+			$output .= "</select> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_CATLEVEL."</span></A></div>";
199
+			$output .= "<div><label for='orderafter'>"._ORDERAFTER.":</label> 
200
+					<select name='orderafter' id='orderafter'>";
201
+			$output .= "<option value='0'>"._MOVETOP."</option>".(isset($opt2) ? $opt2 : "")."</select> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_ORDERAFTER."</span></A></div>
202
+				<div><label for='category'>"._CATNAME.": </label>
203
+				<INPUT  type='text' class='textbox=' name='category'".($new ? ">" : "value='$cat1[category]'><input type='hidden' name='catid' value='$cat1[catid]'>")." <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_CATNAME."</span></A></div>
204
+				<div><label for='description'>"._DESC.": </label><A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_CATDESC."</span></A>
205
+				<div style='margin-left: 30%; padding-left: 1em;'><textarea class='textbox' id='description' name='description' id='description' cols='35' rows='4'>".(!$new ? $cat1['description'] : "")."</textarea></div>";
206
+			if($tinyMCE) 
207
+				$output .= "<div class='tinytoggle'><input type='checkbox' name='toggle' onclick=\"toogleEditorMode('description');\" checked><label for='toggle'>"._TINYMCETOGGLE."</label></div>";
208
+			
209
+			$output.= "</div>
210
+				<div><label for='locked'>"._LOCKED.": </label>
211
+				<INPUT type='checkbox' class='checkbox' name='locked'".(!$new && $cat1['locked'] == 1 ? "checked" : "")."> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_LOCKED."</span></A></div>
212
+				<div><label for='image'>"._IMAGE.": </label>
213
+				<INPUT  type='text' class='textbox='  name='image'".(!$new && $cat1['image'] != "" ? "value='$cat1[image]'": "")."> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_CATIMAGE."</span></A></div>
214
+				<INPUT type='submit' class='button' id='submit' value='"._SUBMIT."' name='submit'>
215
+				</form></div><div style='clear: both;'>&nbsp;</div></div>";
216
+		}
217
+	}
218
+
219
+	if($showlist) {
220
+		// Rebuild the category list to reflect any changes we just did.
221
+			$catlist = array( );
222
+			$catresults = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_categories ORDER BY leveldown, displayorder");
223
+			while($cat = dbassoc($catresults)) {
224
+				$catlist[$cat['catid']] = array("name" => stripslashes($cat['category']), "pid" => $cat['parentcatid'], "order" => $cat['displayorder'], "locked" => $cat['locked'], "leveldown" => $cat['leveldown']);
225
+			}
226
+		$output .= "
227
+<table class=\"tblborder\" align=\"center\" cellspacing=\"0\" cellpadding=\"3\" style='margin: 0 auto;' width=\"90%\">
228
+		<tr><th class=\"tblborder\"><b>"._CATEGORY."</b></th><th class=\"tblborder\" colspan=\"2\"><b>"._MOVE."</b></th><th class=\"tblborder\"><b>"._OPTIONS."</b></th></tr>";
229
+		foreach($catlist as $cat => $catinfo) {
230
+				if($catinfo['pid'] == -1) $output .= build_cat_row($cat, $catinfo);
231
+		}
232
+		$output .= "<tr><td class=\"tblborder\" colspan=\"4\" align=\"center\"><a href=\"admin.php?action=categories&cat=new\">"._NEWMAIN."</a></td></tr></table>";
233
+	}	
234
+
235
+?>
0 236
\ No newline at end of file