1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/13468] Update calls to add_log()

PHPBB3-13468
This commit is contained in:
Gaëtan Muller
2015-01-05 22:21:31 +01:00
parent e2786c37dc
commit 7fc586080b
58 changed files with 568 additions and 329 deletions

View File

@@ -53,7 +53,7 @@ class gd extends captcha_abstract
function acp_page($id, &$module)
{
global $db, $user, $auth, $template;
global $db, $user, $auth, $template, $phpbb_log;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang('acp/board');
@@ -84,7 +84,7 @@ class gd extends captcha_abstract
}
}
add_log('admin', 'LOG_CONFIG_VISUAL');
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_VISUAL');
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action));
}
else if ($submit)

View File

@@ -611,7 +611,7 @@ class qa
*/
function acp_page($id, &$module)
{
global $db, $user, $auth, $template;
global $db, $user, $auth, $template, $phpbb_log;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang('acp/board');
@@ -742,7 +742,7 @@ class qa
$this->acp_add_question($data);
}
add_log('admin', 'LOG_CONFIG_VISUAL');
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_VISUAL');
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($list_url));
}
}

View File

@@ -75,7 +75,7 @@ class recaptcha extends captcha_abstract
function acp_page($id, &$module)
{
global $config, $db, $template, $user;
global $config, $db, $template, $user, $phpbb_log;
$captcha_vars = array(
'recaptcha_pubkey' => 'RECAPTCHA_PUBKEY',
@@ -101,7 +101,7 @@ class recaptcha extends captcha_abstract
}
}
add_log('admin', 'LOG_CONFIG_VISUAL');
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_VISUAL');
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action));
}
else if ($submit)

View File

@@ -67,6 +67,8 @@ class tidy_plupload extends \phpbb\cron\task\base
*/
public function run()
{
global $user, $phpbb_log;
// Remove old temporary file (perhaps failed uploads?)
$last_valid_timestamp = time() - $this->max_file_age;
try
@@ -88,13 +90,11 @@ class tidy_plupload extends \phpbb\cron\task\base
}
catch (\UnexpectedValueException $e)
{
add_log(
'critical',
'LOG_PLUPLOAD_TIDY_FAILED',
$phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_PLUPLOAD_TIDY_FAILED', false, array(
$this->plupload_upload_path,
$e->getMessage(),
$e->getTraceAsString()
);
));
}
$this->config->set('plupload_last_gc', time(), true);

View File

@@ -171,6 +171,8 @@ class module implements \phpbb\db\migration\tool\tool_interface
*/
public function add($class, $parent = 0, $data = array())
{
global $user, $phpbb_log;
// Allows '' to be sent as 0
$parent = $parent ?: 0;
@@ -266,7 +268,7 @@ class module implements \phpbb\db\migration\tool\tool_interface
{
// Success
$module_log_name = ((isset($this->user->lang[$data['module_langname']])) ? $this->user->lang[$data['module_langname']] : $data['module_langname']);
add_log('admin', 'LOG_MODULE_ADD', $module_log_name);
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_MODULE_ADD', false, array($module_log_name));
// Move the module if requested above/below an existing one
if (isset($data['before']) && $data['before'])

View File

@@ -27,7 +27,7 @@ class log implements \phpbb\log\log_interface
/**
* An array with the disabled log types. Logs of such types will not be
* added when add_log() is called.
* added when add() is called.
* @var array
*/
protected $disabled_types;
@@ -223,14 +223,14 @@ class log implements \phpbb\log\log_interface
return false;
}
if ($log_time == false)
if ($log_time === false)
{
$log_time = time();
}
$sql_ary = array(
'user_id' => $user_id,
'log_ip' => $log_ip,
'user_id' => $user_id ? (int) $user_id : ANONYMOUS,
'log_ip' => empty($log_ip) ? '' : $log_ip,
'log_time' => $log_time,
'log_operation' => $log_operation,
);

View File

@@ -32,8 +32,8 @@ interface log_interface
* Disable log
*
* This function allows disabling the log system or parts of it, for this
* page call. When add_log is called and the type is disabled,
* the log will not be added to the database.
* page call. When add() is called and the type is disabled, the log will
* not be added to the database.
*
* @param mixed $type The log type we want to disable. Empty to
* disable all logs. Can also be an array of types.
@@ -57,12 +57,12 @@ interface log_interface
/**
* Adds a log entry to the database
*
* @param string $mode The mode defines which log_type is used and from which log the entry is retrieved
* @param int $user_id User ID of the user
* @param string $log_ip IP address of the user
* @param string $log_operation Name of the operation
* @param int $log_time Timestamp when the log entry was added, if empty time() will be used
* @param array $additional_data More arguments can be added, depending on the log_type
* @param string $mode The mode defines which log_type is used and from which log the entry is retrieved
* @param int $user_id User ID of the user
* @param string $log_ip IP address of the user
* @param string $log_operation Name of the operation
* @param int|bool $log_time Timestamp when the log entry was added. If false, time() will be used
* @param array $additional_data More arguments can be added, depending on the log_type
*
* @return int|bool Returns the log_id, if the entry was added to the database, false otherwise.
*/

View File

@@ -454,6 +454,8 @@ class fulltext_sphinx
*/
public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{
global $user, $phpbb_log;
// No keywords? No posts.
if (!strlen($this->search_query) && !sizeof($author_ary))
{
@@ -601,7 +603,7 @@ class fulltext_sphinx
if ($this->sphinx->GetLastError())
{
add_log('critical', 'LOG_SPHINX_ERROR', $this->sphinx->GetLastError());
$phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_SPHINX_ERROR', false, array($this->sphinx->GetLastError()));
if ($this->auth->acl_get('a_'))
{
trigger_error($this->user->lang('SPHINX_SEARCH_FAILED', $this->sphinx->GetLastError()));

View File

@@ -215,7 +215,7 @@ class session
function session_begin($update_session_page = true)
{
global $phpEx, $SID, $_SID, $_EXTRA_URL, $db, $config, $phpbb_root_path;
global $request, $phpbb_container;
global $request, $phpbb_container, $user, $phpbb_log;
// Give us some basic information
$this->time_now = time();
@@ -490,11 +490,18 @@ class session
{
if ($referer_valid)
{
add_log('critical', 'LOG_IP_BROWSER_FORWARDED_CHECK', $u_ip, $s_ip, $u_browser, $s_browser, htmlspecialchars($u_forwarded_for), htmlspecialchars($s_forwarded_for));
$phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_IP_BROWSER_FORWARDED_CHECK', false, array(
$u_ip,
$s_ip,
$u_browser,
$s_browser,
htmlspecialchars($u_forwarded_for),
htmlspecialchars($s_forwarded_for)
));
}
else
{
add_log('critical', 'LOG_REFERER_INVALID', $this->referer);
$phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_REFERER_INVALID', false, array($this->referer));
}
}
}