Question

I’m trying to use BlackHole trap outlined here on my website, but I always get an error message saying “Error Opening file.”

 $fp = fopen($filename, 'r') or die('<p>Error opening file.</p>');
 while ($line = fgets($fp)) {
     if (!preg_match("/(googlebot|slurp|msnbot|teoma|yandex)/i", $line)) {
         $u = explode(' ', $line);
         if ($u[0] == $ipaddress) ++$badbot;
     }
 }

How can I fix it?

Was it helpful?

Solution

Since your first line is as follows:

$fp = fopen($filename, 'r') or die('<p>Error opening file.</p>');

We can pretty quickly deduce that the fopen() call is failing. Verify that you're providing the function with a correct file path -- nothing after it matters if the file doesn't open!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top