| Textpattern | PHP Cross Reference | Content Management Systems |
1 <?php 2 3 /* 4 This is Textpattern 5 Copyright 2005 by Dean Allen - all rights reserved. 6 7 Use of this software denotes acceptance of the Textpattern license agreement 8 9 $HeadURL: https://textpattern.googlecode.com/svn/releases/4.5.4/source/textpattern/publish/log.php $ 10 $LastChangedRevision: 3505 $ 11 12 */ 13 14 15 // ------------------------------------------------------------- 16 function log_hit($status) 17 { 18 global $nolog, $logging; 19 callback_event('log_hit'); 20 if(!isset($nolog) && $status != '404') { 21 if($logging == 'refer') { 22 logit('refer', $status); 23 } elseif ($logging == 'all') { 24 logit('', $status); 25 } 26 } 27 } 28 29 // ------------------------------------------------------------- 30 function logit($r='', $status='200') 31 { 32 global $siteurl, $prefs, $pretext; 33 $mydomain = str_replace('www.','',preg_quote($siteurl,"/")); 34 $out['uri'] = @$pretext['request_uri']; 35 $out['ref'] = clean_url(str_replace("http://","",serverSet('HTTP_REFERER'))); 36 $ip = remote_addr(); 37 $host = $ip; 38 39 if (!empty($prefs['use_dns'])) { 40 // A crude rDNS cache 41 if ($h = safe_field('host', 'txp_log', "ip='".doSlash($ip)."' limit 1")) { 42 $host = $h; 43 } 44 else { 45 // Double-check the rDNS 46 $host = @gethostbyaddr($ip); 47 if ($host != $ip and @gethostbyname($host) != $ip) 48 $host = $ip; 49 } 50 } 51 52 $out['ip'] = $ip; 53 $out['host'] = $host; 54 $out['status'] = $status; 55 $out['method'] = serverSet('REQUEST_METHOD'); 56 if (preg_match("/^[^\.]*\.?$mydomain/i", $out['ref'])) $out['ref'] = ""; 57 58 if ($r=='refer') { 59 if (trim($out['ref']) != "") { insert_logit($out); } 60 } else insert_logit($out); 61 } 62 63 // ------------------------------------------------------------- 64 function insert_logit($in) 65 { 66 $in = doSlash($in); 67 extract($in); 68 safe_insert("txp_log", "`time`=now(),page='$uri',ip='$ip',host='$host',refer='$ref',status='$status',method='$method'"); 69 } 70 71 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
title