Php记录网站访问log日志
作者:admin 日期:2012-11-19
PHP代码
- function GetRootPath()
- {
- $sRealPath = realpath( './' ) ;
- $sSelfPath = $_SERVER['PHP_SELF'] ;
- $sSelfPath = substr( $sSelfPath, 0, strrpos( $sSelfPath, '/' ) ) ;
- return substr( $sRealPath, 0, strlen( $sRealPath ) - strlen( $sSelfPath ) ) ;
- }
- //记录访问日志
- $logtxt="IP: ".$_SERVER["REMOTE_ADDR"]." 时间: ".strftime("%Y-%m-%d %H:%M:%S")." 页面:".$_SERVER["PHP_SELF"]." 来路: ".$_SERVER['HTTP_REFERER']." 客户端: ".$_SERVER['HTTP_USER_AGENT']."\r\n";
- $fp = @fopen(GetRootPath().'/log/'.date("Ymd").'.txt',"a+");
- fwrite($fp,$logtxt);
- fclose($fp);
上一篇: MySQL中时间-->数字转换和IP地址-->数字转换
下一篇: .htaccess配置PHP错误显示
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: php
相关日志:
下一篇: .htaccess配置PHP错误显示
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: php
相关日志:
评论: 0 | 引用: 0 | 查看次数: 3936
发表评论
广告位