$file_name = "0.dat" ;
$script_name = "index.php" ;
$crlf = "\n" ;
if (isSet($_GET["line"]) == true)
{ $file = fopen($file_name,"r+") ;
flock($file,LOCK_EX) ;
$lines = explode($crlf,fread($file,filesize($file_name))) ;
if (isSet($lines[(integer) $_GET["line"]]) == true)
{ unset($lines[(integer) $_GET["line"]]) ;
fseek($file,0) ;
$data_size = 0 ;
ftruncate($file,fwrite($file,implode($crlf,$lines))) ;
fflush($file) ;
}
flock($file,LOCK_UN) ;
fclose($file) ;
header("Location: " . $script_name) ;
exit() ;
}
$file = fopen($file_name,"r") ;
flock($file,LOCK_SH) ;
$lines = explode($crlf,fread($file,filesize($file_name) )) ;
flock($file,LOCK_UN) ;
fclose($file) ;
$count = sizeof($lines) ; for ($a = 0 ; $a < $count ; ++$a)
{ echo "<p><a href='" . $script_name . "?line=" . $a . "'>" . (strlen(str_replace("\r","",$lines[$a])) == true ? $lines[$a] : "[empty line]") . "</a></p>" ;
}