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,117 @@
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 save_blocks( $blocks ) {
28
+	
29
+	foreach($blocks as $block =>$value) {
30
+		unset($blockvars);
31
+		if((isset($_GET['admin']) && $_GET['admin'] != $block) || (isset($_GET['init']) && $_GET['init'] != $block)) continue;
32
+		foreach($value as $var=>$val) {
33
+			if($var != "name" && $var != "title" && $var != "file" && $var != "status") $blockvars[$var] = $val;
34
+		}
35
+		$tmp_title = isset($value['title']) ? escapestring($value['title']) : "";
36
+		$tmp_file  = isset($value['file']) ?  $value['file'] : "";
37
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_blocks SET block_name = '$block', block_title = '". $tmp_title."', block_file = '". $tmp_file."', block_status = '".$value['status']."', block_variables =  '".(isset($blockvars) ? addslashes(serialize($blockvars)) : "")."' WHERE block_name = '$block'");
38
+	}
39
+}
40
+if(isset($_GET['admin'])) $admin = $_GET['admin'];
41
+else $admin = false;
42
+$content = "";
43
+
44
+	if($admin) {
45
+		$output .= "<div id='pagetitle'>"._ADMIN." - ".(isset($blocks[$_GET['admin']]['title']) ? $blocks[$_GET['admin']]['title'] : "")."</div>";
46
+		include("blocks/".$_GET['admin']."/admin.php");
47
+		save_blocks( $blocks );
48
+	}
49
+	if(isset($_GET['init'])) {
50
+		if(file_exists("blocks/".$_GET['init']."/init.php")) include("blocks/".$_GET['init']."/init.php");
51
+		else return _ERROR;
52
+		save_blocks( $blocks );
53
+	}
54
+
55
+	if(isset($_POST['submit']) && empty($admin)) {
56
+		$x = 1;
57
+ 
58
+		while(isset($_POST[$x])) {
59
+			// activate inactive blocks.
60
+			if(isset($blocks[$_POST[$x]])) {
61
+				$tmp_title  = isset($_POST[$x . "_title"]) ? descript($_POST[$x . "_title"]) : "";
62
+				$tmp_status = isset($_POST[$x . "_status"]) ? descript($_POST[$x . "_status"]) : "";
63
+				$blocks[$_POST[$x]]['title'] = $tmp_title;
64
+				$blocks[$_POST[$x]]["status"] = $tmp_status;
65
+			}
66
+			$x++;	
67
+		}
68
+		save_blocks( $blocks );
69
+		$output .= write_message(_ACTIONSUCCESSFUL);
70
+	}
71
+// In case the skin has already overridden the block settings or we've just changed the settings.
72
+
73
+$blockquery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_blocks");
74
+while ($block = dbassoc($blockquery))
75
+{
76
+	if ($block['block_variables'] > 0)
77
+	{
78
+		$block_vars = @unserialize($block['block_variables']);
79
+		if ($block_vars)
80
+		{
81
+			$blocks[$block['block_name']] = $block_vars;
82
+		}
83
+		//else
84
+		//{
85
+		//	print_r($block);
86
+		//}
87
+	}
88
+	$blocks[$block['block_name']]['title'] = $block['block_title'];
89
+	$blocks[$block['block_name']]['file'] = $block['block_file'];
90
+	$blocks[$block['block_name']]['status'] = $block['block_status'];
91
+}
92
+	unset($content);
93
+
94
+if(empty($admin)) {
95
+	$output .= "<form method=\"POST\" enctype=\"multipart/form-data\" action=\"admin.php?action=blocks\"><center><table class=\"tblborder\" cellpadding=\"3\"><tr><th>"._NAME."</th><th>"._TITLE."</th><th>"._STATUS."</th><th>"._ADMIN."</th></tr>";
96
+	$x = 1;
97
+	$directory = opendir("blocks");
98
+	while($filename = readdir($directory)) {
99
+			if($filename=="." || $filename==".." || !is_dir("blocks/".$filename)) continue;
100
+			$output .= "<tr><td class=\"tblborder\"><input type=\"hidden\" name=\"$x\" value=\"$filename\">$filename</td>";
101
+			if(isset($blocks[$filename]['file'])) $output .= "<td class=\"tblborder\"><input name=\"{$x}_title\" type=\"text\" class=\"textbox\" value=\"".stripslashes($blocks[$filename]['title'])."\"><input name=\"{$x}_file\" type=\"hidden\" value=\"".$blocks[$filename]['file']."\"></td>
102
+				<td class=\"tblborder\"><select name=\"{$x}_status\">
103
+					<option value=\"0\"".(!$blocks[$filename]['status'] ? " selected" : "").">"._INACTIVE."</option>
104
+					<option value=\"1\"".($blocks[$filename]['status'] == 1? " selected" : "").">"._ACTIVE."</option>
105
+					<option value=\"2\"".($blocks[$filename]['status'] == 2 ? " selected" : "").">"._INDEXONLY."</option>
106
+					</select></td>
107
+				<td class=\"tblborder\">".(file_exists("blocks/$filename/admin.php") ? "<a href=\"admin.php?action=blocks&admin=$filename\">"._OPTIONS."</a>" :  _NONE);
108
+			else $output .= "<td class=\"tblborder\" colspan=\"3\" align=\"center\"><a href=\"admin.php?action=blocks&init=$filename\">"._INITIALIZE."</a>";
109
+			$output .= "</td></tr>";
110
+			$x++;
111
+	}
112
+	closedir($directory);
113
+	$output .= "</table><br /><INPUT type=\"submit\" class=\"button\" name=\"submit\" value=\""._SUBMIT."\"></form>";
114
+}
115
+// Now load the skin settings back in.
116
+	if(file_exists("$skindir/variables.php")) include("$skindir/variables.php"); 
117
+?>
0 118
\ No newline at end of file