Browse code

3.5.6 efiction version

Jimako authored on 2024/03/09 16:09:42
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,147 @@
1
+<?php
2
+
3
+// ----------------------------------------------------------------------
4
+// eFiction 3.2
5
+// Copyright (c) 2007 by Tammy Keefer
6
+// Valid HTML 4.01 Transitional
7
+// Based on eFiction 1.1
8
+// Copyright (C) 2003 by Rebecca Smallwood.
9
+// http://efiction.sourceforge.net/
10
+// ----------------------------------------------------------------------
11
+// LICENSE
12
+//
13
+// This program is free software; you can redistribute it and/or
14
+// modify it under the terms of the GNU General Public License (GPL)
15
+// as published by the Free Software Foundation; either version 2
16
+// of the License, or (at your option) any later version.
17
+//
18
+// This program is distributed in the hope that it will be useful,
19
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
+// GNU General Public License for more details.
22
+//
23
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
24
+// ----------------------------------------------------------------------
25
+
26
+if(!defined("_CHARSET")) exit( );
27
+
28
+	$output .= "<div id='pagetitle'>"._CHARACTERS."</div>";
29
+	if(isset($_GET["delete"])) {
30
+		$charid = $_GET["delete"];
31
+		$confirm = isset($_GET['confirm']) ? $_GET['confirm'] : false;
32
+		if($confirm == "yes" && isNumber($charid))
33
+		{
34
+			$result5 = dbquery("SELECT catid, charname FROM ".TABLEPREFIX."fanfiction_characters WHERE charid = '$charid'");
35
+			$chars = dbassoc($result5);
36
+			dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_characters where charid = '$charid'");
37
+			$storyquery = dbquery("SELECT charid, sid FROM ".TABLEPREFIX."fanfiction_stories WHERE FIND_IN_SET('$charid', charid) > 0");
38
+			while($story = dbassoc($storyquery)) {
39
+				$newcharlist = array_diff(explode(",", $story['charid']), array($charid));
40
+				dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET charid = '".($newcharlist ? implode(",", $newcharlist) : "")."' WHERE sid = '$story[sid]'");
41
+			}
42
+			$seriesquery = dbquery("SELECT characters, seriesid FROM ".TABLEPREFIX."fanfiction_series WHERE FIND_IN_SET('$charid', characters) > 0");
43
+			while($series = dbassoc($seriesquery)) {
44
+				$newcharlist = array_diff(explode(",", $series['characters']), array($charid));
45
+				dbquery("UPDATE ".TABLEPREFIX."fanfiction_series SET characters = '".($newcharlist ? implode(",", $newcharlist) : "")."' WHERE seriesid = '$series[seriesid]'");
46
+			}
47
+			$code = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'delchar'");
48
+			while($c = dbassoc($code)) {
49
+				eval($c['code_text']);
50
+			}
51
+			$output .= write_message(_ACTIONSUCCESSFUL);
52
+		}
53
+		else if ($confirm  == "no") 	{
54
+			$output .= write_message(_ACTIONCANCELLED);
55
+		}
56
+		else {
57
+			$output .= write_message(_CONFIRMDELETE."<br /><br />
58
+				[ <a href=\"admin.php?action=characters&amp;delete=$charid&amp;confirm=yes\">"._YES."</a> | <a href=\"admin.php?action=characters&amp;delete=$charid&amp;confirm=no\">"._NO."</a> ]");
59
+		}
60
+	}		
61
+	if(isset($_GET['do']) && $_GET['do'] == "addform") {
62
+		if(isset($_GET['charid']) && isNumber($_GET['charid'])) $charid = $_GET['charid'];
63
+		if(isset($_POST['numchars']) &&  isNumber($_POST['numchars'])) $numchars = $_POST['numchars'];
64
+		if(!isset($numchars)) $numchars = $itemsperpage;
65
+		if(isset($charid)) {
66
+			$charquery = dbquery("SELECT charname, bio FROM ".TABLEPREFIX."fanfiction_characters WHERE charid = '$charid' LIMIT 1");
67
+			$charinfo = dbassoc($charquery);
68
+			$output .= "<form method=\"POST\" enctype=\"multipart/form-data\" id='settingsform' action=\"admin.php?action=characters&do=update\">
69
+				<input type=\"hidden\" name=\"charid\" value=\"$charid\">";
70
+			$numchars = 1;
71
+		}
72
+		else if(isset($_GET['catid'])) {
73
+			$output .= "<form method=\"POST\" enctype=\"multipart/form-data\" id='settingsform' action=\"admin.php?action=characters&do=add\"><input type=\"hidden\" name=\"numchars\" value=\"$numchars\"><input type=\"hidden\" name=\"catid\" value=\"".$_GET['catid']."\">";
74
+		}
75
+		else {
76
+			$output .= "<div style='width: 100%;'><div  id=\"settingsform\"><form method=\"POST\" enctype=\"multipart/form-data\" id='settingsform'  action=\"admin.php?action=characters&do=add\"><input type=\"hidden\" name=\"numchars\" value=\"$numchars\"><input type=\"hidden\" name=\"catid\" value=\"".$_POST['catid']."\">";
77
+		}
78
+		for($x = 1; $x <= $numchars; $x++) {
79
+			$output .= "<div class='sectionheader'>".(isset($charid) ? _EDITCHAR : _NEWCHAR." $x")."</div>
80
+				<div><label for='character$x'>"._CHARACTER.":</label><input type=\"text\" class=\"textbox\" name=\"character$x\" size=\"35\"".(isset($charinfo['charname']) ? " value=\"".$charinfo['charname']."\"" : "")."> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_CHARS."</span></A></div>
81
+				<div><label for='bio$x'>"._DESC.":</label><textarea class=\"textbox\" rows=\"6\" cols=\"40\" id= 'bio$x' name=\"bio$x\">".(isset($charinfo) ? $charinfo['bio'] : "")."</textarea></div>";
82
+			if($tinyMCE) 
83
+				$output .= "<div class='tinytoggle'><input type='checkbox' name='toggle' onclick=\"toogleEditorMode('bio$x');\" checked><label for='toggle'>"._TINYMCETOGGLE."</label></div>";	
84
+		}
85
+		$output .= "<div id='submitdiv'><INPUT type=\"submit\" id=\"submit\" class=\"button\" name=\"submit\" value=\""._SUBMIT."\"></div></form></div><div style='clear: both;'>";
86
+		unset($_POST['submit']);
87
+	}
88
+	if(isset($_POST["submit"])) {
89
+		if($_GET["do"] == "add") {
90
+			$numchars = $_POST["numchars"];
91
+			if(!isNumber($numchars)) $numchars = $itempsperpage;
92
+			for($x = 1; $x <= $numchars; $x++) {
93
+				if(isset($_POST["character$x"]) && $_POST["character$x"] != "") {
94
+					$result = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_characters (charname, bio, catid) VALUES('".escapestring(descript(strip_tags(trim($_POST["character$x"]))))."', '".escapestring(descript($_POST["bio$x"]))."', '$_POST[catid]')");
95
+				}
96
+			}
97
+		}
98
+		else if($_GET["do"] == "update") {
99
+			$result = dbquery("UPDATE ".TABLEPREFIX."fanfiction_characters SET charname = '".escapestring(descript(strip_tags(trim($_POST["character1"]))))."', bio = '".escapestring(descript($_POST["bio1"]))."' WHERE charid = '$_POST[charid]'");
100
+		}
101
+		$output .= write_message(_ACTIONSUCCESSFUL);
102
+	}
103
+	if(!isset($_GET['do']) || isset($_POST['submit'])) {
104
+		if(isset($_GET['cat']) && isNumber($_GET['cat'])) $cat =  $_GET['cat'];
105
+		else $cat = -1;
106
+	
107
+		$output .= "<div style='text-align: center;'><form method=\"POST\" name=\"form\" enctype=\"multipart/form-data\" action=\"admin.php?action=characters&do=addform\">
108
+			<label for='catid'>"._CATEGORY.": </label>
109
+			<select name=\"catid\" onChange='document.location = document.location.pathname + \"?action=characters&cat=\"+ document.form.catid.options[document.form.catid.selectedIndex].value;'>
110
+			<option value=\"-1\">"._BACK2CATS."</option><option value=\"-1\"".($cat == "-1" ? " selected" : "").">"._SITEWIDE."</option>";
111
+		foreach($catlist as $category => $info){
112
+			if($category == $cat || $info['pid'] == $cat) $output .= "<option value=\"$category\"".($category == $cat ? " selected" : "").">".$info['name']."</option>";
113
+		}
114
+		$output .= "</select></form></div>";
115
+
116
+		// Repopulate the characters list to reflect any changes we made.
117
+		$charlist = array( );
118
+		$result = dbquery("SELECT charname, catid, charid FROM ".TABLEPREFIX."fanfiction_characters ORDER BY charname");
119
+		while($char = dbassoc($result)) {
120
+			$charlist[$char['charid']] = array("name" => stripslashes($char['charname']), "catid" => $char['catid']);
121
+		}
122
+
123
+		//List of current characters
124
+		$output .= "<center>"._CHOOSECATNOTE."</center><br /><table class=\"tblborder\" cellspacing=\"0\" cellpadding=\"3\" style='margin: 0 auto;' align=\"center\">
125
+		<tr>
126
+		<th class=\"tblborder\">"._CHARACTER."</th><th class=\"tblborder\">"._OPTIONS."</th>
127
+		</tr>";
128
+		$count = 0;
129
+		foreach($charlist as $char =>$charinfo) {
130
+			if($charinfo['catid'] == $cat) {
131
+				$output .= "<tr><td class=\"tblborder\">
132
+				<a href=\"browse.php?type=characters&amp;charid=$char\">".$charinfo['name']."</a></td><td class=\"tblborder\"><a href=\"admin.php?action=characters&amp;do=addform&amp;charid=$char&amp;cat=$cat\">"._EDIT."</a> | <a href=\"admin.php?action=characters&amp;delete=$char&amp;cat=$cat\">"._DELETE."</a></td></tr>";
133
+				$count++;
134
+			}
135
+		}	
136
+		if($count == 0) $output .= "<tr><td class=\"tblborder\" colspan=\"2\" style=\"text-align: center;\">"._NORESULTS."</td></tr>";
137
+		$output .= "</table></p>";
138
+		$output .= "<div class='sectionheader'>"._ADDNEWCHARS."</div>
139
+		<div><form method=\"POST\" name=\"addform\" enctype=\"multipart/form-data\" id='settingsform' action=\"admin.php?action=characters&do=addform&catid=$cat\">
140
+		<div><label for='numchars'>"._NUMCHARS.":</label><select name=\"numchars\">";
141
+		for($x = 1; $x < $itemsperpage + 1; $x++) {
142
+			$output .= "<option value=\"$x\">$x</option>";
143
+		}
144
+		$output .= "</select><A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_NUMCHARS."</span></A></div><div id='submitdiv'><INPUT type=\"submit\" class=\"button\" id='submit' value=\""._SUBMIT."\" name=\"submit\"></div>
145
+			</form><div style='clear: both;'>&nbsp;</div></div>";
146
+	}
147
+?>
0 148
\ No newline at end of file