/** * Returns a list of available plugins of given type * * @param $type string, plugin_type name; * the type of plugin to return, * use empty string for all types * @param $all bool; * false to only return enabled plugins, * true to return both enabled and disabled plugins * * @return array of plugin names * * @author Andreas Gohr <*****@*****.**> */ function plugin_list($type = '', $all = false) { $plugins = array(); if ($dh = opendir(DOKU_PLUGIN)) { while (false !== ($plugin = readdir($dh))) { if ($plugin == '.' || $plugin == '..' || $plugin == 'tmp') { continue; } if (is_file(DOKU_PLUGIN . $plugin)) { continue; } // if required, skip disabled plugins if (!$all && plugin_isdisabled($plugin)) { continue; } if ($type == '' || @file_exists(DOKU_PLUGIN . "{$plugin}/{$type}.php")) { $plugins[] = $plugin; } else { if ($dp = @opendir(DOKU_PLUGIN . "{$plugin}/{$type}/")) { while (false !== ($component = readdir($dp))) { if (substr($component, 0, 1) == '.' || strtolower(substr($component, -4)) != ".php") { continue; } if (is_file(DOKU_PLUGIN . "{$plugin}/{$type}/{$component}")) { $plugins[] = $plugin . '_' . substr($component, 0, -4); } } closedir($dp); } } } closedir($dh); } return $plugins; }
function render($mode, &$renderer, $indata) { if ($mode == 'xhtml') { list($state, $data) = $indata; switch ($state) { case DOKU_LEXER_ENTER: $pluginClass = $this->getConf('addStyling') ? 'blockquote-plugin' : ''; $attr = ''; if ($data && strlen($data) > 0 && !plugin_isdisabled('wrap')) { // get attributes from wrap helper plugin (if installed) $wrap =& plugin_load('helper', 'wrap'); $attr = $wrap->buildAttributes($data, $pluginClass); } else { if ($pluginClass) { $attr = 'class="' . $pluginClass . '"'; } } $renderer->doc .= '<cite ' . $attr . '>'; break; case DOKU_LEXER_UNMATCHED: $renderer->doc .= $renderer->_xmlEntities($data); break; case DOKU_LEXER_EXIT: $renderer->doc .= "</cite>"; break; } return true; } // unsupported $mode return false; }
function html_pluginlist() { global $ID; global $plugin_protected; foreach ($this->manager->plugin_list as $plugin) { $disabled = plugin_isdisabled($plugin); $protected = in_array($plugin, $plugin_protected); $checked = $disabled ? '' : ' checked="checked"'; $check_disabled = $protected ? ' disabled="disabled"' : ''; // determine display class(es) $class = array(); if (in_array($plugin, $this->downloaded)) { $class[] = 'new'; } if ($disabled) { $class[] = 'disabled'; } if ($protected) { $class[] = 'protected'; } $class = count($class) ? ' class="' . join(' ', $class) . '"' : ''; ptln(' <fieldset' . $class . '>'); ptln(' <legend>' . $plugin . '</legend>'); ptln(' <input type="checkbox" class="enable" name="enabled[]" id="dw__p_' . $plugin . '" value="' . $plugin . '"' . $checked . $check_disabled . ' />'); ptln(' <h3 class="legend"><label for="dw__p_' . $plugin . '">' . $plugin . '</label></h3>'); $this->html_button($plugin, 'info', false, 6); if (in_array('settings', $this->manager->functions)) { $this->html_button($plugin, 'settings', !@file_exists(DOKU_PLUGIN . $plugin . '/settings.php'), 6); } $this->html_button($plugin, 'update', !$this->plugin_readlog($plugin, 'url'), 6); $this->html_button($plugin, 'delete', $protected, 6); ptln(' </fieldset>'); } }
/** * Prints the actions links * * @author Michael Klier <*****@*****.**> */ function tpl_actions() { $actions = array('admin', 'edit', 'history', 'recent', 'backlink', 'subscribe', 'subscribens', 'index', 'login', 'profile'); print '<div class="sidebar_box">' . DOKU_LF; print ' <ul>' . DOKU_LF; foreach ($actions as $action) { if (!actionOK($action)) { continue; } // start output buffering if ($action == 'edit') { // check if new page button plugin is available if (!plugin_isdisabled('npd') && ($npd =& plugin_load('helper', 'npd'))) { $npb = $npd->html_new_page_button(true); if ($npb) { print ' <li><div class="li">'; print $npb; print '</div></li>' . DOKU_LF; } } } ob_start(); print ' <li><div class="li">'; if (tpl_actionlink($action)) { print '</div></li>' . DOKU_LF; ob_end_flush(); } else { ob_end_clean(); } } print ' </ul>' . DOKU_LF; print '</div>' . DOKU_LF; }
/** * Render Output */ function render($mode, &$renderer, $data) { // do cool stuff here if (plugin_isdisabled('blogtng')) { return; } // FIXME do nothing and scream //$this->helper =& plugin_load('helper', 'blogtng_FIXME')); if ($mode == 'xhtml') { $renderer->info['cache'] = false; $renderer->doc .= $this->_list($data); } }
/** * Render xhtml output or metadata * * @param string $mode Renderer mode (supported modes: xhtml and metadata) * @param Doku_Renderer $renderer The renderer * @param array $data The data from the handler function * @return bool If rendering was successful. */ function render($mode, &$renderer, $data) { global $lang; $flags = $data; if ($mode == 'xhtml') { /* @var Doku_Renderer_xhtml $renderer */ // prevent caching to ensure content is always fresh $renderer->info['cache'] = false; /* @var helper_plugin_pagelist $pagelist */ // let Pagelist Plugin do the work for us if (plugin_isdisabled('pagelist') || !($pagelist = plugin_load('helper', 'pagelist'))) { msg($this->getLang('missing_pagelistplugin'), -1); return false; } // Prepare the flags for the pagelist plugin $configflags = explode(',', str_replace(" ", "", $this->getConf('pagelist_flags'))); $flags = array_merge($configflags, $flags); foreach ($flags as $key => $flag) { if ($flag == "") { unset($flags[$key]); } } // print the search form $renderer->doc .= $this->getForm(); // get the tag input data $tags = $this->getTagSearchString(); if ($tags != NULL) { /* @var helper_plugin_tag $my */ if ($my =& plugin_load('helper', 'tag')) { $pages = $my->getTopic($this->getNS(), '', $tags); } // Display a message when no pages were found if (!isset($pages) || !$pages) { $renderer->p_open(); $renderer->cdata($lang['nothingfound']); $renderer->p_close(); } else { // display the actual search results $pagelist->setFlags($flags); $pagelist->startList(); foreach ($pages as $page) { $pagelist->addPage($page); } $renderer->doc .= $pagelist->finishList(); } } return true; } return false; }
/** * Optionally add a CSS class for the first tag * * @author Michael Klier <*****@*****.**> */ function _get_firsttag($page) { if(plugin_isdisabled('tag') || (!$taghelper =& plugin_load('helper', 'tag'))) { return false; } $subject = p_get_metadata($page, 'subject'); if (is_array($subject)) { $tag = $subject[0]; } else { list($tag, $rest) = explode(' ', $subject, 2); } if($tag) { return $tag; } else { return false; } }
function process() { global $plugin_protected; global $INPUT; $count_enabled = $count_disabled = 0; $this->enabled = $INPUT->arr('enabled'); foreach ($this->manager->plugin_list as $plugin) { if (in_array($plugin, $plugin_protected)) { continue; } $new = in_array($plugin, $this->enabled); $old = !plugin_isdisabled($plugin); if ($new != $old) { switch ($new) { // enable plugin case true: if (plugin_enable($plugin)) { msg(sprintf($this->lang['enabled'], $plugin), 1); $count_enabled++; } else { msg(sprintf($this->lang['notenabled'], $plugin), -1); } break; case false: if (plugin_disable($plugin)) { msg(sprintf($this->lang['disabled'], $plugin), 1); $count_disabled++; } else { msg(sprintf($this->lang['notdisabled'], $plugin), -1); } break; } } } // refresh plugins, including expiring any dokuwiki cache(s) if ($count_enabled || $count_disabled) { $this->refresh(); } }
function check_captcha_selection() { $list = plugin_list(); $this->captcha = $this->getConf('captcha'); if (!in_array('captcha', $list)) { if (preg_match("/captcha/", $this->captcha)) { $this->captcha = 'builtin'; } return; } if ($this->captcha == 'none' || $this->captcha == 'builtin') { return; } if (plugin_isdisabled('captcha')) { $this->captcha = 'builtin'; return; } $this->captcha = 'captcha'; }
/** * Run a few sanity checks * * @author Andreas Gohr <*****@*****.**> */ function check() { global $conf; global $INFO; if ($INFO['isadmin'] || $INFO['ismanager']) { msg('DokuWiki version: ' . getVersion(), 1); } if (version_compare(phpversion(), '5.2.0', '<')) { msg('Your PHP version is too old (' . phpversion() . ' vs. 5.2.0+ needed)', -1); } else { msg('PHP version ' . phpversion(), 1); } $mem = (int) php_to_byte(ini_get('memory_limit')); if ($mem) { if ($mem < 16777216) { msg('PHP is limited to less than 16MB RAM (' . $mem . ' bytes). Increase memory_limit in php.ini', -1); } elseif ($mem < 20971520) { msg('PHP is limited to less than 20MB RAM (' . $mem . ' bytes), you might encounter problems with bigger pages. Increase memory_limit in php.ini', -1); } elseif ($mem < 33554432) { msg('PHP is limited to less than 32MB RAM (' . $mem . ' bytes), but that should be enough in most cases. If not, increase memory_limit in php.ini', 0); } else { msg('More than 32MB RAM (' . $mem . ' bytes) available.', 1); } } if (is_writable($conf['changelog'])) { msg('Changelog is writable', 1); } else { if (@file_exists($conf['changelog'])) { msg('Changelog is not writable', -1); } } if (isset($conf['changelog_old']) && @file_exists($conf['changelog_old'])) { msg('Old changelog exists', 0); } if (@file_exists($conf['changelog'] . '_failed')) { msg('Importing old changelog failed', -1); } else { if (@file_exists($conf['changelog'] . '_importing')) { msg('Importing old changelog now.', 0); } else { if (@file_exists($conf['changelog'] . '_import_ok')) { msg('Old changelog imported', 1); if (!plugin_isdisabled('importoldchangelog')) { msg('Importoldchangelog plugin not disabled after import', -1); } } } } if (is_writable(DOKU_CONF)) { msg('conf directory is writable', 1); } else { msg('conf directory is not writable', -1); } if ($conf['authtype'] == 'plain') { global $config_cascade; if (is_writable($config_cascade['plainauth.users']['default'])) { msg('conf/users.auth.php is writable', 1); } else { msg('conf/users.auth.php is not writable', 0); } } if (function_exists('mb_strpos')) { if (defined('UTF8_NOMBSTRING')) { msg('mb_string extension is available but will not be used', 0); } else { msg('mb_string extension is available and will be used', 1); if (ini_get('mbstring.func_overload') != 0) { msg('mb_string function overloading is enabled, this will cause problems and should be disabled', -1); } } } else { msg('mb_string extension not available - PHP only replacements will be used', 0); } if (!UTF8_PREGSUPPORT) { msg('PHP is missing UTF-8 support in Perl-Compatible Regular Expressions (PCRE)', -1); } if (!UTF8_PROPERTYSUPPORT) { msg('PHP is missing Unicode properties support in Perl-Compatible Regular Expressions (PCRE)', -1); } $loc = setlocale(LC_ALL, 0); if (!$loc) { msg('No valid locale is set for your PHP setup. You should fix this', -1); } elseif (stripos($loc, 'utf') === false) { msg('Your locale <code>' . hsc($loc) . '</code> seems not to be a UTF-8 locale, you should fix this if you encounter problems.', 0); } else { msg('Valid locale ' . hsc($loc) . ' found.', 1); } if ($conf['allowdebug']) { msg('Debugging support is enabled. If you don\'t need it you should set $conf[\'allowdebug\'] = 0', -1); } else { msg('Debugging support is disabled', 1); } if ($INFO['userinfo']['name']) { msg('You are currently logged in as ' . $_SERVER['REMOTE_USER'] . ' (' . $INFO['userinfo']['name'] . ')', 0); msg('You are part of the groups ' . join($INFO['userinfo']['grps'], ', '), 0); } else { msg('You are currently not logged in', 0); } msg('Your current permission for this page is ' . $INFO['perm'], 0); if (is_writable($INFO['filepath'])) { msg('The current page is writable by the webserver', 0); } else { msg('The current page is not writable by the webserver', 0); } if ($INFO['writable']) { msg('The current page is writable by you', 0); } else { msg('The current page is not writable by you', 0); } // Check for corrupted search index $lengths = idx_listIndexLengths(); $index_corrupted = false; foreach ($lengths as $length) { if (count(idx_getIndex('w', $length)) != count(idx_getIndex('i', $length))) { $index_corrupted = true; break; } } foreach (idx_getIndex('metadata', '') as $index) { if (count(idx_getIndex($index . '_w', '')) != count(idx_getIndex($index . '_i', ''))) { $index_corrupted = true; break; } } if ($index_corrupted) { msg('The search index is corrupted. It might produce wrong results and most probably needs to be rebuilt. See <a href="http://www.dokuwiki.org/faq:searchindex">faq:searchindex</a> for ways to rebuild the search index.', -1); } elseif (!empty($lengths)) { msg('The search index seems to be working', 1); } else { msg('The search index is empty. See <a href="http://www.dokuwiki.org/faq:searchindex">faq:searchindex</a> for help on how to fix the search index. If the default indexer isn\'t used or the wiki is actually empty this is normal.'); } }
/** * Get template from namespace/page and config * * @author Michael Klier <*****@*****.**> * @author Anika Henke <*****@*****.**> */ private function _getTplPerNamespace() { global $ID; $config = DOKU_CONF . 'loadskin.conf'; if (@file_exists($config)) { $data = unserialize(io_readFile($config, false)); $id = $ID; // remove language path from $id before you check for a match (it would only be at the start) if ($this->getConf('inheritInTranslations') && !plugin_isdisabled('translation')) { $transplugin =& plugin_load('helper', 'translation'); $langPath = $transplugin->getLangPart($id) . ':'; $pos = strpos($id, $langPath); if ($pos !== false && $pos == 0) { $id = str_ireplace($langPath, '', $id); } } if ($data[$id]) { return $data[$id]; } $path = explode(':', $id); while (count($path) > 0) { $id = implode(':', $path); if ($data[$id]) { return $data[$id]; } array_pop($path); } } return false; }
<div class="bar-left"> <?php if (!tpl_getConf('closedwiki') || tpl_getConf('closedwiki') && isset($_SERVER['REMOTE_USER'])) { switch (tpl_getConf('wiki_actionlinks')) { case 'buttons': // check if new page button plugin is available if (!plugin_isdisabled('npd') && ($npd =& plugin_load('helper', 'npd'))) { $npd->html_new_page_button(); } tpl_button('edit'); tpl_button('history'); tpl_button('media'); break; case 'links': // check if new page button plugin is available if (!plugin_isdisabled('npd') && ($npd =& plugin_load('helper', 'npd'))) { $npd->html_new_page_button(); } tpl_actionlink('edit'); tpl_actionlink('history'); tpl_actionlink('media'); break; } } ?> </div> <div class="bar-right"> <?php switch (tpl_getConf('wiki_actionlinks')) { case 'buttons': if (!tpl_getConf('closedwiki') || tpl_getConf('closedwiki') && isset($_SERVER['REMOTE_USER'])) {
function render($mode, &$renderer, $data) { global $conf; list($type, $num, $namespaces) = $data; if ($mode == 'xhtml') { if ($type == 'tag') { // we need the tag helper plugin if (plugin_isdisabled('tag') || !($tag = plugin_load('helper', 'tag'))) { msg('The Tag Plugin must be installed to display tag clouds.', -1); return false; } $cloud = $this->_getTagCloud($num, $min, $max, $namespaces, $tag); } elseif ($type == 'search') { $helper = plugin_load('helper', 'searchstats'); if ($helper) { $cloud = $helper->getSearchWordArray($num); // calculate min/max values $min = PHP_INT_MAX; $max = 0; foreach ($cloud as $size) { $min = min($size, $min); $max = max($size, $max); } } else { msg('You have to install the searchstats plugin to use this feature.', -1); return false; } } else { $cloud = $this->_getWordCloud($num, $min, $max); } if (!is_array($cloud) || empty($cloud)) { return false; } $delta = ($max - $min) / 16; // prevent caching to ensure the included pages are always fresh $renderer->info['cache'] = false; // and render the cloud $renderer->doc .= '<div class="cloud">' . DOKU_LF; foreach ($cloud as $word => $size) { if ($size < $min + round($delta)) { $class = 'cloud1'; } elseif ($size < $min + round(2 * $delta)) { $class = 'cloud2'; } elseif ($size < $min + round(4 * $delta)) { $class = 'cloud3'; } elseif ($size < $min + round(8 * $delta)) { $class = 'cloud4'; } else { $class = 'cloud5'; } $name = $word; if ($type == 'tag') { $id = $word; $exists = false; resolve_pageID($tag->namespace, $id, $exists); if ($exists) { $link = wl($id); if ($conf['useheading']) { $name = p_get_first_heading($id, false); } else { $name = $word; } } else { $link = wl($id, array('do' => 'showtag', 'tag' => $word)); } $title = $word; $class .= $exists ? '_tag1' : '_tag2'; } else { if ($conf['userewrite'] == 2) { $link = wl($word, array('do' => 'search', 'id' => $word)); $title = $size; } else { $link = wl($word, 'do=search'); $title = $size; } } $renderer->doc .= DOKU_TAB . '<a href="' . $link . '" class="' . $class . '"' . ' title="' . $title . '">' . hsc($name) . '</a>' . DOKU_LF; } $renderer->doc .= '</div>' . DOKU_LF; return true; } return false; }
/** * Handler to prepare matched data for the rendering process * * @param string $match The text matched by the patterns * @param int $state The lexer state for the match * @param int $pos The character position of the matched text * @param Doku_Handler $handler The Doku_Handler object * @return bool|array Return an array with all data you want to use in render, false don't add an instruction */ public function handle($match, $state, $pos, Doku_Handler $handler) { $match = substr($match, 6, -7); // remove form wrap $lines = explode("\n", $match); $actions = $rawactions = array(); $thanks = ''; $labels = ''; // parse the lines into an command/argument array $cmds = array(); while (count($lines) > 0) { $line = trim(array_shift($lines)); if (!$line) { continue; } $args = $this->_parse_line($line, $lines); $args[0] = $this->_sanitizeClassName($args[0]); if (in_array($args[0], array('action', 'thanks', 'labels'))) { if (count($args) < 2) { msg(sprintf($this->getLang('e_missingargs'), hsc($args[0]), hsc($args[1])), -1); continue; } // is action element? if ($args[0] == 'action') { array_shift($args); $rawactions[] = array('type' => array_shift($args), 'argv' => $args); continue; } // is thank you text? if ($args[0] == 'thanks') { $thanks = $args[1]; continue; } // is labels? if ($args[0] == 'labels') { $labels = $args[1]; continue; } } if (strpos($args[0], '_') === false) { $name = 'bureaucracy_field' . $args[0]; } else { //name convention: plugin_componentname $name = $args[0]; } /** @deprecated 6-11-2014 rename old field name*/ if ($name == 'bureaucracy_fielddataplugin') { msg("Please rename the field 'dataplugin' into 'data_aliastextbox'", -1); $name = 'data_aliastextbox'; } /** @var helper_plugin_bureaucracy_field $field */ $field = $this->loadHelper($name, false); if ($field) { $field->initialize($args); $cmds[] = $field; } else { /** @deprecated 6-11-2014 old date plugin installed */ if ($name == 'data_aliastextbox') { msg("Please update the Data plugin for enabling the 'data_aliastextbox' field again (previous known as 'dataplugin' field)", -1); } msg(sprintf($this->getLang('e_unknowntype'), hsc($name)), -1); } } // check if action is available foreach ($rawactions as $action) { $action['type'] = $this->_sanitizeClassName($action['type']); if (strpos($action['type'], '_') === false) { $action['actionname'] = 'bureaucracy_action' . $action['type']; } else { //name convention for other plugins: plugin_componentname $action['actionname'] = $action['type']; } list($plugin, $component) = explode('_', $action['actionname']); $alternativename = $action['type'] . '_' . $action['type']; // bureaucracy_action<name> or <plugin>_<componentname> if (!plugin_isdisabled($action['actionname']) || @file_exists(DOKU_PLUGIN . $plugin . '/helper/' . $component . '.php')) { $actions[] = $action; // shortcut for other plugins with component name <name>_<name> } elseif (plugin_isdisabled($alternativename) || !@file_exists(DOKU_PLUGIN . $action['type'] . '/helper/' . $action['type'] . '.php')) { $action['actionname'] = $alternativename; $actions[] = $action; // not found } else { msg(sprintf($this->getLang('e_unknownaction'), hsc($action['actionname'])), -1); /** @deprecated 6-11-2014 old date plugin installed */ if ($action['actionname'] == 'pagemod_pagemod') { msg("Please update the Pagemod plugin for enabling the 'pagemod_pagemod' field again (previous known as 'pagemod' field)", -1); } } } // action(s) found? if (count($actions) < 1) { msg($this->getLang('e_noaction'), -1); } // set thank you message if (!$thanks) { $thanks = ""; foreach ($actions as $action) { $thanks .= $this->getLang($action['type'] . '_thanks'); } } else { $thanks = hsc($thanks); } return array('fields' => $cmds, 'actions' => $actions, 'thanks' => $thanks, 'labels' => $labels); }
/** * Run a few sanity checks * * @author Andreas Gohr <*****@*****.**> */ function check() { global $conf; global $INFO; msg('DokuWiki version: ' . getVersion(), 1); if (version_compare(phpversion(), '5.1.2', '<')) { msg('Your PHP version is too old (' . phpversion() . ' vs. 5.1.2+ needed)', -1); } else { msg('PHP version ' . phpversion(), 1); } $mem = (int) php_to_byte(ini_get('memory_limit')); if ($mem) { if ($mem < 16777216) { msg('PHP is limited to less than 16MB RAM (' . $mem . ' bytes). Increase memory_limit in php.ini', -1); } elseif ($mem < 20971520) { msg('PHP is limited to less than 20MB RAM (' . $mem . ' bytes), you might encounter problems with bigger pages. Increase memory_limit in php.ini', -1); } elseif ($mem < 33554432) { msg('PHP is limited to less than 32MB RAM (' . $mem . ' bytes), but that should be enough in most cases. If not, increase memory_limit in php.ini', 0); } else { msg('More than 32MB RAM (' . $mem . ' bytes) available.', 1); } } if (is_writable($conf['changelog'])) { msg('Changelog is writable', 1); } else { if (@file_exists($conf['changelog'])) { msg('Changelog is not writable', -1); } } if (isset($conf['changelog_old']) && @file_exists($conf['changelog_old'])) { msg('Old changelog exists', 0); } if (@file_exists($conf['changelog'] . '_failed')) { msg('Importing old changelog failed', -1); } else { if (@file_exists($conf['changelog'] . '_importing')) { msg('Importing old changelog now.', 0); } else { if (@file_exists($conf['changelog'] . '_import_ok')) { msg('Old changelog imported', 1); if (!plugin_isdisabled('importoldchangelog')) { msg('Importoldchangelog plugin not disabled after import', -1); } } } } if (is_writable($conf['datadir'])) { msg('Datadir is writable', 1); } else { msg('Datadir is not writable', -1); } if (is_writable($conf['olddir'])) { msg('Attic is writable', 1); } else { msg('Attic is not writable', -1); } if (is_writable($conf['mediadir'])) { msg('Mediadir is writable', 1); } else { msg('Mediadir is not writable', -1); } if (is_writable($conf['cachedir'])) { msg('Cachedir is writable', 1); } else { msg('Cachedir is not writable', -1); } if (is_writable($conf['lockdir'])) { msg('Lockdir is writable', 1); } else { msg('Lockdir is not writable', -1); } if ($conf['authtype'] == 'plain') { if (is_writable(DOKU_CONF . 'users.auth.php')) { msg('conf/users.auth.php is writable', 1); } else { msg('conf/users.auth.php is not writable', 0); } } if (function_exists('mb_strpos')) { if (defined('UTF8_NOMBSTRING')) { msg('mb_string extension is available but will not be used', 0); } else { msg('mb_string extension is available and will be used', 1); if (ini_get('mbstring.func_overload') != 0) { msg('mb_string function overloading is enabled, this will cause problems and should be disabled', -1); } } } else { msg('mb_string extension not available - PHP only replacements will be used', 0); } if ($conf['allowdebug']) { msg('Debugging support is enabled. If you don\'t need it you should set $conf[\'allowdebug\'] = 0', -1); } else { msg('Debugging support is disabled', 1); } if ($INFO['userinfo']['name']) { msg('You are currently logged in as ' . $_SERVER['REMOTE_USER'] . ' (' . $INFO['userinfo']['name'] . ')', 0); msg('You are part of the groups ' . join($INFO['userinfo']['grps'], ', '), 0); } else { msg('You are currently not logged in', 0); } msg('Your current permission for this page is ' . $INFO['perm'], 0); if (is_writable($INFO['filepath'])) { msg('The current page is writable by the webserver', 0); } else { msg('The current page is not writable by the webserver', 0); } if ($INFO['writable']) { msg('The current page is writable by you', 0); } else { msg('The current page is not writable by you', 0); } require_once DOKU_INC . 'inc/HTTPClient.php'; $check = wl('', '', true) . 'data/_dummy'; $http = new DokuHTTPClient(); $http->timeout = 6; $res = $http->get($check); if (strpos($res, 'data directory') !== false) { msg('It seems like the data directory is accessible from the web. Make sure this directory is properly protected (See <a href="http://www.dokuwiki.org/security">security</a>)', -1); } elseif ($http->status == 404 || $http->status == 403) { msg('The data directory seems to be properly protected', 1); } else { msg('Failed to check if the data directory is accessible from the web. Make sure this directory is properly protected (See <a href="http://www.dokuwiki.org/security">security</a>)', -1); } }
/** * Prints given sidebar box * * @author Michael Klier <*****@*****.**> */ function _sidebar_dispatch($sb, $pos) { global $lang; global $conf; global $ID; global $REV; global $INFO; $svID = $ID; // save current ID $svREV = $REV; // save current REV $pname = $this->getConf('pagename'); switch ($sb) { case 'main': $main_sb = $pname; if (@page_exists($main_sb)) { if (auth_quickaclcheck($main_sb) >= AUTH_READ) { $always = $this->getConf('main_always'); if ($always or !$always && !getNS($ID)) { print '<div class="main_sidebar sidebar_box">' . DOKU_LF; print $this->p_sidebar_xhtml($main_sb, $pos) . DOKU_LF; print '</div>' . DOKU_LF; } } } else { $out = $this->locale_xhtml('nosidebar'); $link = '<a href="' . wl($pname) . '" class="wikilink2">' . $pname . '</a>' . DOKU_LF; print '<div class="main_sidebar sidebar_box">' . DOKU_LF; print str_replace('LINK', $link, $out); print '</div>' . DOKU_LF; } break; case 'namespace': $user_ns = $this->getConf('user_ns'); $group_ns = $this->getConf('group_ns'); if (!preg_match("/^" . $user_ns . ":.*?\$|^" . $group_ns . ":.*?\$/", $svID)) { // skip group/user sidebars and current ID $ns_sb = $this->_getNsSb($svID); if ($ns_sb && auth_quickaclcheck($ns_sb) >= AUTH_READ) { print '<div class="namespace_sidebar sidebar_box">' . DOKU_LF; print $this->p_sidebar_xhtml($ns_sb, $pos) . DOKU_LF; print '</div>' . DOKU_LF; } } break; case 'user': $user_ns = $this->getConf('user_ns'); if (isset($INFO['userinfo']['name'])) { $user = $_SERVER['REMOTE_USER']; $user_sb = $user_ns . ':' . $user . ':' . $pname; if (@page_exists($user_sb)) { $subst = array('pattern' => array('/@USER@/'), 'replace' => array($user)); print '<div class="user_sidebar sidebar_box">' . DOKU_LF; print $this->p_sidebar_xhtml($user_sb, $pos, $subst) . DOKU_LF; print '</div>'; } // check for namespace sidebars in user namespace too if (preg_match('/' . $user_ns . ':' . $user . ':.*/', $svID)) { $ns_sb = $this->_getNsSb($svID); if ($ns_sb && $ns_sb != $user_sb && auth_quickaclcheck($ns_sb) >= AUTH_READ) { print '<div class="namespace_sidebar sidebar_box">' . DOKU_LF; print $this->p_sidebar_xhtml($ns_sb, $pos) . DOKU_LF; print '</div>' . DOKU_LF; } } } break; case 'group': $group_ns = $this->getConf('group_ns'); if (isset($INFO['userinfo']['grps'])) { foreach ($INFO['userinfo']['grps'] as $grp) { $group_sb = $group_ns . ':' . $grp . ':' . $pname; if (@page_exists($group_sb) && auth_quickaclcheck(cleanID($group_sb)) >= AUTH_READ) { $subst = array('pattern' => array('/@GROUP@/'), 'replace' => array($grp)); print '<div class="group_sidebar sidebar_box">' . DOKU_LF; print $this->p_sidebar_xhtml($group_sb, $pos, $subst) . DOKU_LF; print '</div>' . DOKU_LF; } } } else { $group_sb = $group_ns . ':all:' . $pname; if (@page_exists($group_sb) && auth_quickaclcheck(cleanID($group_sb)) >= AUTH_READ) { print '<div class="group_sidebar sidebar_box">' . DOKU_LF; print $this->p_sidebar_xhtml($group_sb, $pos, $subst) . DOKU_LF; print '</div>' . DOKU_LF; } } break; case 'toolbox': $actions = array('admin', 'edit', 'history', 'recent', 'backlink', 'subscribe', 'subscribens', 'index', 'login', 'profile'); print '<div class="toolbox_sidebar sidebar_box">' . DOKU_LF; print ' <ul>' . DOKU_LF; foreach ($actions as $action) { if (!actionOK($action)) { continue; } // start output buffering if ($action == 'edit') { // check if new page button plugin is available if (!plugin_isdisabled('npd') && ($npd =& plugin_load('helper', 'npd'))) { $npb = $npd->html_new_page_button(true); if ($npb) { print ' <li class="level1"><div class="li">'; print $npb; print '</div></li>' . DOKU_LF; } } } ob_start(); print ' <li><div class="li">'; if (tpl_actionlink($action)) { print '</div></li>' . DOKU_LF; ob_end_flush(); } else { ob_end_clean(); } } print ' </ul>' . DOKU_LF; print '</div>' . DOKU_LF; break; case 'trace': print '<div class="trace_sidebar sidebar_box">' . DOKU_LF; print ' <h1>' . $lang['breadcrumb'] . '</h1>' . DOKU_LF; print ' <div class="breadcrumbs">' . DOKU_LF; $conf['youarehere'] != 1 ? tpl_breadcrumbs() : tpl_youarehere(); print ' </div>' . DOKU_LF; print '</div>' . DOKU_LF; break; case 'extra': print '<div class="extra_sidebar sidebar_box">' . DOKU_LF; @(include dirname(__FILE__) . '/sidebar.html'); print '</div>' . DOKU_LF; break; default: // check for user defined sidebars if (@file_exists(DOKU_PLUGIN . 'sidebarng/sidebars/' . $sb . '/sidebar.php')) { print '<div class="' . $sb . '_sidebar sidebar_box">' . DOKU_LF; @(require_once DOKU_PLUGIN . 'sidebarng/sidebars/' . $sb . '/sidebar.php'); print '</div>' . DOKU_LF; } break; } // restore ID and REV $ID = $svID; $REV = $svREV; }
/** * Returns <a></a> links with font style attribut representing number of ocurrences * (inspired by DokuWiki Cloud plugin by Gina Häußge, Michael Klier, Esther Brunner) */ function _getTagXml($options) { global $conf; if ($options['show'] == 'tags') { // we need the tag helper plugin if (plugin_isdisabled('tag') || !($tag = plugin_load('helper', 'tag'))) { msg('The Tag Plugin must be installed to display tag clouds.', -1); return ''; } $cloud = $this->_getTagCloud($options['max'], $min, $max, $tag); } elseif ($options['show'] == 'namespaces') { $cloud = $this->_getNamespaceCloud($options['max'], $min, $max); } else { $cloud = $this->_getWordCloud($options['max'], $min, $max); } if (!is_array($cloud) || empty($cloud)) { return ''; } $delta = ($max - $min) / 16; if ($delta == 0) { $delta = 1; } foreach ($cloud as $word => $size) { if ($size < $min + round($delta)) { $class = 'cloud1'; } elseif ($size < $min + round(2 * $delta)) { $class = 'cloud2'; } elseif ($size < $min + round(4 * $delta)) { $class = 'cloud3'; } elseif ($size < $min + round(8 * $delta)) { $class = 'cloud4'; } else { $class = 'cloud5'; } $name = $word; if ($options['show'] == 'tags') { $id = $word; resolve_pageID($tag->namespace, $id, $exists); if ($exists) { $link = wl($id, '', true); if ($conf['useheading']) { $name = p_get_first_heading($id, false); } } else { $link = wl($id, array('do' => 'showtag', 'tag' => noNS($id)), true); } $title = $id; $class .= $exists ? '_tag1' : '_tag2'; } elseif ($options['show'] == 'namespaces') { $id = ''; resolve_pageID($word, $id, $exists); $link = wl($id, '', true); $title = $id; $size = 108; $class = 'cloud5'; } else { if ($conf['userewrite'] == 2) { $link = wl($word, array('do' => 'search', 'id' => $word), true); $title = $size; } else { $link = wl($word, 'do=search', true); $title = $size; } } $fsize = 8 + round(($size - $min) / $delta); $xmlCloude .= '<a href="' . $link . '" class="' . $class . '"' . ' title="' . $title . '" style="font-size: ' . $fsize . 'pt;">' . hsc($name) . '</a>' . DOKU_LF; } return $xmlCloude; }
/** * Returns the meta line below the included page */ function html_footer($page, $sect, $sect_title, $flags, $footer_lvl, &$renderer) { global $conf, $ID; if(!$flags['footer']) return ''; $meta = p_get_metadata($page); $exists = page_exists($page); $xhtml = array(); // permalink if ($flags['permalink']) { $class = ($exists ? 'wikilink1' : 'wikilink2'); $url = ($sect) ? wl($page) . '#' . $sect : wl($page); $name = ($sect) ? $sect_title : $page; $title = ($sect) ? $page . '#' . $sect : $page; if (!$title) $title = str_replace('_', ' ', noNS($page)); $link = array( 'url' => $url, 'title' => $title, 'name' => $name, 'target' => $conf['target']['wiki'], 'class' => $class . ' permalink', 'more' => 'rel="bookmark"', ); $xhtml[] = $renderer->_formatLink($link); } // date if ($flags['date'] && $exists) { $date = $meta['date']['created']; if ($date) { $xhtml[] = '<abbr class="published" title="'.strftime('%Y-%m-%dT%H:%M:%SZ', $date).'">' . strftime($conf['dformat'], $date) . '</abbr>'; } } // modified date if ($flags['mdate'] && $exists) { $mdate = $meta['date']['modified']; if ($mdate) { $xhtml[] = '<abbr class="published" title="'.strftime('%Y-%m-%dT%H:%M:%SZ', $mdate).'">' . strftime($conf['dformat'], $mdate) . '</abbr>'; } } // author if ($flags['user'] && $exists) { $author = $meta['creator']; if ($author) { $userpage = cleanID($this->getConf('usernamespace').':'.$author); resolve_pageid(getNS($ID), $userpage, $exists); $class = ($exists ? 'wikilink1' : 'wikilink2'); $link = array( 'url' => wl($userpage), 'title' => $userpage, 'name' => hsc($author), 'target' => $conf['target']['wiki'], 'class' => $class.' url fn', 'pre' => '<span class="vcard author">', 'suf' => '</span>', ); $xhtml[] = $renderer->_formatLink($link); } } // comments - let Discussion Plugin do the work for us if (empty($sect) && $flags['comments'] && (!plugin_isdisabled('discussion')) && ($discussion =& plugin_load('helper', 'discussion'))) { $disc = $discussion->td($page); if ($disc) $xhtml[] = '<span class="comment">' . $disc . '</span>'; } // linkbacks - let Linkback Plugin do the work for us if (empty($sect) && $flags['linkbacks'] && (!plugin_isdisabled('linkback')) && ($linkback =& plugin_load('helper', 'linkback'))) { $link = $linkback->td($page); if ($link) $xhtml[] = '<span class="linkback">' . $link . '</span>'; } $xhtml = implode(DOKU_LF . DOKU_TAB . '· ', $xhtml); // tags - let Tag Plugin do the work for us if (empty($sect) && $flags['tags'] && (!plugin_isdisabled('tag')) && ($tag =& plugin_load('helper', 'tag'))) { $tags = $tag->td($page); if($tags) { $xhtml .= '<div class="tags"><span>' . DOKU_LF . DOKU_TAB . $tags . DOKU_LF . DOKU_TAB . '</span></div>' . DOKU_LF; } } if (!$xhtml) $xhtml = ' '; $class = 'inclmeta'; $class .= ' level' . $footer_lvl; return '<div class="' . $class . '">' . DOKU_LF . DOKU_TAB . $xhtml . DOKU_LF . '</div>' . DOKU_LF; }
function ping($sourceUri, $targetUri) { // Plugin not enabled? Quit if (plugin_isdisabled('linkback')) { return new IXR_Error(PINGBACK_ERROR_TARGETURI_CANNOT_BE_USED, ''); } // pingback disabled? Quit if (!$this->tools->getConf('enable_pingback')) { return new IXR_Error(PINGBACK_ERROR_TARGETURI_CANNOT_BE_USED, ''); } // Given URLs are no urls? Quit if (!preg_match("#^([a-z0-9\\-\\.+]+?)://.*#i", $sourceUri)) { return new IXR_Error(PINGBACK_ERROR_GENERIC, ''); } if (!preg_match("#^([a-z0-9\\-\\.+]+?)://.*#i", $targetUri)) { return new IXR_Error(PINGBACK_ERROR_GENERIC, ''); } // Source URL does not exist? Quit $page = $this->tools->getPage($sourceUri); if (!$page['success'] && ($page['status'] < 200 || $page['status'] >= 300)) { return new IXR_Error(PINGBACK_ERROR_SOURCEURI_DOES_NOT_EXIST, ''); } // Target URL does not match with request? Quit $ID = substr($_SERVER['PATH_INFO'], 1); if ($targetUri != wl($ID, '', true)) { return new IXR_Error(PINGBACK_ERROR_GENERIC, ''); } $file = metaFN($ID, '.linkbacks'); $data = array('send' => false, 'receive' => false, 'display' => false, 'sentpings' => array(), 'receivedpings' => array(), 'number' => 0); if (@file_exists($file)) { $data = unserialize(io_readFile($file, false)); } // Target URL is not pingback enabled? Quit if (!$data['receive']) { return new IXR_Error(PINGBACK_ERROR_TARGETURI_CANNOT_BE_USED, ''); } // Pingback already done? Quit if ($data['receivedpings'][md5($sourceUri)]) { return new IXR_Error(PINGBACK_ERROR_PINGBACK_ALREADY_MADE, ''); } // Retrieve data from source $linkback = $this->_getTrackbackData($sourceUri, $targetUri, $page); // Source URL does not contain link to target? Quit if (!$linkback) { return new IXR_Error(PINGBACK_ERROR_SOURCEURI_DOES_NOT_CONTAIN_LINK, ''); } // Prepare event for Antispam plugins $evt_data = array('linkback' => $linkback, 'page' => $page, 'target' => $targetUri, 'show' => true, 'log' => array(date('Y/m/d H:i', time()) . ': Received pingback from ' . $linkback['url'] . ' (' . $linkback['lid'] . ')')); $event = new Doku_Event('ACTION_LINKBACK_RECEIVED', $evt_data); if ($event->advise_before()) { $linkback['show'] = $evt_data['show']; if ($this->tools->getConf('usefavicon')) { $linkback['favicon'] = $this->tools->getFavicon($linkback['url'], $page['body']); } // add pingback $data['receivedpings'][$linkback['lid']] = $linkback; if ($linkback['show']) { $data['number']++; } io_saveFile($file, serialize($data)); $this->tools->addLogEntry($linkback['received'], $ID, 'cl', '', $linkback['lid']); $this->tools->notify($ID, $linkback); if ($this->tools->getConf('log_processing')) { $this->tools->addProcessLogEntry($evt_data['log']); } $event->advise_after(); } else { // Pingback was denied if ($this->tools->getConf('log_processing')) { $this->tools->addProcessLogEntry($evt_data['log']); } $event->advise_after(); return new IXR_Error(PINGBACK_ERROR_ACCESS_DENIED, $helper->getLang('error_noreason')); } }
function render($mode, &$renderer, $data) { list($ns, $start, $end, $flags, $refine) = $data; // get the blog entries for our namespace if ($my =& plugin_load('helper', 'blog')) { $entries = $my->getBlog($ns); } // use tag refinements? if ($refine) { if (plugin_isdisabled('tag') || !($tag = plugin_load('helper', 'tag'))) { msg($this->getLang('missing_tagplugin'), -1); } else { $entries = $tag->tagRefine($entries, $refine); } } if (!$entries) { return true; } // nothing to display if ($mode == 'xhtml') { // Configuration $archive_mode = $this->getConf('archive_mode'); $max_months = $this->getConf('max_months'); $histogram_height = $this->getConf('histogram_height'); // prevent caching for current month to ensure content is always fresh if (time() < $end) { $renderer->info['cache'] = false; } if ($this->getConf('showhistogram')) { $current_year = ''; $current_month = ''; $ul_open = false; $histogram = ''; $histogram_count = array(); $histogram_higher = 0; $posts_count = 0; $list = ''; // Generate posts list foreach ($entries as $entry) { // entry in the right date range? if ($start > $entry['date'] || $entry['date'] >= $end) { continue; } if ($current_year != date('o', $entry['date'])) { if ($ul_open) { $list .= '</ul>' . DOKU_LF; $ul_open = false; } $current_year = date('o', $entry['date']); $list .= '<h2>' . $current_year . '</h2>' . DOKU_LF; } if ($current_month != date('m', $entry['date'])) { if ($ul_open) { $list .= '</ul>' . DOKU_LF; } $current_month = date('m', $entry['date']); $list .= '<h3 id="m' . date('o-m', $entry['date']) . '">' . $this->getLang('month_' . $current_month) . '</h3><ul>' . DOKU_LF; $ul_open = true; } $posts_count += 1; $histogram_count[date('o-m', $entry['date'])] += 1; if ($histogram_higher < $histogram_count[date('o-m', $entry['date'])]) { $histogram_higher = $histogram_count[date('o-m', $entry['date'])]; } $list .= '<li>' . date('d', $entry['date']) . ' - <a href="' . wl($entry['id']) . '" title="' . $entry['id'] . '">' . $entry['title'] . '</a></li>' . DOKU_LF; } $list .= '</ul>' . DOKU_LF; if ($posts_count > $max_posts) { $posts_count = $max_posts; } // Generate histogram $histogram_count = array_reverse($histogram_count); $month_count = 0; foreach ($histogram_count as $key => $month_reference) { // Check the max_months parameter if ($month_count >= $max_months) { break; } if ($month_reference > 0) { // Height in "px" $current_height = $histogram_height / $histogram_higher * $month_reference; } else { // Height in "px" $current_height = 1; } // Generate the alt attribute $alt = $key . ': ' . $month_reference . ' '; if ($month_reference > 1) { $alt .= $this->getLang('entries'); } else { $alt .= $this->getLang('entry'); } $histogram .= '<a href="#m' . $key . '" title="#m' . $key . '">'; $histogram .= '<img class="blog_archive_bar" alt="' . $alt . '" height="' . $current_height . '" src="lib/images/blank.gif"/></a>' . DOKU_LF; $month_count += 1; } // Add histogram and posts list $renderer->doc .= '<div class="level1"><h1>' . $this->getLang('archive_title') . '</h1>' . $histogram . '<br/><br/>' . $list . '</div>' . DOKU_LF; } else { // prevent caching for current month to ensure content is always fresh if (time() < $end) { $renderer->info['cache'] = false; } // let Pagelist Plugin do the work for us if (plugin_isdisabled('pagelist') || !($pagelist =& plugin_load('helper', 'pagelist'))) { msg($this->getLang('missing_pagelistplugin'), -1); return false; } $pagelist->setFlags($flags); $pagelist->startList(); foreach ($entries as $entry) { // entry in the right date range? if ($start > $entry['date'] || $entry['date'] >= $end) { continue; } $pagelist->addPage($entry); } $renderer->doc .= $pagelist->finishList(); } return true; // for metadata renderer } elseif ($mode == 'metadata') { foreach ($entries as $entry) { // entry in the right date range? if ($start > $entry['date'] || $entry['date'] >= $end) { continue; } $renderer->meta['relation']['references'][$entry['id']] = true; } return true; } return false; }
/** * Sets the list header */ function startList() { // table style switch ($this->style) { case 'table': $class = 'inline'; break; case 'list': $class = 'ul'; break; case 'simplelist': $class = false; break; default: $class = 'pagelist'; } if($class) { $this->doc = '<div class="table">'.DOKU_LF.'<table class="'.$class.'">'.DOKU_LF; } else { // Simplelist is enabled; Skip header and firsthl $this->showheader = false; $this->showfirsthl = false; //$this->doc .= DOKU_LF.DOKU_TAB.'</tr>'.DOKU_LF; $this->doc = '<ul>'; } $this->page = NULL; // check if some plugins are available - if yes, load them! foreach ($this->plugins as $plug => $col) { if (!$this->column[$col]) continue; if (plugin_isdisabled($plug) || (!$this->$plug = plugin_load('helper', $plug))) $this->column[$col] = false; } // header row if ($this->showheader) { $this->doc .= DOKU_TAB.'<tr>'.DOKU_LF.DOKU_TAB.DOKU_TAB; $columns = array('page', 'date', 'user', 'desc'); if ($this->column['image']) { if (!$this->header['image']) $this->header['image'] = hsc($this->pageimage->th()); $this->doc .= '<th class="images">'.$this->header['image'].'</th>'; } foreach ($columns as $col) { if ($this->column[$col]) { if (!$this->header[$col]) $this->header[$col] = hsc($this->getLang($col)); $this->doc .= '<th class="'.$col.'">'.$this->header[$col].'</th>'; } } foreach ($this->plugins as $plug => $col) { if ($this->column[$col] && $col != 'image') { if (!$this->header[$col]) $this->header[$col] = hsc($this->$plug->th()); $this->doc .= '<th class="'.$col.'">'.$this->header[$col].'</th>'; } } $this->doc .= DOKU_LF.DOKU_TAB.'</tr>'.DOKU_LF; } return true; }
function render($mode, &$renderer, $data) { global $ID; global $conf; global $INFO; global $lang; list($type, $num, $order) = $data; if ($type == "book") { $renderer->info['cache'] = false; if ($mode == 'text' && (isset($_GET['do']) && $_GET['do'] == 'export_text')) { $mode = 'xhtml'; } if ($mode == 'xhtml') { // verifica che se l'utente può salvare/eliminare le selezioni $this->usercansave = auth_quickaclcheck($this->getConf('save_namespace') . ':*') >= AUTH_CREATE; // verifica che se l'utente può salvare/eliminare le selezioni if ($this->usercansave) { if (isset($_POST['task']) && $_POST['task'] == "save") { checkSecurityToken(); if (isset($_COOKIE['list-pagelist'])) { if (isset($_POST['bookcreator_title'])) { $list = explode("|", $_COOKIE['list-pagelist']); $content = "====== " . $_POST['bookcreator_title'] . " ======" . DOKU_LF; for ($n = 0; $n < count($list); $n++) { $page = $list[$n]; $content .= " * [[:{$page}]]" . DOKU_LF; } saveWikiText($this->getConf('save_namespace') . ":" . $_POST['bookcreator_title'], $content, "selection created"); msg($this->getLang('bookcreator_saved') . ": " . $this->getConf('save_namespace') . ":" . $_POST['bookcreator_title']); } else { msg($this->getLang('bookcreator_needtitle')); } } else { msg($this->getLang('bookcreator_empty')); } } elseif (isset($_POST['task']) && $_POST['task'] == "del") { saveWikiText($this->getConf('save_namespace') . ":" . $_POST['page'], '', "selection removed"); msg($this->getLang('bookcreator_deleted') . ": " . $this->getConf('save_namespace') . ":" . $_POST['page']); } } if (isset($_GET['do']) || isset($_GET['mddo'])) { if ($_GET['do'] == 'export_html' || $_GET['do'] == 'export_text') { if (isset($_COOKIE['list-pagelist'])) { $renderer->doc = ''; $list = explode("|", $_COOKIE['list-pagelist']); } $render_mode = 'xhtml'; $lf_subst = ''; if ($_GET['do'] == 'export_text') { $render_mode = 'text'; $lf_subst = '<br>'; } for ($n = 0; $n < count($list); $n++) { $page = $list[$n]; $renderer->doc .= str_replace(DOKU_LF, $lf_subst, p_cached_output(wikiFN($page), $render_mode)); //p_wiki_xhtml($page,$REV,false); } } } else { $renderer->info['cache'] = FALSE; $renderer->doc .= '<script language="JavaScript" type="text/javascript" src="' . DOKU_URL . 'lib/plugins/bookcreator/sorter/core.js"></script>'; $renderer->doc .= '<script language="JavaScript" type="text/javascript" src="' . DOKU_URL . 'lib/plugins/bookcreator/sorter/events.js"></script>'; $renderer->doc .= '<script language="JavaScript" type="text/javascript" src="' . DOKU_URL . 'lib/plugins/bookcreator/sorter/css.js"></script>'; $renderer->doc .= '<script language="JavaScript" type="text/javascript" src="' . DOKU_URL . 'lib/plugins/bookcreator/sorter/coordinates.js"></script>'; $renderer->doc .= '<script language="JavaScript" type="text/javascript" src="' . DOKU_URL . 'lib/plugins/bookcreator/sorter/drag.js"></script>'; $renderer->doc .= '<script language="JavaScript" type="text/javascript" src="' . DOKU_URL . 'lib/plugins/bookcreator/sorter/dragsort.js"></script>'; $renderer->doc .= '<script language="JavaScript" type="text/javascript" src="' . DOKU_URL . 'lib/plugins/bookcreator/sorter/cookies.js"></script>'; $renderer->doc .= '<script language="JavaScript" type="text/javascript" src="' . DOKU_URL . 'lib/plugins/bookcreator/sorter/more.js"></script>'; if (isset($_COOKIE['bookcreator']) || isset($_POST['task']) && $_POST['task'] == "read") { $list = array(); $i = 0; // c'è una selezione salvata da recuperare if (isset($_POST['task']) && $_POST['task'] == "read") { checkSecurityToken(); $renderer->doc .= "\n <script type='text/javascript'><!--//--><![CDATA[//><!-- \n book_removeAllPages('bookcreator');\n //--><!]]></script>"; $select = rawWiki($this->getConf('save_namespace') . ":" . $_POST['page']); $lines = explode("\n", $select); $nr = count($lines); for ($n = 0; $n < $nr; $n++) { if (trim($lines[$n]) == '') { continue; } if ($n > 0 && substr($lines[$n], 0, 7) != " * [[:") { continue; } if ($n === 0) { $lines[$n] = str_replace("====== ", '', $lines[$n]); $lines[$n] = str_replace(" ======", '', $lines[$n]); $title = $lines[$i]; } else { $lines[$n] = str_replace(" * [[:", '', $lines[$n]); $lines[$n] = str_replace("]]", '', $lines[$n]); $list[$n] = $lines[$n]; $renderer->doc .= ' <script type="text/javascript"><!--//--><![CDATA[//><!-- book_changePage(\'bookcreator[' . $list[$n] . ']\', 1, new Date(\'July 21, 2099 00:00:00\'), \'/\'); //--><!]]></script>'; $i++; } } // oppure quella appena selezionata } elseif (isset($_COOKIE['bookcreator'])) { $fav = $_COOKIE['bookcreator']; //Se non ci sono pagine già inserite if ($fav == "" || count($fav) == 0) { $renderer->doc .= $this->getLang('bookcreator_empty'); return; } foreach ($fav as $page => $cpt) { list($cpt, $date) = explode(";", $cpt); if ($cpt < 1) { continue; } $i++; $list[$i] = $page; } } $renderer->doc .= "<table width='100%' border='0' ><tr>"; $renderer->doc .= "<td width='60%' valign='top'>"; // Pagine selezionate for ($n = 1; $n <= $i; $n++) { $page = $list[$n]; if ($n == 1) { $renderer->header($this->getLang('bookcreator_toprint'), 2, 0); $renderer->doc .= '<ul id="pagelist" class="boxes">'; } $lien = $this->createLink($page); $renderer->doc .= ' <li itemID="' . $page . '">'; $renderer->doc .= ' <a href="javascript:book_changePage(\'bookcreator[' . $page . ']\', 0, new Date(\'July 21, 2099 00:00:00\'), \'/\'); book_recharge();"><img src="' . DOKU_URL . 'lib/plugins/bookcreator/images/remove.png" title="' . $this->getLang('bookcreator_remove') . '" border="0" style="vertical-align:middle;" name="ctrl" /></a> '; $renderer->doc .= $lien; $renderer->doc .= '</li>'; if ($n == $i) { $renderer->doc .= '</ul>'; $renderer->doc .= "<br />"; } } // Pagine selezionate // Pagine escluse dal libro if (isset($fav)) { $i = 0; foreach ($fav as $page => $cpt) { list($cpt, $date) = explode(";", $cpt); if ($cpt == 0) { if (!$i) { $renderer->header($this->getLang('bookcreator_removed'), 2, 0); $renderer->listu_open(); } $lien = $this->createLink($page); $i++; $renderer->doc .= "<div id=\"ex__{$page}\">"; $renderer->listitem_open(1); $renderer->doc .= '<a href="javascript:book_changePage(\'bookcreator[' . $page . ']\', 1, new Date(\'July 21, 2099 00:00:00\'), \'/\'); book_recharge();"><img src="' . DOKU_URL . 'lib/plugins/bookcreator/images/include.png" title="' . $this->getLang('bookcreator_include') . '" border="0" style="vertical-align:middle;" name="ctrl" /></a> '; $renderer->doc .= $lien; $renderer->doc .= "</div>"; $renderer->listitem_close(); } } if ($i) { $renderer->listu_close(); } } // azzera selezione $renderer->doc .= "<div align='center'>"; $onclick = "javascript:if(confirm('" . $this->getLang('bookcreator_reserconfirm') . "')) {book_removeAllPages('bookcreator'); document.reset.submit();}"; $renderer->doc .= '<form name="reset" class="button" method="get" action="' . wl($ID) . '">'; $renderer->doc .= "<input type='button' value='" . $this->getLang('bookcreator_reset') . "' class='button' onclick=\"" . $onclick . "\">"; $renderer->doc .= "<input type='hidden' name='id' value='{$ID}'/>"; $renderer->doc .= formSecurityToken(false); $renderer->doc .= '</form>'; $renderer->doc .= '</div>'; // azzera selezione $renderer->doc .= "</td>"; $renderer->doc .= "<td width='40%' valign='top' >"; $renderer->doc .= "<div align='center'>"; //Esportazione PDF $renderer->doc .= '<form class="button" method="get" action="' . wl($ID) . '" accept-charset="' . $lang['encoding'] . '">'; $renderer->doc .= "<fieldset style=\"text-align:left;\"><legend><b>" . $this->getLang('bookcreator_export') . "</b></legend>"; $renderer->doc .= $this->getLang('bookcreator_title') . " "; $renderer->doc .= '<input type="text" class="edit" value="' . $title . '" name="pdfbook_title" size="40" />'; $renderer->doc .= '<select name="do" size="1">'; $renderer->doc .= '<option value="export_html" selected="selected">' . $this->getLang('bookcreator_exportprint') . '</option>'; if (file_exists(DOKU_PLUGIN . "text/renderer.php") && !plugin_isdisabled("text")) { $renderer->doc .= '<option value="export_text">' . $this->getLang('bookcreator_exporttext') . '</option>'; } if (file_exists(DOKU_PLUGIN . "dw2pdf/action.php") && !plugin_isdisabled("dw2pdf")) { $renderer->doc .= '<option value="export_pdfbook" selected="selected">' . $this->getLang('bookcreator_exportpdf') . '</option>'; } $renderer->doc .= '</select>'; $renderer->doc .= '<input type="submit" value="' . $this->getLang('bookcreator_create') . '" class="button"/> <input type="hidden" name="id" value="' . $ID . '" />'; $renderer->doc .= '</fieldset>'; $renderer->doc .= formSecurityToken(false); $renderer->doc .= '</form>'; //Esportazione PDF if ($this->usercansave) { //Salva selezione $renderer->doc .= '<form class="button" method="post" action="' . wl($ID) . '" accept-charset="' . $lang['encoding'] . '">'; $renderer->doc .= "<fieldset style=\"text-align:left;\"><legend><b>" . $this->getLang('bookcreator_saveselection') . "</b></legend>"; $renderer->doc .= '<input type="text" class="edit" value="' . $title . '" name="bookcreator_title" />'; $renderer->doc .= '<input type="submit" value="' . $this->getLang('bookcreator_save') . '" class="button"/>'; $renderer->doc .= '<input type="hidden" name="task" value="save" /> <input type="hidden" name="id" value="' . $ID . '" />'; $renderer->doc .= '</fieldset>'; $renderer->doc .= formSecurityToken(false); $renderer->doc .= '</form>'; //Salva selezione } $renderer->doc .= '</div>'; $renderer->doc .= "</tr></td>"; $renderer->doc .= "</table>"; } else { $renderer->doc .= $this->getLang('bookcreator_nocookies'); } // genera la lista delle selezioni salvate $result = $this->_getlist($order); if (sizeof($result) > 0) { $renderer->doc .= '<form class="button" id="bookcreator__selections__list" name="bookcreator__selections__list" method="post" action="' . wl($ID) . '">'; $renderer->doc .= "<fieldset style=\"text-align:left;\"><legend><b>" . $this->getLang('bookcreator_listselections') . "</b></legend>"; $this->_showlist($renderer, $result, true, true); $renderer->doc .= "<input type='hidden' name='task' value=''/>"; $renderer->doc .= "<input type='hidden' name='page' value=''/>"; $renderer->doc .= "<input type='hidden' name='id' value='{$ID}'/>"; $renderer->doc .= formSecurityToken(false); $renderer->doc .= '</fieldset>'; $renderer->doc .= '</form>'; } // genera la lista delle selezioni salvate } } return false; } else { if ($mode == 'xhtml') { // genera la lista delle selezioni salvate $result = $this->_getlist($order, $num); if (sizeof($result) > 0) { $renderer->doc .= '<form class="button" id="bookcreator__selections__list" name="bookcreator__selections__list" method="post" action="' . wl($this->getConf('book_page')) . '">'; $this->_showlist($renderer, $result); $renderer->doc .= "<input type='hidden' name='task' value=''/>"; $renderer->doc .= "<input type='hidden' name='page' value=''/>"; $renderer->doc .= "<input type='hidden' name='id' value='" . $this->getConf('book_page') . "'/>"; $renderer->doc .= formSecurityToken(false); $renderer->doc .= '</form>'; } // genera la lista delle selezioni salvate } return false; } }
/** * Adapted version of pageTemplate() function */ function _pageTemplate($data) { global $conf, $INFO; $id = $data['id']; $user = $_SERVER['REMOTE_USER']; $tpl = io_readFile(DOKU_PLUGIN . 'blog/_template.txt'); // standard replacements $replace = array('@ID@' => $id, '@NS@' => $data['ns'], '@PAGE@' => strtr(noNS($id), '_', ' '), '@USER@' => $user, '@NAME@' => $INFO['userinfo']['name'], '@MAIL@' => $INFO['userinfo']['mail'], '@DATE@' => strftime($conf['dformat'])); // additional replacements $replace['@TITLE@'] = $data['title']; // tag if tag plugin is available if (@file_exists(DOKU_PLUGIN . 'tag/syntax/tag.php') && !plugin_isdisabled('tag')) { $replace['@TAG@'] = "\n\n{{tag>}}"; } else { $replace['@TAG@'] = ''; } // discussion if discussion plugin is available if (@file_exists(DOKU_PLUGIN . 'discussion/syntax/comments.php') && !plugin_isdisabled('discussion')) { $replace['@DISCUSSION@'] = "~~DISCUSSION~~"; } else { $replace['@DISCUSSION@'] = ''; } // linkbacks if linkback plugin is available if (@file_exists(DOKU_PLUGIN . 'linkback/syntax.php') && !plugin_isdisabled('linkback')) { $replace['@LINKBACK@'] = "~~LINKBACK~~"; } else { $replace['@LINKBACK@'] = ''; } // do the replace $tpl = str_replace(array_keys($replace), array_values($replace), $tpl); return $tpl; }
<?php $idArray = explode(":", $ID); if (($ID == "start" or !plugin_isdisabled('translation') and strlen($idArray[0]) == 2 and $idArray[1] == "start") and $ACT == "show" and (!empty($_SERVER['REMOTE_USER']) and tpl_getConf('hideLanding') == 0 or empty($_SERVER['REMOTE_USER'])) and $INPUT->str('id') == null) { ?> <div id="mixture__landing" class="container full-width items-center text-center mixture-fadein<?php echo strpos(tpl_getConf('elements'), 'header_landing_bgimage') !== false ? ' hasBgImage' : ''; ?> "> <?php if (strpos(tpl_getConf('elements'), 'header_landing_text') !== false) { ?> <div class="container full-width"> <span id="mixture__landing_title" class="container full-width justify-center"><a href="#dokuwiki__top" title="<?php echo $lang['btn_top']; ?> "><?php echo $conf['title']; ?> </a></span> <span id="mixture__landing_tagline" class="container full-width justify-center"><a href="#dokuwiki__top" title="<?php echo $lang['btn_top']; ?> "><?php echo $conf['tagline']; ?> </a></span> <span id="mixture__landing_skip" class="container full-width justify-center"><a href="#dokuwiki__top" title="<?php echo $lang['btn_top']; ?> "><span><?php
/** * Loads a given helper plugin (if enabled) * * @author Esther Brunner <*****@*****.**> * * @param $name name of plugin to load * @param $msg message to display in case the plugin is not available * * @return object helper plugin object */ function loadHelper($name, $msg) { if (!plugin_isdisabled($name)) { $obj =& plugin_load('helper', $name); } else { $obj = null; } if (is_null($obj) && $msg) { msg("Helper plugin {$name} is not available or invalid.", -1); } return $obj; }
/** * INITALIZE TEMPLATE * * Load usefull plugins' helpers. */ function _mixture_init() { global $ID, $conf, $JSINFO; // New global variables global $styleIni, $glyphs, $uhp, $trs; // Parse style.ini file (has to be here rather than in _mixture_init() to be abble to use it's data for fonts declarations) $styleIni = array(); // Look for a customized 'style.ini' generated by Styling plugin if (is_file(DOKU_CONF . "tpl/mixture/style.ini")) { $styleIni = parse_ini_file(DOKU_CONF . "tpl/mixture/style.ini", true); } // Or for template's default 'style.ini' if (count($styleIni) == 0) { $styleIni = parse_ini_file("style.ini", true); } // Parse glyphs.conf files $glyphs = array(); // Get template's default glyphs if (is_file(tpl_incdir() . "conf/glyphs.php")) { include tpl_incdir() . "conf/glyphs.php"; } // Get custom glyphs if (is_file(DOKU_CONF . "tpl/mixture/glyphs.php")) { include DOKU_CONF . "tpl/mixture/glyphs.php"; } //dbg($glyphs); // Look for a customized 'style.ini' generated by Styling plugin if (is_file(DOKU_CONF . "tpl/mixture/style.ini")) { $styleIni = parse_ini_file(DOKU_CONF . "tpl/mixture/style.ini", true); } // Store options into $JSINFO for later use $JSINFO['ScrollDelay'] = tpl_getConf('scrollDelay'); // if ((strpos(tpl_getConf('elements'), 'header_landing_changes') !== false) or (strpos(tpl_getConf('elements'), 'header_topbar_date') !== false)) { // $JSINFO['LoadMoment'] = true; // } else { // $JSINFO['LoadMoment'] = false; // } if (strpos(tpl_getConf('elements'), 'header_landing_changes') !== false or strpos(tpl_getConf('elements'), 'header_topbar_lastchanges') !== false) { $JSINFO['LoadNewsTicker'] = true; } else { $JSINFO['LoadNewsTicker'] = false; } // Preparing usefull plugins' helpers $interwiki = getInterwiki(); $mixturePublicId = ltrim(str_replace('{NAME}', $_SERVER['REMOTE_USER'], $interwiki['user']), ':'); if (!plugin_isdisabled('userhomepage')) { $uhpHelper = plugin_load('helper', 'userhomepage'); $uhp = $uhpHelper->getElements(); if (isset($mixturePublicId) and !isset($uhp['public'])) { $uhp['public'] = array(); $uhp['public']['id'] = $mixturePublicId; } } else { // Without Userhomepage plugin, Public Page namespace is set by 'user' value in 'conf/interwiki.conf' $uhp = array(); $uhp['private'] = null; $uhp['public'] = array(); $uhp['public']['id'] = $mixturePublicId; } if (!plugin_isdisabled('translation')) { $trs = array(); $translationHelper = plugin_load('helper', 'translation'); $trs['parts'] = $translationHelper->getTransParts($ID); } else { $trs['parts'] = null; } // Adding test alerts if debug is enabled if ($_GET['debug'] == true) { msg("This is an error alert (-1)", -1); msg("This is an info message (0)", 0); msg("This is a success message (1)", 1); msg("This is a notification (2)", 2); } }
/** * Dispatches the given sidebar type to return the right content * * @author Michael Klier <*****@*****.**> */ function tpl_sidebar_dispatch($sb, $pos) { global $lang; global $conf; global $ID; global $REV; global $INFO; global $TOC; $svID = $ID; // save current ID $svREV = $REV; // save current REV $svTOC = $TOC; // save current TOC $pname = tpl_getConf('pagename'); switch ($sb) { case 'main': if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) { return; } $main_sb = $pname; if (@page_exists($main_sb) && auth_quickaclcheck($main_sb) >= AUTH_READ) { $always = tpl_getConf('main_sidebar_always'); if ($always or !$always && !getNS($ID)) { print '<div class="main_sidebar sidebar_box">' . DOKU_LF; print p_sidebar_xhtml($main_sb, $pos) . DOKU_LF; print '</div>' . DOKU_LF; } } elseif (!@page_exists($main_sb) && auth_quickaclcheck($main_sb) >= AUTH_CREATE) { if (@file_exists(DOKU_TPLINC . 'lang/' . $conf['lang'] . '/nonidebar.txt')) { $out = p_render('xhtml', p_get_instructions(io_readFile(DOKU_TPLINC . 'lang/' . $conf['lang'] . '/nosidebar.txt')), $info); } else { $out = p_render('xhtml', p_get_instructions(io_readFile(DOKU_TPLINC . 'lang/en/nosidebar.txt')), $info); } $link = '<a href="' . wl($pname) . '" class="wikilink2">' . $pname . '</a>' . DOKU_LF; print '<div class="main_sidebar sidebar_box">' . DOKU_LF; print str_replace('LINK', $link, $out); print '</div>' . DOKU_LF; } break; case 'namespace': if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) { return; } $user_ns = tpl_getConf('user_sidebar_namespace'); $group_ns = tpl_getConf('group_sidebar_namespace'); if (!preg_match("/^" . $user_ns . ":.*?\$|^" . $group_ns . ":.*?\$/", $svID)) { // skip group/user sidebars and current ID $ns_sb = _getNsSb($svID); if ($ns_sb && auth_quickaclcheck($ns_sb) >= AUTH_READ) { print '<div class="namespace_sidebar sidebar_box">' . DOKU_LF; print p_sidebar_xhtml($ns_sb, $pos) . DOKU_LF; print '</div>' . DOKU_LF; } } break; case 'user': if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) { return; } $user_ns = tpl_getConf('user_sidebar_namespace'); if (isset($INFO['userinfo']['name'])) { $user = $_SERVER['REMOTE_USER']; $user_sb = $user_ns . ':' . $user . ':' . $pname; if (@page_exists($user_sb)) { $subst = array('pattern' => array('/@USER@/'), 'replace' => array($user)); print '<div class="user_sidebar sidebar_box">' . DOKU_LF; print p_sidebar_xhtml($user_sb, $pos, $subst) . DOKU_LF; print '</div>'; } // check for namespace sidebars in user namespace too if (preg_match('/' . $user_ns . ':' . $user . ':.*/', $svID)) { $ns_sb = _getNsSb($svID); if ($ns_sb && $ns_sb != $user_sb && auth_quickaclcheck($ns_sb) >= AUTH_READ) { print '<div class="namespace_sidebar sidebar_box">' . DOKU_LF; print p_sidebar_xhtml($ns_sb, $pos) . DOKU_LF; print '</div>' . DOKU_LF; } } } break; case 'group': if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) { return; } $group_ns = tpl_getConf('group_sidebar_namespace'); if (isset($INFO['userinfo']['name'], $INFO['userinfo']['grps'])) { foreach ($INFO['userinfo']['grps'] as $grp) { $group_sb = $group_ns . ':' . $grp . ':' . $pname; if (@page_exists($group_sb) && auth_quickaclcheck(cleanID($group_sb)) >= AUTH_READ) { $subst = array('pattern' => array('/@GROUP@/'), 'replace' => array($grp)); print '<div class="group_sidebar sidebar_box">' . DOKU_LF; print p_sidebar_xhtml($group_sb, $pos, $subst) . DOKU_LF; print '</div>' . DOKU_LF; } } } break; case 'index': if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) { return; } print '<div class="index_sidebar sidebar_box">' . DOKU_LF; print ' ' . p_index_xhtml($svID, $pos) . DOKU_LF; print '</div>' . DOKU_LF; break; case 'toc': if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) { return; } if (auth_quickaclcheck($svID) >= AUTH_READ) { $toc = tpl_toc(true); // replace ids to keep XHTML compliance if (!empty($toc)) { $toc = preg_replace('/id="(.*?)"/', 'id="sb__' . $pos . '__\\1"', $toc); print '<div class="toc_sidebar sidebar_box">' . DOKU_LF; print $toc; print '</div>' . DOKU_LF; } } break; case 'toolbox': if (tpl_getConf('hideactions') && !isset($_SERVER['REMOTE_USER'])) { return; } if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) { print '<div class="toolbox_sidebar sidebar_box">' . DOKU_LF; print ' <div class="level1">' . DOKU_LF; print ' <ul>' . DOKU_LF; print ' <li><div class="li">'; tpl_actionlink('login'); print ' </div></li>' . DOKU_LF; print ' </ul>' . DOKU_LF; print ' </div>' . DOKU_LF; print '</div>' . DOKU_LF; } else { $actions = array('admin', 'revert', 'edit', 'history', 'recent', 'backlink', 'subscription', 'index', 'login', 'profile', 'top'); print '<div class="toolbox_sidebar sidebar_box">' . DOKU_LF; print ' <div class="level1">' . DOKU_LF; print ' <ul>' . DOKU_LF; foreach ($actions as $action) { if (!actionOK($action)) { continue; } // start output buffering if ($action == 'edit') { // check if new page button plugin is available if (!plugin_isdisabled('npd') && ($npd =& plugin_load('helper', 'npd'))) { $npb = $npd->html_new_page_button(true); if ($npb) { print ' <li><div class="li">'; print $npb; print '</div></li>' . DOKU_LF; } } } ob_start(); print ' <li><div class="li">'; if (tpl_actionlink($action)) { print '</div></li>' . DOKU_LF; ob_end_flush(); } else { ob_end_clean(); } } print ' </ul>' . DOKU_LF; print ' </div>' . DOKU_LF; print '</div>' . DOKU_LF; } break; case 'trace': if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) { return; } print '<div class="trace_sidebar sidebar_box">' . DOKU_LF; print ' <h1>' . $lang['breadcrumb'] . '</h1>' . DOKU_LF; print ' <div class="breadcrumbs">' . DOKU_LF; $conf['youarehere'] != 1 ? tpl_breadcrumbs() : tpl_youarehere(); print ' </div>' . DOKU_LF; print '</div>' . DOKU_LF; break; case 'extra': if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) { return; } print '<div class="extra_sidebar sidebar_box">' . DOKU_LF; @(include dirname(__FILE__) . '/' . $pos . '_sidebar.html'); print '</div>' . DOKU_LF; break; default: if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) { return; } // check for user defined sidebars if (@file_exists(DOKU_TPLINC . 'sidebars/' . $sb . '/sidebar.php')) { print '<div class="' . $sb . '_sidebar sidebar_box">' . DOKU_LF; @(require_once DOKU_TPLINC . 'sidebars/' . $sb . '/sidebar.php'); print '</div>' . DOKU_LF; } break; } // restore ID, REV and TOC $ID = $svID; $REV = $svREV; $TOC = $svTOC; }
function admin_plugin_plugin() { $this->disabled = plugin_isdisabled('plugin'); }
function call($methodname, $args) { if (!$this->hasMethod($methodname)) { return new IXR_Error(-32601, 'server error. requested method ' . $methodname . ' does not exist.'); } $method = $this->callbacks[$methodname]; // Perform the callback and send the response # Removed for DokuWiki to have a more consistent interface # if (count($args) == 1) { # // If only one paramater just send that instead of the whole array # $args = $args[0]; # } # Adjusted for DokuWiki to use call_user_func_array // args need to be an array $args = (array) $args; // Are we dealing with a function or a method? if (substr($method, 0, 5) == 'this:') { // It's a class method - check it exists $method = substr($method, 5); if (!method_exists($this, $method)) { return new IXR_Error(-32601, 'server error. requested class method "' . $method . '" does not exist.'); } // Call the method #$result = $this->$method($args); $result = call_user_func_array(array(&$this, $method), $args); } elseif (substr($method, 0, 7) == 'plugin:') { list($pluginname, $callback) = explode(':', substr($method, 7), 2); if (!plugin_isdisabled($pluginname)) { $plugin = plugin_load('action', $pluginname); return call_user_func_array(array($plugin, $callback), $args); } else { return new IXR_Error(-99999, 'server error'); } } else { // It's a function - does it exist? if (!function_exists($method)) { return new IXR_Error(-32601, 'server error. requested function "' . $method . '" does not exist.'); } // Call the function #$result = $method($args); $result = call_user_func_array($method, $args); } return $result; }
/** * checks if the submitted reCAPTCHA string is valid * * @author Adrian Schlegel <*****@*****.**> */ function _recaptchaCheck() { if (plugin_isdisabled('recaptcha') || !($recaptcha = plugin_load('helper', 'recaptcha'))) { return; } // reCAPTCHA is disabled or not available // do nothing if logged in user and no reCAPTCHA required if (!$recaptcha->getConf('forusers') && $_SERVER['REMOTE_USER']) { return; } $resp = $recaptcha->check(); if (!$resp->is_valid) { msg($recaptcha->getLang('testfailed'), -1); if ($_REQUEST['comment'] == 'save') { $_REQUEST['comment'] = 'edit'; } elseif ($_REQUEST['comment'] == 'add') { $_REQUEST['comment'] = 'show'; } } }