function cg2_header($function, $name)
{
    // only send header once - v2.51
    static $alreadySent = false;
    if ($alreadySent) {
        return;
    }
    $alreadySent = true;
    // set title and button
    $title = sprintf("%s &gt; <a href='?menu=_codeGenerator'>%s</a> &gt; ", t('Admin'), t('Code Generator')) . htmlencode($name);
    $button = '';
    // <input class="button" type="button" name="null" value="Start Over &gt;&gt;" onclick="window.location=\'?menu=_codeGenerator\'"/>';
    // get header html
    $html = plugin_header('###TITLE###', $button, false);
    $html = preg_replace('/###TITLE###/', $title, $html);
    $html = preg_replace('/<form method="post"/', '<form method="get"', $html);
    // use get form so users can use browser back button with reposting form
    // add javascript (not yet needed or used)
    $oldHtml = $html;
    $jsPath = "lib/menus/_codeGenerator/generator_functions.js";
    $jsTag = "<script type='text/javascript' src='{$jsPath}?" . filemtime(SCRIPT_DIR . "/{$jsPath}") . "'></script>\n";
    // on file change browsers should no longer use cached versions
    $html = preg_replace("|^\\s*<!-- /javascript -->|m", "{$jsTag}\$0", $oldHtml);
    if ($oldHtml == $html) {
        dieAsCaller("Could insert javascript tag!");
    }
    // add hidden fields
    $html .= "<input type='hidden' name='menu' value='_codeGenerator' />\n";
    $html .= "<input type='hidden' name='_generator' value='{$function}' />\n";
    //
    return $html;
}
function cg2_homepage($error = '')
{
    if ($error) {
        alert($error);
    }
    // header
    $title = t('Admin') . " &gt; <a href='?menu=_codeGenerator'>" . t('Code Generator') . "</a>\n";
    $html = plugin_header('###TITLE###', '', false);
    $html = preg_replace('/###TITLE###/', $title, $html);
    // list internal generators
    $html .= _cg2_getGeneratorList(t("Create a Viewer"), t("'Viewers' are PHP files that display the data from the CMS in all the different 'views' you might have on your site."), "private");
    // list other generators (added by plugins)
    $html .= _cg2_getGeneratorList(t("Other Generators"), t("Plugins can add their own code generators here"), "public");
    // footer
    $html .= plugin_footer();
    //
    print $html;
    exit;
}
Exemplo n.º 3
0
<?php

require_once 'conf/common.inc.php';
require_once 'inc/functions.inc.php';
require_once 'inc/html.inc.php';
$host = validate_get(GET('h'), 'host');
$plugin = validate_get(GET('p'), 'plugin');
if (GET('a') == 'del') {
    plugin_header($host, $plugin, 1);
} else {
    plugin_header($host, $plugin, 0);
    graphs_from_plugin($host, $plugin);
}
Exemplo n.º 4
0
if (!$plugins) {
    echo "Unknown host\n";
    return false;
}
# first the ones defined in overview
foreach ($CONFIG['overview'] as $plugin) {
    if (in_array($plugin, $plugins)) {
        printf('<div id="%s">' . "\n", $plugin);
        plugin_header($host, $plugin, 0);
        graphs_from_plugin($host, $plugin);
        print "</div>\n";
    }
}
# other plugins
foreach ($plugins as $plugin) {
    if (!in_array($plugin, $CONFIG['overview'])) {
        printf('<div id="%s">' . "\n", $plugin);
        if ($splugin == $plugin) {
            plugin_header($host, $plugin, 0);
            graphs_from_plugin($host, $plugin);
        } else {
            plugin_header($host, $plugin, 1);
        }
        print "</div>\n";
    }
}
html_end();
$content = ob_get_clean();
$redis->setex("cache:grapher:host:{$host}:{$splugin}", 300, $content);
http_cache_etag();
http_send_data($content);
Exemplo n.º 5
0
require_once 'conf/common.inc.php';
require_once 'inc/html.inc.php';
require_once 'inc/collectd.inc.php';
header("Content-Type: text/html");
$host = GET('h');
$plugin = GET('p');
$selected_plugins = !$plugin ? $CONFIG['overview'] : array($plugin);
html_start();
printf("<fieldset id=\"%s\">", htmlentities($host));
printf("<legend>%s</legend>", htmlentities($host));
echo <<<EOT
<input type="checkbox" id="navicon" class="navicon" />
<label for="navicon"></label>

EOT;
if (!strlen($host) || !($plugins = collectd_plugins($host))) {
    echo "Unknown host\n";
    return false;
}
plugins_list($host, $selected_plugins);
echo '<div class="graphs">';
foreach ($selected_plugins as $selected_plugin) {
    if (in_array($selected_plugin, $plugins)) {
        plugin_header($host, $selected_plugin);
        graphs_from_plugin($host, $selected_plugin, empty($plugin));
    }
}
echo '</div>';
printf("</fieldset>");
html_end();
Exemplo n.º 6
0
$selected_plugins = !$plugin ? $CONFIG['overview'] : array($plugin);
html_start();
printf('<fieldset id="%s">', htmlentities($host));
printf('<legend>%s</legend>', htmlentities($host));
echo <<<EOT
<input type="checkbox" id="navicon" class="navicon" />
<label for="navicon"></label>

EOT;
if (!($plugins = collectd_plugins($host))) {
    echo "Unknown host\n";
    return false;
}
plugins_list($host, $selected_plugins);
echo '<div class="graphs">';
plugin_header($host, $plugin);
$args = GET();
print '<ul class="time-range">' . "\n";
foreach ($CONFIG['term'] as $key => $s) {
    $args['s'] = $s;
    $selected = selected_timerange($seconds, $s);
    printf('<li><a %s href="%s%s">%s</a></li>' . "\n", $selected, htmlentities($CONFIG['weburl']), htmlentities(build_url('detail.php', $args)), htmlentities($key));
}
print "</ul>\n";
if ($CONFIG['graph_type'] == 'canvas') {
    chdir($CONFIG['webdir']);
    include $CONFIG['webdir'] . '/graph.php';
} else {
    printf("<img src=\"%s%s\">\n", htmlentities($CONFIG['weburl']), htmlentities(build_url('graph.php', GET())));
}
echo '</div>';