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,126 @@
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
+$field = isset($_GET['field']) ? $_GET['field'] : false;
28
+$list = true;
29
+$fieldtypes = array("1" => _FIELDURL, "2" => _FIELDSELECT, "3" => _FIELDYESNO, "4" => _FIELDIDURL, "5" => _FIELDCUSTOM, "6" => _TEXT);
30
+if(!empty($_GET['delete'])) {
31
+	$delete = $_GET['delete'];
32
+	$confirm = isset($_GET['confirm']) ? $_GET['confirm'] : false;
33
+	if($confirm == "yes" && isNumber($delete)) {
34
+		$result = dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_id = '$delete' LIMIT 1");
35
+		if($result) $output .= write_message(_ACTIONSUCCESSFUL);
36
+		else $output .= write_error(_ERROR);
37
+
38
+	}
39
+	else if($confirm == "no") {
40
+		$output .= write_message(_ACTIONCANCELLED);
41
+	}
42
+	else {
43
+		$output .= write_message(_CONFIRMDELETE."<br /><br />
44
+					[ <a href=\"admin.php?action=authorfields&amp;delete=$delete&amp;confirm=yes\">"._YES."</a> | <a href=\"admin.php?action=authorfields&amp;delete=$delete&amp;confirm=no\">"._NO."</a> ]");
45
+
46
+	}
47
+}
48
+if(!empty($_GET['edit'])) {
49
+	$new = $_GET['edit'] == "new" ? true : false;
50
+	if(isset($_POST['submit'])) {
51
+		$field_name = isset($_POST['field_name']) ? descript($_POST['field_name']) : "";
52
+		$field_title = isset($_POST['field_title']) ? descript($_POST['field_title']) : "";
53
+		$field_type = isset($_POST['field_type']) && isNumber($_POST['field_type'])? $_POST['field_type'] : "0";
54
+		$field_on = isset($_POST['field_on']) && $_POST['field_on'] == "on" ? "1" : "0";
55
+		$field_options = "";
56
+		$code_in = "";
57
+		$code_out = "";
58
+		if(!$field_type) {
59
+			$output .= write_error(_NOFIELDTYPE);	
60
+		}
61
+		else {
62
+			if($field_type == 4) $field_options = isset($_POST['options_4']) ? descript($_POST['options_4']) : "";
63
+			if($field_type == 2) $field_options = implode("|#|", explode("\r\n", ltrim(strip_tags(preg_replace( '!<p>!iU', "\r\n",  stripslashes(trim($_POST['options_2']))), preg_replace("!<p>!iu", "", $allowed_tags)))));
64
+			if($field_type == 5) {
65
+				$code_in = isset($_POST['code_in']) ? descript($_POST['code_in']) : "";
66
+				$code_out = isset($_POST['code_out']) ? descript($_POST['code_out']) : "";
67
+			}
68
+			if($new) {
69
+				$result = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_authorfields(`field_name`, `field_title`, `field_type`, `field_options`, `field_code_in`, `field_code_out`, `field_on`) 
70
+					VALUES('".escapestring($field_name)."', '".escapestring($field_title)."', '$field_type', '".escapestring($field_options)."', '".escapestring($code_in)."', '".escapestring($code_out)."', '$field_on');");
71
+			}
72
+			else {
73
+				$result = dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorfields SET field_type = '$field_type', field_name = '".escapestring($field_name)."', field_title = '".escapestring($field_title)."', field_options = '".escapestring($field_options)."', field_code_in = '".escapestring($code_in)."', field_code_out = '".escapestring($code_out)."', field_on = '$field_on' WHERE field_id = '".$_GET['edit']."'");
74
+			}
75
+			if($result) $output .= write_message(_ACTIONSUCCESSFUL);
76
+			else $output .= write_error(_ERROR);
77
+		}
78
+	}
79
+	else {
80
+		if($new) {
81
+			$fieldinfo = array("field_type" => "", "field_id" => "", "field_name" => "", "field_title" => "", "field_options" => "", "field_code_in" => "", "field_code_out" => "", "field_on" => "0");
82
+		}
83
+		else {
84
+			$fieldinfo = dbassoc(dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_id = '".$_GET['edit']."' LIMIT 1"));
85
+		}
86
+		$output .= "
87
+		<div class='sectionheader'>".($new ? _ADDFIELD : _EDITFIELD)."</div>
88
+			<div><form method=\"POST\" id='settingsform' enctype=\"multipart/form-data\" action=\"admin.php?action=authorfields&amp;edit=".$_GET['edit']."\">
89
+			<label for='field_name'>"._NAME.":</label> <input type='text' class='textbox' name='field_name' id='field_name' value='".$fieldinfo['field_name']."'><br />
90
+			<label for='field_title'>"._TITLE.":</label> <input type='text' class='textbox' name='field_title' id='field_title' value='".$fieldinfo['field_title']."'><br />
91
+			<div><label for='field_on'>"._FIELDON.":</label> <input type='checkbox' name='field_on' id='field_on'".($fieldinfo['field_on'] ? " checked='checked'" : "")."></div>
92
+			<label for='field_type'>"._TYPE.":</label> <select name='field_type' id='field_type' onchange=\"javascript:displayTypeOpts()\">";
93
+		foreach($fieldtypes as $id => $name) {
94
+				$output .= "<option value='$id'".(isset($fieldinfo) && $fieldinfo['field_type'] == $id ? " selected" : "").">$name</option>";
95
+		}
96
+		$output .= "</select> <A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_FIELDTYPE."</span></A><br />
97
+			<div id='opt_2'".($fieldinfo['field_type'] == 2 ? "" :"style='display: none;'")."><label for='options_2'>"._FIELDSELECT.":</label><A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_FIELDSELECT."</span></A><div style='margin-left: 30%; padding-left: 1em;'><textarea style='width: 100%; height: 150px;' name='options_2' cols='35' rows='4' class='mceNoEditor' id='options_2'>".($fieldinfo['field_type'] == 2 ? preg_replace("@\|#\|@", "\n", stripslashes($fieldinfo['field_options'])) : "")."</textarea></div>";
98
+				if($tinyMCE) 
99
+				$output .= "<div class='tinytoggle'><input type='checkbox' name='toggle' onclick=\"toogleEditorMode('options_2');\"><label for='toggle'>"._TINYMCETOGGLE."</label></div>";
100
+		$output .= "</div>
101
+			<div id='opt_4'".($fieldinfo['field_type'] == 4 ? "" :"style='display: none;'")."><label for='options_4'>"._FIELDIDURL.":</label><input type='text' name='options_4' id='options_4' ".($fieldinfo['field_type'] == 4 ? "value='".stripslashes($fieldinfo['field_options'])."'" : "")."><A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_FIELDIDURL."</span></A></div>
102
+			<div id='opt_5'".($fieldinfo['field_type'] == 5 ? "" :"style='display: none;'").">
103
+				<label for='code_in'>"._FIELDCODEIN.":</label><A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_FIELDCODEIN."</span></A><div style='margin-left: 30%; padding-left: 1em;'><textarea cols='35' rows='4' style='width: 100%; height: 150px;' name='code_in' class='mceNoEditor' id='code_in'>".stripslashes($fieldinfo['field_code_in'])."</textarea>";
104
+		$output .= "</div>
105
+				<label for='code_out'>"._FIELDCODEOUT.":</label><A HREF=\"#\" class=\"pophelp\">[?]<span>"._HELP_FIELDCODEOUT."</span></A><div style='margin-left: 30%; padding-left: 1em;'><textarea name='code_out' cols='35' rows='4'  style='width: 100%; height: 150px;' class='mceNoEditor' id='code_out'>".stripslashes($fieldinfo['field_code_out'])."</textarea>";
106
+		$output .= "</div>
107
+			</div>
108
+			<div id='submitdiv'><INPUT type='submit' id='submit' class='button' value='"._SUBMIT."' name='submit'></div></form><div class='cleaner'>&nbsp;</div></div>";
109
+
110
+		$list = false;
111
+	}
112
+}
113
+else if(!empty($_GET['delete'])) {
114
+
115
+}
116
+if($list) {
117
+	$fields = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorfields");
118
+	if(dbnumrows($fields) > 0) {
119
+		$output .= "<table class='tblborder' style='margin: 0 auto;'><tr><th class='tblborder'>"._NAME."</th><th class='tblborder'>"._STATUS."</th><th class='tblborder'>"._OPTIONS."</th></tr>";
120
+		while($field = dbassoc($fields)) {
121
+			$output .= "<tr><td class='tblborder'>".(empty($field['field_title']) ? $field['field_name'] : $field['field_title'])."</td><td class='tblborder' style='text-align: center;'>".($field['field_on'] ? _ON : _OFF)."</td><td class='tblborder'><a href='admin.php?action=authorfields&amp;edit=".$field['field_id']."'>"._EDIT."</a> | <a href='admin.php?action=authorfields&amp;delete=".$field['field_id']."'>"._DELETE."</a></td></tr>";
122
+		}
123
+		$output .= "<tr><td class='tblborder' colspan='3' style='text-align: center;'><a href='admin.php?action=authorfields&amp;edit=new'>"._ADDNEWFIELD."</a></td></tr></table>";
124
+	}
125
+}
126
+?>
0 127
\ No newline at end of file