/**
  * Returns array of plugin names
  *
  * @return array plugin names
  */
 function get_plugin_list()
 {
     if (is_null($this->_plugin_list)) {
         $list = plugin_list('', false);
         $this->_plugin_list = $list;
     }
     return $this->_plugin_list;
 }
Esempio n. 2
0
function p_get_parsermodes()
{
    global $conf;
    //reuse old data
    static $modes = null;
    if ($modes != null) {
        return $modes;
    }
    //import parser classes and mode definitions
    require_once DOKU_INC . 'includes/parser/parser.php';
    // we now collect all syntax modes and their objects, then they will
    // be sorted and added to the parser in correct order
    $modes = array();
    // add syntax plugins
    $pluginlist = plugin_list('syntax');
    if (count($pluginlist)) {
        global $PARSER_MODES;
        $obj = null;
        foreach ($pluginlist as $p) {
            if (!($obj =& plugin_load('syntax', $p))) {
                continue;
            }
            //attempt to load plugin into $obj
            $PARSER_MODES[$obj->getType()][] = "plugin_{$p}";
            //register mode type
            //add to modes
            $modes[] = array('sort' => $obj->getSort(), 'mode' => "plugin_{$p}", 'obj' => $obj);
            unset($obj);
            //remove the reference
        }
    }
    // add default modes
    $std_modes = array('listblock', 'preformatted', 'notoc', 'nocache', 'header', 'table', 'linebreak', 'footnote', 'hr', 'unformatted', 'php', 'html', 'code', 'file', 'quote', 'multiplyentity', 'quotes', 'internallink', 'rss', 'media', 'externallink', 'emaillink', 'windowssharelink', 'eol');
    foreach ($std_modes as $m) {
        $class = "Doku_Parser_Mode_{$m}";
        $obj = new $class();
        $modes[] = array('sort' => $obj->getSort(), 'mode' => $m, 'obj' => $obj);
    }
    // add formatting modes
    $fmt_modes = array('strong', 'emphasis', 'underline', 'monospace', 'subscript', 'superscript', 'deleted');
    foreach ($fmt_modes as $m) {
        $obj = new Doku_Parser_Mode_formatting($m);
        $modes[] = array('sort' => $obj->getSort(), 'mode' => $m, 'obj' => $obj);
    }
    //sort modes
    usort($modes, 'p_sort_modes');
    return $modes;
}
/**
 * prints needed HTML to include plugin CSS and JS files
 *
 * @deprecated - now handled by the style and script loader in lib/exe
 */
function plugin_printCSSJS()
{
    global $conf;
    if (isset($conf['pluginmanager']) && $conf['pluginmanager'] && @file_exists(DOKU_INC . 'lib/plugins/plugin_style.css')) {
        // individual plugin instances of the files swept into one file each
        $dir = "lib/plugins/plugin_";
        if (@file_exists(DOKU_INC . $dir . 'style.css')) {
            print '  <link rel="stylesheet" type="text/css" href="' . DOKU_BASE . $dir . 'style.css" />' . "\n";
        }
        if (@file_exists(DOKU_INC . $dir . 'screen.css')) {
            print '  <link rel="stylesheet" media="screen" type="text/css" href="' . DOKU_BASE . $dir . 'screen.css" />' . "\n";
        }
        if (@file_exists(DOKU_INC . $dir . 'print.css')) {
            print '  <link rel="stylesheet" media="print" type="text/css" href="' . DOKU_BASE . $dir . 'print.css" />' . "\n";
        }
        if (@file_exists(DOKU_INC . $dir . 'script.js')) {
            print '  <script type="text/javascript" language="javascript" charset="utf-8" src="' . DOKU_BASE . $dir . 'script.js"></script>' . "\n";
        }
    } else {
        // no plugin manager (or aggregate files not setup) so individual instances of these files for any plugin that uses them
        $plugins = plugin_list();
        foreach ($plugins as $p) {
            $dir = "lib/plugins/{$p}/";
            if (@file_exists(DOKU_INC . $dir . 'style.css')) {
                print '  <link rel="stylesheet" type="text/css" href="' . DOKU_BASE . $dir . 'style.css" />' . "\n";
            }
            if (@file_exists(DOKU_INC . $dir . 'screen.css')) {
                print '  <link rel="stylesheet" media="screen" type="text/css" href="' . DOKU_BASE . $dir . 'screen.css" />' . "\n";
            }
            if (@file_exists(DOKU_INC . $dir . 'print.css')) {
                print '  <link rel="stylesheet" media="print" type="text/css" href="' . DOKU_BASE . $dir . 'print.css" />' . "\n";
            }
            if (@file_exists(DOKU_INC . $dir . 'script.js')) {
                print '  <script type="text/javascript" language="javascript" charset="utf-8" src="' . DOKU_BASE . $dir . 'script.js"></script>' . "\n";
            }
        }
    }
}
Esempio n. 4
0
function ws_run_report($window_name, $form = '')
{
    // Get the plugin location info.
    $reportlist = plugin_list('report');
    // Loop through the list of reports till we find the matching name
    foreach ($reportlist as $report) {
        if ($report['name'] == $form['report']) {
            // Load the report include file
            if (require_once $report['path']) {
                // Run the report and put it in the report_content box
                list($status, $report_output) = rpt_run($form, 'html');
            }
        }
    }
    // Insert the new html into the window
    // Instantiate the xajaxResponse object
    $response = new xajaxResponse();
    $response->addAssign("report_content", "innerHTML", $report_output);
    if ($js) {
        $response->addScript($js);
    }
    return $response->getXML();
}
 function __call($name, $arguments)
 {
     if (in_array('highlight', plugin_list())) {
         die('ERROR: highlight loaded');
     }
     require dirname(__FILE__) . '/mapping.php';
     $this->conf['m'] = $m;
     $m = $this->conf['m'];
     $args = func_get_args();
     array_shift($args);
     $args = $args[0];
     if (substr($name, -5) === '_open') {
         $type = 'OPEN';
         $multi = true;
         $this->opened++;
     } elseif (substr($name, -6) === '_close') {
         $type = 'CLOSE';
         $multi = true;
         $this->opened--;
     } else {
         $type = 'SINGLE';
         $multi = false;
     }
     $tag = str_replace(array('_open', '_close'), '', $name);
     // not nice but short
     // Footnote
     if (!isset($this->footnote_open)) {
         $this->footnote_open = false;
     }
     if ($tag == 'footnote') {
         $this->footnote_open = $type == 'OPEN';
     }
     if (isset($m[$tag])) {
         $mapping = $m[$tag];
     } else {
         foreach ($m as $key => $value) {
             if (in_array($tag, $value['alias'])) {
                 $mapping = $m[$key];
                 break;
             }
         }
     }
     if (!is_array($mapping)) {
         echo '<span style="color:red; display:block">No mapping found for function "' . $name . '()" and tag "' . $tag . '"</span>' . PHP_EOL;
         $this->doc = 'NO MAPPING FOUND' . $this->doc;
         exit;
     }
     // Use different template when p tag (paragraph) is open
     if (($this->pTagOpen or $this->sectionTagOpen) and isset($mapping['template_p_open'])) {
         $mapping['template'] = $mapping['template_p_open'];
     }
     // Special template for Headline level 1
     if (in_array($name, array('header', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'))) {
         if ($args[1] == 1) {
             $mapping['template'] = $mapping['template_level_0'];
         } else {
             // Reduce level by 1
             $args[1]--;
         }
     }
     // Get the corresponding part of the template
     $templateParts = explode($mapping['replacement'], $mapping['template']);
     switch ($type) {
         case 'OPEN':
             $doc = self::cleanTemplate($templateParts[0]);
             break;
         case 'CLOSE':
             $doc = self::cleanTemplate($templateParts[1]);
             break;
         case 'SINGLE':
             // $args[0] = str_replace('"',      '&quot;',   $args[0]); // seems not to work in headlines
             $args[0] = str_replace('&', '&amp;', $args[0]);
             $args[0] = str_replace('\'', '&apos;', $args[0]);
             $args[0] = str_replace('<', '&lt;', $args[0]);
             $args[0] = str_replace('>', '&gt;', $args[0]);
             if (isset($args[1]) and strpos($name, 'link') != false) {
                 $args[1] = str_replace('&', '&amp;', $args[1]);
                 $args[1] = str_replace('\'', '&apos;', $args[1]);
                 $args[1] = str_replace('<', '&lt;', $args[1]);
                 $args[1] = str_replace('>', '&gt;', $args[1]);
             }
             if ($name == 'emaillink') {
                 $args[0] = 'mailto:' . $args[0];
             }
             // Add link text if there is none
             if (($name === 'internallink' or $name === 'externallink' or $name === 'emaillink') and empty($args[1])) {
                 $args[1] = $args[0];
             }
             // Link text " -> &qout;
             if (($name === 'internallink' or $name === 'externallink' or $name === 'emaillink') and empty($args[1])) {
                 $args[1] = str_replace('"', '&quot;', $args[1]);
             }
             // Full URL for internal links
             if ($name === 'internallink') {
                 $args[0] = DOKU_URL . $args[0];
             }
             // Code linebreaks
             if ($name === 'code') {
                 $args[0] = str_replace("\n", '<dir-break-space/>', $args[0]);
             }
             // Replace linebreaks with a single space
             // <line-break/> ???
             $args[0] = preg_replace("~ {0,1}\n~", ' ', $args[0]);
             // Geschützte Leerzeichen für "S. 1234"
             // $args[0] = preg_replace('~\sS\.([ ]{1})\d+~', '<dir-break-space/>', $args[0]); // Seems not to work
             // Geviertstrich und Halbgeviertstrich
             // TODO utf8 codes possible?
             // TODO longer lines like "hr" should be rendered first to not confuse this
             $args[0] = str_replace(array('---', '--'), array('—', '–'), $args[0]);
             // Auslassungspunkte
             $args[0] = str_replace(array('...'), array('…'), $args[0]);
             // If not header do replace
             if (!in_array($name, array('header', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'))) {
                 $args[0] = str_replace('"', '&quot;', $args[0]);
                 // This might depend on the way " are used in the XML template!!!
             }
             // Highlight
             // This is incompatible with the highlight plugin.
             // make sure in /lib/plugins/highlight/syntax.php
             // "if (strpos($_SERVER['REQUEST_URI'], '_export/mellelexport') !== false) {} else {" is added at the top!
             // There might be a caching problem! When it does not show the highlighted text try to add "&dummy=123" to the download URL
             if (preg_match('~&lt;hi ~', $args[0])) {
                 // &lt;hi #ff4500&gt;bunt&lt;/hi&gt;
                 // U = not greedy
                 $args[0] = preg_replace('~&lt;hi #([a-zA-Z0-9]+)&gt;(.*)&lt;/hi&gt;~Ui', '</c><c style=\'cs-0\' marker=\'$1\'>$2</c><c style=\'cs-0\'>', $args[0]);
                 // $args[0] = preg_replace('~&lt;hi #[a-zA-Z0-9]+&gt;~',                   '</c><c style=\'cs-0\' marker=\'1\'>', $args[0]);
                 // Replace marker with Mellel marker ids
                 $args[0] = preg_replace_callback('~marker=\'([a-zA-Z0-9]+)\'~', 'callback_marker', $args[0]);
             }
             $args[0] = str_replace('&lt;/hi&gt;', '</c><c style=\'cs-0\'>', $args[0]);
             $string = str_replace($mapping['replacement'], $args[0], self::cleanTemplate($mapping['template']));
             $doc = $string;
             break;
         default:
             die('No type set');
     }
     // Formating within footnote text
     if ($this->footnote_open and $tag != 'footnote') {
         $doc = str_replace(' style="cs-0"', ' style="cs-6"', $doc);
     }
     // Check the given arguments and parse additional information
     if (!$multi) {
         array_shift($args);
         // remove the first entry
     }
     if (isset($args)) {
         $doc = str_replace($mapping['subpattern'], $args, $doc);
     }
     // Set header length
     if ($tag === 'header' or isset($key) and $key === 'header') {
         if (function_exists('mb_strlen')) {
             $hederLength = mb_strlen($arguments[0]);
         } else {
             $hederLength = strlen($arguments[0]);
         }
         $doc = str_replace('{{LENGTH}}', $hederLength + 10, $doc);
     }
     // :?: --> rendered as a yellow questionmark image
     $doc = str_replace(array(':?:'), array('<c style=\'cs-0\' marker=\'1\'>?</c>'), $doc);
     if (DEBUG) {
         // all args excluded the first one
         $tmp_args = func_get_args();
         array_shift($tmp_args);
         $tmp_args = $tmp_args[0];
         echo '<tr><td></td><td style="vertical-align: top;">' . $tag . '</td><td></td><td style="vertical-align: top;">' . $type . '</td><td>&nbsp;&nbsp;</td><td style="vertical-align: top;">' . var_export($tmp_args, 1) . '</td><td style="font-family: monospace;">' . trim(htmlentities($doc, NULL, 'UTF-8')) . '</td></tr>';
     }
     $this->doc .= $doc;
     $this->lastTag = $name;
     if ($tag == 'p') {
         if ($type == 'OPEN') {
             $this->pTagOpen = TRUE;
         } else {
             $this->pTagOpen = FALSE;
         }
     }
     if ($tag == 'section') {
         if ($type == 'OPEN') {
             $this->sectionTagOpen = TRUE;
         } else {
             $this->sectionTagOpen = FALSE;
         }
     }
 }
Esempio n. 6
0
function ona_sql($options = "")
{
    // The important globals
    global $conf, $onadb, $base;
    // Version - UPDATE on every edit!
    $version = '1.05';
    // TODO: Maybe make this into a sys_config option
    $srvdir = dirname($base) . "/sql";
    printmsg('DEBUG => ona_sql(' . $options . ') called', 3);
    // Parse incoming options string to an array
    $options = parse_options($options);
    // Sanitize delimeter
    if (!$options['delimiter']) {
        $options['delimiter'] = ':';
    }
    // fix up the escaped ' marks.  may need the = and & stuff too????
    $options['sql'] = str_replace('\\\'', '\'', $options['sql']);
    $options['sql'] = str_replace('\\=', '=', $options['sql']);
    // Set "options[commit] to no if it's not set
    if (!array_key_exists('commit', $options)) {
        $options['commit'] = 'N';
    } else {
        $options['commit'] = sanitize_YN($options['commit'], 'N');
    }
    // Set "options[commit] to no if it's not set
    if (!array_key_exists('dataarray', $options)) {
        $options['dataarray'] = 'N';
    } else {
        $options['dataarray'] = sanitize_YN($options['dataarray'], 'N');
    }
    // Set "options[header] to yes if it's not set
    if (!array_key_exists('header', $options)) {
        $options['header'] = 'Y';
    } else {
        $options['header'] = sanitize_YN($options['header'], 'Y');
    }
    // Check permissions
    if (!auth('ona_sql')) {
        $self['error'] = "Permission denied!";
        printmsg($self['error'], 0);
        return array(10, $self['error'] . "\n");
    }
    // Return the usage summary if we need to
    if ($options['help'] or !($options['list'] and !$options['sql'] or !$options['list'] and $options['sql'])) {
        // NOTE: Help message lines should not exceed 80 characters for proper display on a console
        return array(1, <<<EOM

ona_sql-v{$version}
Runs the specified SQL query on the database and prints the result

  Synopsis: ona_sql [KEY=VALUE] ...

  Required:
    sql=STATEMENT|FILENAME   quoted SQL statement to execute
    OR
    list                     lists the SQL files available on the server side

  Optional:
    show                     displays contents of SQL, gives usage etc
    commit=yes|no            commit the transaction (no)
    header=yes|no            display record header (yes)
    delimiter=DELIMITER      record delimiter for output (:)
    (1,2,..)=VALUE           bind variables, replaces ? in query sequentially.
                             the first ? found is replaced by 1=value, and so on

  Notes:
    * Query is sent to the configured OpenNetAdmin database server.
    * The use of bind variables requires your options to match positionally.
    * The SQL option will be tried first as a local file, then as a server
      file, then as a raw text SQL query.  Filenames are case sensitive.
    * Server based SQL files are located in {$srvdir}
    * Some plugins may provide their own SQL dir inside the plugin directory
    * Use the show option to display contents of SQL files, this should contain
      a long description and any usage information that is needed.


EOM
);
    }
    // TODO: check that the user has admin privs? or at least a ona_sql priv
    // Get a list of the files
    $plugins = plugin_list();
    $files = array();
    $srvdirs = array();
    array_push($srvdirs, $srvdir);
    // add a local sql dir as well so they don't get overrriden by installs
    array_push($srvdirs, dirname($base) . '/www/local/sql');
    // loop through the plugins and find files inside of their sql directories.
    foreach ($plugins as $plug) {
        array_push($srvdirs, $plug['path'] . '/sql');
    }
    // Loop through each of our plugin directories and the default directory to find .sql files
    foreach ($srvdirs as $srvdir) {
        if ($handle = @opendir($srvdir)) {
            while (false !== ($file = readdir($handle))) {
                if ($file != "." && $file != ".." && substr($file, -4) == '.sql') {
                    // Build an array of filenames
                    array_push($files, $srvdir . '/' . $file);
                }
            }
            closedir($handle);
        }
    }
    // sort the file names
    asort($files);
    // List the sql files on the server side
    if ($options['list'] == 'Y') {
        $text .= sprintf("\n%-25s%s\n", 'FILE', 'DESCRIPTION');
        $text .= sprintf("%'-80s\n", '');
        // Loop through and display info about the files
        foreach ($files as $file) {
            // Open the file and get the first line, this is the short description
            $fh = fopen($file, 'r');
            $desc = rtrim(fgets($fh));
            fclose($fh);
            // Print the info
            $text .= sprintf("%-25s%s\n", basename($file), $desc);
        }
        $text .= "\n";
        return array(0, $text);
    }
    // Check that the sql variable passsed matches a file name locally, if it does, open it and replace $options['sql'] with it
    // Loop through files array till we find the right file
    $foundfile = false;
    foreach ($files as $file) {
        if (strstr($file, $options['sql'])) {
            $options['sql'] = trim(file_get_contents($file));
            $foundfile = true;
        }
    }
    // if we have not found a file on the server and the sql option does end in .sql then print a message that we coulnt find a file
    // otherwise assume it is a sql statement being passed at the cli
    if ($foundfile == false and substr($options['sql'], -4) == '.sql') {
        $self['error'] = "ERROR => Unable to find specified SQL stored on server: {$options['sql']}";
        printmsg($self['error'], 2);
        return array(10, $self['error'] . "\n");
    }
    // Show the contents of the sql query for usage info etc.
    if ($options['show'] == 'Y') {
        $text .= $options['sql'] . "\n\n";
        return array(0, $text);
    }
    // Count how many ?s there are in the sql query. that must match how many sqlopts are passed
    // if this is an oracle database you could change the ? to a :.. more work on this however needs to be done
    $qvars = substr_count($options['sql'], '?');
    // loop through the options based on how many qvars are in the sql statement. print an error if we didnt
    // get a variable to use in the sql statement
    for ($i = 1; $i <= $qvars; $i++) {
        if (!array_key_exists($i, $options)) {
            $self['error'] = "ERROR => You did not supply a value for bind variable {$i}!";
            printmsg($self['error'], 2);
            return array(10, $self['error'] . "\n");
        }
        // assign the variables to sqlopts
        $sqlopts[$i] = $options[$i];
    }
    // One last check to be sure
    // Count how many times ? is in the sql statement.  there should be that many elements in sqlopts
    if (count($sqlopts) != $qvars) {
        $self['error'] = "ERROR => SQL query and bind variable count did not match.";
        printmsg($self['error'], 2);
        return array(1, $self['error'] . "\n");
    }
    printmsg("DEBUG => [ona_sql] Running SQL query: {$options['sql']}", 5);
    // Run the query
    $rs = $onadb->Execute($options['sql'], $sqlopts);
    if ($rs === false) {
        $self['error'] = "ERROR => SQL query failed: " . $onadb->ErrorMsg() . "\n";
        return array(2, $self['error']);
    }
    $text = "";
    $dataarr = array();
    // If we got a record, that means they did a select .. display it
    if ($rs->RecordCount()) {
        $build_header = 1;
        $i = 0;
        // Loop through each record returned by the sql query
        while (!$rs->EOF) {
            $i++;
            $record = $rs->FetchRow();
            $dataarr[$i] = $record;
            // Build the header if we need to
            if ($build_header == 1 and $options['header'] == 'Y') {
                $build_header = 0;
                foreach (array_keys($record) as $key) {
                    $text .= $key . $options['delimiter'];
                }
                $text = preg_replace("/{$options['delimiter']}\$/", "", $text);
                $text .= "\n";
            }
            // Display the row
            foreach (array_keys($record) as $key) {
                $text .= $record[$key] . $options['delimiter'];
            }
            $text = preg_replace("/{$options['delimiter']}\$/", "", $text);
            $text .= "\n";
        }
    } else {
        $text .= "NOTICE => SQL executed successfully - no records returned\n";
    }
    // If we want the recordset returned instead of the text
    if ($options['dataarray'] == 'Y') {
        return array(0, $dataarr);
    }
    // Unless the user said YES to commit, return a non-zero
    // exit status so that module_run.php doesn't commit the DB transaction.
    $return = 1;
    if ($options['commit'] == 'Y') {
        $return = 0;
    }
    return array($return, $text);
}
Esempio n. 7
0
function plugin_multi_edit()
{
    $selected = ps('selected');
    $method = ps('edit_method');
    if (!$selected or !is_array($selected)) {
        return plugin_list();
    }
    $where = "name IN ('" . join("','", doSlash($selected)) . "')";
    switch ($method) {
        case 'delete':
            safe_delete('txp_plugin', $where);
            break;
        case 'changestatus':
            safe_update('txp_plugin', 'status = (1-status)', $where);
            break;
        case 'changeorder':
            $order = min(max(intval(ps('order')), 1), 9);
            safe_update('txp_plugin', 'load_order = ' . $order, $where);
            break;
    }
    $message = gTxt('plugin_' . ($method == 'delete' ? 'deleted' : 'updated'), array('{name}' => join(', ', $selected)));
    plugin_list($message);
}
Esempio n. 8
0
list($wspl, $wsjs) = workspace_plugin_loader('desktop_firsttasks', $record, $extravars);
print $wspl;
print <<<EOL



            <!-- END OF FIRST COLUMN OF SMALL BOXES -->
            </td>


        </tr>
        <tr>
            <td nowrap="true" valign="top" style="padding: 15px;">
EOL;
// Get all the plugin based worspace items
$wspl_list = plugin_list('wspl_item');
// Load all the dynamic plugins
foreach ($wspl_list as $p) {
    list($wspl, $wsjs) = workspace_plugin_loader($p['path'], $record, $extravars);
    print $wspl;
    $ws_plugin_js .= $wsjs;
}
print <<<EOL
            </td>
        </tr>
        </table>

        <!-- Print the MOTD info if any -->
        <div>{$MOTD}</div>

        </div>
Esempio n. 9
0
 /**
  * Receives current values for the setting $key
  *
  * @param mixed $default   default setting value
  * @param mixed $local     local setting value
  * @param mixed $protected protected setting value
  */
 function initialize($default, $local, $protected)
 {
     $format = $this->_format;
     foreach (plugin_list('renderer') as $plugin) {
         $renderer = plugin_load('renderer', $plugin);
         if (method_exists($renderer, 'canRender') && $renderer->canRender($format)) {
             $this->_choices[] = $plugin;
             $info = $renderer->getInfo();
             $this->_prompts[$plugin] = $info['name'];
         }
     }
     parent::initialize($default, $local, $protected);
 }
Esempio n. 10
0
/**
 * Return an two-dimensional array with strings from the language file of each plugin.
 *
 * - $lang['js'] must be an array.
 * - Nothing is returned for plugins without an entry for $lang['js']
 *
 * @author Gabriel Birke <*****@*****.**>
 */
function js_pluginstrings()
{
    global $conf;
    $pluginstrings = array();
    $plugins = plugin_list();
    foreach ($plugins as $p) {
        if (isset($lang)) {
            unset($lang);
        }
        if (@file_exists(DOKU_PLUGIN . "{$p}/lang/en/lang.php")) {
            include DOKU_PLUGIN . "{$p}/lang/en/lang.php";
        }
        if (isset($conf['lang']) && $conf['lang'] != 'en' && @file_exists(DOKU_PLUGIN . "{$p}/lang/" . $conf['lang'] . "/lang.php")) {
            include DOKU_PLUGIN . "{$p}/lang/" . $conf['lang'] . "/lang.php";
        }
        if (isset($lang['js'])) {
            $pluginstrings[$p] = $lang['js'];
        }
    }
    return $pluginstrings;
}
Esempio n. 11
0
function plugin_multi_edit()
{
    $selected = ps('selected');
    $method = ps('edit_method');
    if (!$selected or !is_array($selected)) {
        return plugin_list();
    }
    $where = "name IN ('" . join("','", doSlash($selected)) . "')";
    switch ($method) {
        case 'delete':
            foreach ($selected as $name) {
                if (safe_field('flags', 'txp_plugin', "name ='" . doSlash($name) . "'") & PLUGIN_LIFECYCLE_NOTIFY) {
                    load_plugin($name, true);
                    callback_event("plugin_lifecycle.{$name}", 'disabled');
                    callback_event("plugin_lifecycle.{$name}", 'deleted');
                }
            }
            safe_delete('txp_plugin', $where);
            break;
        case 'changestatus':
            foreach ($selected as $name) {
                if (safe_field('flags', 'txp_plugin', "name ='" . doSlash($name) . "'") & PLUGIN_LIFECYCLE_NOTIFY) {
                    $status = safe_field('status', 'txp_plugin', "name ='" . doSlash($name) . "'");
                    load_plugin($name, true);
                    // NB: won't show returned messages anywhere due to potentially overwhelming verbiage.
                    callback_event("plugin_lifecycle.{$name}", $status ? 'disabled' : 'enabled');
                }
            }
            safe_update('txp_plugin', 'status = (1-status)', $where);
            break;
        case 'changeorder':
            $order = min(max(intval(ps('order')), 1), 9);
            safe_update('txp_plugin', 'load_order = ' . $order, $where);
            break;
    }
    $message = gTxt('plugin_' . ($method == 'delete' ? 'deleted' : 'updated'), array('{name}' => join(', ', $selected)));
    plugin_list($message);
}
Esempio n. 12
0
 function get_plugin_list()
 {
     if (is_null($this->_plugin_list)) {
         $list = plugin_list('', true);
         // all plugins, including disabled ones
         // remove this plugin from the list
         $idx = array_search('config', $list);
         unset($list[$idx]);
         trigger_event('PLUGIN_CONFIG_PLUGINLIST', $list);
         $this->_plugin_list = $list;
     }
     return $this->_plugin_list;
 }
Esempio n. 13
0
 /**
  * @return array all plugin methods.
  */
 public function getPluginMethods()
 {
     if ($this->pluginMethods === null) {
         $this->pluginMethods = array();
         $plugins = plugin_list('remote');
         foreach ($plugins as $pluginName) {
             $plugin = plugin_load('remote', $pluginName);
             if (!is_subclass_of($plugin, 'DokuWiki_Remote_Plugin')) {
                 throw new RemoteException("Plugin {$pluginName} does not implement DokuWiki_Remote_Plugin");
             }
             $methods = $plugin->_getMethods();
             foreach ($methods as $method => $meta) {
                 $this->pluginMethods["plugin.{$pluginName}.{$method}"] = $meta;
             }
         }
     }
     return $this->pluginMethods;
 }
 function _html_admin()
 {
     global $ID;
     global $INFO;
     global $lang;
     global $conf;
     global $auth;
     // build menu of admin functions from the plugins that handle them
     $pluginlist = plugin_list('admin');
     $menu = array();
     foreach ($pluginlist as $p) {
         if (($obj =& plugin_load('admin', $p)) === NULL) {
             continue;
         }
         // check permissions
         if ($obj->forAdminOnly() && !$INFO['isadmin']) {
             continue;
         }
         $menu[$p] = array('plugin' => $p, 'prompt' => $obj->getMenuText($conf['lang']), 'sort' => $obj->getMenuSort());
     }
     // check if UserManager available
     $usermanageravailable = true;
     if (!isset($auth)) {
         $usermanageravailable = false;
     } else {
         if (!$auth->canDo('getUsers')) {
             $usermanageravailable = false;
         }
     }
     // output main tasks
     ptln('<h1>' . $this->getLang('pageheader') . '</h1>');
     ptln('<div id="admin__maintable">');
     ptln('  <div id="admin__tasks">');
     if ($INFO['isadmin']) {
         if ($usermanageravailable) {
             ptln('    <div id="admin__usermanager"><a href="' . wl($ID, 'do=admin&amp;page=usermanager') . '">' . $menu[usermanager]['prompt'] . '</a></div>');
         }
         ptln('    <div id="admin__acl"><a href="' . wl($ID, 'do=admin&amp;page=acl') . '">' . $menu['acl']['prompt'] . '</a></div>');
         ptln('    <div id="admin__plugin"><a href="' . wl($ID, 'do=admin&amp;page=plugin') . '">' . $menu['plugin']['prompt'] . '</a></div>');
         ptln('    <div id="admin__config"><a href="' . wl($ID, 'do=admin&amp;page=config') . '">' . $menu['config']['prompt'] . '</a></div>');
     } else {
         ptln('&nbsp');
     }
     ptln('  </div>');
     ptln('  <div id="admin__version">');
     ptln('    <div><b>' . $this->getLang('wiki_version') . '</b><br/>' . getVersion() . '</div>');
     ptln('    <div><b>' . $this->getLang('php_version') . '</b><br/>' . phpversion() . '</div>');
     ptln('  </div>');
     ptln('</div>');
     // remove the four main plugins
     unset($menu['acl']);
     if ($usermanageravailable) {
         unset($menu['usermanager']);
     }
     unset($menu['config']);
     unset($menu['plugin']);
     // output the remaining menu
     usort($menu, 'p_sort_modes');
     ptln('<h2>' . $this->getLang('more_adminheader') . '</h2>');
     ptln('<div class="level2">');
     echo $this->render($this->getLang('more_admintext'));
     ptln('<ul id="admin__pluginlist">');
     foreach ($menu as $item) {
         if (!$item['prompt']) {
             continue;
         }
         ptln('  <li class="level1"><div class="li"><a href="' . wl($ID, 'do=admin&amp;page=' . $item['plugin']) . '">' . $item['prompt'] . '</a></div></li>');
     }
     ptln('</ul></div>');
 }
Esempio n. 15
0
<?php

/**
 * Language file for fckg in UTF-8
 *  
 * @author:     Ianka Kryukov <*****@*****.**>
 */
$lang['groups'] = "Разделенный запятыми список групп, которым разрешено отключать таймер блокировки";
$lang['middot'] = "Разделенный запятыми список групп using &amp;middot; for &amp;nbsp;";
$lang['big_files'] = "Отметте чтобы защитить редактирование больших (oversized) файлов";
$lang['big_file_sz'] = "Размер большого (oversized) файла (в байтах)";
$lang['big_file_tm'] = "Обработка большого (oversized) файла будет закончена через (секунд):";
$lang['fck_preview'] = "FCK Preview Group";
$lang['guest_toolbar'] = "Отображать ли панель для незарегистрированных пользователей";
$lang['guest_media'] = "Могут ли незарегистрированные пользователи вставлять ссылки на медиа файлы";
$lang['open_upload'] = "Могут ли незарегистрированные пользователи загружать файлы";
$list = plugin_list('syntax');
$list = implode(", ", $list);
$lang['xcl_plugins'] = "Разделенный запятыми список плагинов Immutable Syntax. " . "Их имена должны быть точно такими же, как в этом списке инсталлированных плагинов: {$list}";
$lang['default_fb'] = "Доступ для просмотра файлов по умолчанию. Если выбрать none, то ACL не будет использоваться.";
$lang['openfb'] = "Открытый просмотр файлов. Это дает пользователю доступ ко всей структуре папок, несмотря на то, имеет ли он права на это или нет. При этом ACL применяется для разрешения загрузки.";
$lang['csrf'] = "Если Вы получаете CSRF предупреждения, отметте этот пункт.";
Esempio n. 16
0
 /**
  * event_handler
  *
  * constructor, loads all action plugins and calls their register() method giving them
  * an opportunity to register any hooks they require
  */
 function Doku_Event_Handler()
 {
     // load action plugins
     $plugin = NULL;
     $pluginlist = plugin_list('action');
     foreach ($pluginlist as $plugin_name) {
         $plugin =& plugin_load('action', $plugin_name);
         if ($plugin !== NULL) {
             $plugin->register($this);
         }
     }
 }
Esempio n. 17
0
 /**
  * list all installed plugins
  *
  * uses some of the original renderer methods
  */
 function _helpermethods_xhtml(Doku_Renderer &$renderer)
 {
     $plugins = plugin_list('helper');
     foreach ($plugins as $p) {
         if (!($po = plugin_load('helper', $p))) {
             continue;
         }
         if (!method_exists($po, 'getMethods')) {
             continue;
         }
         $methods = $po->getMethods();
         $info = $po->getInfo();
         $hid = $this->_addToTOC($info['name'], 2, $renderer);
         $doc = '<h2><a name="' . $hid . '" id="' . $hid . '">' . hsc($info['name']) . '</a></h2>';
         $doc .= '<div class="level2">';
         $doc .= '<p>' . strtr(hsc($info['desc']), array("\n" => "<br />")) . '</p>';
         $doc .= '<pre class="code">$' . $p . " = plugin_load('helper', '" . $p . "');</pre>";
         $doc .= '</div>';
         foreach ($methods as $method) {
             $title = '$' . $p . '->' . $method['name'] . '()';
             $hid = $this->_addToTOC($title, 3, $renderer);
             $doc .= '<h3><a name="' . $hid . '" id="' . $hid . '">' . hsc($title) . '</a></h3>';
             $doc .= '<div class="level3">';
             $doc .= '<div class="table"><table class="inline"><tbody>';
             $doc .= '<tr><th>Description</th><td colspan="2">' . $method['desc'] . '</td></tr>';
             if ($method['params']) {
                 $c = count($method['params']);
                 $doc .= '<tr><th rowspan="' . $c . '">Parameters</th><td>';
                 $params = array();
                 foreach ($method['params'] as $desc => $type) {
                     $params[] = hsc($desc) . '</td><td>' . hsc($type);
                 }
                 $doc .= join($params, '</td></tr><tr><td>') . '</td></tr>';
             }
             if ($method['return']) {
                 $doc .= '<tr><th>Return value</th><td>' . hsc(key($method['return'])) . '</td><td>' . hsc(current($method['return'])) . '</td></tr>';
             }
             $doc .= '</tbody></table></div>';
             $doc .= '</div>';
         }
         unset($po);
         $renderer->doc .= $doc;
     }
 }
Esempio n. 18
0
 /**
  * Returns a list of all plugins, including the disabled ones
  */
 function _get_plugin_list()
 {
     if (empty($this->plugin_list)) {
         $list = plugin_list('', true);
         // all plugins, including disabled ones
         sort($list);
         trigger_event('PLUGIN_PLUGINMANAGER_PLUGINLIST', $list);
         $this->plugin_list = $list;
     }
     return $this->plugin_list;
 }
Esempio n. 19
0
<?php

$blogtng_meta__excluded_syntax = array('info', 'blogtng_commentreply', 'blogtng_blog', 'blogtng_readmore', 'blogtng_header', 'blogtng_topic');
$meta['commentstatus_default'] = array('multichoice', '_choices' => array('enabled', 'closed', 'disabled'));
$meta['comments_allow_web'] = array('onoff');
$meta['comments_subscription'] = array('onoff');
$meta['comments_gravatar_rating'] = array('multichoice', '_choices' => array('X', 'R', 'PG', 'G'));
$meta['comments_gravatar_default'] = array('multichoice', '_choices' => array('blank', 'default', 'identicon', 'monsterid', 'wavatar'));
$meta['comments_forbid_syntax'] = array('multicheckbox', '_choices' => array_diff(plugin_list('syntax'), $blogtng_meta__excluded_syntax));
$meta['comments_xhtml_renderer'] = array('multicheckbox', '_choices' => array_diff(plugin_list('syntax'), $blogtng_meta__excluded_syntax));
$meta['editform_set_date'] = array('onoff');
$meta['tags'] = array('string');
$meta['receive_linkbacks'] = array('onoff');
$meta['send_linkbacks'] = array('onoff');
/**
 * Adapted from tpl_admin.php file of Bootstrap3 template by Giuseppe Di Terlizzi <*****@*****.**>
 */
function _mixture_adminDropdown()
{
    global $ID, $ACT, $auth, $conf;
    $admin_plugins = plugin_list('admin');
    $tasks = array('usermanager', 'acl', 'extension', 'config', 'styling', 'revert', 'popularity', 'upgrade');
    $addons = array_diff($admin_plugins, $tasks);
    $adminmenu = array('tasks' => $tasks, 'addons' => $addons);
    foreach ($adminmenu['tasks'] as $task) {
        if (($plugin = plugin_load('admin', $task, true)) === null) {
            continue;
        }
        //        if($plugin->forAdminOnly() && !$INFO['isadmin']) continue;
        if ($task == 'usermanager' && !($auth && $auth->canDo('getUsers'))) {
            continue;
        }
        $label = $plugin->getMenuText($conf['lang']);
        if (!$label) {
            continue;
        }
        if ($task == "popularity") {
            $label = preg_replace("/\\([^)]+\\)/", "", $label);
        }
        if ($ACT == 'admin' and $_GET['page'] == $task) {
            $class = ' class="action active"';
        } else {
            $class = ' class="action"';
        }
        echo sprintf('<li><a href="%s" title="%s"%s>%s%s</a></li>', wl($ID, array('do' => 'admin', 'page' => $task)), $label, $class, _mixture_glyph($task, true), _mixture_menuitem_string($label, 'dropdown'));
    }
    $f = fopen(DOKU_INC . 'inc/lang/' . $conf['lang'] . '/adminplugins.txt', 'r');
    $line = fgets($f);
    fclose($f);
    $line = preg_replace('/=/', '', $line);
    echo '<li class="dropdown-header"><span>' . $line . '</span></li>';
    echo '<li class="divider"></li>';
    foreach ($adminmenu['addons'] as $task) {
        if (($plugin = plugin_load('admin', $task, true)) === null) {
            continue;
        }
        if ($task == "move_tree") {
            $parts = explode('<a href="%s">', $plugin->getLang('treelink'));
            $label = substr($parts[1], 0, -4);
        } else {
            $label = $plugin->getMenuText($conf['lang']);
        }
        if ($label == null) {
            $label = ucfirst($task);
        }
        if ($ACT == 'admin' and $_GET['page'] == $task) {
            $class = ' class="action active"';
        } else {
            $class = ' class="action"';
        }
        echo sprintf('<li><a href="%s" title="%s"%s>%s %s</a></li>', wl($ID, array('do' => 'admin', 'page' => $task)), ucfirst($task), $class, _mixture_glyph($task, true), _mixture_menuitem_string(ucfirst($label), 'dropdown'));
    }
    echo '<li class="dropdown-header"><span>Cache</span></li>';
    echo '<li class="divider"></li>';
    echo '<li><a href="';
    echo wl($ID, array("do" => $_GET['do'], "page" => $_GET['page'], "purge" => "true"));
    echo '" class="action"><i class="fa fa-fw text-alt fa-recycle"></i> Purge current page\'s cache</a></li>';
    echo '<li><a href="' . DOKU_URL . 'lib/exe/js.php" class="action"><i class="fa fa-fw text-alt fa-code"></i> Purge JavaScript cache</a></li>';
    echo '<li><a href="' . DOKU_URL . 'lib/exe/css.php" class="action"><i class="fa fa-fw text-alt fa-file-code-o"></i> Purge CSS cache</a></li>';
}
Esempio n. 21
0
/**
 * List available Administration Tasks
 *
 * @author Andreas Gohr <*****@*****.**>
 * @author Håkan Sandell <*****@*****.**>
 */
function html_admin()
{
    global $ID;
    global $INFO;
    global $conf;
    /** @var DokuWiki_Auth_Plugin $auth */
    global $auth;
    // build menu of admin functions from the plugins that handle them
    $pluginlist = plugin_list('admin');
    $menu = array();
    foreach ($pluginlist as $p) {
        /** @var DokuWiki_Admin_Plugin $obj */
        if (($obj = plugin_load('admin', $p)) === null) {
            continue;
        }
        // check permissions
        if ($obj->forAdminOnly() && !$INFO['isadmin']) {
            continue;
        }
        $menu[$p] = array('plugin' => $p, 'prompt' => $obj->getMenuText($conf['lang']), 'sort' => $obj->getMenuSort());
    }
    // data security check
    // simple check if the 'savedir' is relative and accessible when appended to DOKU_URL
    // it verifies either:
    //   'savedir' has been moved elsewhere, or
    //   has protection to prevent the webserver serving files from it
    if (substr($conf['savedir'], 0, 2) == './') {
        echo '<a style="border:none; float:right;"
                href="http://www.dokuwiki.org/security#web_access_security">
                <img src="' . DOKU_URL . $conf['savedir'] . '/security.png" alt="Your data directory seems to be protected properly."
                onerror="this.parentNode.style.display=\'none\'" /></a>';
    }
    print p_locale_xhtml('admin');
    // Admin Tasks
    if ($INFO['isadmin']) {
        ptln('<ul class="admin_tasks">');
        if ($menu['usermanager'] && $auth && $auth->canDo('getUsers')) {
            ptln('  <li class="admin_usermanager"><div class="li">' . '<a href="' . wl($ID, array('do' => 'admin', 'page' => 'usermanager')) . '">' . $menu['usermanager']['prompt'] . '</a></div></li>');
        }
        unset($menu['usermanager']);
        if ($menu['acl']) {
            ptln('  <li class="admin_acl"><div class="li">' . '<a href="' . wl($ID, array('do' => 'admin', 'page' => 'acl')) . '">' . $menu['acl']['prompt'] . '</a></div></li>');
        }
        unset($menu['acl']);
        if ($menu['extension']) {
            ptln('  <li class="admin_plugin"><div class="li">' . '<a href="' . wl($ID, array('do' => 'admin', 'page' => 'extension')) . '">' . $menu['extension']['prompt'] . '</a></div></li>');
        }
        unset($menu['extension']);
        if ($menu['config']) {
            ptln('  <li class="admin_config"><div class="li">' . '<a href="' . wl($ID, array('do' => 'admin', 'page' => 'config')) . '">' . $menu['config']['prompt'] . '</a></div></li>');
        }
        unset($menu['config']);
        if ($menu['styling']) {
            ptln('  <li class="admin_styling"><div class="li">' . '<a href="' . wl($ID, array('do' => 'admin', 'page' => 'styling')) . '">' . $menu['styling']['prompt'] . '</a></div></li>');
        }
        unset($menu['styling']);
    }
    ptln('</ul>');
    // Manager Tasks
    ptln('<ul class="admin_tasks">');
    if ($menu['revert']) {
        ptln('  <li class="admin_revert"><div class="li">' . '<a href="' . wl($ID, array('do' => 'admin', 'page' => 'revert')) . '">' . $menu['revert']['prompt'] . '</a></div></li>');
    }
    unset($menu['revert']);
    if ($menu['popularity']) {
        ptln('  <li class="admin_popularity"><div class="li">' . '<a href="' . wl($ID, array('do' => 'admin', 'page' => 'popularity')) . '">' . $menu['popularity']['prompt'] . '</a></div></li>');
    }
    unset($menu['popularity']);
    // print DokuWiki version:
    ptln('</ul>');
    echo '<div id="admin__version">';
    echo getVersion();
    echo '</div>';
    // print the rest as sorted list
    if (count($menu)) {
        // sort by name, then sort
        usort($menu, function ($a, $b) {
            $strcmp = strcasecmp($a['prompt'], $b['prompt']);
            if ($strcmp != 0) {
                return $strcmp;
            }
            if ($a['sort'] == $b['sort']) {
                return 0;
            }
            return $a['sort'] < $b['sort'] ? -1 : 1;
        });
        // output the menu
        ptln('<div class="clearer"></div>');
        print p_locale_xhtml('adminplugins');
        ptln('<ul>');
        foreach ($menu as $item) {
            if (!$item['prompt']) {
                continue;
            }
            ptln('  <li><div class="li"><a href="' . wl($ID, 'do=admin&amp;page=' . $item['plugin']) . '">' . $item['prompt'] . '</a></div></li>');
        }
        ptln('</ul>');
    }
}
Esempio n. 22
0
function _tpl_toc($return = false)
{
    global $TOC;
    global $ACT;
    global $ID;
    global $REV;
    global $INFO;
    global $conf;
    global $INPUT;
    $toc = array();
    if (is_array($TOC)) {
        // if a TOC was prepared in global scope, always use it
        $toc = $TOC;
    } elseif (($ACT == 'show' || substr($ACT, 0, 6) == 'export') && !$REV && $INFO['exists']) {
        // get TOC from metadata, render if neccessary
        $meta = p_get_metadata($ID, false, METADATA_RENDER_USING_CACHE);
        if (isset($meta['internal']['toc'])) {
            $tocok = $meta['internal']['toc'];
        } else {
            $tocok = true;
        }
        $toc = $meta['description']['tableofcontents'];
        if (!$tocok || !is_array($toc) || !$conf['tocminheads'] || count($toc) < $conf['tocminheads']) {
            $toc = array();
        }
    } elseif ($ACT == 'admin') {
        // try to load admin plugin TOC FIXME: duplicates code from tpl_admin
        $plugin = null;
        $class = $INPUT->str('page');
        if (!empty($class)) {
            $pluginlist = plugin_list('admin');
            if (in_array($class, $pluginlist)) {
                // attempt to load the plugin
                /** @var $plugin DokuWiki_Admin_Plugin */
                $plugin =& plugin_load('admin', $class);
            }
        }
        if ($plugin !== null && (!$plugin->forAdminOnly() || $INFO['isadmin'])) {
            $toc = $plugin->getTOC();
            $TOC = $toc;
            // avoid later rebuild
        }
    }
    trigger_event('TPL_TOC_RENDER', $toc, null, false);
    $html = bootstrap_html_TOC($toc);
    if ($return) {
        return $html;
    }
    echo $html;
    return '';
}
Esempio n. 23
0
/**
 * Handle the admin page contents
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function tpl_admin()
{
    global $INFO;
    global $TOC;
    global $INPUT;
    $plugin = null;
    $class = $INPUT->str('page');
    if (!empty($class)) {
        $pluginlist = plugin_list('admin');
        if (in_array($class, $pluginlist)) {
            // attempt to load the plugin
            /** @var $plugin DokuWiki_Admin_Plugin */
            $plugin =& plugin_load('admin', $class);
        }
    }
    if ($plugin !== null) {
        if (!is_array($TOC)) {
            $TOC = $plugin->getTOC();
        }
        //if TOC wasn't requested yet
        if ($INFO['prependTOC']) {
            tpl_toc();
        }
        $plugin->html();
    } else {
        html_admin();
    }
    return true;
}
Esempio n. 24
0
 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';
 }
Esempio n. 25
0
 /**
  * Gather all information
  *
  * @return array The popularity data as an array
  */
 function _gather()
 {
     global $conf;
     /** @var $auth DokuWiki_Auth_Plugin */
     global $auth;
     $data = array();
     $phptime = ini_get('max_execution_time');
     @set_time_limit(0);
     $pluginInfo = $this->getInfo();
     // version
     $data['anon_id'] = md5(auth_cookiesalt());
     $data['version'] = getVersion();
     $data['popversion'] = $pluginInfo['date'];
     $data['language'] = $conf['lang'];
     $data['now'] = time();
     $data['popauto'] = (int) $this->isAutoSubmitEnabled();
     // some config values
     $data['conf_useacl'] = $conf['useacl'];
     $data['conf_authtype'] = $conf['authtype'];
     $data['conf_template'] = $conf['template'];
     // number and size of pages
     $list = array();
     search($list, $conf['datadir'], array($this, '_search_count'), array('all' => false), '');
     $data['page_count'] = $list['file_count'];
     $data['page_size'] = $list['file_size'];
     $data['page_biggest'] = $list['file_max'];
     $data['page_smallest'] = $list['file_min'];
     $data['page_nscount'] = $list['dir_count'];
     $data['page_nsnest'] = $list['dir_nest'];
     if ($list['file_count']) {
         $data['page_avg'] = $list['file_size'] / $list['file_count'];
     }
     $data['page_oldest'] = $list['file_oldest'];
     unset($list);
     // number and size of media
     $list = array();
     search($list, $conf['mediadir'], array($this, '_search_count'), array('all' => true));
     $data['media_count'] = $list['file_count'];
     $data['media_size'] = $list['file_size'];
     $data['media_biggest'] = $list['file_max'];
     $data['media_smallest'] = $list['file_min'];
     $data['media_nscount'] = $list['dir_count'];
     $data['media_nsnest'] = $list['dir_nest'];
     if ($list['file_count']) {
         $data['media_avg'] = $list['file_size'] / $list['file_count'];
     }
     unset($list);
     // number and size of cache
     $list = array();
     search($list, $conf['cachedir'], array($this, '_search_count'), array('all' => true));
     $data['cache_count'] = $list['file_count'];
     $data['cache_size'] = $list['file_size'];
     $data['cache_biggest'] = $list['file_max'];
     $data['cache_smallest'] = $list['file_min'];
     if ($list['file_count']) {
         $data['cache_avg'] = $list['file_size'] / $list['file_count'];
     }
     unset($list);
     // number and size of index
     $list = array();
     search($list, $conf['indexdir'], array($this, '_search_count'), array('all' => true));
     $data['index_count'] = $list['file_count'];
     $data['index_size'] = $list['file_size'];
     $data['index_biggest'] = $list['file_max'];
     $data['index_smallest'] = $list['file_min'];
     if ($list['file_count']) {
         $data['index_avg'] = $list['file_size'] / $list['file_count'];
     }
     unset($list);
     // number and size of meta
     $list = array();
     search($list, $conf['metadir'], array($this, '_search_count'), array('all' => true));
     $data['meta_count'] = $list['file_count'];
     $data['meta_size'] = $list['file_size'];
     $data['meta_biggest'] = $list['file_max'];
     $data['meta_smallest'] = $list['file_min'];
     if ($list['file_count']) {
         $data['meta_avg'] = $list['file_size'] / $list['file_count'];
     }
     unset($list);
     // number and size of attic
     $list = array();
     search($list, $conf['olddir'], array($this, '_search_count'), array('all' => true));
     $data['attic_count'] = $list['file_count'];
     $data['attic_size'] = $list['file_size'];
     $data['attic_biggest'] = $list['file_max'];
     $data['attic_smallest'] = $list['file_min'];
     if ($list['file_count']) {
         $data['attic_avg'] = $list['file_size'] / $list['file_count'];
     }
     $data['attic_oldest'] = $list['file_oldest'];
     unset($list);
     // user count
     if ($auth && $auth->canDo('getUserCount')) {
         $data['user_count'] = $auth->getUserCount();
     }
     // calculate edits per day
     $list = @file($conf['metadir'] . '/_dokuwiki.changes');
     $count = count($list);
     if ($count > 2) {
         $first = (int) substr(array_shift($list), 0, 10);
         $last = (int) substr(array_pop($list), 0, 10);
         $dur = ($last - $first) / (60 * 60 * 24);
         // number of days in the changelog
         $data['edits_per_day'] = $count / $dur;
     }
     unset($list);
     // plugins
     $data['plugin'] = plugin_list();
     // pcre info
     if (defined('PCRE_VERSION')) {
         $data['pcre_version'] = PCRE_VERSION;
     }
     $data['pcre_backtrack'] = ini_get('pcre.backtrack_limit');
     $data['pcre_recursion'] = ini_get('pcre.recursion_limit');
     // php info
     $data['os'] = PHP_OS;
     $data['webserver'] = $_SERVER['SERVER_SOFTWARE'];
     $data['php_version'] = phpversion();
     $data['php_sapi'] = php_sapi_name();
     $data['php_memory'] = $this->_to_byte(ini_get('memory_limit'));
     $data['php_exectime'] = $phptime;
     $data['php_extension'] = get_loaded_extensions();
     // plugin usage data
     $this->_add_plugin_usage_data($data);
     return $data;
 }
Esempio n. 26
0
/**
 * Call the needed action handlers
 *
 * @author Andreas Gohr <*****@*****.**>
 * @triggers ACTION_ACT_PREPROCESS
 * @triggers ACTION_HEADERS_SEND
 */
function act_dispatch()
{
    global $INFO;
    global $ACT;
    global $ID;
    global $QUERY;
    global $lang;
    global $conf;
    global $license;
    $preact = $ACT;
    // give plugins an opportunity to process the action
    $evt = new Doku_Event('ACTION_ACT_PREPROCESS', $ACT);
    if ($evt->advise_before()) {
        //sanitize $ACT
        $ACT = act_clean($ACT);
        //check if searchword was given - else just show
        $s = cleanID($QUERY);
        if ($ACT == 'search' && empty($s)) {
            $ACT = 'show';
        }
        //login stuff
        if (in_array($ACT, array('login', 'logout'))) {
            $ACT = act_auth($ACT);
        }
        //check if user is asking to (un)subscribe a page
        if ($ACT == 'subscribe') {
            try {
                $ACT = act_subscription($ACT);
            } catch (Exception $e) {
                msg($e->getMessage(), -1);
            }
        }
        //check permissions
        $ACT = act_permcheck($ACT);
        //register
        $nil = array();
        if ($ACT == 'register' && $_POST['save'] && register()) {
            $ACT = 'login';
        }
        if ($ACT == 'resendpwd' && act_resendpwd()) {
            $ACT = 'login';
        }
        //update user profile
        if ($ACT == 'profile') {
            if (!$_SERVER['REMOTE_USER']) {
                $ACT = 'login';
            } else {
                if (updateprofile()) {
                    msg($lang['profchanged'], 1);
                    $ACT = 'show';
                }
            }
        }
        //revert
        if ($ACT == 'revert') {
            if (checkSecurityToken()) {
                $ACT = act_revert($ACT);
            } else {
                $ACT = 'show';
            }
        }
        //save
        if ($ACT == 'save') {
            if (checkSecurityToken()) {
                $ACT = act_save($ACT);
            } else {
                $ACT = 'show';
            }
        }
        //cancel conflicting edit
        if ($ACT == 'cancel') {
            $ACT = 'show';
        }
        //draft deletion
        if ($ACT == 'draftdel') {
            $ACT = act_draftdel($ACT);
        }
        //draft saving on preview
        if ($ACT == 'preview') {
            $ACT = act_draftsave($ACT);
        }
        //edit
        if (($ACT == 'edit' || $ACT == 'preview') && $INFO['editable']) {
            $ACT = act_edit($ACT);
        } else {
            unlock($ID);
            //try to unlock
        }
        //handle export
        if (substr($ACT, 0, 7) == 'export_') {
            $ACT = act_export($ACT);
        }
        //display some infos
        if ($ACT == 'check') {
            check();
            $ACT = 'show';
        }
        //handle admin tasks
        if ($ACT == 'admin') {
            // retrieve admin plugin name from $_REQUEST['page']
            if (!empty($_REQUEST['page'])) {
                $pluginlist = plugin_list('admin');
                if (in_array($_REQUEST['page'], $pluginlist)) {
                    // attempt to load the plugin
                    if (($plugin =& plugin_load('admin', $_REQUEST['page'])) !== null) {
                        $plugin->handle();
                    }
                }
            }
        }
        // check permissions again - the action may have changed
        $ACT = act_permcheck($ACT);
    }
    // end event ACTION_ACT_PREPROCESS default action
    $evt->advise_after();
    unset($evt);
    // when action 'show', the intial not 'show' and POST, do a redirect
    if ($ACT == 'show' && $preact != 'show' && strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
        act_redirect($ID, $preact);
    }
    //call template FIXME: all needed vars available?
    $headers[] = 'Content-Type: text/html; charset=utf-8';
    trigger_event('ACTION_HEADERS_SEND', $headers, 'act_sendheaders');
    include template('main.php');
    // output for the commands is now handled in inc/templates.php
    // in function tpl_content()
}
Esempio n. 27
0
/**
 * List available Administration Tasks
 *
 * @author Andreas Gohr <*****@*****.**>
 * @author Håkan Sandell <*****@*****.**>
 */
function html_admin()
{
    global $ID;
    global $INFO;
    global $lang;
    global $conf;
    global $auth;
    // build menu of admin functions from the plugins that handle them
    $pluginlist = plugin_list('admin');
    $menu = array();
    foreach ($pluginlist as $p) {
        if (($obj =& plugin_load('admin', $p)) === null) {
            continue;
        }
        // check permissions
        if ($obj->forAdminOnly() && !$INFO['isadmin']) {
            continue;
        }
        $menu[$p] = array('plugin' => $p, 'prompt' => $obj->getMenuText($conf['lang']), 'sort' => $obj->getMenuSort());
    }
    // data security check
    // @todo: could be checked and only displayed if $conf['savedir'] is under the web root
    echo '<a style="border:none; float:right;"
            href="http://www.dokuwiki.org/security#web_access_security">
            <img src="data/security.png" alt="Your data directory seems to be protected properly."
             onerror="this.parentNode.style.display=\'none\'" /></a>';
    print p_locale_xhtml('admin');
    // Admin Tasks
    if ($INFO['isadmin']) {
        ptln('<ul class="admin_tasks">');
        if ($menu['usermanager'] && $auth && $auth->canDo('getUsers')) {
            ptln('  <li class="admin_usermanager"><div class="li">' . '<a href="' . wl($ID, array('do' => 'admin', 'page' => 'usermanager')) . '">' . $menu['usermanager']['prompt'] . '</a></div></li>');
        }
        unset($menu['usermanager']);
        if ($menu['acl']) {
            ptln('  <li class="admin_acl"><div class="li">' . '<a href="' . wl($ID, array('do' => 'admin', 'page' => 'acl')) . '">' . $menu['acl']['prompt'] . '</a></div></li>');
        }
        unset($menu['acl']);
        if ($menu['plugin']) {
            ptln('  <li class="admin_plugin"><div class="li">' . '<a href="' . wl($ID, array('do' => 'admin', 'page' => 'plugin')) . '">' . $menu['plugin']['prompt'] . '</a></div></li>');
        }
        unset($menu['plugin']);
        if ($menu['config']) {
            ptln('  <li class="admin_config"><div class="li">' . '<a href="' . wl($ID, array('do' => 'admin', 'page' => 'config')) . '">' . $menu['config']['prompt'] . '</a></div></li>');
        }
        unset($menu['config']);
    }
    ptln('</ul>');
    // Manager Tasks
    ptln('<ul class="admin_tasks">');
    if ($menu['revert']) {
        ptln('  <li class="admin_revert"><div class="li">' . '<a href="' . wl($ID, array('do' => 'admin', 'page' => 'revert')) . '">' . $menu['revert']['prompt'] . '</a></div></li>');
    }
    unset($menu['revert']);
    if ($menu['popularity']) {
        ptln('  <li class="admin_popularity"><div class="li">' . '<a href="' . wl($ID, array('do' => 'admin', 'page' => 'popularity')) . '">' . $menu['popularity']['prompt'] . '</a></div></li>');
    }
    unset($menu['popularity']);
    // print DokuWiki version:
    ptln('</ul>');
    echo '<div id="admin__version">';
    echo getVersion();
    echo '</div>';
    // print the rest as sorted list
    if (count($menu)) {
        usort($menu, 'p_sort_modes');
        // output the menu
        ptln('<div class="clearer"></div>');
        print p_locale_xhtml('adminplugins');
        ptln('<ul>');
        foreach ($menu as $item) {
            if (!$item['prompt']) {
                continue;
            }
            ptln('  <li><div class="li"><a href="' . wl($ID, 'do=admin&amp;page=' . $item['plugin']) . '">' . $item['prompt'] . '</a></div></li>');
        }
        ptln('</ul>');
    }
}
Esempio n. 28
0
function html_admin()
{
    global $ID;
    global $INFO;
    global $lang;
    global $conf;
    print p_locale_xhtml('admin');
    // build menu of admin functions from the plugins that handle them
    $pluginlist = plugin_list('admin');
    $menu = array();
    foreach ($pluginlist as $p) {
        if (($obj =& plugin_load('admin', $p)) === NULL) {
            continue;
        }
        // check permissions
        if ($obj->forAdminOnly() && !$INFO['isadmin']) {
            continue;
        }
        $menu[] = array('plugin' => $p, 'prompt' => $obj->getMenuText($conf['lang']), 'sort' => $obj->getMenuSort());
    }
    usort($menu, 'p_sort_modes');
    // output the menu
    ptln('<ul>');
    foreach ($menu as $item) {
        if (!$item['prompt']) {
            continue;
        }
        ptln('  <li><div class="li"><a href="' . wl($ID, 'do=admin&amp;page=' . $item['plugin']) . '">' . $item['prompt'] . '</a></div></li>');
    }
    ptln('</ul>');
}
Esempio n. 29
0
/**
 * Returns a list of possible Plugin Styles (no existance check here)
 *
 * @author Andreas Gohr <*****@*****.**>
 *
 * @param string $mediatype
 * @return array
 */
function css_pluginstyles($mediatype = 'screen')
{
    $list = array();
    $plugins = plugin_list();
    foreach ($plugins as $p) {
        $list[DOKU_PLUGIN . "{$p}/{$mediatype}.css"] = DOKU_BASE . "lib/plugins/{$p}/";
        $list[DOKU_PLUGIN . "{$p}/{$mediatype}.less"] = DOKU_BASE . "lib/plugins/{$p}/";
        // alternative for screen.css
        if ($mediatype == 'screen') {
            $list[DOKU_PLUGIN . "{$p}/style.css"] = DOKU_BASE . "lib/plugins/{$p}/";
            $list[DOKU_PLUGIN . "{$p}/style.less"] = DOKU_BASE . "lib/plugins/{$p}/";
        }
    }
    return $list;
}
Esempio n. 30
0
/**
 * Handle the admin page contents
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function tpl_admin()
{
    global $INFO;
    global $TOC;
    $plugin = null;
    if (!empty($_REQUEST['page'])) {
        $pluginlist = plugin_list('admin');
        if (in_array($_REQUEST['page'], $pluginlist)) {
            // attempt to load the plugin
            $plugin =& plugin_load('admin', $_REQUEST['page']);
        }
    }
    if ($plugin !== null) {
        if ($plugin->forAdminOnly() && !$INFO['isadmin']) {
            msg('For admins only', -1);
            html_admin();
        } else {
            if (!is_array($TOC)) {
                $TOC = $plugin->getTOC();
            }
            //if TOC wasn't requested yet
            if ($INFO['prependTOC']) {
                tpl_toc();
            }
            $plugin->html();
        }
    } else {
        html_admin();
    }
    return true;
}