Browse code

admin/- custpages.php, messages.php: add id to textarea in order for the tinyMCE toggle to work in tinyMCE 6.x and later

Clarissa Walker authored on 2026/11/13 18:05:18
Showing 1 changed files
... ...
@@ -85,7 +85,7 @@ if((isset($_GET['edit']) && isNumber($_GET['edit'])) || isset($_GET["new"]) || i
85 85
 		<div><label for=\"name\">"._NAME.":</label> <input type=\"text\" class=\"textbox\" name=\"name\" value=\"$name\"></div>
86 86
 		<div><label for=\"title\">"._TITLE.":</label> <input type=\"text\" class=\"textbox\" name=\"title\" value=\"$title\" size=\"30\"></div>
87 87
 		<div><label for=\"text\">"._TEXT.":</label><br />
88
-		<textarea class=\"textbox\" rows=\"10\" cols=\"60\" style='width: 100%;' name=\"text\">$text</textarea>";
88
+		<textarea class=\"textbox\" rows=\"10\" cols=\"60\" style='width: 100%;' name=\"text\" id=\"text\">$text</textarea>";
89 89
 	if($tinyMCE) 
90 90
 		$output .= "<div class='tinytoggle'><input type='checkbox' name='toggle' onclick=\"toogleEditorMode('text');\" checked><label for='toggle'>"._TINYMCETOGGLE."</label></div>";
91 91
 	$output .= "</div><INPUT type=\"submit\" class=\"button\" name=\"preview\" id=\"preview\" value=\""._PREVIEW."\"><INPUT type=\"submit\" class=\"button\" name=\"submit\" id=\"submit\" value=\""._SUBMIT."\"></form></div>";
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
... ...
@@ -24,14 +24,6 @@
24 24
 
25 25
 if(!defined("_CHARSET")) exit( );
26 26
 
27
-$csrfKey = SITEKEY . '_custpages_csrf';
28
-if(empty($_SESSION[$csrfKey])) $_SESSION[$csrfKey] = bin2hex(random_bytes(32));
29
-$isWrite = isset($_POST['submit']) || isset($_POST['preview']);
30
-if($isWrite && (!isset($_POST['csrf']) || !hash_equals($_SESSION[$csrfKey], (string) $_POST['csrf']))) {
31
-	http_response_code(403);
32
-	exit('Forbidden');
33
-}
34
-$efCsrfField = "<input type='hidden' name='csrf' value='".htmlspecialchars($_SESSION[$csrfKey], ENT_QUOTES, 'UTF-8')."'>";
35 27
 $confirm = isset($_GET['confirm']) ? $_GET['confirm'] : false;
36 28
 
37 29
 	$output .= "<div id=\"pagetitle\">"._CUSTPAGES."</div>";
... ...
@@ -90,7 +82,6 @@ if((isset($_GET['edit']) && isNumber($_GET['edit'])) || isset($_GET["new"]) || i
90 82
 		$text = "";
91 83
 	}
92 84
 	$output .= "<div id='settingsform'><form method=\"POST\" enctype=\"multipart/form-data\" action=\"admin.php?action=custpages".(isset($edit) ? "&amp;edit=$edit" : "")."\">
93
-		$efCsrfField
94 85
 		<div><label for=\"name\">"._NAME.":</label> <input type=\"text\" class=\"textbox\" name=\"name\" value=\"$name\"></div>
95 86
 		<div><label for=\"title\">"._TITLE.":</label> <input type=\"text\" class=\"textbox\" name=\"title\" value=\"$title\" size=\"30\"></div>
96 87
 		<div><label for=\"text\">"._TEXT.":</label><br />
Browse code

admin/custpages.php: restore trailing space - editor change...

Clarissa Walker authored on 2026/10/27 05:47:55
Showing 1 changed files
... ...
@@ -108,7 +108,7 @@ else {
108 108
 		if($msg['message_name'] == "welcome" ||  $msg['message_name'] == "nothankyou" || $msg['message_name'] == "thankyou" ||
109 109
 		$msg['message_name'] == "copyright" || $msg['message_name'] == "printercopyright") continue;
110 110
 		$output .= "<tr><td class=\"tblborder\">$msg[message_id]</td><td class=\"tblborder\">$msg[message_name]</td><td class=\"tblborder\"><a href='viewpage.php?page=$msg[message_name]'>$msg[message_title]</a></td>
111
-		<td class=\"tblborder\"><a href=\"admin.php?action=custpages&amp;edit=$msg[message_id]\">"._EDIT."</a> |
111
+		<td class=\"tblborder\"><a href=\"admin.php?action=custpages&amp;edit=$msg[message_id]\">"._EDIT."</a> | 
112 112
 		<a href=\"admin.php?action=custpages&amp;delete=$msg[message_id]\">"._DELETE."</a></td></tr>";
113 113
 	}
114 114
 	if(!dbnumrows($listquery)) $output .= "<tr><td class=\"tblborder\" colspan=\"3\" align=\"center\">"._NORESULTS."</td></tr>";
Browse code

admin/messages.php: Security - CSRF protection for admin message forms; viewpage.php, admin/custpages.php: Security - do not execute PHP in stored pages and CSRF protection, but delete is a confirmation prompt instead - from @ariadoss

Clarissa Walker authored on 2026/10/26 20:56:31
Showing 1 changed files
... ...
@@ -24,12 +24,29 @@
24 24
 
25 25
 if(!defined("_CHARSET")) exit( );
26 26
 
27
+$csrfKey = SITEKEY . '_custpages_csrf';
28
+if(empty($_SESSION[$csrfKey])) $_SESSION[$csrfKey] = bin2hex(random_bytes(32));
29
+$isWrite = isset($_POST['submit']) || isset($_POST['preview']);
30
+if($isWrite && (!isset($_POST['csrf']) || !hash_equals($_SESSION[$csrfKey], (string) $_POST['csrf']))) {
31
+	http_response_code(403);
32
+	exit('Forbidden');
33
+}
34
+$efCsrfField = "<input type='hidden' name='csrf' value='".htmlspecialchars($_SESSION[$csrfKey], ENT_QUOTES, 'UTF-8')."'>";
35
+$confirm = isset($_GET['confirm']) ? $_GET['confirm'] : false;
27 36
 
28 37
 	$output .= "<div id=\"pagetitle\">"._CUSTPAGES."</div>";
29 38
 if(isset($_GET['delete']) && isNumber($_GET['delete'])) {
30
-	$result = dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_messages WHERE message_id = ".$_GET['delete']." LIMIT 1");
31
-	if($result) $output .= write_message(_ACTIONSUCCESSFUL);
32
-	else $output .= write_error(_ERROR);
39
+	if($confirm == "yes") {
40
+		$result = dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_messages WHERE message_id = ".$_GET['delete']." LIMIT 1");
41
+		if($result) $output .= write_message(_ACTIONSUCCESSFUL);
42
+		else $output .= write_error(_ERROR);
43
+	}
44
+	else if($confirm == "no") {
45
+	$output .= write_message(_ACTIONCANCELLED);
46
+	}
47
+	else {
48
+		$output .= write_message("Are you sure you want to remove this custom page? <a href='admin.php?action=custpages&amp;delete=".$_GET['delete']."&amp;confirm=yes'>"._YES."</a> "._OR." <a href='admin.php?action=custpages&amp;delete=".$_GET['delete']."&amp;confirm=no'>"._NO."</a>");
49
+	}
33 50
 }
34 51
 if(isset($_POST['submit'])) {
35 52
 	if(!preg_match("!^[a-z0-9_]{3,30}$!i", $_POST['name'])) $output .= write_error(_BADVARNAME);
... ...
@@ -54,12 +71,8 @@ if((isset($_GET['edit']) && isNumber($_GET['edit'])) || isset($_GET["new"]) || i
54 71
 		$title = descript($_POST['title']);
55 72
 		$thistext = descript($_POST['text']);
56 73
 		$edit = isset($_GET['edit']) ? $_GET['edit'] : "";
57
-		if(strpos($thistext, "?>") === false) $output .= "<div id='pagetitle'>$title</div>\n\n$thistext";
58
-		else {
59
-			$text = "";
60
-			eval("?>".$thistext."<?php ");
61
-			$output .= "<div id='pagetitle'>$title</div>\n\n$text";
62
-		}
74
+		if(preg_match('/<\?(?:php|=)|\?>/i', (string) $thistext)) $output .= "<div id='pagetitle'>$title</div>".write_error("This draft contains embedded PHP. This eFiction fork does not execute stored PHP; convert the page to static HTML.");
75
+		else $output .= "<div id='pagetitle'>$title</div>\n\n$thistext";
63 76
 		$text = $thistext;
64 77
 	}
65 78
 	else if(isset($_GET['edit'])) {
... ...
@@ -77,6 +90,7 @@ if((isset($_GET['edit']) && isNumber($_GET['edit'])) || isset($_GET["new"]) || i
77 90
 		$text = "";
78 91
 	}
79 92
 	$output .= "<div id='settingsform'><form method=\"POST\" enctype=\"multipart/form-data\" action=\"admin.php?action=custpages".(isset($edit) ? "&amp;edit=$edit" : "")."\">
93
+		$efCsrfField
80 94
 		<div><label for=\"name\">"._NAME.":</label> <input type=\"text\" class=\"textbox\" name=\"name\" value=\"$name\"></div>
81 95
 		<div><label for=\"title\">"._TITLE.":</label> <input type=\"text\" class=\"textbox\" name=\"title\" value=\"$title\" size=\"30\"></div>
82 96
 		<div><label for=\"text\">"._TEXT.":</label><br />
... ...
@@ -94,7 +108,7 @@ else {
94 108
 		if($msg['message_name'] == "welcome" ||  $msg['message_name'] == "nothankyou" || $msg['message_name'] == "thankyou" ||
95 109
 		$msg['message_name'] == "copyright" || $msg['message_name'] == "printercopyright") continue;
96 110
 		$output .= "<tr><td class=\"tblborder\">$msg[message_id]</td><td class=\"tblborder\">$msg[message_name]</td><td class=\"tblborder\"><a href='viewpage.php?page=$msg[message_name]'>$msg[message_title]</a></td>
97
-		<td class=\"tblborder\"><a href=\"admin.php?action=custpages&amp;edit=$msg[message_id]\">"._EDIT."</a> | 
111
+		<td class=\"tblborder\"><a href=\"admin.php?action=custpages&amp;edit=$msg[message_id]\">"._EDIT."</a> |
98 112
 		<a href=\"admin.php?action=custpages&amp;delete=$msg[message_id]\">"._DELETE."</a></td></tr>";
99 113
 	}
100 114
 	if(!dbnumrows($listquery)) $output .= "<tr><td class=\"tblborder\" colspan=\"3\" align=\"center\">"._NORESULTS."</td></tr>";
... ...
@@ -102,4 +116,4 @@ else {
102 116
 	$output .= "</table>";
103 117
 	$output .= write_message(_CUSTPAGENOTE);
104 118
 }
105
-?>
106 119
\ No newline at end of file
120
+?>
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,105 @@
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
+
28
+	$output .= "<div id=\"pagetitle\">"._CUSTPAGES."</div>";
29
+if(isset($_GET['delete']) && isNumber($_GET['delete'])) {
30
+	$result = dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_messages WHERE message_id = ".$_GET['delete']." LIMIT 1");
31
+	if($result) $output .= write_message(_ACTIONSUCCESSFUL);
32
+	else $output .= write_error(_ERROR);
33
+}
34
+if(isset($_POST['submit'])) {
35
+	if(!preg_match("!^[a-z0-9_]{3,30}$!i", $_POST['name'])) $output .= write_error(_BADVARNAME);
36
+	else {
37
+		$pagename = descript($_POST['name']);
38
+		$pagetitle = descript($_POST['title']);
39
+		if(isset($_GET['edit']) && isNumber($_GET['edit'])) 
40
+			$result = dbquery("UPDATE ".TABLEPREFIX."fanfiction_messages SET message_name = '".escapestring($pagename)."', message_title = '".escapestring($pagetitle)."', message_text = '".escapestring(descript($_POST['text']))."' WHERE message_id = ".$_GET['edit']." LIMIT 1");
41
+		else {
42
+			$result = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_messages(`message_name`, `message_title`, `message_text`) VALUES( '".escapestring($pagename)."', '".escapestring($pagetitle)."', '".escapestring(descript($_POST['text']))."')");
43
+			if($result) $result = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_pagelinks(`link_name`, `link_text`, `link_url`, `link_target`, `link_access`) VALUES('".escapestring($pagename)."_link', '".escapestring($pagetitle)."', 'viewpage.php?page=$pagename', '0', '0')");
44
+		}
45
+		if($result) $output .= write_message(_ACTIONSUCCESSFUL."<br /><br /><a href='viewpage.php?page=$pagename'>$pagetitle</a>");
46
+		else $output .= write_error(_ERROR);
47
+		unset($_GET['edit']);
48
+	}
49
+}
50
+if((isset($_GET['edit']) && isNumber($_GET['edit'])) || isset($_GET["new"]) || isset($_POST['preview'])) {
51
+	unset($message, $id, $name, $title, $text);
52
+	if(isset($_POST['preview'])) {
53
+		$name = descript($_POST['name']);
54
+		$title = descript($_POST['title']);
55
+		$thistext = descript($_POST['text']);
56
+		$edit = isset($_GET['edit']) ? $_GET['edit'] : "";
57
+		if(strpos($thistext, "?>") === false) $output .= "<div id='pagetitle'>$title</div>\n\n$thistext";
58
+		else {
59
+			$text = "";
60
+			eval("?>".$thistext."<?php ");
61
+			$output .= "<div id='pagetitle'>$title</div>\n\n$text";
62
+		}
63
+		$text = $thistext;
64
+	}
65
+	else if(isset($_GET['edit'])) {
66
+		$edit = $_GET['edit'];
67
+		$pagequery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_messages WHERE message_id = $edit LIMIT 1");
68
+		$message =  dbassoc($pagequery);
69
+		$id = $message['message_id'];
70
+		$name = $message['message_name'];
71
+		$title = $message['message_title'];
72
+		$text = $message['message_text'];
73
+	}
74
+	else {
75
+		$name = "";
76
+		$title = "";
77
+		$text = "";
78
+	}
79
+	$output .= "<div id='settingsform'><form method=\"POST\" enctype=\"multipart/form-data\" action=\"admin.php?action=custpages".(isset($edit) ? "&amp;edit=$edit" : "")."\">
80
+		<div><label for=\"name\">"._NAME.":</label> <input type=\"text\" class=\"textbox\" name=\"name\" value=\"$name\"></div>
81
+		<div><label for=\"title\">"._TITLE.":</label> <input type=\"text\" class=\"textbox\" name=\"title\" value=\"$title\" size=\"30\"></div>
82
+		<div><label for=\"text\">"._TEXT.":</label><br />
83
+		<textarea class=\"textbox\" rows=\"10\" cols=\"60\" style='width: 100%;' name=\"text\">$text</textarea>";
84
+	if($tinyMCE) 
85
+		$output .= "<div class='tinytoggle'><input type='checkbox' name='toggle' onclick=\"toogleEditorMode('text');\" checked><label for='toggle'>"._TINYMCETOGGLE."</label></div>";
86
+	$output .= "</div><INPUT type=\"submit\" class=\"button\" name=\"preview\" id=\"preview\" value=\""._PREVIEW."\"><INPUT type=\"submit\" class=\"button\" name=\"submit\" id=\"submit\" value=\""._SUBMIT."\"></form></div>";
87
+	$output .= write_message(_CUSTPAGENOTE);
88
+}
89
+else {
90
+	$listquery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_messages");
91
+	$output .= "<table class=\"tblborder\" style=\"margin: 0 auto;\"><tr><th class=\"tblborder\">"._ID."</th><th class=\"tblborder\">"._NAME."</th><th class=\"tblborder\">"._TITLE."</th><th class=\"tblborder\">"._OPTIONS."</th></tr>";
92
+	while($msg = dbassoc($listquery)) {
93
+		// Hidden messages they're listed in the settings.
94
+		if($msg['message_name'] == "welcome" ||  $msg['message_name'] == "nothankyou" || $msg['message_name'] == "thankyou" ||
95
+		$msg['message_name'] == "copyright" || $msg['message_name'] == "printercopyright") continue;
96
+		$output .= "<tr><td class=\"tblborder\">$msg[message_id]</td><td class=\"tblborder\">$msg[message_name]</td><td class=\"tblborder\"><a href='viewpage.php?page=$msg[message_name]'>$msg[message_title]</a></td>
97
+		<td class=\"tblborder\"><a href=\"admin.php?action=custpages&amp;edit=$msg[message_id]\">"._EDIT."</a> | 
98
+		<a href=\"admin.php?action=custpages&amp;delete=$msg[message_id]\">"._DELETE."</a></td></tr>";
99
+	}
100
+	if(!dbnumrows($listquery)) $output .= "<tr><td class=\"tblborder\" colspan=\"3\" align=\"center\">"._NORESULTS."</td></tr>";
101
+	$output .= "<tr><td class=\"tblborder\" colspan=\"4\" align=\"center\"><a href=\"admin.php?action=custpages&amp;new=1\">"._ADDCUSTPAGE."</a></td></tr>";
102
+	$output .= "</table>";
103
+	$output .= write_message(_CUSTPAGENOTE);
104
+}
105
+?>
0 106
\ No newline at end of file