function search_text2simple($str) { global $search_simplerules; $str = search_text2sort($str); // regeln anwenden foreach ($search_simplerules as $rule) { $str = mb_ereg_replace($rule[0], $rule[1], $str); } // doppelte chars ersetzen for ($c = ord('a'); $c <= ord('z'); $c++) { $str = mb_ereg_replace(chr($c) . chr($c), chr($c), $str); } return $str; }
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); }
HAVING `distance` < ' . ($distance + 0); sql_slave($cachesFilter); sql_slave('ALTER TABLE &result_caches ADD PRIMARY KEY ( `cache_id` )'); $sql_select[] = '&result_caches.`cache_id`'; $sql_from = '&result_caches'; $sql_innerjoin[] = '`caches` ON `caches`.`cache_id`=&result_caches.`cache_id`'; } 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;
$sql_from[] = '`result_caches`, `caches`'; $sql_where[] = '`caches`.`cache_id`=`result_caches`.`cache_id`'; $dbc->reset(); } else { $options['error_locidnocoords'] = true; outputSearchForm($options); unset($dbc); unset($dbcSearch); exit; } } else { if ($options['searchtype'] == 'byort') { if ($locid == 0) { require_once $rootpath . 'lib/search.inc.php'; $ort = trim($options['ort']); $simpletexts = search_text2sort($ort); $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;
* ************************************************************************* */ header('Content-Type: text/plain'); set_time_limit(0); $rootpath = '../../'; require_once $rootpath . 'lib/search.inc.php'; /* begin search index rebuild */ $doubleindex['sankt'] = 'st'; 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++; } } }
<?php /*************************************************************************** * For license information see doc/license.txt * * Unicode Reminder メモ * * Dieses Script erstellt den Suchindex für Ortsnamen aus den Daten der * Opengeodb. (Obsolet, dieser Suchindex wird nicht verwendet.) ***************************************************************************/ $opt['rootpath'] = '../../'; require_once __DIR__ . '/../../lib2/cli.inc.php'; require_once __DIR__ . '/../../lib2/search/search.inc.php'; sql('DELETE FROM geodb_search'); $rs = sql("SELECT `loc_id`, `text_val`\n FROM `geodb_textdata`\n WHERE `text_type`=500100000\n AND text_locale IN ('da', 'de', 'en', 'fi', 'fr', 'it', 'nl', 'rm')"); while ($r = sql_fetch_array($rs)) { $simpletexts = search_text2sort($r['text_val']); $simpletextsarray = explode_multi($simpletexts, ' -/,'); foreach ($simpletextsarray as $text) { if ($text != '') { if (nonalpha($text)) { die($text . "\n"); } $simpletext = search_text2simple($text); sql("INSERT INTO `geodb_search` (`loc_id`, `sort`, `simple`, `simplehash`)\n VALUES ('&1', '&2', '&3', '&4')", $r['loc_id'], $text, $simpletext, sprintf("%u", crc32($simpletext))); } } } mysql_free_result($rs); function nonalpha($str) { for ($i = 0; $i < mb_strlen($str); $i++) {