diff options
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r-- | phpBB/includes/functions.php | 61 |
1 files changed, 19 insertions, 42 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d0ef2759d5..590fc15aa7 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3512,65 +3512,42 @@ function parse_cfg_file($filename, $lines = false) */ function add_log() { - global $db, $user; + global $phpbb_log; - // In phpBB 3.1.x i want to have logging in a class to be able to control it - // For now, we need a quite hakish approach to circumvent logging for some actions - // @todo implement cleanly - if (!empty($GLOBALS['skip_add_log'])) + $args = func_get_args(); + $log = (isset($args[0])) ? $args[0] : false; + + if ($log === false) { return false; } - $args = func_get_args(); - - $mode = array_shift($args); - $reportee_id = ($mode == 'user') ? intval(array_shift($args)) : ''; - $forum_id = ($mode == 'mod') ? intval(array_shift($args)) : ''; - $topic_id = ($mode == 'mod') ? intval(array_shift($args)) : ''; - $action = array_shift($args); - $data = (!sizeof($args)) ? '' : serialize($args); - - $sql_ary = array( - 'user_id' => (empty($user->data)) ? ANONYMOUS : $user->data['user_id'], - 'log_ip' => $user->ip, - 'log_time' => time(), - 'log_operation' => $action, - 'log_data' => $data, - ); + $mode = array_shift($args); + // This looks kind of dirty, but add_log has some additional data before the log_operation + $additional_data = array(); switch ($mode) { case 'admin': - $sql_ary['log_type'] = LOG_ADMIN; + case 'critical': break; - case 'mod': - $sql_ary += array( - 'log_type' => LOG_MOD, - 'forum_id' => $forum_id, - 'topic_id' => $topic_id - ); + $additional_data['forum_id'] = array_shift($args); + $additional_data['topic_id'] = array_shift($args); break; - case 'user': - $sql_ary += array( - 'log_type' => LOG_USERS, - 'reportee_id' => $reportee_id - ); + $additional_data['reportee_id'] = array_shift($args); break; - - case 'critical': - $sql_ary['log_type'] = LOG_CRITICAL; - break; - - default: - return false; } + $log_operation = array_shift($args); + $additional_data = array_merge($additional_data, $args); + + global $user; - $db->sql_query('INSERT INTO ' . LOG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); + $user_id = (empty($user->data)) ? ANONYMOUS : $user->data['user_id']; + $user_ip = (empty($user->ip)) ? '' : $user->ip; - return $db->sql_nextid(); + return $phpbb_log->add($mode, $user_id, $user_ip, $log_operation, time(), $additional_data); } /** |