PhpDig.net

PhpDig.net (http://www.phpdig.net/forum/index.php)
-   Bug Tracker (http://www.phpdig.net/forum/forumdisplay.php?f=27)
-   -   Search Hangs (http://www.phpdig.net/forum/showthread.php?t=675)

dsstowe 03-16-2004 01:27 AM

Search Hangs
 
If you search for a 0 "zero" followed by a space and then anything else. the search hangs and puts a heavy load on server.

Charter 03-16-2004 01:40 AM

Hi. Thanks for the post. Moved to bugs. To fix do the following.

In search_function.php find:
PHP Code:

if (SMALL_WORDS_SIZE >= 1) {
while (
ereg(' ([^ ]{1,'.SMALL_WORDS_SIZE.'}) | ([^ ]{1,'.SMALL_WORDS_SIZE.'})$|^([^ ]{1,'.SMALL_WORDS_SIZE.'}) ',$test_short,$regs)) {
     for (
$n=1$n <=3$n++) {
        if (
$regs[$n]) {
            
$ignore .= "\"".stripslashes($regs[$n])."\", ";
            
$test_short trim(str_replace($regs[$n],"",$test_short));
        }
     }
}


and replace with the following:
PHP Code:

if (SMALL_WORDS_SIZE >= 1) {
while (
ereg('( [^ ]{1,'.SMALL_WORDS_SIZE.'} )|( [^ ]{1,'.SMALL_WORDS_SIZE.'})$|^([^ ]{1,'.SMALL_WORDS_SIZE.'} )',$test_short,$regs)) {
     for (
$n=1$n <=3$n++) {
        if ((
$regs[$n]) || ($reg[$n] == 0)) {
            
$ignore .= "\"".trim(stripslashes($regs[$n]))."\", ";
            
$test_short trim(str_replace($regs[$n],"",$test_short));
        }
     }
}
if (
strlen($test_short) <= SMALL_WORDS_SIZE) {
  if (!
eregi("\"".$test_short."\", ",$ignore)) {
    
$ignore .= "\"".stripslashes($test_short)."\", ";
  }
  
$test_short trim(str_replace($test_short,"",$test_short));
}
}
$ignore str_replace("\"\", ","",$ignore); 

This should prevent the loop as well as correct the display message for too short keywords.

Remember to remove any "word" wrapping in the above code.

tomas 03-16-2004 09:33 AM

hello list,

maybe - to prevent other yet unknown loops/bugs -
in first line of search.php:

PHP Code:

set_time_limit(20); 

should help to keep the server live.


All times are GMT -8. The time now is 02:01 AM.

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