php 文件記錄訪問者IP實例代碼 ,代碼很少,在PHP環境裡可以運行,希望可以幫助有需要的人。
- <?php
- $fp = fopen("log.txt","a ");
- fwrite($fp,date("Y-m-d H:i:s"));
- fwrite($fp," ");
- fwrite($fp,$_SERVER[REMOTE_ADDR]);
- fwrite($fp," ");
- fwrite($fp,$_SERVER[HTTP_X_REWRITE_URL]);
- fwrite($fp," ");
- fwrite($fp,$_SERVER[HTTP_USER_AGENT]);
- fwrite($fp," ");
- fwrite($fp,$_SERVER["HTTP_REFERER"]);
- fwrite($fp,"
");
- fclose($fp);
- ?>