aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2016-05-27 20:37:37 -0400
committerAndrew Manning <tamanning@zoho.com>2016-05-27 20:37:37 -0400
commitca78ebce6d254f244b4c1fbe25eb3aca40b26952 (patch)
tree87f2f1a3dabf9d28d36a5210547e88a9328851fa
parent97e6b7c4ba1938a46ea18d3ef96eba2d6246dab0 (diff)
downloadvolse-hubzilla-ca78ebce6d254f244b4c1fbe25eb3aca40b26952.tar.gz
volse-hubzilla-ca78ebce6d254f244b4c1fbe25eb3aca40b26952.tar.bz2
volse-hubzilla-ca78ebce6d254f244b4c1fbe25eb3aca40b26952.zip
Check if wiki exists and redirect if it does not
-rw-r--r--Zotlabs/Module/Wiki.php7
-rw-r--r--include/wiki.php13
2 files changed, 19 insertions, 1 deletions
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php
index 221068e0a..290c2e005 100644
--- a/Zotlabs/Module/Wiki.php
+++ b/Zotlabs/Module/Wiki.php
@@ -26,6 +26,7 @@ class Wiki extends \Zotlabs\Web\Controller {
}
function get() {
+ require_once('include/wiki.php');
require_once('include/acl_selectors.php');
if(local_channel()) {
$channel = \App::get_channel();
@@ -56,6 +57,10 @@ class Wiki extends \Zotlabs\Web\Controller {
} elseif (argc()<4) {
$wikiheader = 'Empty wiki: ' . rawurldecode(argv(2)); // show wiki name
$hide_editor = true;
+ // Check if wiki exists andr redirect if it does not
+ if(!wiki_exists_by_name(argv(2))['id']) {
+ goaway('/'.argv(0).'/'.argv(1));
+ }
} elseif (argc()<5) {
$wikiheader = rawurldecode(argv(2)) . ': ' . rawurldecode(argv(3)); // show wiki name and page
$hide_editor = false;
@@ -112,7 +117,7 @@ class Wiki extends \Zotlabs\Web\Controller {
// then, use webpage permissions
if (!$perms['write_pages']) {
notice(t('Permission denied.') . EOL);
- goaway(argv(0).'/'.argv(1).'/'.argv(2));
+ goaway('/'.argv(0).'/'.argv(1).'/'.argv(2));
}
}
$name = escape_tags(urlencode($_POST['wikiName'])); //Get new wiki name
diff --git a/include/wiki.php b/include/wiki.php
index 828121ba9..90b30d492 100644
--- a/include/wiki.php
+++ b/include/wiki.php
@@ -124,3 +124,16 @@ function wiki_delete_wiki($resource_id) {
return array('item' => $item, 'success' => (($drop === 1 && $pathdel) ? true : false));
}
}
+
+function wiki_exists_by_name($name) {
+ $item = q("SELECT id FROM item WHERE resource_type = '%s' AND title = '%s' AND item_deleted = 0 limit 1",
+ dbesc(WIKI_ITEM_RESOURCE_TYPE),
+ dbesc($name)
+ );
+ if (!$item) {
+ return array('id' => null);
+ } else {
+ return array('id' => $item[0]['id']);
+ }
+
+} \ No newline at end of file