Web lists-archives.com

[PHP] No such file... but there is!




Hi!

	I'm having an intermittent problem with a script locating a text file.  Here's the code section:


function is_crawler($agent) {
  global $path;
    $bots_file = $path;
    $spiders = file($bots_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

  foreach ($spiders as $spider) {
    if (stristr($agent, $spider)) {
      return true;
   }
  }
}

	The error log shows these lines:

[28-Nov-2017 06:50:03] PHP Warning:  file(.../counter/bots.txt): failed to open stream: No such file or directory in /home/.../counter/page_hit_counter.php on line 235
[28-Nov-2017 06:50:03] PHP Warning:  Invalid argument supplied for foreach() in /home/.../counter/page_hit_counter.php on line 238


	The bots file is there and is populated, so I'm not sure why this happens from time to time.  It's not read by any other script, so I don't think it's a locking issue(?).

	What could be causing this issue?

Thank you,
Jenni
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php