本文整理汇总了PHP中utime函数的典型用法代码示例。如果您正苦于以下问题:PHP utime函数的具体用法?PHP utime怎么用?PHP utime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
function search($uname, &$u)
{
$utimer = utime();
$filter = '(sAMAccountName=' . $uname . ')';
if ($result = ldap_search($this->c, LDAPTREE, $filter)) {
$data = ldap_get_entries($this->c, $result);
$keys = array_keys($data[0]);
$member = '';
while (list($k, $v) = each($keys)) {
// echo "<!-- [$v] -->\n";
if (isset($u->{$v})) {
if ($v == 'memberof') {
for ($i = 0; $i < $data[0][$v]['count']; $i++) {
$member .= $data[0][$v][$i] . ';';
}
$u->{$v} = $member;
} else {
$u->{$v} = $data[0][$v]['0'];
}
}
// debug - et mis meil üldse AD'st saada on
// $uu = $data['0'][$v]['0'];
// echo "<!-- $v = $uu -->\n";
}
if ($this->debug) {
$t = stop_utimer($utimer);
$this->m[] = "<!-- LDAP [{$t}] userdata for [{$uname}] -->\n";
}
return true;
}
return false;
}
示例2: add_to_timeline
function add_to_timeline($timestamp, $type, $title, $url)
{
global $conf, $timeline;
$utime = utime();
$time_since = $utime - $conf->last_utime;
$conf->last_utime = $utime;
echo "{$time_since} [{$type}]: {$timestamp} - {$title}<br />\n";
$timeline[$timestamp][] = array("type" => $type, "url" => $url, "title" => $title);
}
示例3: parse
public function parse($vars, $fname)
{
$utimer = utime();
$this->vars = $vars;
// loop peab nägema
$this::open($fname, 'r');
$this->content = $this::read();
$parsed = $this::rip_open_and_do_replacements($vars);
if ($this->debug) {
$this->msg[] = "<!-- file: [{$fname}] parsed in " . stop_utimer($utimer) . " s. -->\n";
}
return $parsed;
}
示例4: conf
function conf()
{
$this->now = date("YmdHi");
$this->last_utime = utime();
$this->created_on = "created_on_{$this->now}";
$this->compiled_on = date("l dS \\of F Y h:i:s A");
$this->user = "johnc";
$this->keywords = "John, Carmack, id, archive, compilation, doom, quake";
$this->title = "The John Carmack Archive";
$this->fullname = "John Carmack";
$this->header = read_file("template/header.html");
$this->footer = read_file("template/footer.html");
}
示例5: debug
function debug($mode, $cur_query = null)
{
if (!$this->dbg_enabled) {
return;
}
$id =& $this->dbg_id;
$dbg =& $this->dbg[$id];
if ($mode == 'start') {
$this->sql_starttime = utime();
$dbg['sql'] = isset($cur_query) ? short_query($cur_query) : short_query($this->cur_query);
$dbg['src'] = $this->debug_find_source();
$dbg['file'] = $this->debug_find_source('file');
$dbg['line'] = $this->debug_find_source('line');
$dbg['time'] = '';
} else {
if ($mode == 'stop') {
$this->cur_query_time = utime() - $this->sql_starttime;
$this->sql_timetotal += $this->cur_query_time;
$dbg['time'] = $this->cur_query_time;
$id++;
}
}
}
示例6: discover_device
function discover_device($device, $options = NULL)
{
global $config, $valid, $exec_status, $discovered_devices;
// Initialise variables
$valid = array();
// Reset $valid array
$modules = array();
$cache_discovery = array();
// Specific discovery cache for exchange snmpwalk data between modules (memory/storage/sensors/etc)
$attribs = get_entity_attribs('device', $device['device_id']);
$device_start = utime();
// Start counting device poll time
// Check if device discovery already running
$pid_info = check_process_run($device);
if ($pid_info) {
// Process ID exist in DB
print_message("%rAnother " . $pid_info['process_name'] . " process (PID: " . $pid_info['PID'] . ", UID: " . $pid_info['UID'] . ", STARTED: " . $pid_info['STARTED'] . ") already running for device " . $device['hostname'] . " (" . $device['device_id'] . ").%n", 'color');
return FALSE;
}
add_process_info($device);
// Store process info
print_cli_heading($device['hostname'] . " [" . $device['device_id'] . "]", 1);
$detect_os = TRUE;
// Set TRUE or FALSE for module 'os' (exclude double os detection)
if ($device['os'] == 'generic' || isset($options['h']) && $options['h'] == 'new') {
$detect_os = FALSE;
$old_os = $device['os'];
$device['os'] = get_device_os($device);
if ($device['os'] != $old_os) {
print_cli_data("Device OS changed", $old_os . " -> " . $device['os'], 1);
log_event('OS changed: ' . $old_os . ' -> ' . $device['os'], $device, 'device', $device['device_id'], 'warning');
dbUpdate(array('os' => $device['os']), 'devices', '`device_id` = ?', array($device['device_id']));
}
}
print_cli_data("OS Type", $device['os'], 1);
if ($config['os'][$device['os']]['group']) {
$device['os_group'] = $config['os'][$device['os']]['group'];
print_cli_data("OS Group", $device['os_group'], 1);
}
print_cli_data("SNMP Version", $device['snmp_version'], 1);
print_cli_data("Last discovery", $device['last_discovered'], 1);
print_cli_data("Last duration", $device['last_discovered_timetaken'] . " seconds", 1);
echo PHP_EOL;
// Either only run the modules specified on the commandline, or run all modules in config.
if ($options['m']) {
foreach (explode(",", $options['m']) as $module) {
$modules[$module] = TRUE;
}
} else {
if ($device['force_discovery'] && $options['h'] == 'new' && isset($attribs['force_discovery_modules'])) {
// Forced discovery specific modules
foreach (json_decode($attribs['force_discovery_modules'], TRUE) as $module) {
$modules[$module] = TRUE;
}
log_event('Forced discovery module(s): ' . implode(', ', array_keys($modules)), $device, 'device', $device['device_id'], 'debug');
} else {
$modules = $config['discovery_modules'];
}
}
// Use os specific modules order
//print_vars($modules);
if (isset($config['os'][$device['os']]['discovery_order'])) {
//print_vars($config['os'][$device['os']]['discovery_order']);
foreach ($config['os'][$device['os']]['discovery_order'] as $module => $module_order) {
if (array_key_exists($module, $modules)) {
$module_status = $modules[$module];
switch ($module_order) {
case 'last':
// add to end of modules list
unset($modules[$module]);
$modules[$module] = $module_status;
break;
case 'first':
// add to begin of modules list, but not before os/system
$new_modules = array();
if ($modules['os']) {
$new_modules['os'] = $modules['os'];
unset($modules['os']);
}
if ($modules['system']) {
$new_modules['system'] = $modules['system'];
unset($modules['system']);
}
$new_modules[$module] = $module_status;
unset($modules[$module]);
$modules = $new_modules + $modules;
break;
default:
// add into specific place (after module name in $module_order)
// yes, this is hard and magically
if (array_key_exists($module_order, $modules)) {
unset($modules[$module]);
$new_modules = array();
foreach ($modules as $new_module => $new_status) {
array_shift($modules);
$new_modules[$new_module] = $new_status;
if ($new_module == $module_order) {
$new_modules[$module] = $module_status;
break;
}
//.........这里部分代码省略.........
示例7: print_debug
$mask = $mask != NULL ? $mask : '32';
$range = $net . '/' . $mask;
if ($mask >= 0 && $mask <= 32 && Net_IPv4::ipInNetwork($_SERVER['REMOTE_ADDR'], $range)) {
$auth = TRUE;
// hardcode authenticated for matched subnet
print_debug("认证的CIDR匹配IPv4 {$range}.");
break;
}
} elseif (Net_IPv6::checkIPv6($net)) {
// IPv6
$mask = $mask != NULL ? $mask : '128';
$range = $net . '/' . $mask;
if ($mask >= 0 && $mask <= 128 && Net_IPv6::isInNetmask($_SERVER['REMOTE_ADDR'], $range)) {
$auth = TRUE;
// hardcode authenticated for matched subnet
print_debug("认证的CIDR匹配IPv6 {$range}");
break;
}
}
}
}
if (!$auth) {
// Normal auth
include $config['html_dir'] . "/includes/authenticate.inc.php";
}
// Push $_GET into $vars to be compatible with web interface naming
$vars = get_vars('GET');
include $config['html_dir'] . "/includes/graphs/graph.inc.php";
$runtime = utime() - $start;
print_debug("运行时间 " . $runtime . " 秒");
// EOF
示例8: ob_get_contents
$panel_html = ob_get_contents();
ob_end_clean();
register_html_panel($panel_html);
}
} else {
if ($config['auth_mechanism'] == 'cas') {
// Not Authenticated. CAS logon.
echo 'Not authorized.';
exit;
} else {
// Not Authenticated. Print login.
include $config['html_dir'] . "/pages/logon.inc.php";
exit;
}
}
$gentime = utime() - $runtime_start;
$fullsize = memory_get_usage();
unset($cache);
$cachesize = $fullsize - memory_get_usage();
if ($cachesize < 0) {
$cachesize = 0;
}
// Silly PHP!
?>
</div>
<?php
if ($vars['bare'] != 'yes') {
?>
<div class="navbar navbar-fixed-bottom">
示例9: pla_error
}
$filter = "({$attr}=*{$filter})";
break;
case 'equals':
$filter = "({$attr}={$filter})";
break;
case 'sounds like':
$filter = "({$attr}~={$filter})";
break;
default:
pla_error("Unrecognized criteria option: " . htmlspecialchars($criterion) . "If you want to add your own criteria to the list. Be sure to edit " . "search.php to handle them. Quitting.");
}
}
$time_start = utime();
$results = pla_ldap_search($server_id, $filter, $base_dn, $search_result_attributes, $scope);
$time_end = utime();
$time_elapsed = round($time_end - $time_start, 2);
$count = count($results);
?>
<br />
<center>Found <b><?php
echo $count;
?>
</b> <?php
echo $count == 1 ? 'entry' : 'entries';
?>
.
<?php
if ($form == 'simple') {
示例10: accept
public function accept()
{
$server = $this->getServer();
# Get the data to be exported
$query = array();
$base = get_request('dn', 'REQUEST');
$query['baseok'] = true;
$query['filter'] = get_request('filter', 'REQUEST', false, 'objectclass=*');
$query['scope'] = get_request('scope', 'REQUEST', false, 'base');
$query['deref'] = $_SESSION[APPCONFIG]->getValue('deref', 'export');
$query['size_limit'] = 0;
$attrs = get_request('attributes', 'REQUEST');
$attrs = preg_replace('/\\s+/', '', $attrs);
if ($attrs) {
$query['attrs'] = explode(',', $attrs);
} else {
$query['attrs'] = array('*');
}
if (get_request('sys_attr')) {
if (!in_array('*', $query['attrs'])) {
array_push($query['attrs'], '*');
}
array_push($query['attrs'], '+');
}
if (!$base) {
$bases = $server->getBaseDN();
} else {
$bases = array($base);
}
foreach ($bases as $base) {
$query['base'] = $base;
$time_start = utime();
$this->results[$base] = $server->query($query, null);
$time_end = utime();
usort($this->results[$base], 'pla_compare_dns');
$this->resultsdata[$base]['time'] = round($time_end - $time_start, 2);
# If no result, there is a something wrong
if (!$this->results[$base] && $server->getErrorNum(null)) {
system_message(array('title' => _('Encountered an error while performing search.'), 'body' => ldap_error_msg($server->getErrorMessage(null), $server->getErrorNum(null)), 'type' => 'error'));
}
$this->items += count($this->results[$base]);
}
$this->resultsdata['scope'] = $query['scope'];
$this->resultsdata['filter'] = $query['filter'];
$this->resultsdata['attrs'] = $query['attrs'];
# Other settings
switch (get_request('format', 'POST', false, 'unix')) {
case 'win':
$this->br = "\r\n";
break;
case 'mac':
$this->br = "\r";
break;
case 'unix':
default:
$this->br = "\n";
}
if (get_request('compress', 'REQUEST') == 'on') {
$this->compress = true;
}
}
示例11: poll_device
function poll_device($device, $options)
{
global $config, $debug, $device, $polled_devices, $db_stats, $memcache;
$old_device_state = unserialize($device['device_state']);
$attribs = get_dev_attribs($device['device_id']);
$status = 0;
unset($array);
$device_start = utime();
// Start counting device poll time
echo $device['hostname'] . " " . $device['device_id'] . " " . $device['os'] . " ";
if ($config['os'][$device['os']]['group']) {
$device['os_group'] = $config['os'][$device['os']]['group'];
echo "(" . $device['os_group'] . ")";
}
echo "\n";
unset($poll_update);
unset($poll_update_query);
unset($poll_separator);
$poll_update_array = array();
$host_rrd = $config['rrd_dir'] . "/" . $device['hostname'];
if (!is_dir($host_rrd)) {
mkdir($host_rrd);
echo "Created directory : {$host_rrd}\n";
}
$device['pingable'] = isPingable($device['hostname']);
if ($device['pingable']) {
$device['snmpable'] = isSNMPable($device);
if ($device['snmpable']) {
$status = "1";
$status_type = '';
} else {
echo "SNMP Unreachable";
$status = "0";
$status_type = ' (snmp)';
}
} else {
echo "Unpingable";
$status = "0";
$status_type = ' (ping)';
}
if ($device['status'] != $status) {
$poll_update .= $poll_separator . "`status` = '{$status}'";
$poll_separator = ", ";
dbUpdate(array('status' => $status), 'devices', 'device_id=?', array($device['device_id']));
dbInsert(array('importance' => '0', 'device_id' => $device['device_id'], 'message' => "Device is " . ($status == '1' ? 'up' : 'down')), 'alerts');
log_event('Device status changed to ' . ($status == '1' ? 'Up' : 'Down') . $status_type, $device, 'system');
notify($device, "Device " . ($status == '1' ? 'Up' : 'Down') . ": " . $device['hostname'] . $status_type, "Device " . ($status == '1' ? 'up' : 'down') . ": " . $device['hostname']);
}
$rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/status.rrd";
if (!is_file($rrd)) {
rrdtool_create($rrd, "DS:status:GAUGE:600:0:1 " . $config['rrd_rra']);
}
if ($status == "1" || $status == "0") {
rrdtool_update($rrd, "N:" . $status);
} else {
rrdtool_update($rrd, "N:U");
}
// Ping response RRD database.
$ping_rrd = $config['rrd_dir'] . '/' . $device['hostname'] . '/ping.rrd';
if (!is_file($ping_rrd)) {
rrdtool_create($ping_rrd, "DS:ping:GAUGE:600:0:65535 " . $config['rrd_rra']);
}
if ($device['pingable']) {
rrdtool_update($ping_rrd, "N:" . $device['pingable']);
} else {
rrdtool_update($ping_rrd, "N:U");
}
// SNMP response RRD database.
$ping_snmp_rrd = $config['rrd_dir'] . '/' . $device['hostname'] . '/ping_snmp.rrd';
if (!is_file($ping_snmp_rrd)) {
rrdtool_create($ping_snmp_rrd, "DS:ping_snmp:GAUGE:600:0:65535 " . $config['rrd_rra']);
}
if ($device['snmpable']) {
rrdtool_update($ping_snmp_rrd, "N:" . $device['snmpable']);
} else {
rrdtool_update($ping_snmp_rrd, "N:U");
}
if ($status == "1") {
$graphs = array();
$oldgraphs = array();
// Enable Ping graphs
$graphs['ping'] = TRUE;
// Enable SNMP graphs
$graphs['ping_snmp'] = TRUE;
if ($options['m']) {
foreach (explode(",", $options['m']) as $module) {
if (is_file("includes/polling/" . $module . ".inc.php")) {
include "includes/polling/" . $module . ".inc.php";
}
}
} else {
foreach ($config['poller_modules'] as $module => $module_status) {
if ($attribs['poll_' . $module] || $module_status && !isset($attribs['poll_' . $module])) {
if ($debug) {
echo "including: includes/polling/{$module}.inc.php\n";
}
include 'includes/polling/' . $module . '.inc.php';
} elseif (isset($attribs['poll_' . $module]) && $attribs['poll_' . $module] == "0") {
echo "Module [ {$module} ] disabled on host.\n";
} else {
//.........这里部分代码省略.........
示例12: logfile
logfile("Connection to UNIX agent on " . $agent_socket . " failed. ERROR: " . $errno . " " . $errstr);
/// Try check_mk port if the official one doesn't work.
$agent_port = "6556";
$agent_start = utime();
$agent_socket = "tcp://" . $device['hostname'] . ":" . $agent_port;
$agent = @stream_socket_client($agent_socket, $errno, $errstr, 10);
if (!$agent) {
echo "Connection to UNIX agent on " . $agent_socket . " failed. ERROR: " . $errno . " " . $errstr . "\n";
logfile("Connection to UNIX agent on " . $agent_socket . " failed. ERROR: " . $errno . " " . $errstr);
} else {
$agent_raw = stream_get_contents($agent);
}
} else {
$agent_raw = stream_get_contents($agent);
}
$agent_end = utime();
$agent_time = round(($agent_end - $agent_start) * 1000);
if (!empty($agent_raw)) {
echo "execution time: " . $agent_time . "ms";
$agent_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/agent.rrd";
if (!is_file($agent_rrd)) {
rrdtool_create($agent_rrd, "DS:time:GAUGE:600:0:U " . $config['rrd_rra']);
}
rrdtool_update($agent_rrd, "N:" . $agent_time);
$graphs['agent'] = TRUE;
foreach (explode("<<<", $agent_raw) as $section) {
list($section, $data) = explode(">>>", $section);
list($sa, $sb, $sc) = explode("-", $section, 3);
## Compatibility with versions of scripts with and without app-
## Disabled for DRBD because it falsely detects the check_mk output
if ($section == "apache") {
示例13: htmlspecialchars
$key = $value[2];
$val = htmlspecialchars(stripslashes($pdef[$plkp[$key]]));
if ($value[1]) {
$checked = $val ? ' checked' : '';
}
eval('$opt="' . addslashes($templates[$value[1]][1]) . ($value[1] == 'tf' ? '' : '<br />') . '";');
if ($value[1] != 'hidden') {
tr($value[0], " {$opt} {$value['4']}", 1);
} else {
echo $opt;
}
}
}
}
end_table();
?>
<br />
<center>
<input name="action" type="hidden" value="submit" readonly>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Reset">
</center>
</form>
<?php
end_frame();
end_main_frame();
$pgt = utime() - $pgs;
echo "<center>Page Generated in {$pgt} Seconds</center>";
stdfoot();
die;
示例14: graph_error
}
} else {
#$rrd_options .= " HRULE:0#999999";
if ($no_file) {
if ($width < 200) {
graph_error("无RRD");
} else {
graph_error("未找到 RRD数据文件");
}
} elseif (isset($vars['command_only']) && $vars['command_only'] == TRUE) {
$graph_start = utime();
$return = rrdtool_graph($graphfile, $rrd_options);
$graph_end = utime();
$graph_run = $graph_end - $graph_start;
$graph_time = substr($graph_run, 0, 5);
$total_end = utime();
$total_run = $total_end - $total_start;
$total_time = substr($total_run, 0, 5);
unlink($graphfile);
$graph_return['total_time'] = $total_time;
$graph_return['rrdtool_time'] = $graph_time;
$graph_return['cmd'] = "rrdtool graph {$graphfile} {$rrd_options}";
} else {
if ($rrd_options) {
rrdtool_graph($graphfile, $rrd_options);
if ($debug) {
echo $rrd_cmd;
}
if (is_file($graphfile)) {
if ($vars['image_data_uri'] == TRUE) {
$image_data_uri = data_uri($graphfile, 'image/png');
示例15: discover_device
function discover_device($device, $options = null)
{
global $config, $valid;
$valid = array();
// Reset $valid array
$attribs = get_dev_attribs($device['device_id']);
$device_start = utime();
// Start counting device poll time
echo $device['hostname'] . ' ' . $device['device_id'] . ' ' . $device['os'] . ' ';
if ($device['os'] == 'generic') {
// verify if OS has changed from generic
$device['os'] = getHostOS($device);
if ($device['os'] != 'generic') {
echo "\nDevice os was updated to " . $device['os'] . '!';
dbUpdate(array('os' => $device['os']), 'devices', '`device_id` = ?', array($device['device_id']));
}
}
if ($config['os'][$device['os']]['group']) {
$device['os_group'] = $config['os'][$device['os']]['group'];
echo ' (' . $device['os_group'] . ')';
}
echo "\n";
// If we've specified modules, use them, else walk the modules array
if ($options['m']) {
foreach (explode(',', $options['m']) as $module) {
if (is_file("includes/discovery/{$module}.inc.php")) {
include "includes/discovery/{$module}.inc.php";
}
}
} else {
foreach ($config['discovery_modules'] as $module => $module_status) {
if ($attribs['discover_' . $module] || $module_status && !isset($attribs['discover_' . $module])) {
include 'includes/discovery/' . $module . '.inc.php';
} else {
if (isset($attribs['discover_' . $module]) && $attribs['discover_' . $module] == '0') {
echo "Module [ {$module} ] disabled on host.\n";
} else {
echo "Module [ {$module} ] disabled globally.\n";
}
}
}
}
// Set type to a predefined type for the OS if it's not already set
if ($device['type'] == 'unknown' || $device['type'] == '') {
if ($config['os'][$device['os']]['type']) {
$device['type'] = $config['os'][$device['os']]['type'];
}
}
$device_end = utime();
$device_run = $device_end - $device_start;
$device_time = substr($device_run, 0, 5);
dbUpdate(array('last_discovered' => array('NOW()'), 'type' => $device['type'], 'last_discovered_timetaken' => $device_time), 'devices', '`device_id` = ?', array($device['device_id']));
echo "Discovered in {$device_time} seconds\n";
global $discovered_devices;
echo "\n";
$discovered_devices++;
}