diff options
-rw-r--r-- | Zotlabs/Module/Wiki.php | 7 | ||||
-rw-r--r-- | include/wiki.php | 13 |
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 |