Jump to content

jane65

New Members
  • Posts

    1
  • Joined

  • Last visited

jane65's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I installed an auction script that was running fine for a couple of days, but today when I went to the website there are warning errors displaying. I'm not sure if it is the script at fault or if my server has altered something that has affected the script as the server went down yesterday, and today was the first time I'd looked at the website since then. It just seems strange how it was running ok before now. The site doesn't have any users as yet except for me. I've found the part of the script that I think the warnings relate to, and pasted it below and hoping that someone here may be able to help me or tell me why this has happened. Thanks in advance for any help. function online_users($in_admin = false) { $data_file = (($in_admin) ? '../' : '') . 'online_users.txt'; $session_time = 60; //time in **minutes** to consider someone online before removing them if(!file_exists($data_file)) { $fp = fopen($data_file, 'w+'); fclose($fp); } $ip = $_SERVER['REMOTE_ADDR']; $users = array(); $online_users = array(); //get users part $fp = fopen($data_file, 'r'); flock($fp, LOCK_SH); while(!feof($fp)) { $users[] = rtrim(fgets($fp, 32)); } flock($fp, LOCK_UN); fclose($fp); //cleanup part $x = 0; $already_in = false; foreach($users as $key => $data) { list( , $last_visit) = explode('|', $data); if(CURRENT_TIME - $last_visit >= $session_time * 60) { $users[$x] = ''; } else { if(strpos($data, $ip) !== false) { $already_in = true; $users[$x] = $ip . '|' . time(); //update record } } $x++; } if($already_in == false) { $users[] = $ip . '|' . time(); } //write file $fp = fopen($data_file, 'w+'); flock($fp, LOCK_EX); $nb_users = 0; foreach($users as $user) { if(!empty($user)) { fwrite($fp, $user . "\r\n"); $nb_users++; } } flock($fp, LOCK_UN); fclose($fp); if ($in_admin) { $nb_users--; $nb_users = ($nb_users < 0) ? 0 : $nb_users; } return $nb_users; }
×
×
  • 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.