-4

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?

Jolta
  • 2,620
  • 1
  • 29
  • 42
URaff Joseph
  • 25
  • 2
  • 6

1 Answers1

0

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!

Sam Hanley
  • 4,707
  • 7
  • 35
  • 63