public function SetElements($id, $elements) { $es = (array) $elements; foreach ($es as $a) { // Force as an array $a = (array) $a; // Preprocessing $a['form_id'] = $id; // If id = 0, process as new entry if ((int) $a['id'] == 0) { syslog(LOG_DEBUG, "SetElements: adding new address for {$id}"); $GLOBALS['sql']->load_data($a); $query = $GLOBALS['sql']->insert_query('xmr_element', $this->element_keys); $GLOBALS['sql']->query($query); } else { if ($a['altered']) { syslog(LOG_DEBUG, "SetElements: modifying address for form {$id}, id = " . $a['id']); $GLOBALS['sql']->load_data($a); $query = $GLOBALS['sql']->update_query('xmr_element', $this->element_keys, array('id' => $a['id'])); $GLOBALS['sql']->query($query); } } } return true; }
static function log_debug($msg, $skip_trace = 1) { if (strlen(Config::get('app.loglevel')) < 5) { return; } syslog(LOG_DEBUG, Util::get_trace($skip_trace) . $msg); }
/** * Verify that syslog logging is activated in the config via the * debug->syslog variable and does a call to the syslog() function is it * is true. * * @param emergency Syslog emergency. * @param log_string String to log. */ function syslog_msg($emergency, $log_string) { if (!function_exists('syslog') || !isset($_SESSION[APPCONFIG]) || !$_SESSION[APPCONFIG]->getValue('debug', 'syslog')) { return; } return syslog($emergency, $log_string); }
function processData() { $flag = false; $firstName = $_POST['firstname']; if (strlen($firstName) == 0) { $flag = true; } $lastName = $_POST['lastname']; if (strlen($lastName) == 0) { $flag = true; } $emailAddress = $_POST['emailaddress']; if (strlen($emailAddress) == 0) { $flag = true; } if ($flag == false) { openlog('php', LOG_CONS | LOG_NDELAY | LOG_PID, LOG_USER | LOG_PERROR); syslog(LOG_ERR, 'Error!'); syslog(LOG_INFO, "{$firstName} {$lastName} {$emailAddress}"); closelog(); echo "<style type='text/css'>#formContainer{display:none;}</style>"; echo "\n\t\t\t\t\t\t\t\t\t\t<h3 class='FormLabel'>SUCCESS!</h3>\n\t\t\t\t\t\t\t\t\t\tThank you for creating an account {$firstName} {$lastName}!\n\t\t\t\t\t\t\t\t\t\tA confirmation email has been sent to {$emailAddress}.\n\t\t\t\t\t\t\t\t\t\tOnce you receive this email please follow the instructions\n\t\t\t\t\t\t\t\t\t\tprovided to active your new account.\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<h6>This page will refresh in 10 seconds...</h6>\n\t\t\t\t\t\t\t\t\t"; header("refresh:10;url=index.php"); } }
public function log($err) { if (!is_string($err['message'])) { $err['message'] = print_r($err['message'], true); } syslog(LOG_WARNING, 'error in file: ' . $err['file'] . ' (line ' . $err['line'] . '). ' . $err['message']); }
function report($message, $severity) { global $is_logged_in; $uid = ''; if ($is_logged_in) { $uid = $is_logged_in; } $time = date('r'); $message = "{$uid} {$time}: {$message}"; switch ($severity) { case SEVERITY::PROBLEM: $filename = PROBLEM_LOGFILE; break; case SEVERITY::ERROR: $filename = ERROR_LOGFILE; break; case SEVERITY::BAD_PAGE: $filename = BAD_PAGE_LOGFILE; break; default: report("Invalid report for {$message} of {$severity}!", SEVERITY::ERROR); break; } error_log("{$message}\n", 3, $filename); beginlog(); syslog(LOG_CRIT, $message); endlog(); // do this last because it's the most risky operation, and we at least want some logs first. if ($severity == SEVERITY::ERROR) { // echo exec("echo 'A fatal error has occured. Time is now $time.' | mutt -s INTERSANGO_ERROR genjix@gmail.com -a $filename"); } }
public function write($uuid, $appName, $timestamp, $arguments) { openlog('WebSessionProfiler', LOG_PID, $this->_facility); $msg = array('wspid' => $uuid, 'appName' => $appName, 'timestamp' => $timestamp, 'message' => json_encode($arguments)); $msg = json_encode($msg); syslog($this->_priority, $msg); }
function Debuglogs($text = null, $function = null, $line = null) { if (!$GLOBALS["DEBUG"]) { return; } if ($text == null) { return; } $linetext = null; if ($function == null) { if (function_exists("debug_backtrace")) { $trace = @debug_backtrace(); } if (is_array($trace)) { $filename = basename($trace[1]["file"]); $function = $trace[1]["function"]; $line = $trace[1]["line"]; } } $linetext = $text; if ($function != null) { $linetext = "{$function}/{$line} {$linetext}"; } else { if ($line != null) { $linetext = "{$line} {$linetext}"; } } if (function_exists("syslog")) { $LOG_SEV = LOG_INFO; openlog("error_page", LOG_PID, LOG_SYSLOG); syslog($LOG_SEV, $linetext); closelog(); } }
public function writeLog($message = null, $code = null) { if (empty($this->message) && empty($message)) { return; } else { $this->message = $message; } if (empty($this->code) && empty($code)) { $this->code = 0; } else { $this->code = $code; } if (openlog(LoggingConfig::LOG_IDENT, LOG_PID | LOG_CONS, LoggingConfig::LOG_FACILITY) === true) { $entries = explode("\n", $this->message); foreach ($entries as $entry) { syslog(LOG_INFO, sprintf("(%s) [%s] %s %s %s - %s", $this->ip, $this->user, strtoupper($this->method), $this->code, $this->uri, $entry)); } if (LoggingConfig::LOG_DEBUG == true && !empty($this->input) && $this->input != "null") { syslog(LOG_DEBUG, sprintf("(%s) [%s] Input: %s", $this->ip, $this->user, $this->input)); } if (LoggingConfig::LOG_DEBUG == true && !empty($this->output) && $this->output != "null") { syslog(LOG_DEBUG, sprintf("(%s) [%s] Output: %s", $this->ip, $this->user, $this->output)); } closelog(); } else { trigger_error("Could not open syslog facility", E_USER_ERROR); } }
public function log() { $argsNum = func_num_args(); if ($argsNum < 2) { return false; } $args = func_get_args(); $priority = $args[0]; $message = $args[1]; if ($priority > $this->allowPriority) { return false; } $priorityName = $this->getLevelName($priority); $strLog = ''; if ($priorityName) { $strLog = "[{$priorityName}]"; } $strLog .= "{$message}"; for ($i = 2; $i < $argsNum; $i++) { $strLog .= $args[$i]; } openlog('SPF', LOG_PID, LOG_USER); syslog($priority, $strLog); closelog(); }
public function update(\SplSubject $subject, $logs = array(), $groups = array()) { $bottomLogs = array(); foreach ($logs as &$log) { if (is_array($log)) { if (count($log) > 0) { if ($groups[$log[0]->group]->onBottom) { $groups[$log[0]->group] = clone $groups[$log[0]->group]; $bottomLogs[] = $log; $groups[$log[0]->group]->onBottom = false; } else { syslog($log[0]->level, $groups[$log[0]->group]->label); foreach ($log as &$l) { syslog($l->level, $l->message); } syslog($log[0]->level, $groups[$log[0]->group]->label); } } } else { syslog($log->level, $log->message); } } if (count($bottomLogs) > 0) { $this->update($subject, $bottomLogs, $groups); } }
public function write(string $level, string $message) { $l = LOG_INFO; $message = $this->interpolate($level, $message); switch ($level) { case 'emergency': case 'alert': case 'critical': case 'error': case 'warning': $l = LOG_WARNING; break; case 'notice': $l = LOG_NOTICE; break; case 'debug': $l = LOG_DEBUG; break; default: break; } if (\openlog($this->ident, LOG_PID, LOG_USER)) { \syslog($l, $message); } }
function save($filename, $image_type = IMAGETYPE_JPEG, $compression = 80) { if (!$this->image) { return false; } if ($image_type == -1) { // Save in the same format $image_type = $this->image_type; } switch ($image_type) { case IMAGETYPE_JPEG: $res = imagejpeg($this->image, $filename, $compression); break; case IMAGETYPE_GIF: $res = imagegif($this->image, $filename); break; case IMAGETYPE_PNG: $res = imagepng($this->image, $filename); break; default: syslog(LOG_INFO, "IMAGE not type found: {$image_type}"); return false; } if ($res) { return true; } else { return false; } }
public function logMessage($m) { // Only log if logging to syslog is enabled in config if ($this->debug) { syslog(LOG_DEBUG, $m . "."); } }
function saveContacts($contacts) { global $contacts_file; // parse permissions if (!file_exists($contacts_file)) { echo 'error: notes file ' . $contacts_file . ' does not exist'; return; } if (!is_writable($contacts_file)) { echo 'error: cannot write projects file (' . $contacts_file . ')'; return; } // lets sort the contacts alphabetically first //sort($contacts); //echo ("{ \"message\": \"save these values: " . join($contacts) . "\"}"); // be more careful here, we need to write first to a new file, make sure that this // works and copy the result over to the pw_file $testfn = $contacts_file . '_test'; file_put_contents($testfn, json_encode($contacts, JSON_PRETTY_PRINT)); if (filesize($testfn) > 0) { // seems to have worked, now rename this file to pw_file rename($testfn, $contacts_file); } else { syslog(LOG_EMERG, 'error: could not write file into ' . $testfn); } }
public function run_counters($start = NULL, $stop = NULL) { $now = time(); $counter = array(); $accepteddomains = array_flip($this->__getAcceptedDomains()); $return = array('starttimestamp' => 0, 'stoptimestamp' => 0, 'addedstats' => 0, 'deletedstats' => 0); if (!is_null($start)) { $start = $this->__decodeDate($start); } elseif (is_null($start)) { //if we are passed nothing, operate on today $start = $this->__decodeDate("00:00:00"); } if (!is_null($stop)) { $stop = $this->__decodeDate($stop); $stop = $stop + 86400; } elseif (is_null($stop)) { //if we are passed nothing, operate on today $stop = $this->__decodeDate("00:00:00"); $stop = $stop + 86400; } $return['starttimestamp'] = $start; $return['stoptimestamp'] = $stop; // run query to return all messages $tousers = $this->db->query('SELECT `sent`-(`sent`%86400) as `day`,`to`,count(*) as `count`,sum(`size`) as `size` FROM ' . VIEW_MESSAGES . ' WHERE `sent` >= ' . $start . ' AND `sent` < ' . $stop . ' GROUP BY FROM_UNIXTIME(`day`, "%Y.%m.%d."), `to`;'); $fromusers = $this->db->query('SELECT `sent`-(`sent`%86400) as `day`,`from`,count(*) as `count`,sum(`size`) as `size` FROM ' . VIEW_MESSAGES . ' WHERE `sent` >= ' . $start . ' AND `sent` < ' . $stop . ' GROUP BY FROM_UNIXTIME(`day`, "%Y.%m.%d."), `from`;'); // process results from above four queries if ($tousers->num_rows > 0) { foreach ($tousers->rows as $row) { $counter[$row['day']][$row['to']]['recd'] = $row['count']; $counter[$row['day']][$row['to']]['sizerecd'] = $row['size']; } } if ($fromusers->num_rows > 0) { foreach ($fromusers->rows as $row) { $counter[$row['day']][$row['from']]['sent'] = $row['count']; $counter[$row['day']][$row['from']]['sizesent'] = $row['size']; } } foreach ($counter as $date => $users) { // execute queries to update the users and domains counter table $deletestats = $this->db->query("DELETE FROM " . TABLE_STAT_COUNTER . " WHERE `date` = {$date};"); $return['deletedstats'] = $return['deletedstats'] + $this->db->countAffected(); foreach ($users as $username => $userdata) { //todo: consolidate $sent = isset($userdata['sent']) ? $userdata['sent'] : 0; $recd = isset($userdata['recd']) ? $userdata['recd'] : 0; $sizesent = isset($userdata['sizesent']) ? $userdata['sizesent'] : 0; $sizerecd = isset($userdata['sizerecd']) ? $userdata['sizerecd'] : 0; $parts = explode('@', $username); if (isset($parts[1]) && isset($accepteddomains[$parts[1]])) { $addusers = $this->db->query("INSERT INTO " . TABLE_STAT_COUNTER . " (`date`,`email`,`domain`,`sent`,`recd`,`sentsize`,`recdsize`) VALUES({$date},'{$username}','" . $parts[1] . "',{$sent},{$recd},{$sizesent},{$sizerecd});"); $return['addedstats'] = $return['addedstats'] + $this->db->countAffected(); } } } if (ENABLE_SYSLOG == 1) { syslog(LOG_INFO, sprintf("processed %s to %s: %d records deleted, %d records added", date(DATE_TEMPLATE, $return['starttimestamp']), date(DATE_TEMPLATE, $return['stoptimestamp']), $return['deletedstats'], $return['addedstats'])); } return $return; }
public function EnglishIrregularVerbs() { $this->MysqlBase(); $this->Databasename = "mysql:dbname=otest;host=localhost"; syslog(LOG_DEBUG, "IrregularVerbs"); $this->loadChangedVerbs(); }
function LogInfo($msg) { global $argv; openlog($argv[0], LOG_PID, LOG_USER); syslog(LOG_INFO, $msg); closelog(); }
public function get($property_name) { if (!property_exists($this, $property_name)) { syslog(LOG_ERR, 'Lib class does not have such property ' . $property_name); } return $this->{$property_name}; }
public static function write($stack) { if (self::$isOpen === false) { $default = array('ident' => 'PhotonApp', 'facility' => LOG_USER, 'option' => LOG_CONS | LOG_NDELAY | LOG_PID); $conf = Conf::f('log_syslog', $default); $conf = array_merge($default, $conf); // Windows can log only in LOG_USER if (substr(PHP_OS, 0, 3) === 'WIN') { $conf['facility'] = LOG_USER; } $rc = openlog($conf['ident'], $conf['option'], $conf['facility']); if ($rc === true) { self::$isOpen = true; } } foreach ($stack as $elt) { $level = self::$photon2syslog[$elt[1]]; if (is_array($elt[2]) || is_object($elt[2])) { $msg = json_encode($elt[2]); } else { $msg = $elt[2]; } syslog($level, $msg); } return false; }
/** * {@inheritdoc} */ protected function write(array $record) { if (!openlog($this->ident, $this->logopts, $this->facility)) { throw new \LogicException('Can\'t open syslog for ident "' . $this->ident . '" and facility "' . $this->facility . '"'); } syslog($this->logLevels[$record['level']], (string) $record['formatted']); }
function get_instance($id, $name) { global $KERNEL_INFO_TABLE; $db = openqrm_get_db_connection(); if ("{$id}" != "") { $kernel_array = $db->Execute("select * from {$KERNEL_INFO_TABLE} where kernel_id={$id}"); } else { if ("{$name}" != "") { $kernel_array = $db->Execute("select * from {$KERNEL_INFO_TABLE} where kernel_name='{$name}'"); } else { $this->__event->log("get_instance", $_SERVER['REQUEST_TIME'], 2, "kernel.class.php", "Could not create instance of kernel without data", "", "", 0, 0, 0); foreach (debug_backtrace() as $key => $msg) { syslog(LOG_ERR, $msg['function'] . '() ' . basename($msg['file']) . ':' . $msg['line']); } return; } } foreach ($kernel_array as $index => $kernel) { $this->id = $kernel["kernel_id"]; $this->name = $kernel["kernel_name"]; $this->version = $kernel["kernel_version"]; $this->capabilities = $kernel["kernel_capabilities"]; $this->comment = $kernel["kernel_comment"]; } return $this; }
function json_error($mess) { syslog(LOG_INFO, "Meneame: avatar {$mess}"); $dict['error'] = $mess; echo json_encode($dict); die; }
protected function output($level, $msg) { // map logging levels to syslog priority levels $priorities = array(LogLevel::EMERGENCY => LOG_EMERG, LogLevel::ALERT => LOG_ALERT, LogLevel::CRITICAL => LOG_CRIT, LogLevel::ERROR => LOG_ERR, LogLevel::WARNING => LOG_WARNING, LogLevel::NOTICE => LOG_NOTICE, LogLevel::INFO => LOG_INFO, LogLevel::DEBUG => LOG_DEBUG); $priority = isset($priorities[$level]) ? $priorities[$level] : LOG_INFO; syslog($priority, $this->prefix . $msg); }
private function request($url, $data, $apiKey = null, $operation = null) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->connectionTimeout); curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if ($this->certificationFile) { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_CAINFO, $this->certificationFile); } else { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); } if ($this->proxy) { curl_setopt($ch, CURLOPT_PROXY, $this->proxy); } $headers = array("Content-Type: application/json+gzip", "User-Agent: QafooLabs Profiler Collector DevMode"); if ($apiKey) { $headers[] = 'X-Profiler-Key: ' . $apiKey; } if ($operation) { $headers[] = 'X-Profiler-Op: ' . $operation; } curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, gzencode(json_encode($data))); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); if (curl_exec($ch) === false) { syslog(LOG_WARNING, "Qafoo Profiler DevMode cURL failed: " . curl_error($ch)); } }
/** * Writes each of the messages into the syslog. * * @param array messages * @return void */ public function write(array $messages) { foreach ($messages as $message) { syslog($this->_syslog_levels[$message['type']], $message['body']); } }
function insertFail($errorCode) { syslog(LOG_NOTICE, " 계시글 등록이 실패 했습니다. : " . $errorCode); setResultCode($errorCode); setResultStr('계시글 등록이 실패 했습니다.'); flushOut(); }
function fwLog($str) { global $STDIN, $STDOUT, $STDERR; $lfstat = @stat("/tmp/firewall.log"); if (is_array($lfstat) && $lfstat['size'] > 1048576) { // Logfile is over 1mb @unlink("/tmp/firewall.log.old"); rename("/tmp/firewall.log", "/tmp/firewall.log.old"); // This is so hacky. if (is_resource($STDIN)) { fclose($STDIN); fclose($STDOUT); fclose($STDERR); $STDIN = fopen('/dev/null', 'r'); $STDOUT = fopen('/tmp/firewall.log', 'ab'); $STDERR = fopen('/tmp/firewall.err', 'ab'); } print "Rotated Log\n"; } print time() . ": {$str}\n"; // No need to write to the logfile, as we're sending it there already by the print // $fh = fopen("/tmp/firewall.log", "a"); // fwrite($fh, time().": $str\n"); syslog(LOG_WARNING | LOG_LOCAL0, $str); }
public function send($view, array $data, $callback) { // First we need to parse the view, which could either be a string or an array // containing both an HTML and plain text versions of the view which should // be used when sending an e-mail. We will extract both of them out here. list($view, $plain) = $this->parseView($view); $data['message'] = $message = $this->createMessage(); $this->callMessageBuilder($callback, $message); // Once we have retrieved the view content for the e-mail we will set the body // of this message using the HTML type, which will provide a simple wrapper // to creating view based emails that are able to receive arrays of data. $this->addContent($message, $view, $plain, $data); $message = $message->getSwiftMessage(); try { $emails = implode(', ', array_keys((array) $message->getTo())); $subj = $message->getSubject(); $body = $message->getBody(); $mail_options = ["sender" => "admin@" . Config::get('appengine::appengine.appid') . ".appspotmail.com", "to" => $emails, "subject" => $subj, "htmlBody" => $body]; $gae_message = new GAEMessage($mail_options); return $gae_message->send(); } catch (InvalidArgumentException $e) { syslog(LOG_WARNING, "Exception sending mail: " . $e); return false; } }
function logEvent($logLine, $logType = LOG_INFO) { global $logFile, $useSysLog, $logFd, $auth; $attr = array(); if (isset($auth['name'])) { $attr[] = $auth['name']; } if (isset($_SERVER['REMOTE_ADDR'])) { $attr[] = $_SERVER['REMOTE_ADDR']; } if (count($attr)) { $logLine = '[' . implode(", ", $attr) . '] ' . $logLine; } if ($logType == LOG_ERR) { $logLine = 'error: ' . $logLine; } if ($useSysLog) { syslog($logType, $logLine); } elseif (!isset($logFd)) { if ($logType == LOG_ERR) { error_log('DL: ' . $logLine); } } else { $logLine = "[" . date(DATE_W3C) . "] {$logLine}\n"; flock($logFd, LOCK_EX); fseek($logFd, 0, SEEK_END); fwrite($logFd, $logLine); fflush($logFd); flock($logFd, LOCK_UN); } }