<?php
/*
* ITMS ValleyData source file version 1.0 May 11, 2001
*
* Sends error messages to syslog.
*
*
* Here are the error priorities in decending order:
* LOG_EMERG system is unusable
* LOG_ALERT action must be taken immediately
* LOG_CRIT critical conditions
* LOG_ERR error conditions
* LOG_WARNING warning conditions
* LOG_NOTICE normal, but significant, condition
* LOG_INFO informational message
* LOG_DEBUG debug-level message
*
* http://www.php.net/manual/en/function.openlog.php
* http://www.php.net/manual/en/function.syslog.php
*
* Sample:
* define_syslog_variables();
* openlog("myScripLog", LOG_PID | LOG_PERROR, LOG_LOCAL0);
* $access = date("Y/m/d H:i:s");
* syslog(LOG_WARNING,"Unauthorized client: $access $REMOTE_ADDR ($HTTP_USER_AGENT)");
* closelog();
*
*
*
* Internet Task Management System: An online system used for recording information about and assigning tasks and processes.
* Copyright (C) 2001 ValleyData Programming Group
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* See file named "gpl.txt" included with source code or
* visit http://www.gnu.org/copyleft/gpl.txt on the internet.
*/
function error_out($message, $LOG_X = "LOG_INFO")
{
global $ADMIN_EMAIL;
define_syslog_variables();
openlog("ITMS Log", LOG_PID | LOG_PERROR, LOG_LOCAL0);
$messages = make_clean($messages);
switch($LOG_X)
{
case "LOG_EMERG":
mail($admin_email, "ITMS ERROR ($LOG_X)", "The following error was reported by ITMS:\n$message");
syslog(LOG_EMERG, $message);
break;
case "LOG_ALERT":
mail($admin_email, "ITMS ERROR ($LOG_X)", "The following error was reported by ITMS:\n$message");
syslog(LOG_ALERT, $message);
break;
case "LOG_CRIT":
mail($admin_email, "ITMS ERROR ($LOG_X)", "The following error was reported by ITMS:\n$message");
syslog(LOG_CRIT, $message);
break;
case "LOG_ERR":
add_error_to_table(LOG_ERR, $message);
syslog(LOG_ERR, $message);
break;
case "LOG_WARNING":
add_error_to_table(LOG_WARNING, $message);
syslog(LOG_WARNING, $message);
break;
case "LOG_NOTICE":
add_error_to_table(LOG_NOTICE, $message);
syslog(LOG_NOTICE, $message);
break;
case "LOG_INFO":
add_error_to_table(LOG_INFO, $message);
syslog(LOG_INFO, $message);
break;
case "LOG_DEBUG":
add_error_to_table(LOG_DEBUG, $message);
syslog(LOG_DEBUG, $message);
break;
default:
add_error_to_table(LOG_DEBUG, $message);
break;
}
db_close();
}
//store error in DB table log
function add_error_to_table($priority, $message)
{
$priority = make_clean($priority);
$priority = addslashes($priority);
$message = make_clean($message);
$message = addslashes($message);
//print("priority: $priority, message: $message");
db_open();
db_use();
$query = "INSERT INTO error_log (priority, message) VALUES ('$priority', '$message')";
db_query($query, "NO_ERR");
}
?>