Hello!
l was wondering if you might be able to help me. l am trying to find out how to make PHP read a file, and then check if that text is already there, and if so don't re-write it. l'll give out my code for an example.
<?php
//text file that counts the peeps that visit the site
$lne = "line.txt";
$File = "counter.txt";
$handle = fopen($File, 'r+') ;
//file open
$data = fread($handle, 512) ;
//file read
$count = $data + 1;
//Adds one person :DDDDD
fseek($handle, 0) ;
fwrite($handle, $count) ;
//saves the new person
echo 'Count #'.$count;
//
//
//
//
//
//
$File2 = "ips.txt";
fclose($handle) ;
if (isset($_POST['ip'])) {
$ip = $_POST['ip'];
$port = $_POST['port'];
echo 'Connecting to ' . $ip . ':' . $port;
exit();
}
$ip = getenv("REMOTE_ADDR");
echo '<br>'.$ip;
$handle2 = fopen($File2, 'r+') ;
//file open
$data2 = fread($handle2, 512) ;
//file read
fwrite($handle2,"\n" . $ip .':' . $count);
//saves the new ip
?>
<html>
<form method="POST">
<input type="hidden" name="ip">
<input type="hidden" name="port">
</html>
lt just re-writes the lP with the new counter, very annoying. l can filter it out with VB but l want it all to be server sided. Thank you for your time ~Papa Beans