本文整理汇总了PHP中define_syslog_variables函数的典型用法代码示例。如果您正苦于以下问题:PHP define_syslog_variables函数的具体用法?PHP define_syslog_variables怎么用?PHP define_syslog_variables使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了define_syslog_variables函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logMessage
function logMessage($type, $level, $message)
{
global $debug;
global $use_syslog;
if ($use_syslog) {
define_syslog_variables();
if ($debug) {
}
if ($level == 0) {
$s_level = LOG_ERR;
} else {
if ($level == 1) {
$s_level = LOG_WARNING;
} else {
if ($level == 2) {
$s_level = LOG_INFO;
} else {
if ($level == 3) {
$s_level = LOG_DEBUG;
} else {
$s_level = LOG_ERR;
}
}
}
}
$s_message = $type . " " . $message;
openlog("restbot", LOG_PID, LOG_DAEMON);
syslog($s_level, $s_message);
closelog();
}
}
示例2: JabberAuth
function JabberAuth()
{
@define_syslog_variables();
@openlog("pipe-auth", LOG_NDELAY, LOG_SYSLOG);
if ($this->debug) {
@error_reporting(E_ALL);
@ini_set("log_errors", "1");
@ini_set("error_log", $this->debugfile);
}
$this->logg("Starting pipe-auth ...");
// We notice that it's starting ...
$this->openstd();
}
示例3: alert_action_syslog
function alert_action_syslog($data)
{
global $NATS;
$NATS->Event("Syslog AA Called for " . $data['name'], 10, "Syslog", "Start");
if ($data['name'] != "_syslog") {
return false;
}
$lvl = LOG_ERR;
define_syslog_variables();
openlog("FreeNATS", LOG_PID | LOG_PERROR, LOG_LOCAL0);
if (syslog($lvl, $data['data']) === false) {
$NATS->Event("Syslog Failed for " . $data['data'], 2, "Syslog", "Write");
} else {
$NATS->Event("Syslog Succeeded for " . $data['data'], 10, "Syslog", "Write");
}
closelog();
return true;
}
示例4: log
/**
* Adds an entry to the log.
*
* Adds an entry to the log with Linux style log format.
* Possible $level constants (can also be combined with "|"s)
* SMARTIRC_DEBUG_NONE
* SMARTIRC_DEBUG_NOTICE
* SMARTIRC_DEBUG_CONNECTION
* SMARTIRC_DEBUG_SOCKET
* SMARTIRC_DEBUG_IRCMESSAGES
* SMARTIRC_DEBUG_MESSAGETYPES
* SMARTIRC_DEBUG_ACTIONHANDLER
* SMARTIRC_DEBUG_TIMEHANDLER
* SMARTIRC_DEBUG_MESSAGEHANDLER
* SMARTIRC_DEBUG_CHANNELSYNCING
* SMARTIRC_DEBUG_MODULES
* SMARTIRC_DEBUG_USERSYNCING
* SMARTIRC_DEBUG_ALL
*
* @see SMARTIRC_DEBUG_NOTICE
* @param integer $level bit constants (SMARTIRC_DEBUG_*)
* @param string $entry the new log entry
* @return void
* @access public
*/
function log($level, $entry, $file = null, $line = null)
{
// prechecks
if (!is_integer($level) || !($level & SMARTIRC_DEBUG_ALL)) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: invalid log level passed to log() (' . $level . ')', __FILE__, __LINE__);
return;
}
if (!($level & $this->_debug) || $this->_logdestination == SMARTIRC_NONE) {
return;
}
if (substr($entry, -1) != "\n") {
$entry .= "\n";
}
if ($file !== null && $line !== null) {
$file = basename($file);
$entry = $file . '(' . $line . ') ' . $entry;
} else {
$entry = 'unknown(0) ' . $entry;
}
$formatedentry = date('M d H:i:s ') . $entry;
switch ($this->_logdestination) {
case SMARTIRC_STDOUT:
echo $formatedentry;
flush();
break;
case SMARTIRC_BROWSEROUT:
echo '<pre>' . htmlentities($formatedentry) . '</pre>';
break;
case SMARTIRC_FILE:
if (!is_resource($this->_logfilefp)) {
if ($this->_logfilefp === null) {
// we reconncted and don't want to destroy the old log entries
$this->_logfilefp = fopen($this->_logfile, 'a');
} else {
$this->_logfilefp = fopen($this->_logfile, 'w');
}
}
fwrite($this->_logfilefp, $formatedentry);
fflush($this->_logfilefp);
break;
case SMARTIRC_SYSLOG:
define_syslog_variables();
if (!is_int($this->_logfilefp)) {
$this->_logfilefp = openlog('Net_SmartIRC', LOG_NDELAY, LOG_DAEMON);
}
syslog(LOG_INFO, $entry);
break;
}
}
示例5: LOGLevel
function LOGLevel($msg, $level, $dodb = true)
{
$msga = sanitizeText(str_replace("\n", " ", $msg));
$msg = now() . ": ";
if (!get_cfg_var('define_syslog_variables')) {
if (function_exists('define_syslog_variables')) {
define_syslog_variables();
}
}
$prior = LOG_CRIT;
switch ($level) {
case 0:
$msg .= "ERROR: ";
$type = "error";
$prior = LOG_ERR;
break;
case 1:
$msg .= "WARN: ";
$type = "warn";
$prior = LOG_WARNING;
break;
case 2:
$msg .= "INFO: ";
$type = "info";
$prior = LOG_INFO;
break;
case 3:
$msg .= "DEBUG: ";
$type = "debug";
$prior = LOG_DEBUG;
break;
}
$msg .= getIPHost() . ": " . $msga;
openlog("BOCA", LOG_ODELAY, LOG_USER);
syslog($prior, $msg);
closelog();
if ($dodb && isset($_SESSION["usertable"])) {
DBNewLog($_SESSION["usertable"]["contestnumber"], $_SESSION["usertable"]["usersitenumber"], $_SESSION["usertable"]["usernumber"], $type, getIP(), $msga, "");
}
}
示例6: activateOptions
function activateOptions()
{
define_syslog_variables();
$this->closed = false;
}
示例7: foreach
foreach ($openlog_facilities as $facility) {
openlog("PCC_TEST", $option, $facility);
foreach ($syslog_priorities as $priority) {
necho(380 + ($count / 1000), "option=$option, facility=$facility, priority=$priority, count=$count");
syslog($priority, "$id: option=$option, facility=$facility, priority=$priority");
}
closelog();
}
}
*/
necho(400, "log output: ");
if (posix_geteuid() == 0) {
system("tail -5000 `find /var/log -type f` | grep -a {$id} | sed s/..:..:..//g | sed 's/PCC_TEST\\[.*\\]/PCC_TEST/' | sed 's/{$id}/PCC_TEST/' | sort");
}
// define_syslog_variables
necho(410, define_syslog_variables());
//} // winnt
// gethostbynamel
necho(520, gethostbynamel('www.roadsend.com'));
necho(530, gethostbynamel('tenkan.org'));
necho(540, gethostbynamel('localhost'));
// getmxrr
if (PHP_OS != 'WINNT') {
$mxhosts = array();
$weights = array();
necho(550, getmxrr('roadsend.com', &$mxhosts, &$weights));
sort($mxhosts);
sort($weights);
necho(560, "mxhosts: ");
print_r($mxhosts);
necho(570, "weights: ");
示例8: cacti_log
function cacti_log($string, $output = false, $environ = "CMDPHP") {
global $config;
/* fill in the current date for printing in the log */
$date = date("m/d/Y h:i:s A");
/* determine how to log data */
$logdestination = read_config_option("log_destination");
$logfile = read_config_option("path_cactilog");
/* format the message */
if (($environ != "SYSTEM") && ($environ != "EXPORT") && ($environ != "RECACHE")) {
$message = "$date - " . $environ . ": Poller[0] " . $string . "\n";
}else {
$message = "$date - " . $environ . " " . $string . "\n";
}
/* Log to Logfile */
if ((($logdestination == 1) || ($logdestination == 2)) && (read_config_option("log_verbosity") != POLLER_VERBOSITY_NONE)) {
if ($logfile == "") {
$logfile = $config["base_path"] . "/log/cacti.log";
}
/* echo the data to the log (append) */
$fp = @fopen($logfile, "a");
if ($fp) {
@fwrite($fp, $message);
fclose($fp);
}
}
/* Log to Syslog/Eventlog */
/* Syslog is currently Unstable in Win32 */
if (($logdestination == 2) || ($logdestination == 3)) {
$log_type = "";
if (substr_count($string,"ERROR:"))
$log_type = "err";
else if (substr_count($string,"WARNING:"))
$log_type = "warn";
else if (substr_count($string,"STATS:"))
$log_type = "stat";
else if (substr_count($string,"NOTICE:"))
$log_type = "note";
if (strlen($log_type)) {
define_syslog_variables();
if ($config["cacti_server_os"] == "win32")
openlog("Cacti", LOG_NDELAY | LOG_PID, LOG_USER);
else
openlog("Cacti", LOG_NDELAY | LOG_PID, LOG_SYSLOG);
if (($log_type == "err") && (read_config_option("log_perror"))) {
syslog(LOG_CRIT, $environ . ": " . $string);
}
if (($log_type == "warn") && (read_config_option("log_pwarn"))) {
syslog(LOG_WARNING, $environ . ": " . $string);
}
if ((($log_type == "stat") || ($log_type == "note")) && (read_config_option("log_pstats"))) {
syslog(LOG_INFO, $environ . ": " . $string);
}
closelog();
}
}
/* print output to standard out if required */
if (($output == true) && (isset($_SERVER["argv"][0]))){
print $message;
}
}
示例9: initSysLog
/**
* Init system error log.
*
* @return void
* @see sysLog()
*/
public static function initSysLog()
{
global $TYPO3_CONF_VARS;
// for CLI logging name is <fqdn-hostname>:<TYPO3-path>
if (defined('TYPO3_cliMode') && TYPO3_cliMode) {
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] = t3lib_div::getHostname($requestHost = FALSE) . ':' . PATH_site;
} else {
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
}
// init custom logging
if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'])) {
$params = array('initLog' => TRUE);
$fakeThis = FALSE;
foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'] as $hookMethod) {
t3lib_div::callUserFunction($hookMethod, $params, $fakeThis);
}
}
// init TYPO3 logging
foreach (explode(';', $TYPO3_CONF_VARS['SYS']['systemLog'], 2) as $log) {
list($type, $destination) = explode(',', $log, 3);
if ($type == 'syslog') {
define_syslog_variables();
if (TYPO3_OS == 'WIN') {
$facility = LOG_USER;
} else {
$facility = constant('LOG_' . strtoupper($destination));
}
openlog($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'], LOG_ODELAY, $facility);
}
}
$TYPO3_CONF_VARS['SYS']['systemLogLevel'] = t3lib_div::intInRange($TYPO3_CONF_VARS['SYS']['systemLogLevel'], 0, 4);
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogInit'] = TRUE;
}
示例10: thold_config_settings
function thold_config_settings()
{
global $tabs, $settings, $item_rows, $config;
if (isset($_SERVER['PHP_SELF']) && basename($_SERVER['PHP_SELF']) != 'settings.php') {
return;
}
include_once "./plugins/thold/thold_functions.php";
define_syslog_variables();
if ($config["cacti_server_os"] == "unix") {
$syslog_facil_array = array(LOG_AUTH => 'Auth', LOG_AUTHPRIV => 'Auth Private', LOG_CRON => 'Cron', LOG_DAEMON => 'Daemon', LOG_KERN => 'Kernel', LOG_LOCAL0 => 'Local 0', LOG_LOCAL1 => 'Local 1', LOG_LOCAL2 => 'Local 2', LOG_LOCAL3 => 'Local 3', LOG_LOCAL4 => 'Local 4', LOG_LOCAL5 => 'Local 5', LOG_LOCAL6 => 'Local 6', LOG_LOCAL7 => 'Local 7', LOG_LPR => 'LPR', LOG_MAIL => 'Mail', LOG_NEWS => 'News', LOG_SYSLOG => 'Syslog', LOG_USER => 'User', LOG_UUCP => 'UUCP');
$default_facility = LOG_DAEMON;
} else {
$syslog_facil_array = array(LOG_USER => 'User');
$default_facility = LOG_USER;
}
$tabs['alerts'] = 'Thresholds';
$settings['alerts'] = array('general_header' => array('friendly_name' => 'General', 'method' => 'spacer'), 'thold_disable_all' => array('friendly_name' => 'Disable All Thresholds', 'description' => 'Checking this box will disable Alerting on all Thresholds. This can be used when it is necessary to perform maintenance on your network.', 'method' => 'checkbox', 'default' => 'off'), 'thold_disable_legacy' => array('friendly_name' => 'Disable Legacy Notifications', 'description' => 'Checking this box will disable Legacy Alerting on all Thresholds. Legacy Alerting is defined as any Specific Email Alerts not associated with a Notification List.', 'method' => 'checkbox', 'default' => ''), 'thold_filter_default' => array('friendly_name' => 'Default Status', 'description' => 'Default Threshold Filter Status', 'method' => 'drop_array', 'array' => array("-1" => "Any", "0" => "Disabled", "2" => "Enabled", "1" => "Breached", "3" => "Triggered"), 'default' => 20), 'alert_base_url' => array('friendly_name' => 'Base URL', 'description' => 'Cacti base URL', 'method' => 'textbox', 'default' => isset($_SERVER['HTTP_HOST']) && isset($_SERVER['PHP_SELF']) && basename($_SERVER['PHP_SELF']) == 'settings.php' ? 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/' : '', 'max_length' => 255), 'alert_num_rows' => array('friendly_name' => 'Thresholds Per Page', 'description' => 'Number of thresholds to display per page', 'method' => 'drop_array', 'array' => $item_rows, 'default' => 20), 'thold_log_cacti' => array('friendly_name' => 'Log Threshold Breaches', 'description' => 'Enable logging of all Threshold failures to the Cacti Log', 'method' => 'checkbox', 'default' => 'off'), 'thold_log_changes' => array('friendly_name' => 'Log Threshold Changes', 'description' => 'Enable logging of all Threshold changes to the Cacti Log', 'method' => 'checkbox', 'default' => 'off'), 'thold_log_debug' => array('friendly_name' => 'Debug Log', 'description' => 'Enable logging of debug messages with Thold', 'method' => 'checkbox', 'default' => 'off'), 'thold_alerting_header' => array('friendly_name' => 'Default Alerting Options', 'method' => 'spacer'), 'alert_exempt' => array('friendly_name' => 'Weekend exemptions', 'description' => 'If this is checked, thold will not run on weekends.', 'method' => 'checkbox'), 'alert_trigger' => array('friendly_name' => 'Default Trigger Count', 'description' => 'Default number of consecutive times the Data Source must be in breach of the Threshold for an Alert to be raised', 'method' => 'textbox', 'size' => 4, 'max_length' => 4, 'default' => 1), 'alert_repeat' => array('friendly_name' => 'Re-Alerting', 'description' => 'Repeat Alert after specified number of poller cycles.', 'method' => 'textbox', 'size' => 4, 'max_length' => 4, 'default' => 12), 'alert_syslog' => array('friendly_name' => 'Syslog Support', 'description' => 'These messages will be sent to your local syslog. If you would like these sent to a remote box, you must setup your local syslog to do so', 'method' => 'checkbox'), 'thold_syslog_level' => array('friendly_name' => 'Syslog Level', 'description' => 'This is the priority level that your syslog messages will be sent as.', 'method' => 'drop_array', 'default' => LOG_WARNING, 'array' => array(LOG_EMERG => 'Emergency', LOG_ALERT => 'Alert', LOG_CRIT => 'Critical', LOG_ERR => 'Error', LOG_WARNING => 'Warning', LOG_NOTICE => 'Notice', LOG_INFO => 'Info', LOG_DEBUG => 'Debug')), 'thold_syslog_facility' => array('friendly_name' => 'Syslog Facility', 'description' => 'This is the facility level that your syslog messages will be sent as.', 'method' => 'drop_array', 'default' => $default_facility, 'array' => $syslog_facil_array), 'thold_email_header' => array('friendly_name' => 'Emailing Options', 'method' => 'spacer'), 'thold_email_prio' => array('friendly_name' => 'Send Emails with Urgent Priority', 'description' => 'Allows you to set e-mails with urgent priority', 'method' => 'checkbox', 'default' => 'off'), 'alert_deadnotify' => array('friendly_name' => 'Dead Hosts Notifications', 'description' => 'Enable Dead/Recovering host notification', 'method' => 'checkbox', 'default' => 'on'), 'alert_email' => array('friendly_name' => 'Dead Host Notifications Email', 'description' => 'This is the Email Address that the Dead Host Notifications will be sent to if the Global Notification List is selected.', 'method' => 'textbox', 'size' => 80, 'max_length' => 255), 'thold_down_subject' => array('friendly_name' => 'Down Host Subject', 'description' => 'This is the Email subject that will be used for Down Host Messages.', 'method' => 'textbox', 'size' => 80, 'max_length' => 255, 'default' => 'Host Error: <DESCRIPTION> (<HOSTNAME>) is DOWN'), 'thold_down_text' => array('friendly_name' => 'Down Host Message', 'description' => 'This is the message that will be displayed as the message body of all UP / Down Host Messages (255 Char MAX). HTML is allowed, but will be removed for text only Emails. There are several descriptors that may be used.<br><HOSTNAME> <DESCRIPTION> <UPTIME> <UPTIMETEXT> <DOWNTIME> <MESSAGE> <SUBJECT> <DOWN/UP> <SNMP_HOSTNAME> <SNMP_LOCATION> <SNMP_CONTACT> <SNMP_SYSTEM> <LAST_FAIL> <AVAILABILITY> <TOT_POLL> <FAIL_POLL> <CUR_TIME> <AVG_TIME> <NOTES>', 'method' => 'textarea', 'class' => 'textAreaNotes', 'textarea_rows' => '5', 'textarea_cols' => '80', 'default' => 'System Error : <DESCRIPTION> (<HOSTNAME>) is <DOWN/UP><br>Reason: <MESSAGE><br><br>Average system response : <AVG_TIME> ms<br>System availability: <AVAILABILITY><br>Total Checks Since Clear: <TOT_POLL><br>Total Failed Checks: <FAIL_POLL><br>Last Date Checked DOWN : <LAST_FAIL><br>Host Previously UP for: <DOWNTIME><br>NOTE: <NOTES>'), 'thold_up_subject' => array('friendly_name' => 'Recovering Host Subject', 'description' => 'This is the Email subject that will be used for Recovering Host Messages.', 'method' => 'textbox', 'size' => 80, 'max_length' => 255, 'default' => 'Host Notice: <DESCRIPTION> (<HOSTNAME>) returned from DOWN state'), 'thold_up_text' => array('friendly_name' => 'Recovering Host Message', 'description' => 'This is the message that will be displayed as the message body of all UP / Down Host Messages (255 Char MAX). HTML is allowed, but will be removed for text only Emails. There are several descriptors that may be used.<br><HOSTNAME> <DESCRIPTION> <UPTIME> <UPTIMETEXT> <DOWNTIME> <MESSAGE> <SUBJECT> <DOWN/UP> <SNMP_HOSTNAME> <SNMP_LOCATION> <SNMP_CONTACT> <SNMP_SYSTEM> <LAST_FAIL> <AVAILABILITY> <TOT_POLL> <FAIL_POLL> <CUR_TIME> <AVG_TIME> <NOTES>', 'method' => 'textarea', 'class' => 'textAreaNotes', 'textarea_rows' => '5', 'textarea_cols' => '80', 'default' => '<br>System <DESCRIPTION> (<HOSTNAME>) status: <DOWN/UP><br><br>Current ping response: <CUR_TIME> ms<br>Average system response : <AVG_TIME> ms<br>System availability: <AVAILABILITY><br>Total Checks Since Clear: <TOT_POLL><br>Total Failed Checks: <FAIL_POLL><br>Last Date Checked UP: <LAST_FAIL><br>Host Previously DOWN for: <DOWNTIME><br><br>Snmp Info:<br>Name - <SNMP_HOSTNAME><br>Location - <SNMP_LOCATION><br>Uptime - <UPTIMETEXT> (<UPTIME> ms)<br>System - <SNMP_SYSTEM><br><br>NOTE: <NOTES>'), 'thold_from_email' => array('friendly_name' => 'From Email Address', 'description' => 'This is the Email address that the threshold will appear from.', 'method' => 'textbox', 'default' => read_config_option("settings_from_email"), 'max_length' => 255), 'thold_from_name' => array('friendly_name' => 'From Name', 'description' => 'This is the actual name that the threshold will appear from.', 'method' => 'textbox', 'default' => read_config_option("settings_from_name"), 'max_length' => 255), 'thold_alert_text' => array('friendly_name' => 'Threshold Alert Message', 'description' => 'This is the message that will be displayed at the top of all Threshold Alerts (255 Char MAX). HTML is allowed, but will be removed for text only Emails. There are several descriptors that may be used.<br><DESCRIPTION> <HOSTNAME> <TIME> <URL> <GRAPHID> <CURRENTVALUE> <THRESHOLDNAME> <DSNAME> <SUBJECT> <GRAPH>', 'method' => 'textarea', 'class' => 'textAreaNotes', 'textarea_rows' => '5', 'textarea_cols' => '80', 'default' => 'An Alert has been issued that requires your attention. <br><br><strong>Host</strong>: <DESCRIPTION> (<HOSTNAME>)<br><strong>URL</strong>: <URL><br><strong>Message</strong>: <SUBJECT><br><br><GRAPH>'), 'thold_warning_text' => array('friendly_name' => 'Threshold Warning Message', 'description' => 'This is the message that will be displayed at the top of all threshold warnings (255 Char MAX). HTML is allowed, but will be removed for text only Emails. There are several descriptors that may be used.<br><DESCRIPTION> <HOSTNAME> <TIME> <URL> <GRAPHID> <CURRENTVALUE> <THRESHOLDNAME> <DSNAME> <SUBJECT> <GRAPH>', 'method' => 'textarea', 'class' => 'textAreaNotes', 'textarea_rows' => '5', 'textarea_cols' => '80', 'default' => 'A warning has been issued that requires your attention. <br><br><strong>Host</strong>: <DESCRIPTION> (<HOSTNAME>)<br><strong>URL</strong>: <URL><br><strong>Message</strong>: <SUBJECT><br><br><GRAPH>'), 'thold_send_text_only' => array('friendly_name' => 'Send Alerts as Text', 'description' => 'If checked, this will cause all Alerts to be sent as plain text Emails with no graph. The default is HTML Emails with the graph embedded in the Email.', 'method' => 'checkbox', 'default' => 'off'), 'thold_baseline_header' => array('friendly_name' => 'Default Baseline Settings', 'method' => 'spacer'), 'alert_bl_timerange_def' => array('friendly_name' => 'Baseline Time Range Default', 'description' => 'This is the default value used in creating thresholds or templates.', 'method' => 'drop_array', 'array' => get_reference_types(), 'size' => 12, 'max_length' => 12, 'default' => 86400), 'alert_bl_trigger' => array('friendly_name' => 'Baseline Trigger Count', 'description' => 'Default number of consecutive times the Data Source must be in breach of the calculated Baseline Threshold for an Alert to be raised', 'method' => 'textbox', 'size' => 4, 'max_length' => 4, 'default' => 2), 'alert_bl_percent_def' => array('friendly_name' => 'Baseline Deviation Percentage', 'description' => 'This is the default value used in creating thresholds or templates.', 'method' => 'textbox', 'size' => 3, 'max_length' => 3, 'default' => 20));
}
示例11: make_nrc_file
function make_nrc_file($username, $rand, $unique_list)
{
if (!$username) {
$filename = _NESSUS_STORE . '/' . $rand . ".nrc";
} else {
$filename = _NESSUS_STORE . '/' . $username . '-' . $rand . ".nrc";
}
$fh = fopen($filename, "w");
// do an exclusive lock
if (flock($fh, LOCK_EX)) {
// Write a common header
fwrite($fh, "# Nessus Client Preferences File\n");
// This defines the start of the scanner list
fwrite($fh, "begin(SCANNER_SET)\n");
foreach ($unique_list as $key => $val) {
fwrite($fh, $key . " = " . $val . "\n");
}
fwrite($fh, "end(SCANNER_SET)\n");
// This defines the start of the plugin list
fwrite($fh, "begin(PLUGIN_SET)\n");
foreach ($unique_list as $key => $val) {
fwrite($fh, $key . " = " . $val . "\n");
}
fwrite($fh, "end(PLUGIN_SET)\n");
flock($fh, LOCK_UN);
// release the lock
} else {
define_syslog_variables();
syslog(LOG_WARNING, "Couldn't lock the nessusrc file !");
}
fclose($fh);
chmod($filename, 0777);
return $filename;
}
示例12: thold_cacti_log
function thold_cacti_log($string)
{
global $config;
$environ = 'THOLD';
/* fill in the current date for printing in the log */
$date = date("m/d/Y h:i:s A");
/* determine how to log data */
$logdestination = read_config_option("log_destination");
$logfile = read_config_option("path_cactilog");
/* format the message */
$message = "{$date} - " . $environ . ": " . $string . "\n";
/* Log to Logfile */
if (($logdestination == 1 || $logdestination == 2) && read_config_option("log_verbosity") != POLLER_VERBOSITY_NONE) {
if ($logfile == "") {
$logfile = $config["base_path"] . "/log/cacti.log";
}
/* echo the data to the log (append) */
$fp = @fopen($logfile, "a");
if ($fp) {
@fwrite($fp, $message);
fclose($fp);
}
}
/* Log to Syslog/Eventlog */
/* Syslog is currently Unstable in Win32 */
if ($logdestination == 2 || $logdestination == 3) {
$string = strip_tags($string);
$log_type = "";
if (substr_count($string, "ERROR:")) {
$log_type = "err";
} else {
if (substr_count($string, "WARNING:")) {
$log_type = "warn";
} else {
if (substr_count($string, "STATS:")) {
$log_type = "stat";
} else {
if (substr_count($string, "NOTICE:")) {
$log_type = "note";
}
}
}
}
if (strlen($log_type)) {
define_syslog_variables();
if ($config["cacti_server_os"] == "win32") {
openlog("Cacti", LOG_NDELAY | LOG_PID, LOG_USER);
} else {
openlog("Cacti", LOG_NDELAY | LOG_PID, LOG_SYSLOG);
}
if ($log_type == "err" && read_config_option("log_perror")) {
syslog(LOG_CRIT, $environ . ": " . $string);
}
if ($log_type == "warn" && read_config_option("log_pwarn")) {
syslog(LOG_WARNING, $environ . ": " . $string);
}
if (($log_type == "stat" || $log_type == "note") && read_config_option("log_pstats")) {
syslog(LOG_INFO, $environ . ": " . $string);
}
closelog();
}
}
}
示例13: InitSession
function InitSession()
{
set_time_limit(1200);
error_reporting(E_ALL ^ E_NOTICE);
define_syslog_variables();
openlog("smbwebclient", LOG_ODELAY | LOG_PID, $this->cfgFacility);
if ($this->cfgSessionName != '') {
session_name($this->cfgSessionName);
}
session_start();
}
示例14:
$_REQUEST["logtohtml"]=1;
// Correction PHP_SELF (ex pour apache via caudium) car PHP_SELF doit valoir URL relative
// et non path absolu.
if (isset($_SERVER["DOCUMENT_URI"]) && $_SERVER["DOCUMENT_URI"])
{
$_SERVER["PHP_SELF"]=$_SERVER["DOCUMENT_URI"];
}
// Definition des constantes syslog
if (function_exists("define_syslog_variables"))
{
if (version_compare(PHP_VERSION, '5.3.0', '<'))
{
define_syslog_variables(); // Deprecated since php 5.3.0, syslog variables no longer need to be initialized
}
}
else
{
// Pour PHP sans syslog (comme sous Windows)
define('LOG_EMERG',0);
define('LOG_ALERT',1);
define('LOG_CRIT',2);
define('LOG_ERR',3);
define('LOG_WARNING',4);
define('LOG_NOTICE',5);
define('LOG_INFO',6);
define('LOG_DEBUG',7);
}
示例15: syslog_write
function syslog_write($msg)
{
global $phpenv, $win32;
$msg = 'Client ' . $phpenv['remote'] . ' ' . $phpenv['useragent'] . ' ' . $msg;
if (!$win32) {
if (function_exists('define_syslog_variables')) {
define_syslog_variables();
}
openlog('kplaylist', LOG_PID | LOG_PERROR, LOG_LOCAL0);
syslog(LOG_INFO, $msg);
closelog();
} else {
user_error($msg);
}
}