PhpDig.net

PhpDig.net (http://www.phpdig.net/forum/index.php)
-   Bug Tracker (http://www.phpdig.net/forum/forumdisplay.php?f=27)
-   -   BUGFIX: PHPDIG stops indexing when a 0 is in the page (http://www.phpdig.net/forum/showthread.php?t=297)

janalwin 12-16-2003 02:16 AM

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++;
}

Charter 12-26-2003 05:08 PM

Hi. Thanks. :)


All times are GMT -8. The time now is 11:15 AM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.