Öyle uğraşma, Aşağıdaki ip.txt içerisine yazdırır.ip.txt chmod 777 olucak tabi. Biraz editlersen Güzelce kullanabilirsin.

<?
$ip = $_SERVER['REMOTE_ADDR'];
    if ( !file_exists("ip.txt")) {
        touch("ip.txt");
        $file = @fopen("ip.txt", "+r");
        @fclose($file);
        header( 'refresh: 1; url=/' );
        } else {
        $file = @fopen("ip.txt", "a");
        $text = "-----------------------------". "\r\n" . "Tarih : " . date('d/m/Y - H:i') . "\r\n" . "IP Adresi :" . "\r\n" . $ip . "\r\n". "-----------------------------" . "\r\n";
        @fwrite($file, $text);
        @fclose($file);
        } 
?>