Files
oc-server3/htdocs/util2/geodb/make_searchindex.php
T
following f5565a918c ported search.php & tools to lib2, and ...
- fixed logentry sorting for logs with identical date
- fixed ä etc. display in short descriptions on search results page
- try to select a matching language for the short descriptions
- added some translations
- hide download and map links if no search results (updates #235)
- nicer display of selectlocid page
- use site-dependent urls in GPX, LOC, TXT and KML
- unified XML encoding, now all done via two functions in lib2/util.inc.php (updates #121)
- some preventive XML encoding adjustments in GPX
- removed XML encoding in LOC CDATA section
- improved charset conversion for OVL and OV2 output
- some optimizations
- discarded lots of obsolete code
- disabled debug mode force_compile in OcSmarty class (performance)
2013-07-13 12:38:57 +02:00

58 lines
1.5 KiB
PHP
Executable File

#!/usr/local/bin/php -q
<?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($opt['rootpath'] . 'lib2/cli.inc.php');
require_once($opt['rootpath'] . 'lib2/search/search.inc.php');
sql('DELETE FROM geodb_search');
$rs = sql("
SELECT `loc_id`, `text_val`
FROM `geodb_textdata`
WHERE `text_type`=500100000
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`)
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++)
if (!((ord(mb_substr($str, $i, 1)) >= ord('a')) && (ord(mb_substr($str, $i, 1)) <= ord('z'))))
return true;
return false;
}
?>