function createLabelCache() { global $opt; foreach ($opt['locale'] as $sLanguage => $v) { // cheating a little bit $opt['template']['locale'] = $sLanguage; labels::CreateCacheFile(); // change to file owner $sFilename = $opt['rootpath'] . 'cache2/labels-' . $opt['template']['locale'] . '.inc.php'; chown($sFilename, $opt['httpd']['user']); chgrp($sFilename, $opt['httpd']['group']); } }
<?php /*************************************************************************** * For license information see doc/license.txt * * Unicode Reminder メモ ***************************************************************************/ // try to include cache file if (!file_exists($opt['rootpath'] . 'cache2/labels-' . $opt['template']['locale'] . '.inc.php')) { labels::CreateCacheFile(); } require $opt['rootpath'] . 'cache2/labels-' . $opt['template']['locale'] . '.inc.php'; class labels { static $aLabels = array(); static function CreateCacheFile() { global $opt; $f = fopen($opt['rootpath'] . 'cache2/labels-' . $opt['template']['locale'] . '.inc.php', 'w'); fwrite($f, "<?php\n"); $a = array(); $rs = sql("SELECT `cache_attrib`.`id`, IFNULL(`sys_trans_text`.`text`, `cache_attrib`.`name`) AS `name`\n\t\t FROM `cache_attrib`\n\t\t LEFT JOIN `sys_trans` ON `cache_attrib`.`trans_id`=`sys_trans`.`id` AND `cache_attrib`.`name`=`sys_trans`.`text`\n\t\t LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'", $opt['template']['locale']); while ($r = sql_fetch_assoc($rs)) { $a[$r['id']] = $r['name']; } sql_free_result($rs); fwrite($f, 'labels::addLabels("cache_attrib", "' . str_replace('"', '\\"', serialize($a)) . '");' . "\n"); $a = array(); $rs = sql("SELECT `cache_size`.`id`, IFNULL(`sys_trans_text`.`text`, `cache_size`.`name`) AS `name`\n\t\t FROM `cache_size`\n\t\t LEFT JOIN `sys_trans` ON `cache_size`.`trans_id`=`sys_trans`.`id` AND `cache_size`.`name`=`sys_trans`.`text`\n\t\t LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'", $opt['template']['locale']); while ($r = sql_fetch_assoc($rs)) { $a[$r['id']] = $r['name'];