about summary refs log tree commit diff stats
path: root/wiki/inc/actions.php
diff options
context:
space:
mode:
authorahriman <ahriman@falte.red>2018-12-03 19:22:25 -0500
committerahriman <ahriman@falte.red>2018-12-03 19:22:25 -0500
commit0ae8cbf5c0b1a198b963490985b7738392ebcb97 (patch)
treeb2c77ae72c6b717e2b97492065196ac5ffb2d9e2 /wiki/inc/actions.php
parentf57f6cc5a2d159f90168d292437dc4bd8cd7f934 (diff)
downloadsite-0ae8cbf5c0b1a198b963490985b7738392ebcb97.tar.gz
installed dokuwiki, added to navbar, updated news
Diffstat (limited to 'wiki/inc/actions.php')
-rw-r--r--wiki/inc/actions.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/wiki/inc/actions.php b/wiki/inc/actions.php
new file mode 100644
index 0000000..9ba8878
--- /dev/null
+++ b/wiki/inc/actions.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * DokuWiki Actions
+ *
+ * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author     Andreas Gohr <andi@splitbrain.org>
+ */
+
+if(!defined('DOKU_INC')) die('meh.');
+
+/**
+ * All action processing starts here
+ */
+function act_dispatch(){
+    // always initialize on first dispatch (test request may dispatch mutliple times on one request)
+    $router = \dokuwiki\ActionRouter::getInstance(true);
+
+    $headers = array('Content-Type: text/html; charset=utf-8');
+    trigger_event('ACTION_HEADERS_SEND',$headers,'act_sendheaders');
+
+    // clear internal variables
+    unset($router);
+    unset($headers);
+    // make all globals available to the template
+    extract($GLOBALS);
+
+    include(template('main.php'));
+    // output for the commands is now handled in inc/templates.php
+    // in function tpl_content()
+}
+
+/**
+ * Send the given headers using header()
+ *
+ * @param array $headers The headers that shall be sent
+ */
+function act_sendheaders($headers) {
+    foreach ($headers as $hdr) header($hdr);
+}
+
+/**
+ * Sanitize the action command
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param array|string $act
+ * @return string
+ */
+function act_clean($act){
+    // check if the action was given as array key
+    if(is_array($act)){
+        list($act) = array_keys($act);
+    }
+
+    //remove all bad chars
+    $act = strtolower($act);
+    $act = preg_replace('/[^1-9a-z_]+/','',$act);
+
+    if($act == 'export_html') $act = 'export_xhtml';
+    if($act == 'export_htmlbody') $act = 'export_xhtmlbody';
+
+    if($act === '') $act = 'show';
+    return $act;
+}