We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30167
    • 5 Posts
    Hi guys, I’ve just upgraded from MODx 1.0.3 to 1.0.4 and am now getting an error when inputting a search in the search box

    Fatal error: Call to undefined function: mb_stripos() in ../cms/assets/snippets/ajaxSearch/classes/ajaxSearchResults.class.inc.php on line 884


    Any thoughts? Cheers
      • 5811
      • 1,717 Posts

      Apologize tlidell, stripos and mb_stripos are required for the _doFilterTags function but runs only with Php5 (I didn’t care of this tongue )

      So for the moment, to avoid this issue comment the line 690 of the file classes/ajaxSearchResults.class.inc.php. Replace:
              $results = $this->_doFilterTags($results, $searchString, $advSearch);
      by
               // $results = $this->_doFilterTags($results, $searchString, $advSearch);


      On this post the reason of this filering are explained.

      I will search a solution for Php4 users.
        • 5811
        • 1,717 Posts
        Issue registered as AJAXSEARCH-67

        Also a related post to this issue.
          • 30167
          • 5 Posts
          Many thanks, that sorted it out grin
            • 5811
            • 1,717 Posts
            is there somebody with 4.4 < php < 5.2, who can test this new version of the file class/ajaxSearchResults.class.inc.php

            [Edit] Tested with PHP 5.1.6. It works. Is there somebody for a test with Php 4.x ?


            To test this new file:

            1/ rename your class/ajaxSearchResults.inc.class.php as class/ajaxSearchResults.class.inc.php.txt

            2/ unzip the attached file and drop the file ajaxSearchResults.class.inc.php in ajaxSearch/classes

            3/ run a search with a possible search term => you should get results without error

            4/ run a search with "src" => you should get no results (if this text is included only in html tags)

            Let me know the results. Thanks


            In class/ajaxSearchResults.class.inc.php I replace:
                /*
                *  Filter the search results when the search terms are found inside HTML or MODx tags
                */
                function _doFilterTags($results, $searchString, $advSearch) {
                    $filteredResults = array();
                    $nbr = count($results);
                    for($i=0;$i<$nbr;$i++) {
                        if ($advSearch === NOWORDS) $found = true;
                        else {
                            $text = implode(' ',$results[$i]);
                            $text = $this->defaultStripOutput($text);
                            $found = true;
                            if ($searchString !== '') {
                                if (($this->asCfg->dbCharset == 'utf8') && ($this->asCfg->cfg['mbstring'])) {
                                    $text = $this->_html_entity_decode($text, ENT_QUOTES, 'UTF-8');
                                    $mbStrpos = 'mb_stripos';
                                    mb_internal_encoding('UTF-8');
                                }
                                else {
                                    $text = html_entity_decode($text, ENT_QUOTES);
                                    $mbStrpos = 'stripos';
                                }
            
                                $searchList = $this->asCtrl->getSearchWords($searchString, $advSearch);
                                foreach ($searchList as $searchTerm) {
                                    $found = $mbStrpos($text, $searchTerm);
                                    if ($found !== false) break;
                                }
                            }
                        }
                        if ($found) $filteredResults[] = $results[$i];
                    }
                    return $filteredResults;
                }
            by
                /*
                *  Filter the search results when the search terms are found inside HTML or MODx tags
                */
                function _doFilterTags($results, $searchString, $advSearch) {
                    $filteredResults = array();
                    $nbr = count($results);
                    for($i=0;$i<$nbr;$i++) {
                        if ($advSearch === NOWORDS) $found = true;
                        else {
                            $text = implode(' ',$results[$i]);
                            $text = $this->defaultStripOutput($text);
                            $found = true;
                            if ($searchString !== '') {
                                if (($this->asCfg->dbCharset == 'utf8') && ($this->asCfg->cfg['mbstring'])) {
                                    $text = $this->_html_entity_decode($text, ENT_QUOTES, 'UTF-8');
                                }
                                else {
                                    $text = html_entity_decode($text, ENT_QUOTES);
                                }
            
                                $searchList = $this->asCtrl->getSearchWords($searchString, $advSearch);
                                $pcreModifier = $this->asCfg->pcreModifier;
                                foreach ($searchList as $searchTerm) {
                                    $pattern = '/' . preg_quote($searchTerm, '/') . '/' . $pcreModifier;
                                    $matches = array();
                                    $found = preg_match($pattern, $text, $matches, PREG_OFFSET_CAPTURE);
                                    if ($found) break;
                                }
                            }
                        }
                        if ($found) $filteredResults[] = $results[$i];
                    }
                    return $filteredResults;
                }

              • 18940
              • 152 Posts
              I got this problem too and luckily remembered this post.

              Tested and successfully working on a live PHP Version 4.4.9-0.dotdeb.1 environment.
                Quality doesn&#39;t need a big signature.
                • 1299
                • 1 Posts
                Same problem

                Succesfull with PHP 4.4.9 grin