PDA

View Full Version : Forumhome error


Boofo
05-04-2003, 01:03 AM
Can someone please tell me what I am getting this error on my forumhome?

Warning: Unknown modifier 'k' in /home/bear/public_html/forum/index.php on line 414

Here is the chunk of code in question:

// vbarchive robot info for currently active users
$loggedins=$DB_site->query("SELECT session.useragent FROM session WHERE userid=0 AND lastactivity>$datecut");
$numberwebrobots=0;
$loggedinrobots="";

while ($loggedin=$DB_site->fetch_array($loggedins)) {
$checkagent = $loggedin['useragent'];
$webrobot = useragentcheck($checkagent, 1);
if ($webrobot)
{
$numberwebrobots++;
if (!(preg_match("/$webrobot/i", $loggedinrobots) )) $loggedinrobots .= $webrobot . ", ";
}
}
if (!empty($loggedinrobots)) $loggedinrobots = "(" . substr($loggedinrobots, 0, -2) .")";
$numberguest = ($numberguest - $numberwebrobots);
// vbarchive robot info for currently active users end

Line 414 of this is:

if (!(preg_match("/$webrobot/i", $loggedinrobots) )) $loggedinrobots .= $webrobot . ", ";

And here is the web robot in question:

Teoma/Ask Jeeves

thuffner
05-05-2003, 07:26 PM
I'd just reupload an original copy of index.php to fix the problem

WEForums
05-05-2003, 09:40 PM
He wants to fix the problem though and keep his hacks.

Boofo
05-06-2003, 02:39 AM
Yes, I would like to keep the others hacks. I know the problem lies in that piece if code. I'm just not sure how to fix the one line though.

WEForums
05-06-2003, 02:48 AM
What does "k" mean?

Boofo
05-06-2003, 03:05 AM
I'm in the dark as much as you are on that one. ;)

filburt1
05-06-2003, 10:18 AM
Try using preg_quote on the useragent first.

Boofo
05-06-2003, 10:29 AM
How do you mean?

filburt1
05-06-2003, 10:45 AM
if (!(preg_match("/" . preg_quote($webrobot) . "/i",
$loggedinrobots) )) $loggedinrobots .= $webrobot . ", ";

Boofo
05-06-2003, 11:02 AM
Ok, I took out:

if (!(preg_match("/$webrobot/i", $loggedinrobots) )) $loggedinrobots .= $webrobot . ", ";

and put in it's place:

if (!(preg_match("/" . preg_quote($webrobot) . "/i", $loggedinrobots) )) $loggedinrobots .= $webrobot . ", ";

Was the slash in the web robot name the problem then?

And thank you very much for this. ;)

filburt1
05-06-2003, 01:43 PM
It's because $webrobot had characters in it that were being interpreted as part of the regexp. :)

Boofo
05-06-2003, 01:46 PM
Thank you for the fix. That has been bugging me for a while. ;)

filburt1
05-06-2003, 01:48 PM
While you're at it, check out http://www.php.net/preg_quote and (IIRC) http://www.php.net/preg . Very useful stuff, that documentation ;)

Boofo
05-06-2003, 02:00 PM
Thank you. Now it makes a little more sense. It was the forward slash causing problems. One last question...what is the i for ("/i", ) in the line of code? I mean, what does it do exactly?

filburt1
05-06-2003, 02:01 PM
I have no idea. I know that some permutation of "siU" makes the regular expression not "greedy" but beyond that, no idea.

Erwin
05-07-2003, 02:32 AM
This is deep stuff. :) Good work filburt.