ted_chou12 Posted February 11, 2007 Share Posted February 11, 2007 adding this cause my page to load ten thousand years, so I thought there might be something which repeats itself, can anyone have a look at it please? this basically writes a guests ip and the current time into the txt files, while when the system has the guest's ip already, then update the time instead: <?php if ($username == "") { $ips = file("guests/iponline.txt"); $guestip = $_SERVER['REMOTE_ADDR']; $datetime = date("Y-m-d H:i:s"); foreach ($ips as $ip) {$data = explode(",", $ip); $ipadd = explode(",", $ip);$iplist[] = $ipadd[0]; if ($guestip == $data[0]) {$guest = "old";}} if ($guest == "") { $file = fopen("guests/iponline.txt","a"); $write = fwrite($file,"$guestip,$datetime"); fclose($file);} else {$line = array_keys($iplist, $guestip); $ips[$line[0]] = "$guestip,$datetime"; $handle = fopen("guests/iponline.txt", "w"); foreach ($ips as $val) {$write = fwrite($handle, $val);} fclose($handle);}} Thanks Ted Link to comment https://forums.phpfreaks.com/topic/38013-check-why-my-script-lags/ Share on other sites More sharing options...
ted_chou12 Posted February 11, 2007 Author Share Posted February 11, 2007 sorry, forgot to add, the text file looks like: xxx.xxx.xxx.xxx,2007-02-12 01:52:25 Link to comment https://forums.phpfreaks.com/topic/38013-check-why-my-script-lags/#findComment-181948 Share on other sites More sharing options...
Hypnos Posted February 11, 2007 Share Posted February 11, 2007 How big is iponline.txt? You should consider changing this to a database, or changing it to append only (not read and rewrite). Link to comment https://forums.phpfreaks.com/topic/38013-check-why-my-script-lags/#findComment-182043 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.