PageMode constants

This commit is contained in:
Matthew Barbour 2019-06-18 20:58:28 -05:00 committed by matthew
parent 123089bfbf
commit 826c623538
62 changed files with 160 additions and 159 deletions

View file

@ -26,6 +26,11 @@
* Various other common functions are available as part of the Themelet class.
*/
abstract class PageMode {
const REDIRECT = 'redirect';
const DATA = 'data';
const PAGE = 'page';
}
/**
* Class Page
@ -40,7 +45,7 @@ class Page
/** @name Overall */
//@{
/** @var string */
public $mode = "page";
public $mode = PageMode::PAGE;
/** @var string */
public $type = "text/html; charset=utf-8";
@ -261,7 +266,7 @@ class Page
}
switch ($this->mode) {
case "page":
case PageMode::PAGE:
if (CACHE_HTTP) {
header("Vary: Cookie, Accept-Encoding");
if ($user->is_anonymous() && $_SERVER["REQUEST_METHOD"] == "GET") {
@ -285,14 +290,14 @@ class Page
$layout = new Layout();
$layout->display_page($page);
break;
case "data":
case PageMode::DATA:
header("Content-Length: ".strlen($this->data));
if (!is_null($this->filename)) {
header('Content-Disposition: attachment; filename='.$this->filename);
}
print $this->data;
break;
case "redirect":
case PageMode::REDIRECT:
header('Location: '.$this->redirect);
print 'You should be redirected to <a href="'.$this->redirect.'">'.$this->redirect.'</a>';
break;

View file

@ -70,7 +70,7 @@ class AdminPage extends Extension
}
if ($aae->redirect) {
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("admin"));
}
}
@ -149,7 +149,7 @@ class AdminPage extends Extension
send_event(new ImageDeletionEvent($image));
}
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/list"));
return false;
}
@ -218,7 +218,7 @@ class AdminPage extends Extension
//FIXME: .SQL dump is empty if cmd doesn't exist
if ($cmd) {
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->set_type("application/x-unknown");
$page->set_filename('shimmie-'.date('Ymd').'.sql');
$page->set_data(shell_exec($cmd));
@ -243,7 +243,7 @@ class AdminPage extends Extension
$zip->close();
}
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link($filename)); //TODO: Delete file after downloaded?
return false; // we do want a redirect, but a manual one

View file

@ -41,7 +41,7 @@ class AliasEditor extends Extension
try {
$aae = new AddAliasEvent($_POST['oldtag'], $_POST['newtag']);
send_event($aae);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("alias/list"));
} catch (AddAliasException $ex) {
$this->theme->display_error(500, "Error adding alias", $ex->getMessage());
@ -54,7 +54,7 @@ class AliasEditor extends Extension
$database->execute("DELETE FROM aliases WHERE oldtag=:oldtag", ["oldtag" => $_POST['oldtag']]);
log_info("alias_editor", "Deleted alias for ".$_POST['oldtag'], "Deleted alias");
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("alias/list"));
}
}
@ -80,7 +80,7 @@ class AliasEditor extends Extension
$this->theme->display_aliases($alias, $page_number + 1, $total_pages);
} elseif ($event->get_arg(0) == "export") {
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->set_type("text/csv");
$page->set_filename("aliases.csv");
$page->set_data($this->get_alias_csv($database));
@ -91,7 +91,7 @@ class AliasEditor extends Extension
$contents = file_get_contents($tmp);
$this->add_alias_csv($database, $contents);
log_info("alias_editor", "Imported aliases from file", "Imported aliases"); # FIXME: how many?
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("alias/list"));
} else {
$this->theme->display_error(400, "No File Specified", "You have to upload a file");

View file

@ -172,7 +172,7 @@ class Artists extends Extension
}
case "new_artist":
{
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("artist/new"));
break;
}
@ -183,7 +183,7 @@ class Artists extends Extension
if ($newArtistID == -1) {
$this->theme->display_error(400, "Error", "Error when entering artist data.");
} else {
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("artist/view/".$newArtistID));
}
} else {
@ -238,7 +238,7 @@ class Artists extends Extension
case "edit_artist":
{
$artistID = $_POST['artist_id'];
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("artist/edit/".$artistID));
break;
}
@ -246,14 +246,14 @@ class Artists extends Extension
{
$artistID = int_escape($_POST['id']);
$this->update_artist();
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("artist/view/".$artistID));
break;
}
case "nuke_artist":
{
$artistID = $_POST['artist_id'];
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("artist/nuke/".$artistID));
break;
}
@ -261,7 +261,7 @@ class Artists extends Extension
{
$artistID = $event->get_arg(1);
$this->delete_artist($artistID); // this will delete the artist, its alias, its urls and its members
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("artist/list"));
break;
}
@ -291,7 +291,7 @@ class Artists extends Extension
{
$artistID = $_POST['artistID'];
$this->add_alias();
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("artist/view/".$artistID));
break;
}
@ -300,7 +300,7 @@ class Artists extends Extension
$aliasID = $event->get_arg(2);
$artistID = $this->get_artistID_by_aliasID($aliasID);
$this->delete_alias($aliasID);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("artist/view/".$artistID));
break;
}
@ -316,7 +316,7 @@ class Artists extends Extension
$this->update_alias();
$aliasID = int_escape($_POST['aliasID']);
$artistID = $this->get_artistID_by_aliasID($aliasID);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("artist/view/".$artistID));
break;
}
@ -332,7 +332,7 @@ class Artists extends Extension
{
$artistID = $_POST['artistID'];
$this->add_urls();
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("artist/view/".$artistID));
break;
}
@ -341,7 +341,7 @@ class Artists extends Extension
$urlID = $event->get_arg(2);
$artistID = $this->get_artistID_by_urlID($urlID);
$this->delete_url($urlID);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("artist/view/".$artistID));
break;
}
@ -357,7 +357,7 @@ class Artists extends Extension
$this->update_url();
$urlID = int_escape($_POST['urlID']);
$artistID = $this->get_artistID_by_urlID($urlID);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("artist/view/".$artistID));
break;
}
@ -372,7 +372,7 @@ class Artists extends Extension
{
$artistID = $_POST['artistID'];
$this->add_members();
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("artist/view/".$artistID));
break;
}
@ -381,7 +381,7 @@ class Artists extends Extension
$memberID = int_escape($event->get_arg(2));
$artistID = $this->get_artistID_by_memberID($memberID);
$this->delete_member($memberID);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("artist/view/".$artistID));
break;
}
@ -397,7 +397,7 @@ class Artists extends Extension
$this->update_member();
$memberID = int_escape($_POST['memberID']);
$artistID = $this->get_artistID_by_memberID($memberID);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("artist/view/".$artistID));
break;
}

View file

@ -21,7 +21,7 @@ class AutoComplete extends Extension
return;
}
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->set_type("application/json");
$s = strtolower($_GET["s"]);

View file

@ -61,7 +61,7 @@ class Blocks extends Extension
", [$_POST['pages'], $_POST['title'], $_POST['area'], (int)$_POST['priority'], $_POST['content']]);
log_info("blocks", "Added Block #".($database->get_last_insert_id('blocks_id_seq'))." (".$_POST['title'].")");
$database->cache->delete("blocks");
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("blocks/list"));
}
}
@ -81,7 +81,7 @@ class Blocks extends Extension
log_info("blocks", "Updated Block #".$_POST['id']." (".$_POST['title'].")");
}
$database->cache->delete("blocks");
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("blocks/list"));
}
} elseif ($event->get_arg(0) == "list") {

View file

@ -102,7 +102,7 @@ class Blotter extends Extension
[$entry_text, $important]
);
log_info("blotter", "Added Message: $entry_text");
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("blotter/editor"));
}
break;
@ -119,7 +119,7 @@ class Blotter extends Extension
}
$database->Execute("DELETE FROM blotter WHERE id=:id", ["id"=>$id]);
log_info("blotter", "Removed Entry #$id");
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("blotter/editor"));
}
break;

View file

@ -54,7 +54,7 @@ class BrowserSearch extends Extension
";
// And now to send it to the browser
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->set_type("text/xml");
$page->set_data($xml);
} elseif (
@ -85,7 +85,7 @@ class BrowserSearch extends Extension
// And now for the final output
$json_string = "[\"$tag_search\",[\"$json_tag_list\"],[],[]]";
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->set_data($json_string);
}
}

View file

@ -171,7 +171,7 @@ class BulkActions extends Extension
}
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
if (!isset($_SERVER['HTTP_REFERER'])) {
$_SERVER['HTTP_REFERER'] = make_link();
}

View file

@ -178,7 +178,7 @@ class CommentList extends Extension
$i_iid = int_escape($_POST['image_id']);
$cpe = new CommentPostingEvent($_POST['image_id'], $user, $_POST['comment']);
send_event($cpe);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/$i_iid#comment_on_$i_iid"));
} catch (CommentPostingException $ex) {
$this->theme->display_error(403, "Comment Blocked", $ex->getMessage());
@ -194,7 +194,7 @@ class CommentList extends Extension
if ($event->count_args() === 3) {
send_event(new CommentDeletionEvent($event->get_arg(1)));
flash_message("Deleted comment");
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
if (!empty($_SERVER['HTTP_REFERER'])) {
$page->set_redirect($_SERVER['HTTP_REFERER']);
} else {
@ -224,7 +224,7 @@ class CommentList extends Extension
}
flash_message("Deleted $num comments");
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("admin"));
} else {
$this->theme->display_permission_denied();

View file

@ -456,7 +456,7 @@ class CronUploader extends Extension
global $page;
// Display message
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->set_type("text/plain");
$page->set_data($this->upload_info);

View file

@ -60,7 +60,7 @@ class DanbooruApi extends Extension
private function api_danbooru(PageRequestEvent $event)
{
global $page;
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
if (($event->get_arg(1) == 'add_post') || (($event->get_arg(1) == 'post') && ($event->get_arg(2) == 'create.xml'))) {
// No XML data is returned from this function
@ -80,7 +80,7 @@ class DanbooruApi extends Extension
// This redirects that to http://shimmie/post/view/123
elseif (($event->get_arg(1) == 'post') && ($event->get_arg(2) == 'show')) {
$fixedlocation = make_link("post/view/" . $event->get_arg(3));
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect($fixedlocation);
}
}

View file

@ -26,7 +26,7 @@ class DowntimeTheme extends Themelet
$login_link = make_link("user_admin/login");
$auth = $user->get_auth_html();
$page->set_mode('data');
$page->set_mode(PageMode::DATA);
$page->set_code(503);
$page->set_data(
<<<EOD

View file

@ -18,7 +18,7 @@ class EmoticonListTheme extends Themelet
}
$html .= "</tr></table>";
$html .= "</body></html>";
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->set_data($html);
}
}

View file

@ -125,7 +125,7 @@ class ExtManager extends Extension
if (is_writable("data/config")) {
$this->set_things($_POST);
log_warning("ext_manager", "Active extensions changed", "Active extensions changed");
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("ext_manager"));
} else {
$this->theme->display_error(

View file

@ -81,7 +81,7 @@ class Favorites extends Extension
log_debug("favourite", "Favourite removed for $image_id", "Favourite removed");
}
}
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/$image_id"));
}
}

View file

@ -37,7 +37,7 @@ class Featured extends Extension
if ($id > 0) {
$config->set_int("featured_id", $id);
log_info("featured", "Featured image set to $id", "Featured image set");
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/$id"));
}
}
@ -45,7 +45,7 @@ class Featured extends Extension
if ($event->get_arg(0) == "download") {
$image = Image::by_id($config->get_int("featured_id"));
if (!is_null($image)) {
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->set_type($image->get_mime_type());
$page->set_data(file_get_contents($image->get_image_filename()));
}

View file

@ -139,7 +139,7 @@ class Forum extends Extension
$redirectTo = "forum/view/".$newThreadID."/1";
}
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link($redirectTo));
break;
@ -151,7 +151,7 @@ class Forum extends Extension
$this->delete_post($postID);
}
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("forum/view/".$threadID));
break;
case "nuke":
@ -161,7 +161,7 @@ class Forum extends Extension
$this->delete_thread($threadID);
}
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("forum/index"));
break;
case "answer":
@ -176,11 +176,11 @@ class Forum extends Extension
}
$this->save_new_post($threadID, $user);
}
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("forum/view/".$threadID."/".$total_pages));
break;
default:
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("forum/index"));
//$this->theme->display_error(400, "Invalid action", "You should check forum/index.");
break;

View file

@ -14,7 +14,7 @@ class Handle404 extends Extension
{
global $config, $page;
// hax.
if ($page->mode == "page" && (!isset($page->blocks) || $this->count_main($page->blocks) == 0)) {
if ($page->mode == PageMode::PAGE && (!isset($page->blocks) || $this->count_main($page->blocks) == 0)) {
$h_pagename = html_escape(implode('/', $event->args));
log_debug("handle_404", "Hit 404: $h_pagename");
$page->set_code(404);

View file

@ -14,7 +14,7 @@ class HandleStatic extends Extension
{
global $config, $page;
// hax.
if ($page->mode == "page" && (!isset($page->blocks) || $this->count_main($page->blocks) == 0)) {
if ($page->mode == PageMode::PAGE && (!isset($page->blocks) || $this->count_main($page->blocks) == 0)) {
$h_pagename = html_escape(implode('/', $event->args));
$f_pagename = preg_replace("/[^a-z_\-\.]+/", "_", $h_pagename);
$theme_name = $config->get_string("theme", "default");
@ -27,7 +27,7 @@ class HandleStatic extends Extension
$page->add_http_header("Cache-control: public, max-age=600");
$page->add_http_header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 600) . ' GMT');
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->set_data(file_get_contents($filename));
if (endsWith($filename, ".ico")) {
$page->set_type("image/x-icon");

View file

@ -57,7 +57,7 @@ class SVGFileHandler extends DataHandlerExtension
$hash = $image->hash;
$page->set_type("image/svg+xml");
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$sanitizer = new Sanitizer();
$sanitizer->removeRemoteReferences(true);

View file

@ -4,7 +4,7 @@ class HomeTheme extends Themelet
{
public function display_page(Page $page, $sitename, $base_href, $theme_name, $body)
{
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->add_auto_html_headers();
$hh = $page->get_all_html_headers();
$page->set_data(

View file

@ -43,7 +43,7 @@ class ImageIO extends Extension
$image = Image::by_id($_POST['image_id']);
if ($image) {
send_event(new ImageDeletionEvent($image));
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
if (isset($_SERVER['HTTP_REFERER']) && !strstr($_SERVER['HTTP_REFERER'], 'post/view')) {
$page->set_redirect($_SERVER['HTTP_REFERER']);
} else {
@ -56,7 +56,7 @@ class ImageIO extends Extension
if ($user->can("replace_image") && isset($_POST['image_id']) && $user->check_auth_token()) {
$image = Image::by_id($_POST['image_id']);
if ($image) {
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link('upload/replace/'.$image->id));
} else {
/* Invalid image ID */
@ -251,7 +251,7 @@ class ImageIO extends Extension
global $page;
if (!is_null($image)) {
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
if ($type == "thumb") {
$ext = $config->get_string("thumb_type");
if (array_key_exists($ext, MIME_TYPE_MAP)) {

View file

@ -79,7 +79,7 @@ class ImageBan extends Extension
flash_message("Image deleted");
}
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect($_SERVER['HTTP_REFERER']);
}
} elseif ($event->get_arg(0) == "remove") {
@ -87,7 +87,7 @@ class ImageBan extends Extension
send_event(new RemoveImageHashBanEvent($_POST['hash']));
flash_message("Image ban removed");
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect($_SERVER['HTTP_REFERER']);
}
} elseif ($event->get_arg(0) == "list") {

View file

@ -239,10 +239,10 @@ class Index extends Extension
// implode(explode()) to resolve aliases and sanitise
$search = url_escape(Tag::implode(Tag::explode($_GET['search'], false)));
if (empty($search)) {
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/list/1"));
} else {
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link('post/list/'.$search.'/1'));
}
return;
@ -278,7 +278,7 @@ class Index extends Extension
$this->theme->display_intro($page);
send_event(new PostListBuildingEvent($search_terms));
} elseif ($count_search_terms > 0 && $count_images === 1 && $page_number === 1) {
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link('post/view/'.$images[0]->id));
} else {
$plbe = new PostListBuildingEvent($search_terms);

View file

@ -77,7 +77,7 @@ class IPBan extends Extension
send_event(new AddIPBanEvent($_POST['ip'], $_POST['reason'], $end));
flash_message("Ban for {$_POST['ip']} added");
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("ip_ban/list"));
}
} elseif ($event->get_arg(0) == "remove" && $user->check_auth_token()) {
@ -85,7 +85,7 @@ class IPBan extends Extension
send_event(new RemoveIPBanEvent($_POST['id']));
flash_message("Ban removed");
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("ip_ban/list"));
}
} elseif ($event->get_arg(0) == "list") {

View file

@ -35,7 +35,7 @@ class MailTest extends Extension
{
if ($event->page_matches("mail/test")) {
global $page;
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
echo "Alert: uncomment this page's code on /ext/mail/main.php starting on line 33, and change the email address. Make sure you're using a server with a domain, not localhost.";
/*
echo "Preparing to send message:<br>";

View file

@ -64,7 +64,7 @@ class MassTagger extends Extension
}
}
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
if (!isset($_SERVER['HTTP_REFERER'])) {
$_SERVER['HTTP_REFERER'] = make_link();
}

View file

@ -81,14 +81,14 @@ class NotATag extends Extension
[$tag, $redirect]
);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect($_SERVER['HTTP_REFERER']);
} elseif ($event->get_arg(0) == "remove") {
if (isset($_POST['tag'])) {
$database->Execute("DELETE FROM untags WHERE tag = ?", [$_POST['tag']]);
flash_message("Image ban removed");
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect($_SERVER['HTTP_REFERER']);
}
} elseif ($event->get_arg(0) == "list") {

View file

@ -100,7 +100,7 @@ class Notes extends Extension
$this->revert_history($noteID, $reviewID);
}
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("note/updated"));
break;
case "add_note":
@ -108,7 +108,7 @@ class Notes extends Extension
$this->add_new_note();
}
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
break;
case "add_request":
@ -116,7 +116,7 @@ class Notes extends Extension
$this->add_note_request();
}
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
break;
case "nuke_notes":
@ -124,7 +124,7 @@ class Notes extends Extension
$this->nuke_notes();
}
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
break;
case "nuke_requests":
@ -132,25 +132,25 @@ class Notes extends Extension
$this->nuke_requests();
}
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
break;
case "edit_note":
if (!$user->is_anonymous()) {
$this->update_note();
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/" . $_POST["image_id"]));
}
break;
case "delete_note":
if ($user->is_admin()) {
$this->delete_note();
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
}
break;
default:
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("note/list"));
break;
}

View file

@ -94,7 +94,7 @@ class NumericScore extends Extension
if (!is_null($score) && $image_id>0) {
send_event(new NumericScoreSetEvent($image_id, $user, $score));
}
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/$image_id"));
}
} elseif ($event->page_matches("numeric_score/remove_votes_on") && $user->check_auth_token()) {
@ -108,13 +108,13 @@ class NumericScore extends Extension
"UPDATE images SET numeric_score=0 WHERE id=?",
[$image_id]
);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/$image_id"));
}
} elseif ($event->page_matches("numeric_score/remove_votes_by") && $user->check_auth_token()) {
if ($user->can("edit_other_vote")) {
$this->delete_votes_by(int_escape($_POST['user_id']));
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link());
}
} elseif ($event->page_matches("popular_by_day") || $event->page_matches("popular_by_month") || $event->page_matches("popular_by_year")) {

View file

@ -41,7 +41,7 @@ class Oekaki extends Extension
throw new UploadException("File type not recognised");
} else {
unlink($tmpname);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/".$duev->image_id));
}
}

View file

@ -404,7 +404,7 @@ class OuroborosAPI extends Extension
} elseif ($this->type == 'xml') {
$page->set_type('text/xml; charset=utf-8');
}
$page->set_mode('data');
$page->set_mode(PageMode::DATA);
$this->tryAuth();
if ($event->page_matches('post')) {
@ -464,7 +464,7 @@ class OuroborosAPI extends Extension
}
}
} elseif ($event->page_matches('post/show')) {
$page->set_mode('redirect');
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link(str_replace('post/show', 'post/view', implode('/', $event->args))));
$page->display();
die();

View file

@ -149,7 +149,7 @@ class PrivMsg extends Extension
$database->execute("DELETE FROM private_message WHERE id = :id", ["id" => $pm_id]);
$database->cache->delete("pm-count-{$user->id}");
log_info("pm", "Deleted PM #$pm_id", "PM deleted");
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect($_SERVER["HTTP_REFERER"]);
}
}
@ -162,7 +162,7 @@ class PrivMsg extends Extension
$message = $_POST["message"];
send_event(new SendPMEvent(new PM($from_id, $_SERVER["REMOTE_ADDR"], $to_id, $subject, $message)));
flash_message("PM sent");
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect($_SERVER["HTTP_REFERER"]);
}
break;

View file

@ -130,7 +130,7 @@ class Pools extends Extension
case "create": // ADD _POST
try {
$newPoolID = $this->add_pool();
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("pool/view/".$newPoolID));
} catch (PoolCreationException $e) {
$this->theme->display_error(400, "Error", $e->error);
@ -150,7 +150,7 @@ class Pools extends Extension
if (!$user->is_anonymous()) {
$historyID = int_escape($event->get_arg(1));
$this->revert_history($historyID);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("pool/updated"));
}
break;
@ -159,7 +159,7 @@ class Pools extends Extension
if ($this->have_permission($user, $pool)) {
$this->theme->edit_pool($page, $this->get_pool($pool_id), $this->edit_posts($pool_id));
} else {
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("pool/view/".$pool_id));
}
break;
@ -169,13 +169,13 @@ class Pools extends Extension
if ($this->have_permission($user, $pool)) {
$this->theme->edit_order($page, $this->get_pool($pool_id), $this->edit_order($pool_id));
} else {
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("pool/view/".$pool_id));
}
} else {
if ($this->have_permission($user, $pool)) {
$this->order_posts();
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("pool/view/".$pool_id));
} else {
$this->theme->display_error(403, "Permission Denied", "You do not have permission to access this page");
@ -194,7 +194,7 @@ class Pools extends Extension
case "add_posts":
if ($this->have_permission($user, $pool)) {
$this->add_posts();
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("pool/view/".$pool_id));
} else {
$this->theme->display_error(403, "Permission Denied", "You do not have permission to access this page");
@ -204,7 +204,7 @@ class Pools extends Extension
case "remove_posts":
if ($this->have_permission($user, $pool)) {
$this->remove_posts();
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("pool/view/".$pool_id));
} else {
$this->theme->display_error(403, "Permission Denied", "You do not have permission to access this page");
@ -215,7 +215,7 @@ class Pools extends Extension
case "edit_description":
if ($this->have_permission($user, $pool)) {
$this->edit_description();
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("pool/view/".$pool_id));
} else {
$this->theme->display_error(403, "Permission Denied", "You do not have permission to access this page");
@ -228,7 +228,7 @@ class Pools extends Extension
// -> Only admins and owners may do this
if ($user->is_admin() || $user->id == $pool['user_id']) {
$this->nuke_pool($pool_id);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("pool/list"));
} else {
$this->theme->display_error(403, "Permission Denied", "You do not have permission to access this page");
@ -236,7 +236,7 @@ class Pools extends Extension
break;
default:
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("pool/list"));
break;
}

View file

@ -40,7 +40,7 @@ class RandomImage extends Extension
if ($action === "download") {
if (!is_null($image)) {
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->set_type($image->get_mime_type());
$page->set_data(file_get_contents($image->get_image_filename()));
}
@ -50,7 +50,7 @@ class RandomImage extends Extension
}
} elseif ($action === "widget") {
if (!is_null($image)) {
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->set_type("text/html");
$page->set_data($this->theme->build_thumb_html($image));
}

View file

@ -21,10 +21,10 @@ class RandomList extends Extension
// implode(explode()) to resolve aliases and sanitise
$search = url_escape(Tag::implode(Tag::explode($_GET['search'], false)));
if (empty($search)) {
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("random"));
} else {
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link('random/'.$search));
}
return;

View file

@ -91,7 +91,7 @@ class Ratings extends Extension
$user_view_level = Ratings::get_user_privs($user);
$user_view_level = preg_split('//', $user_view_level, -1);
if (!in_array($event->image->rating, $user_view_level)) {
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/list"));
}
}
@ -228,7 +228,7 @@ class Ratings extends Extension
# select image_id from image_tags join tags
# on image_tags.tag_id = tags.id where tags.tag = ?);
# ", array($_POST["rating"], $_POST["tag"]));
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/list"));
}
}

View file

@ -43,7 +43,7 @@ class RegenThumb extends Extension
$this->regenerate_thumbnail($image);
}
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/list"));
}
}

View file

@ -67,7 +67,7 @@ class ReportImage extends Extension
if (!empty($_POST['image_id']) && !empty($_POST['reason'])) {
$image_id = int_escape($_POST['image_id']);
send_event(new AddReportedImageEvent(new ImageReport($image_id, $user->id, $_POST['reason'])));
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/$image_id"));
} else {
$this->theme->display_error(500, "Missing input", "Missing image ID or report reason");
@ -76,7 +76,7 @@ class ReportImage extends Extension
if (!empty($_POST['id'])) {
if ($user->can("view_image_report")) {
send_event(new RemoveReportedImageEvent($_POST['id']));
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("image_report/list"));
}
} else {
@ -85,7 +85,7 @@ class ReportImage extends Extension
} elseif ($event->get_arg(0) == "remove_reports_by" && $user->check_auth_token()) {
if ($user->can("view_image_report")) {
$this->delete_reports_by(int_escape($_POST['user_id']));
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link());
}
} elseif ($event->get_arg(0) == "list") {

View file

@ -149,7 +149,7 @@ class ResizeImage extends Extension
//$this->theme->display_resize_page($page, $image_id);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/".$image_id));
} catch (ImageResizeException $e) {
$this->theme->display_resize_error($page, "Error Resizing", $e->error);

View file

@ -96,7 +96,7 @@ class RotateImage extends Extension
//$this->theme->display_rotate_page($page, $image_id);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/".$image_id));
} catch (ImageRotateException $e) {
$this->theme->display_rotate_error($page, "Error Rotating", $e->error);

View file

@ -24,7 +24,7 @@ class RSS_Comments extends Extension
{
global $config, $database, $page;
if ($event->page_matches("rss/comments")) {
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->set_type("application/rss+xml");
$comments = $database->get_all("

View file

@ -39,7 +39,7 @@ class RSS_Images extends Extension
{
global $page;
global $config;
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->set_type("application/rss+xml");
$data = "";

View file

@ -90,14 +90,14 @@ class Rule34 extends Extension
'UPDATE users SET comic_admin=? WHERE id=?',
[$input['is_admin'] ? 't' : 'f', $input['user_id']]
);
$page->set_mode('redirect');
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(@$_SERVER['HTTP_REFERER']);
}
}
if ($event->page_matches("tnc_agreed")) {
setcookie("ui-tnc-agreed", "true", 0, "/");
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(@$_SERVER['HTTP_REFERER'] ?? "/");
}
@ -123,7 +123,7 @@ class Rule34 extends Extension
}
}
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("admin"));
}
}

View file

@ -203,7 +203,7 @@ class Setup extends Extension
global $config, $page, $user;
if ($event->page_matches("nicetest")) {
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->set_data("ok");
}
@ -216,7 +216,7 @@ class Setup extends Extension
$config->save();
flash_message("Config saved");
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("setup"));
} elseif ($event->get_arg(0) == "advanced") {
$this->theme->display_advanced($page, $config->values);

View file

@ -53,7 +53,7 @@ class ShimmieApi extends Extension
global $page, $user;
if ($event->page_matches("api/shimmie")) {
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->set_type("text/plain");
if ($event->page_matches("api/shimmie/get_tags")) {
@ -100,7 +100,7 @@ class ShimmieApi extends Extension
$all = $this->api_get_user($type, $query);
$page->set_data(json_encode($all));
} else {
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("ext_doc/shimmie_api"));
}
}

View file

@ -152,7 +152,7 @@ class XMLSitemap extends Extension
// Generate new sitemap
file_put_contents($this->sitemap_filepath, $xml);
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->set_type("application/xml");
$page->set_data($xml);
}
@ -188,7 +188,7 @@ class XMLSitemap extends Extension
$xml = file_get_contents($this->sitemap_filepath);
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->set_type("application/xml");
$page->set_data($xml);
}

View file

@ -132,7 +132,7 @@ class Source_History extends Extension
// check for the nothing case
if ($revert_id < 1) {
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link());
return;
}
@ -165,7 +165,7 @@ class Source_History extends Extension
send_event(new SourceSetEvent($image, $stored_source));
// all should be done now so redirect the user back to the image
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link('post/view/'.$stored_image_id));
}

View file

@ -165,14 +165,14 @@ class TagEdit extends Extension
$search = $_POST['search'];
$replace = $_POST['replace'];
$this->mass_tag_edit($search, $replace);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("admin"));
}
}
if ($event->get_arg(0) == "mass_source_set") {
if ($user->can("mass_tag_edit") && isset($_POST['tags']) && isset($_POST['source'])) {
$this->mass_source_edit($_POST['tags'], $_POST['source']);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/list"));
}
}

View file

@ -132,7 +132,7 @@ class Tag_History extends Extension
// check for the nothing case
if ($revert_id < 1) {
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link());
return;
}
@ -162,7 +162,7 @@ class Tag_History extends Extension
send_event(new TagSetEvent($image, Tag::explode($stored_tags)));
// all should be done now so redirect the user back to the image
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link('post/view/'.$stored_image_id));
}

View file

@ -75,7 +75,7 @@ class TagList extends Extension
$database->cache->set($cache_key, $res, 600);
}
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->set_type("text/plain");
$page->set_data(implode("\n", $res));
}

View file

@ -59,7 +59,7 @@ class TaggerXML extends Extension
$tags.
"</tags>";
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->set_type("text/xml");
$page->set_data($xml);
}

View file

@ -51,7 +51,7 @@ class Tips extends Extension
case "save":
if ($user->check_auth_token()) {
$this->saveTip();
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("tips/list"));
}
break;
@ -59,14 +59,14 @@ class Tips extends Extension
// FIXME: HTTP GET CSRF
$tipID = int_escape($event->get_arg(1));
$this->setStatus($tipID);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("tips/list"));
break;
case "delete":
// FIXME: HTTP GET CSRF
$tipID = int_escape($event->get_arg(1));
$this->deleteTip($tipID);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("tips/list"));
break;
}

View file

@ -199,7 +199,7 @@ class TranscodeImage extends Extension
if (isset($_POST['transcode_format'])) {
try {
$this->transcode_and_replace_image($image_obj, $_POST['transcode_format']);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/".$image_id));
} catch (ImageTranscodeException $e) {
$this->theme->display_transcode_error($page, "Error Transcoding", $e->getMessage());

View file

@ -38,7 +38,7 @@ class Update extends Extension
if ($event->page_matches("update/download")) {
$ok = $this->download_shimmie();
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
if ($ok) {
$page->set_redirect(make_link("update/update", "sha=".$_GET['sha']));
} else {
@ -47,7 +47,7 @@ class Update extends Extension
} elseif ($event->page_matches("update/update")) {
$ok = $this->update_shimmie();
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
if ($ok) {
$page->set_redirect(make_link("admin"));
} //TODO: Show success?

View file

@ -300,7 +300,7 @@ class UploadTheme extends Themelet
public function display_upload_status(Page $page, bool $ok)
{
if ($ok) {
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link());
} else {
$page->set_title("Upload Status");

View file

@ -372,7 +372,7 @@ class UserPage extends Extension
if (!is_null($duser)) {
$user = $duser;
$this->set_login_cookie($duser->name, $pass);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
// Try returning to previous page
if ($config->get_int("user_loginshowprofile", 0) == 0 &&
@ -397,7 +397,7 @@ class UserPage extends Extension
$page->add_cookie("user", "", time() + 60 * 60 * 24 * $config->get_int('login_memory'), "/");
}
log_info("user", "Logged out");
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
// Try forwarding to same page on logout unless user comes from registration page
if ($config->get_int("user_loginshowprofile", 0) == 0 &&
@ -440,7 +440,7 @@ class UserPage extends Extension
$uce = new UserCreationEvent($_POST['name'], $_POST['pass1'], $_POST['email']);
send_event($uce);
$this->set_login_cookie($uce->username, $uce->password);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("user"));
} catch (UserCreationException $ex) {
$this->theme->display_error(400, "User Creation Error", $ex->getMessage());
@ -532,10 +532,10 @@ class UserPage extends Extension
global $page, $user;
if ($user->id == $duser->id) {
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("user"));
} else {
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("user/{$duser->name}"));
}
}
@ -698,7 +698,7 @@ class UserPage extends Extension
["id" => $_POST['id']]
);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/list"));
}
}

View file

@ -123,7 +123,7 @@ class ViewImage extends Extension
return;
}
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/{$image->id}", $query));
} elseif ($event->page_matches("post/view")) {
if (!is_numeric($event->get_arg(0))) {
@ -157,7 +157,7 @@ class ViewImage extends Extension
send_event(new ImageInfoSetEvent(Image::by_id($image_id)));
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/view/$image_id", url_escape(@$_POST['query'])));
}
}

View file

@ -137,7 +137,7 @@ class Wiki extends Extension
send_event(new WikiUpdateEvent($user, $wikipage));
$u_title = url_escape($title);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("wiki/$u_title"));
} catch (WikiUpdateException $e) {
$original = $this->get_page($title);
@ -159,7 +159,7 @@ class Wiki extends Extension
["title"=>$_POST["title"], "rev"=>$_POST["revision"]]
);
$u_title = url_escape($_POST["title"]);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("wiki/$u_title"));
}
} elseif ($event->page_matches("wiki_admin/delete_all")) {
@ -170,7 +170,7 @@ class Wiki extends Extension
["title"=>$_POST["title"]]
);
$u_title = url_escape($_POST["title"]);
$page->set_mode("redirect");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("wiki/$u_title"));
}
}
@ -213,7 +213,7 @@ class Wiki extends Extension
return false;
}
private function get_page(string $title): WikiPage
private function get_page(string $title, int $revision=-1): WikiPage
{
global $database;
// first try and get the actual page
@ -222,21 +222,17 @@ class Wiki extends Extension
SELECT *
FROM wiki_pages
WHERE SCORE_STRNORM(title) LIKE SCORE_STRNORM(:title)
ORDER BY revision DESC
LIMIT 1
"),
ORDER BY revision DESC"),
["title"=>$title]
);
// fall back to wiki:default
if (empty($row)) {
$row = $database->get_row("
SELECT *
FROM wiki_pages
WHERE title LIKE :title
ORDER BY revision DESC
LIMIT 1
", ["title"=>"wiki:default"]);
SELECT *
FROM wiki_pages
WHERE title LIKE :title
ORDER BY revision DESC", ["title"=>"wiki:default"]);
// fall further back to manual
if (empty($row)) {

View file

@ -52,7 +52,7 @@ abstract class ShimmiePHPUnitTestCase extends \PHPUnit\Framework\TestCase
$_POST = [];
$page = class_exists("CustomPage") ? new CustomPage() : new Page();
send_event(new PageRequestEvent($page_name));
if ($page->mode == "redirect") {
if ($page->mode == PageMode::REDIRECT) {
$page->code = 302;
}
}
@ -68,7 +68,7 @@ abstract class ShimmiePHPUnitTestCase extends \PHPUnit\Framework\TestCase
$_POST = $args;
$page = class_exists("CustomPage") ? new CustomPage() : new Page();
send_event(new PageRequestEvent($page_name));
if ($page->mode == "redirect") {
if ($page->mode == PageMode::REDIRECT) {
$page->code = 302;
}
}

View file

@ -4,7 +4,7 @@ class CustomHomeTheme extends HomeTheme
{
public function display_page(Page $page, $sitename, $base_href, $theme_name, $body)
{
$page->set_mode("data");
$page->set_mode(PageMode::DATA);
$page->add_auto_html_headers();
$hh = $page->get_all_html_headers();
$page->set_data(