From cb95c565bbf526b28fa620c46a51d81ecd91ab71 Mon Sep 17 00:00:00 2001 From: "Amin.MasterkinG" Date: Thu, 10 Sep 2020 12:11:07 +0430 Subject: [PATCH] Multi-language support - Part 1. --- application/config/config.php.sample | 5 ++++- application/include/functions.php | 10 ++++++++++ application/language/english.php | 12 ++++++++++++ application/language/index.html | 1 + application/loader.php | 16 +++++++++++----- 5 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 application/language/english.php create mode 100644 application/language/index.html diff --git a/application/config/config.php.sample b/application/config/config.php.sample index 299ba18..32762d7 100644 --- a/application/config/config.php.sample +++ b/application/config/config.php.sample @@ -11,9 +11,12 @@ baseurl That's your website URL. Example: "https://DOMAIN.COM" page_title That's your website title. Example: "My WOW Private server!" +language + Website language (english) =====================================================================*/ $config['baseurl'] = "http://localhost"; $config['page_title'] = "Simple Register"; +$config['language'] = "english"; /*=================================================================== If you see a white screen or have an issue, you can enable it to see the errors. Note that after testing, be sure to disable this option. @@ -296,4 +299,4 @@ $config['realmlists'] = array( // Add your realmlist here -$config['script_version'] = '1.9.8'; +$config['script_version'] = '1.9.9'; diff --git a/application/include/functions.php b/application/include/functions.php index c676441..21a1458 100644 --- a/application/include/functions.php +++ b/application/include/functions.php @@ -340,4 +340,14 @@ function verifySRP6($user, $pass, $salt, $verifier) ); $v = gmp_powm($g, $x, $N); return ($verifier === str_pad(gmp_export($v, 1, GMP_LSW_FIRST), 32, chr(0), STR_PAD_RIGHT)); +} + +// Get language text +function lang($val) +{ + global $language; + if (!empty($language[$val])) { + return $language[$val]; + } + return ""; } \ No newline at end of file diff --git a/application/language/english.php b/application/language/english.php new file mode 100644 index 0000000..57f8302 --- /dev/null +++ b/application/language/english.php @@ -0,0 +1,12 @@ +MasterkinG32.CoM \ No newline at end of file diff --git a/application/loader.php b/application/loader.php index bffce0f..40ea3b0 100644 --- a/application/loader.php +++ b/application/loader.php @@ -34,14 +34,20 @@ require_once app_path . 'include/database.php'; require_once app_path . 'include/user.php'; require_once app_path . 'include/vote.php'; require_once app_path . 'include/status.php'; + +if (!preg_match('/^([a-z]+)$/i', get_config('language')) || !file_exists(app_path . 'language/' . get_config('language') . '.php')) { + die('Language is not valid!'); +} + +require_once app_path . 'language/' . get_config('language') . '.php'; + $antiXss = new AntiXSS(); if (!empty(get_config('script_version'))) { /* @TODO Add online version check! */ - if(version_compare(get_config('script_version'), '1.9.8', '<') ) - { - echo 'Use last version of config.php file.'; - exit(); - } + if (version_compare(get_config('script_version'), '1.9.9', '<')) { + echo 'Use last version of config.php file.'; + exit(); + } } else { echo 'Use last version of config.php file.'; exit();