本文整理汇总了PHP中log_event函数的典型用法代码示例。如果您正苦于以下问题:PHP log_event函数的具体用法?PHP log_event怎么用?PHP log_event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log_event函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete_note
function delete_note($noteid)
{
$db = new DbConn();
$result = $db->fetch('select userid from notes where id = ?');
if ($result) {
$db->exec('delete from notes where id = ?', $noteid);
log_event(LOG_NOTE_DELETED, $result->userid, $noteid);
}
}
示例2: run_sql
function run_sql($query)
{
global $dblog;
log_event($query, $dblog);
$tmp = mysql_query($query) or die("Error in query:" . $query . " " . mysql_error());
return $tmp;
}
示例3: update
function update()
{
$this->load->helper('html2text');
$id = $this->input->post('id');
$subject = $this->input->post('subject');
$htmlbody = $this->input->post('htmlbody');
$textbody = html_to_plaintext($htmlbody);
$attachments = $this->input->post('attachment');
$db = new DbConn();
if (!$id) {
// New template
$db->exec('insert into mail_templates () values ()');
$id = $db->last_insert_id();
}
$rows = $db->exec('insert into mail_template_versions (templateid, subject, html, plaintext, datecreated, creator)
values (?, ?, ?, ?, ?, ?)', (int) $id, $subject, $htmlbody, $textbody, date_create(), $this->admin->id());
if ($rows != 1) {
throw new RuntimeException("Insertion failed!");
}
$newId = $db->last_insert_id();
// process attachments
if ($attachments) {
foreach ($attachments as $attachId) {
$attachId = (int) $attachId;
$db->exec('insert into templatevers_to_attachments (templateverid, attachmentid) values (?, ?)', $newId, $attachId);
}
}
$template = get_mail_template($id);
$role = $template ? $template->role : '(unknown)';
log_event(LOG_MAIL_TEMPLATE_EDITED, NULL, $role);
redirect("admin/emails/index/{$id}");
}
示例4: exitFail
/**
* Script finished with errors
*/
function exitFail($error, $exit)
{
echo "1;" . $error;
log_event("ERROR", $error);
if ($exit) {
exit;
}
}
示例5: discover_service
function discover_service($device, $service)
{
if (!dbFetchCell('SELECT COUNT(service_id) FROM `services` WHERE `service_type`= ? AND `device_id` = ?', array($service, $device['device_id']))) {
add_service($device, $service, "(Auto discovered) {$service}");
log_event('Autodiscovered service: type ' . mres($service), $device, 'service');
echo '+';
}
echo "{$service} ";
}
示例6: discover_service
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage poller
* @copyright (C) 2006-2014 Adam Armstrong
*
*/
function discover_service($device, $service)
{
if (!dbFetchCell("SELECT COUNT(service_id) FROM `services` WHERE `service_type`= ? AND `device_id` = ?", array($service, $device['device_id']))) {
add_service($device, $service, "(自动发现) {$service}");
log_event("自动发现服务: 类型 {$service}", $device, 'service');
echo "+";
}
echo "{$service} ";
}
示例7: login
function login()
{
$this->_logout();
$email = $this->input->post('login_email');
$password = $this->input->post('login_password');
$user = FALSE;
if (!($email === FALSE || $password === FALSE)) {
$user = get_user_by_credentials($email, $password);
}
if (!$user) {
$errmsg = 'Sorry, unrecognized e-mail or incorrect password.';
$this->load->view('header');
$this->load->view('index', array('login_error' => $errmsg));
$this->load->view('footer');
} else {
log_event(LOG_USER_LOGIN, $user->id);
$this->session->set_userdata('userid', $user->id);
// TODO: Pick up where user left off, not on page 1
redirect('welcome/dispatch');
}
}
示例8: log_action
function log_action($op, $user, $agg, $slice = NULL, $rspec = NULL, $slice_id = NULL)
{
$log_url = get_first_service_of_type(SR_SERVICE_TYPE::LOGGING_SERVICE);
$user_id = $user->account_id;
if (!is_array($agg)) {
$aggs[] = $agg;
} else {
$aggs = $agg;
}
foreach ($aggs as $am) {
$attributes['aggregate'] = $am;
$msg = "{$op} at {$am}";
if ($slice) {
$msg .= " on {$slice}";
$slice_attributes = get_attribute_for_context(CS_CONTEXT_TYPE::SLICE, $slice_id);
$attributes = array_merge($attributes, $slice_attributes);
}
if ($rspec) {
$attributes['rspec'] = $rspec;
}
$result = log_event($log_url, $user, $msg, $attributes);
}
}
示例9: elseif
} elseif (isset($data['ipNetToMediaPhysAddress'])) {
$raw_mac = $data['ipNetToMediaPhysAddress'];
list($if, $ip) = explode('.', $ip, 2);
$ipv = 'ipv4';
}
$interface = get_port_by_index_cache($device['device_id'], $if);
$port_id = $interface['port_id'];
if (!empty($ip) && $ipv === 'ipv4' && $raw_mac != '0:0:0:0:0:0' && !isset($arp_table[$port_id][$ip])) {
$mac = implode(array_map('zeropad', explode(':', $raw_mac)));
$arp_table[$port_id][$ip] = $mac;
$index = array_search($ip, $ipv4_addresses);
if ($index !== false) {
$old_mac = $existing_data[$index]['mac_address'];
if ($mac != $old_mac && $mac != '') {
d_echo("Changed mac address for {$ip} from {$old_mac} to {$mac}\n");
log_event("MAC change: {$ip} : " . mac_clean_to_readable($old_mac) . ' -> ' . mac_clean_to_readable($mac), $device, 'interface', $port_id);
dbUpdate(array('mac_address' => $mac), 'ipv4_mac', 'port_id=? AND ipv4_address=? AND context_name=?', array($port_id, $ip, $context));
}
d_echo(null, '.');
} elseif (isset($interface['port_id'])) {
d_echo(null, '+');
$insert_data[] = array('port_id' => $port_id, 'mac_address' => $mac, 'ipv4_address' => $ip, 'context_name' => $context);
}
}
}
// add new entries
if (!empty($insert_data)) {
dbBulkInsert($insert_data, 'ipv4_mac');
}
// remove stale entries
foreach ($existing_data as $entry) {
示例10: renamehost
function renamehost($id, $new, $source = 'console')
{
global $config;
// FIXME does not check if destination exists!
$host = dbFetchCell("SELECT `hostname` FROM `devices` WHERE `device_id` = ?", array($id));
if (rename($config['rrd_dir'] . "/{$host}", $config['rrd_dir'] . "/{$new}") === TRUE) {
dbUpdate(array('hostname' => $new), 'devices', 'device_id=?', array($id));
log_event("Hostname changed -> {$new} ({$source})", $id, 'system');
} else {
echo "Renaming of {$host} failed\n";
log_event("Renaming of {$host} failed", $id, 'system');
}
}
示例11: del_dev_attrib
} else {
del_dev_attrib($device, 'override_sysLocation_bool');
}
if (isset($override_sysLocation_string)) {
set_dev_attrib($device, 'override_sysLocation_string', $override_sysLocation_string);
}
# FIXME needs more sanity checking! and better feedback
# FIXME -- update location too? Need to trigger geolocation!
$param = array('purpose' => $vars['descr'], 'type' => $vars['type'], 'ignore' => $vars['ignore'], 'disabled' => $vars['disabled']);
$rows_updated = dbUpdate($param, 'devices', '`device_id` = ?', array($device['device_id']));
if ($rows_updated > 0 || $updated) {
if ((bool) $vars['ignore'] != (bool) $device['ignore']) {
log_event('设备 ' . ((bool) $vars['ignore'] ? 'ignored' : 'attended') . ': ' . $device['hostname'], $device['device_id'], 'device', $device['device_id'], 5);
}
if ((bool) $vars['disabled'] != (bool) $device['disabled']) {
log_event('设备 ' . ((bool) $vars['disabled'] ? 'disabled' : 'enabled') . ': ' . $device['hostname'], $device['device_id'], 'device');
}
$update_message = "设备更新的记录.";
if ($updated == 2) {
$update_message .= " 请注意, 最新的系统位置字符串将在轮询后可见.";
}
$updated = 1;
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
} elseif ($rows_updated = '-1') {
$update_message = "装置记录不变. 没有更新的必要.";
$updated = -1;
} else {
$update_message = "装置的记录更新错误.";
}
} else {
include "includes/error-no-perm.inc.php";
示例12: d_echo
$stp['rootBridge'] = '0';
}
d_echo($stp);
if ($stp_raw[0]['version'] == '3') {
echo "RSTP ";
} else {
echo "STP ";
}
if (!$stp_db['bridgeAddress'] && $stp['bridgeAddress']) {
dbInsert($stp, 'stp');
log_event('STP added, bridge address: ' . $stp['bridgeAddress'], $device, 'stp');
echo '+';
}
if ($stp_db['bridgeAddress'] && !$stp['bridgeAddress']) {
dbDelete('stp', 'device_id = ?', array($device['device_id']));
log_event('STP removed', $device, 'stp');
echo '-';
}
// STP port related stuff
foreach ($stp_raw as $port => $value) {
if ($port) {
// $stp_raw[0] ist not port related so we skip this one
$stp_port = array('priority' => $stp_raw[$port]['dot1dStpPortPriority'], 'state' => $stp_raw[$port]['dot1dStpPortState'], 'enable' => $stp_raw[$port]['dot1dStpPortEnable'], 'pathCost' => $stp_raw[$port]['dot1dStpPortPathCost'], 'designatedCost' => $stp_raw[$port]['dot1dStpPortDesignatedCost'], 'designatedPort' => $stp_raw[$port]['dot1dStpPortDesignatedPort'], 'forwardTransitions' => $stp_raw[$port]['dot1dStpPortForwardTransitions']);
// set device binding
$stp_port['device_id'] = $device['device_id'];
// set port binding
$stp_port['port_id'] = dbFetchCell('SELECT port_id FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $stp_raw[$port]['dot1dStpPort']));
$dr = str_replace(array(' ', ':', '-'), '', strtolower($stp_raw[$port]['dot1dStpPortDesignatedRoot']));
$dr = substr($dr, -12);
//remove first two octets
$stp_port['designatedRoot'] = $dr;
示例13: poll_device
function poll_device($device, $options)
{
global $config, $device, $polled_devices, $db_stats, $memcache;
$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();
$update_array = array();
$host_rrd = $config['rrd_dir'] . '/' . $device['hostname'];
if (!is_dir($host_rrd)) {
mkdir($host_rrd);
echo "Created directory : {$host_rrd}\n";
}
$address_family = snmpTransportToAddressFamily($device['transport']);
$ping_response = isPingable($device['hostname'], $address_family, $attribs);
$device_perf = $ping_response['db'];
$device_perf['device_id'] = $device['device_id'];
$device_perf['timestamp'] = array('NOW()');
if (can_ping_device($attribs) === true && is_array($device_perf)) {
dbInsert($device_perf, 'device_perf');
}
$device['pingable'] = $ping_response['result'];
$ping_time = $ping_response['last_ping_timetaken'];
$response = array();
$status_reason = '';
if ($device['pingable']) {
$device['snmpable'] = isSNMPable($device);
if ($device['snmpable']) {
$status = '1';
$response['status_reason'] = '';
} else {
echo 'SNMP Unreachable';
$status = '0';
$response['status_reason'] = 'snmp';
}
} else {
echo 'Unpingable';
$status = '0';
$response['status_reason'] = 'icmp';
}
if ($device['status'] != $status) {
$poll_update .= $poll_separator . "`status` = '{$status}'";
$poll_separator = ', ';
dbUpdate(array('status' => $status, 'status_reason' => $response['status_reason']), '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'), $device, $status == '1' ? 'up' : 'down');
}
if ($status == '1') {
$graphs = array();
$oldgraphs = array();
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])) {
// TODO per-module polling stats
include 'includes/polling/' . $module . '.inc.php';
} else {
if (isset($attribs['poll_' . $module]) && $attribs['poll_' . $module] == '0') {
echo "Module [ {$module} ] disabled on host.\n";
} else {
echo "Module [ {$module} ] disabled globally.\n";
}
}
}
}
//end if
if (!$options['m']) {
// FIXME EVENTLOGGING -- MAKE IT SO WE DO THIS PER-MODULE?
// This code cycles through the graphs already known in the database and the ones we've defined as being polled here
// If there any don't match, they're added/deleted from the database.
// Ideally we should hold graphs for xx days/weeks/polls so that we don't needlessly hide information.
foreach (dbFetch('SELECT `graph` FROM `device_graphs` WHERE `device_id` = ?', array($device['device_id'])) as $graph) {
if (isset($graphs[$graph['graph']])) {
$oldgraphs[$graph['graph']] = true;
} else {
dbDelete('device_graphs', '`device_id` = ? AND `graph` = ?', array($device['device_id'], $graph['graph']));
}
}
foreach ($graphs as $graph => $value) {
if (!isset($oldgraphs[$graph])) {
echo '+';
dbInsert(array('device_id' => $device['device_id'], 'graph' => $graph), 'device_graphs');
}
echo $graph . ' ';
//.........这里部分代码省略.........
示例14: print_cli_data
print_cli_data("Asset", $asset_tag ?: "%b<empty>%n");
echo PHP_EOL;
foreach ($os_additional_info as $header => $entries) {
print_cli_heading($header, 3);
foreach ($entries as $field => $entry) {
print_cli_data($field, $entry, 3);
}
echo PHP_EOL;
}
// Fields notified in event log
$update_fields = array('version', 'features', 'hardware', 'serial', 'kernel', 'distro', 'distro_ver', 'arch', 'asset_tag');
// Log changed variables
foreach ($update_fields as $field) {
if (isset(${$field})) {
${$field} = snmp_fix_string(${$field});
}
// Fix unprintable chars
if ((isset(${$field}) || strlen($device[$field])) && ${$field} != $device[$field]) {
$update_array[$field] = ${$field};
log_event(nicecase($field) . " -> " . $update_array[$field], $device, 'device', $device['device_id']);
}
}
// Here additional fields, change only if not set already
foreach (array('type', 'icon') as $field) {
if (isset(${$field}) && ($device[$field] == "unknown" || $device[$field] == '' || !isset($device[$field]) || !strlen($device[$field]))) {
$update_array[$field] = ${$field};
log_event(nicecase($field) . " -> " . $update_array[$field], $device, 'device', $device['device_id']);
}
}
unset($entPhysical, $oids, $hw, $os_additional_info);
// EOF
示例15: do_sendit
/**
* @param $userid
* @param $headers
* @param $table_csv
* @param array $fields
* @param $parent_chkd_flds
* @param $export_file_name
* @param $debug
* @param null $comment
* @param array $to
*/
public static function do_sendit($userid, $headers, $table_csv, $fields = array(), $parent_chkd_flds, $export_file_name, $comment = null, $to = array(), $debug)
{
global $project_id, $user_rights, $app_title, $lang, $redcap_version; // we could use the global $userid, but we need control of it for setting the user as [CRON], so this is passed in args.
$return_val = false;
$export_type = 0; // this puts all files generated here in the Data Export category in the File Repository
$today = date("Y-m-d_Hi"); //get today for filename
$projTitleShort = substr(str_replace(" ", "", ucwords(preg_replace("/[^a-zA-Z0-9 ]/", "", html_entity_decode($app_title, ENT_QUOTES)))), 0, 20); // shortened project title for filename
$originalFilename = $projTitleShort . "_" . $export_file_name . "_DATA_" . $today . ".csv"; // name the file for storage
$today = date("Y-m-d-H-i-s"); // get today for comment, subsequent processing as needed
$docs_comment_WH = $export_type ? "Data export file created by $userid on $today" : fix_case($export_file_name) . " file created by $userid on $today. $comment"; // unused, but I keep it around just in case
/**
* setup vars for value export logging
*/
$chkd_fields = implode(',', $fields);
/**
* turn on/off exporting per user rights
*/
if (($user_rights['data_export_tool'] || $userid == '[CRON]') && !$debug) {
$table_csv = addBOMtoUTF8($headers . $table_csv);
/**
* Store the file in the file system and log the activity, handle if error
*/
if (!DataExport::storeExportFile($originalFilename, $table_csv, true)) {
log_event("", "redcap_data", "data_export", "", str_replace("'", "", $chkd_fields) . (($parent_chkd_flds == "") ? "" : ", " . str_replace("'", "", $parent_chkd_flds)), "Data Export Failed");
} else {
log_event("", "redcap_data", "data_export", "", str_replace("'", "", $chkd_fields) . (($parent_chkd_flds == "") ? "" : ", " . str_replace("'", "", $parent_chkd_flds)), "Export data for SendIt");
/**
* email file link and download password in two separate emails via REDCap SendIt
*/
$file_info_sql = db_query("SELECT docs_id, docs_size, docs_type FROM redcap_docs WHERE project_id = $project_id ORDER BY docs_id DESC LIMIT 1"); // get required info about the file we just created
if ($file_info_sql) {
$docs_id = db_result($file_info_sql, 0, 'docs_id');
$docs_size = db_result($file_info_sql, 0, 'docs_size');
$docs_type = db_result($file_info_sql, 0, 'docs_type');
}
$yourName = 'PRIORITIZE REDCap';
$expireDays = 3; // set the SendIt to expire in this many days
/**
* $file_location:
* 1 = ephemeral, will be deleted on $expireDate
* 2 = export file, visible only to rights in file repository
*/
$file_location = 2;
$send = 1; // always send download confirmation
$expireDate = date('Y-m-d H:i:s', strtotime("+$expireDays days"));
$expireYear = substr($expireDate, 0, 4);
$expireMonth = substr($expireDate, 5, 2);
$expireDay = substr($expireDate, 8, 2);
$expireHour = substr($expireDate, 11, 2);
$expireMin = substr($expireDate, 14, 2);
// Add entry to sendit_docs table
$query = "INSERT INTO redcap_sendit_docs (doc_name, doc_orig_name, doc_type, doc_size, send_confirmation, expire_date, username,
location, docs_id, date_added)
VALUES ('$originalFilename', '" . prep($originalFilename) . "', '$docs_type', '$docs_size', $send, '$expireDate', '" . prep($userid) . "',
$file_location, $docs_id, '" . NOW . "')";
db_query($query);
$newId = db_insert_id();
$logDescrip = "Send file from file repository (Send-It)";
log_event($query, "redcap_sendit_docs", "MANAGE", $newId, "document_id = $newId", $logDescrip);
// Set email subject
$subject = "[PRIORITIZE] " . $comment;
$subject = html_entity_decode($subject, ENT_QUOTES);
// Set email From address
$from = array('Ken Bergquist' => 'kbergqui@email.unc.edu');
// Begin set up of email to send to recipients
$email = new Message();
foreach ($from as $name => $address) {
$email->setFrom($address);
$email->setFromName($name);
}
$email->setSubject($subject);
// Loop through each recipient and send email
foreach ($to as $name => $address) {
// If a non-blank email address
if (trim($address) != '') {
// create key for unique url
$key = strtoupper(substr(uniqid(md5(mt_rand())), 0, 25));
// create password
$pwd = generateRandomHash(8, false, true);
$query = "INSERT INTO redcap_sendit_recipients (email_address, sent_confirmation, download_date, download_count, document_id, guid, pwd)
VALUES ('$address', 0, NULL, 0, $newId, '$key', '" . md5($pwd) . "')";
//.........这里部分代码省略.........