コード例 #1
0
ファイル: authlog.inc.php プロジェクト: skive/observium
/**
 * Display authentication log.
 *
 * @param array $vars
 * @return none
 *
 */
function print_authlog($vars)
{
    $authlog = get_authlog_array($vars);
    if (!$authlog['count']) {
        // There have been no entries returned. Print the warning. Shouldn't happen, how did you get here without auth?!
        print_warning('<h4>No authentication entries found!</h4>');
    } else {
        // Entries have been returned. Print the table.
        $string = "<table class=\"table table-bordered table-striped table-hover table-condensed table-rounded\">\n  <thead>\n    <tr>\n      <th style=\"width: 200px;\">Date</th>\n      <th style=\"width: 200px;\">User</th>\n      <th style=\"width: 200px;\">From</th>\n      <th>Action</th>\n    </tr>\n  </thead>\n  <tbody>";
        foreach ($authlog['entries'] as $entry) {
            if (strstr(strtolower($entry['result']), 'fail', true)) {
                $class = " class=\"error\"";
            } else {
                $class = "";
            }
            $string .= '
      <tr' . $class . '>
        <td>' . $entry['datetime'] . '</td>
        <td>' . $entry['user'] . '</td>
        <td>' . $entry['address'] . '</td>
        <td>' . $entry['result'] . '</td>
      </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>';
        // Add pagination header
        if ($authlog['pagination_html']) {
            $string = $authlog['pagination_html'] . $string . $authlog['pagination_html'];
        }
        // Print authlog
        echo $string;
    }
}
コード例 #2
0
 function hook_prefs_tab_section($id)
 {
     if ($id == "prefFeedsPublishedGenerated") {
         print_warning(__("You can disable all articles shared by unique URLs here."));
         print "<p>";
         print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearArticleAccessKeys()\">" . __('Unshare all articles') . "</button> ";
         print "</p>";
     }
 }
コード例 #3
0
/**
 * Display neighbours.
 *
 * Display pages with device neighbours in some formats.
 * Examples:
 * print_neighbours() - display all neighbours from all devices
 * print_neighbours(array('pagesize' => 99)) - display 99 neighbours from all device
 * print_neighbours(array('pagesize' => 10, 'pageno' => 3, 'pagination' => TRUE)) - display 10 neighbours from page 3 with pagination header
 * print_neighbours(array('pagesize' => 10, 'device' = 4)) - display 10 neighbours for device_id 4
 *
 * @param array $vars
 * @return none
 *
 */
function print_neighbours($vars)
{
    // Get neighbours array
    $neighbours = get_neighbours_array($vars);
    if (!$neighbours['count']) {
        // There have been no entries returned. Print the warning.
        print_warning('<h4>No neighbours found!</h4>');
    } else {
        // Entries have been returned. Print the table.
        $list = array('device' => FALSE);
        if ($vars['page'] != 'device') {
            $list['device'] = TRUE;
        }
        if (in_array($vars['graph'], array('bits', 'upkts', 'nupkts', 'pktsize', 'percent', 'errors', 'etherlike', 'fdb_count'))) {
            $graph_types = array($vars['graph']);
        } else {
            $graph_types = array('bits', 'upkts', 'errors');
        }
        $string = generate_box_open($vars['header']);
        $string .= '<table class="table  table-striped table-hover table-condensed">' . PHP_EOL;
        $cols = array(array(NULL, 'class="state-marker"'), 'device_a' => 'Local Device', 'port_a' => 'Local Port', 'NONE' => NULL, 'device_b' => 'Remote Device', 'port_b' => 'Remote Port', 'protocol' => 'Protocol');
        if (!$list['device']) {
            unset($cols[0], $cols['device_a']);
        }
        $string .= get_table_header($cols, $vars);
        $string .= '  <tbody>' . PHP_EOL;
        foreach ($neighbours['entries'] as $entry) {
            $string .= '  <tr class="' . $entry['row_class'] . '">' . PHP_EOL;
            if ($list['device']) {
                $string .= '   <td class="state-marker"></td>';
                $string .= '    <td class="entity">' . generate_device_link($entry, NULL, array('tab' => 'ports', 'view' => 'neighbours')) . '</td>' . PHP_EOL;
            }
            $string .= '    <td><span class="entity">' . generate_port_link($entry) . '</span><br />' . $entry['ifAlias'] . '</td>' . PHP_EOL;
            $string .= '    <td><i class="icon-resize-horizontal text-success"></i></td>' . PHP_EOL;
            if (is_numeric($entry['remote_port_id']) && $entry['remote_port_id']) {
                $remote_port = get_port_by_id_cache($entry['remote_port_id']);
                $remote_device = device_by_id_cache($remote_port['device_id']);
                $string .= '    <td><span class="entity">' . generate_device_link($remote_device) . '</span><br />' . $remote_device['hardware'] . '</td>' . PHP_EOL;
                $string .= '    <td><span class="entity">' . generate_port_link($remote_port) . '</span><br />' . $remote_port['ifAlias'] . '</td>' . PHP_EOL;
            } else {
                $string .= '    <td><span class="entity">' . $entry['remote_hostname'] . '</span><br />' . $entry['remote_platform'] . '</td>' . PHP_EOL;
                $string .= '    <td><span class="entity">' . $entry['remote_port'] . '</span></td>' . PHP_EOL;
            }
            $string .= '    <td>' . strtoupper($entry['protocol']) . '</td>' . PHP_EOL;
            $string .= '  </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>';
        $string .= generate_box_close();
        // Print pagination header
        if ($neighbours['pagination_html']) {
            $string = $neighbours['pagination_html'] . $string . $neighbours['pagination_html'];
        }
        // Print
        echo $string;
    }
}
コード例 #4
0
ファイル: authlog.inc.php プロジェクト: Natolumin/observium
/**
 * Display authentication log.
 *
 * @param array $vars
 * @return none
 *
 */
function print_authlog($vars)
{
    $authlog = get_authlog_array($vars);
    if (!$authlog['count']) {
        // There have been no entries returned. Print the warning. Shouldn't happen, how did you get here without auth?!
        print_warning('<h4>No authentication entries found!</h4>');
    } else {
        $string = generate_box_open($vars['header']);
        // Entries have been returned. Print the table.
        $string .= '<table class="' . OBS_CLASS_TABLE_STRIPED_MORE . '">' . PHP_EOL;
        $cols = array('date' => array('Date', 'style="width: 150px;"'), 'user' => 'User', 'from' => 'From', 'ua' => array('User-Agent', 'style="width: 200px;"'), 'NONE' => 'Action');
        if ($vars['page'] == 'preferences') {
            unset($cols['user']);
        }
        $string .= get_table_header($cols);
        //, $vars); // Currently sorting is not available
        $string .= '<tbody>' . PHP_EOL;
        foreach ($authlog['entries'] as $entry) {
            if (strlen($entry['user_agent']) > 1) {
                $entry['detect_browser'] = detect_browser($entry['user_agent']);
                //r($entry['detect_browser']);
                $entry['user_agent'] = '<i class="' . $entry['detect_browser']['icon'] . '"></i>&nbsp;' . $entry['detect_browser']['browser_full'];
                if ($entry['detect_browser']['platform']) {
                    $entry['user_agent'] .= ' (' . $entry['detect_browser']['platform'] . ')';
                }
            }
            if (strstr(strtolower($entry['result']), 'fail', true)) {
                $class = " class=\"error\"";
            } else {
                $class = "";
            }
            $string .= '
      <tr' . $class . '>
        <td>' . $entry['datetime'] . '</td>';
            if (isset($cols['user'])) {
                $string .= '
        <td>' . escape_html($entry['user']) . '</td>';
            }
            $string .= '
        <td>' . ($_SESSION['userlevel'] > 5 ? generate_popup_link('ip', $entry['address']) : preg_replace('/^\\d+/', '*', $entry['address'])) . '</td>
        <td>' . $entry['user_agent'] . '</td>
        <td>' . $entry['result'] . '</td>
      </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>';
        $string .= generate_box_close();
        // Add pagination header
        if ($authlog['pagination_html']) {
            $string = $authlog['pagination_html'] . $string . $authlog['pagination_html'];
        }
        // Print authlog
        echo $string;
    }
}
コード例 #5
0
/**
 * Display authentication log.
 *
 * @param array $vars
 * @return none
 *
 */
function print_authlog($vars)
{
    $authlog = get_authlog_array($vars);
    if (!$authlog['count']) {
        // There have been no entries returned. Print the warning. Shouldn't happen, how did you get here without auth?!
        print_warning('<h4>没有发现任何认证项目!</h4>');
    } else {
        // Entries have been returned. Print the table.
        $string = '<table class="table table-bordered table-striped table-hover table-condensed table-rounded">' . PHP_EOL;
        $cols = array('date' => array('Date', 'style="width: 200px;"'), 'user' => '用户', 'from' => 'From', 'ua' => array('User-Agent', 'style="width: 200px;"'), 'NONE' => 'Action');
        $string .= get_table_header($cols);
        //, $vars); // Currently sorting is not available
        $string .= '<tbody>' . PHP_EOL;
        foreach ($authlog['entries'] as $entry) {
            if (strlen($entry['user_agent']) > 1) {
                $entry['detect_browser'] = detect_browser($entry['user_agent'], TRUE);
                $entry['user_agent'] = $entry['detect_browser']['browser'];
                if ($entry['detect_browser']['platform']) {
                    $entry['user_agent'] .= ' (' . $entry['detect_browser']['platform'] . ')';
                }
            }
            if (strstr(strtolower($entry['result']), 'fail', true)) {
                $class = " class=\"error\"";
            } else {
                $class = "";
            }
            $string .= '
      <tr' . $class . '>
        <td>' . $entry['datetime'] . '</td>
        <td>' . escape_html($entry['user']) . '</td>
        <td>' . $entry['address'] . '</td>
        <td>' . $entry['user_agent'] . '</td>
        <td>' . $entry['result'] . '</td>
      </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>';
        // Add pagination header
        if ($authlog['pagination_html']) {
            $string = $authlog['pagination_html'] . $string . $authlog['pagination_html'];
        }
        // Print authlog
        echo $string;
    }
}
コード例 #6
0
}
if (is_ssl()) {
    $config['base_url'] = preg_replace('/^http:/', 'https:', $config['base_url']);
}
if (!isset($config['web_url'])) {
    $config['web_url'] = isset($config['base_url']) ? $config['base_url'] : 'http://localhost:80';
}
if (substr($config['web_url'], -1) != '/') {
    $config['web_url'] .= '/';
}
// Connect to database
$observium_link = mysql_connect($config['db_host'], $config['db_user'], $config['db_pass']);
if (!$observium_link) {
    include_once "common.inc.php";
    if (defined('__PHPUNIT_PHAR__')) {
        print_warning("警告. PHP中的单元测试可以跳过MySQL连接. 但如果你的MySQL功能测试, 检查你的配置.");
    } else {
        print_error("MySQL错误: " . mysql_error());
        die;
        // Die if not PHP Unit tests
    }
}
$observium_db = mysql_select_db($config['db_name'], $observium_link);
// Connect to statsd
if ($config['statsd']['enable'] && class_exists('StatsD')) {
    $statsd = new StatsD($config['statsd']['host'] . ':' . $config['statsd']['port']);
}
// Set some times needed by loads of scripts (it's dynamic, so we do it here!)
$config['time']['now'] = time();
$config['time']['fourhour'] = $config['time']['now'] - 14400;
//time() - (4 * 60 * 60);
コード例 #7
0
<?php 
    if ($config['smokeping']['dir'] != '') {
        $smokeping_files = get_smokeping_files(1);
        echo '<p />';
        if ($smokeping_files['incoming'][$device['hostname']]) {
            print_success("RRD发现进向流量延迟.");
        } else {
            print_error("RRD未发现进向流量延迟.");
        }
        if ($smokeping_files['outgoing'][$device['hostname']]) {
            print_success("RRD发现出向流量延迟.");
        } else {
            print_error("RRD未发现出向流量延迟.");
        }
    } else {
        print_warning("没有配置Smokeping目录.");
    }
    ?>
      </div>
    </div>
  </div>

</div>

    <div class="well info_box">
      <div class="title"><a href="<?php 
    echo generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'graphs'));
    ?>
">
        <i class="oicon-blocks"></i> 设备图形</a></div>
      <div class="content">
コード例 #8
0
ファイル: functions.inc.php プロジェクト: Natolumin/observium
function poll_status($device)
{
    global $config, $agent_sensors, $ipmi_sensors, $graphs, $oid_cache;
    $sql = "SELECT * FROM `status`";
    $sql .= " LEFT JOIN `status-state` USING(`status_id`)";
    $sql .= " WHERE `device_id` = ?";
    foreach (dbFetchRows($sql, array($device['device_id'])) as $status_db) {
        //print_cli_heading("Status: ".$status_db['status_descr']. "(".$status_db['poller_type'].")", 3);
        print_debug("Checking (" . $status_db['poller_type'] . ") " . $status_db['status_descr'] . " ");
        // $status_poll = $status_db;    // Cache non-humanized status array for use as new status state
        if ($status_db['poller_type'] == "snmp") {
            // Check if a specific poller file exists for this status, else collect via SNMP.
            $file = $config['install_dir'] . "/includes/polling/status/" . $status_db['status_type'] . ".inc.php";
            if (is_file($file)) {
                include $file;
            } else {
                // Take value from $oid_cache if we have it, else snmp_get it
                if (is_numeric($oid_cache[$status_db['status_oid']])) {
                    print_debug("value taken from oid_cache");
                    $status_value = $oid_cache[$status_db['status_oid']];
                } else {
                    $status_value = snmp_get($device, $status_db['status_oid'], "-OUqnv", "SNMPv2-MIB");
                }
                $status_value = snmp_fix_numeric($status_value);
            }
        } else {
            if ($status_db['poller_type'] == "agent") {
                if (isset($agent_sensors['state'])) {
                    $status_value = $agent_sensors['state'][$status_db['status_type']][$status_db['status_index']]['current'];
                } else {
                    print_warning("No agent status data available.");
                    continue;
                }
            } else {
                if ($status_db['poller_type'] == "ipmi") {
                    if (isset($ipmi_sensors['state'])) {
                        $status_value = $ipmi_sensors['state'][$status_db['status_type']][$status_db['status_index']]['current'];
                    } else {
                        print_warning("No IPMI status data available.");
                        continue;
                    }
                } else {
                    print_warning("Unknown status poller type.");
                    continue;
                }
            }
        }
        $status_polled_time = time();
        // Store polled time for current status
        // Write new value and humanize (for alert checks)
        $state_array = get_state_array($status_db['status_type'], $status_value, $status_db['poller_type']);
        $status_poll['status_value'] = $state_array['value'];
        $status_poll['status_name'] = $state_array['name'];
        if ($status_db['status_ignore'] || $status_db['status_disable']) {
            $status_poll['status_event'] = 'ignore';
        } else {
            $status_poll['status_event'] = $state_array['event'];
        }
        // If last change never set, use current time
        if (empty($status_db['status_last_change'])) {
            $status_db['status_last_change'] = $status_polled_time;
        }
        if ($status_poll['status_event'] != $status_db['status_event']) {
            // Status event changed, log and set status_last_change
            $status_poll['status_last_change'] = $status_polled_time;
            if ($status_poll['status_event'] == 'ignore') {
                print_message("[%ystatus Ignored%n]", 'color');
            } else {
                if ($status_db['status_event'] != '') {
                    // If old state not empty and new state not equals to new state
                    $msg = 'Status ';
                    switch ($status_poll['status_event']) {
                        case 'alert':
                            // New state alerted
                            $msg .= "Alert: " . $device['hostname'] . " " . $status_db['status_descr'] . " entered ALERT state: " . $status_poll['status_name'] . " (previous: " . $status_db['status_name'] . ")";
                            log_event($msg, $device, 'status', $status_db['status_id'], 'warning');
                            break;
                        case 'warning':
                            // New state warned
                            $msg .= "Warning: " . $device['hostname'] . " " . $status_db['status_descr'] . " entered WARNING state: " . $status_poll['status_name'] . " (previous: " . $status_db['status_name'] . ")";
                            log_event($msg, $device, 'status', $status_db['status_id']);
                            break;
                        case 'ok':
                            // New state ok
                            $msg .= "Ok: " . $device['hostname'] . " " . $status_db['status_descr'] . " entered OK state: " . $status_poll['status_name'] . " (previous: " . $status_db['status_name'] . ")";
                            log_event($msg, $device, 'status', $status_db['status_id'], 'warning');
                            break;
                    }
                }
            }
        } else {
            // If status not changed, leave old last_change
            $status_poll['status_last_change'] = $status_db['status_last_change'];
        }
        if (OBS_DEBUG > 1) {
            print_vars($status_poll);
        }
        // Send statistics array via AMQP/JSON if AMQP is enabled globally and for the ports module
        if ($config['amqp']['enable'] == TRUE && $config['amqp']['modules']['status']) {
            $json_data = array('value' => $status_value);
            messagebus_send(array('attribs' => array('t' => time(), 'device' => $device['hostname'], 'device_id' => $device['device_id'], 'e_type' => 'status', 'e_type' => $status_db['status_type'], 'e_index' => $status_db['status_index']), 'data' => $json_data));
        }
        // Update StatsD/Carbon
        if ($config['statsd']['enable'] == TRUE) {
            StatsD::gauge(str_replace(".", "_", $device['hostname']) . '.' . 'status' . '.' . $status_db['status_class'] . '.' . $status_db['status_type'] . '.' . $status_db['status_index'], $status_value);
        }
        // Update RRD - FIXME - can't convert to NG because filename is dynamic! new function should return index instead of filename.
        $rrd_file = get_status_rrd($device, $status_db);
        rrdtool_create($device, $rrd_file, "DS:status:GAUGE:600:-20000:U");
        rrdtool_update($device, $rrd_file, "N:{$status_value}");
        // Enable graph
        $graphs[$sensor_db['status']] = TRUE;
        // Check alerts
        $metrics = array();
        $metrics['status_value'] = $status_value;
        $metrics['status_name'] = $status_poll['status_name'];
        $metrics['status_name_uptime'] = $status_polled_time - $status_poll['status_last_change'];
        $metrics['status_event'] = $status_poll['status_event'];
        //print_cli_data("Event (State)", $status_poll['status_event'] ." (".$status_poll['status_name'].")", 3);
        $GLOBALS['table_rows'][] = array($status_db['status_descr'], $status_db['status_type'], $status_db['status_index'], $status_db['poller_type'], $status_poll['status_name'], $status_poll['status_event'], format_unixtime($status_poll['status_last_change']));
        check_entity('status', $status_db, $metrics);
        // Update SQL State
        if (is_numeric($status_db['status_polled'])) {
            dbUpdate(array('status_value' => $status_value, 'status_name' => $status_poll['status_name'], 'status_event' => $status_poll['status_event'], 'status_last_change' => $status_poll['status_last_change'], 'status_polled' => $status_polled_time), 'status-state', '`status_id` = ?', array($status_db['status_id']));
        } else {
            dbInsert(array('status_id' => $status_db['status_id'], 'status_value' => $status_value, 'status_name' => $status_poll['status_name'], 'status_event' => $status_poll['status_event'], 'status_last_change' => $status_poll['status_last_change'], 'status_polled' => $status_polled_time), 'status-state');
        }
    }
}
コード例 #9
0
ファイル: port-edit.inc.php プロジェクト: Natolumin/observium
         $update_array[$param] = $new_param;
     }
 }
 if (count($update_array)) {
     //r($update_array);
     dbUpdate($update_array, 'ports', '`device_id` = ? AND `port_id` = ?', array($device_id, $port_id));
     $updated = TRUE;
 }
 // Check custom ifSpeed
 $old_ifSpeed_bool = isset($port['ifSpeed_custom']);
 $new_ifSpeed_bool = isset($vars['ifSpeed_custom_bool_' . $port_id]);
 if ($new_ifSpeed_bool) {
     $vars['ifSpeed_custom_' . $port_id] = intval(unit_string_to_numeric($vars['ifSpeed_custom_' . $port_id], 1000));
     if ($vars['ifSpeed_custom_' . $port_id] <= 0) {
         // Wrong ifSpeed, skip
         print_warning("Passed incorrect value for port speed.");
         $old_ifSpeed_bool = $new_ifSpeed_bool = FALSE;
         // Skip change
     }
 }
 if ($old_ifSpeed_bool && $new_ifSpeed_bool) {
     // Both set, compare values
     if ($vars['ifSpeed_custom_' . $port_id] != $port['ifSpeed_custom']) {
         //r($vars['ifSpeed_custom_' . $port_id]); r($port['ifSpeed_custom']);
         set_entity_attrib('port', $port_id, 'ifSpeed_custom', $vars['ifSpeed_custom_' . $port_id]);
         $updated = TRUE;
     }
 } else {
     if ($old_ifSpeed_bool !== $new_ifSpeed_bool) {
         // Added or removed
         if ($old_ifSpeed_bool) {
コード例 #10
0
function detect_device_snmpauth($hostname, $snmp_port = 161, $snmp_transport = 'udp', $detect_ip_version = FALSE)
{
    global $config;
    // Additional checks for IP version
    if ($detect_ip_version) {
        $ip_version = get_ip_version($hostname);
        if (!$ip_version) {
            $ip = gethostbyname6($hostname);
            $ip_version = get_ip_version($ip);
        }
        // Detect snmp transport
        if (stripos($snmp_transport, 'tcp') !== FALSE) {
            $snmp_transport = $ip_version == 4 ? 'tcp' : 'tcp6';
        } else {
            $snmp_transport = $ip_version == 4 ? 'udp' : 'udp6';
        }
    }
    // Detect snmp port
    if (!is_numeric($snmp_port) || $snmp_port < 1 || $snmp_port > 65535) {
        $snmp_port = 161;
    } else {
        $snmp_port = (int) $snmp_port;
    }
    // Here set default snmp version order
    $i = 1;
    $snmp_version_order = array();
    foreach (array('v2c', 'v3', 'v1') as $tmp_version) {
        if ($config['snmp']['version'] == $tmp_version) {
            $snmp_version_order[0] = $tmp_version;
        } else {
            $snmp_version_order[$i] = $tmp_version;
        }
        $i++;
    }
    ksort($snmp_version_order);
    foreach ($snmp_version_order as $snmp_version) {
        if ($snmp_version === 'v3') {
            // Try each set of parameters from config
            foreach ($config['snmp']['v3'] as $snmp_v3) {
                $device = build_initial_device_array($hostname, NULL, $snmp_version, $snmp_port, $snmp_transport, $snmp_v3);
                print_message("Trying v3 parameters " . $device['snmp_authname'] . "/" . $device['snmp_authlevel'] . " ... ");
                if (isSNMPable($device)) {
                    return $device;
                } else {
                    print_warning("证书无应答 " . $device['snmp_authname'] . "/" . $device['snmp_authlevel'] . " using {$snmp_version}.");
                }
            }
        } else {
            // if ($snmp_version === "v2c" || $snmp_version === "v1")
            // Try each community from config
            foreach ($config['snmp']['community'] as $snmp_community) {
                $device = build_initial_device_array($hostname, $snmp_community, $snmp_version, $snmp_port, $snmp_transport);
                print_message("尝试 {$snmp_version} community {$snmp_community} ...");
                if (isSNMPable($device)) {
                    return $device;
                } else {
                    print_warning("Community无应答 {$snmp_community} 使用 {$snmp_version}.");
                }
            }
        }
    }
    return FALSE;
}
コード例 #11
0
ファイル: data.inc.php プロジェクト: Natolumin/observium
    return;
}
$export_device = $device;
if ($config['snmp']['hide_auth']) {
    $params = array('snmp_community', 'snmp_authlevel', 'snmp_authname', 'snmp_authpass', 'snmp_authalgo', 'snmp_cryptopass', 'snmp_cryptoalgo');
    foreach ($params as $param) {
        if (strlen($export_device[$param])) {
            $export_device[$param] = '***';
        }
    }
}
if ($vars['saveas'] == 'yes' && $vars['filename']) {
    download_as_file(gzencode(_json_encode($export_device)), $vars['filename']);
} else {
    if ($config['snmp']['hide_auth']) {
        print_warning("NOTE, <strong>\$config['snmp']['hide_auth']</strong> is set to <strong>TRUE</strong>, snmp community and snmp v3 auth hidden from output and export.");
    } else {
        print_error("WARNING, <strong>\$config['snmp']['hide_auth']</strong> is set to <strong>FALSE</strong>, snmp community and snmp v3 auth <strong>NOT hidden</strong> from output and export.");
    }
    $form = array('type' => 'rows', 'space' => '10px', 'url' => generate_url($vars));
    // Filename
    $form['row'][0]['filename'] = array('type' => 'text', 'name' => 'Filename', 'value' => $device['hostname'] . '.json.txt.gz', 'width' => '100%', 'placeholder' => TRUE);
    // Compress
    //$form['row'][0]['compress'] = array(
    //                                'type'        => 'switch',
    //                                'value'       => 1);
    // Search button
    $form['row'][0]['saveas'] = array('type' => 'submit', 'name' => 'Export', 'icon' => 'icon-save', 'right' => TRUE, 'value' => 'yes');
    print_form($form);
    r($export_device);
}
コード例 #12
0
foreach (get_type_groups($vars['metric']) as $group) {
    if ($group['group_id'] == $vars['group'] || in_array($group['group_id'], $vars['group'])) {
        $navbar['options']['group']['class'] = 'active';
        $navbar['options']['group']['text'] .= " (" . $group['group_name'] . ')';
        $navbar['options']['group']['suboptions'][$group['group_id']]['url'] = generate_url($vars, array('group' => NULL));
    }
    $navbar['options']['group']['suboptions'][$group['group_id']]['text'] = $group['group_name'];
    $navbar['options']['group']['suboptions'][$group['group_id']]['url'] = generate_url($vars, array('group' => $group['group_id']));
}
$navbar['options']['graphs']['text'] = '图像';
$navbar['options']['graphs']['icon'] = 'oicon-chart-up';
$navbar['options']['graphs']['right'] = TRUE;
if ($vars['view'] == "graphs") {
    $navbar['options']['graphs']['class'] = 'active';
    $navbar['options']['graphs']['url'] = generate_url($vars, array('view' => "detail"));
} else {
    $navbar['options']['graphs']['url'] = generate_url($vars, array('view' => "graphs"));
}
print_navbar($navbar);
if (isset($datas[$vars['metric']])) {
    if (is_file('pages/health/' . $vars['metric'] . '.inc.php')) {
        include 'pages/health/' . $vars['metric'] . '.inc.php';
    } else {
        $sensor_type = $vars['metric'];
        include 'pages/health/sensors.inc.php';
    }
} else {
    print_warning("没有传感器类型 " . $vars['metric'] . " 发现.");
}
$page_title[] = "系统健康";
// EOF
コード例 #13
0
ファイル: logalert.inc.php プロジェクト: Natolumin/observium
/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage web
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
function print_logalert_log($vars)
{
    global $config;
    foreach (dbFetchRows("SELECT * FROM `syslog_rules` ORDER BY `la_name`") as $la) {
        $syslog_rules[$la['la_id']] = $la;
    }
    $entries = get_logalert_log($vars);
    if (!$entries['count']) {
        // There have been no entries returned. Print the warning.
        print_warning('<h4>No logging alert entries found!</h4>');
    } else {
        // Entries have been returned. Print the table.
        $list = array('device' => FALSE);
        if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'alert_log') {
            $list['device'] = TRUE;
        }
        if (!isset($vars['la_id']) || empty($vars['la_id'])) {
            $list['la_id'] = TRUE;
        }
        $string = generate_box_open($vars['header']);
        $string .= '<table class="table table-striped table-hover table-condensed-more">' . PHP_EOL;
        if (!$entries['short']) {
            $cols = array();
            $cols[] = array(NULL, 'class="state-marker"');
            $cols['date'] = array('Date', 'style="width: 140px"');
            if ($list['device']) {
                $cols['device'] = array('Device', 'style="width: 150px;"');
            }
            if ($list['la_id']) {
                $cols['la_id'] = array('Alert Rule', 'style="width: 150px;"');
            }
            $cols[] = array('Program', 'style="width: 80px"');
            $cols[] = 'Message';
            $cols[] = array('Notified', 'style="width: 40px"');
            $string .= get_table_header($cols);
            // , $vars); // Actually sorting is disabled now
        }
        $string .= '  <tbody>' . PHP_EOL;
        foreach ($entries['entries'] as $entry) {
            $string .= '  <tr class="' . $entry['html_row_class'] . '">' . PHP_EOL;
            $string .= '<td class="state-marker"></td>' . PHP_EOL;
            if ($entries['short']) {
                $string .= '    <td class="syslog" style="white-space: nowrap">';
                $timediff = $GLOBALS['config']['time']['now'] - strtotime($entry['timestamp']);
                $string .= generate_tooltip_link('', formatUptime($timediff, "short-3"), format_timestamp($entry['timestamp']), NULL) . '</td>' . PHP_EOL;
            } else {
                $string .= '    <td>';
                $string .= format_timestamp($entry['timestamp']) . '</td>' . PHP_EOL;
            }
            if ($list['device']) {
                $dev = device_by_id_cache($entry['device_id']);
                $device_vars = array('page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'alertlog');
                $string .= '    <td class="entity">' . generate_device_link($dev, short_hostname($dev['hostname']), $device_vars) . '</td>' . PHP_EOL;
            }
            if ($list['la_id']) {
                $string .= '<td><strong><a href="' . generate_url(array('page' => 'syslog_rules', 'la_id' => $entry['la_id'])) . '">' . (is_array($syslog_rules[$entry['la_id']]) ? $syslog_rules[$entry['la_id']]['la_name'] : 'Rule Deleted') . '</td>' . PHP_EOL;
            }
            $string .= '<td>' . (strlen($entry['program']) ? '<span class="label">' . $entry['program'] . '</span> ' : '') . '</td>' . PHP_EOL;
            $string .= '<td>' . escape_html($entry['message']) . '</td>' . PHP_EOL;
            if (!$vars['short']) {
                //$string .= '<td>' . escape_html($entry['log_type']) . '</td>' . PHP_EOL;
                $string .= '<td style="text-align: right">' . ($entry['notified'] == '1' ? '<span class="label label-success">YES</span>' : ($entry['notified'] == '-1' ? '<span class="label label-suppressed">NO</span>' : '<span class="label">NO</span>')) . '</td>' . PHP_EOL;
            }
            $string .= '  </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>';
        $string .= generate_box_close();
    }
    // Print pagination header
    if ($entries['pagination_html']) {
        $string = $entries['pagination_html'] . $string . $entries['pagination_html'];
    }
    // Print events
    echo $string;
}
コード例 #14
0
    function dbupdate()
    {
        startup_gettext();
        if (!SINGLE_USER_MODE && $_SESSION["access_level"] < 10) {
            $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
            render_login_form();
            exit;
        }
        ?>
<html>
			<head>
			<title>Database Updater</title>
			<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
			<link rel="stylesheet" type="text/css" href="css/utility.css"/>
			</head>
			<style type="text/css">
				span.ok { color : #009000; font-weight : bold; }
				span.err { color : #ff0000; font-weight : bold; }
			</style>
		<body>
			<script type='text/javascript'>
			function confirmOP() {
				return confirm("Update the database?");
			}
			</script>

			<div class="floatingLogo"><img src="images/logo_small.png"></div>

			<h1><?php 
        echo __("Database Updater");
        ?>
</h1>

			<div class="content">

			<?php 
        @($op = $_REQUEST["subop"]);
        $updater = new DbUpdater(Db::get(), DB_TYPE, SCHEMA_VERSION);
        if ($op == "performupdate") {
            if ($updater->isUpdateRequired()) {
                print "<h2>Performing updates</h2>";
                print "<h3>Updating to schema version " . SCHEMA_VERSION . "</h3>";
                print "<ul>";
                for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) {
                    print "<li>Performing update up to version {$i}...";
                    $result = $updater->performUpdateTo($i);
                    if (!$result) {
                        print "<span class='err'>FAILED!</span></li></ul>";
                        print_warning("One of the updates failed. Either retry the process or perform updates manually.");
                        print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t\t\t</form>";
                        break;
                    } else {
                        print "<span class='ok'>OK!</span></li>";
                    }
                }
                print "</ul>";
                print_notice("Your Tiny Tiny RSS database is now updated to the latest version.");
                print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t</form>";
            } else {
                print "<h2>Your database is up to date.</h2>";
                print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t</form>";
            }
        } else {
            if ($updater->isUpdateRequired()) {
                print "<h2>Database update required</h2>";
                print "<h3>";
                printf("Your Tiny Tiny RSS database needs update to the latest version: %d to %d.", $updater->getSchemaVersion(), SCHEMA_VERSION);
                print "</h3>";
                print_warning("Please backup your database before proceeding.");
                print "<form method='POST'>\n\t\t\t\t\t\t\t<input type='hidden' name='subop' value='performupdate'>\n\t\t\t\t\t\t\t<input type='submit' onclick='return confirmOP()' value='" . __("Perform updates") . "'>\n\t\t\t\t\t\t</form>";
            } else {
                print_notice("Tiny Tiny RSS database is up to date.");
                print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t</form>";
            }
        }
        ?>

			</div>
			</body>
			</html>
		<?php 
    }
コード例 #15
0
 function index()
 {
     global $access_level_names;
     $prefs_blacklist = array("STRIP_UNSAFE_TAGS", "REVERSE_HEADLINES", "SORT_HEADLINES_BY_FEED_DATE", "DEFAULT_ARTICLE_LIMIT", "FEEDS_SORT_BY_UNREAD");
     /* "FEEDS_SORT_BY_UNREAD", "HIDE_READ_FEEDS", "REVERSE_HEADLINES" */
     $profile_blacklist = array("ALLOW_DUPLICATE_POSTS", "PURGE_OLD_DAYS", "PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP", "BLACKLISTED_TAGS", "ENABLE_API_ACCESS", "UPDATE_POST_ON_CHECKSUM_CHANGE", "DEFAULT_UPDATE_INTERVAL", "USER_TIMEZONE", "SORT_HEADLINES_BY_FEED_DATE", "SSL_CERT_SERIAL", "DIGEST_PREFERRED_TIME");
     $_SESSION["prefs_op_result"] = "";
     print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
     print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Personal data / Authentication') . "\">";
     print "<form dojoType=\"dijit.form.Form\" id=\"changeUserdataForm\">";
     print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\tevt.preventDefault();\n\t\tif (this.validate()) {\n\t\t\tnotify_progress('Saving data...', true);\n\n\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\tnotify_callback2(transport);\n\t\t\t} });\n\n\t\t}\n\t\t</script>";
     print "<table width=\"100%\" class=\"prefPrefsList\">";
     print "<h2>" . __("Personal data") . "</h2>";
     $result = $this->dbh->query("SELECT email,full_name,otp_enabled,\n\t\t\taccess_level FROM ttrss_users\n\t\t\tWHERE id = " . $_SESSION["uid"]);
     $email = htmlspecialchars($this->dbh->fetch_result($result, 0, "email"));
     $full_name = htmlspecialchars($this->dbh->fetch_result($result, 0, "full_name"));
     $otp_enabled = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "otp_enabled"));
     print "<tr><td width=\"40%\">" . __('Full name') . "</td>";
     print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" name=\"full_name\" required=\"1\"\n\t\t\tvalue=\"{$full_name}\"></td></tr>";
     print "<tr><td width=\"40%\">" . __('E-mail') . "</td>";
     print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" name=\"email\" required=\"1\" value=\"{$email}\"></td></tr>";
     if (!SINGLE_USER_MODE && !$_SESSION["hide_hello"]) {
         $access_level = $this->dbh->fetch_result($result, 0, "access_level");
         print "<tr><td width=\"40%\">" . __('Access level') . "</td>";
         print "<td>" . $access_level_names[$access_level] . "</td></tr>";
     }
     print "</table>";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"changeemail\">";
     print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Save data") . "</button>";
     print "</form>";
     if ($_SESSION["auth_module"]) {
         $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]);
     } else {
         $authenticator = false;
     }
     if ($authenticator && method_exists($authenticator, "change_password")) {
         print "<h2>" . __("Password") . "</h2>";
         $result = $this->dbh->query("SELECT id FROM ttrss_users\n\t\t\t\tWHERE id = " . $_SESSION["uid"] . " AND pwd_hash\n\t\t\t\t= 'SHA1:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'");
         if ($this->dbh->num_rows($result) != 0) {
             print format_warning(__("Your password is at default value, please change it."), "default_pass_warning");
         }
         print "<form dojoType=\"dijit.form.Form\">";
         print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\t\tevt.preventDefault();\n\t\t\tif (this.validate()) {\n\t\t\t\tnotify_progress('Changing password...', true);\n\n\t\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\t\tnotify('');\n\t\t\t\t\t\tif (transport.responseText.indexOf('ERROR: ') == 0) {\n\t\t\t\t\t\t\tnotify_error(transport.responseText.replace('ERROR: ', ''));\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnotify_info(transport.responseText);\n\t\t\t\t\t\t\tvar warn = \$('default_pass_warning');\n\t\t\t\t\t\t\tif (warn) Element.hide(warn);\n\t\t\t\t\t\t}\n\t\t\t\t}});\n\t\t\t\tthis.reset();\n\t\t\t}\n\t\t\t</script>";
         if ($otp_enabled) {
             print_notice(__("Changing your current password will disable OTP."));
         }
         print "<table width=\"100%\" class=\"prefPrefsList\">";
         print "<tr><td width=\"40%\">" . __("Old password") . "</td>";
         print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\" name=\"old_password\"></td></tr>";
         print "<tr><td width=\"40%\">" . __("New password") . "</td>";
         print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\"\n\t\t\t\tname=\"new_password\"></td></tr>";
         print "<tr><td width=\"40%\">" . __("Confirm password") . "</td>";
         print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\" name=\"confirm_password\"></td></tr>";
         print "</table>";
         print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
         print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"changepassword\">";
         print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Change password") . "</button>";
         print "</form>";
         if ($_SESSION["auth_module"] == "auth_internal") {
             print "<h2>" . __("One time passwords / Authenticator") . "</h2>";
             if ($otp_enabled) {
                 print_notice(__("One time passwords are currently enabled. Enter your current password below to disable."));
                 print "<form dojoType=\"dijit.form.Form\">";
                 print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\t\t\tevt.preventDefault();\n\t\t\t\tif (this.validate()) {\n\t\t\t\t\tnotify_progress('Disabling OTP', true);\n\n\t\t\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\t\t\tnotify('');\n\t\t\t\t\t\t\tif (transport.responseText.indexOf('ERROR: ') == 0) {\n\t\t\t\t\t\t\t\tnotify_error(transport.responseText.replace('ERROR: ', ''));\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\twindow.location.reload();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t}});\n\t\t\t\t\tthis.reset();\n\t\t\t\t}\n\t\t\t\t</script>";
                 print "<table width=\"100%\" class=\"prefPrefsList\">";
                 print "<tr><td width=\"40%\">" . __("Enter your password") . "</td>";
                 print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\"\n\t\t\t\t\tname=\"password\"></td></tr>";
                 print "</table>";
                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"otpdisable\">";
                 print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Disable OTP") . "</button>";
                 print "</form>";
             } else {
                 if (function_exists("imagecreatefromstring")) {
                     print_warning(__("You will need a compatible Authenticator to use this. Changing your password would automatically disable OTP."));
                     print "<p>" . __("Scan the following code by the Authenticator application:") . "</p>";
                     $csrf_token = $_SESSION["csrf_token"];
                     print "<img src=\"backend.php?op=pref-prefs&method=otpqrcode&csrf_token={$csrf_token}\">";
                     print "<form dojoType=\"dijit.form.Form\" id=\"changeOtpForm\">";
                     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
                     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"otpenable\">";
                     print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\t\t\t\tevt.preventDefault();\n\t\t\t\t\tif (this.validate()) {\n\t\t\t\t\t\tnotify_progress('Saving data...', true);\n\n\t\t\t\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\t\t\t\tnotify('');\n\t\t\t\t\t\t\t\tif (transport.responseText.indexOf('ERROR:') == 0) {\n\t\t\t\t\t\t\t\t\tnotify_error(transport.responseText.replace('ERROR:', ''));\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\twindow.location.reload();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} });\n\n\t\t\t\t\t}\n\t\t\t\t\t</script>";
                     print "<table width=\"100%\" class=\"prefPrefsList\">";
                     print "<tr><td width=\"40%\">" . __("Enter your password") . "</td>";
                     print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\"\n\t\t\t\t\t\tname=\"password\"></td></tr>";
                     print "<tr><td width=\"40%\">" . __("Enter the generated one time password") . "</td>";
                     print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" autocomplete=\"off\"\n\t\t\t\t\t\trequired=\"1\"\n\t\t\t\t\t\tname=\"otp\"></td></tr>";
                     print "<tr><td colspan=\"2\">";
                     print "</td></tr><tr><td colspan=\"2\">";
                     print "</td></tr>";
                     print "</table>";
                     print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Enable OTP") . "</button>";
                     print "</form>";
                 } else {
                     print_notice(__("PHP GD functions are required for OTP support."));
                 }
             }
         }
     }
     PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefPrefsAuth");
     print "</div>";
     #pane
     print "<div dojoType=\"dijit.layout.AccordionPane\" selected=\"true\" title=\"" . __('Preferences') . "\">";
     print "<form dojoType=\"dijit.form.Form\" id=\"changeSettingsForm\">";
     print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt, quit\">\n\t\tif (evt) evt.preventDefault();\n\t\tif (this.validate()) {\n\t\t\tconsole.log(dojo.objectToQuery(this.getValues()));\n\n\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\tvar msg = transport.responseText;\n\t\t\t\t\tif (quit) {\n\t\t\t\t\t\tgotoMain();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (msg == 'PREFS_NEED_RELOAD') {\n\t\t\t\t\t\t\twindow.location.reload();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnotify_info(msg);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t} });\n\t\t}\n\t\t</script>";
     print '<div dojoType="dijit.layout.BorderContainer" gutters="false">';
     print '<div dojoType="dijit.layout.ContentPane" region="center" style="overflow-y : auto">';
     if ($_SESSION["profile"]) {
         print_notice(__("Some preferences are only available in default profile."));
     }
     if ($_SESSION["profile"]) {
         initialize_user_prefs($_SESSION["uid"], $_SESSION["profile"]);
         $profile_qpart = "profile = '" . $_SESSION["profile"] . "'";
     } else {
         initialize_user_prefs($_SESSION["uid"]);
         $profile_qpart = "profile IS NULL";
     }
     /* if ($_SESSION["prefs_show_advanced"])
     			$access_query = "true";
     		else
     			$access_query = "(access_level = 0 AND section_id != 3)"; */
     $access_query = 'true';
     $result = $this->dbh->query("SELECT DISTINCT\n\t\t\tttrss_user_prefs.pref_name,value,type_name,\n\t\t\tttrss_prefs_sections.order_id,\n\t\t\tdef_value,section_id\n\t\t\tFROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs\n\t\t\tWHERE type_id = ttrss_prefs_types.id AND\n\t\t\t\t{$profile_qpart} AND\n\t\t\t\tsection_id = ttrss_prefs_sections.id AND\n\t\t\t\tttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND\n\t\t\t\t{$access_query} AND\n\t\t\t\towner_uid = " . $_SESSION["uid"] . "\n\t\t\tORDER BY ttrss_prefs_sections.order_id,pref_name");
     $lnum = 0;
     $active_section = "";
     $listed_boolean_prefs = array();
     while ($line = $this->dbh->fetch_assoc($result)) {
         if (in_array($line["pref_name"], $prefs_blacklist)) {
             continue;
         }
         $type_name = $line["type_name"];
         $pref_name = $line["pref_name"];
         $section_name = $this->getSectionName($line["section_id"]);
         $value = $line["value"];
         $short_desc = $this->getShortDesc($pref_name);
         $help_text = $this->getHelpText($pref_name);
         if (!$short_desc) {
             continue;
         }
         if ($_SESSION["profile"] && in_array($line["pref_name"], $profile_blacklist)) {
             continue;
         }
         if ($active_section != $line["section_id"]) {
             if ($active_section != "") {
                 print "</table>";
             }
             print "<table width=\"100%\" class=\"prefPrefsList\">";
             $active_section = $line["section_id"];
             print "<tr><td colspan=\"3\"><h3>" . $section_name . "</h3></td></tr>";
             $lnum = 0;
         }
         print "<tr>";
         print "<td width=\"40%\" class=\"prefName\" id=\"{$pref_name}\">";
         print "<label for='CB_{$pref_name}'>";
         print $short_desc;
         print "</label>";
         if ($help_text) {
             print "<div class=\"prefHelp\">" . __($help_text) . "</div>";
         }
         print "</td>";
         print "<td class=\"prefValue\">";
         if ($pref_name == "USER_LANGUAGE") {
             print_select_hash($pref_name, $value, get_translations(), "style='width : 220px; margin : 0px' dojoType='dijit.form.Select'");
         } else {
             if ($pref_name == "USER_TIMEZONE") {
                 $timezones = explode("\n", file_get_contents("lib/timezones.txt"));
                 print_select($pref_name, $value, $timezones, 'dojoType="dijit.form.FilteringSelect"');
             } else {
                 if ($pref_name == "USER_STYLESHEET") {
                     print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\t\tonclick=\"customizeCSS()\">" . __('Customize') . "</button>";
                 } else {
                     if ($pref_name == "USER_CSS_THEME") {
                         $themes = array_map("basename", glob("themes/*.css"));
                         print_select($pref_name, $value, $themes, 'dojoType="dijit.form.Select"');
                     } else {
                         if ($pref_name == "DEFAULT_UPDATE_INTERVAL") {
                             global $update_intervals_nodefault;
                             print_select_hash($pref_name, $value, $update_intervals_nodefault, 'dojoType="dijit.form.Select"');
                         } else {
                             if ($type_name == "bool") {
                                 array_push($listed_boolean_prefs, $pref_name);
                                 $checked = $value == "true" ? "checked=\"checked\"" : "";
                                 if ($pref_name == "PURGE_UNREAD_ARTICLES" && FORCE_ARTICLE_PURGE != 0) {
                                     $disabled = "disabled=\"1\"";
                                     $checked = "checked=\"checked\"";
                                 } else {
                                     $disabled = "";
                                 }
                                 print "<input type='checkbox' name='{$pref_name}' {$checked} {$disabled}\n\t\t\t\t\tdojoType='dijit.form.CheckBox' id='CB_{$pref_name}' value='1'>";
                             } else {
                                 if (array_search($pref_name, array('FRESH_ARTICLE_MAX_AGE', 'PURGE_OLD_DAYS', 'LONG_DATE_FORMAT', 'SHORT_DATE_FORMAT')) !== false) {
                                     $regexp = $type_name == 'integer' ? 'regexp="^\\d*$"' : '';
                                     if ($pref_name == "PURGE_OLD_DAYS" && FORCE_ARTICLE_PURGE != 0) {
                                         $disabled = "disabled=\"1\"";
                                         $value = FORCE_ARTICLE_PURGE;
                                     } else {
                                         $disabled = "";
                                     }
                                     print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\trequired=\"1\" {$regexp} {$disabled}\n\t\t\t\t\tname=\"{$pref_name}\" value=\"{$value}\">";
                                 } else {
                                     if ($pref_name == "SSL_CERT_SERIAL") {
                                         print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\tid=\"SSL_CERT_SERIAL\" readonly=\"1\"\n\t\t\t\t\tname=\"{$pref_name}\" value=\"{$value}\">";
                                         $cert_serial = htmlspecialchars(get_ssl_certificate_id());
                                         $has_serial = $cert_serial ? "false" : "true";
                                         print " <button dojoType=\"dijit.form.Button\" disabled=\"{$has_serial}\"\n\t\t\t\t\tonclick=\"insertSSLserial('{$cert_serial}')\">" . __('Register') . "</button>";
                                         print " <button dojoType=\"dijit.form.Button\"\n\t\t\t\t\tonclick=\"insertSSLserial('')\">" . __('Clear') . "</button>";
                                     } else {
                                         if ($pref_name == 'DIGEST_PREFERRED_TIME') {
                                             print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\tid=\"{$pref_name}\" regexp=\"[012]?\\d:\\d\\d\" placeHolder=\"12:00\"\n\t\t\t\t\tname=\"{$pref_name}\" value=\"{$value}\"><div class=\"insensitive\">" . T_sprintf("Current server time: %s (UTC)", date("H:i")) . "</div>";
                                         } else {
                                             $regexp = $type_name == 'integer' ? 'regexp="^\\d*$"' : '';
                                             print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\t{$regexp}\n\t\t\t\t\tname=\"{$pref_name}\" value=\"{$value}\">";
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         print "</td>";
         print "</tr>";
         $lnum++;
     }
     print "</table>";
     $listed_boolean_prefs = htmlspecialchars(join(",", $listed_boolean_prefs));
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"boolean_prefs\" value=\"{$listed_boolean_prefs}\">";
     PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefPrefsPrefsInside");
     print '</div>';
     # inside pane
     print '<div dojoType="dijit.layout.ContentPane" region="bottom">';
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"saveconfig\">";
     print "<div dojoType=\"dijit.form.ComboButton\" type=\"submit\">\n\t\t\t<span>" . __('Save configuration') . "</span>\n\t\t\t<div dojoType=\"dijit.DropDownMenu\">\n\t\t\t\t<div dojoType=\"dijit.MenuItem\"\n\t\t\t\t\tonclick=\"dijit.byId('changeSettingsForm').onSubmit(null, true)\">" . __("Save and exit preferences") . "</div>\n\t\t\t</div>\n\t\t\t</div>";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"return editProfiles()\">" . __('Manage profiles') . "</button> ";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"return validatePrefsReset()\">" . __('Reset to defaults') . "</button>";
     print "&nbsp;";
     /* $checked = $_SESSION["prefs_show_advanced"] ? "checked='1'" : "";
     
     		print "<input onclick='toggleAdvancedPrefs()'
     				id='prefs_show_advanced'
     				dojoType=\"dijit.form.CheckBox\"
     				$checked
     				type=\"checkbox\"></input>
     				<label for='prefs_show_advanced'>" .
     				__("Show additional preferences") . "</label>"; */
     PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefPrefsPrefsOutside");
     print "</form>";
     print '</div>';
     # inner pane
     print '</div>';
     # border container
     print "</div>";
     #pane
     print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Plugins') . "\">";
     print "<p>" . __("You will need to reload Tiny Tiny RSS for plugin changes to take effect.") . "</p>";
     print_notice(__("Download more plugins at tt-rss.org <a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/forum/viewforum.php?f=22\">forums</a> or <a target=\"_blank\" class=\"visibleLink\" href=\"http://tt-rss.org/wiki/Plugins\">wiki</a>."));
     print "<form dojoType=\"dijit.form.Form\" id=\"changePluginsForm\">";
     print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\tevt.preventDefault();\n\t\tif (this.validate()) {\n\t\t\tnotify_progress('Saving data...', true);\n\n\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\tnotify('');\n\t\t\t\t\tif (confirm(__('Selected plugins have been enabled. Reload?'))) {\n\t\t\t\t\t\twindow.location.reload();\n\t\t\t\t\t}\n\t\t\t} });\n\n\t\t}\n\t\t</script>";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setplugins\">";
     print "<table width='100%' class='prefPluginsList'>";
     print "<tr><td colspan='4'><h3>" . __("System plugins") . "</h3></td></tr>";
     print "<tr class=\"title\">\n\t\t\t\t<td width=\"5%\">&nbsp;</td>\n\t\t\t\t<td width='10%'>" . __('Plugin') . "</td>\n\t\t\t\t<td width=''>" . __('Description') . "</td>\n\t\t\t\t<td width='5%'>" . __('Version') . "</td>\n\t\t\t\t<td width='10%'>" . __('Author') . "</td></tr>";
     $system_enabled = array_map("trim", explode(",", PLUGINS));
     $user_enabled = array_map("trim", explode(",", get_pref("_ENABLED_PLUGINS")));
     $tmppluginhost = new PluginHost();
     $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"]);
     $tmppluginhost->load_data(true);
     foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
         $about = $plugin->about();
         if ($about[3] && strpos($name, "example") === FALSE) {
             if (in_array($name, $system_enabled)) {
                 $checked = "checked='1'";
             } else {
                 $checked = "";
             }
             print "<tr>";
             print "<td align='center'><input disabled='1'\n\t\t\t\t\t\tdojoType=\"dijit.form.CheckBox\" {$checked}\n\t\t\t\t\t\ttype=\"checkbox\"></td>";
             $plugin_icon = $checked ? "plugin.png" : "plugin_disabled.png";
             print "<td><label><img src='images/{$plugin_icon}' alt=''> {$name}</label></td>";
             print "<td>" . htmlspecialchars($about[1]);
             if (@$about[4]) {
                 print " &mdash; <a target=\"_blank\" class=\"visibleLink\"\n\t\t\t\t\t\thref=\"" . htmlspecialchars($about[4]) . "\">" . __("more info") . "</a>";
             }
             print "</td>";
             print "<td>" . htmlspecialchars(sprintf("%.2f", $about[0])) . "</td>";
             print "<td>" . htmlspecialchars($about[2]) . "</td>";
             if (count($tmppluginhost->get_all($plugin)) > 0) {
                 if (in_array($name, $system_enabled)) {
                     print "<td><a href='#' onclick=\"clearPluginData('{$name}')\"\n\t\t\t\t\t\t\tclass='visibleLink'>" . __("Clear data") . "</a></td>";
                 }
             }
             print "</tr>";
         }
     }
     print "<tr><td colspan='4'><h3>" . __("User plugins") . "</h3></td></tr>";
     print "<tr class=\"title\">\n\t\t\t\t<td width=\"5%\">&nbsp;</td>\n\t\t\t\t<td width='10%'>" . __('Plugin') . "</td>\n\t\t\t\t<td width=''>" . __('Description') . "</td>\n\t\t\t\t<td width='5%'>" . __('Version') . "</td>\n\t\t\t\t<td width='10%'>" . __('Author') . "</td></tr>";
     foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
         $about = $plugin->about();
         if (!$about[3] && strpos($name, "example") === FALSE) {
             if (in_array($name, $system_enabled)) {
                 $checked = "checked='1'";
                 $disabled = "disabled='1'";
                 $rowclass = '';
             } else {
                 if (in_array($name, $user_enabled)) {
                     $checked = "checked='1'";
                     $disabled = "";
                     $rowclass = "Selected";
                 } else {
                     $checked = "";
                     $disabled = "";
                     $rowclass = '';
                 }
             }
             print "<tr class='{$rowclass}'>";
             $plugin_icon = $checked ? "plugin.png" : "plugin_disabled.png";
             print "<td align='center'><input id='FPCHK-{$name}' name='plugins[]' value='{$name}' onclick='toggleSelectRow2(this);'\n\t\t\t\t\tdojoType=\"dijit.form.CheckBox\" {$checked} {$disabled}\n\t\t\t\t\ttype=\"checkbox\"></td>";
             print "<td><label for='FPCHK-{$name}'><img src='images/{$plugin_icon}' alt=''> {$name}</label></td>";
             print "<td><label for='FPCHK-{$name}'>" . htmlspecialchars($about[1]) . "</label>";
             if (@$about[4]) {
                 print " &mdash; <a target=\"_blank\" class=\"visibleLink\"\n\t\t\t\t\t\thref=\"" . htmlspecialchars($about[4]) . "\">" . __("more info") . "</a>";
             }
             print "</td>";
             print "<td>" . htmlspecialchars(sprintf("%.2f", $about[0])) . "</td>";
             print "<td>" . htmlspecialchars($about[2]) . "</td>";
             if (count($tmppluginhost->get_all($plugin)) > 0) {
                 if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) {
                     print "<td><a href='#' onclick=\"clearPluginData('{$name}')\" class='visibleLink'>" . __("Clear data") . "</a></td>";
                 }
             }
             print "</tr>";
         }
     }
     print "</table>";
     print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Enable selected plugins") . "</button></p>";
     print "</form>";
     print "</div>";
     #pane
     PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefPrefs");
     print "</div>";
     #container
 }
コード例 #16
0
ファイル: adduser.php プロジェクト: Natolumin/observium
if (is_file($auth_file)) {
    include $auth_file;
    // Include base auth functions calls
    include $config['html_dir'] . '/includes/authenticate-functions.inc.php';
} else {
    print_error("ERROR: no valid auth_mechanism defined.");
    exit;
}
if (auth_usermanagement()) {
    if (isset($argv[1]) && isset($argv[2]) && isset($argv[3])) {
        if (!auth_user_exists($argv[1])) {
            if (adduser($argv[1], $argv[2], $argv[3], @$argv[4])) {
                print_success("User " . $argv[1] . " added successfully.");
            } else {
                print_error("User " . $argv[1] . " creation failed!");
            }
        } else {
            print_warning("User " . $argv[1] . " already exists!");
        }
    } else {
        $msg = "%n\nUSAGE:\n{$scriptname} <username> <password> <level 1-10> [email]\n\nEXAMPLE:\n%WADMIN%n:   {$scriptname} <username> <password> 10 [email]\n\nUSER LEVELS:" . PHP_EOL;
        foreach ($GLOBALS['config']['user_level'] as $level => $entry) {
            $msg .= '  ' . $level . ' - %W' . $entry['name'] . '%n (' . $entry['subtext'] . ')' . PHP_EOL;
        }
        $msg .= PHP_EOL . "%rInvalid arguments!%n";
        print_message($msg, 'color', FALSE);
    }
} else {
    print_error("Auth module does not allow adding users!");
}
// EOF
コード例 #17
0
if (isset($options['a']) || isset($options['t'])) {
    $modules[] = 'timing';
}
// Get age from command line
if (isset($options['A'])) {
    $age = age_to_seconds($options['A']);
    if ($age) {
        foreach ($modules as $module) {
            if ($module == 'ports') {
                $module = 'deleted_ports';
            }
            $config['housekeeping'][$module]['age'] = $age;
        }
    } else {
        print_debug("指定了无效的老化时间 '" . $options['A'] . "', 跳过.");
    }
    unset($age, $module);
}
if (!count($modules)) {
    print_message("%n\nUSAGE:\n{$scriptname} [-Vyaserptd] [-A <age>]\n\nNOTE, by default {$scriptname} asks 'Are you sure want to delete (y/N)?'.\n      To assume 'yes' as answer to all prompts and run non-interactively,\n      add '-y' in command line.\n      Not necessary when run from cron (determined automatically).\n\nOPTIONS:\n -V                                          Show version and exit.\n -y                                          Automatically answer 'yes' to prompts\n -a                                          Maintain all modules as specified below.\n -s                                          Clean up syslog\n -e                                          Clean up event log\n -l                                          Clean up alert log\n -r                                          Clean up unused RRD files\n -p                                          Clean up deleted ports\n -t                                          Clean up timing data (discovery and poll times)\n -A <age>                                    Specifies maximum age for all modules (overrides configuration)\n\nDEBUGGING OPTIONS:\n -d                                          Enable debugging output.\n -dd                                         More verbose debugging output.\n\nEXAMPLES:\n  {$scriptname} -a                        Clean up by all modules interactively (with prompts!)\n  {$scriptname} -ya                       Clean up by all modules without prompts\n\n%r无效的参数!%n", 'color', FALSE);
    exit;
} else {
    foreach ($modules as $module) {
        if (is_file($config['install_dir'] . "/includes/housekeeping/{$module}.inc.php")) {
            include $config['install_dir'] . "/includes/housekeeping/{$module}.inc.php";
        } else {
            print_warning("管家模块没有找到: {$module}");
        }
    }
}
// EOF
コード例 #18
0
ファイル: ports.inc.php プロジェクト: skive/observium
 if ($config['debug_port'][$port['port_id']]) {
     print_debug("Wrote port debugging data");
     $debug_file = "/tmp/port_debug_" . $port['port_id'] . ".txt";
     //FIXME. I think formatted debug out (as for spikes) more informative, but output here more parsable as CSV
     $port_msg = $port['port_id'] . "|" . $polled . "|" . $polled_period . "|" . $debug_port['ifInOctets'] . "|" . $debug_port['ifOutOctets'] . "|" . $debug_port['ifHCInOctets'] . "|" . $debug_port['ifHCOutOctets'];
     $port_msg .= "|" . formatRates($port['stats']['ifInOctets_rate']) . "|" . formatRates($port['stats']['ifOutOctets_rate']) . "|" . $device['snmpver'] . "\n";
     file_put_contents($debug_file, $port_msg, FILE_APPEND);
 }
 // If we see a spike above ifSpeed or negative rate, output it to /tmp/port_debug_spikes.txt
 // Example how to read usefull info from this debug by grep:
 // grep -B 1 -A 6 'ID:\ 520' /tmp/port_debug_spikes.txt
 if ($config['debug_port']['spikes'] && $this_port['ifSpeed'] > "0" && ($port['stats']['ifInBits_rate'] > $this_port['ifSpeed'] || $port['stats']['ifOutBits_rate'] > $this_port['ifSpeed'] || isset($port['stats']['ifInOctets_negative_rate']) || isset($port['stats']['ifOutOctets_negative_rate']))) {
     if (!$port['port_64bit']) {
         $hc_prefix = '';
     }
     print_warning("Spike above ifSpeed or negative rate detected! See debug info here: ");
     $debug_file = "/tmp/port_debug_spikes.txt";
     $debug_format = "| %20s | %20s | %20s |\n";
     $debug_msg = sprintf("+%'-68s+\n", '');
     $debug_msg .= sprintf("|%67s |\n", $device['hostname'] . " " . $debug_port['ifDescr'] . " (ID: " . $port['port_id'] . ") " . formatRates($debug_port['ifSpeed']) . " " . ($port['port_64bit'] ? 'Counter64' : 'Counter32'));
     $debug_msg .= sprintf("+%'-68s+\n", '');
     $debug_msg .= sprintf("| %-20s | %-20s | %-20s |\n", 'Polled time', 'if' . $hc_prefix . 'OutOctets', 'if' . $hc_prefix . 'InOctets');
     $debug_msg .= sprintf($debug_format, '(prev) ' . $port['poll_time'], $port['ifOutOctets'], $port['ifInOctets']);
     $debug_msg .= sprintf($debug_format, '(now)  ' . $polled, $this_port['ifOutOctets'], $this_port['ifInOctets']);
     $debug_msg .= sprintf($debug_format, format_unixtime($polled), formatRates($port['stats']['ifOutBits_rate'] * 8), formatRates($port['stats']['ifInBits_rate']));
     $debug_msg .= sprintf("%'+70s\n", '');
     $debug_msg .= sprintf("| %-67s|\n", 'Port dump:');
     // Added full original port variable dump
     foreach ($debug_port as $debug_key => $debug_var) {
         $debug_msg .= sprintf("|  %-66s|\n", "'{$debug_key}' => '{$debug_var}',");
     }
コード例 #19
0
        $('#deleteBtn').attr('disabled', 'disabled');
      }
    }
    function showWarningRRD(checked) {
      if (checked) {
        $('.alert').hide();
      } else {
        $('.alert').show();
      }
    }
  </script>

  <fieldset>
    <legend>删除设备</legend>
<?php 
    print_warning("<h4>警告!</h4>\n      这将从Observium包括所有日志条目删除该设备, 但不会删除RRDS.");
    ?>

    <div class="control-group">
      <label class="control-label" for="id">设备</label>
      <div class="controls">
        <select class="selectpicker" name="id">
<?php 
    foreach (dbFetchRows("SELECT * FROM `devices` ORDER BY `disabled` DESC, `hostname`") as $data) {
        $status = '';
        if ($data['disabled']) {
            $status = ' [disabled]';
        } else {
            if (!$data['status']) {
                $status = ' [down]';
            }
コード例 #20
0
ファイル: users.php プロジェクト: zamentur/ttrss_ynh
 function index()
 {
     global $access_level_names;
     print "<div id=\"pref-user-wrap\" dojoType=\"dijit.layout.BorderContainer\" gutters=\"false\">";
     print "<div id=\"pref-user-header\" dojoType=\"dijit.layout.ContentPane\" region=\"top\">";
     print "<div id=\"pref-user-toolbar\" dojoType=\"dijit.Toolbar\">";
     $user_search = $this->dbh->escape_string($_REQUEST["search"]);
     if (array_key_exists("search", $_REQUEST)) {
         $_SESSION["prefs_user_search"] = $user_search;
     } else {
         $user_search = $_SESSION["prefs_user_search"];
     }
     print "<div style='float : right; padding-right : 4px;'>\n\t\t\t\t<input dojoType=\"dijit.form.TextBox\" id=\"user_search\" size=\"20\" type=\"search\"\n\t\t\t\t\tvalue=\"{$user_search}\">\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"updateUsersList()\">" . __('Search') . "</button>\n\t\t\t\t</div>";
     $sort = $this->dbh->escape_string($_REQUEST["sort"]);
     if (!$sort || $sort == "undefined") {
         $sort = "login";
     }
     print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Select') . "</span>";
     print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
     print "<div onclick=\"selectTableRows('prefUserList', 'all')\"\n\t\t\t\tdojoType=\"dijit.MenuItem\">" . __('All') . "</div>";
     print "<div onclick=\"selectTableRows('prefUserList', 'none')\"\n\t\t\t\tdojoType=\"dijit.MenuItem\">" . __('None') . "</div>";
     print "</div></div>";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"addUser()\">" . __('Create user') . "</button>";
     print "\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"selectedUserDetails()\">" . __('Details') . "</button dojoType=\"dijit.form.Button\">\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"editSelectedUser()\">" . __('Edit') . "</button dojoType=\"dijit.form.Button\">\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"removeSelectedUsers()\">" . __('Remove') . "</button dojoType=\"dijit.form.Button\">\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"resetSelectedUserPass()\">" . __('Reset password') . "</button dojoType=\"dijit.form.Button\">";
     PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefUsersToolbar");
     print "</div>";
     #toolbar
     print "</div>";
     #pane
     print "<div id=\"pref-user-content\" dojoType=\"dijit.layout.ContentPane\" region=\"center\">";
     print "<div id=\"sticky-status-msg\"></div>";
     if ($user_search) {
         $user_search = explode(" ", $user_search);
         $tokens = array();
         foreach ($user_search as $token) {
             $token = trim($token);
             array_push($tokens, "(UPPER(login) LIKE UPPER('%{$token}%'))");
         }
         $user_search_query = "(" . join($tokens, " AND ") . ") AND ";
     } else {
         $user_search_query = "";
     }
     $result = $this->dbh->query("SELECT\n\t\t\t\t\tid,login,access_level,email,\n\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_login,1,16) as last_login,\n\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(created,1,16) as created\n\t\t\t\tFROM\n\t\t\t\t\tttrss_users\n\t\t\t\tWHERE\n\t\t\t\t\t{$user_search_query}\n\t\t\t\t\tid > 0\n\t\t\t\tORDER BY {$sort}");
     if ($this->dbh->num_rows($result) > 0) {
         print "<p><table width=\"100%\" cellspacing=\"0\"\n\t\t\t\tclass=\"prefUserList\" id=\"prefUserList\">";
         print "<tr class=\"title\">\n\t\t\t\t\t\t<td align='center' width=\"5%\">&nbsp;</td>\n\t\t\t\t\t\t<td width='30%'><a href=\"#\" onclick=\"updateUsersList('login')\">" . __('Login') . "</a></td>\n\t\t\t\t\t\t<td width='30%'><a href=\"#\" onclick=\"updateUsersList('access_level')\">" . __('Access Level') . "</a></td>\n\t\t\t\t\t\t<td width='20%'><a href=\"#\" onclick=\"updateUsersList('created')\">" . __('Registered') . "</a></td>\n\t\t\t\t\t\t<td width='20%'><a href=\"#\" onclick=\"updateUsersList('last_login')\">" . __('Last login') . "</a></td></tr>";
         $lnum = 0;
         while ($line = $this->dbh->fetch_assoc($result)) {
             $uid = $line["id"];
             print "<tr id=\"UMRR-{$uid}\">";
             $line["login"] = htmlspecialchars($line["login"]);
             $line["created"] = make_local_datetime($line["created"], false);
             $line["last_login"] = make_local_datetime($line["last_login"], false);
             print "<td align='center'><input onclick='toggleSelectRow2(this);'\n\t\t\t\t\tdojoType=\"dijit.form.CheckBox\" type=\"checkbox\"\n\t\t\t\t\tid=\"UMCHK-{$uid}\"></td>";
             $onclick = "onclick='editUser({$uid}, event)' title='" . __('Click to edit') . "'";
             print "<td {$onclick}><img src='images/user.png' class='markedPic' alt=''> " . $line["login"] . "</td>";
             if (!$line["email"]) {
                 $line["email"] = "&nbsp;";
             }
             print "<td {$onclick}>" . $access_level_names[$line["access_level"]] . "</td>";
             print "<td {$onclick}>" . $line["created"] . "</td>";
             print "<td {$onclick}>" . $line["last_login"] . "</td>";
             print "</tr>";
             ++$lnum;
         }
         print "</table>";
     } else {
         print "<p>";
         if (!$user_search) {
             print_warning(__('No users defined.'));
         } else {
             print_warning(__('No matching users found.'));
         }
         print "</p>";
     }
     print "</div>";
     #pane
     PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefUsers");
     print "</div>";
     #container
 }
コード例 #21
0
    ?>

    </div>
  </div>
</div>
</form>

<?php 
    if ($vars['user_id']) {
        if ($vars['action'] == "deleteuser") {
            include "pages/edituser/deleteuser.inc.php";
        } else {
            // Perform actions if requested
            if (auth_can_change_password($user_data['username']) && $vars['action'] == "changepass") {
                if ($vars['new_pass'] == "" || $vars['new_pass2'] == "") {
                    print_warning("密码不能留空.");
                } elseif ($vars['new_pass'] == $vars['new_pass2']) {
                    auth_change_password($user_data['username'], $vars['new_pass']);
                    print_message("密码已更改.");
                } else {
                    print_error("密码不匹配!");
                }
            }
            // FIXME broken PoS code.
            if ($vars['action'] == "becomeuser") {
                $_SESSION['origusername'] = $_SESSION['username'];
                $_SESSION['username'] = $user_data['username'];
                header('位置: ' . $config['base_url']);
                dbInsert(array('user' => $_SESSION['origusername'], 'address' => $_SERVER["REMOTE_ADDR"], 'result' => '成为 ' . $_SESSION['username']), 'authlog');
                include "includes/authenticate.inc.php";
            }
コード例 #22
0
function get_status_array($status)
{
    // Mike: I know that there are duplicated variables, but later will remove global
    global $config, $cache;
    $max_interval = filter_var($status['max']['interval'], FILTER_VALIDATE_INT, array('options' => array('default' => 24, 'min_range' => 1)));
    $max_count = filter_var($status['max']['count'], FILTER_VALIDATE_INT, array('options' => array('default' => 200, 'min_range' => 1)));
    $query_device_permitted = generate_query_permitted(array('device'), array('device_table' => 'D'));
    $query_port_permitted = generate_query_permitted(array('port'), array('port_table' => 'I'));
    // Show Device Status
    if ($status['devices']) {
        $query = 'SELECT * FROM `devices` AS D ';
        $query .= 'WHERE D.`status` = 0' . $query_device_permitted;
        $query .= 'ORDER BY D.`hostname` ASC';
        $entries = dbFetchRows($query);
        foreach ($entries as $device) {
            $boxes[] = array('sev' => 100, 'class' => 'Device', 'event' => 'Down', 'device_link' => generate_device_link($device, short_hostname($device['hostname'])), 'time' => deviceUptime($device, 'short-3'));
        }
    }
    // Uptime
    if ($status['uptime']) {
        if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) {
            $query = 'SELECT * FROM `devices` AS D ';
            $query .= 'WHERE D.`status` = 1 AND D.`uptime` > 0 AND D.`uptime` < ' . $config['uptime_warning'];
            $query .= $query_device_permitted;
            $query .= 'ORDER BY D.`hostname` ASC';
            $entries = dbFetchRows($query);
            foreach ($entries as $device) {
                $boxes[] = array('sev' => 10, 'class' => 'Device', 'event' => 'Rebooted', 'device_link' => generate_device_link($device, short_hostname($device['hostname'])), 'time' => deviceUptime($device, 'short-3'), 'location' => $device['location']);
            }
        }
    }
    // Ports Down
    if ($status['ports'] || $status['links']) {
        // warning about deprecated option: $config['warn']['ifdown']
        if (isset($config['warn']['ifdown']) && !$config['warn']['ifdown']) {
            print_warning("<strong>Config option obsolete</strong>\n                    Please note that config option <strong>\$config['warn']['ifdown']</strong> is now obsolete.\n                    Use options: <strong>\$config['frontpage']['device_status']['ports']</strong> and <strong>\$config['frontpage']['device_status']['errors']</strong>\n                    To remove this message, delete <strong>\$config['warn']['ifdown']</strong> from configuration file.");
        }
        $query = 'SELECT * FROM `ports` AS I ';
        if ($status['links'] && !$status['ports']) {
            $query .= 'INNER JOIN `links` as L ON I.`port_id` = L.`local_port_id` ';
        }
        $query .= 'LEFT JOIN `devices` AS D ON I.`device_id` = D.`device_id` ';
        $query .= "WHERE I.`ifOperStatus` = 'down' AND I.`ifAdminStatus` = 'up' ";
        if ($status['links'] && !$status['ports']) {
            $query .= ' AND L.`active` = 1 ';
        }
        $query .= $query_port_permitted;
        $query .= ' AND I.`ifLastChange` >= DATE_SUB(NOW(), INTERVAL ' . $max_interval . ' HOUR) ';
        $query .= 'ORDER BY I.`ifLastChange` DESC, D.`hostname` ASC, I.`ifDescr` * 1 ASC ';
        $entries = dbFetchRows($query);
        $i = 1;
        foreach ($entries as $port) {
            if ($i > $max_count) {
                // Limit to 200 ports on overview page
                break;
            }
            humanize_port($port);
            $boxes[] = array('sev' => 50, 'class' => 'Port', 'event' => 'Down', 'device_link' => generate_device_link($port, short_hostname($port['hostname'])), 'entity_link' => generate_port_link($port, short_ifname($port['label'], 13)), 'time' => formatUptime($config['time']['now'] - strtotime($port['ifLastChange'])), 'location' => $device['location']);
        }
    }
    // Ports Errors (only deltas)
    if ($status['errors']) {
        foreach ($cache['ports']['errored'] as $port_id) {
            $port = get_port_by_id($port_id);
            $device = device_by_id_cache($port['device_id']);
            humanize_port($port);
            if ($port['ifInErrors_delta']) {
                $port['string'] .= 'Rx: ' . format_number($port['ifInErrors_delta']);
            }
            if ($port['ifInErrors_delta'] && $port['ifOutErrors_delta']) {
                $port['string'] .= ', ';
            }
            if ($port['ifOutErrors_delta']) {
                $port['string'] .= 'Tx: ' . format_number($port['ifOutErrors_delta']);
            }
            $boxes[] = array('sev' => 75, 'class' => 'Port', 'event' => 'Errors', 'device_link' => generate_device_link($device, short_hostname($device['hostname'])), 'entity_link' => generate_port_link($port, short_ifname($port['label'], 13)), 'time' => $port['string'], 'location' => $device['location']);
        }
    }
    // Services
    if ($status['services']) {
        $query = 'SELECT * FROM `services` AS S ';
        $query .= 'LEFT JOIN `devices` AS D ON S.device_id = D.device_id ';
        $query .= "WHERE S.`service_status` = 'down' AND S.`service_ignore` = 0";
        $query .= $query_device_permitted;
        $query .= 'ORDER BY D.`hostname` ASC';
        $entries = dbFetchRows($query);
        foreach ($entries as $service) {
            $boxes[] = array('sev' => 50, 'class' => 'Service', 'event' => 'Down', 'device_link' => generate_device_link($service, short_hostname($service['hostname'])), 'entity_link' => $service['service_type'], 'time' => formatUptime($config['time']['now'] - strtotime($service['service_changed']), 'short'), 'location' => $device['location']);
        }
    }
    // BGP
    if ($status['bgp']) {
        if (isset($config['enable_bgp']) && $config['enable_bgp']) {
            $query = 'SELECT * FROM `devices` AS D ';
            $query .= 'LEFT JOIN `bgpPeers` AS B ON B.`device_id` = D.`device_id` ';
            $query .= 'LEFT JOIN `bgpPeers-state` AS BS ON B.`bgpPeer_id` = BS.`bgpPeer_id` ';
            $query .= "WHERE (`bgpPeerAdminStatus` = 'start' OR `bgpPeerAdminStatus` = 'running') AND `bgpPeerState` != 'established' ";
            $query .= $query_device_permitted;
            $query .= 'ORDER BY D.`hostname` ASC';
            $entries = dbFetchRows($query);
            foreach ($entries as $peer) {
                $peer_ip = strstr($peer['bgpPeerRemoteAddr'], ':') ? Net_IPv6::compress($peer['bgpPeerRemoteAddr']) : $peer['bgpPeerRemoteAddr'];
                $peer['wide'] = strstr($peer['bgpPeerRemoteAddr'], ':') ? TRUE : FALSE;
                $boxes[] = array('sev' => 75, 'class' => 'BGP Peer', 'event' => 'Down', 'device_link' => generate_device_link($peer, short_hostname($peer['hostname'])), 'entity_link' => $peer_ip, 'wide' => $peer['wide'], 'time' => formatUptime($peer['bgpPeerFsmEstablishedTime'], 'short-3'), 'location' => $device['location']);
            }
        }
    }
    // Return boxes array
    return $boxes;
}
コード例 #23
0
ファイル: update.php プロジェクト: RulerOf/Tiny-Tiny-IRC
    }
}
ksort($update_versions, SORT_NUMERIC);
$latest_version = max(array_keys($update_versions));
if ($version == $latest_version) {
    if ($version != SCHEMA_VERSION) {
        print_error(__("Could not update database"));
        print "<p>" . __("Could not find necessary schema file, need version:") . " " . SCHEMA_VERSION . __(", found: ") . $latest_version . "</p>";
    } else {
        print "<p>" . __("Tiny Tiny IRC database is up to date.") . "</p>";
        print "<form method=\"GET\" action=\"index.php\">\n\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny IRC") . "\">\n\t\t\t\t</form>";
    }
    return;
}
if (!$op) {
    print_warning(__("Please backup your database before proceeding."));
    print "<p>" . T_sprintf("Your Tiny Tiny RSS database needs update to the latest version (<b>%d</b> to <b>%d</b>).", $version, $latest_version) . "</p>";
    /*		print "<p>Available incremental updates:";
    	
    		foreach (array_keys($update_versions) as $v) {
    			if ($v > $version) {
    				print " <a href='$update_versions[$v]'>$v</a>";
    			}
    		} */
    print "</p>";
    print "<form method='POST'>\n\t\t\t<input type='hidden' name='op' value='do'>\n\t\t\t<input type='submit' onclick='return confirmOP()' value='" . __("Perform updates") . "'>\n\t\t\t</form>";
} else {
    if ($op == "do") {
        print "<p>" . __("Performing updates...") . "</p>";
        $num_updates = 0;
        foreach (array_keys($update_versions) as $v) {
コード例 #24
0
unset($navbar);
// Change password
if ($vars['password'] == "save") {
    if (authenticate($_SESSION['username'], $vars['old_pass'])) {
        if ($vars['new_pass'] == "" || $vars['new_pass2'] == "") {
            print_warning("Password must not be blank.");
        } else {
            if ($vars['new_pass'] == $vars['new_pass2']) {
                auth_change_password($_SESSION['username'], $vars['new_pass']);
                print_success("Password Changed.");
            } else {
                print_warning("Passwords don't match.");
            }
        }
    } else {
        print_warning("Incorrect password");
    }
}
unset($prefs);
if (is_numeric($_SESSION['user_id'])) {
    $user_id = $_SESSION['user_id'];
    $prefs = get_user_prefs($user_id);
    // Reset RSS/Atom key
    if ($vars['atom_key'] == "toggle") {
        if (set_user_pref($user_id, 'atom_key', md5(strgen()))) {
            print_success('RSS/Atom key updated.');
            $prefs = get_user_prefs($user_id);
        } else {
            print_error('Error generating RSS/Atom key.');
        }
    }
コード例 #25
0
ファイル: poller.php プロジェクト: Natolumin/observium
foreach (dbFetch($query, $params) as $device) {
    $device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
    poll_device($device, $options);
    $polled_devices++;
}
$poller_end = utime();
$poller_run = $poller_end - $poller_start;
$poller_time = substr($poller_run, 0, 5);
if ($polled_devices) {
    dbInsert(array('type' => 'poll', 'doing' => $doing, 'start' => $poller_start, 'duration' => $poller_time, 'devices' => $polled_devices), 'perf_times');
    if (is_numeric($doing)) {
        $doing = $device['hostname'];
    }
    // Single device ID convert to hostname for log
} else {
    print_warning("WARNING: 0 devices polled. Did you specify a device that does not exist?");
}
$string = $argv[0] . ": {$doing} - {$polled_devices} devices polled in {$poller_time} secs";
print_debug($string);
print_cli_heading("%WCompleted polling run at " . date("Y-m-d H:i:s"), 0);
if (!isset($options['q'])) {
    if ($config['snmp']['hide_auth']) {
        print_debug("NOTE, \$config['snmp']['hide_auth'] is set to TRUE, snmp community and snmp v3 auth hidden from debug output.");
    }
    print_cli_data('Devices Polled', $polled_devices, 0);
    print_cli_data('Poller Time', $poller_time . " secs", 0);
    print_cli_data('Memory usage', formatStorage(memory_get_usage(TRUE), 2, 4) . ' (peak: ' . formatStorage(memory_get_peak_usage(TRUE), 2, 4) . ')', 0);
    $mysql_time = 0;
    foreach ($db_stats as $cmd => $count) {
        if (isset($db_stats[$cmd . '_sec'])) {
            $mysql_times[] = ucfirst(str_replace("fetch", "", $cmd)) . "[" . $count . "/" . round($db_stats[$cmd . '_sec'], 3) . "s]";
コード例 #26
0
ファイル: delete_device.php プロジェクト: skive/observium
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage cli
 * @author     Adam Armstrong <*****@*****.**>
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
chdir(dirname($argv[0]));
include "includes/defaults.inc.php";
include "config.php";
include "includes/definitions.inc.php";
include "includes/functions.inc.php";
$scriptname = basename($argv[0]);
print_message("%g" . OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION . "\n%WRemove Device%n\n", 'color');
// Remove a host and all related data from the system
if ($argv[1]) {
    $host = strtolower($argv[1]);
    $id = getidbyname($host);
    $delete_rrd = isset($argv[2]) && strtolower($argv[2]) == 'rrd' ? TRUE : FALSE;
    // Test if a valid id was fetched from getidbyname.
    if (isset($id) && is_numeric($id)) {
        print_warning(delete_device($id, $delete_rrd));
        print_success("Device {$host} removed.");
    } else {
        print_error("Device {$host} doesn't exist!");
    }
} else {
    print_message("%n\nUSAGE:\n{$scriptname} <hostname> [rrd]\n\nEXAMPLE:\n%WKeep RRDs%n:   {$scriptname} <hostname>\n%WRemove RRDs%n: {$scriptname} <hostname> rrd\n\n%rInvalid arguments!%n", 'color', FALSE);
}
// EOF
コード例 #27
0
ファイル: pref_feeds.php プロジェクト: 4iji/Tiny-Tiny-RSS
 function editCats()
 {
     $action = $_REQUEST["action"];
     if ($action == "save") {
         $cat_title = db_escape_string(trim($_REQUEST["value"]));
         $cat_id = db_escape_string($_REQUEST["cid"]);
         db_query($this->link, "BEGIN");
         $result = db_query($this->link, "SELECT title FROM ttrss_feed_categories\n\t\t\t\tWHERE id = '{$cat_id}' AND owner_uid = " . $_SESSION["uid"]);
         if (db_num_rows($result) == 1) {
             $old_title = db_fetch_result($result, 0, "title");
             if ($cat_title != "") {
                 $result = db_query($this->link, "UPDATE ttrss_feed_categories SET\n\t\t\t\t\t\ttitle = '{$cat_title}' WHERE id = '{$cat_id}' AND\n\t\t\t\t\t\towner_uid = " . $_SESSION["uid"]);
                 print $cat_title;
             } else {
                 print $old_title;
             }
         } else {
             print $_REQUEST["value"];
         }
         db_query($this->link, "COMMIT");
         return;
     }
     if ($action == "add") {
         $feed_cat = db_escape_string(trim($_REQUEST["cat"]));
         if (!add_feed_category($this->link, $feed_cat)) {
             print_warning(T_sprintf("Category <b>\$%s</b> already exists in the database.", $feed_cat));
         }
     }
     if ($action == "remove") {
         $ids = split(",", db_escape_string($_REQUEST["ids"]));
         foreach ($ids as $id) {
             remove_feed_category($this->link, $id, $_SESSION["uid"]);
         }
     }
     print "<div dojoType=\"dijit.Toolbar\">";
     print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Select') . "</span>";
     print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
     print "<div onclick=\"selectTableRows('prefFeedCatList', 'all')\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('All') . "</div>";
     print "<div onclick=\"selectTableRows('prefFeedCatList', 'none')\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('None') . "</div>";
     print "</div></div>";
     print "<div style='float : right'>";
     print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"newcat\">\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').addCategory()\">" . __('Create category') . "</button></div>";
     print "</div>";
     $result = db_query($this->link, "SELECT c.title, c.id,COUNT(f.id) AS count\n\t\t\tFROM ttrss_feed_categories AS c LEFT JOIN ttrss_feeds AS f ON\n\t\t\t\t(f.cat_id = c.id)\n\t\t\tWHERE c.owner_uid = " . $_SESSION["uid"] . "\n\t\t\tGROUP BY c.title, c.id ORDER BY title");
     if (db_num_rows($result) != 0) {
         print "<div class=\"prefFeedCatHolder\">";
         print "<table width=\"100%\" class=\"prefFeedCatList\"\n\t\t\t\tcellspacing=\"0\" id=\"prefFeedCatList\">";
         $lnum = 0;
         while ($line = db_fetch_assoc($result)) {
             $class = $lnum % 2 ? "even" : "odd";
             $cat_id = $line["id"];
             $this_row_id = "id=\"FCATR-{$cat_id}\"";
             print "<tr class=\"placeholder\" {$this_row_id}>";
             $edit_title = htmlspecialchars($line["title"]);
             print "<td width='5%' align='center'><input id=\"FCATC-{$cat_id}\"\n\t\t\t\t\tonclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"\n\t\t\t\t\ttype=\"checkbox\"></td>";
             print "<td>";
             if ($line['count'] == 0) {
                 print '<em>';
             }
             print "<span dojoType=\"dijit.InlineEditBox\"\n\t\t\t\t\twidth=\"300px\" autoSave=\"false\"\n\t\t\t\t\tcat-id=\"{$cat_id}\">" . $edit_title . "<script type=\"dojo/method\" event=\"onChange\" args=\"item\">\n\t\t\t\t\t\tvar elem = this;\n\t\t\t\t\t\tdojo.xhrPost({\n\t\t\t\t\t\t\turl: 'backend.php',\n\t\t\t\t\t\t\tcontent: {op: 'pref-feeds', method: 'editCats',\n\t\t\t\t\t\t\t\taction: 'save',\n\t\t\t\t\t\t\t\tvalue: this.value,\n\t\t\t\t\t\t\t\tcid: this.srcNodeRef.getAttribute('cat-id')},\n\t\t\t\t\t\t\t\tload: function(response) {\n\t\t\t\t\t\t\t\t\telem.attr('value', response);\n\t\t\t\t\t\t\t\t\tupdateFeedList();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t</script>\n\t\t\t\t</span>";
             if ($line['count'] == 0) {
                 print '</em>';
             }
             print "</td>";
             print "<td align='right' class='insensitive'>";
             echo T_sprintf("%d feeds", $line['count']);
             print "</td></tr>";
             ++$lnum;
         }
         print "</table>";
         print "</div>";
     } else {
         print "<p>" . __('No feed categories defined.') . "</p>";
     }
     print "<div class='dlgButtons'>\n\t\t\t<div style='float : left'>\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').removeSelected()\">" . __('Remove selected categories') . "</button>\n\t\t\t</div>";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').hide()\">" . __('Close this window') . "</button></div>";
     return;
 }
コード例 #28
0
ファイル: housekeeping.php プロジェクト: skive/observium
if (isset($options['a']) || isset($options['t'])) {
    $modules[] = 'timing';
}
// Get age from command line
if (isset($options['A'])) {
    $age = age_to_seconds($options['A']);
    if ($age) {
        foreach ($modules as $module) {
            if ($module == 'ports') {
                $module = 'deleted_ports';
            }
            $config['housekeeping'][$module]['age'] = $age;
        }
    } else {
        print_debug("Invalid age specified '" . $options['A'] . "', skipped.");
    }
    unset($age, $module);
}
if (!count($modules)) {
    print_message("%n\nUSAGE:\n{$scriptname} [-Vyaserptd] [-A <age>]\n\nNOTE, by default {$scriptname} asks 'Are you sure want to delete (y/N)?'.\n      To assume 'yes' as answer to all prompts and run non-interactively,\n      add '-y' in command line.\n      Not necessary when run from cron (determined automatically).\n\nOPTIONS:\n -V                                          Show version and exit.\n -y                                          Automatically answer 'yes' to prompts\n -a                                          Maintain all modules as specified below.\n -s                                          Clean up syslog\n -e                                          Clean up event log\n -l                                          Clean up alert log\n -r                                          Clean up unused RRD files\n -p                                          Clean up deleted ports\n -t                                          Clean up timing data (discovery and poll times)\n -A <age>                                    Specifies maximum age for all modules (overrides configuration)\n\nDEBUGGING OPTIONS:\n -d                                          Enable debugging output.\n\nEXAMPLES:\n  {$scriptname} -a                        Clean up by all modules interactively (with prompts!)\n  {$scriptname} -ya                       Clean up by all modules without prompts\n\n%rInvalid arguments!%n", 'color', FALSE);
    exit;
} else {
    foreach ($modules as $module) {
        if (is_file($config['install_dir'] . "/includes/housekeeping/{$module}.inc.php")) {
            include $config['install_dir'] . "/includes/housekeeping/{$module}.inc.php";
        } else {
            print_warning("Housekeeping module not found: {$module}");
        }
    }
}
// EOF
コード例 #29
0
ファイル: feeds.php プロジェクト: AHinMaine/ttrss
 function index()
 {
     print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
     print "<div id=\"pref-feeds-feeds\" dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Feeds') . "\">";
     $result = $this->dbh->query("SELECT COUNT(id) AS num_errors\n\t\t\tFROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION["uid"]);
     $num_errors = $this->dbh->fetch_result($result, 0, "num_errors");
     if ($num_errors > 0) {
         $error_button = "<button dojoType=\"dijit.form.Button\"\n\t\t\t  \t\tonclick=\"showFeedsWithErrors()\" id=\"errorButton\">" . __("Feeds with errors") . "</button>";
     }
     $inactive_button = "<button dojoType=\"dijit.form.Button\"\n\t\t\t\tid=\"pref_feeds_inactive_btn\"\n\t\t\t\tstyle=\"display : none\"\n\t\t\t\tonclick=\"showInactiveFeeds()\">" . __("Inactive feeds") . "</button>";
     $feed_search = $this->dbh->escape_string($_REQUEST["search"]);
     if (array_key_exists("search", $_REQUEST)) {
         $_SESSION["prefs_feed_search"] = $feed_search;
     } else {
         $feed_search = $_SESSION["prefs_feed_search"];
     }
     print '<div dojoType="dijit.layout.BorderContainer" gutters="false">';
     print "<div region='top' dojoType=\"dijit.Toolbar\">";
     #toolbar
     print "<div style='float : right; padding-right : 4px;'>\n\t\t\t<input dojoType=\"dijit.form.TextBox\" id=\"feed_search\" size=\"20\" type=\"search\"\n\t\t\t\tvalue=\"{$feed_search}\">\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"updateFeedList()\">" . __('Search') . "</button>\n\t\t\t</div>";
     print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Select') . "</span>";
     print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
     print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(true)\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('All') . "</div>";
     print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(false)\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('None') . "</div>";
     print "</div></div>";
     print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Feeds') . "</span>";
     print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
     print "<div onclick=\"quickAddFeed()\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('Subscribe to feed') . "</div>";
     print "<div onclick=\"editSelectedFeed()\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('Edit selected feeds') . "</div>";
     print "<div onclick=\"resetFeedOrder()\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('Reset sort order') . "</div>";
     print "<div onclick=\"batchSubscribe()\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('Batch subscribe') . "</div>";
     print "<div dojoType=\"dijit.MenuItem\" onclick=\"removeSelectedFeeds()\">" . __('Unsubscribe') . "</div> ";
     print "</div></div>";
     if (get_pref('ENABLE_FEED_CATS')) {
         print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Categories') . "</span>";
         print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
         print "<div onclick=\"createCategory()\"\n\t\t\t\tdojoType=\"dijit.MenuItem\">" . __('Add category') . "</div>";
         print "<div onclick=\"resetCatOrder()\"\n\t\t\t\tdojoType=\"dijit.MenuItem\">" . __('Reset sort order') . "</div>";
         print "<div onclick=\"removeSelectedCategories()\"\n\t\t\t\tdojoType=\"dijit.MenuItem\">" . __('Remove selected') . "</div>";
         print "</div></div>";
     }
     print $error_button;
     print $inactive_button;
     if (defined('_ENABLE_FEED_DEBUGGING')) {
         print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\">\n\t\t\t\t<option value=\"facDefault\" selected>" . __('More actions...') . "</option>";
         if (FORCE_ARTICLE_PURGE == 0) {
             print "<option value=\"facPurge\">" . __('Manual purge') . "</option>";
         }
         print "\n\t\t\t\t<option value=\"facClear\">" . __('Clear feed data') . "</option>\n\t\t\t\t<option value=\"facRescore\">" . __('Rescore articles') . "</option>";
         print "</select>";
     }
     print "</div>";
     # toolbar
     //print '</div>';
     print '<div dojoType="dijit.layout.ContentPane" region="center">';
     print "<div id=\"feedlistLoading\">\n\t\t<img src='images/indicator_tiny.gif'>" . __("Loading, please wait...") . "</div>";
     print "<div dojoType=\"fox.PrefFeedStore\" jsId=\"feedStore\"\n\t\t\turl=\"backend.php?op=pref-feeds&method=getfeedtree\">\n\t\t</div>\n\t\t<div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"feedModel\" store=\"feedStore\"\n\t\tquery=\"{id:'root'}\" rootId=\"root\" rootLabel=\"Feeds\"\n\t\t\tchildrenAttrs=\"items\" checkboxStrict=\"false\" checkboxAll=\"false\">\n\t\t</div>\n\t\t<div dojoType=\"fox.PrefFeedTree\" id=\"feedTree\"\n\t\t\tdndController=\"dijit.tree.dndSource\"\n\t\t\tbetweenThreshold=\"5\"\n\t\t\tmodel=\"feedModel\" openOnClick=\"false\">\n\t\t<script type=\"dojo/method\" event=\"onClick\" args=\"item\">\n\t\t\tvar id = String(item.id);\n\t\t\tvar bare_id = id.substr(id.indexOf(':')+1);\n\n\t\t\tif (id.match('FEED:')) {\n\t\t\t\teditFeed(bare_id);\n\t\t\t} else if (id.match('CAT:')) {\n\t\t\t\teditCat(bare_id, item);\n\t\t\t}\n\t\t</script>\n\t\t<script type=\"dojo/method\" event=\"onLoad\" args=\"item\">\n\t\t\tElement.hide(\"feedlistLoading\");\n\n\t\t\tcheckInactiveFeeds();\n\t\t</script>\n\t\t</div>";
     #		print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
     #			".__('<b>Hint:</b> you can drag feeds and categories around.')."
     #			</div>";
     print '</div>';
     print '</div>';
     print "</div>";
     # feeds pane
     print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('OPML') . "\">";
     print "<p>" . __("Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings.") . __("Only main settings profile can be migrated using OPML.") . "</p>";
     print "<iframe id=\"upload_iframe\"\n\t\t\tname=\"upload_iframe\" onload=\"opmlImportComplete(this)\"\n\t\t\tstyle=\"width: 400px; height: 100px; display: none;\"></iframe>";
     print "<form  name=\"opml_form\" style='display : block' target=\"upload_iframe\"\n\t\t\tenctype=\"multipart/form-data\" method=\"POST\"\n\t\t\taction=\"backend.php\">\n\t\t\t<input id=\"opml_file\" name=\"opml_file\" type=\"file\">&nbsp;\n\t\t\t<input type=\"hidden\" name=\"op\" value=\"dlg\">\n\t\t\t<input type=\"hidden\" name=\"method\" value=\"importOpml\">\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"return opmlImport();\" type=\"submit\">" . __('Import my OPML') . "</button>";
     print "<hr>";
     $opml_export_filename = "TinyTinyRSS_" . date("Y-m-d") . ".opml";
     print "<p>" . __('Filename:') . " <input type=\"text\" id=\"filename\" value=\"{$opml_export_filename}\" />&nbsp;" . __('Include settings') . "<input type=\"checkbox\" id=\"settings\" checked=\"1\"/>";
     print "</p><button dojoType=\"dijit.form.Button\"\n\t\t\tonclick=\"gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked)\" >" . __('Export OPML') . "</button></p></form>";
     print "<hr>";
     print "<p>" . __('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.') . "</p>";
     print_warning("Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.");
     print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('" . __("Public OPML URL") . "','pubOPMLUrl')\">" . __('Display published OPML URL') . "</button> ";
     PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefFeedsOPML");
     print "</div>";
     # pane
     if (strpos($_SERVER['HTTP_USER_AGENT'], "Firefox") !== false) {
         print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Firefox integration') . "\">";
         print_notice(__('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.'));
         print "<p>";
         print "<button onclick='window.navigator.registerContentHandler(" . "\"application/vnd.mozilla.maybe.feed\", " . "\"" . add_feed_url() . "\", " . " \"Tiny Tiny RSS\")'>" . __('Click here to register this site as a feed reader.') . "</button>";
         print "</p>";
         print "</div>";
         # pane
     }
     print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Published & shared articles / Generated feeds') . "\">";
     print "<p>" . __('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.') . "</p>";
     $rss_url = '-2::' . htmlspecialchars(get_self_url_prefix() . "/public.php?op=rss&id=-2&view-mode=all_articles");
     print "<p>";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('" . __("View as RSS") . "','generatedFeed', '{$rss_url}')\">" . __('Display URL') . "</button> ";
     print "<button class=\"warning\" dojoType=\"dijit.form.Button\" onclick=\"return clearFeedAccessKeys()\">" . __('Clear all generated URLs') . "</button> ";
     print "</p>";
     PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefFeedsPublishedGenerated");
     print "</div>";
     #pane
     PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefFeeds");
     print "</div>";
     #container
 }
コード例 #30
0
/**
 * Display syslog messages.
 *
 * Display pages with device syslog messages.
 * Examples:
 * print_syslogs() - display last 10 syslog messages from all devices
 * print_syslogs(array('pagesize' => 99)) - display last 99 syslog messages from all device
 * print_syslogs(array('pagesize' => 10, 'pageno' => 3, 'pagination' => TRUE)) - display 10 syslog messages from page 3 with pagination header
 * print_syslogs(array('pagesize' => 10, 'device' = 4)) - display last 10 syslog messages for device_id 4
 * print_syslogs(array('short' => TRUE)) - show small block with last syslog messages
 *
 * @param array $vars
 * @return none
 *
 */
function print_syslogs($vars)
{
    // Short events? (no pagination, small out)
    $short = isset($vars['short']) && $vars['short'];
    // With pagination? (display page numbers in header)
    $pagination = isset($vars['pagination']) && $vars['pagination'];
    $pageno = isset($vars['pageno']) && !empty($vars['pageno']) ? $vars['pageno'] : 1;
    $pagesize = isset($vars['pagesize']) && !empty($vars['pagesize']) ? $vars['pagesize'] : 10;
    $start = $pagesize * $pageno - $pagesize;
    $priorities = $GLOBALS['config']['syslog']['priorities'];
    $param = array();
    $where = ' WHERE 1 ';
    foreach ($vars as $var => $value) {
        if ($value != '') {
            $cond = array();
            switch ($var) {
                case 'device':
                case 'device_id':
                    $where .= ' AND `device_id` = ?';
                    $param[] = $value;
                    break;
                case 'priority':
                    if (!is_array($value)) {
                        $value = array($value);
                    }
                    foreach ($value as $k => $v) {
                        // Rewrite priority strings to numbers
                        $value[$k] = priority_string_to_numeric($v);
                    }
                    // Do not break here, it's true!
                // Do not break here, it's true!
                case 'program':
                    if (!is_array($value)) {
                        $value = array($value);
                    }
                    foreach ($value as $v) {
                        $cond[] = '?';
                        $param[] = $v === '[[EMPTY]]' ? '' : $v;
                    }
                    $where .= " AND `{$var}` IN (";
                    $where .= implode(', ', $cond);
                    $where .= ')';
                    break;
                case 'message':
                    foreach (explode(',', $value) as $val) {
                        $param[] = '%' . $val . '%';
                        $cond[] = '`msg` LIKE ?';
                    }
                    $where .= 'AND (';
                    $where .= implode(' OR ', $cond);
                    $where .= ')';
                    break;
                case 'timestamp_from':
                    $where .= ' AND `timestamp` > ?';
                    $param[] = $value;
                    break;
                case 'timestamp_to':
                    $where .= ' AND `timestamp` < ?';
                    $param[] = $value;
                    break;
            }
        }
    }
    // Show events only for permitted devices
    $query_permitted = generate_query_permitted();
    $query = 'FROM `syslog` ';
    $query .= $where . $query_permitted;
    $query_count = 'SELECT COUNT(`seq`) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= ' ORDER BY `seq` DESC ';
    $query .= "LIMIT {$start},{$pagesize}";
    // Query syslog messages
    $entries = dbFetchRows($query, $param);
    // Query syslog count
    if ($pagination && !$short) {
        $count = dbFetchCell($query_count, $param);
    } else {
        $count = count($entries);
    }
    if (!$count) {
        // There have been no entries returned. Print the warning.
        print_warning('<h4>No syslog entries found!</h4>
Check that the syslog daemon and Observium configuration options are set correctly, that your devices are configured to send syslog to Observium and that there are no firewalls blocking the messages.

See <a href="http://www.observium.org/wiki/Category:Documentation" target="_blank">documentation</a> and <a href="http://www.observium.org/wiki/Configuration_Options#Syslog_Settings" target="_blank">configuration options</a> for more information.');
    } else {
        // Entries have been returned. Print the table.
        $list = array('device' => FALSE, 'priority' => TRUE);
        // For now (temporarily) priority always displayed
        if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'syslog') {
            $list['device'] = TRUE;
        }
        if ($short || !isset($vars['priority']) || empty($vars['priority'])) {
            $list['priority'] = TRUE;
        }
        $string = '<table class="table table-bordered table-striped table-hover table-condensed-more">' . PHP_EOL;
        if (!$short) {
            $string .= '  <thead>' . PHP_EOL;
            $string .= '    <tr>' . PHP_EOL;
            $string .= '      <th>Date</th>' . PHP_EOL;
            if ($list['device']) {
                $string .= '      <th>Device</th>' . PHP_EOL;
            }
            if ($list['priority']) {
                $string .= '      <th>Priority</th>' . PHP_EOL;
            }
            $string .= '      <th>Message</th>' . PHP_EOL;
            $string .= '    </tr>' . PHP_EOL;
            $string .= '  </thead>' . PHP_EOL;
        }
        $string .= '  <tbody>' . PHP_EOL;
        foreach ($entries as $entry) {
            $string .= '  <tr>';
            if ($short) {
                $string .= '    <td class="syslog" style="white-space: nowrap">';
                $timediff = $GLOBALS['config']['time']['now'] - strtotime($entry['timestamp']);
                $string .= overlib_link('', formatUptime($timediff, "short-3"), format_timestamp($entry['timestamp']), NULL) . '</td>' . PHP_EOL;
            } else {
                $string .= '    <td width="160">';
                $string .= format_timestamp($entry['timestamp']) . '</td>' . PHP_EOL;
            }
            if ($list['device']) {
                $dev = device_by_id_cache($entry['device_id']);
                $device_vars = array('page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'syslog');
                $string .= '    <td class="entity">' . generate_device_link($dev, short_hostname($dev['hostname']), $device_vars) . '</td>' . PHP_EOL;
            }
            if ($list['priority']) {
                if (!$short) {
                    $string .= '    <td style="color: ' . $priorities[$entry['priority']]['color'] . '; white-space: nowrap;">' . nicecase($priorities[$entry['priority']]['name']) . ' (' . $entry['priority'] . ')</td>' . PHP_EOL;
                }
            }
            $entry['program'] = empty($entry['program']) ? '[[EMPTY]]' : $entry['program'];
            if ($short) {
                $string .= '    <td class="syslog">';
                $string .= '<strong style="color: ' . $priorities[$entry['priority']]['color'] . ';">' . $entry['program'] . '</strong> : ';
            } else {
                $string .= '    <td>';
                $string .= '<strong>' . $entry['program'] . '</strong> : ';
            }
            $string .= htmlspecialchars($entry['msg']) . '</td>' . PHP_EOL;
            $string .= '  </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>' . PHP_EOL;
        // Print pagination header
        if ($pagination && !$short) {
            $string = pagination($vars, $count) . $string . pagination($vars, $count);
        }
        // Print syslog
        echo $string;
    }
}