diff --git a/core/cli_app.php b/core/cli_app.php index 3867f7b0..47fec20b 100644 --- a/core/cli_app.php +++ b/core/cli_app.php @@ -21,7 +21,7 @@ class CliApp extends \Symfony\Component\Console\Application $definition->addOption(new InputOption( '--user', '-u', - InputOption::VALUE_NONE, + InputOption::VALUE_REQUIRED, 'Log in as the given user' )); @@ -36,9 +36,10 @@ class CliApp extends \Symfony\Component\Console\Application $output ??= new ConsoleOutput(); if ($input->hasParameterOption(['--user', '-u'])) { - $user = User::by_name($input->getOption('user')); + $name = $input->getParameterOption(['--user', '-u']); + $user = User::by_name($name); if (is_null($user)) { - die("Unknown user"); + die("Unknown user '$name'\n"); } else { send_event(new UserLoginEvent($user)); } diff --git a/core/polyfills.php b/core/polyfills.php index b57a2da6..08e7a01c 100644 --- a/core/polyfills.php +++ b/core/polyfills.php @@ -306,18 +306,14 @@ function get_base_href(): string if (defined("BASE_HREF") && !empty(BASE_HREF)) { return BASE_HREF; } - $possible_vars = ['SCRIPT_NAME', 'PHP_SELF', 'PATH_INFO', 'ORIG_PATH_INFO']; - $ok_var = null; - foreach ($possible_vars as $var) { - if (isset($_SERVER[$var]) && substr($_SERVER[$var], -4) === '.php') { - $ok_var = $_SERVER[$var]; - break; - } + if(str_ends_with($_SERVER['PHP_SELF'], 'index.php')) { + $self = $_SERVER['PHP_SELF']; } - assert(!empty($ok_var)); - $dir = dirname($ok_var); + elseif(isset($_SERVER['SCRIPT_FILENAME']) && isset($_SERVER['DOCUMENT_ROOT'])) { + $self = substr($_SERVER['SCRIPT_FILENAME'], strlen(rtrim($_SERVER['DOCUMENT_ROOT'], "/"))); + } + $dir = dirname($self); $dir = str_replace("\\", "/", $dir); - $dir = str_replace("//", "/", $dir); $dir = rtrim($dir, "/"); return $dir; } diff --git a/core/tests/PolyfillsTest.php b/core/tests/PolyfillsTest.php index 2ca5328f..aa43c4da 100644 --- a/core/tests/PolyfillsTest.php +++ b/core/tests/PolyfillsTest.php @@ -254,4 +254,42 @@ class PolyfillsTest extends TestCase deltree($dir); $this->assertFalse(file_exists($dir)); } + + private function _tbh(array $vars, string $result): void + { + // update $_SERVER with $vars, call get_base_href() and check result, then reset $_SERVER to original value + $old_server = $_SERVER; + $_SERVER = array_merge($_SERVER, $vars); + $this->assertEquals($result, get_base_href()); + $_SERVER = $old_server; + } + + public function test_get_base_href(): void + { + // PHP_SELF should point to "the currently executing script + // relative to the document root" + $this->_tbh(["PHP_SELF" => "/index.php"], ""); + $this->_tbh(["PHP_SELF" => "/mydir/index.php"], "/mydir"); + + + // SCRIPT_FILENAME should point to "the absolute pathname of + // the currently executing script" and DOCUMENT_ROOT should + // point to "the document root directory under which the + // current script is executing" + $this->_tbh([ + "PHP_SELF" => "", + "SCRIPT_FILENAME" => "/var/www/html/mydir/index.php", + "DOCUMENT_ROOT" => "/var/www/html", + ], "/mydir"); + $this->_tbh([ + "PHP_SELF" => "", + "SCRIPT_FILENAME" => "/var/www/html/mydir/index.php", + "DOCUMENT_ROOT" => "/var/www/html/", + ], "/mydir"); + $this->_tbh([ + "PHP_SELF" => "", + "SCRIPT_FILENAME" => "/var/www/html/index.php", + "DOCUMENT_ROOT" => "/var/www/html", + ], ""); + } } diff --git a/core/tests/UtilTest.php b/core/tests/UtilTest.php index d622cc2d..7fa13806 100644 --- a/core/tests/UtilTest.php +++ b/core/tests/UtilTest.php @@ -162,4 +162,27 @@ class UtilTest extends TestCase path_to_tags("/category:/tag/baz.jpg") ); } + + public function test_get_query(): void + { + // niceurls + $_SERVER["REQUEST_URI"] = "/test/tasty/cake"; + $this->assertEquals("/tasty/cake", _get_query()); + + // no niceurls + $_SERVER["REQUEST_URI"] = "/test/index.php?q=/tasty/cake"; + $this->assertEquals("/tasty/cake", _get_query()); + + // leave url encoding alone + $_SERVER["REQUEST_URI"] = "/test/index.php?q=/tasty/cake%20pie"; + $this->assertEquals("/tasty/cake%20pie", _get_query()); + + // if just viewing index.php + $_SERVER["REQUEST_URI"] = "/test/index.php"; + $this->assertEquals("/", _get_query()); + + // niceurl root + $_SERVER["REQUEST_URI"] = "/test/"; + $this->assertEquals("/", _get_query()); + } } diff --git a/core/util.php b/core/util.php index 18ae26e3..cbdaead7 100644 --- a/core/util.php +++ b/core/util.php @@ -715,19 +715,33 @@ function _get_user(): User function _get_query(): string { - // if query is explicitly set, use it - $q = @$_POST["q"] ?: @$_GET["q"]; - if(!empty($q)) { - return $q; + // if q is set in POST, use that + if(isset($_POST["q"])) { + return $_POST["q"]; } + + // if q is set in GET, use that + // (we need to manually parse the query string because PHP's $_GET + // does an extra round of URL decoding, which we don't want) + $parts = parse_url($_SERVER['REQUEST_URI']); + $qs = []; + foreach(explode('&', $parts['query'] ?? "") as $z) { + $qps = explode('=', $z, 2); + if(count($qps) == 2) { + $qs[$qps[0]] = $qps[1]; + } + } + if(isset($qs["q"])) { + return $qs["q"]; + } + // if we're just looking at index.php, use the default query - elseif (str_contains($_SERVER['REQUEST_URI'], "index.php")) { + if(str_ends_with($parts["path"], "index.php")) { return "/"; } - // otherwise, use the request URI - else { - return explode("?", $_SERVER['REQUEST_URI'])[0]; - } + + // otherwise, use the request URI minus the base path + return substr($parts["path"], strlen(get_base_href())); } diff --git a/ext/ext_manager/main.php b/ext/ext_manager/main.php index 73b176d1..55f21024 100644 --- a/ext/ext_manager/main.php +++ b/ext/ext_manager/main.php @@ -117,7 +117,7 @@ class ExtManager extends Extension } /** - * @param array $settings + * @param array $settings */ private function set_things(array $settings): void { @@ -125,7 +125,10 @@ class ExtManager extends Extension $extras = []; foreach (ExtensionInfo::get_all_keys() as $key) { - if (!in_array($key, $core) && isset($settings["ext_$key"])) { + if (in_array($key, $core)) { + continue; // core extensions are always enabled + } + if (isset($settings["ext_$key"]) && $settings["ext_$key"] === "on") { $extras[] = $key; } } diff --git a/ext/rule34/info.php b/ext/rule34/info.php deleted file mode 100644 index e2c9a4f6..00000000 --- a/ext/rule34/info.php +++ /dev/null @@ -1,21 +0,0 @@ -notify("shm_image_bans", $event->image->hash); - } - - public function onImageInfoSet(ImageInfoSetEvent $event): void - { - global $cache; - $cache->delete("thumb-block:{$event->image->id}"); - } - - public function onAdminBuilding(AdminBuildingEvent $event): void - { - global $page; - $html = make_form(make_link("admin/cache_purge"), "POST"); - $html .= ""; - $html .= "
"; - $html .= "\n"; - $page->add_block(new Block("Cache Purger", $html)); - } - - public function onCliGen(CliGenEvent $event): void - { - $event->app->register('wipe-thumb-cache') - ->addArgument('tags', InputArgument::REQUIRED) - ->setDescription('Delete cached thumbnails for images matching the given tags') - ->setCode(function (InputInterface $input, OutputInterface $output): int { - global $cache; - $tags = Tag::explode($input->getArgument('tags')); - foreach (Search::find_images_iterable(0, null, $tags) as $image) { - $output->writeln((string)$image->id); - $cache->delete("thumb-block:{$image->id}"); - } - return Command::SUCCESS; - }); - } - - public function onSourceSet(SourceSetEvent $event): void - { - // Maybe check for 404? - if (empty($event->source)) { - return; - } - if (!preg_match("/^(https?:\/\/)?[a-zA-Z0-9\.\-]+(\/.*)?$/", $event->source)) { - throw new SCoreException("Invalid source URL"); - } - } - - public function onRobotsBuilding(RobotsBuildingEvent $event): void - { - // robots should only check the canonical site, not mirrors - if ($_SERVER['HTTP_HOST'] != "rule34.paheal.net") { - $event->add_disallow(""); - } - } - - public function onPageRequest(PageRequestEvent $event): void - { - global $database, $page, $user; - - # Database might not be connected at this point... - #$database->set_timeout(null); // deleting users can take a while - - $page->add_html_header(""); - $page->add_html_header(""); - - if ($event->page_matches("tnc_agreed")) { - setcookie("ui-tnc-agreed", "true", 0, "/"); - $page->set_mode(PageMode::REDIRECT); - $page->set_redirect(referer_or("/")); - } - - if ($event->page_matches("admin/cache_purge")) { - if (!$user->can(Permissions::MANAGE_ADMINTOOLS)) { - $this->theme->display_permission_denied(); - } else { - if ($user->check_auth_token()) { - $all = $_POST["hash"]; - $matches = []; - if (preg_match_all("/([a-fA-F0-9]{32})/", $all, $matches)) { - $matches = $matches[0]; - foreach ($matches as $hash) { - $page->flash("Cleaning {$hash}"); - if (strlen($hash) != 32) { - continue; - } - log_info("admin", "Cleaning {$hash}"); - @unlink(warehouse_path(Image::IMAGE_DIR, $hash)); - @unlink(warehouse_path(Image::THUMBNAIL_DIR, $hash)); - $database->notify("shm_image_bans", $hash); - } - } - } - - $page->set_mode(PageMode::REDIRECT); - $page->set_redirect(make_link("admin")); - } - } - } -} diff --git a/ext/rule34/script.js b/ext/rule34/script.js deleted file mode 100644 index 6c41f30e..00000000 --- a/ext/rule34/script.js +++ /dev/null @@ -1,39 +0,0 @@ -let tnc_div = document.createElement('div'); -tnc_div.innerHTML = ` -
-
-

Cookies may be used. Please read our privacy policy for more information. -

By accepting to enter you agree to our rules and terms of service. -

Agree / Disagree -

-`; - - -document.addEventListener('DOMContentLoaded', () => { - if(shm_cookie_get("ui-tnc-agreed") !== "true" && window.location.href.indexOf("/wiki/") == -1) { - document.body.classList.add('censored'); - document.body.appendChild(tnc_div); - } -}); - -function tnc_agree() { - shm_cookie_set("ui-tnc-agreed", "true"); - document.body.classList.remove('censored'); - tnc_div.remove(); -} - -function image_hash_ban(id) { - var reason = prompt("WHY?", "DNP"); - if(reason) { - $.post( - "/image_hash_ban/add", - { - "image_id": id, - "reason": reason, - }, - function() { - $("#thumb_" + id).parent().parent().hide(); - } - ); - } -} diff --git a/ext/rule34/style.css b/ext/rule34/style.css deleted file mode 100644 index 13aca22b..00000000 --- a/ext/rule34/style.css +++ /dev/null @@ -1,35 +0,0 @@ -BODY.censored #header, -BODY.censored NAV, -BODY.censored ARTICLE, -BODY.censored FOOTER { - filter: blur(10px); -} -.tnc_bg { - position: fixed; - top: 0; - left: 0; - right: 0; - bottom: 0; - background: #ACE4A3; - opacity: 0.75; - z-index: 999999999999999999999; -} -.tnc { - position: fixed; - top: 20%; - left: 20%; - right: 20%; - text-align: center; - font-size: 2rem; - background: #ACE4A3; - border: 1px solid #7EB977; - z-index: 9999999999999999999999; -} -@media (max-width: 1024px) { - .tnc { - top: 5%; - left: 5%; - right: 5%; - font-size: 3vw; - } -} diff --git a/ext/setup/main.php b/ext/setup/main.php index 5c3d76b7..1b185ce9 100644 --- a/ext/setup/main.php +++ b/ext/setup/main.php @@ -355,30 +355,6 @@ class Setup extends Extension $themes[$human] = $name; } - $test_url = str_replace("/index.php", "/nicetest", $_SERVER["SCRIPT_NAME"]); - - $nicescript = ""; $sb = $event->panel->create_new_block("General"); $sb->position = 0; $sb->add_text_option(SetupConfig::TITLE, "Site title: "); @@ -388,7 +364,7 @@ class Setup extends Extension $sb->add_choice_option(SetupConfig::THEME, $themes, "
Theme: "); //$sb->add_multichoice_option("testarray", array("a" => "b", "c" => "d"), "
Test Array: "); $sb->add_bool_option("nice_urls", "
Nice URLs: "); - $sb->add_label("(Javascript inactive, can't test!)$nicescript"); + $sb->add_label("(Javascript inactive, can't test!)"); $sb = $event->panel->create_new_block("Remote API Integration"); $sb->add_label("Akismet"); diff --git a/ext/setup/script.js b/ext/setup/script.js new file mode 100644 index 00000000..ee6d067e --- /dev/null +++ b/ext/setup/script.js @@ -0,0 +1,29 @@ +document.addEventListener('DOMContentLoaded', () => { + const checkbox = document.getElementById('nice_urls'); + const out_span = document.getElementById('nicetest'); + + if(checkbox !== null && out_span !== null) { + checkbox.disabled = true; + out_span.innerHTML = '(testing...)'; + + fetch(document.body.getAttribute('data-base-href') + "/nicetest").then(response => { + if(!response.ok) { + checkbox.disabled = true; + out_span.innerHTML = '(http error)'; + } else { + response.text().then(text => { + if(text === 'ok') { + checkbox.disabled = false; + out_span.innerHTML = '(test passed)'; + } else { + checkbox.disabled = true; + out_span.innerHTML = '(test failed)'; + } + }); + } + }).catch(() => { + checkbox.disabled = true; + out_span.innerHTML = '(request failed)'; + }); + } +}); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 32fc0ea1..ec8f9b74 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -19,7 +19,10 @@ require_once "core/sys_config.php"; require_once "core/polyfills.php"; require_once "core/util.php"; +$_SERVER['SCRIPT_FILENAME'] = '/var/www/html/test/index.php'; +$_SERVER['DOCUMENT_ROOT'] = '/var/www/html'; $_SERVER['QUERY_STRING'] = '/'; + if (file_exists("data/test-trace.json")) { unlink("data/test-trace.json"); } diff --git a/tests/defines.php b/tests/defines.php index 9a820285..3d5a9a4c 100644 --- a/tests/defines.php +++ b/tests/defines.php @@ -20,7 +20,6 @@ define("VERSION", 'unit-tests'); define("TRACE_FILE", null); define("TRACE_THRESHOLD", 0.0); define("TIMEZONE", 'UTC'); -define("BASE_HREF", "/test"); define("CLI_LOG_LEVEL", 50); define("STATSD_HOST", null); define("TRUSTED_PROXIES", []); diff --git a/themes/rule34v2/apple-touch-icon-precomposed.png b/themes/rule34v2/apple-touch-icon-precomposed.png deleted file mode 100644 index d9aed471..00000000 Binary files a/themes/rule34v2/apple-touch-icon-precomposed.png and /dev/null differ diff --git a/themes/rule34v2/apple-touch-icon.png b/themes/rule34v2/apple-touch-icon.png deleted file mode 100644 index d9aed471..00000000 Binary files a/themes/rule34v2/apple-touch-icon.png and /dev/null differ diff --git a/themes/rule34v2/default_avatar.png b/themes/rule34v2/default_avatar.png deleted file mode 100644 index 6887a3cf..00000000 Binary files a/themes/rule34v2/default_avatar.png and /dev/null differ diff --git a/themes/rule34v2/flags/china-flag.png b/themes/rule34v2/flags/china-flag.png deleted file mode 100644 index b54e1c73..00000000 Binary files a/themes/rule34v2/flags/china-flag.png and /dev/null differ diff --git a/themes/rule34v2/flags/dutch-flag.png b/themes/rule34v2/flags/dutch-flag.png deleted file mode 100644 index 99d69fde..00000000 Binary files a/themes/rule34v2/flags/dutch-flag.png and /dev/null differ diff --git a/themes/rule34v2/flags/english-flag.png b/themes/rule34v2/flags/english-flag.png deleted file mode 100644 index c171928b..00000000 Binary files a/themes/rule34v2/flags/english-flag.png and /dev/null differ diff --git a/themes/rule34v2/flags/finnish-flag.png b/themes/rule34v2/flags/finnish-flag.png deleted file mode 100644 index eddfdba4..00000000 Binary files a/themes/rule34v2/flags/finnish-flag.png and /dev/null differ diff --git a/themes/rule34v2/flags/german-flag.png b/themes/rule34v2/flags/german-flag.png deleted file mode 100644 index 1b9d04f6..00000000 Binary files a/themes/rule34v2/flags/german-flag.png and /dev/null differ diff --git a/themes/rule34v2/flags/italian-flag.png b/themes/rule34v2/flags/italian-flag.png deleted file mode 100644 index c687ea2b..00000000 Binary files a/themes/rule34v2/flags/italian-flag.png and /dev/null differ diff --git a/themes/rule34v2/flags/norway-flag.png b/themes/rule34v2/flags/norway-flag.png deleted file mode 100644 index 0e9bb5a8..00000000 Binary files a/themes/rule34v2/flags/norway-flag.png and /dev/null differ diff --git a/themes/rule34v2/flags/port-flag.png b/themes/rule34v2/flags/port-flag.png deleted file mode 100644 index b883e280..00000000 Binary files a/themes/rule34v2/flags/port-flag.png and /dev/null differ diff --git a/themes/rule34v2/flags/russian-flag.png b/themes/rule34v2/flags/russian-flag.png deleted file mode 100644 index 95333f6f..00000000 Binary files a/themes/rule34v2/flags/russian-flag.png and /dev/null differ diff --git a/themes/rule34v2/flags/spain-flag.png b/themes/rule34v2/flags/spain-flag.png deleted file mode 100644 index 4c2921f0..00000000 Binary files a/themes/rule34v2/flags/spain-flag.png and /dev/null differ diff --git a/themes/rule34v2/flags/swedish-flag.png b/themes/rule34v2/flags/swedish-flag.png deleted file mode 100644 index b0e4a760..00000000 Binary files a/themes/rule34v2/flags/swedish-flag.png and /dev/null differ diff --git a/themes/rule34v2/header.inc b/themes/rule34v2/header.inc deleted file mode 100644 index 1c85fd24..00000000 --- a/themes/rule34v2/header.inc +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - - - - - - - - - - - -
- - - -
- - -
diff --git a/themes/rule34v2/index.theme.php b/themes/rule34v2/index.theme.php deleted file mode 100644 index 02602f56..00000000 --- a/themes/rule34v2/index.theme.php +++ /dev/null @@ -1,50 +0,0 @@ -can("delete_image") ? "can-del" : ""; - $h_query = html_escape($query); - - $table = "
"; - foreach ($images as $image) { - $table .= $this->build_thumb_html($image); - } - $table .= "
"; - return $table; - } - - // Override to add a custom error message - public function display_page(Page $page, $images): void - { - $this->display_page_header($page, $images); - - $nav = $this->build_navigation($this->page_number, $this->total_pages, $this->search_terms); - if (!empty($this->search_terms)) { - static::$_search_query = $this->search_terms; - } - $page->add_block(new Block("Navigation", $nav, "left", 0)); - - if (count($images) > 0) { - $this->display_page_images($page, $images); - } else { - $this->display_error( - 404, - "No Posts Found", - "No images were found to match the search criteria. Try looking up a character/series/artist by another name if they go by more than one. Remember to use underscores in place of spaces and not to use commas. If you came to this page by following a link, try using the search box directly instead. See the FAQ for more information." - ); - } - } -} diff --git a/themes/rule34v2/menuh.css b/themes/rule34v2/menuh.css deleted file mode 100644 index 1fb96d80..00000000 --- a/themes/rule34v2/menuh.css +++ /dev/null @@ -1,121 +0,0 @@ -/* Begin CSS Drop Down Menu */ - -a:link.menu { color:#FF0000; text-decoration: none; } - -a:visited.menu { color: #FF0000; text-decoration: none; } - -a:hover.menu { color: #FF0000; text-decoration: none; } - -a:active.menu { color: #FF0000; text-decoration: none; } - -#menuh-container - { - font-size: 1rem; - float: left; - top:0; - left: 5%; - width: 100%; - margin: 0; - } - -#menuh - { - font-size: small; - font-family: arial, helvetica, sans-serif; - width:100%; - margin-top: 0; - } - -#menuh a.sub_option - { - border: 1px solid #555; - /*background-image:url(topban.jpg);*/ - } - -#menuh a - { - text-align: center; - background: #ACE4A3; - display:block; - white-space:nowrap; - margin: 0; - padding: 0.2em; - } - -#menuh a, #menuh a:visited /* menu at rest */ - { - color: #000099; - text-decoration:none; - } - -#menuh a:hover /* menu at mouse-over */ - { - color: #000000; - } - -#menuh a.top_parent, #menuh a.top_parent:hover /* attaches down-arrow to all top-parents */ - { - /*background-image: url(navdown_white.gif);*/ - background-position: right center; - background-repeat: no-repeat; - } - -#menuh a.parent, #menuh a.parent:hover /* attaches side-arrow to all parents */ - { - /*background-image: url(nav_white.gif);*/ - background-position: right center; - border: 1px solid #555; - background-repeat: no-repeat; - } - -#menuh ul - { - list-style:none; - margin:0; - padding:0; - float:left; - width:10em; /* width of all menu boxes */ - } - -#menuh li - { - position:relative; - min-height: 1px; /* Sophie Dennis contribution for IE7 */ - vertical-align: bottom; /* Sophie Dennis contribution for IE7 */ - } - -#menuh ul ul - { - position:absolute; - z-index:500; - top:auto; - display:none; - padding: 1em; - margin:-1em 0 0 -1em; - } - -#menuh ul ul ul - { - top:0; - left:100%; - } - -div#menuh li:hover - { - cursor:pointer; - z-index:100; - } - -div#menuh li:hover ul ul, -div#menuh li li:hover ul ul, -div#menuh li li li:hover ul ul, -div#menuh li li li li:hover ul ul -{display:none;} - -div#menuh li:hover ul, -div#menuh li li:hover ul, -div#menuh li li li:hover ul, -div#menuh li li li li:hover ul -{display:block;} - -/* End CSS Drop Down Menu */ diff --git a/themes/rule34v2/page.class.php b/themes/rule34v2/page.class.php deleted file mode 100644 index e11cd76c..00000000 --- a/themes/rule34v2/page.class.php +++ /dev/null @@ -1,136 +0,0 @@ -get_string('theme', 'default'); - $header_html = $this->get_all_html_headers(); - $data_href = get_base_href(); - - return <<{$this->title} - - - - -$header_html - - - - - -EOD; - } - - public function body_html(): string - { - global $config, $user; - - $left_block_html = ""; - $right_block_html = ""; - $main_block_html = ""; - $head_block_html = ""; - $sub_block_html = ""; - - $main_headings = 0; - foreach ($this->blocks as $block) { - if ($block->section == "main" && !empty($block->header) && $block->header != "Comments") { - $main_headings++; - } - } - - foreach ($this->blocks as $block) { - switch ($block->section) { - case "left": - $left_block_html .= $block->get_html(true); - break; - case "right": - $right_block_html .= $block->get_html(true); - break; - case "head": - $head_block_html .= "".$block->get_html(false).""; - break; - case "main": - if ($main_headings == 1) { - $block->header = null; - } - $main_block_html .= $block->get_html(false); - break; - case "subheading": - $sub_block_html .= $block->body; // $block->get_html(true); - break; - default: - print "

error: {$block->header} using an unknown section ({$block->section})"; - break; - } - } - - $query = !empty(CustomIndexTheme::$_search_query) ? html_escape(Tag::implode(CustomIndexTheme::$_search_query)) : ""; - // @phpstan-ignore-next-line - yes this is deliberately asserting a constant - assert(!is_null($query)); # used in header.inc, do not remove :P - $flash_html = $this->flash ? "".nl2br(html_escape(implode("\n", $this->flash)))."" : ""; - $generated = autodate(date('c')); - $footer_html = $this->footer_html(); - - $header_inc = file_get_contents_ex("themes/rule34v2/header.inc"); - assert($header_inc !== false); - $header_inc = str_replace('$QUERY', $query, $header_inc); - return << - - $header_inc - $head_block_html - - - $sub_block_html - -

- -
- $flash_html - - $main_block_html -
- - - - - - -EOD; - } -} diff --git a/themes/rule34v2/prebid-ads.js b/themes/rule34v2/prebid-ads.js deleted file mode 100644 index 59a38482..00000000 --- a/themes/rule34v2/prebid-ads.js +++ /dev/null @@ -1 +0,0 @@ -var canRunAds = true; diff --git a/themes/rule34v2/rule34_logo_christ.png b/themes/rule34v2/rule34_logo_christ.png deleted file mode 100644 index d587f675..00000000 Binary files a/themes/rule34v2/rule34_logo_christ.png and /dev/null differ diff --git a/themes/rule34v2/rule34_logo_halloween.png b/themes/rule34v2/rule34_logo_halloween.png deleted file mode 100644 index 1c9215cc..00000000 Binary files a/themes/rule34v2/rule34_logo_halloween.png and /dev/null differ diff --git a/themes/rule34v2/rule34_logo_top.png b/themes/rule34v2/rule34_logo_top.png deleted file mode 100644 index 98298cb0..00000000 Binary files a/themes/rule34v2/rule34_logo_top.png and /dev/null differ diff --git a/themes/rule34v2/script.js b/themes/rule34v2/script.js deleted file mode 100644 index 7897627b..00000000 --- a/themes/rule34v2/script.js +++ /dev/null @@ -1,48 +0,0 @@ -// Disable things that get in the way of smooth admin'ing -document.addEventListener('DOMContentLoaded', () => { - document.querySelectorAll("input[type='date']").forEach(e => e.setAttribute('type', 'text')); -}); - -// Navbar controls -var navHidden = false; -function toggleNav() { - if(navHidden) { - document.body.classList.remove('navHidden'); - shm_cookie_set("ui-shownav", "true"); - } - else { - document.body.classList.add('navHidden'); - shm_cookie_set("ui-shownav", "false"); - } - navHidden = !navHidden; -} - -document.addEventListener('DOMContentLoaded', () => { - if(shm_cookie_get("ui-shownav") === "false") { - toggleNav(); - } -}); - -// Desktop mode toggle -var forceDesktop = false; -function toggleDesktop() { - if(forceDesktop) { - let viewport = document.querySelector("meta[name=viewport]"); - viewport.setAttribute('content', 'width=512'); - shm_cookie_set("ui-desktop", "false"); - } - else { - let viewport = document.querySelector("meta[name=viewport]"); - viewport.setAttribute('content', 'width=1024, initial-scale=0.4'); - shm_cookie_set("ui-desktop", "true"); - navHidden = true; - toggleNav(); - } - forceDesktop = !forceDesktop; -} - -document.addEventListener('DOMContentLoaded', () => { - if(shm_cookie_get("ui-desktop") === "true") { - toggleDesktop(); - } -}); diff --git a/themes/rule34v2/static/favicon.ico b/themes/rule34v2/static/favicon.ico deleted file mode 100644 index 2ec940d8..00000000 Binary files a/themes/rule34v2/static/favicon.ico and /dev/null differ diff --git a/themes/rule34v2/style.css b/themes/rule34v2/style.css deleted file mode 100644 index 3376c912..00000000 --- a/themes/rule34v2/style.css +++ /dev/null @@ -1,379 +0,0 @@ - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* things common to all pages * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -:root { - font-family: "Arial", sans-serif; - font-size: 14px; -} -BODY { - background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPBAMAAADJ+Ih5AAAAFVBMVEV8und+uXeo5aKo5qOq5aOr46Ks5KN5+6UZAAAAN0lEQVQImWNIc2FLcUhzYWBIczRLEU5zNGBwEQlxdHURCWBwdEkRcXN0SWBgVkswSgMSDDRTDADa2B2AhUf94AAAAABJRU5ErkJggg=='); - margin: 0; -} -#header { - border-bottom: 1px solid #7EB977; - margin-top: 0; - margin-bottom: 16px; - padding: 8px; - background: #ACE4A3; - text-align: center; -} -H1 { - font-size: 5rem; - margin: 0; - padding: 0; -} -H1 A { - color: black; -} -H3 { - text-align: center; - margin: 0; -} -THEAD { - font-weight: bold; -} -TD { - vertical-align: top; - text-align: center; -} - -#flash { - background: #FF7; - display: block; - padding: 8px; - margin: 8px; - border: 1px solid #882; -} - -TABLE.zebra {background: #ACE4A3; border-collapse: collapse; border: 1px solid #7EB977;} -TABLE.zebra TD {font-size: 0.8rem;margin: 0; border-top: 1px solid #7EB977; padding: 2px;} -TABLE.zebra TR:nth-child(odd) {background: #9CD493;} -TABLE.zebra TR:nth-child(even) {background: #ACE4A3;} - -FOOTER { - clear: both; - padding: 8px; - font-size: 0.7rem; - text-align: center; - border-top: 1px solid #7EB977; - background: #ACE4A3; -} - - -A {color: #000099; text-decoration: none; font-weight: bold;} -A:hover {color: #000099; text-decoration: underline;} -A:visited {color: #000099; text-decoration: none} -A:active {color: #000099; text-decoration: underline;} - -UL { - text-align: left; -} - -.ad1{ - display:flex; - justify-content:center; -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* the navigation bar, and all its blocks * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -NAV { - width: 250px; - float: left; - text-align: center; - margin-left: 16px; -} -NAV .blockbody { - font-size: 0.85rem; - text-align: center; -} -NAV TABLE { - width: 100%; -} -NAV TD { - vertical-align: middle; -} -NAV INPUT { - width: 100%; - padding: 0; -} -NAV SELECT { - width: 100%; - padding: 0; -} - -#Friends_of_Pahealleft { - z-index: 0; - position: relative; -} - -.comment .info { - background: #ACE4A3; - border: 1px solid #7EB977; -} - -.more:after { - content: " >>>"; -} - -.tag_count:before { - content: "("; -} -.tag_count:after { - content: ")"; -} - -#imagelist .blockbody, -#paginator .blockbody { - background: none; - border: none; - box-shadow: none; -} - -#commentlistimage .blockbody, -#commentlistrecent .blockbody { - background: none; - border: none; - box-shadow: none; - padding: 0; -} - -#commentlistimage .blockbody .comment, -#commentlistrecent .blockbody .comment { - margin-left: 0; - margin-right: 0; -} - - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* the main part of each page * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -ARTICLE { - margin-left: 276px; - margin-right: 16px; - text-align: center; - height: 1%; - margin-top: 16px; -} -ARTICLE TABLE { - width: 90%; - margin: auto; -} -NAV SECTION:first-child H3 { - margin-top: 0; -} - - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* specific page types * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#pagelist { - margin-top: 32px; -} - -#tagmap A { - padding: 8px 4px 8px 4px; -} - -SECTION>.blockbody, .comment, .setupblock { - background: #ACE4A3; - margin: 8px; - border: 1px solid #7EB977; - padding: 8px; -} - -SECTION>H3 { - text-align: center; - background: #9CD493; - margin: 8px; - border: 1px solid #7EB977; - padding: 8px; -} - -.shm-image-list { - justify-items: center; - align-items: end; -} -.thumb { - text-align: center; -} -.thumb IMG { - border: 1px solid #7EB977; - background: #ACE4A3; - padding: 4px; -} - -.username { - font-weight: bold; -} - -#bans TD, .image_info TD { - vertical-align: middle; -} -#bans INPUT { - font-size: 0.85rem; -} - -.need-del { - display: none; -} -.can-del .need-del { - display: inline; -} - - -.unread { - color: red; -} - -[data-tags~="ai-generated"]>A>IMG { background: #BC8F8F; } -[data-tags~="animated"]>A>IMG { background: #CC00CC; } -[data-ext="mp4"]>A>IMG, -[data-ext="webm"]>A>IMG { background: #0000FF; } - -#menuh-container { - float: none; - width: 650px; - margin: auto; -} - -/* - * Image info - show both edit and view modes at the same time, - * except for Tags, Locked, and the Edit button. - */ -.image_info.infomode-view .edit, -.image_info.infomode-view .view { - display: block; -} -.image_info.infomode-view TR[data-row="Tags"] .view, -.image_info.infomode-view TR[data-row="Locked"] .view, -.image_info INPUT[type="button"][value="Edit"] { - display: none; -} - - - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* responsive overrides * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -@media (max-width: 750px) { - .atoz, #paginator { - font-size: 2rem; - } - .header-sites { - display: none; - } - SECTION>.blockbody { - overflow-x: auto; - } -} - -/* responsive padding */ -@media (max-width: 1024px) { - NAV {margin-left: 0;} - ARTICLE {margin-right: 0; margin-left: 242px;} -} -@media (max-width: 750px) { - NAV {margin-left: 0;} - ARTICLE {margin-right: 0; margin-left: 250px;} -} - -/* responsive navbar */ -#nav-toggle {display: none;} -@media (max-width: 750px) { - TD#nav-toggle {display: table-cell; width: 40px;} - #nav-toggle A {border: 1px solid black; border-radius: 8px;} - #nav-toggle A:hover {text-decoration: none;} - - NAV>SECTION>.blockbody, - NAV>SECTION>.blockbody>.comment { - margin: 0; - } - NAV>SECTION>H3 { - margin: 0; - } - - BODY.navHidden #menuh-container {display: none;} - BODY.navHidden NAV {display: none;} - BODY.navHidden ARTICLE {margin-left: 0;} - -/* - NAV { - position: fixed; - top: 6.5em; - bottom: 0px; - overflow-y: scroll; - } - */ -} - -/* sticky header */ -@media (max-width: 750px) { - BODY.navHidden {padding-top: 5.4em} -} -@media (max-width: 750px) { - #header {position: fixed; top: 0; left: 0; z-index: 99999999999;} - .ui-autocomplete {z-index: 999999999999;} - BODY {padding-top: 7em} -} - -/* responsive header */ -#Uploadleft {display: none;} -#Uploadhead {display: block;} -#UserBlockleft {display: none;} -#UserBlockhead {display: block;} -#Loginleft {display: none;} -#Loginhead {display: block;} -.headcol {width: 250px; font-size: 0.85rem;} -.headbox {width: 80%; margin: auto;} -.headbox INPUT {width: 100%;} -#big-logo {display: table-cell;} -#mini-logo {display: none;} -@media (max-width: 1024px) { - #Uploadleft {display: block;} - #Uploadhead {display: none;} - #UserBlockleft {display: block;} - #UserBlockhead {display: none;} - #Loginleft {display: block;} - #Loginhead {display: none;} - .headcol {display: none;} - .headbox {width: 100%; margin: auto;} - #big-logo {display: none;} - #mini-logo {display: table-cell; width: 100px;} - - /* hide nav-search when header-search is sticky */ - ARTICLE {margin-top: 0;} - #Navigationleft .blockbody {font-size: 1.5rem;} - #Navigationleft .blockbody P, - #Navigationleft .blockbody FORM - {display: none;} -} - -/* responsive comments */ -.comment_list_table {width: 100%;} - -/* responsive misc */ -@media (max-width: 750px) { - #shm-main-image { max-width: 95%; } -} - -#ed91727bc9c7a73fdcec6db562e63151main { - overflow: scroll; -} - -/* front page */ -div#front-page h1 {font-size: 4rem; margin-top: 2em; margin-bottom: 0; text-align: center; border: none; background: none; box-shadow: none; -webkit-box-shadow: none; -moz-box-shadow: none;} -div#front-page {text-align:center;} -.space {margin-bottom: 1em;} -div#front-page div#links a {margin: 0 0.5em;} -div#front-page li {list-style-type: none; margin: 0;} -@media (max-width: 800px) { - div#front-page h1 {font-size: 3rem; margin-top: 0.5em; margin-bottom: 0.5em;} - #counter {display: none;} -} diff --git a/themes/rule34v2/themelet.class.php b/themes/rule34v2/themelet.class.php deleted file mode 100644 index e26ff229..00000000 --- a/themes/rule34v2/themelet.class.php +++ /dev/null @@ -1,53 +0,0 @@ -get("thumb-block:{$image->id}"); - if (!is_null($cached)) { - return rawHTML($cached); - } - - $id = $image->id; - $view_link = make_link('post/view/'.$id); - $image_link = $image->get_image_link(); - $thumb_link = $image->get_thumb_link(); - $tip = $image->get_tooltip(); - $tags = strtolower($image->get_tag_list()); - $ext = strtolower($image->get_ext()); - - // If file is flash or svg then sets thumbnail to max size. - if ($image->get_mime() === MimeType::FLASH || $image->get_mime() === MimeType::SVG) { - $tsize = get_thumbnail_size($config->get_int('thumb_width'), $config->get_int('thumb_height')); - } else { - $tsize = get_thumbnail_size($image->width, $image->height); - } - - $html = DIV( - ['class' => 'shm-thumb thumb', 'data-ext' => $ext, 'data-tags' => $tags, 'data-post-id' => $id], - A( - ['class' => 'shm-thumb-link', 'href' => $view_link], - IMG(['id' => "thumb_$id", 'title' => $tip, 'alt' => $tip, 'height' => $tsize[1], 'width' => $tsize[0], 'src' => $thumb_link, 'loading' => 'lazy']) - ), - BR(), - A(['href' => $image_link], 'File Only'), - SPAN(['class' => 'need-del'], ' - ', A(['href' => '#', 'onclick' => "image_hash_ban($id); return false;"], 'Ban')) - ); - - // cache for ages; will be cleared in ext/index:onImageInfoSet - $cache->set("thumb-block:{$image->id}", (string)$html, rand(43200, 86400)); - - return $html; - } -} diff --git a/themes/rule34v2/upload.theme.php b/themes/rule34v2/upload.theme.php deleted file mode 100644 index 20f3e05a..00000000 --- a/themes/rule34v2/upload.theme.php +++ /dev/null @@ -1,44 +0,0 @@ -add_block(new Block("Upload", $this->build_upload_block(), "head", 20)); - $page->add_block(new Block("Upload", $this->build_upload_block(), "left", 20)); - } - - // override to put the warning in the header - public function display_full(Page $page): void - { - $page->add_block(new Block("Upload", "Disk nearly full, uploads disabled", "head", 20)); - } - - // override to remove small uploader and just show a link to - // the big page - protected function build_upload_block(): HTMLElement - { - return A(["href" => make_link("upload"), "style" => 'font-size: 1.7rem; display: block;'], "Upload"); - } -} diff --git a/themes/rule34v2/user.theme.php b/themes/rule34v2/user.theme.php deleted file mode 100644 index 1c16c0b3..00000000 --- a/themes/rule34v2/user.theme.php +++ /dev/null @@ -1,59 +0,0 @@ - $parts - */ - public function display_user_block(Page $page, User $user, array $parts): void - { - $h_name = html_escape($user->name); - $lines = []; - foreach ($parts as $part) { - if ($part["name"] == "User Options") { - continue; - } - $lines[] = "{$part["name"]}"; - } - if (count($lines) < 6) { - $html = implode("\n
", $lines); - } else { - $html = implode(" | \n", $lines); - } - $page->add_block(new Block("Logged in as $h_name", $html, "head", 90, "UserBlockhead")); - $page->add_block(new Block("Logged in as $h_name", $html, "left", 15, "UserBlockleft")); - } - - // Override to display login block in the head and in the left column - // (with css media queries deciding which one is visible) - public function display_login_block(Page $page): void - { - $page->add_block(new Block("Login", $this->create_login_block(), "head", 90)); - $page->add_block(new Block("Login", $this->create_login_block(), "left", 15)); - } -}