We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21772
    • 69 Posts
    It doesn’t operate in HyperFlexSeachForm Japanese environment.

    I tested by two categories.
    One is a Japanese environment.
    Another one is an English environment.

    example:
    [[HyperFlexSearchForm? &parentSearch=`10`]] => Japanese categories(Search word japanese NG)
    [[HyperFlexSearchForm? &parentSearch=`98`]] => English categories(Search word english OK)

    The character-code is UTF8.
    The version of MODx0.9.6, and HyperFlexSeachForm(3r2), and PHP 5.2.2, and mysql5.0.37.

    Under English-language environments, the problem doesn’t occur.

    It is not possible to retrieve in a Japanese environment when the
    retrieval is executed or it exists without the response.

    What will the cause?

    I’m sorry for poor English. Thank you.
      • 3098
      • 37 Posts
      Hi nori,


      The problem comes from MODx and not from the HyperFlexSearchForm snippet.

      MODx protects the posted values with a function called "modx_sanitize_gpc()"

      This function loops through each posted values and delete defined tags from the values.

      One of this pattern is "’@&#(\d+);@e’" and because all search characters are converted into HTML entities,
      MODx delete each characters and your querystring becomes an empty string after posted values protection.

      Example : "住" is converted into "住" and then deleted by MODx.

      You can try commenting the line 19 in the file "manager/includes/protect.inc.php" :
      $modxtags = array (
          '@<script[^>]*?>.*?</script>@si',
          //'@&#(\d+);@e',
          '@\[\[(.*?)\]\]@si',
          '@\[!(.*?)!\]@si',
          '@\[\~(.*?)\~\]@si',
          '@\[\((.*?)\)\]@si',
          '@{{(.*?)}}@si',
          '@\[\+(.*?)\+\]@si',
          '@\[\*(.*?)\*\]@si'
      );

      Please tell me if the search works after commenting the line !


      Benjamin
        • 21772
        • 69 Posts
        Thank you for the Benjamin advice.
        We wish to express our gratitude.

        The state has not been improved in the part (I try commenting the line 19 in the file "manager/includes/protect.inc.php" ) pointed out.

        However, the keyword that was able to be retrieved even if it did
        not comment was able to be found.

        OK WORD
        Example "電子"
        QueryString "http://www.../93?search=%E9%9B%BB%E5%AD%90&sub=Go%21"

        NG WORD
        Example "マップ"
        QueryString "http://www.../93?search=%E3%83%9E%E3%83%83%E3%83%97&sub=Go%21"

        In my environment
        I think that "住" has been converted into %E4%BD%8F.

        Are there any things to remember?

        The tested siteIt is here.
        The comment is effective now. (commenting the line 19 in the file "manager/includes/protect.inc.php" )
        http://www.tanabesouko.co.jp/93

        Thank you!
          • 21772
          • 69 Posts
          Hello.

          It was possible to solve it to the problem of a Japanese retrieval by the
          following correction.

          (snippet.HyperFlexSearchForm.autogenerated.php)

          mask this part
          //$searchString_copy_t = strtolower(strtr($searchString_copy_t, $input_t, $output_t));
          

          SELECT cnt.`id`, cnt.`pagetitle`, cnt.`description`, cnt.`content` FROM `modx`.`modx_site_content` AS cnt WHERE cnt.`published`=’1’ AND cnt.`searchable`=’1’ AND cnt.`deleted`=’0’ AND (cnt.`parent`=’98’) AND (( (LOWER(cnt.`pagetitle`) LIKE ’%子%’ OR LOWER(cnt.`description`) LIKE ’%子%’ OR LOWER(cnt.`content`) LIKE ’%子%’) OR (LOWER(cnt.`pagetitle`) LIKE ’%å­�%’ OR LOWER(cnt.`description`) LIKE ’%å­�%’ OR LOWER(cnt.`content`) LIKE ’%å­�%’) )) ORDER BY `editedon` DESC, `createdon` DESC LIMIT 200;

          ↓change
          SELECT cnt.`id`, cnt.`pagetitle`, cnt.`description`, cnt.`content` FROM `modx`.`modx_site_content` AS cnt WHERE cnt.`published`=’1’ AND cnt.`searchable`=’1’ AND cnt.`deleted`=’0’ AND (cnt.`parent`=’98’) AND (( (LOWER(cnt.`pagetitle`) LIKE ’%子%’ OR LOWER(cnt.`description`) LIKE ’%子%’ OR LOWER(cnt.`content`) LIKE ’%子%’) OR (LOWER(cnt.`pagetitle`) LIKE ’%子%’ OR LOWER(cnt.`description`) LIKE ’%子%’ OR LOWER(cnt.`content`) LIKE ’%子%’) )) ORDER BY `editedon` DESC, `createdon` DESC LIMIT 200;

          Another one, I think correct SQL to be issued by changing the following
          part.
          //if ($q1_t != $q2_t) {
          if ( !strcasecmp($q1_t,$q1_2) ){
          

          ↓change
          SELECT cnt.`id`, cnt.`pagetitle`, cnt.`description`, cnt.`content` FROM `modx`.`modx_site_content` AS cnt WHERE cnt.`published`=’1’ AND cnt.`searchable`=’1’ AND cnt.`deleted`=’0’ AND (cnt.`parent`=’98’) AND ( (LOWER(cnt.`pagetitle`) LIKE ’%子%’ OR LOWER(cnt.`description`) LIKE ’%子%’ OR LOWER(cnt.`content`) LIKE ’%子%’) ) ORDER BY `editedon` DESC, `createdon` DESC LIMIT 200;

          It came to be able to serch it.
          The following problem occurred.

          However, when the folder where all Japanese documents are stored is
          retrieved, the retrieval does the time-out.

          Isn’t there thing something being thought?
          Thank you!
            • 3098
            • 37 Posts
            Hi nori,

            Thank you for your tests, I’ll check this out as soon as possible !

            Have a good day,


            Benjamin
              • 21772
              • 69 Posts
              Thank you Benjamin. grin

              You are doing wonderful work.
              I sincerely wish it to be able to be used.
                • 3098
                • 37 Posts
                I’ve just added a new release so you can download, install and test it :

                http://modxcms.com/HyperFlexSeachForm-768.html

                Thank you for your interest !


                Benjamin
                  • 21772
                  • 69 Posts
                  Hi Benjamin

                  Thank you for new HyperFlexSearchForm. grin I was moved deeply.

                  It tested immediately.

                  To our regret,
                  When all documents are written in Japanese, Sarch cannot be done.

                  Example1: Search word japanese NG(All Japanese Word Time-Out: "電子部品", "業務案内", "文書保管"... )
                  http://www.tanabesouko.co.jp/124

                  It is not thought that the mistake is found in SQL that HyperFlexSearchForm
                  generates.

                  Because LIKE ’%*****%’ (example: ’%倉庫%’...etc, test in mysql console)
                  "*****" When the part is changed with the manual, the retrieval in
                  Japanese is possible.

                  SELECT cnt.`id`, cnt.`pagetitle`, cnt.`description`, cnt.`content` FROM `modx`.`modx_site_content` AS cnt WHERE cnt.`published`=’1’ AND cnt.`searchable`=’1’ AND cnt.`deleted`=’0’ AND (cnt.`parent`=’18’) AND ( (LOWER(cnt.`pagetitle`) LIKE ’%*****%’ OR LOWER(cnt.`description`) LIKE ’%*****%’ OR LOWER(cnt.`content`) LIKE ’%*****%’) ) ORDER BY `editedon` DESC, `createdon` DESC LIMIT 200;

                  The cause is in the thing that the program has done the time-out before
                  executing SQL.

                  In the test
                  ...the following thing.. I see.
                  When little Japanese exists together in the document written in
                  English. Japanese can be retrieved.

                  Example2: Search word japanese OK(All Japanese Word OK: "電子部品", "業務案内", "文書保管"... )
                  http://www.tanabesouko.co.jp/93

                  It is examined whether there is in the loop processing of the program the
                  problem.

                  I am sorry for English not understood easily.

                  Thank you.
                    • 21772
                    • 69 Posts
                    Hi Benjamin

                    The cause of the time-out
                    It has understood.

                    This part of "snippet.HyperFlexSearchForm.autogenerated.php"

                    Line 978
                    while ($content_t{$extractLength_i} != ' ') {
                          $extractLength_i--;
                    }
                    

                    mask of this part
                    It operates in Japanese without trouble.

                    Even if you masking do here
                    Is it no problem?

                    Thank you!
                      • 3098
                      • 37 Posts
                      Hi nori,


                      A new release is available with a new system to extract parts of results content :

                      http://modxcms.com/HyperFlexSeachForm-768.html


                      Benjamin