update language
This commit is contained in:
parent
dcc2695657
commit
c6ba200ff0
12 changed files with 216 additions and 556 deletions
|
@ -6,7 +6,7 @@ if (!defined('IN_SYS')) {
|
|||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?php echo $lang->get_lang(); ?>">
|
||||
<html lang="<?php echo $lang->language_current; ?>">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
|
@ -25,8 +25,8 @@ if (!defined('IN_SYS')) {
|
|||
<script src="assets/respond/respond.min.js?_=<?php echo $static_release; ?>"></script>
|
||||
<![endif]-->
|
||||
<script type="text/javascript">
|
||||
var domain = "<?php echo $lang->getDomain(); ?>";
|
||||
var cur_lang = "<?php echo $lang->get_lang(); ?>";
|
||||
var domain = "<?php echo getDomain(); ?>";
|
||||
var cur_lang = "<?php echo $lang->language_current; ?>";
|
||||
var ifastnet_aff = <?php echo $iFastNetAff; ?>;
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
@ -1,178 +0,0 @@
|
|||
<?php
|
||||
define('IN_SYS', true);
|
||||
require_once ("core.php");
|
||||
$security_id = md5(rand(6000,getrandmax())); // $security_id = md5(rand(6000,PHP_INT_MAX));
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?php echo $lang->get_lang(); ?>">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title><?php echo $title; ?> - <?php echo $lang->I18N('register'); ?></title>
|
||||
<?php include ("headmate.php"); ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php include ("nav.php"); ?>
|
||||
|
||||
<div class="container">
|
||||
<div class="form-group form-horizontal form-account">
|
||||
<input type="hidden" name="plan_name" value="free webhosting">
|
||||
<div class="form-group">
|
||||
<label for="inputUsername" class="control-label"><?php echo $lang->I18N('username'); ?></label>
|
||||
<input type="text" name="username" class="form-control" id="inputUsername" placeholder="<?php echo $lang->I18N('input_username'); ?>" value="<?php if (isset($_GET['username'])) { echo $_GET['username']; }?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputDomain" class="control-label"><?php echo $lang->I18N('domain'); ?></label>
|
||||
<input type="text" name="domain" class="form-control" id="inputDomain" placeholder="<?php echo $lang->I18N('input-domain'); ?>" value="<?php if (isset($_GET['domain'])) { echo $_GET['domain']; }?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputPassword" class="control-label"><?php echo $lang->I18N('password'); ?></label>
|
||||
<input type="password" name="password" class="form-control" id="inputPassword" placeholder="<?php echo $lang->I18N('input_password'); ?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputEmail" class="control-label"><?php echo $lang->I18N('email'); ?></label>
|
||||
<input type="email" name="email" class="form-control" id="inputEmail" placeholder="<?php echo $lang->I18N('input_email'); ?>" value="<?php if (isset($_GET['email'])) { echo $_GET['email']; }?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputCategory" class="control-label"><?php echo $lang->I18N('site_category'); ?></label>
|
||||
<select class="form-control" name="website_category" id="inputCategory">
|
||||
<option><?php echo $lang->I18N('choose_from_below'); ?></option>
|
||||
<option><?php echo $lang->I18N('personal'); ?></option>
|
||||
<option><?php echo $lang->I18N('business'); ?></option>
|
||||
<option><?php echo $lang->I18N('hobby'); ?></option>
|
||||
<option><?php echo $lang->I18N('forum'); ?></option>
|
||||
<option><?php echo $lang->I18N('dating'); ?></option>
|
||||
<option><?php echo $lang->I18N('software_download'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputLanguage" class="control-label"><?php echo $lang->I18N('site_language'); ?></label>
|
||||
<select class="form-control" name="website_language" id="inputLanguage">
|
||||
<option><?php echo $lang->I18N('choose_from_below'); ?></option>
|
||||
<!-- <option data-i18n="english">English</option> -->
|
||||
<!-- <option data-i18n="non_english">Non-English</option> -->
|
||||
<option selected="selected" value="English">Auto: English</option>
|
||||
<option>Afrikaans</option>
|
||||
<option>Albanian</option>
|
||||
<option>Amharic</option>
|
||||
<option>Arabic</option>
|
||||
<option>Armenian</option>
|
||||
<option>Azeerbaijani</option>
|
||||
<option>Basque</option>
|
||||
<option>Belarusian</option>
|
||||
<option>Bengali</option>
|
||||
<option>Bosnian</option>
|
||||
<option>Bulgarian</option>
|
||||
<option>Burmese</option>
|
||||
<option>Catalan</option>
|
||||
<option>Cebuano</option>
|
||||
<option>Chichewa</option>
|
||||
<option>Chinese_simplified</option>
|
||||
<option>Chinese_traditional</option>
|
||||
<option>Corsican</option>
|
||||
<option>Croatian</option>
|
||||
<option>Czech</option>
|
||||
<option>Danish</option>
|
||||
<option>Dutch</option>
|
||||
<option>English</option>
|
||||
<option>Esperanto</option>
|
||||
<option>Estonian</option>
|
||||
<option>Farsi</option>
|
||||
<option>Filipino</option>
|
||||
<option>Finnish</option>
|
||||
<option>French</option>
|
||||
<option>Frisian</option>
|
||||
<option>Galician</option>
|
||||
<option>Georgian</option>
|
||||
<option>German</option>
|
||||
<option>Greek</option>
|
||||
<option>Gujarati</option>
|
||||
<option>Haitian Creole</option>
|
||||
<option>Hausa</option>
|
||||
<option>Hawaiian</option>
|
||||
<option>Hebrew</option>
|
||||
<option>Hindi</option>
|
||||
<option>Hmong</option>
|
||||
<option>Hungarian</option>
|
||||
<option>Icelandic</option>
|
||||
<option>Igbo</option>
|
||||
<option>Indonesian</option>
|
||||
<option>Irish</option>
|
||||
<option>Italian</option>
|
||||
<option>Japanese</option>
|
||||
<option>Javanese</option>
|
||||
<option>Kannada</option>
|
||||
<option>Kazakh</option>
|
||||
<option>Khmer</option>
|
||||
<option>Korean</option>
|
||||
<option>Kurdish</option>
|
||||
<option>Kyrgyz</option>
|
||||
<option>Lao</option>
|
||||
<option>Latin</option>
|
||||
<option>Latvian</option>
|
||||
<option>Lithuanian</option>
|
||||
<option>Luxembourgish</option>
|
||||
<option>Macedonian</option>
|
||||
<option>Malagasy</option>
|
||||
<option>Malay</option>
|
||||
<option>Malayalam</option>
|
||||
<option>Maltese</option>
|
||||
<option>Maori</option>
|
||||
<option>Marathi</option>
|
||||
<option>Mongolian</option>
|
||||
<option>Nepali</option>
|
||||
<option>Norwegian</option>
|
||||
<option>Pashto</option>
|
||||
<option>Persian</option>
|
||||
<option>Polish</option>
|
||||
<option>Portuguese</option>
|
||||
<option>Punjabi</option>
|
||||
<option>Romanian</option>
|
||||
<option>Russian</option>
|
||||
<option>Samoan</option>
|
||||
<option>Scots Gaelic</option>
|
||||
<option>Serbian</option>
|
||||
<option>Sesotho</option>
|
||||
<option>Shona</option>
|
||||
<option>Sindhi</option>
|
||||
<option>Sinhala</option>
|
||||
<option>Slovak</option>
|
||||
<option>Slovenian</option>
|
||||
<option>Somali</option>
|
||||
<option>Spanish</option>
|
||||
<option>Sundanese</option>
|
||||
<option>Swahili</option>
|
||||
<option>Swedish</option>
|
||||
<option>Tajik</option>
|
||||
<option>Tamil</option>
|
||||
<option>Telugu</option>
|
||||
<option>Thai</option>
|
||||
<option>Turkish</option>
|
||||
<option>Ukrainian</option>
|
||||
<option>Urdu</option>
|
||||
<option>Uzbek</option>
|
||||
<option>Vietnamese</option>
|
||||
<option>Welsh</option>
|
||||
<option>Xhosa</option>
|
||||
<option>Yiddish</option>
|
||||
<option>Yoruba</option>
|
||||
<option>Zulu</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputID" class="control-label"><?php echo $lang->I18N('security_code'); ?></label>
|
||||
<img width="90px" height="25px" src="./security_code.php?id=<?=$security_id?>">
|
||||
<input type="hidden" name="id" class="form-control" id="inputID" value="<?=$security_id?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputSecurityCode" class="control-label"><?php echo $lang->I18N('input_security_code'); ?></label>
|
||||
<input type="text" name="number" class="form-control" id="inputSecurityCode" placeholder="<?php echo $lang->I18N('input_security_code_above'); ?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="submit" name="submit" class="btn btn-primary"><?php echo $lang->I18N('register'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include ("footer.php"); ?>
|
||||
</body>
|
||||
</html>
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
require_once("core.php");
|
||||
$domain = "uiisc.com";
|
||||
$post_data = $_POST;
|
||||
print_r($post_data);
|
||||
$data = file_get_contents("php://input");
|
||||
$url = "http://order.{$domain}/register.php";
|
||||
// $data = $post_data;
|
||||
function curlrequest($url, $data, $method = "post")
|
||||
{
|
||||
$ch = curl_init(); // 初始化CURL句柄
|
||||
curl_setopt($ch, CURLOPT_URL, $url); // 设置请求的URL
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // 设为TRUE把curl_exec()结果转化为字串,而不是直接输出
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); // 设置请求方式
|
||||
curl_setopt($ch, CURLOPT_REFERER, $url); // 构造来路
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-HTTP-Method-Override: $method")); // 设置HTTP头信息
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // 设置提交的字符串
|
||||
$document = curl_exec($ch); // 执行预定义的CURL
|
||||
if (!curl_errno($ch)) {
|
||||
$info = curl_getinfo($ch);
|
||||
echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url'];
|
||||
} else {
|
||||
echo 'Curl error: ' . curl_error($ch);
|
||||
}
|
||||
curl_close($ch);
|
||||
// $document=preg_replace("/[\t\n\r]+/","",$document);
|
||||
return $document;
|
||||
}
|
||||
|
||||
$return = curlrequest($url, $post_data, "post");
|
||||
|
||||
var_dump($return);
|
||||
exit;
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
define('IN_SYS', true);
|
||||
require_once ("core.php");
|
||||
$domain = "uiisc.com";
|
||||
// $html = file_get_contents("http://cpanel.".$domain."/lostpassword.php");
|
||||
// preg_match('/<footer[^>]*id="footer"[^>]*>(.*?) <//footer>/si', $html, $match);
|
||||
$password_reset_token_id = "b374b5bd4e35d2cadd98caa77d68c19a";
|
||||
$logged_ipaddress = "116.228.234.98";
|
||||
$title = $title . ' - Lost Password / Password Recovery';
|
||||
?>
|
||||
<?php include ("header.php"); ?>
|
||||
|
||||
<div class="container">
|
||||
<!--<?=$match?>-->
|
||||
<!--<?=$str_code?>-->
|
||||
<blink>ipaddress logged <?=$logged_ipaddress?></blink>
|
||||
<h2 data-i18n="password_eset">Lost Password Retrieval System</h2>
|
||||
<form class="form-signin" role="form" action="http://cpanel.<?=$domain?>/passwords.php" method="post" name="password_reset">
|
||||
<h2 data-i18n="password_eset">Password Reset</h2>
|
||||
<input type="hidden" name="token" value="<?=$password_reset_token_id?>">
|
||||
<div class="form-group">
|
||||
<label for="inputUsername" class="control-label" data-i18n="username">Username</label>
|
||||
<input type="text" name="username" class="form-control" id="inputUsername" placeholder="Username" data-i18n="input_username" required autofocus>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputEmail" class="control-label" data-i18n="email">Email Address</label>
|
||||
<input type="email" name="email" class="form-control" id="inputEmail" placeholder="Email Address" data-i18n="input_email" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="submit" name="submit" class="btn btn-primary btn-block" data-i18n="Fetch">Fetch</button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="row">
|
||||
<p>In the above form, enter the username and the REGISTERED email address that was used when signing up for the account.<br>
|
||||
We will then email the registered email address with reset account details.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php include ("footer.php"); ?>
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
define('IN_SYS', true);
|
||||
require_once ("core.php");
|
||||
$domain = "uiisc.com";
|
||||
$logged_ipaddress = "116.228.234.98";
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title><?=$title?> - Lost Password / Password Recovery</title>
|
||||
<?php include ("headmate.php"); ?>
|
||||
</head>
|
||||
<body>
|
||||
<?php include ("nav.php"); ?>
|
||||
|
||||
<div class="container">
|
||||
<blink>ipaddress logged <?=$logged_ipaddress?></blink>
|
||||
<!-- <h2 data-i18n="password_eset">Lost Password Retrieval System</h2> -->
|
||||
<div class="form-group form-horizontal form-account">
|
||||
<!-- <h2 data-i18n="password_eset">Password Reset</h2> -->
|
||||
<input type="hidden" name="ipaddress" value="<?=$logged_ipaddress?>">
|
||||
<div class="form-group">
|
||||
<label for="inputUsername" class="control-label" data-i18n="username">Username</label>
|
||||
<input type="text" name="username" class="form-control" id="inputUsername" placeholder="Username" data-i18n="input_username" required autofocus>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputEmail" class="control-label" data-i18n="email">Email Address</label>
|
||||
<input type="email" name="email" class="form-control" id="inputEmail" placeholder="Email Address" data-i18n="input_email" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Not yet have an account ?</label>
|
||||
<label><a href="register.php"><?php echo $lang->I18N('register'); ?></a></label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="submit" name="submit" class="btn btn-primary btn-block">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<p>In the above form, enter the username and the REGISTERED email address that was used when signing up for the account.<br>
|
||||
We will then email the registered email address with reset account details.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php include ("footer.php"); ?>
|
||||
</body>
|
||||
</html>
|
|
@ -6,7 +6,7 @@ if (!defined('IN_SYS')) {
|
|||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?php echo $lang->get_lang(); ?>">
|
||||
<html lang="<?php echo $lang->language_current; ?>">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
|
@ -25,8 +25,8 @@ if (!defined('IN_SYS')) {
|
|||
<script src="assets/respond/respond.min.js?_=<?php echo $static_release; ?>"></script>
|
||||
<![endif]-->
|
||||
<script type="text/javascript">
|
||||
var domain = "<?php echo $lang->getDomain(); ?>";
|
||||
var cur_lang = "<?php echo $lang->get_lang(); ?>";
|
||||
var domain = "<?php echo getDomain(); ?>";
|
||||
var cur_lang = "<?php echo $lang->language_current; ?>";
|
||||
var ifastnet_aff = <?php echo $iFastNetAff; ?>;
|
||||
</script>
|
||||
</head>
|
||||
|
|
3
core.php
3
core.php
|
@ -6,7 +6,6 @@ if (!defined('IN_SYS')) {
|
|||
}
|
||||
$ROOT = __DIR__;
|
||||
include_once "{$ROOT}/data/config.php";
|
||||
include_once "{$ROOT}/data/lang.php";
|
||||
include_once "{$ROOT}/library/lang.class.php";
|
||||
include_once "{$ROOT}/library/functions.php";
|
||||
include_once "{$ROOT}/library/pdo.class.php";
|
||||
|
@ -14,4 +13,4 @@ include_once "{$ROOT}/library/pdo.class.php";
|
|||
$rooturl = $_SERVER['HTTP_HOST'];
|
||||
$domain = preg_replace('/^www\./', '', $rooturl);
|
||||
|
||||
$lang = new Language("{$ROOT}/data/language/", $languages, 'en-US');
|
||||
$lang = new Language("{$ROOT}/data/language/");
|
||||
|
|
|
@ -6,7 +6,7 @@ if (!defined('IN_SYS')) {
|
|||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?php echo $lang->get_lang(); ?>">
|
||||
<html lang="<?php echo $lang->language_current; ?>">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
|
@ -26,8 +26,8 @@ if (!defined('IN_SYS')) {
|
|||
<script src="assets/respond/respond.min.js?_=<?php echo $static_release; ?>"></script>
|
||||
<![endif]-->
|
||||
<script type="text/javascript">
|
||||
var domain = "<?php echo $lang->getDomain(); ?>";
|
||||
var cur_lang = "<?php echo $lang->get_lang(); ?>";
|
||||
var domain = "<?php echo getDomain(); ?>";
|
||||
var cur_lang = "<?php echo $lang->language_current; ?>";
|
||||
var ifastnet_aff = <?php echo $iFastNetAff; ?>;
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
@ -46,8 +46,8 @@ if (!defined('IN_SYS')) {
|
|||
</div>
|
||||
|
||||
<!-- <script type="text/javascript">
|
||||
var domain = "<?php echo $lang->getDomain(); ?>";
|
||||
var cur_language = "<?php echo $lang->get_lang(); ?>";
|
||||
var domain = "<?php echo getDomain(); ?>";
|
||||
var cur_language = "<?php echo $lang->language_current; ?>";
|
||||
function change_language(lan) {
|
||||
setCookie('lang', lan, 1, '/', domain, false);
|
||||
if (cur_language == lan) {
|
||||
|
|
111
data/lang.php
111
data/lang.php
|
@ -1,111 +0,0 @@
|
|||
<?php
|
||||
|
||||
$languages = [
|
||||
'en-US' => ['English', 'English'],
|
||||
'zh-CN' => ['简体中文', 'Chinese_simplified'],
|
||||
'zh-SG' => ['简体中文(新加坡)', 'Chinese_simplified'],
|
||||
'zh-HK' => ['繁體中文(香港)', 'Chinese_traditional'],
|
||||
'zh-TW' => ['繁體中文(台湾)', 'Chinese_traditional'],
|
||||
'af' => ['Afrikaans', 'Afrikaans'],
|
||||
'sq' => ['የአልባኒያ', 'Albanian'],
|
||||
'am' => ['Amharic', 'Amharic'],
|
||||
'ar' => ['Arabic', 'Arabic'],
|
||||
'hy' => ['Armenian', 'Armenian'],
|
||||
'az' => ['Azərbaycan', 'Azeerbaijani'],
|
||||
'eu' => ['Basque', 'Basque'],
|
||||
'be' => ['Belarusian', 'Belarusian'],
|
||||
'bn' => ['Bengali', 'Bengali'],
|
||||
'bs' => ['Bosnian', 'Bosnian'],
|
||||
'bg' => ['Bulgarian', 'Bulgarian'],
|
||||
'my' => ['Burmese', 'Burmese'],
|
||||
'ca' => ['Catalan', 'Catalan'],
|
||||
'ce' => ['Cebuano', 'Cebuano'], // 宿务语
|
||||
'ch' => ['Chichewa', 'Chichewa'],
|
||||
'co' => ['Corsican', 'Corsican'],
|
||||
'hr' => ['Croatian', 'Croatian'],
|
||||
'cs' => ['Czech', 'Czech'],
|
||||
'da' => ['Danish', 'Danish'],
|
||||
'nl' => ['Dutch', 'Dutch'],
|
||||
'eo' => ['Esperanto', 'Esperanto'],
|
||||
'et' => ['Estonian', 'Estonian'],
|
||||
'fa' => ['Farsi', 'Farsi'],
|
||||
'fil' => ['Filipino', 'Filipino'],
|
||||
'fi' => ['Finnish', 'Finnish'],
|
||||
'fr' => ['français', 'French'],
|
||||
'fy' => ['Frisian', 'Frisian'],
|
||||
'gl' => ['Galician', 'Galician'],
|
||||
'ka' => ['Georgian', 'Georgian'],
|
||||
'de' => ['Deutsch', 'German'],
|
||||
'el' => ['Greek', 'Greek'],
|
||||
'gu' => ['Gujarati', 'Gujarati'],
|
||||
'ko' => ['Haitian Creole', 'Haitian Creole'],
|
||||
'ha' => ['Hausa', 'Hausa'],
|
||||
'haw' => ['Hawaiian', 'Hawaiian'],
|
||||
'he' => ['Hebrew', 'Hebrew'],
|
||||
'hi' => ['Hindi', 'Hindi'],
|
||||
'hm' => ['Hmong', 'Hmong'],
|
||||
'hu' => ['Hungarian', 'Hungarian'],
|
||||
'is' => ['Icelandic', 'Icelandic'],
|
||||
'ig' => ['Igbo', 'Igbo'],
|
||||
'id' => ['Indonesian', 'Indonesian'],
|
||||
'ga' => ['Irish', 'Irish'],
|
||||
'it' => ['Italian', 'Italian'],
|
||||
'jp' => ['日本語', 'Japanese'],
|
||||
'jv' => ['Wong Jawa', 'Javanese'],
|
||||
'kn' => ['Kannada', 'Kannada'],
|
||||
'kk' => ['Kazakh', 'Kazakh'],
|
||||
'kh' => ['Khmer', 'Khmer'],
|
||||
'ko' => ['한국의', 'Korean'],
|
||||
'ku' => ['Kurdish', 'Kurdish'],
|
||||
'kz' => ['Kyrgyz', 'Kyrgyz'],
|
||||
'lo' => ['ພາສາລາວ', 'Lao'],
|
||||
'la' => ['Latinae', 'Latin'],
|
||||
'lv' => ['Latvian', 'Latvian'],
|
||||
'lt' => ['Lithuanian', 'Lithuanian'],
|
||||
'lu' => ['Luxembourgish', 'Luxembourgish'],
|
||||
'mk' => ['Macedonian', 'Macedonian'],
|
||||
'ma' => ['Malagasy', 'Malagasy'],
|
||||
'ms' => ['Malay', 'Malay'],
|
||||
'ml' => ['Malayalam', 'Malayalam'],
|
||||
'mt' => ['Maltese', 'Maltese'],
|
||||
'ma' => ['Maori', 'Maori'],
|
||||
'mr' => ['Marathi', 'Marathi'],
|
||||
'mn' => ['Mongolian', 'Mongolian'],
|
||||
'ne' => ['Nepali', 'Nepali'],
|
||||
'no' => ['Norwegian', 'Norwegian'],
|
||||
'pa' => ['Pashto', 'Pashto'],
|
||||
'pe' => ['Persian', 'Persian'],
|
||||
'po' => ['Polish', 'Polish'],
|
||||
'pg' => ['Português', 'Portuguese'],
|
||||
'pu' => ['Punjabi', 'Punjabi'],
|
||||
'ro' => ['Romanian', 'Romanian'],
|
||||
'ru' => ['Russian', 'Russian'],
|
||||
'sa' => ['Samoan', 'Samoan'],
|
||||
'gd' => ['Scots Gaelic', 'Scots Gaelic'],
|
||||
'sr' => ['Serbian', 'Serbian'],
|
||||
'se' => ['Sesotho', 'Sesotho'],
|
||||
'sh' => ['Shona', 'Shona'],
|
||||
'si' => ['Sindhi', 'Sindhi'],
|
||||
'sin' => ['Sinhala', 'Sinhala'],
|
||||
'sk' => ['Slovak', 'Slovak'],
|
||||
'sl' => ['Slovenian', 'Slovenian'],
|
||||
'so' => ['Somali', 'Somali'],
|
||||
'es' => ['Spanish', 'Spanish'],
|
||||
'su' => ['Sundanese', 'Sundanese'],
|
||||
'sw' => ['Swahili', 'Swahili'],
|
||||
'sv' => ['Swedish', 'Swedish'],
|
||||
'tj' => ['Tajik', 'Tajik'],
|
||||
'ta' => ['Tamil', 'Tamil'],
|
||||
'te' => ['Telugu', 'Telugu'],
|
||||
'ts' => ['Thai', 'Thai'],
|
||||
'tu' => ['Turkish', 'Turkish'],
|
||||
'uk' => ['Ukrainian', 'Ukrainian'],
|
||||
'ur' => ['Urdu', 'Urdu'],
|
||||
'uz' => ['Uzbek', 'Uzbek'],
|
||||
'vi' => ['Vietnamese', 'Vietnamese'],
|
||||
'we' => ['Welsh', 'Welsh'],
|
||||
'xh' => ['Xhosa', 'Xhosa'],
|
||||
'yi' => ['Yiddish', 'Yiddish'],
|
||||
'yo' => ['Yorùbá', 'Yoruba'],
|
||||
'zu' => ['Zulu', 'Zulu'],
|
||||
];
|
|
@ -219,7 +219,7 @@ function is_email($email = "")
|
|||
*/
|
||||
function getVersion()
|
||||
{
|
||||
if ((float)phpversion() < 5.5) {
|
||||
if ((float) phpversion() < 5.5) {
|
||||
exit('requires the php version 5.5.+');
|
||||
}
|
||||
}
|
||||
|
@ -228,3 +228,20 @@ function setProtect($x)
|
|||
{
|
||||
return htmlentities(htmlspecialchars($x));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get current domain
|
||||
*/
|
||||
function getDomain()
|
||||
{
|
||||
$domain = $_SERVER['SERVER_NAME'];
|
||||
if (strcasecmp($domain, "localhost") === 0) {
|
||||
return $domain;
|
||||
}
|
||||
if (preg_match("/^(\\d+\\.){3}\\d+\$/", $domain, $domain_temp)) {
|
||||
return $domain_temp[0];
|
||||
}
|
||||
preg_match_all("/\\w+\\.\\w+\$/", $domain, $domain);
|
||||
return $domain[0][0];
|
||||
}
|
||||
|
|
|
@ -2,164 +2,207 @@
|
|||
|
||||
class Language
|
||||
{
|
||||
public $language_area; // area
|
||||
public $language_country; // country
|
||||
public $language_dir;
|
||||
public $languages; // languages enabled
|
||||
public $dir;
|
||||
|
||||
public function __construct($language_root, $languages, $lang_default = "en-US")
|
||||
public $language_current;
|
||||
private $language_cached;
|
||||
private $language_default;
|
||||
private $language_root;
|
||||
private $language_file;
|
||||
private $languages = [
|
||||
'en-US' => ['English', 'English'],
|
||||
'zh-CN' => ['简体中文', 'Chinese_simplified'],
|
||||
'zh-SG' => ['简体中文(新加坡)', 'Chinese_simplified'],
|
||||
'zh-HK' => ['繁體中文(香港)', 'Chinese_traditional'],
|
||||
'zh-TW' => ['繁體中文(台湾)', 'Chinese_traditional'],
|
||||
'af' => ['Afrikaans', 'Afrikaans'],
|
||||
'sq' => ['የአልባኒያ', 'Albanian'],
|
||||
'am' => ['Amharic', 'Amharic'],
|
||||
'ar' => ['Arabic', 'Arabic'],
|
||||
'hy' => ['Armenian', 'Armenian'],
|
||||
'az' => ['Azərbaycan', 'Azeerbaijani'],
|
||||
'eu' => ['Basque', 'Basque'],
|
||||
'be' => ['Belarusian', 'Belarusian'],
|
||||
'bn' => ['Bengali', 'Bengali'],
|
||||
'bs' => ['Bosnian', 'Bosnian'],
|
||||
'bg' => ['Bulgarian', 'Bulgarian'],
|
||||
'my' => ['Burmese', 'Burmese'],
|
||||
'ca' => ['Catalan', 'Catalan'],
|
||||
'ce' => ['Cebuano', 'Cebuano'], // 宿务语
|
||||
'ch' => ['Chichewa', 'Chichewa'],
|
||||
'co' => ['Corsican', 'Corsican'],
|
||||
'hr' => ['Croatian', 'Croatian'],
|
||||
'cs' => ['Czech', 'Czech'],
|
||||
'da' => ['Danish', 'Danish'],
|
||||
'nl' => ['Dutch', 'Dutch'],
|
||||
'eo' => ['Esperanto', 'Esperanto'],
|
||||
'et' => ['Estonian', 'Estonian'],
|
||||
'fa' => ['Farsi', 'Farsi'],
|
||||
'fil' => ['Filipino', 'Filipino'],
|
||||
'fi' => ['Finnish', 'Finnish'],
|
||||
'fr' => ['français', 'French'],
|
||||
'fy' => ['Frisian', 'Frisian'],
|
||||
'gl' => ['Galician', 'Galician'],
|
||||
'ka' => ['Georgian', 'Georgian'],
|
||||
'de' => ['Deutsch', 'German'],
|
||||
'el' => ['Greek', 'Greek'],
|
||||
'gu' => ['Gujarati', 'Gujarati'],
|
||||
'ko' => ['Haitian Creole', 'Haitian Creole'],
|
||||
'ha' => ['Hausa', 'Hausa'],
|
||||
'haw' => ['Hawaiian', 'Hawaiian'],
|
||||
'he' => ['Hebrew', 'Hebrew'],
|
||||
'hi' => ['Hindi', 'Hindi'],
|
||||
'hm' => ['Hmong', 'Hmong'],
|
||||
'hu' => ['Hungarian', 'Hungarian'],
|
||||
'is' => ['Icelandic', 'Icelandic'],
|
||||
'ig' => ['Igbo', 'Igbo'],
|
||||
'id' => ['Indonesian', 'Indonesian'],
|
||||
'ga' => ['Irish', 'Irish'],
|
||||
'it' => ['Italian', 'Italian'],
|
||||
'jp' => ['日本語', 'Japanese'],
|
||||
'jv' => ['Wong Jawa', 'Javanese'],
|
||||
'kn' => ['Kannada', 'Kannada'],
|
||||
'kk' => ['Kazakh', 'Kazakh'],
|
||||
'kh' => ['Khmer', 'Khmer'],
|
||||
'ko' => ['한국의', 'Korean'],
|
||||
'ku' => ['Kurdish', 'Kurdish'],
|
||||
'kz' => ['Kyrgyz', 'Kyrgyz'],
|
||||
'lo' => ['ພາສາລາວ', 'Lao'],
|
||||
'la' => ['Latinae', 'Latin'],
|
||||
'lv' => ['Latvian', 'Latvian'],
|
||||
'lt' => ['Lithuanian', 'Lithuanian'],
|
||||
'lu' => ['Luxembourgish', 'Luxembourgish'],
|
||||
'mk' => ['Macedonian', 'Macedonian'],
|
||||
'ma' => ['Malagasy', 'Malagasy'],
|
||||
'ms' => ['Malay', 'Malay'],
|
||||
'ml' => ['Malayalam', 'Malayalam'],
|
||||
'mt' => ['Maltese', 'Maltese'],
|
||||
'ma' => ['Maori', 'Maori'],
|
||||
'mr' => ['Marathi', 'Marathi'],
|
||||
'mn' => ['Mongolian', 'Mongolian'],
|
||||
'ne' => ['Nepali', 'Nepali'],
|
||||
'no' => ['Norwegian', 'Norwegian'],
|
||||
'pa' => ['Pashto', 'Pashto'],
|
||||
'pe' => ['Persian', 'Persian'],
|
||||
'po' => ['Polish', 'Polish'],
|
||||
'pg' => ['Português', 'Portuguese'],
|
||||
'pu' => ['Punjabi', 'Punjabi'],
|
||||
'ro' => ['Romanian', 'Romanian'],
|
||||
'ru' => ['Russian', 'Russian'],
|
||||
'sa' => ['Samoan', 'Samoan'],
|
||||
'gd' => ['Scots Gaelic', 'Scots Gaelic'],
|
||||
'sr' => ['Serbian', 'Serbian'],
|
||||
'se' => ['Sesotho', 'Sesotho'],
|
||||
'sh' => ['Shona', 'Shona'],
|
||||
'si' => ['Sindhi', 'Sindhi'],
|
||||
'sin' => ['Sinhala', 'Sinhala'],
|
||||
'sk' => ['Slovak', 'Slovak'],
|
||||
'sl' => ['Slovenian', 'Slovenian'],
|
||||
'so' => ['Somali', 'Somali'],
|
||||
'es' => ['Spanish', 'Spanish'],
|
||||
'su' => ['Sundanese', 'Sundanese'],
|
||||
'sw' => ['Swahili', 'Swahili'],
|
||||
'sv' => ['Swedish', 'Swedish'],
|
||||
'tj' => ['Tajik', 'Tajik'],
|
||||
'ta' => ['Tamil', 'Tamil'],
|
||||
'te' => ['Telugu', 'Telugu'],
|
||||
'ts' => ['Thai', 'Thai'],
|
||||
'tu' => ['Turkish', 'Turkish'],
|
||||
'uk' => ['Ukrainian', 'Ukrainian'],
|
||||
'ur' => ['Urdu', 'Urdu'],
|
||||
'uz' => ['Uzbek', 'Uzbek'],
|
||||
'vi' => ['Vietnamese', 'Vietnamese'],
|
||||
'we' => ['Welsh', 'Welsh'],
|
||||
'xh' => ['Xhosa', 'Xhosa'],
|
||||
'yi' => ['Yiddish', 'Yiddish'],
|
||||
'yo' => ['Yorùbá', 'Yoruba'],
|
||||
'zu' => ['Zulu', 'Zulu'],
|
||||
];
|
||||
private $LANG;
|
||||
private $domain;
|
||||
|
||||
/** 构造函数
|
||||
* @param string $language_root 翻译文件根目录
|
||||
* @param array $languages 可用语言列表
|
||||
* @param string $lang_default 默认语言
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($language_root, $lang_default = '')
|
||||
{
|
||||
$this->dir = $language_root;
|
||||
$this->language_area = $lang_default;
|
||||
$this->languages = $languages;
|
||||
$this->initDefaultLanguage();
|
||||
if (empty($this->language_country) && !empty($this->language_area)) {
|
||||
$this->language_country = substr($this->language_area, 0, strpos($this->language_area, "-"));
|
||||
$this->language_root = $language_root;
|
||||
if (!empty($lang_default) && array_key_exists($lang_default, $this->languages)) {
|
||||
$this->language_default = $lang_default;
|
||||
$this->language_current = $lang_default;
|
||||
} else {
|
||||
$this->language_default = 'en-US';
|
||||
$this->language_current = 'en-US';
|
||||
}
|
||||
$this->initLanguageDir();
|
||||
echo $this->getFileDir('language.php');
|
||||
echo $this->language_country;
|
||||
include $this->getFileDir('language.php');
|
||||
$this->LANG = $LANG;
|
||||
$this->init_domain();
|
||||
$this->init_language();
|
||||
$this->init_language_file();
|
||||
}
|
||||
|
||||
function I18N($key = "")
|
||||
{
|
||||
// global $LANG;
|
||||
return isset($key) ? isset($this->LANG[$key]) ? $this->LANG[$key] : $key : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* get absolute path of language file
|
||||
*/
|
||||
public function getFileDir($file)
|
||||
{
|
||||
if (file_exists($this->language_dir . $file)) {
|
||||
return $this->language_dir . $file;
|
||||
} else {
|
||||
echo '-----';
|
||||
if (file_exists($this->dir . $this->language_area . "/" . $file)) {
|
||||
return $this->dir . $this->language_area . "/" . $file;
|
||||
} else {
|
||||
if (file_exists($this->dir . $this->language_country . "/" . $file)) {
|
||||
return $this->dir . $this->language_country . "/" . $file;
|
||||
} else {
|
||||
return $this->dir . "en-US/" . $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get current language directory
|
||||
*/
|
||||
private function initLanguageDir()
|
||||
{
|
||||
if (file_exists($this->dir . $this->language_area) && !empty($this->language_area)) {
|
||||
$this->language_dir = $this->dir . $this->language_area . '/';
|
||||
} else {
|
||||
if (file_exists($this->dir . $this->language_country) && !empty($this->language_country)) {
|
||||
$this->language_dir = $this->dir . $this->language_country . '/';
|
||||
} else {
|
||||
$this->language_dir = $this->dir . 'en-US/';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the default language
|
||||
*/
|
||||
public function initDefaultLanguage()
|
||||
{
|
||||
if ($this->get_cookie_lang()) {
|
||||
return;
|
||||
}
|
||||
$language = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
||||
preg_match_all("/[\\w-]+/", $language, $language);
|
||||
$this->language_area = $language[0][0];
|
||||
@($this->language_country = $language[0][1]);
|
||||
$this->setCookieLanguage();
|
||||
}
|
||||
/**
|
||||
* get lang form cookie
|
||||
*/
|
||||
public function get_cookie_lang()
|
||||
{
|
||||
if (!@empty($_COOKIE['lang'])) {
|
||||
$language = $_COOKIE['lang'];
|
||||
if (strpos($language, "-")) {
|
||||
$this->language_area = $language;
|
||||
} else {
|
||||
$this->language_country = $language;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* set current language to cookie
|
||||
*/
|
||||
public function setCookieLanguage($lang = "")
|
||||
{
|
||||
if (empty($lang)) {
|
||||
$lang = $this->language_area;
|
||||
}
|
||||
if (empty($lang)) {
|
||||
$lang = $this->language_country;
|
||||
}
|
||||
if (empty($lang)) {
|
||||
return false;
|
||||
}
|
||||
setcookie("lang", $lang, time() + 365 * 24 * 3600, "/", $this->getDomain());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* get current domain
|
||||
*/
|
||||
public function getDomain()
|
||||
private function init_domain()
|
||||
{
|
||||
if (empty($this->domain)) {
|
||||
$domain = $_SERVER['SERVER_NAME'];
|
||||
if (strcasecmp($domain, "localhost") === 0) {
|
||||
if (strcasecmp($domain, 'localhost') === 0) {
|
||||
$this->domain = $domain;
|
||||
return $this->domain;
|
||||
}
|
||||
if (preg_match("/^(\\d+\\.){3}\\d+\$/", $domain, $domain_temp)) {
|
||||
} else if (preg_match("/^(\\d+\\.){3}\\d+\$/", $domain, $domain_temp)) {
|
||||
$this->domain = $domain_temp[0];
|
||||
return $this->domain;
|
||||
}
|
||||
} else {
|
||||
preg_match_all("/\\w+\\.\\w+\$/", $domain, $domain);
|
||||
$this->domain = $domain[0][0];
|
||||
return $this->domain;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function init_language()
|
||||
{
|
||||
if (!@empty(trim($_COOKIE['lang']))) {
|
||||
// has cached lang
|
||||
$this->language_cached = trim($_COOKIE['lang']);
|
||||
if (array_key_exists($this->language_cached, $this->languages) && $this->has_language_file($this->language_cached)) {
|
||||
$this->language_current = $this->language_cached;
|
||||
} else {
|
||||
return $this->domain;
|
||||
$this->language_current = $this->language_default;
|
||||
}
|
||||
} else {
|
||||
// get browser lang
|
||||
$lang_browser = $_SERVER['HTTP_ACCEPT_LANGUAGE']; // zh-CN,zh;q=0.9
|
||||
preg_match_all("/[\\w-]+/", $lang_browser, $lang_browser); // [['zh-CN', 'zh']]
|
||||
if (array_key_exists($lang_browser[0][0], $this->languages) && $this->has_language_file($lang_browser[0][0])) {
|
||||
$this->language_current = $lang_browser[0][0];
|
||||
} else if (array_key_exists($lang_browser[0][1], $this->languages) && $this->has_language_file($lang_browser[0][1])) {
|
||||
$this->language_current = $lang_browser[0][1];
|
||||
} else {
|
||||
$this->language_current = $this->language_default;
|
||||
}
|
||||
$this->language_cached = $this->language_current;
|
||||
setcookie("lang", $this->language_current, time() + 365 * 24 * 3600, "/", $this->domain);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* return current language directory
|
||||
*/
|
||||
public function get_language_dir()
|
||||
private function has_language_file($lang)
|
||||
{
|
||||
return $this->language_dir;
|
||||
return !empty($lang) && file_exists($this->language_root . $lang . '/' . 'language.php');
|
||||
}
|
||||
|
||||
public function get_lang()
|
||||
private function init_language_file()
|
||||
{
|
||||
if (array_key_exists($this->language_area, $this->languages)) {
|
||||
return $this->language_area;
|
||||
} else if (array_key_exists($this->language_country, $this->languages)) {
|
||||
return $this->language_country;
|
||||
if ($this->has_language_file($this->language_current)) {
|
||||
$this->language_file = $this->language_root . $this->language_current . '/' . 'language.php';
|
||||
} else {
|
||||
$this->language_file = $this->language_root . $this->language_default . '/' . 'language.php';
|
||||
}
|
||||
include $this->language_file;
|
||||
$this->LANG = $LANG;
|
||||
}
|
||||
|
||||
public function get_languages_tags()
|
||||
{
|
||||
$tags = '';
|
||||
foreach ($this->languages as $k => $value) {
|
||||
$actived = $k == $this->get_lang() ? ' class="active"' : '';
|
||||
foreach ($this->languages as $k => $v) {
|
||||
$actived = $k == $this->language_current ? ' class="active"' : '';
|
||||
$tags .= '<li' . $actived . '><a class="language-change-click" data-language="' . $k . '" href="javascript://">' . $this->languages[$k][0] . '</a></li>';
|
||||
}
|
||||
return $tags;
|
||||
|
@ -167,16 +210,25 @@ class Language
|
|||
|
||||
public function get_language_name()
|
||||
{
|
||||
return $this->languages[$this->get_lang()][0];
|
||||
return $this->languages[$this->language_current][0];
|
||||
}
|
||||
|
||||
/** 登录下拉框选项
|
||||
* language select for login to control panel
|
||||
* @return void
|
||||
*/
|
||||
public function get_languages_options()
|
||||
{
|
||||
$options = '';
|
||||
foreach ($this->languages as $k => $value) {
|
||||
$selected = $k == $this->get_lang() ? ' selected="selected"' : '';
|
||||
$options .= '<option value="' . $value[1] . '"' . $selected . '>' . $value[0] . '</option>';
|
||||
foreach ($this->languages as $k => $v) {
|
||||
$selected = $k == $this->language_cached ? ' selected="selected"' : '';
|
||||
$options .= '<option value="' . $v[1] . '"' . $selected . '>' . $v[0] . '</option>';
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function I18N($key = '')
|
||||
{
|
||||
return isset($key) ? isset($this->LANG[$key]) ? $this->LANG[$key] : $key : '';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue