compuphase / sphider-pdo

A simple search engine and spider in PHP
GNU General Public License v2.0
31 stars 14 forks source link

PHP warnings in include/commonfuncs.php and admin/spiderfuncs.php #7

Closed superlgn closed 2 years ago

superlgn commented 6 years ago

Hi,

I was running with display_errors enabled and noticed some PHP warnings for undefined variables/indexes in a few files.

The first is in include/commonfuncs.php in the cvc() function (currently lines 693 and 694), for $regexvowel and $regex_consonant variables. Looks like these just need to be declared as global like the other functions do, eg:

    function cvc($str)
    {
            global $regex_vowel, $regex_consonant;

            $c = $regex_consonant;
            $v = $regex_vowel;

The other is in admin/spiderfuncs.php in the url_purify() function (line 397), for an undefined index. I'm not really sure what's going on here to be honest:

if (isset($urlparts['query'])) {
    if ($apache_indexes[$urlparts['query']])
        return '';
}

If it's just testing if the variable is defined then an isset() alone may work, but if it's actually testing the value of the variable (0 or 1, empty or non-empty string, etc) then that's no good and you'd probably want an isset() and then the var check, eg:

if (isset($urlparts['query'])) {
    if (isset($apache_indexes[$urlparts['query']]) && $apache_indexes[$urlparts['query']])
        return '';
}
compuphase commented 2 years ago

Fixed in commit f4dfad0a6a0e8836821ca32332f9f475f51d4023. Thanks for reporting.