/** * Create a new log item * * @param string $operation What function is being monitored (e.g. 'save_post') * @param int $item ID to the item being monitored (e.g post ID, comment ID) * @param string $data Any data associated with the item (e.g. the post) * @param string $title A title string in case the data may change in the future (i.e the current post title) * @param int $user The user ID (if different from the current user) * @return void **/ static function create($operation, $item = '', $data = '', $title = '', $user = false) { global $wpdb, $user_ID; $ip = AT_Audit::get_ip(); $ip = sprintf('%u', ip2long($ip)); if ($user === false) { $user = $user_ID; } $data = maybe_serialize($data); $values = array('user_id' => $user, 'ip' => $ip, 'operation' => $operation, 'item_id' => $item, 'happened_at' => current_time('mysql'), 'data' => maybe_serialize($data), 'title' => $title); $wpdb->insert($wpdb->prefix . 'audit_trail', $values); }
/** * Login failed * Called from wp_authenticate() */ function wp_login_failed($username) { AT_Audit::create('wp_login_failed', 0, $username); if (get_option('audit_error_log')) { error_log('WordPress Login Failure: ' . $username . ' from ' . AT_Audit::get_ip()); } }