示例#1
0
 /**
  * Handles input from the newform and redirects to the edit mode
  *
  * @author Andreas Gohr <*****@*****.**>
  * @author Gina Haeussge <*****@*****.**>
  *
  * @param Doku_Event $event  event object by reference
  * @param array      $param  empty array as passed to register_hook()
  * @return bool
  */
 function handle_act_preprocess(Doku_Event $event, $param)
 {
     global $TEXT;
     global $ID;
     if ($event->data != 'btngnew') {
         return true;
     }
     /** @var helper_plugin_blogtng_tools $tools */
     $tools = plugin_load('helper', 'blogtng_tools');
     if (!$tools->getParam('new/title')) {
         msg($this->getLang('err_notitle'), -1);
         $event->data = 'show';
         return true;
     }
     $event->preventDefault();
     $new = $tools->mkpostid($tools->getParam('new/format'), $tools->getParam('new/title'));
     if ($ID != $new) {
         $urlparams = array('do' => 'btngnew', 'btng[post][blog]' => $tools->getParam('post/blog'), 'btng[post][tags]' => $tools->getParam('post/tags'), 'btng[post][commentstatus]' => $tools->getParam('post/commentstatus'), 'btng[new][format]' => $tools->getParam('new/format'), 'btng[new][title]' => $tools->getParam('new/title'));
         send_redirect(wl($new, $urlparams, true, '&'));
         return false;
         //never reached
     } else {
         $TEXT = $this->_prepare_template($new, $tools->getParam('new/title'));
         $event->data = 'preview';
         return false;
     }
 }
示例#2
0
 /**
  * @param Doku_Event$event
  * @param $param
  */
 public function ajax(Doku_Event $event, $param)
 {
     if ($event->data !== 'bureaucracy_user_field') {
         return;
     }
     $event->stopPropagation();
     $event->preventDefault();
     $search = $_REQUEST['search'];
     /** @var DokuWiki_Auth_Plugin $auth */
     global $auth;
     $users = array();
     foreach ($auth->retrieveUsers() as $username => $data) {
         if ($search === '' || stripos($username, $search) === 0 || stripos($data['name'], $search) !== false) {
             // Full name
             $users[$username] = $data['name'];
         }
         if (count($users) === 10) {
             break;
         }
     }
     if (count($users) === 1 && key($users) === $search) {
         $users = array();
     }
     require_once DOKU_INC . 'inc/JSON.php';
     $json = new JSON();
     echo $json->encode($users);
 }
示例#3
0
 /**
  * @param Doku_Event $event  event object by reference
  * @param array      $param  empty array as passed to register_hook()
  */
 function handle_ajax_call(Doku_Event $event, $param)
 {
     /** @var DokuWiki_Auth_Plugin $auth */
     global $auth;
     if ($event->data != 'blogtng__comment_preview') {
         return;
     }
     $event->preventDefault();
     $event->stopPropagation();
     require_once DOKU_PLUGIN . 'blogtng/helper/comments.php';
     $comment = new blogtng_comment();
     $comment->data['text'] = $_REQUEST['text'];
     $comment->data['name'] = $_REQUEST['name'];
     $comment->data['mail'] = $_REQUEST['mail'];
     $comment->data['web'] = isset($_REQUEST['web']) ? $_REQUEST['web'] : '';
     $comment->data['cid'] = 'preview';
     $comment->data['created'] = time();
     $comment->data['status'] = 'visible';
     if (!$comment->data['name'] && $_SERVER['REMOTE_USER']) {
         if ($auth and $info = $auth->getUserData($_SERVER['REMOTE_USER'])) {
             $comment->data['name'] = $info['name'];
             $comment->data['mail'] = $info['mail'];
         }
     }
     $comment->output($_REQUEST['tplname']);
 }
 /**
  * [Custom event handler which performs action]
  *
  * @param Doku_Event $event event object by reference
  * @param mixed $param [the parameters passed as fifth argument to register_hook() when this
  *                           handler was registered]
  * @return void
  */
 public function handle_auth_user_change(Doku_Event &$event, $param)
 {
     if ($event->data['type'] !== 'create') {
         return;
     }
     $domains = array_map(function ($domain) {
         return trim($domain);
     }, explode(';', $this->getConf('_domainWhiteList')));
     $email = $event->data['params'][3];
     $checks = array(in_array(trim(substr(strrchr($email, "@"), 1)), $domains), (bool) preg_match($this->getConf('_emailRegex', '/@/'), $email));
     if ($this->getConf('checksAnd', true)) {
         $status = array_reduce($checks, function ($a, $b) {
             return $a && $b;
         }, true);
     } else {
         $status = array_reduce($checks, function ($a, $b) {
             return $a || $b;
         }, false);
     }
     if (!$status) {
         $event->preventDefault();
         $event->stopPropagation();
         $event->result = false;
         msg($this->getConf('_domainlistErrorMEssage'), -1);
     }
 }
示例#5
0
 /**
  * Gets the thumbnail
  *
  * @param Doku_Event $event  event object by reference
  * @param mixed      $param  [the parameters passed as fifth argument to register_hook() when this
  *                           handler was registered]
  * @return void
  */
 public function handle_do_action(Doku_Event &$event, $param)
 {
     if ($event->data !== 'obsaudioupload_frame_thumbnail') {
         return;
     }
     //no other ajax call handlers needed
     $event->stopPropagation();
     $event->preventDefault();
     // get the url of the image to make into a thumbnail
     $url = $GLOBALS['INPUT']->str('img');
     $imageInfo = getimagesize($url);
     // 0=width, 1=height, 2=format
     if ($imageInfo[2] == IMG_PNG) {
         $img = imagecreatefrompng($url);
     } else {
         $img = imagecreatefromjpeg($url);
     }
     $newHeight = 50;
     $newWidth = (int) ($imageInfo[0] * $newHeight / $imageInfo[1]);
     $newImg = imagecreatetruecolor($newWidth, $newHeight);
     imagecopyresized($newImg, $img, 0, 0, 0, 0, $newWidth, $newHeight, $imageInfo[0], $imageInfo[1]);
     // output
     header('Content-Type: application/jpeg');
     imagejpeg($newImg, null, 60);
     exit;
 }
 public function onAjaxCallUnknown(\Doku_Event $event, $action)
 {
     if ($event->data != 'yk') {
         return;
     }
     // skip if not our plugin
     $do = $this->G['INPUT']->post->str('action', '');
     if ($action !== $do) {
         return;
         // not match. skip this, continue with another
     }
     $event->preventDefault();
     // what does it do?
     $event->stopPropagation();
     //our hooker found, skip others
     $pageId = $this->G['INPUT']->post->str('id', '');
     $pageNewId = $this->G['INPUT']->post->str('new_page_id', null);
     $json = new \stdClass();
     $json->error = false;
     try {
         $this->logger(strtoupper($do), 'PAGE ' . $pageId);
         $json->result = $this->doAction($pageId, $pageNewId);
         $this->logger('SUCCESS');
     } catch (\Exception $e) {
         $json->error = date('H:i:s') . ' ' . $e->getMessage();
         $this->logger('ERROR', $e->getMessage());
     }
     //header('Content-Type: application/json');
     echo json_encode($json);
 }
 /**
  * Step up
  *
  * @param Doku_Event $event
  */
 public function handle_ajax(Doku_Event $event)
 {
     if ($event->data != 'plugin_move_progress') {
         return;
     }
     $event->preventDefault();
     $event->stopPropagation();
     global $INPUT;
     global $USERINFO;
     if (!auth_ismanager($_SERVER['REMOTE_USER'], $USERINFO['grps'])) {
         http_status(403);
         exit;
     }
     $return = array('error' => '', 'complete' => false, 'progress' => 0);
     /** @var helper_plugin_move_plan $plan */
     $plan = plugin_load('helper', 'move_plan');
     if (!$plan->isCommited()) {
         // There is no plan. Something went wrong
         $return['complete'] = true;
     } else {
         $todo = $plan->nextStep($INPUT->bool('skip'));
         $return['progress'] = $plan->getProgress();
         $return['error'] = $plan->getLastError();
         if ($todo === 0) {
             $return['complete'] = true;
         }
     }
     $json = new JSON();
     header('Content-Type: application/json');
     echo $json->encode($return);
 }
示例#8
0
 /**
  * Rename a single page
  */
 public function handle_ajax(Doku_Event $event)
 {
     if ($event->data != 'plugin_move_rename') {
         return;
     }
     $event->preventDefault();
     $event->stopPropagation();
     global $MSG;
     global $INPUT;
     $src = cleanID($INPUT->str('id'));
     $dst = cleanID($INPUT->str('newid'));
     /** @var helper_plugin_move_op $MoveOperator */
     $MoveOperator = plugin_load('helper', 'move_op');
     $JSON = new JSON();
     header('Content-Type: application/json');
     if ($this->renameOkay($src) && $MoveOperator->movePage($src, $dst)) {
         // all went well, redirect
         echo $JSON->encode(array('redirect_url' => wl($dst, '', true, '&')));
     } else {
         if (isset($MSG[0])) {
             $error = $MSG[0];
             // first error
         } else {
             $error = $this->getLang('cantrename');
         }
         echo $JSON->encode(array('error' => $error));
     }
 }
示例#9
0
 /**
  * Create the detail info for a single plugin
  *
  * @param Doku_Event $event
  * @param            $param
  */
 public function info(Doku_Event &$event, $param)
 {
     global $USERINFO;
     global $INPUT;
     if ($event->data != 'plugin_extension') {
         return;
     }
     $event->preventDefault();
     $event->stopPropagation();
     if (empty($_SERVER['REMOTE_USER']) || !auth_isadmin($_SERVER['REMOTE_USER'], $USERINFO['grps'])) {
         http_status(403);
         echo 'Forbidden';
         exit;
     }
     header('Content-Type: text/html; charset=utf-8');
     $ext = $INPUT->str('ext');
     if (!$ext) {
         echo 'no extension given';
         return;
     }
     /** @var helper_plugin_extension_extension $extension */
     $extension = plugin_load('helper', 'extension_extension');
     $extension->setExtension($ext);
     /** @var helper_plugin_extension_list $list */
     $list = plugin_load('helper', 'extension_list');
     echo $list->make_info($extension);
 }
示例#10
0
 /**
  * @param Doku_Event $event  event object by reference
  * @param mixed      $param  [the parameters passed as fifth argument to register_hook() when this
  *                           handler was registered]
  * @return void
  */
 public function handle_ajax_call_unknown(Doku_Event &$event, $param)
 {
     if ($event->data !== 'tagapi_list') {
         return;
     }
     $event->stopPropagation();
     $event->preventDefault();
     if ($this->tagplugin = $this->loadHelper('tag')) {
         $tags = $this->tagplugin->tagOccurrences(array(), NULL, true);
         $a = print_r($tags, true);
         // file_put_contents(DOKU_INC . 'tags.txt', $a);
     } else {
         $tags = array();
     }
     // sort tags by name ($tags is in the form $tag => $count)
     ksort($tags);
     echo '{"tags":[';
     $firstelement = true;
     foreach (array_keys($tags) as $tag) {
         if ($firstelement) {
             $firstelement = false;
         } else {
             echo ',';
         }
         echo '{"name":"' . $this->tagToName($tag) . '","id":"' . $tag . '"}';
     }
     echo ']}';
 }
 /**
  * Load a whole schema as fields
  *
  * @param Doku_Event $event event object by reference
  * @param mixed $param [the parameters passed as fifth argument to register_hook() when this
  *                           handler was registered]
  * @return bool
  */
 public function handle_schema(Doku_Event $event, $param)
 {
     $args = $event->data['args'];
     if ($args[0] != 'struct_schema') {
         return false;
     }
     $event->preventDefault();
     $event->stopPropagation();
     /** @var helper_plugin_bureaucracy_field $helper */
     $helper = plugin_load('helper', 'bureaucracy_field');
     $helper->initialize($args);
     $schema = new Schema($helper->opt['label']);
     if (!$schema->getId()) {
         msg('This schema does not exist', -1);
         return false;
     }
     foreach ($schema->getColumns(false) as $column) {
         /** @var helper_plugin_struct_field $field */
         $field = plugin_load('helper', 'struct_field');
         // we don't initialize the field but set the appropriate values
         $field->opt = $helper->opt;
         // copy all the settings to each field
         $field->opt['label'] = $column->getFullQualifiedLabel();
         $field->column = $column;
         $event->data['fields'][] = $field;
     }
     return true;
 }
示例#12
0
 /**
  * Display the tag page
  *
  * @param Doku_Event $event The TPL_ACT_UNKNOWN event
  * @param array      $param optional parameters (unused)
  */
 function _handle_tpl_act(Doku_Event &$event, $param)
 {
     global $lang;
     if ($event->data != 'showtag') {
         return;
     }
     $event->preventDefault();
     $tagns = $this->getConf('namespace');
     $flags = explode(',', str_replace(" ", "", $this->getConf('pagelist_flags')));
     $tag = trim(str_replace($this->getConf('namespace') . ':', '', $_REQUEST['tag']));
     $ns = trim($_REQUEST['ns']);
     /* @var helper_plugin_tag $helper */
     if ($helper = $this->loadHelper('tag')) {
         $pages = $helper->getTopic($ns, '', $tag);
     }
     if (!empty($pages)) {
         // let Pagelist Plugin do the work for us
         if (!($pagelist = $this->loadHelper('pagelist'))) {
             return false;
         }
         /* @var helper_plugin_pagelist $pagelist */
         $pagelist->setFlags($flags);
         $pagelist->startList();
         foreach ($pages as $page) {
             $pagelist->addPage($page);
         }
         print '<h1>TAG: ' . hsc(str_replace('_', ' ', $_REQUEST['tag'])) . '</h1>' . DOKU_LF;
         print '<div class="level1">' . DOKU_LF;
         print $pagelist->finishList();
         print '</div>' . DOKU_LF;
     } else {
         print '<div class="level1"><p>' . $lang['nothingfound'] . '</p></div>';
     }
 }
示例#13
0
 /**
  * Hook js script into page headers.
  *
  * @author Samuele Tognini <*****@*****.**>
  */
 public function _handle_before(Doku_Event $event, $param)
 {
     $act = act_clean($event->data);
     if ($act != 'diff') {
         return;
     }
     $event->preventDefault();
     revisionsfull_html_diff();
 }
 /**
  * @param Doku_Event $event  event object by reference
  * @param mixed      $param  [the parameters passed as fifth argument to register_hook() when this
  *                           handler was registered]
  * @return void
  */
 public function handle_register_action(Doku_Event &$event, $param)
 {
     if ($event->data !== 'register') {
         return;
     }
     //no other action handlers needed
     $event->stopPropagation();
     $event->preventDefault();
     $this->override_html_register();
 }
示例#15
0
 /**
  * @param Doku_Event $event  event object by reference
  * @param mixed      $param  [the parameters passed as fifth argument to register_hook() when this
  *                           handler was registered]
  * @return void
  */
 public function handle_ajax_call_unknown(Doku_Event &$event, $param)
 {
     if ($event->data !== 'iwiki_list') {
         return;
     }
     $event->stopPropagation();
     $event->preventDefault();
     $a = getInterwiki();
     ksort($a);
     echo json_encode($a);
 }
示例#16
0
 /**
  * Handler to load page template.
  *
  * @param Doku_Event $event  event object by reference
  * @param mixed      $param  [the parameters passed as fifth argument to register_hook() when this
  *                           handler was registered]
  * @return void
  */
 public function get_template(Doku_Event &$event, $param)
 {
     if (strlen($_REQUEST['copyfrom']) > 0) {
         $template_id = $_REQUEST['copyfrom'];
         if (auth_quickaclcheck($template_id) >= AUTH_READ) {
             $tpl = io_readFile(wikiFN($template_id));
             $event->data['tpl'] = $tpl;
             $event->preventDefault();
         }
     }
 }
示例#17
0
 /**
  * Handle the event
  */
 public function handle_tpl_content_display(Doku_Event &$event, $param)
 {
     global $ACT;
     # If user is not logged in and access to page is denied, show login form
     if ($ACT == 'denied' && !$_SERVER['REMOTE_USER']) {
         $event->preventDefault();
         // prevent "Access denied" page from showing
         html_login();
         // show login dialog instead
     }
     # .. or show regular access denied page
 }
示例#18
0
 /**
  *
  * @param Doku_Event $event  event object by reference
  * @param mixed      $param  [the parameters passed as fifth argument to register_hook() when this
  *                           handler was registered]
  * @return void
  */
 public function handle_ajax_call(Doku_Event &$event, $param)
 {
     // do we have a handler defined for this call?
     if (empty($this->handlers[$event->data])) {
         return;
     }
     //no other ajax call handlers needed
     $event->stopPropagation();
     $event->preventDefault();
     $handler = $this->handlers[$event->data];
     $handler[0]->{$handler}[1]($event);
 }
示例#19
0
 /**
  * Ajax handler
  */
 function _ajax_call(Doku_Event $event, $param)
 {
     if ($event->data !== 'plugin_textvar') {
         return;
     }
     $event->stopPropagation();
     $event->preventDefault();
     $json = new JSON();
     $data = array('%SERVER_ADDR%' => $_SERVER['SERVER_ADDR'], '%REMOTE_ADDR%' => $_SERVER['REMOTE_ADDR']);
     header('Content-Type: application/json');
     echo $json->encode($data);
 }
示例#20
0
 /**
  * Analyze the next chunk of data
  *
  * @param Doku_Event $event
  * @param $param
  */
 function handle_run(&$event, $param)
 {
     echo "logfile analysis started.\n";
     /** @var $log helper_plugin_statdisplay_log */
     $log = plugin_load('helper', 'statdisplay_log');
     $lines = $log->parseLogData();
     // did we do any work?
     if ($lines) {
         $event->preventDefault();
         $event->stopPropagation();
     }
     echo "logfile analysis finished analyzing {$lines} lines.\n";
 }
示例#21
0
 public function handle_ajax_call_unknown(Doku_Event &$event, $param)
 {
     if ($event->data != 'plugin_imgpaste') {
         return;
     }
     global $lang;
     // get data
     global $INPUT;
     $data = $INPUT->post->str('data');
     list($type, $data) = explode(';', $data);
     if (!$data) {
         $this->fail(400, $this->getLang('e_nodata'));
     }
     // process data encoding
     $type = strtolower(substr($type, 5));
     // strip 'data:' prefix
     $data = substr($data, 7);
     // strip 'base64,' prefix
     $data = base64_decode($data);
     // check for supported mime type
     $mimetypes = array_flip(getMimeTypes());
     if (!isset($mimetypes[$type])) {
         $this->fail(415, $lang['uploadwrong']);
     }
     // prepare file names
     $tempname = $this->storetemp($data);
     $filename = $this->getConf('filename');
     $filename = str_replace(array('@NS@', '@ID@', '@USER@'), array(getNS($INPUT->post->str('id')), $INPUT->post->str('id'), $_SERVER['REMOTE_USER']), $filename);
     $filename = strftime($filename);
     $filename .= '.' . $mimetypes[$type];
     $filename = cleanID($filename);
     // check ACLs
     $auth = auth_quickaclcheck($filename);
     if ($auth < AUTH_UPLOAD) {
         $this->fail(403, $lang['uploadfail']);
     }
     // do the actual saving
     $result = media_save(array('name' => $tempname, 'mime' => $type, 'ext' => $mimetypes[$type]), $filename, false, $auth, 'copy');
     if (is_array($result)) {
         $this->fail(500, $result[0]);
     }
     //Still here? We had a successful upload
     $this->clean();
     header('Content-Type: application/json');
     $json = new JSON();
     echo $json->encode(array('message' => $lang['uploadsucc'], 'id' => $result));
     $event->preventDefault();
     $event->stopPropagation();
 }
示例#22
0
 /**
  * Handle section edit buttons, prevents section buttons inside the wrap plugin from being rendered
  *
  * @param Doku_Event $event The event object
  * @param array      $args Parameters for the event
  */
 public function handle_secedit_button($event, $args)
 {
     // counter of the number of currently opened wraps
     static $wraps = 0;
     $data = $event->data;
     if ($data['target'] == 'plugin_wrap_start') {
         ++$wraps;
     } elseif ($data['target'] == 'plugin_wrap_end') {
         --$wraps;
     } elseif ($wraps > 0 && $data['target'] == 'section') {
         $event->preventDefault();
         $event->stopPropagation();
         $event->result = '';
     }
 }
示例#23
0
 /**
  * [Custom event handler which performs action]
  *
  * @param Doku_Event $event event object by reference
  * @param mixed $param [the parameters passed as fifth argument to register_hook() when this
  *                           handler was registered]
  * @return void
  */
 public function handle_ajax_call_unknown(Doku_Event &$event, $param)
 {
     if ($event->data != 'rating') {
         return;
     }
     $event->preventDefault();
     $event->stopPropagation();
     global $ID;
     $ID = getID();
     // let the other handler do it
     $this->handle_vote($event, $param);
     /** @var helper_plugin_rating $hlp */
     $hlp = plugin_load('helper', 'rating');
     $hlp->tpl(true);
 }
示例#24
0
 public function check_spammer_database(Doku_Event $event, $param)
 {
     $can_modify = true;
     if ($event->data['type'] == 'create') {
         $username = $event->data['params'][0];
         $email = $event->data['params'][3];
         $ip = $_SERVER['REMOTE_ADDR'];
         $response = $this->do_check($username, $email, $ip);
         if ($this->checker->userIsValid($response) === false) {
             msg('Potentially a spammer', -1);
             $event->preventDefault();
         }
         $this->logger->LogAttempt($username, $email, $ip, $this->checker->trigger, $this->checker->confidence, $this->checker->accepted);
     }
 }
示例#25
0
 function _action_act_preprocess(Doku_Event $event, $param)
 {
     global $ACT;
     global $INFO;
     if (!is_array($event->data) || !array_key_exists('changes', $event->data)) {
         return;
     }
     if ('preview' == act_permcheck('preview') && 'preview' == act_draftsave('preview') && $INFO['editable'] && 'preview' == act_edit('preview')) {
         $ACT = 'changes';
         $event->stoppropagation();
         $event->preventDefault();
         $this->_change_headers = true;
     } else {
         $ACT = 'preview';
     }
 }
示例#26
0
 /**
  * Reconfigure config for a given type
  *
  * @param Doku_Event $event event object by reference
  * @param mixed $param [the parameters passed as fifth argument to register_hook() when this
  *                           handler was registered]
  */
 public function handle_ajax(Doku_Event $event, $param)
 {
     if ($event->data != 'plugin_struct_config') {
         return;
     }
     $event->preventDefault();
     $event->stopPropagation();
     global $INPUT;
     $conf = json_decode($INPUT->str('conf'), true);
     /** @var AbstractBaseType $type */
     $class = 'dokuwiki\\plugin\\struct\\types\\' . $INPUT->str('type', 'Text');
     $type = new $class($conf);
     header('Content-Type: text/plain');
     // we need the encoded string, not decoded by jQuery
     echo json_encode($type->getConfig());
 }
示例#27
0
 /**
  * Intercept the usual page display and replace it with a
  * blog template controlled one.
  *
  * @param Doku_Event $event  event object by reference
  * @param array      $param  empty array as passed to register_hook()
  * @return void|bool
  */
 function handle_tpl_act_render(Doku_Event $event, $param)
 {
     global $ID;
     if ($event->data != 'show') {
         return false;
     }
     $pid = md5($ID);
     $this->entryhelper->load_by_pid($pid);
     if ($this->entryhelper->get_blog() == '') {
         return true;
     }
     // we can handle it
     $event->preventDefault();
     $this->commenthelper->setPid($pid);
     $this->entryhelper->tpl_content($this->entryhelper->entry['blog'], 'entry');
     return true;
 }
示例#28
0
 /**
  * Check for pages changes and eventually purge cache.
  *
  * @author Samuele Tognini <*****@*****.**>
  *
  * @param Doku_Event $event
  * @param mixed      $param not defined
  */
 function _purgecache(&$event, $param)
 {
     global $ID;
     global $conf;
     /** @var cache_parser $cache */
     $cache =& $event->data;
     if (!isset($cache->page)) {
         return;
     }
     //purge only xhtml cache
     if ($cache->mode != "xhtml") {
         return;
     }
     //Check if it is an pagequery page
     if (!p_get_metadata($ID, 'pagequery')) {
         return;
     }
     $aclcache = $this->getConf('aclcache');
     if ($conf['useacl']) {
         $newkey = false;
         if ($aclcache == 'user') {
             //Cache per user
             if ($_SERVER['REMOTE_USER']) {
                 $newkey = $_SERVER['REMOTE_USER'];
             }
         } else {
             if ($aclcache == 'groups') {
                 //Cache per groups
                 global $INFO;
                 if ($INFO['userinfo']['grps']) {
                     $newkey = implode('#', $INFO['userinfo']['grps']);
                 }
             }
         }
         if ($newkey) {
             $cache->key .= "#" . $newkey;
             $cache->cache = getCacheName($cache->key, $cache->ext);
         }
     }
     //Check if a page is more recent than purgefile.
     if (@filemtime($cache->cache) < @filemtime($conf['cachedir'] . '/purgefile')) {
         $event->preventDefault();
         $event->stopPropagation();
         $event->result = false;
     }
 }
示例#29
0
 /**
  * @param Doku_Event $event
  * @param array $param
  */
 function hide(Doku_Event &$event, $param)
 {
     if (!$this->hlp->isActive()) {
         return;
     }
     if (!$this->hlp->isHiddenForUser()) {
         return;
     }
     global $ACT;
     if (!in_array($ACT, array('show', 'edit', 'source', 'diff'))) {
         return;
     }
     $ACT = 'denied';
     $event->preventDefault();
     $event->stopPropagation();
     print p_locale_xhtml('denied');
 }
 /**
  * 
  *
  * @param Doku_Event $event  Not used
  * @param mixed      $param  Not used
  * @return void
  */
 public function handle(Doku_Event &$event, $param)
 {
     global $conf;
     if ($event->data != 'feedaggregator') {
         return;
     }
     $event->preventDefault();
     // See if we need a token and whether it matches.
     $requiredToken = $this->getConf('token');
     $suppliedToken = isset($_GET['token']) ? $_GET['token'] : false;
     if (!empty($requiredToken) && $suppliedToken !== $requiredToken) {
         msg("Token doesn't match for feedaggregator");
         return true;
     }
     // Get the feed list.
     $feeds = file(fullpath($conf['tmpdir'] . '/feedaggregator.csv'));
     // Set up SimplePie and merge all the feeds together.
     $simplepie = new FeedParser();
     $ua = 'Mozilla/4.0 (compatible; DokuWiki feedaggregator plugin ' . wl('', '', true) . ')';
     $simplepie->set_useragent($ua);
     $simplepie->force_feed($this->getConf('force_feed'));
     $simplepie->force_fsockopen($this->getConf('force_fsockopen'));
     $simplepie->set_feed_url($feeds);
     // Set up caching.
     $cacheDir = fullpath($conf['cachedir'] . '/feedaggregator');
     io_mkdir_p($cacheDir);
     $simplepie->enable_cache();
     $simplepie->set_cache_location($cacheDir);
     // Run the actual feed aggregation.
     $simplepie->init();
     // Check for errors.
     if ($simplepie->error()) {
         header("Content-type:text/plain");
         echo join("\n", $simplepie->error());
     }
     // Create the output HTML and cache it for use by the syntax component.
     $html = '';
     foreach ($simplepie->get_items() as $item) {
         $html .= "<div class='feedaggregator_item'>\n" . "<h2>" . $item->get_title() . "</h2>\n" . $item->get_content() . "\n" . "<p>" . "  <a href='" . $item->get_permalink() . "'>Published " . $item->get_date('j M Y') . "</a> " . "  in <a href='" . $item->get_feed()->get_permalink() . "'>" . $item->get_feed()->get_title() . "</a>" . "</p>\n" . "</div>\n\n";
     }
     io_saveFile($cacheDir . '/output.html', $html);
     // Output nothing, as this should be run from cron and we don't want to
     // flood the logs with success.
     exit(0);
 }