| ... | ... |
@@ -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) ? "&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 /> |
| ... | ... |
@@ -22,34 +22,22 @@ |
| 22 | 22 |
|
| 23 | 23 |
if(!defined("_CHARSET")) exit( );
|
| 24 | 24 |
|
| 25 |
-$csrfKey = SITEKEY . '_messages_csrf'; |
|
| 26 |
-if(empty($_SESSION[$csrfKey])) $_SESSION[$csrfKey] = bin2hex(random_bytes(32)); |
|
| 27 |
-if(isset($_POST['submit']) && (!isset($_POST['csrf']) || !hash_equals($_SESSION[$csrfKey], (string) $_POST['csrf']))) {
|
|
| 28 |
- http_response_code(403); |
|
| 29 |
- exit('Forbidden');
|
|
| 30 |
-} |
|
| 31 |
-$messageName = (isset($_GET['message']) && preg_match('/^[a-z0-9_]{3,30}$/i', (string) $_GET['message'])) ? (string) $_GET['message'] : "";
|
|
| 32 |
-$efCsrfField = "<input type='hidden' name='csrf' value='".htmlspecialchars($_SESSION[$csrfKey], ENT_QUOTES, 'UTF-8')."'>"; |
|
| 33 |
- |
|
| 34 | 25 |
$output .= "<div id=\"pagetitle\">"._MESSAGESETTINGS."</div>"; |
| 35 | 26 |
|
| 36 |
-if($messageName === "") {
|
|
| 37 |
- $output .= write_error(_BADVARNAME); |
|
| 38 |
-} else if(isset($_POST['submit'])) {
|
|
| 39 |
- $result = dbquery("UPDATE ".TABLEPREFIX."fanfiction_messages SET message_text = '".escapestring(descript($_POST['text']))."' WHERE message_name = '".escapestring($messageName)."' LIMIT 1");
|
|
| 27 |
+if(isset($_POST['submit'])) {
|
|
| 28 |
+ $result = dbquery("UPDATE ".TABLEPREFIX."fanfiction_messages SET message_text = '".escapestring(descript($_POST['text']))."' WHERE message_name = '".$_GET['message']."' LIMIT 1");
|
|
| 40 | 29 |
if($result) $output .= write_message(_ACTIONSUCCESSFUL); |
| 41 | 30 |
else $output .= write_error(_ERROR); |
| 42 | 31 |
} |
| 43 | 32 |
else {
|
| 44 |
- $pagequery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_messages WHERE message_name = '".escapestring($messageName)."' LIMIT 1");
|
|
| 33 |
+ $pagequery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_messages WHERE message_name = '".$_GET['message']."' LIMIT 1");
|
|
| 45 | 34 |
$message = dbassoc($pagequery); |
| 46 | 35 |
$text = $message['message_text']; |
| 47 |
- if(!$message) dbquery("INSERT INTO `".TABLEPREFIX."fanfiction_messages` (`message_name` , `message_title` , `message_text` ) VALUES ('".escapestring($messageName)."', '', '')");
|
|
| 48 |
- $output .= "<div class='sectionheader'>".htmlspecialchars(preg_replace("@\{sitename\}@", (string) $sitename, (string) $message['message_title']), ENT_QUOTES, 'UTF-8')."</div>
|
|
| 49 |
- <div style='width: 100%;'><div id=\"settingsform\"><form method=\"POST\" enctype=\"multipart/form-data\" action=\"admin.php?action=messages&message=".htmlspecialchars($messageName, ENT_QUOTES, 'UTF-8')."\"> |
|
| 50 |
- $efCsrfField |
|
| 51 |
- <textarea rows=\"10\" cols=\"60\" style=\"width: 100%;\" ".($messageName == "tinyMCE" ? "class='mceNoEditor'" :"")." name=\"text\">$text</textarea>"; |
|
| 52 |
- if($tinyMCE && $messageName != "tinyMCE") |
|
| 36 |
+ if(!$message) dbquery("INSERT INTO `".TABLEPREFIX."fanfiction_messages` (`message_name` , `message_title` , `message_text` ) VALUES ('".$_GET['message']."', '', '')");
|
|
| 37 |
+ $output .= "<div class='sectionheader'>".preg_replace("@\{sitename\}@", $sitename, $message['message_title'])."</div>
|
|
| 38 |
+ <div style='width: 100%;'><div style='width: 35%; margin: 0 auto;'><form method=\"POST\" enctype=\"multipart/form-data\" action=\"admin.php?action=messages&message=".$_GET['message']."\"> |
|
| 39 |
+ <textarea rows=\"10\" cols=\"60\" style=\"width: 100%;\" ".($_GET['message'] == "tinyMCE" ? "class='mceNoEditor'" :"")." name=\"text\">$text</textarea>"; |
|
| 40 |
+ if($tinyMCE && $_GET['message'] != "tinyMCE") |
|
| 53 | 41 |
$output .= "<div class='tinytoggle'><input type='checkbox' name='toggle' onclick=\"toogleEditorMode('text');\" checked><label for='toggle'>"._TINYMCETOGGLE."</label></div>";
|
| 54 | 42 |
$output .= "<div style='clear: both;'> </div><INPUT type='submit' class='button' id='submit' value='"._SUBMIT."' name='submit'> |
| 55 | 43 |
</form></div><div style='clear: both;'> </div></div>"; |