Esempio n. 1
0
     } else {
         $options['error_locidnocoords'] = true;
         outputSearchForm($options);
         exit;
     }
 } else {
     if ($options['searchtype'] == 'byort') {
         if ($locid == 0) {
             $ort = $options['ort'];
             $simpletexts = search_text2sort($ort, true);
             $simpletextsarray = explode_multi($simpletexts, ' -/,');
             $sqlhashes = '';
             $wordscount = 0;
             foreach ($simpletextsarray as $text) {
                 if ($text != '') {
                     $searchstring = search_text2simple($text);
                     if ($sqlhashes != '') {
                         $sqlhashes .= ' OR ';
                     }
                     $sqlhashes .= '`gns_search`.`simplehash`=' . sprintf("%u", crc32($searchstring));
                     $wordscount++;
                 }
             }
             if ($sqlhashes == '') {
                 $options['error_noort'] = true;
                 outputSearchForm($options);
             }
             // temporäre tabelle erstellen und dann einträge entfernen, die nicht mindestens so oft vorkommen wie worte gegeben wurden
             sql_drop_temp_table_slave('tmpuniids');
             sql_temp_table_slave('tmpuniids');
             sql_slave('CREATE TEMPORARY TABLE &tmpuniids (`uni_id` int(11) NOT NULL, `cnt` int(11) NOT NULL, `olduni` int(11) NOT NULL, `simplehash` int(11) NOT NULL) ENGINE=MEMORY SELECT `gns_search`.`uni_id` `uni_id`, 0 `cnt`, 0 `olduni`, `simplehash` FROM `gns_search` WHERE ' . $sqlhashes);
Esempio n. 2
0
function dbv_128()
{
    sql("DELETE FROM `gns_search`");
    if (sql_field_exists('gns_search', 'id')) {
        sql("ALTER TABLE `gns_search` DROP COLUMN `id`");
    }
    // unused, does not make sense; will also drop primary index
    $rs = sql("SELECT `uni`, `full_name_nd` FROM `gns_locations` WHERE `dsg` LIKE 'PPL%'");
    while ($r = sql_fetch_array($rs)) {
        $text = search_text2sort($r['full_name_nd'], true);
        if (preg_match("/[a-z]+/", $text)) {
            $simpletext = search_text2simple($text);
            sql("INSERT INTO `gns_search`\n                    (`uni_id`, `sort`, `simple`, `simplehash`)\n                    VALUES ('&1', '&2', '&3', '&4')", $r['uni'], $text, $simpletext, sprintf("%u", crc32($simpletext)));
        }
    }
    mysql_free_result($rs);
}
Esempio n. 3
0
sql('TRUNCATE TABLE `gns_search`');
sql("DROP TABLE IF EXISTS `gns_search`");
sql("CREATE TABLE `gns_search` (\n  `id` int(11) NOT NULL AUTO_INCREMENT,\n  `uni_id` int(11) NOT NULL DEFAULT '0',\n  `sort` varchar(255) NOT NULL,\n  `simple` varchar(255) NOT NULL,\n  `simplehash` int(11) unsigned NOT NULL DEFAULT '0',\n  PRIMARY KEY (`id`),\n  KEY `simplehash` (`simplehash`)\n) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$in_count = 0;
$out_count = 0;
$rs = sql("SELECT `uni`, `full_name_nd` FROM `gns_locations` WHERE `dsg` LIKE 'PPL%'");
while ($r = sql_fetch_array($rs)) {
    $in_count++;
    $simpletexts = search_text2sort($r['full_name_nd']);
    $simpletextsarray = mb_split(' |-|/|,', $simpletexts);
    foreach ($simpletextsarray as $text) {
        if ($text != '') {
            /*              if (nonalpha($text))
                          die($r['uni'] . ' ' . $text . "\n");
                         */
            $simpletext = search_text2simple($text);
            sql("INSERT INTO `gns_search` (`uni_id`, `sort`, `simple`, `simplehash`) VALUES ('&1', '&2', '&3', '&4')", $r['uni'], $text, $simpletext, sprintf("%u", crc32($simpletext)));
            $out_count++;
            if (isset($doubleindex[$text])) {
                sql("INSERT INTO `gns_search` (`uni_id`, `sort`, `simple`, `simplehash`) VALUES ('&1', '&2', '&3', '&4')", $r['uni'], $text, $doubleindex[$text], sprintf("%u", crc32($doubleindex[$text])));
                $out_count++;
            }
        }
    }
}
mysql_free_result($rs);
echo "Processed {$in_count} rows, inserted {$out_count} index items";
/* end search index rebuild */
function nonalpha($str)
{
    for ($i = 0; $i < mb_strlen($str); $i++) {