| [ Index ] | [ Index ] [ Classes ] [ Functions ] [ Variables ] [ Constants ] |
PHP Cross Reference of TXP stable 4.0.6 |
||
[Summary view] [Print] [Text view]
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: http://svn.textpattern.com/releases/4.0.6/source/textpattern/publish/log.php $ 10 $LastChangedRevision: 1637 $ 11 12 */ 13 14 15 // ------------------------------------------------------------- 16 function log_hit($status) 17 { 18 global $nolog, $logging; 19 if(!isset($nolog) && $status != '404') { 20 if($logging == 'refer') { 21 logit('refer', $status); 22 } elseif ($logging == 'all') { 23 logit('', $status); 24 } 25 } 26 } 27 28 // ------------------------------------------------------------- 29 function logit($r='', $status='200') 30 { 31 global $siteurl, $prefs, $pretext; 32 $mydomain = str_replace('www.','',preg_quote($siteurl,"/")); 33 $out['uri'] = @$pretext['request_uri']; 34 $out['ref'] = clean_url(str_replace("http://","",serverSet('HTTP_REFERER'))); 35 $host = $ip = serverSet('REMOTE_ADDR'); 36 37 if (!empty($prefs['use_dns'])) { 38 // A crude rDNS cache 39 if ($h = safe_field('host', 'txp_log', "ip='".doSlash($ip)."' limit 1")) { 40 $host = $h; 41 } 42 else { 43 // Double-check the rDNS 44 $host = @gethostbyaddr(serverSet('REMOTE_ADDR')); 45 if ($host != $ip and @gethostbyname($host) != $ip) 46 $host = $ip; 47 } 48 } 49 $out['ip'] = $ip; 50 $out['host'] = $host; 51 $out['status'] = $status; 52 $out['method'] = serverSet('REQUEST_METHOD'); 53 if (preg_match("/^[^\.]*\.?$mydomain/i", $out['ref'])) $out['ref'] = ""; 54 55 if ($r=='refer') { 56 if (trim($out['ref']) != "") { insert_logit($out); } 57 } else insert_logit($out); 58 } 59 60 // ------------------------------------------------------------- 61 function insert_logit($in) 62 { 63 global $DB; 64 $in = doSlash($in); 65 extract($in); 66 safe_insert("txp_log", "`time`=now(),page='$uri',ip='$ip',host='$host',refer='$ref',status='$status',method='$method'"); 67 } 68 69 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Feb 18 03:42:45 2008 | Cross-referenced by PHPXref 0.7 |