1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-22 04:23:01 +00:00

Bugfixes: undefine property protect

This commit is contained in:
Starbeamrainbowlabs 2015-10-03 12:41:35 +01:00
parent 4c93418f85
commit cad2270512
4 changed files with 28 additions and 12 deletions

View file

@ -1055,6 +1055,7 @@ function render_sidebar($pageindex, $root_pagename = "")
error_log("Initialising redirect page support");
register_module([ register_module([
"name" => "Redirect pages", "name" => "Redirect pages",
"version" => "0.1", "version" => "0.1",
@ -1063,6 +1064,7 @@ register_module([
"id" => "feature-redirect", "id" => "feature-redirect",
"code" => function() { "code" => function() {
register_save_preprocessor(function(&$index_entry, &$pagedata) { register_save_preprocessor(function(&$index_entry, &$pagedata) {
error_log("Running redirect check");
$matches = []; $matches = [];
if(preg_match("/^# ?REDIRECT ?\[\[([^\]]+)\]\]/i", $pagedata) === 1) if(preg_match("/^# ?REDIRECT ?\[\[([^\]]+)\]\]/i", $pagedata) === 1)
{ {
@ -1230,10 +1232,11 @@ register_module([
if((!$env->is_logged_in and !$settings->anonedits) or // if we aren't logged in and anonymous edits are disbled if((!$env->is_logged_in and !$settings->anonedits) or // if we aren't logged in and anonymous edits are disbled
!$settings->editing or// or editing is disabled !$settings->editing or// or editing is disabled
( // the page exists and is protected and the user isn't an admin (
isset($pageindex->$page) and isset($pageindex->$page) and // the page exists
$pageindex->$page->protect and isset($pageindex->$page->protect) and // the protect property exists
!$env->is_admin $pageindex->$page->protect and // the protect property is true
!$env->is_admin // the user isn't an admin
) )
) )
{ {
@ -1284,7 +1287,11 @@ register_module([
exit("You are not logged in, so you are not allowed to save pages on $settings->sitename. Redirecting in 5 seconds...."); exit("You are not logged in, so you are not allowed to save pages on $settings->sitename. Redirecting in 5 seconds....");
} }
$page = $env->page; $page = $env->page;
if($pageindex->$page->protect and !$env->is_admin) if((
isset($pageindex->$page) and
isset($pageindex->page->protect) and
$pageindex->$page->protect
) and !$env->is_admin)
{ {
http_response_code(403); http_response_code(403);
header("refresh: 5; url=index.php?page=$env->page"); header("refresh: 5; url=index.php?page=$env->page");

View file

@ -41,7 +41,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds support for redirect pages. Uses the same syntax that Mediawiki does.", "description": "Adds support for redirect pages. Uses the same syntax that Mediawiki does.",
"id": "feature-redirect", "id": "feature-redirect",
"lastupdate": 1443871356, "lastupdate": 1443872212,
"optional": false "optional": false
}, },
{ {
@ -68,7 +68,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.", "description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.",
"id": "page-edit", "id": "page-edit",
"lastupdate": 1443871529, "lastupdate": 1443872342,
"optional": false "optional": false
}, },
{ {

View file

@ -1,4 +1,5 @@
<?php <?php
error_log("Initialising redirect page support");
register_module([ register_module([
"name" => "Redirect pages", "name" => "Redirect pages",
"version" => "0.1", "version" => "0.1",
@ -7,6 +8,7 @@ register_module([
"id" => "feature-redirect", "id" => "feature-redirect",
"code" => function() { "code" => function() {
register_save_preprocessor(function(&$index_entry, &$pagedata) { register_save_preprocessor(function(&$index_entry, &$pagedata) {
error_log("Running redirect check");
$matches = []; $matches = [];
if(preg_match("/^# ?REDIRECT ?\[\[([^\]]+)\]\]/i", $pagedata) === 1) if(preg_match("/^# ?REDIRECT ?\[\[([^\]]+)\]\]/i", $pagedata) === 1)
{ {

View file

@ -39,10 +39,11 @@ register_module([
if((!$env->is_logged_in and !$settings->anonedits) or // if we aren't logged in and anonymous edits are disbled if((!$env->is_logged_in and !$settings->anonedits) or // if we aren't logged in and anonymous edits are disbled
!$settings->editing or// or editing is disabled !$settings->editing or// or editing is disabled
( // the page exists and is protected and the user isn't an admin (
isset($pageindex->$page) and isset($pageindex->$page) and // the page exists
$pageindex->$page->protect and isset($pageindex->$page->protect) and // the protect property exists
!$env->is_admin $pageindex->$page->protect and // the protect property is true
!$env->is_admin // the user isn't an admin
) )
) )
{ {
@ -93,7 +94,11 @@ register_module([
exit("You are not logged in, so you are not allowed to save pages on $settings->sitename. Redirecting in 5 seconds...."); exit("You are not logged in, so you are not allowed to save pages on $settings->sitename. Redirecting in 5 seconds....");
} }
$page = $env->page; $page = $env->page;
if($pageindex->$page->protect and !$env->is_admin) if((
isset($pageindex->$page) and
isset($pageindex->page->protect) and
$pageindex->$page->protect
) and !$env->is_admin)
{ {
http_response_code(403); http_response_code(403);
header("refresh: 5; url=index.php?page=$env->page"); header("refresh: 5; url=index.php?page=$env->page");
@ -135,9 +140,11 @@ register_module([
$pageindex->$page->lasteditor = utf8_encode("anonymous"); $pageindex->$page->lasteditor = utf8_encode("anonymous");
var_dump($save_preprocessors);
// Execute all the preprocessors // Execute all the preprocessors
foreach($save_preprocessors as $func) foreach($save_preprocessors as $func)
{ {
error_log("Executing handler");
$func($pageindex->$page, $pagedata); $func($pageindex->$page, $pagedata);
} }