static function insert($type, $ref_id, $user_id = 0, $annotation = false) { global $db, $globals; if ($globals['behind_load_balancer'] && $globals['form_user_ip']) { // If the page stored the "real IP" in a form $ip = $globals['form_user_ip']; $ip_int = inet_ptod($globals['form_user_ip']); } else { $ip = $globals['user_ip']; $ip_int = $globals['user_ip_int']; } $sub = SitesMgr::my_id(); // Get this subsite's parent id (or itself if it's a parent) $res = $db->query("insert into logs (log_sub, log_date, log_type, log_ref_id, log_user_id, log_ip_int, log_ip) values ({$sub}, now(), '{$type}', {$ref_id}, {$user_id}, {$ip_int}, '{$ip}')"); if ($res && $annotation) { $a = new Annotation('log-' . $db->insert_id); $a->text = $annotation; $a->store(time() + 86400 * 30); // Valid for one month } return $res; }
} else { $globals['scheme'] = 'http:'; } } // Use proxy and load balancer detection if ($globals['check_behind_proxy']) { $globals['proxy_ip'] = $_SERVER["REMOTE_ADDR"]; $globals['user_ip'] = check_ip_behind_proxy(); } elseif ($globals['behind_load_balancer']) { $globals['proxy_ip'] = $_SERVER["REMOTE_ADDR"]; $globals['user_ip'] = check_ip_behind_load_balancer(); } else { $globals['user_ip'] = $_SERVER["REMOTE_ADDR"]; $globals['proxy_ip'] = false; } $globals['user_ip_int'] = inet_ptod($globals['user_ip']); $globals['cache-control'] = array(); $globals['uri'] = preg_replace('/[<>\\r\\n]/', '', urldecode($_SERVER['REQUEST_URI'])); // clean it for future use //echo "<!-- " . $globals['uri'] . "-->\n"; // For PHP < 5 if (!function_exists('htmlspecialchars_decode')) { function htmlspecialchars_decode($text) { return strtr($text, array_flip(get_html_translation_table(HTML_SPECIALCHARS))); } } if ($_SERVER['HTTP_HOST']) { // Check bots if (empty($_SERVER['HTTP_USER_AGENT']) || preg_match('/(spider|httpclient|bot|slurp|wget|libwww|\\Wphp|wordpress|joedog|facebookexternalhit|squider)[\\W\\s0-9]/i', $_SERVER['HTTP_USER_AGENT'])) { $globals['bot'] = true;