Jump to content

Check why my script lags


ted_chou12

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.