Merge branch 'branch-2.10'
This commit is contained in:
@@ -117,7 +117,7 @@ class ExtManager extends Extension
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, bool> $settings
|
||||
* @param array<string, mixed> $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;
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shimmie2;
|
||||
|
||||
class Rule34Info extends ExtensionInfo
|
||||
{
|
||||
public const KEY = "rule34";
|
||||
|
||||
public string $key = self::KEY;
|
||||
public string $name = "Rule34 Customisations";
|
||||
public string $url = self::SHIMMIE_URL;
|
||||
public array $authors = self::SHISH_AUTHOR;
|
||||
public string $license = self::LICENSE_GPLV2;
|
||||
public string $description = "Extra site-specific bits";
|
||||
public ?string $documentation =
|
||||
"Probably not much use to other sites, but it gives a few examples of how a shimmie-based site can be integrated with other systems";
|
||||
public array $db_support = [DatabaseDriverID::PGSQL]; # Only PG has the NOTIFY pubsub system
|
||||
public ExtensionVisibility $visibility = ExtensionVisibility::HIDDEN;
|
||||
}
|
@@ -1,123 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shimmie2;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
use Symfony\Component\Console\Input\{InputInterface,InputArgument};
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
if (
|
||||
// kill these glitched requests immediately
|
||||
!empty($_SERVER["REQUEST_URI"])
|
||||
&& str_contains(@$_SERVER["REQUEST_URI"], "/http")
|
||||
&& str_contains(@$_SERVER["REQUEST_URI"], "paheal.net")
|
||||
) {
|
||||
die("No");
|
||||
}
|
||||
|
||||
class Rule34 extends Extension
|
||||
{
|
||||
public function onImageDeletion(ImageDeletionEvent $event): void
|
||||
{
|
||||
global $database;
|
||||
$database->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 .= "<textarea type='text' name='hash' placeholder='Enter image URL or hash' cols='80' rows='5'></textarea>";
|
||||
$html .= "<br><input type='submit' value='Purge from caches'>";
|
||||
$html .= "</form>\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("<meta name='theme-color' content='#7EB977'>");
|
||||
$page->add_html_header("<meta name='juicyads-site-verification' content='20d309e193510e130c3f8a632f281335'>");
|
||||
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
let tnc_div = document.createElement('div');
|
||||
tnc_div.innerHTML = `
|
||||
<div class='tnc_bg'></div>
|
||||
<div class='tnc'>
|
||||
<p>Cookies may be used. Please read our <a href='https://rule34.paheal.net/wiki/Privacy%20policy'>privacy policy</a> for more information.
|
||||
<p>By accepting to enter you agree to our <a href='https://rule34.paheal.net/wiki/rules'>rules</a> and <a href='https://rule34.paheal.net/wiki/Terms%20of%20use'>terms of service</a>.
|
||||
<p><a onclick='tnc_agree();'>Agree</a> / <a href='https://google.com'>Disagree</a>
|
||||
</div>
|
||||
`;
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -355,30 +355,6 @@ class Setup extends Extension
|
||||
$themes[$human] = $name;
|
||||
}
|
||||
|
||||
$test_url = str_replace("/index.php", "/nicetest", $_SERVER["SCRIPT_NAME"]);
|
||||
|
||||
$nicescript = "<script type='text/javascript'>
|
||||
checkbox = document.getElementById('nice_urls');
|
||||
out_span = document.getElementById('nicetest');
|
||||
|
||||
checkbox.disabled = true;
|
||||
out_span.innerHTML = '(testing...)';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
var http_request = new XMLHttpRequest();
|
||||
http_request.open('GET', '$test_url', false);
|
||||
http_request.send(null);
|
||||
|
||||
if(http_request.status === 200 && http_request.responseText === 'ok') {
|
||||
checkbox.disabled = false;
|
||||
out_span.innerHTML = '(tested ok)';
|
||||
}
|
||||
else {
|
||||
checkbox.disabled = true;
|
||||
out_span.innerHTML = '(test failed)';
|
||||
}
|
||||
});
|
||||
</script>";
|
||||
$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, "<br>Theme: ");
|
||||
//$sb->add_multichoice_option("testarray", array("a" => "b", "c" => "d"), "<br>Test Array: ");
|
||||
$sb->add_bool_option("nice_urls", "<br>Nice URLs: ");
|
||||
$sb->add_label("<span title='$test_url' id='nicetest'>(Javascript inactive, can't test!)</span>$nicescript");
|
||||
$sb->add_label("<span id='nicetest'>(Javascript inactive, can't test!)</span>");
|
||||
|
||||
$sb = $event->panel->create_new_block("Remote API Integration");
|
||||
$sb->add_label("<a href='https://akismet.com/'>Akismet</a>");
|
||||
|
29
ext/setup/script.js
Normal file
29
ext/setup/script.js
Normal file
@@ -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)';
|
||||
});
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user