本文整理汇总了PHP中Util::get_timezone方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::get_timezone方法的具体用法?PHP Util::get_timezone怎么用?PHP Util::get_timezone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Util
的用法示例。
在下文中一共展示了Util::get_timezone方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_note
function add_note($conn, $type)
{
$validate = array('asset_id' => array('validation' => 'OSS_HEX', 'e_message' => 'illegal:' . _('Asset ID')), 'txt' => array('validation' => 'OSS_TEXT, OSS_PUNC_EXT', 'e_message' => 'illegal:' . _('Note text')));
$validation_errors = validate_form_fields('POST', $validate);
if (is_array($validation_errors) && !empty($validation_errors)) {
Av_exception::throw_error(Av_exception::USER_ERROR, _('Error! Note could not be added'));
}
$asset_id = POST('asset_id');
$txt = POST('txt');
// Check Asset Type
$asset_types = array('asset' => 'asset_host', 'network' => 'asset_net', 'group' => 'asset_group', 'net_group' => 'net_group');
// Note type
$type_tr = array('group' => 'host_group', 'network' => 'net', 'asset' => 'host', 'net_group' => 'net_group');
$class_name = $asset_types[$type];
$asset_type = $type_tr[$type];
// Check Asset Permission
if (method_exists($class_name, 'is_allowed') && !$class_name::is_allowed($conn, $asset_id)) {
$error = sprintf(_('Error! %s is not allowed'), ucwords($type));
Av_exception::throw_error(Av_exception::USER_ERROR, $error);
}
$note_id = Notes::insert($conn, $asset_type, gmdate('Y-m-d H:i:s'), $asset_id, $txt);
if (intval($note_id) > 0) {
$tz = Util::get_timezone();
$data['msg'] = _('Note added successfully');
$data['id'] = $note_id;
$data['note'] = $txt;
$data['date'] = gmdate('Y-m-d H:i:s', Util::get_utc_unixtime(gmdate('Y-m-d H:i:s')) + 3600 * $tz);
$data['user'] = Session::get_session_user();
$data['editable'] = 1;
} else {
Av_exception::throw_error(Av_exception::USER_ERROR, _('Error! Note could not be added'));
}
return $data;
}
示例2: calc_events_trend
function calc_events_trend($conn)
{
$tz = Util::get_timezone();
$timetz = gmdate("U") + 3600 * $tz - 3600;
$values = SIEM_trend($conn);
$data = array();
$label = array();
for ($i = 0; $i < 60; $i++) {
//Data
$h = gmdate("i", $timetz + 60 * $i);
$h = preg_replace("/^0/", '', $h);
$data[] = $values[$h] != "" ? $values[$h] : 0;
//Label
$label[] = gmdate("Y-m-d H:i", $timetz + 60 * $i);
}
return array($label, $data);
}
示例3: normalize_date
/**
*
* License:
*
* Copyright (c) 2003-2006 ossim.net
* Copyright (c) 2007-2013 AlienVault
* All rights reserved.
*
* This package is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 dated June, 1991.
* You may not use, modify or distribute this program under any other version
* of the GNU General Public License.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this package; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301 USA
*
*
* On Debian GNU/Linux systems, the complete text of the GNU General
* Public License can be found in `/usr/share/common-licenses/GPL-2'.
*
* Otherwise you can read it here: http://www.gnu.org/licenses/gpl-2.0.txt
*
*/
function normalize_date($from_date, $to_date)
{
// Format correction
$from_date = preg_replace("/(\\d\\d)\\/(\\d\\d)\\/(\\d\\d\\d\\d)/", "\\3-\\2-\\1", $from_date);
$to_date = preg_replace("/(\\d\\d)\\/(\\d\\d)\\/(\\d\\d\\d\\d)/", "\\3-\\2-\\1", $to_date);
// Timezone correction
$tz = Util::get_timezone();
if ($tz != 0) {
$from_date = gmdate("Y-m-d H:i:s", Util::get_utc_unixtime("{$from_date} 00:00:00") + -3600 * $tz);
$to_date = gmdate("Y-m-d H:i:s", Util::get_utc_unixtime("{$to_date} 23:59:59") + -3600 * $tz);
}
if (!preg_match("/\\d+\\:\\d+:\\d+/", $from_date)) {
$from_date .= " 00:00:00";
}
if (!preg_match("/\\d+\\:\\d+:\\d+/", $to_date)) {
$to_date .= " 23:59:59";
}
return array($from_date, $to_date);
}
示例4: SIEM_trend
function SIEM_trend($conn)
{
require_once '../../dashboard/sections/widgets/data/sensor_filter.php';
$tz = Util::get_timezone();
$tzc = Util::get_tzc($tz);
$data = array();
$fringe = gmdate('U') - 86400;
$fringe = gmdate('Y-m-d H:00:00', $fringe);
$ctx_where = Session::get_ctx_where() != '' ? " AND ctx IN (" . Session::get_ctx_where() . ")" : "";
list($join, $where) = make_asset_filter('event');
$sql = "SELECT sum(cnt) as num_events, convert_tz(timestamp,'+00:00','{$tzc}') as hour\n\t\t\t\tFROM alienvault_siem.ac_acid_event acid_event {$join}\n\t\t\t\tWHERE 1=1 {$where} {$ctx_where} AND timestamp >= '{$fringe}' \n\t\t\t\tGROUP BY hour\n\t\t\t\tORDER BY timestamp ASC";
$rg = $conn->Execute($sql);
if (!$rg) {
print $conn->ErrorMsg();
} else {
while (!$rg->EOF) {
$data[$rg->fields['hour']] = $rg->fields['num_events'];
$rg->MoveNext();
}
}
return $data;
}
示例5: DisplayProcessing
//.........这里部分代码省略.........
$cmd_opts['type'] = ($_SESSION['profileinfo']['type'] & 4) > 0 ? 'shadow' : 'real';
$cmd_opts['profile'] = $_SESSION['profileswitch'];
$cmd_opts['srcselector'] = implode(':', $process_form['srcselector']);
#print "<pre>\n";
$patterns = array();
$replacements = array();
$patterns[0] = '/(\\s*)([^\\s]+)/';
$replacements[0] = "\$1<a href='#null' onClick='lookup(\"\$2\", this, event)' title='lookup \$2'>\$2</a>";
// gets HAP4NfSens plugin id. returns -1 if HAP4NfSen is not installed.
function getHAP4NfSenId()
{
$plugins = GetPlugins();
for ($i = 0; $i < count($plugins); $i++) {
$plugin = $plugins[$i];
if ($plugin == "HAP4NfSen") {
return $i;
}
}
return -1;
}
ClearMessages();
$cmd_opts['args'] = "-T {$run}";
$cmd_opts['filter'] = $filter;
$titcol = get_tit_col($run);
$cmd_out = nfsend_query("run-nfdump", $cmd_opts);
if (!is_array($cmd_out)) {
ShowMessages();
} else {
$conf = $GLOBALS["CONF"];
$solera = $conf->get_conf("solera_enable", FALSE) ? true : false;
$db = new ossim_db();
$conn = $db->connect();
$sensors = $hosts = $ossim_servers = array();
$tz = Util::get_timezone();
list($hosts, $host_ids) = Asset_host::get_basic_list($conn, array(), TRUE);
$entities = Session::get_all_entities($conn);
$_sensors = Av_sensor::get_basic_list($conn);
foreach ($_sensors as $s_id => $s) {
$sensors[$s['ip']] = $s['name'];
}
/*$hap4nfsen_id = getHAP4NfSenId();
if ($hap4nfsen_id >= 0) {
// ICMP "port" filter are no currently supported by the HAP4NfSen plugin
function isChecked(&$form, $name) { // helper function used to find out, if an option is checked
return $form[$name]=="checked";
}
$ip_and_port_columns = preg_match('/(flow records)/i', $IPStatOption[$process_form['stattype']]) &&
((isChecked($process_form,'aggr_srcip') && isChecked($process_form,'aggr_srcport')) ||
(isChecked($process_form,'aggr_dstip') && isChecked($process_form,'aggr_dstport')));
$ip_contains_port = $_SESSION["process_form"]["modeselect"]=='0' || !preg_match('/[ip|flow_records]/i', $IPStatOption[$process_form['stattype']]) ||
(preg_match('/(flow records)/i', $IPStatOption[$process_form['stattype']]) && !( // no boxes checked
isChecked($process_form,'aggr_srcip') || isChecked($process_form,'aggr_srcport') ||
isChecked($process_form,'aggr_dstip') || isChecked($process_form,'aggr_dstport')));
$_SESSION["plugin"][$hap4nfsen_id]["cmd_opts"] = $cmd_opts;
$hap_pic = "<img src=\"plugins/HAP4NfSen/graphviz.png\" valign=\"middle\" border=\"0\" alt=\"HAP\" />";
$default_pattern = array_pop($patterns);
$default_replacement = array_pop($replacements);
if ($ip_contains_port) { // matches cases like ip:port
$max_prot_length = 5; // max. port length = 5 chars(highest port number = 65535)
for ($i=$max_prot_length;$i>=1;$i--) {
$diff = ($max_prot_length-$i); // difference between actual and max port length
$ip_port_pattern_icmp = "/(\s*)([^\s|^:]+)(:)(0\s{4}|\d\.\d\s{2}|\d{2}\.\d\|\d\.\d{2}\s|\d{2}\.\d{2})/";
$ip_port_pattern_normal = "/(\s*)([^\s|^:]+)(:)([\d|\.]{{$i}})(\s{{$diff}})/";
$spaces = '';
for ($k=0;$k<$diff;$k++) {$spaces = $spaces . ' ';} // spaces required to align hap viewer icons
array_push($patterns, $ip_port_pattern_icmp);
示例6: main_page
function main_page($viewall, $sortby, $sortdir)
{
global $uroles, $username, $dbconn, $hosts;
global $arruser, $user;
$tz = Util::get_timezone();
if ($sortby == "") {
$sortby = "id";
}
if ($sortdir == "") {
$sortdir = "DESC";
}
/* if ( $uroles['admin'] ) {
if($viewall == 1) {
echo " <a href='manage_jobs.php'>View My Schedules</a> | ";
} else {
echo " <a href='manage_jobs.php?viewall=1'>View All Schedules</a> | ";
}
} else {
$viewall = "1";
}*/
//echo "<a href='sched.php?op=reoccuring'>New Schedule</a> |<br><br>";
$sql_order = "order by {$sortby} {$sortdir}";
// if($viewall == 1) {
// $url_sortby="<a href=\"manage_jobs.php?viewall=1&sortby=";
// } else {
// $url_sortby="<a href=\"manage_jobs.php?sortby=";
// }
echo "<center>";
status($arruser, $user);
echo "<br>";
echo "<form>";
echo "<input type=\"button\" onclick=\"document.location.href='sched.php?smethod=schedule&hosts_alive=1&scan_locally=1'\" value=\"" . _("New Scan Job") . "\" class=\"button\">";
echo " ";
echo "<input type=\"button\" onclick=\"document.location.href='sched.php?smethod=inmediately&hosts_alive=1&scan_locally=1'\" value=\"" . _("Run Scan Now") . "\" class=\"button\">";
echo "</form>";
echo "</center>";
echo "<br>";
$schedulejobs = _("Scheduled Jobs");
echo <<<EOT
<center>
<table cellspacing="0" cellpadding="0" border="0" width="90%"><tr><td class="headerpr" style="border:0;">{$schedulejobs}</td></tr></table>
<table cellspacing="2" width="90%" summary="Job Schedules"
border=0 cellspacing="0" cellpadding="0">
EOT;
if ($sortdir == "ASC") {
$sortdir = "DESC";
} else {
$sortdir = "ASC";
}
$arr = array(_("Name"), _("Schedule Type"), _("Time"), _("Next Scan"), _("Status"));
// modified by hsh to return all scan schedules
if (in_array("admin", $arruser)) {
$query = "SELECT t2.name as profile, t1.meth_TARGET, t1.id, t1.name, t1.schedule_type, t1.meth_VSET, t1.meth_TIMEOUT, t1.username, t1.enabled, t1.next_CHECK, t1.email\n FROM vuln_job_schedule t1 LEFT JOIN vuln_nessus_settings t2 ON t1.meth_VSET=t2.id ";
} else {
$query = "SELECT t2.name as profile, t1.meth_TARGET, t1.id, t1.name, t1.schedule_type, t1.meth_VSET, t1.meth_TIMEOUT, t1.username, t1.enabled, t1.next_CHECK, t1.email\n FROM vuln_job_schedule t1 LEFT JOIN vuln_nessus_settings t2 ON t1.meth_VSET=t2.id WHERE username in ('{$user}') ";
}
// if($viewall == 1) { // list all schedules
// } else { // view only logged in users schedules
// $query .= "where username='$username' ";
// }
$query .= $sql_order;
$result = $dbconn->execute($query);
if ($result->EOF) {
echo "<tr><td height='20' class='nobborder' style='text-align:center;'>" . _("No Scheduled Jobs") . "</td></tr>";
}
if (!$result->EOF) {
echo "<tr>";
foreach ($arr as $value) {
echo "<th><a href=\"manage_jobs.php?sortby={$value}&sortdir={$sortdir}\">{$value}</a></th>";
}
echo "<th>" . _("Action") . "</th></tr>";
}
while (!$result->EOF) {
list($profile, $targets, $schedid, $schedname, $schedtype, $sid, $timeout, $user, $schedstatus, $nextscan, $servers) = $result->fields;
$tz = intval($tz);
$nextscan = gmdate("Y-m-d H:i:s", Util::get_utc_unixtime($dbconn, $nextscan) + 3600 * $tz);
preg_match("/\\d+\\-\\d+\\-\\d+\\s(\\d+:\\d+:\\d+)/", $nextscan, $found);
$time = $found[1];
switch ($schedtype) {
case "N":
$stt = _("Once (Now)");
break;
case "O":
$stt = _("Once");
break;
case "D":
$stt = _("Daily");
break;
case "W":
$stt = _("Weekly");
break;
case "M":
$stt = _("Monthly");
break;
case "Q":
$stt = _("Quarterly");
break;
case "H":
$stt = _("On Hold");
break;
//.........这里部分代码省略.........
示例7: main_page
function main_page($viewall, $sortby, $sortdir)
{
global $uroles, $username, $dbconn, $hosts;
global $arruser, $user;
$dbconn->SetFetchMode(ADODB_FETCH_BOTH);
$tz = Util::get_timezone();
if ($sortby == "") {
$sortby = "id";
}
if ($sortdir == "") {
$sortdir = "DESC";
}
$sql_order = "order by {$sortby} {$sortdir}";
if (Session::menu_perms("environment-menu", "EventsVulnerabilitiesScan")) {
?>
<div style="width:50%; position: relative; height: 5px; float:left">
<div style="width:100%; position: absolute; top: -41px;left:0px;">
<div style="float:left; height:28px; margin:5px 5px 0px 0px;">
<a class="button" href="<?php
echo Menu::get_menu_url(AV_MAIN_PATH . '/vulnmeter/sched.php?smethod=schedule&hosts_alive=1&scan_locally=1', 'environment', 'vulnerabilities', 'scan_jobs');
?>
">
<?php
echo _("New Scan Job");
?>
</a>
</div>
<div style="float:left;height:28px;margin:5px 5px 0px -2px;">
<a class="greybox button av_b_secondary" href="import_nbe.php" title="<?php
echo _("Import nbe file");
?>
">
<?php
echo _("Import nbe file");
?>
</a>
</div>
</div>
</div>
<?php
}
if (intval($_GET['page']) != 0) {
$page = intval($_GET['page']);
} else {
$page = 1;
}
$pagesize = 10;
if ($username == "admin") {
$query = "SELECT count(id) as num FROM vuln_jobs";
} else {
$query = "SELECT count(id) as num FROM vuln_jobs where username='{$username}'";
}
$result = $dbconn->Execute($query);
$jobCount = $result->fields["num"];
$num_pages = ceil($jobCount / $pagesize);
//echo "num_pages:[".$num_pages."]";
//echo "jobCount:[".$jobCount."]";
//echo "page:[".$page."]";
if (Vulnerabilities::scanner_type() == "omp") {
// We can display scan status with OMP protocol
echo Vulnerabilities::get_omp_running_scans($dbconn);
} else {
// Nessus
all_jobs(0, 10, "R");
}
?>
<?php
$schedulejobs = _("Scheduled Jobs");
echo <<<EOT
<table style='margin-top:20px;' class='w100 transparent'><tr><td class='sec_title'>{$schedulejobs}</td></tr></table>
<table summary="Job Schedules" class='w100 table_list'>
EOT;
if ($sortdir == "ASC") {
$sortdir = "DESC";
} else {
$sortdir = "ASC";
}
$arr = array("name" => "Name", "schedule_type" => "Schedule Type", "time" => "Time", "next_CHECK" => "Next Scan", "enabled" => "Status");
// modified by hsh to return all scan schedules
if (empty($arruser)) {
$query = "SELECT t2.name as profile, t1.meth_TARGET, t1.id, t1.name, t1.schedule_type, t1.meth_VSET, t1.meth_TIMEOUT, t1.username, t1.enabled, t1.next_CHECK, t1.email\n FROM vuln_job_schedule t1 LEFT JOIN vuln_nessus_settings t2 ON t1.meth_VSET=t2.id ";
} else {
$query = "SELECT t2.name as profile, t1.meth_TARGET, t1.id, t1.name, t1.schedule_type, t1.meth_VSET, t1.meth_TIMEOUT, t1.username, t1.enabled, t1.next_CHECK, t1.email\n FROM vuln_job_schedule t1 LEFT JOIN vuln_nessus_settings t2 ON t1.meth_VSET=t2.id WHERE username in ({$user}) ";
}
$query .= $sql_order;
$result = $dbconn->execute($query);
if ($result->EOF) {
echo "<tr><td class='empty_results' height='20' style='text-align:center;'>" . _("No Scheduled Jobs") . "</td></tr>";
}
if (!$result->EOF) {
echo "<tr>";
foreach ($arr as $order_by => $value) {
echo "<th><a href=\"manage_jobs.php?sortby={$order_by}&sortdir={$sortdir}\">" . _($value) . "</a></th>";
}
//.........这里部分代码省略.........
示例8: SIEM_trends_hids
function SIEM_trends_hids($agent_ip)
{
include_once '../panel/sensor_filter.php';
require_once 'classes/Plugin.inc';
require_once 'classes/Util.inc';
require_once 'ossim_db.inc';
$tz = Util::get_timezone();
$tzc = Util::get_tzc($tz);
$data = array();
$plugins = $plugins_sql = "";
$db = new ossim_db();
$dbconn = $db->connect();
$sensor_where = make_sensor_filter($dbconn);
// Ossec filter
$oss_p_id_name = Plugin::get_id_and_name($dbconn, "WHERE name LIKE 'ossec%'");
$plugins = implode(",", array_flip($oss_p_id_name));
$plugins_sql = "AND acid_event.plugin_id in ({$plugins})";
// Agent ip filter
$agent_where = make_sid_filter($dbconn, $agent_ip);
if ($agent_where == "") {
$agent_where = "0";
}
$sqlgraph = "SELECT COUNT(acid_event.sid) as num_events, day(convert_tz(timestamp,'+00:00','{$tzc}')) as intervalo, monthname(convert_tz(timestamp,'+00:00','{$tzc}')) as suf FROM snort.acid_event LEFT JOIN ossim.plugin ON acid_event.plugin_id=plugin.id WHERE sid in ({$agent_where}) AND timestamp BETWEEN '" . gmdate("Y-m-d 00:00:00", gmdate("U") - 604800) . "' AND '" . gmdate("Y-m-d 23:59:59") . "' {$plugins_sql} {$sensor_where} GROUP BY suf,intervalo ORDER BY suf,intervalo";
//print $sqlgraph;
if (!($rg =& $dbconn->Execute($sqlgraph))) {
return false;
} else {
while (!$rg->EOF) {
$hours = $rg->fields["intervalo"] . " " . substr($rg->fields["suf"], 0, 3);
$data[$hours] = $rg->fields["num_events"];
$rg->MoveNext();
}
}
$db->close($dbconn);
return $data;
}
示例9: GetTimeProfile2
function GetTimeProfile2($start_date, $end_date, $time_sep, $join, $where)
{
global $db, $cnt, $label_lst, $value_lst, $value_POST_lst, $debug_mode;
// Timezone
$tz = Util::get_timezone();
$tzc = Util::get_tzc($tz);
$precision = $time_sep[0];
// group by date_format(timestamp, "%Y%m%d %H")
switch ($precision) {
case "hour":
$format = "%Y%m%d %H";
break;
case "day":
$format = "%Y%m%d";
break;
case "month":
default:
$format = "%Y%m";
break;
}
if ($where != "") {
$sql = "select date_format(convert_tz(timestamp,'+00:00','{$tzc}'), \"{$format}\") as date, count(convert_tz(timestamp,'+00:00','{$tzc}')) as count from acid_event {$join} {$where} group by date";
} else {
$sql = "select date_format(convert_tz(timestamp,'+00:00','{$tzc}'), \"{$format}\") as date, count(convert_tz(timestamp,'+00:00','{$tzc}')) as count from acid_event where timestamp between \"{$start_date}\" and \"{$end_date}\" + interval 1 day group by date";
}
if ($debug_mode > 0) {
echo $sql;
}
$result = $db->baseExecute($sql);
while ($myrow = $result->baseFetchRow()) {
$date_str = $myrow["date"];
$count = $myrow["count"];
$i_year = substr($date_str, 0, 4);
$i_month = "";
$i_day = "";
$i_hour = "";
switch ($precision) {
case "hour":
$i_month = substr($date_str, 4, 2);
$i_day = substr($date_str, 6, 2);
$i_hour = substr($date_str, 9, 2);
StoreAlertNum2($count, $i_month . "/" . $i_day . "/" . $i_year . " " . $i_hour . ":00:00 - " . $i_hour . ":59:59", $time_sep, $i_year, $i_month, $i_day, $i_hour);
break;
case "day":
$i_month = substr($date_str, 4, 2);
$i_day = substr($date_str, 6, 2);
StoreAlertNum2($count, $i_month . "/" . $i_day . "/" . $i_year, $time_sep, $i_year, $i_month, $i_day, $i_hour);
break;
case "month":
default:
$i_month = substr($date_str, 4, 2);
StoreAlertNum2($count, $i_month . "/" . $i_year, $time_sep, $i_year, $i_month, $i_day, $i_hour);
$format = "%Y%m";
break;
}
}
$result->baseFreeRows();
}
示例10: _
<td class="ne"><?php
echo _("Number of IPs in the database");
?>
</td>
<td class="grb"> <?php
echo Util::number_format_locale($total, 0);
?>
</td>
</tr>
<tr>
<td class="ne"><?php
echo _("Latest update");
?>
</td>
<td class="grb"> <?php
echo gmdate("Y-m-d H:i:s", filemtime($reputation->rep_file) + 3600 * Util::get_timezone());
?>
</td>
</tr>
</table>
</div>
<div class='otx_p_middle'>
<div class='otx_p_title'><?php
echo _("Malicious IPs by Activity");
?>
</div>
<div id="chart" style="width:400px; height:220px"></div>
</div>
<div class='otx_p_right'>
示例11: arsort
//
}
arsort($countries);
// Not found
if (count($countries) == 0)
{
echo "<tr><td><table class='transparent' style='width:100%'><tr><td colspan='5' style='padding:6px'><b>"._("No external IP addresses were found in the SIEM events")."</b></td></tr></table></td></tr>\n";
}
// Results
else
{
echo '<br/><TABLE class="table_list">';
echo '<tr><th style="text-align:left" width="25%">Country</th>
<th width="15%">' . gettext("Events") . " # <span class='idminfo' txt='".Util::timezone(Util::get_timezone())."'>(*)</span>". '</th>
<th width="10%">' . gettext("Unique Src. #") . '</th>
<th width="10%">' . gettext("Unique Dst. #") . '</th>
<th></th></TR>';
$max_cnt = 1;
$i = 0;
foreach ($countries as $country=>$num) {
if ($max_cnt == 1 && $num > 0) $max_cnt = $num;
$data = $country_acc[$country];
if ($data['srcnum']+$data['dstnum'] == 0) $entry_width = 0;
else $entry_width = round($data['events'] / $max_cnt * 100);
if ($data['code']=="") $data['code']="unknown";
?>
<tr>
<td style="padding:7px;text-align:left"><?=$data['flag']." ".$country?></td>
示例12: submit_scan
function submit_scan($op, $sched_id, $sname, $notify_email, $schedule_type, $ROYEAR, $ROMONTH, $ROday, $time_hour, $time_min, $dayofweek, $dayofmonth, $timeout, $SVRid, $sid, $tarSel, $ip_list, $ip_exceptions_list, $ip_start, $ip_end, $named_list, $cidr, $subnet, $system, $cred_type, $credid, $acc, $domain, $accpass, $acctype, $passtype, $passstore, $wpolicies, $wfpolicies, $upolicies, $custadd_type, $cust_plugins, $is_enabled, $hosts_alive, $scan_locally, $nthweekday, $semail, $not_resolve)
{
global $wdaysMap, $daysMap, $allowscan, $uroles, $username, $schedOptions, $adminmail, $mailfrom, $dbk, $dbconn;
require_once "classes/Util.inc";
$tz = Util::get_timezone();
if (empty($ROYEAR)) {
$ROYEAR = gmdate("Y");
}
if (empty($ROMONTH)) {
$ROMONTH = gmdate("m");
}
if (empty($ROday)) {
$ROday = gmdate("d");
}
list($_y, $_m, $_d, $_h, $_u, $_s, $_time) = Util::get_utc_from_date($dbconn, "{$ROYEAR}-{$ROMONTH}-{$ROday} {$time_hour}:{$time_min}:00", $tz);
$ROYEAR = $_y;
$ROMONTH = $_m;
$ROday = $_d;
$time_hour = $_h;
$time_min = $_u;
if ($not_resolve == "1") {
$resolve_names = 0;
} else {
$resolve_names = 1;
}
$notify_email = str_replace(";", ",", $notify_email);
$requested_run = "";
$jobType = "M";
$recurring = False;
$targets = array();
$time_value = "";
$profile_desc = getProfileName($sid);
$target_list = "";
$need_authorized = "";
$request = "";
$plugs_list = "NULL";
$fk_name = "NULL";
$target_list = "NULL";
$tmp_target_list = "";
$jobs_names = array();
$sjobs_names = array();
//$I3crID = getCredentialId ( $cred_type, $passstore, $credid, $acc, $domain, $accpass, $acctype, $passtype );
$I3crID = "";
if ($hosts_alive == "1") {
// option: Only scan hosts that are alive
$I3crID = "1";
} else {
$I3crID = "0";
}
if ($custadd_type == "") {
$custadd_type = "N";
}
if ($custadd_type != "N" && $cust_plugins != "") {
$plugs_list = "";
$vals = preg_split("/\\s+|\r\n|,|;/", $cust_plugins);
foreach ($vals as $v) {
$v = trim($v);
if (strlen($v) > 0) {
$plugs_list .= $v . "\n";
}
}
$plugs_list = "'" . $plugs_list . "'";
}
/* echo <<<EOT
<h3>Job Details:</h3>
<center>
<table>
<tr><th align="right">Job Name</th><td>$sname</td></tr>
<tr><th align="right">Notify</th><td>$notify_email</td></tr>
<tr><th align="right">Timeout</th><td>$timeout</td></tr>
<tr><th align="right">Profile</th><td>$profile_desc</td></tr>
<tr><th></th><td> </td></tr>
<tr><th align="right">Schedule Info</th><td> </td></tr>
EOT;*/
//$arrTime = localtime((int)gmdate('U'), true);
$arrTime = explode(":", gmdate('Y:m:d:w:H:i:s'));
$year = $arrTime[0];
$mon = $arrTime[1];
$mday = $arrTime[2];
$wday = $arrTime[3];
$hour = $arrTime[4];
$min = $arrTime[5];
$sec = $arrTime[6];
$timenow = $hour . $min . $sec;
if ($time_hour) {
$hour = $time_hour;
}
if ($time_min) {
$min = $time_min;
}
#echo "hour=$hour<br>";
#$hour = $hour - $tz_offset;
#echo "offset=$tz_offset<br>hour=$hour<br>";
#if ( $hour < "0" ) { echo "change 1<br>"; $hour = $hour + 24; }
#if ( $hour >= "24" ) { echo "change 2<br>"; $hour = $hour - 24; }
#echo "hour_changed=$hour<br>";
$run_wday = $wdaysMap[$dayofweek];
#echo "run_day=$run_wday<br>dayofweek=$dayofweek<br>";
$run_time = sprintf("%02d%02d%02d", $time_hour, $time_min, "00");
$run_mday = $dayofmonth;
//.........这里部分代码省略.........
示例13: submit_scan
function submit_scan($vuln_op, $sched_id, $sname, $notify_email, $schedule_type, $ROYEAR, $ROMONTH, $ROday, $time_hour, $time_min, $dayofweek, $dayofmonth, $timeout, $SVRid, $sid, $tarSel, $ip_list, $ip_exceptions_list, $ip_start, $ip_end, $named_list, $cidr, $subnet, $system, $cred_type, $credid, $acc, $domain, $accpass, $acctype, $passtype, $passstore, $wpolicies, $wfpolicies, $upolicies, $custadd_type, $cust_plugins, $is_enabled, $hosts_alive, $scan_locally, $nthweekday, $semail, $not_resolve, $time_interval, $biyear, $bimonth, $biday, $ssh_credential = "", $smb_credential = "")
{
global $wdaysMap, $daysMap, $allowscan, $uroles, $username, $schedOptions, $adminmail, $mailfrom, $dbk, $dbconn;
// credentials
$credentials = $ssh_credential . "|" . $smb_credential;
$btime_hour = $time_hour;
// save local time
$btime_min = $time_min;
$bbiyear = $biyear;
$bbimonth = $bimonth;
$bbiday = $biday;
$tz = Util::get_timezone();
if ($schedule_type == "O") {
// date and time for run once
if (empty($ROYEAR)) {
$ROYEAR = gmdate("Y");
}
if (empty($ROMONTH)) {
$ROMONTH = gmdate("m");
}
if (empty($ROday)) {
$ROday = gmdate("d");
}
list($_y, $_m, $_d, $_h, $_u, $_s, $_time) = Util::get_utc_from_date($dbconn, "{$ROYEAR}-{$ROMONTH}-{$ROday} {$time_hour}:{$time_min}:00", $tz);
$ROYEAR = $_y;
$ROMONTH = $_m;
$ROday = $_d;
$time_hour = $_h;
$time_min = $_u;
} else {
if ($schedule_type == "D" || $schedule_type == "W" || $schedule_type == "M" || $schedule_type == "NW") {
// date and time for Daily, Day of Week, Day of month, Nth weekday of month
list($b_y, $b_m, $b_d, $b_h, $b_u, $b_s, $b_time) = Util::get_utc_from_date($dbconn, "{$biyear}-{$bimonth}-{$biday} {$time_hour}:{$time_min}:00", $tz);
$biyear = $b_y;
$bimonth = $b_m;
$biday = $b_d;
$time_hour = $b_h;
$time_min = $b_u;
}
}
if ($not_resolve == "1") {
$resolve_names = 0;
} else {
$resolve_names = 1;
}
$notify_email = str_replace(";", ",", $notify_email);
$requested_run = "";
$jobType = "M";
$recurring = False;
$targets = array();
$time_value = "";
$profile_desc = getProfileName($sid);
$target_list = "";
$need_authorized = "";
$request = "";
$plugs_list = "NULL";
$fk_name = "NULL";
$target_list = "NULL";
$tmp_target_list = "";
$jobs_names = array();
$sjobs_names = array();
$I3crID = "";
if ($hosts_alive == "1") {
// option: Only scan hosts that are alive
$I3crID = "1";
} else {
$I3crID = "0";
}
// if ( $custadd_type == "" ) { $custadd_type = "N"; }
// if ( $custadd_type != "N" && $cust_plugins != "" ) {
// $plugs_list="";
// $vals=preg_split( "/\s+|\r\n|,|;/", $cust_plugins );
// foreach($vals as $v) {
// $v=trim($v);
// if ( strlen($v)>0 ) {
// $plugs_list .= $v . "\n";
// }
// }
// $plugs_list = "'".$plugs_list."'";
// }
if ($schedule_type != "N") {
// current datetime in UTC
$arrTime = explode(":", gmdate('Y:m:d:w:H:i:s'));
$year = $arrTime[0];
$mon = $arrTime[1];
$mday = $arrTime[2];
$wday = $arrTime[3];
$hour = $arrTime[4];
$min = $arrTime[5];
$sec = $arrTime[6];
$timenow = $hour . $min . $sec;
$run_wday = $wdaysMap[$dayofweek];
$run_time = sprintf("%02d%02d%02d", $time_hour, $time_min, "00");
$run_mday = $dayofmonth;
$time_value = "{$time_hour}:{$time_min}:00";
$ndays = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
$begin_in_seconds = mktime($bihour, $bimin, 0, $bimonth, $biday, $biyear);
// selected datetime by user in UTC
$current_in_seconds = mktime($hour, $min, 0, $mon, $mday, $year);
// current datetime in UTC
//.........这里部分代码省略.........
示例14: reportsummary
function reportsummary()
{
//GENERATE REPORT SUMMARY
global $user, $border, $report_id, $scantime, $scantype, $fp, $nfp, $output, $filterip, $query_risk, $dbconn, $pluginid;
global $treport, $sid, $ipl;
$tz = Util::get_timezone();
$htmlsummary = "";
if ($treport == "latest" || $ipl != "") {
$query = "SELECT t2.id, t1.username, t1.name, t2.name, t2.description, t4.hostname as host_name \n FROM vuln_nessus_latest_reports t1\n LEFT JOIN vuln_nessus_settings t2 on t1.sid=t2.id\n LEFT JOIN host t4 ON t4.ip=inet_ntoa(t1.report_id)\n WHERE " . ($ipl != "all" ? "t1.report_id in ({$report_id}) and " : "") . "t1.sid in ({$sid}) AND t1.username in ('{$user}')\n order by t1.scantime DESC";
} else {
$query = "SELECT t2.id, t1.username, t1.name, t2.name, t2.description \n FROM vuln_jobs t1\n LEFT JOIN vuln_nessus_settings t2 on t1.meth_VSET=t2.id\n WHERE t1.report_id in ({$report_id}) AND t1.username in('{$user}')\n order by t1.SCAN_END DESC";
}
$result = $dbconn->execute($query);
//print_r($query);
if ($treport == "latest" || $ipl != "") {
//list( $id_profile, $query_uid, $job_name, $profile_name, $profile_desc, $host_name ) =$result->fields;
$lprofiles = array();
$tmp_profiles = array();
while (list($id_profile, $query_uid, $job_name, $profile_name, $profile_desc, $host_name) = $result->fields) {
if ($host_name != "" && $host_name != long2ip($report_id)) {
$phost_name = "{$host_name} (" . long2ip($report_id) . ")";
} else {
$phost_name = long2ip($report_id);
}
$lprofiles[] = "{$profile_name} - {$profile_desc}";
$tmp_profiles[] = $id_profile;
$result->MoveNext();
}
$profiles = implode("<br>", $lprofiles);
$id_profile = implode(", ", $tmp_profiles);
} else {
list($id_profile, $query_uid, $job_name, $profile_name, $profile_desc) = $result->fields;
if ($job_name == "") {
// imported report
$query_imported_report = "SELECT name FROM vuln_nessus_reports WHERE scantime='{$scantime}'";
$result_imported_report = $dbconn->execute($query_imported_report);
$job_name = $result_imported_report->fields["name"];
}
}
if ($tz == 0) {
$localtime = gen_strtotime($scantime, "");
} else {
$localtime = gmdate("Y-m-d H:i:s", Util::get_utc_unixtime($dbconn, $scantime) + 3600 * $tz);
}
$htmlsummary .= "<table border=\"5\" width=\"900\"><tr><th class=\"noborder\" valign=\"top\" style=\"text-align:left;font-size:12px;\" nowrap>\n \n <b>" . _("Scan time") . ":</b></th><td class=\"noborder\" style=\"text-align:left;padding-left:10px;\">" . $localtime . " </td>";
//Generated date
$gendate = date("Y-m-d H:i:s");
$htmlsummary .= "<th class=\"noborder\" valign=\"top\" style=\"text-align:left;font-size:12px;\" nowrap>\n <b>" . _("Generated") . ":</b></th><td class=\"noborder\" style=\"text-align:left;padding-left:10px;\">{$gendate}</td></tr>";
if ($ipl != "all") {
if ($treport == "latest" || $ipl != "") {
$htmlsummary .= "<tr><th class=\"noborder\" valign=\"top\" style=\"text-align:left;font-size:12px;\" nowrap>\n <b>" . (count($lprofiles) > 1 ? _("Profiles") : _("Profile")) . ":</b></th><td class=\"noborder\" style=\"text-align:left;padding-left:10px;\">";
$htmlsummary .= "{$profiles} </td>\n <th class=\"noborder\" valign=\"top\" style=\"text-align:left;font-size:12px;\" nowrap>\n <b>" . ($treport == "latest" || $ipl != "" ? _("Host - IP") : _("Job Name")) . ":</b></th><td class=\"noborder\" valign=\"top\" style=\"text-align:left;padding-left:10px;\">" . ($treport == "latest" || $ipl != "" ? "{$phost_name}" : "{$job_name}") . "</td></tr>";
} else {
$htmlsummary .= "<tr><th class=\"noborder\" valign=\"top\" style=\"text-align:left;font-size:12px;\" nowrap>\n <b>" . _("Profile") . ":</b></th><td class=\"noborder\" style=\"text-align:left;padding-left:10px;\">";
$htmlsummary .= "{$profile_name} - {$profile_desc} </td>\n <th class=\"noborder\" valign=\"top\" style=\"text-align:left;font-size:12px;\" nowrap>\n <b>" . _("Job Name") . ":</b></th><td class=\"noborder\" style=\"text-align:left;padding-left:10px;\">{$job_name}</td></tr>";
}
}
$htmlsummary .= "</table>";
/*
if($pluginid!="") {
if($fp!=""){
$dbconn->execute("UPDATE vuln_nessus_settings_plugins SET enabled='N' WHERE sid in ($id_profile) and id='$pluginid'");
}
else {
$dbconn->execute("UPDATE vuln_nessus_settings_plugins SET enabled='Y' WHERE sid in ($id_profile) and id='$pluginid'");
}
}
*/
return "<center>" . $htmlsummary . "</center>";
}
示例15: BETWEEN
if ($matches[2] != $matches[3]) {
$where = $matches[1] . " AND timestamp BETWEEN('" . $matches[2] . "') AND ('" . $matches[3] . "') " . $matches[4];
} else {
$where = $matches[1] . " AND timestamp >= '" . $matches[2] . "' " . $matches[4];
}
}
$qs->SetActionSQL($from . $where);
$et->Mark("Initialization");
$qs->RunAction($submit, PAGE_STAT_UADDR, $db);
$et->Mark("Alert Action");
/* Setup the Query Results Table */
$qro = new QueryResultsOutput("base_stat_otx.php?caller=" . $caller);
$qro->AddTitle(_('OTX Pulse'));
$events_title = _("Events"). " # <span class='idminfo' txt='".Util::timezone(Util::get_timezone())."'>(*)</span>";
$qro->AddTitle("<span id='total_title'>$events_title</span>", "occur_a", " ", " ORDER BY num_events ASC, num_iocs ASC", "occur_d", " ", " ORDER BY num_events DESC, num_iocs DESC");
$qro->AddTitle(_("Indicators #") , "ioc_a", " ", " ORDER BY num_iocs ASC", "ioc_d", " ", " ORDER BY num_iocs DESC");
$qro->AddTitle(' ');
$sort_sql = $qro->GetSortSQL($qs->GetCurrentSort() , $qs->GetCurrentCannedQuerySort());
$sql = "SELECT SQL_CALC_FOUND_ROWS hex(otx_data.pulse_id) as pulse, COUNT(distinct otx_data.event_id) as num_events, COUNT(distinct otx_data.ioc_hash) as num_iocs ". $sort_sql[0] . $from . $where . " GROUP BY pulse_id " . $sort_sql[1];
// use accumulate tables only with timestamp criteria
if (file_exists('/tmp/debug_siem'))
{
error_log("STATS OTX:$sql\n", 3, "/tmp/siem");
}
/* Run the Query again for the actual data (with the LIMIT) */