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?

有帮助吗?

解决方案

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!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top