« Back to History
activity_logger.php
|
20260920_164915.php
Initial Domain Snapshot
Copy Code
<?php declare(strict_types=1); if (!function_exists('activity_log')) { function activity_log(array $d): void { global $pdo; if (!$pdo) { return; } try { $stmt = $pdo->prepare(" INSERT INTO activity_logs ( company_id, user_id, module, action_name, entity_type, entity_id, remarks, ip_address, user_agent, created_at ) VALUES ( :company_id, :user_id, :module, :action_name, :entity_type, :entity_id, :remarks, :ip_address, :user_agent, NOW() ) "); $stmt->execute([ ':company_id' => (int)($d['company_id'] ?? 0), ':user_id' => (int)($d['user_id'] ?? 0), ':module' => (string)($d['module'] ?? ''), ':action_name' => (string)($d['action_name'] ?? ''), ':entity_type' => (string)($d['entity_type'] ?? ''), ':entity_id' => (string)($d['entity_id'] ?? ''), ':remarks' => (string)($d['remarks'] ?? ''), ':ip_address' => $_SERVER['REMOTE_ADDR'] ?? '', ':user_agent' => substr($_SERVER['HTTP_USER_AGENT'] ?? '', 0, 500), ]); } catch (Throwable $e) { error_log('activity_log error: ' . $e->getMessage()); } } }