Browse code

Security patches from upstream - and general cleanup of old hacks

Clarissa Walker authored on 2026/10/31 20:10:45
Showing 1 changed files
... ...
@@ -40,6 +40,25 @@ else include_once("languages/en_admin.php");
40 40
 
41 41
 // check that user has permissions to perform this action before going further.  Otherwise kick 'em
42 42
 	if(!isADMIN) accessDenied( );
43
+	// The admin panels put these values straight into SQL. They are all ids, so anything
44
+	// else (other than the few words the panels use) is refused here once for all panels.
45
+	$ef_idkeys = array('uid', 'sid', 'rid', 'chapid', 'catid', 'parentcatid', 'charid', 'class', 'type_id', 'subof', 'field', 'displayorder',
46
+		'after', 'orderafter', 'revoke', 'lock', 'unlock', 'validate', 'release', 'retire', 'remove', 'feature', 'level', 'adlevel', 'category',
47
+		'cat', 'delete', 'edit', 'warning', 'reviewid', 'seriesid', 'inorder', 'message_id', 'link_id', 'nid', 'cid', 'panel_level');
48
+	// "type" is used by admin/classifications.php (delete=type)
49
+	$ef_words = array('', 'new', 'class', 'type', 'yes', 'no', 'all', '-1', 'on');
50
+	// these are posted as text (category name in admin/categories.php, warning text in admin/warnings.php)
51
+	$ef_posttext = array('category', 'warning');
52
+	foreach(array('_GET' => $_GET, '_POST' => $_POST) as $ef_src => $ef_vals) {
53
+		foreach($ef_idkeys as $ef_k) {
54
+			if(!isset($ef_vals[$ef_k])) continue;
55
+			if($ef_src == '_POST' && in_array($ef_k, $ef_posttext, true)) continue;
56
+			foreach((array)$ef_vals[$ef_k] as $ef_v) {
57
+				if(is_array($ef_v) || (!in_array((string)$ef_v, $ef_words, true) && !preg_match('/^-?[0-9]+(,-?[0-9]+)*$/', (string)$ef_v))) accessDenied(_ERROR." (".$ef_k.")");
58
+			}
59
+		}
60
+	}
61
+	unset($ef_idkeys, $ef_words, $ef_posttext, $ef_src, $ef_vals, $ef_k, $ef_v);
43 62
 	$adminquery = dbquery("SELECT categories FROM ".TABLEPREFIX."fanfiction_authorprefs WHERE uid = '".USERUID."' LIMIT 1");
44 63
 	list($admincats) = dbrow($adminquery);
45 64
 	if(empty($admincats)) $admincats = "0";
Browse code

admin.php, admin/custpages.php, admin/messages.php: Revert initial CSRF protection changes - The rest of the CSRF stuff are in more than one commit, so it has to be done in one batch

Clarissa Walker authored on 2026/10/28 20:38:56
Showing 1 changed files
... ...
@@ -26,8 +26,6 @@ if(isset($_GET['action']) && ($_GET['action'] == "categories" || $_GET['action']
26 26
 
27 27
 $disableTiny = true;
28 28
 
29
-ob_start();
30
-
31 29
 include ("header.php");
32 30
 
33 31
 
Browse code

admin.php, browse.php, user.php, includes/get_session_vars.php: Security - SQL injection patches - from @ariadoss

Clarissa Walker authored on 2026/10/26 13:11:20
Showing 1 changed files
... ...
@@ -26,6 +26,8 @@ if(isset($_GET['action']) && ($_GET['action'] == "categories" || $_GET['action']
26 26
 
27 27
 $disableTiny = true;
28 28
 
29
+ob_start();
30
+
29 31
 include ("header.php");
30 32
 
31 33
 
... ...
@@ -56,7 +58,7 @@ else include_once("languages/en_admin.php");
56 58
 	}
57 59
 	$output .= "</div>\n";
58 60
 	if($action) {
59
-		$panelquery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_panels WHERE panel_name = '$action' AND panel_type = 'A' LIMIT 1");
61
+		$panelquery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_panels WHERE panel_name = '".escapestring($action)."' AND panel_type = 'A' LIMIT 1");
60 62
 		if(dbnumrows($panelquery)) {
61 63
 			$panel = dbassoc($panelquery);
62 64
 			if((isset($panel['panel_level']) ? $panel['panel_level'] : 0) >= uLEVEL) {
... ...
@@ -88,4 +90,4 @@ else include_once("languages/en_admin.php");
88 90
 	$tpl->assign( "output", $output );
89 91
 	$tpl->printToScreen();
90 92
 	dbclose( );
91
-?>
92 93
\ No newline at end of file
94
+?>
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,91 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// Copyright (c) 2007 by Tammy Keefer
4
+// Based on eFiction 1.1
5
+// Copyright (C) 2003 by Rebecca Smallwood.
6
+// http://efiction.sourceforge.net/
7
+// ----------------------------------------------------------------------
8
+// LICENSE
9
+//
10
+// This program is free software; you can redistribute it and/or
11
+// modify it under the terms of the GNU General Public License (GPL)
12
+// as published by the Free Software Foundation; either version 2
13
+// of the License, or (at your option) any later version.
14
+//
15
+// This program is distributed in the hope that it will be useful,
16
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
+// GNU General Public License for more details.
19
+//
20
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
21
+// ----------------------------------------------------------------------
22
+
23
+$current = "adminarea";
24
+
25
+if(isset($_GET['action']) && ($_GET['action'] == "categories" || $_GET['action'] == "admins")) $displayform = 1;
26
+
27
+$disableTiny = true;
28
+
29
+include ("header.php");
30
+
31
+
32
+
33
+//make a new TemplatePower object
34
+if(file_exists("$skindir/default.tpl")) $tpl = new TemplatePower( "$skindir/default.tpl" );
35
+else $tpl = new TemplatePower("default_tpls/default.tpl");
36
+include("includes/pagesetup.php");
37
+if(file_exists("languages/".$language."_admin.php")) include_once("languages/".$language."_admin.php");
38
+else include_once("languages/en_admin.php");
39
+// end basic page setup
40
+
41
+// check that user has permissions to perform this action before going further.  Otherwise kick 'em
42
+	if(!isADMIN) accessDenied( );
43
+	$adminquery = dbquery("SELECT categories FROM ".TABLEPREFIX."fanfiction_authorprefs WHERE uid = '".USERUID."' LIMIT 1");
44
+	list($admincats) = dbrow($adminquery);
45
+	if(empty($admincats)) $admincats = "0";
46
+	$output = "<div style='text-align: center; margin: 1em;'>";
47
+	$panelquery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_panels WHERE panel_hidden != '1' AND panel_type = 'A' AND panel_level >= ".uLEVEL." ORDER BY panel_level DESC, panel_order ASC, panel_title ASC");
48
+	if(!dbnumrows($panelquery)) $output .= _FATALERROR;
49
+	$panellist = array();
50
+	while($panel = dbassoc($panelquery)) {
51
+		if(!$panel['panel_url']) $panellist[$panel['panel_level']][]= "<a href=\"admin.php?action=".$panel['panel_name']."\">".$panel['panel_title']."</a>";
52
+		else $panellist[$panel['panel_level']][] = "<a href=\"".$panel['panel_url']."\">".$panel['panel_title']."</a>";
53
+	}
54
+	foreach($panellist as $accesslevel => $row) {
55
+		$output .= implode(" | ", $row)."<br />";
56
+	}
57
+	$output .= "</div>\n";
58
+	if($action) {
59
+		$panelquery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_panels WHERE panel_name = '$action' AND panel_type = 'A' LIMIT 1");
60
+		if(dbnumrows($panelquery)) {
61
+			$panel = dbassoc($panelquery);
62
+			if((isset($panel['panel_level']) ? $panel['panel_level'] : 0) >= uLEVEL) {
63
+				if($panel['panel_url'] && file_exists(_BASEDIR.$panel['panel_url'])) require_once(_BASEDIR.$panel['panel_url']);
64
+				else if (file_exists("admin/{$action}.php")) require_once("admin/{$action}.php");
65
+			}
66
+			else accessDenied( );
67
+		}
68
+	}
69
+	else {
70
+		if (file_exists("install"))
71
+			$output .= write_error(_SECURITYDELETE);
72
+		$adminnotices = "";
73
+		$countquery = dbquery("SELECT COUNT(DISTINCT chapid) FROM ".TABLEPREFIX."fanfiction_chapters WHERE validated < 1");
74
+		list($count) = dbrow($countquery);
75
+		if($count) $adminnotices .= write_message(sprintf(_QUEUECOUNT, $count));
76
+		$codequery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'adminnotices'");
77
+		while($code = dbassoc($codequery)) {
78
+			eval($code['code_text']);
79
+		}
80
+
81
+		$output .= write_message("Actual time: ". time() );
82
+		$output .= write_message("Date format: " . $dateformat);
83
+		$output .= write_message(date("$dateformat", time())); 	
84
+ 
85
+		$output .= write_message($adminnotices);
86
+		$output .= write_message(_RUNNINGVERSION);
87
+	}	
88
+	$tpl->assign( "output", $output );
89
+	$tpl->printToScreen();
90
+	dbclose( );
91
+?>
0 92
\ No newline at end of file