View Single Post
Old 12-16-2003, 02:16 AM   #1
janalwin
Green Mole
 
Join Date: Dec 2003
Location: Groningen, The Netherlands
Posts: 2
BUGFIX: PHPDIG stops indexing when a 0 is in the page

Hallo,

I use an older version of PHPDIG (1.4.X) but the same code seems to be in version 1.6.5

The problem occurs when a 0 (zero) stands on its own in the text. PHPDIG doesn't index the words after the zero.

The problem lies in the function phpdigindexfile in robot_functions.php.

The command strtok is used to cut the text in to separate words. The problem is with the for loop. The loop repeats it's self as long as $token is true. The problem is that if a '0' is in the text $token will become '0'. This will be interpreted as false, so the for loop will stop.

See the phpmanual:
http://nl3.php.net/manual/en/function.strtok.php
(i found the solution in the comments)


BUG:
for ($token = strtok($text2, $separators); $token; $token = strtok($separators))
{
if (!isset($nbre_mots[$token]))
$nbre_mots[$token] = 1;
else
$nbre_mots[$token]++;
$total++;
}


FIX:

for ($token = strtok($text2, $separators); $token!==false; $token = strtok($separators))
{
if (!isset($nbre_mots[$token]))
$nbre_mots[$token] = 1;
else
$nbre_mots[$token]++;
$total++;
}
__________________
Jan Alwin de Jong
janalwin is offline   Reply With Quote