mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-25 05:22:59 +00:00
Make stats-update accept the site secret as a POST param
This commit is contained in:
parent
dc2aaf2854
commit
a63d83bc34
4 changed files with 72 additions and 1 deletions
|
@ -6866,6 +6866,38 @@ register_module([
|
||||||
return $result;
|
return $result;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Wanted pages
|
||||||
|
statistic_add([
|
||||||
|
"id" => "wanted-pages",
|
||||||
|
"name" => "Wanted Pages",
|
||||||
|
"update" => function($old_stats) {
|
||||||
|
global $pageindex, $env;
|
||||||
|
|
||||||
|
$result = new stdClass(); // completed, value, state
|
||||||
|
$pages = [];
|
||||||
|
foreach($pageindex as $pagename => $pagedata) {
|
||||||
|
$page_content = file_get_contents($env->storage_prefix . $pagedata->filename);
|
||||||
|
preg_match_all("/\[\[([^\]]+)\]\]/", $page_content, $linked_pages);
|
||||||
|
if(count($linked_pages) < 2)
|
||||||
|
continue; // No linked pages here
|
||||||
|
foreach($linked_pages[1] as $linked_page) {
|
||||||
|
// We're only interested in pages that don't exist
|
||||||
|
if(!empty($linked_page)) continue;
|
||||||
|
|
||||||
|
if(empty($pages[$linked_page]))
|
||||||
|
$pages[$linked_page] = 0;
|
||||||
|
$pages[$linked_page]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
arsort($pages);
|
||||||
|
|
||||||
|
$result->value = $pages;
|
||||||
|
$result->completed = true;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
add_help_section("20-parser-default", "Editor Syntax",
|
add_help_section("20-parser-default", "Editor Syntax",
|
||||||
"<p>$settings->sitename's editor uses an extended version of <a href='http://parsedown.org/'>Parsedown</a> to render pages, which is a fantastic open source Github flavoured markdown parser. You can find a quick reference guide on Github flavoured markdown <a href='https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet'>here</a> by <a href='https://github.com/adam-p/'>adam-p</a>, or if you prefer a book <a href='https://www.gitbook.com/book/roachhd/master-markdown/details'>Mastering Markdown</a> by KB is a good read, and free too!</p>
|
"<p>$settings->sitename's editor uses an extended version of <a href='http://parsedown.org/'>Parsedown</a> to render pages, which is a fantastic open source Github flavoured markdown parser. You can find a quick reference guide on Github flavoured markdown <a href='https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet'>here</a> by <a href='https://github.com/adam-p/'>adam-p</a>, or if you prefer a book <a href='https://www.gitbook.com/book/roachhd/master-markdown/details'>Mastering Markdown</a> by KB is a good read, and free too!</p>
|
||||||
<h3>Tips</h3>
|
<h3>Tips</h3>
|
||||||
|
|
|
@ -266,7 +266,7 @@
|
||||||
"author": "Emanuil Rusev & Starbeamrainbowlabs",
|
"author": "Emanuil Rusev & Starbeamrainbowlabs",
|
||||||
"description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.",
|
"description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.",
|
||||||
"id": "parser-parsedown",
|
"id": "parser-parsedown",
|
||||||
"lastupdate": 1489056285,
|
"lastupdate": 1500060122,
|
||||||
"optional": false
|
"optional": false
|
||||||
}
|
}
|
||||||
]
|
]
|
|
@ -26,6 +26,13 @@ register_module([
|
||||||
add_action("stats-update", function() {
|
add_action("stats-update", function() {
|
||||||
global $env, $paths, $settings;
|
global $env, $paths, $settings;
|
||||||
|
|
||||||
|
|
||||||
|
if(!$env->is_admin &&
|
||||||
|
(
|
||||||
|
empty($_POST["secret"]) ||
|
||||||
|
$_POST["secret"] !== $settings->secret
|
||||||
|
)
|
||||||
|
)
|
||||||
if(!$env->is_admin)
|
if(!$env->is_admin)
|
||||||
exit(page_renderer::render_main("Error - Recalculating Statistics - $settings->sitename", "<p>You need to be logged in as a moderator or better to get $settings->sitename to recalculate it's statistics. If you're logged in, try <a href='?action=logout'>logging out</a> and logging in again as a moderator. If you aren't logged in, try <a href='?action=login&returnto=%3Faction%3Dstats-update'>logging in</a>.</p>"));
|
exit(page_renderer::render_main("Error - Recalculating Statistics - $settings->sitename", "<p>You need to be logged in as a moderator or better to get $settings->sitename to recalculate it's statistics. If you're logged in, try <a href='?action=logout'>logging out</a> and logging in again as a moderator. If you aren't logged in, try <a href='?action=login&returnto=%3Faction%3Dstats-update'>logging in</a>.</p>"));
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,38 @@ register_module([
|
||||||
return $result;
|
return $result;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Wanted pages
|
||||||
|
statistic_add([
|
||||||
|
"id" => "wanted-pages",
|
||||||
|
"name" => "Wanted Pages",
|
||||||
|
"update" => function($old_stats) {
|
||||||
|
global $pageindex, $env;
|
||||||
|
|
||||||
|
$result = new stdClass(); // completed, value, state
|
||||||
|
$pages = [];
|
||||||
|
foreach($pageindex as $pagename => $pagedata) {
|
||||||
|
$page_content = file_get_contents($env->storage_prefix . $pagedata->filename);
|
||||||
|
preg_match_all("/\[\[([^\]]+)\]\]/", $page_content, $linked_pages);
|
||||||
|
if(count($linked_pages) < 2)
|
||||||
|
continue; // No linked pages here
|
||||||
|
foreach($linked_pages[1] as $linked_page) {
|
||||||
|
// We're only interested in pages that don't exist
|
||||||
|
if(!empty($linked_page)) continue;
|
||||||
|
|
||||||
|
if(empty($pages[$linked_page]))
|
||||||
|
$pages[$linked_page] = 0;
|
||||||
|
$pages[$linked_page]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
arsort($pages);
|
||||||
|
|
||||||
|
$result->value = $pages;
|
||||||
|
$result->completed = true;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
add_help_section("20-parser-default", "Editor Syntax",
|
add_help_section("20-parser-default", "Editor Syntax",
|
||||||
"<p>$settings->sitename's editor uses an extended version of <a href='http://parsedown.org/'>Parsedown</a> to render pages, which is a fantastic open source Github flavoured markdown parser. You can find a quick reference guide on Github flavoured markdown <a href='https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet'>here</a> by <a href='https://github.com/adam-p/'>adam-p</a>, or if you prefer a book <a href='https://www.gitbook.com/book/roachhd/master-markdown/details'>Mastering Markdown</a> by KB is a good read, and free too!</p>
|
"<p>$settings->sitename's editor uses an extended version of <a href='http://parsedown.org/'>Parsedown</a> to render pages, which is a fantastic open source Github flavoured markdown parser. You can find a quick reference guide on Github flavoured markdown <a href='https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet'>here</a> by <a href='https://github.com/adam-p/'>adam-p</a>, or if you prefer a book <a href='https://www.gitbook.com/book/roachhd/master-markdown/details'>Mastering Markdown</a> by KB is a good read, and free too!</p>
|
||||||
<h3>Tips</h3>
|
<h3>Tips</h3>
|
||||||
|
|
Loading…
Reference in a new issue