本文整理匯總了PHP中print_warning函數的典型用法代碼示例。如果您正苦於以下問題:PHP print_warning函數的具體用法?PHP print_warning怎麽用?PHP print_warning使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了print_warning函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: print_authlog
/**
* 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: hook_prefs_tab_section
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: print_neighbours
/**
* 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: print_authlog
/**
* 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> ' . $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: print_authlog
/**
* 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: preg_replace
}
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: get_smokeping_files
<?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: poll_status
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);
//.........這裏部分代碼省略.........
示例9: dbUpdate
$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: detect_device_snmpauth
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: array
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: foreach
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: print_logalert_log
/**
* 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: dbupdate
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: index
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."));
}
}
}
}
//.........這裏部分代碼省略.........