本文整理匯總了PHP中Sys::log方法的典型用法代碼示例。如果您正苦於以下問題:PHP Sys::log方法的具體用法?PHP Sys::log怎麽用?PHP Sys::log使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sys
的用法示例。
在下文中一共展示了Sys::log方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: alertAdmin
function alertAdmin($subject, $message, $log = false)
{
global $cfg;
//Set admin's email address
if (!$cfg || !($to = $cfg->getAdminEmail())) {
$to = ADMIN_EMAIL;
}
//Try getting the alert email.
$email = null;
if ($cfg && !($email = $cfg->getAlertEmail())) {
$email = $cfg->getDefaultEmail();
}
//will take the default email.
if ($email) {
$email->send($to, $subject, $message);
} else {
//no luck - try the system mail.
Email::sendmail($to, $subject, $message, sprintf('"osTicket Alerts"<%s>', $to));
}
//log the alert? Watch out for loops here.
if ($log && is_object($cfg)) {
//if $cfg is not set then it means we don't have DB connection.
Sys::log(LOG_CRIT, $subject, $message, false);
//Log the enter...and make sure no alerts are resent.
}
}
示例2: api_exit
function api_exit($code, $msg = '')
{
global $remotehost, $cfg;
if ($code != EX_SUCCESS) {
//Error occured...
$_SESSION['api']['errors'] += 1;
$_SESSION['api']['time'] = time();
Sys::log(LOG_WARNING, "API error - code #{$code}", $msg);
//echo "API Error:.$msg";
}
if ($remotehost) {
switch ($code) {
case EX_SUCCESS:
Http::response(200, $code, 'text/plain');
break;
case EX_UNAVAILABLE:
Http::response(405, $code, 'text/plain');
break;
case EX_NOPERM:
Http::response(403, $code, 'text/plain');
break;
case EX_DATAERR:
case EX_NOINPUT:
default:
Http::response(416, $code, 'text/plain');
}
}
exit($code);
}
示例3: encrypt
function encrypt($text, $salt)
{
//if mcrypt extension is not installed--simply return unencryted text and log a warning.
if (!function_exists('mcrypt_encrypt') || !function_exists('mcrypt_decrypt')) {
$msg = 'Cryptography extension mcrypt is not enabled or installed. IMAP/POP passwords are being stored as plain text in database.';
Sys::log(LOG_WARN, 'mcrypt missing', $msg);
return $text;
}
return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $salt, $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
}
示例4: db_query
function db_query($query, $database = "", $conn = "")
{
global $cfg;
if ($conn) {
/* connection is provided*/
$response = $database ? mysql_db_query($database, $query, $conn) : mysql_query($query, $conn);
} else {
$response = $database ? mysql_db_query($database, $query) : mysql_query($query);
}
if (!$response) {
//error reporting
$alert = '[' . $query . ']' . "\n\n" . db_error();
Sys::log(LOG_ALERT, 'DB Error #' . db_errno(), $alert, $cfg && $cfg->alertONSQLError());
//echo $msg; #uncomment during debuging or dev.
}
return $response;
}
示例5: Copyright
<?php
/*********************************************************************
logout.php
Destroy users session.
Copyright (c) 2012-2014 Katak Support
http://www.katak-support.com/
Released under the GNU General Public License WITHOUT ANY WARRANTY.
Derived from osTicket v1.6 by Peter Rotich.
See LICENSE.TXT for details.
$Id: $
**********************************************************************/
require_once 'user.inc.php';
//Log logout info...
$msg = sprintf("%s/%s " . _("logged out"), $_SESSION['_user']['userID'], $_SESSION['_user']['key']);
Sys::log(LOG_DEBUG, 'User logout', $msg, $_SESSION['_user']['userID']);
//We are checking to make sure the user is logged in before a logout to avoid session reset tricks on excess logins
$_SESSION['_user'] = array();
session_unset();
session_destroy();
header('Location: index.php');
require 'index.php';
示例6: sprintf
$_SESSION['daylight'] = $user->observeDaylight();
Sys::log(LOG_DEBUG, 'Inicio de sesión de Staff', sprintf("%s Identificado como [%s]", $user->getUserName(), $_SERVER['REMOTE_ADDR']));
//Debug.
//Redirect to the original destination. (make sure it is not redirecting to login page.)
$dest = $dest && (!strstr($dest, 'login.php') && !strstr($dest, 'ajax.php')) ? $dest : 'index.php';
session_write_close();
session_regenerate_id();
@header("Location: {$dest}");
require_once 'index.php';
//Just incase header is messed up.
exit;
}
//If we get to this point we know the login failed.
$_SESSION['_staff']['strikes'] += 1;
if (!$errors && $_SESSION['_staff']['strikes'] > $cfg->getStaffMaxLogins()) {
$msg = 'Acceso Denegado';
$errors['err'] = '¿Olvidaste tus datos de conexión?. Contacta con el Administrador';
$_SESSION['_staff']['laststrike'] = time();
$alert = 'Exceso de intentos de conexión por un miembro del personal' . "\n" . 'Nombre de usuario: ' . $_POST['username'] . "\n" . 'IP: ' . $_SERVER['REMOTE_ADDR'] . "\n" . 'TIME: ' . date('M j, Y, g:i a T') . "\n\n" . 'Intentos #' . $_SESSION['_staff']['strikes'] . "\n" . 'Tiempo de espera: ' . $cfg->getStaffLoginTimeout() / 60 . " Minutos \n\n";
Sys::log(LOG_ALERT, 'Excesivos intentos de conexión (Miembro del Staff)', $alert, $cfg->alertONLoginError());
} elseif ($_SESSION['_staff']['strikes'] % 2 == 0) {
//Log every other failed login attempt as a warning.
$alert = 'Nombre de usuario: ' . $_POST['username'] . "\n" . 'IP: ' . $_SERVER['REMOTE_ADDR'] . "\n" . 'Hora: ' . date('M j, Y, g:i a T') . "\n\n" . 'Intentos #' . $_SESSION['_staff']['strikes'];
Sys::log(LOG_WARNING, 'Intento de inicio de sesión fallido (Miembro del Staff)', $alert);
}
}
define("OSTSCPINC", TRUE);
//Make includes happy!
$login_err = $_POST ? true : false;
//error displayed only on post
include_once INCLUDE_DIR . 'staff/login.tpl.php';
示例7: getMsgTemplate
function getMsgTemplate($name)
{
//TODO: Don't preload - do ondemand fetch!
$tpl = array();
switch (strtolower($name)) {
case 'ticket_autoresp':
$tpl = array('subj' => $this->ht['ticket_autoresp_subj'], 'body' => $this->ht['ticket_autoresp_body']);
break;
case 'msg_autoresp':
$tpl = array('subj' => $this->ht['message_autoresp_subj'], 'body' => $this->ht['message_autoresp_body']);
break;
case 'ticket_notice':
$tpl = array('subj' => $this->ht['ticket_notice_subj'], 'body' => $this->ht['ticket_notice_body']);
break;
case 'overlimit_notice':
$tpl = array('subj' => $this->ht['ticket_overlimit_subj'], 'body' => $this->ht['ticket_overlimit_body']);
break;
case 'ticket_reply':
$tpl = array('subj' => $this->ht['ticket_reply_subj'], 'body' => $this->ht['ticket_reply_body']);
break;
case 'ticket_alert':
$tpl = array('subj' => $this->ht['ticket_alert_subj'], 'body' => $this->ht['ticket_alert_body']);
break;
case 'msg_alert':
$tpl = array('subj' => $this->ht['message_alert_subj'], 'body' => $this->ht['message_alert_body']);
break;
case 'note_alert':
$tpl = array('subj' => $this->ht['note_alert_subj'], 'body' => $this->ht['note_alert_body']);
break;
case 'assigned_alert':
$tpl = array('subj' => $this->ht['assigned_alert_subj'], 'body' => $this->ht['assigned_alert_body']);
break;
case 'transfer_alert':
$tpl = array('subj' => $this->ht['transfer_alert_subj'], 'body' => $this->ht['transfer_alert_body']);
break;
case 'overdue_alert':
$tpl = array('subj' => $this->ht['ticket_overdue_subj'], 'body' => $this->ht['ticket_overdue_body']);
break;
default:
Sys::log(LOG_WARNING, 'Template Fetch Error', "Unable to fetch '{$name}' template - id #" . $this->getId());
$tpl = array();
}
return $tpl;
}
示例8: calls
<?php
/*********************************************************************
cron.php
File to handle cron job calls (local and remote).
Peter Rotich <peter@osticket.com>
Copyright (c) 2006-2010 osTicket
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
$Id: $
**********************************************************************/
@chdir(realpath(dirname(__FILE__)) . '/');
//Change dir.
require 'api.inc.php';
require_once INCLUDE_DIR . 'class.cron.php';
Cron::run();
Sys::log(LOG_DEBUG, 'Cron Job', 'Cron Job Externo ejecutado [' . $_SERVER['REMOTE_ADDR'] . ']');
示例9: sprintf
$_SESSION['TZ_OFFSET'] = $cfg->getTZoffset();
$_SESSION['daylight'] = $cfg->observeDaylightSaving();
//Log login info...
$msg = sprintf("%s/%s logged in [%s]", $ticket->getEmail(), $ticket->getExtId(), $_SERVER['REMOTE_ADDR']);
Sys::log(LOG_DEBUG, 'User login', $msg);
//Redirect tickets.php
session_write_close();
session_regenerate_id();
@header("Location: tickets.php");
require_once 'tickets.php';
//Just incase. of header already sent error.
exit;
}
}
//If we get to this point we know the login failed.
$_SESSION['_client']['strikes'] += 1;
if (!$errors && $_SESSION['_client']['strikes'] > $cfg->getClientMaxLogins()) {
$loginmsg = 'Access Denied';
$errors['err'] = 'Forgot your login info? Please <a href="open.php">open a new ticket</a>.';
$_SESSION['_client']['laststrike'] = time();
$alert = 'Excessive login attempts by a client?' . "\n" . 'Email: ' . $_POST['lemail'] . "\n" . 'Ticket#: ' . $_POST['lticket'] . "\n" . 'IP: ' . $_SERVER['REMOTE_ADDR'] . "\n" . 'Time:' . date('M j, Y, g:i a T') . "\n\n" . 'Attempts #' . $_SESSION['_client']['strikes'];
Sys::log(LOG_ALERT, 'Excessive login attempts (client)', $alert, $cfg->alertONLoginError());
} elseif ($_SESSION['_client']['strikes'] % 2 == 0) {
//Log every other failed login attempt as a warning.
$alert = 'Email: ' . $_POST['lemail'] . "\n" . 'Ticket #: ' . $_POST['lticket'] . "\n" . 'IP: ' . $_SERVER['REMOTE_ADDR'] . "\n" . 'TIME: ' . date('M j, Y, g:i a T') . "\n\n" . 'Attempts #' . $_SESSION['_client']['strikes'];
Sys::log(LOG_WARNING, 'Failed login attempt (client)', $alert);
}
}
require CLIENTINC_DIR . 'header.inc.php';
require CLIENTINC_DIR . 'login.inc.php';
require CLIENTINC_DIR . 'footer.inc.php';
示例10: Copyright
<?php
/*********************************************************************
logout.php
Log out staff
Destroy the session and redirect to login.php
Peter Rotich <peter@osticket.com>
Copyright (c) 2006-2010 osTicket
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
$Id: $
**********************************************************************/
require 'staff.inc.php';
Sys::log(LOG_DEBUG, 'Staff logout', sprintf("%s logged out [%s]", $thisuser->getUserName(), $_SERVER['REMOTE_ADDR']));
//Debug.
$_SESSION['_staff'] = array();
session_unset();
session_destroy();
@header('Location: login.php');
require 'login.php';
示例11: calls
<?php
/*********************************************************************
cron.php
File to handle cron job calls (local and remote).
Peter Rotich <peter@osticket.com>
Copyright (c) 2006-2010 osTicket
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
$Id: cron.php,v 1.1.2.1 2009/08/17 18:25:57 carlos.delfino Exp $
**********************************************************************/
@chdir(realpath(dirname(__FILE__)) . '/');
//Change dir.
require 'api.inc.php';
require_once INCLUDE_DIR . 'class.cron.php';
Cron::run();
Sys::log(LOG_DEBUG, 'Cron Job', 'External cron job executed [' . $_SERVER['REMOTE_ADDR'] . ']');
示例12: ignore_user_abort
ignore_user_abort(1);
//Leave me a lone bro!
@set_time_limit(0);
//useless when safe_mode is on
$data = sprintf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%", 71, 73, 70, 56, 57, 97, 1, 0, 1, 0, 128, 255, 0, 192, 192, 192, 0, 0, 0, 33, 249, 4, 1, 0, 0, 0, 0, 44, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 2, 68, 1, 0, 59);
$datasize = strlen($data);
header('Content-type: image/gif');
header('Cache-Control: no-cache, must-revalidate');
header("Content-Length: {$datasize}");
header('Connection: Close');
print $data;
ob_start();
//Keep the image output clean. Hide our dirt.
//TODO: Make cron DB based to allow for better time limits. Direct calls for now sucks big time.
//We DON'T want to spawn cron on every page load...we record the lastcroncall on the session per user
$sec = time() - $_SESSION['lastcroncall'];
if ($sec > 180) {
//user can call cron once every 3 minutes.
require_once INCLUDE_DIR . 'class.cron.php';
Cron::TicketMonitor();
//Age tickets: We're going to age tickets ever regardless of cron settings.
if ($cfg && $cfg->enableAutoCron()) {
//ONLY fetch tickets if autocron is enabled!
Cron::MailFetcher();
//Fetch mail.
Sys::log(LOG_DEBUG, 'Autocron', 'cron job executed [' . $thisuser->getUserName() . ']');
}
$_SESSION['lastcroncall'] = time();
}
$output = ob_get_contents();
ob_end_clean();
示例13: create
function create($vars, &$errors, $origin, $autorespond = true, $alertstaff = true)
{
global $cfg, $thisclient, $_FILES;
//Make sure the email is not banned
if ($vars['email'] && EmailFilter::isBanned($vars['email'])) {
$errors['err'] = 'Ticket denied. Error #403';
Sys::log(LOG_WARNING, 'Ticket denied', 'Banned email - ' . $vars['email']);
return 0;
}
$id = 0;
$fields = array();
$fields['name'] = array('type' => 'string', 'required' => 1, 'error' => 'Name required');
$fields['email'] = array('type' => 'email', 'required' => 1, 'error' => 'Valid email required');
$fields['subject'] = array('type' => 'string', 'required' => 1, 'error' => 'Subject required');
$fields['message'] = array('type' => 'text', 'required' => 1, 'error' => 'Message required');
switch (strtolower($origin)) {
case 'web':
$fields['topicId'] = array('type' => 'int', 'required' => 1, 'error' => 'Select help topic');
break;
case 'staff':
$fields['deptId'] = array('type' => 'int', 'required' => 1, 'error' => 'Dept. required');
$fields['topicId'] = array('type' => 'int', 'required' => 1, 'error' => 'Topic required');
$fields['duedate'] = array('type' => 'date', 'required' => 0, 'error' => 'Invalid date - must be MM/DD/YY');
case 'api':
$fields['source'] = array('type' => 'string', 'required' => 1, 'error' => 'Indicate source');
break;
case 'email':
$fields['emailId'] = array('type' => 'int', 'required' => 1, 'error' => 'Email unknown');
break;
default:
# TODO: Return error message
$errors['origin'] = 'Invalid origin given';
}
$fields['pri'] = array('type' => 'int', 'required' => 0, 'error' => 'Invalid Priority');
$fields['phone'] = array('type' => 'phone', 'required' => 0, 'error' => 'Valid phone # required');
if (!Validator::process($fields, $vars, $errors) && !$errors['err']) {
$errors['err'] = 'Missing or invalid data - check the errors and try again';
}
//Make sure phone extension is valid
if ($vars['phone_ext']) {
if (!is_numeric($vars['phone_ext']) && !$errors['phone']) {
$errors['phone'] = 'Invalid phone ext.';
} elseif (!$vars['phone']) {
//make sure they just didn't enter ext without phone # XXX: reconsider allowing!
$errors['phone'] = 'Phone number required';
}
}
//Make sure the due date is valid
if ($vars['duedate']) {
if (!$vars['time'] || strpos($vars['time'], ':') === false) {
$errors['time'] = 'Select time';
} elseif (strtotime($vars['duedate'] . ' ' . $vars['time']) === false) {
$errors['duedate'] = 'Invalid duedate';
} elseif (strtotime($vars['duedate'] . ' ' . $vars['time']) <= time()) {
$errors['duedate'] = 'Due date must be in the future';
}
}
//check attachment..if any is set ...only set on webbased tickets..
//XXX:?? Create ticket anyway and simply drop the attachments?? We're already doing so with emails.
if ($_FILES['attachment']['name'] && $cfg->allowOnlineAttachments()) {
if (!$cfg->canUploadFileType($_FILES['attachment']['name'])) {
$errors['attachment'] = 'Invalid file type [ ' . Format::htmlchars($_FILES['attachment']['name']) . ' ]';
} elseif ($_FILES['attachment']['size'] > $cfg->getMaxFileSize()) {
$errors['attachment'] = 'File is too big. Max ' . $cfg->getMaxFileSize() . ' bytes allowed';
}
}
# Perform email filter actions on the new ticket arguments XXX: Move filter to the top and check for reject...
if (!$errors && ($ef = new EmailFilter($vars))) {
$ef->apply($vars);
}
# Some things will need to be unpacked back into the scope of this
# function
if (isset($vars['autorespond'])) {
$autorespond = $vars['autorespond'];
}
//check ticket limits..if limit set is >0
//TODO: Base ticket limits on SLA... XXX: move it elsewhere??
if ($vars['email'] && !$errors && $cfg->getMaxOpenTickets() > 0 && strcasecmp($origin, 'staff')) {
$openTickets = Ticket::getOpenTicketsByEmail($vars['email']);
if ($openTickets >= $cfg->getMaxOpenTickets()) {
$errors['err'] = "You've reached the maximum open tickets allowed.";
//Send the notice only once (when the limit is reached) incase of autoresponders at client end.
if ($cfg->getMaxOpenTickets() == $openTickets && $cfg->sendOverlimitNotice()) {
if ($vars['deptId']) {
$dept = Dept::lookup($vars['deptId']);
}
if (!$dept || !($tpl = $dept->getTemplate())) {
$tpl = $cfg->getDefaultTemplate();
}
if (!$dept || !($email = $dept->getAutoRespEmail())) {
$email = $cfg->getDefaultEmail();
}
if ($tpl && ($msg = $tpl->getOverlimitMsgTemplate()) && $email) {
$body = str_replace('%name', $vars['name'], $msg['body']);
$body = str_replace('%email', $vars['email'], $msg['body']);
$body = str_replace('%url', $cfg->getBaseUrl(), $body);
$body = str_replace('%signature', $dept && $dept->isPublic() ? $dept->getSignature() : '', $body);
$email->send($vars['email'], $msg['subj'], $body);
}
//Log + Alert admin...this might be spammy (no option to disable)...but it is helpful..I think.
//.........這裏部分代碼省略.........
示例14: elseif
$errors['vpassword'] = 'Confirm new password';
}
if (!$errors) {
if (!$thisuser->check_passwd($_POST['password'])) {
$errors['password'] = 'Valid password required';
} elseif (strcmp($_POST['npassword'], $_POST['vpassword'])) {
$errors['npassword'] = $errors['vpassword'] = 'New password(s) don\'t match';
} elseif (!strcasecmp($_POST['password'], $_POST['npassword'])) {
$errors['npassword'] = 'New password is same as old password';
}
}
if (!$errors) {
$sql = 'UPDATE ' . STAFF_TABLE . ' SET updated=NOW() ' . ',change_passwd=0, passwd=' . db_input(MD5($_POST['npassword'])) . ' WHERE staff_id=' . db_input($thisuser->getId());
if (db_query($sql) && db_affected_rows()) {
$msg = 'Password Changed Successfully';
Sys::log(LOG_ALERT, 'Excessive login attempts (staff)', $alert, $cfg->alertONLoginError());
} else {
$errors['err'] = 'Unable to complete password change. Internal error.';
}
}
break;
case 'info':
//Update profile info
if (!$_POST['firstname']) {
$errors['firstname'] = 'First name required';
}
if (!$_POST['lastname']) {
$errors['lastname'] = 'Last name required';
}
if (!$_POST['email'] || !Validator::is_email($_POST['email'])) {
$errors['email'] = 'Valid email required';
示例15: sprintf
$_SESSION['daylight'] = $user->observeDaylight();
Sys::log(LOG_DEBUG, 'Staff login', sprintf('%s ' . _('logged in'), $user->getUserName()), $user->getUserName());
//Debug
//Redirect to the original destination. (make sure it is not redirecting to login page.)
$dest = $dest && (!strstr($dest, 'login.php') && !strstr($dest, 'ajax.php')) ? $dest : 'index.php';
session_write_close();
session_regenerate_id();
@header("Location: {$dest}");
require_once 'index.php';
//Just incase header is messed up.
exit;
}
//If we get to this point we know the login failed.
$_SESSION['_staff']['strikes'] += 1;
if (!$errors && $_SESSION['_staff']['strikes'] > $cfg->getStaffMaxLogins()) {
$msg = _('Access Denied');
$errors['err'] = _('Forgot your login info? Contact IT Dept.');
$_SESSION['_staff']['laststrike'] = time();
$alert = _('Excessive login attempts by a staff member') . "\n\n" . _('Username') . ": " . $_POST['username'] . "\n" . 'IP: ' . $_SERVER['REMOTE_ADDR'] . "\n" . _('Time') . ': ' . date('M j, Y, g:i a T') . "\n\n" . _('Attempts No.') . ' ' . $_SESSION['_staff']['strikes'] . "\n" . 'Timeout: ' . $cfg->getStaffLoginTimeout() / 60 . " " . _("minutes") . " \n";
Sys::log(LOG_ALERT, 'Excessive login attempts (staff)', $alert, $_POST['username'], $cfg->alertONLoginError());
} elseif ($_SESSION['_staff']['strikes'] % 2 == 0) {
//Log every other failed login attempt as a warning.
$alert = _('Failed login attempts by a staff member') . "\n\n" . _('Username') . ": " . $_POST['username'] . "\n" . 'IP: ' . $_SERVER['REMOTE_ADDR'] . "\n" . _('Time') . ": " . date('M j, Y, g:i a T') . "\n" . _('Attempts No.') . ' ' . $_SESSION['_staff']['strikes'];
Sys::log(LOG_WARNING, 'Failed login attempt (staff)', $alert, $_POST['username']);
}
}
define("KTKADMININC", TRUE);
//Make includes happy!
$login_err = $_POST ? true : false;
//error displayed only on post
include_once INCLUDE_DIR . 'staff/login.tpl.php';