AVE.CMS v3.28
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
2.3 KiB

7 years ago
<?php
7 years ago
/**
* AVE.cms
*
* @package AVE.cms
* @version 3.x
* @filesource
* @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
*
* @license GPL v.2
*/
/**
* Запись события в лог
*
* @param string $message Текст сообщения
* @param int $typ тип сообщения
* @param int $rub номер рубрики
2 weeks ago
* @return void
7 years ago
*/
2 weeks ago
function reportLog(string $message, int $typ = 0, int $rub = 0)
7 years ago
{
2 weeks ago
$logfile = BASE_DIR . '/tmp/logs/log.csv';
7 years ago
2 weeks ago
$logData = [
7 years ago
'log_time' => time(),
'log_ip' => $_SERVER['REMOTE_ADDR'],
4 years ago
'log_url' => $_SERVER['REQUEST_URI'],
2 weeks ago
'log_user_id' => ($_SESSION['user_id'] ?? '0'),
'log_user_name' => ($_SESSION['user_name'] ?? 'Anonymous'),
7 years ago
'log_text' => $message,
'log_type' => (int)$typ,
'log_rubric' => (int)$rub
2 weeks ago
];
if ($f_log = @fopen($logfile, 'ab'))
{
if (flock($f_log, LOCK_EX))
{
fputcsv($f_log, $logData);
flock($f_log, LOCK_UN);
}
fclose($f_log);
}
7 years ago
}
/**
* Запись события в лог для Sql ошибок
*
* @param string $message Текст сообщения
2 weeks ago
* @return void
7 years ago
*/
function reportSqlLog($message)
{
2 weeks ago
$logfile = BASE_DIR . '/tmp/logs/sql.csv';
7 years ago
2 weeks ago
$logData = [
7 years ago
'log_time' => time(),
'log_ip' => $_SERVER['REMOTE_ADDR'],
4 years ago
'log_url' => $_SERVER['REQUEST_URI'],
7 years ago
'log_user_id' => $_SESSION['user_id'],
'log_user_name' => $_SESSION['user_name'],
2 weeks ago
'log_text' => base64_encode(serialize($message))
];
if ($f_log = @fopen($logfile, 'ab'))
{
if (flock($f_log, LOCK_EX))
{
fputcsv($f_log, $logData);
flock($f_log, LOCK_UN);
}
fclose($f_log);
}
7 years ago
}
/**
* Запись события в лог для 404 ошибок
*
* @param string $message Текст сообщения
2 weeks ago
* @return void
7 years ago
*/
function report404()
{
2 weeks ago
$logfile = BASE_DIR . '/tmp/logs/404.csv';
7 years ago
2 weeks ago
$logData = [
7 years ago
'log_time' => time(),
'log_ip' => @$_SERVER['REMOTE_ADDR'],
4 years ago
'log_query' => @$_SERVER['REQUEST_URI'],
7 years ago
'log_user_agent' => @$_SERVER['HTTP_USER_AGENT'],
2 weeks ago
'log_user_referer' => ($_SERVER['HTTP_REFERER'] ?? ''),
7 years ago
'log_request_uri' => @$_SERVER['REQUEST_URI']
2 weeks ago
];
if ($f_log = @fopen($logfile, 'ab'))
{
if (flock($f_log, LOCK_EX))
{
fputcsv($f_log, $logData);
flock($f_log, LOCK_UN);
}
fclose($f_log);
}
7 years ago
}
7 years ago
?>