Skip to content

Commit

Permalink
language converter, lang dbs
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwen committed Jan 26, 2021
1 parent ffe1cb8 commit 0d43925
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "mediawiki-zhconverter"]
path = mediawiki-zhconverter
url = https://github.com/soarqin/mediawiki-zhconverter.git
url = https://github.com/tszming/mediawiki-zhconverter.git
14 changes: 7 additions & 7 deletions label.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
}

// Uncomment briefly to clear the memory cache
apc_clear_cache();
// apc_clear_cache();

// APC - query cache
$key = md5($x.'|'.$y.'|'.$z.'|'.$lang.'|'.$g.'|'.$r);
if ($result = apc_fetch($key)) {
if ($result = apcu_fetch($key)) {
echo $result;
exit;
}
Expand All @@ -44,7 +44,7 @@
$langvariant = explode("-", $lang, 2);

// if a variant was provided check if it is supported
if (count($langvariant) == 2 && false) {
if (count($langvariant) == 2) {
$allvariant = explode(',',"zh-hans,zh-hant,zh-cn,zh-hk,zh-mo,zh-sg,zh-tw");
$variant = $lang;
if (array_search($variant, $allvariant) === FALSE) {
Expand All @@ -53,7 +53,7 @@
}

// set the mediawiki path for the mediawiki-zhconverter
define("MEDIAWIKI_PATH", "/opt/mediawiki-1.35.1");
define("MEDIAWIKI_PATH", "/opt/mediawiki-1.26.2");

// include character set converter
require_once "mediawiki-zhconverter/mediawiki-zhconverter.inc.php";
Expand Down Expand Up @@ -130,9 +130,9 @@
echo "Requesting too many tiles!";
exit;
}
$query = "select p.page_title as title, l.name as name, l.lat as lat, l.lon as lon, l.style as style, t.x as dx, t.y as dy, l.weight as wg, l.page_id as id from page_$lang p, wma_tile t, wma_connect c, wma_label l WHERE l.lang_id='$l' AND l.globe='$g' AND c.rev='$rev' AND c.tile_id=t.id AND ( ".implode(" OR ",$q)." ) AND c.label_id=l.id AND t.z='$z' AND c.tile_id = t.id AND l.page_id=p.page_id";
$query = "select p.page_title as title, l.name as name, l.lat as lat, l.lon as lon, l.style as style, t.x as dx, t.y as dy, l.weight as wg, l.page_id as id from page_$lang p, wma_tile t, wma_connect_$lang c, wma_label_$lang l WHERE l.globe='$g' AND c.rev='$rev' AND c.tile_id=t.id AND ( ".implode(" OR ",$q)." ) AND c.label_id=l.id AND t.z='$z' AND c.tile_id = t.id AND l.page_id=p.page_id";
} else {
$query = "select p.page_title as title, l.name as name, l.lat as lat, l.lon as lon, l.style as style, t.x as dx, t.y as dy, l.weight as wg, l.page_id as id from page_$lang p, wma_tile t, wma_connect c, wma_label l WHERE l.lang_id='$l' AND l.globe='$g' AND c.rev='$rev' AND c.tile_id=t.id AND t.x='$x' AND c.label_id=l.id AND t.y='$y' AND t.z='$z' AND c.tile_id = t.id AND l.page_id=p.page_id";
$query = "select p.page_title as title, l.name as name, l.lat as lat, l.lon as lon, l.style as style, t.x as dx, t.y as dy, l.weight as wg, l.page_id as id from page_$lang p, wma_tile t, wma_connect_$lang c, wma_label_$lang l WHERE l.globe='$g' AND c.rev='$rev' AND c.tile_id=t.id AND t.x='$x' AND c.label_id=l.id AND t.y='$y' AND t.z='$z' AND c.tile_id = t.id AND l.page_id=p.page_id";
}

$res = mysqli_query($db, $query);
Expand Down Expand Up @@ -201,5 +201,5 @@
header("Cache-Control: public, max-age=3600");
$result = json_encode( array( "label" => $items, "z" => $z ) );
echo $result;
apc_add($key, $result, 24*60*60); // cache 24h
apcu_store($key, $result, 24*60*60); // cache 24h
?>
2 changes: 1 addition & 1 deletion mediawiki-zhconverter

0 comments on commit 0d43925

Please sign in to comment.