summaryrefslogtreecommitdiff
path: root/includes/general.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/general.php')
-rw-r--r--includes/general.php200
1 files changed, 12 insertions, 188 deletions
diff --git a/includes/general.php b/includes/general.php
index 5c1b3f2..3478dd4 100644
--- a/includes/general.php
+++ b/includes/general.php
@@ -39,6 +39,7 @@
require_once($_SESSION['_config']['filepath']."/includes/mysql.php");
require_once($_SESSION['_config']['filepath'].'/includes/lib/account.php');
+ require_once($_SESSION['_config']['filepath'].'/includes/lib/l10n.php');
if(array_key_exists('HTTP_HOST',$_SERVER) &&
$_SERVER['HTTP_HOST'] != $_SESSION['_config']['normalhostname'] &&
@@ -70,177 +71,8 @@
}
}
-
- ///////////////////////
- // Language Handling //
- ///////////////////////
-
- $_SESSION['_config']['translations'] = array(
- "ar" => "العربية",
- "bg" => "Български",
- "cs" => "Čeština",
- "da" => "Dansk",
- "de" => "Deutsch",
- "el" => "Ελληνικά",
- "en" => "English",
- "es" => "Español",
- "fi" => "Suomi",
- "fr" => "Français",
- "hu" => "Magyar",
- "it" => "Italiano",
- "ja" => "日本語",
- "lv" => "Latviešu",
- "nl" => "Nederlands",
- "pl" => "Polski",
- "pt" => "Português",
- "pt-br" => "Português Brasileiro",
- "ru" => "Русский",
- "sv" => "Svenska",
- "tr" => "Türkçe",
- "zh-cn" => "中文(简体)",
- "zh-tw" => "中文(臺灣)");
-
-
-
- if((array_key_exists("lang",$_REQUEST) && trim($_REQUEST["lang"]) != "") ||
- !(array_key_exists('language',$_SESSION['_config']) &&
- $_SESSION['_config']['language'] != "") )
- {
- $languages=array();
-
- // parse Accept-Language header
- $bits = explode(",", strtolower(str_replace(" ", "", array_key_exists('HTTP_ACCEPT_LANGUAGE',$_SERVER)?$_SERVER['HTTP_ACCEPT_LANGUAGE']:"")));
- foreach($bits as $lang)
- {
- $b = explode(";", $lang);
- if(count($b)>1 && substr($b[1], 0, 2) == "q=")
- $c = floatval(substr($b[1], 2));
- else
- $c = 1;
-
- if ($c != 0)
- {
- $languages["$c"] = trim($b[0]);
- }
- }
-
- // check if there is an explicit language given as parameter
- if(array_key_exists("lang",$_REQUEST) && trim($_REQUEST["lang"]) != "")
- {
- // higher priority as those values in the header
- $languages["2.0"] = strtolower(trim($_REQUEST["lang"]));
- }
-
- // fallback, qvalues may only have three digits after the .
- $languages["0.0005"] = "en";
-
- // remove any non-conforming values (that's why we don't need to
- // mysql_real_escape() or escapeshellarg() but take care of the *)
- // spec: ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" )
- function is_language_range($candidate)
- {
- return preg_match('/^(?:[a-zA-Z]{1,8}(?:-[a-zA-Z]{1,8})*|\*)$/',
- $candidate) === 1;
- }
- $languages = array_filter($languages, "is_language_range");
-
- krsort($languages, SORT_NUMERIC);
-
- $all_translations = array(
- "ar" => "ar_JO",
- "bg" => "bg_BG",
- "cs" => "cs_CZ",
- "da" => "da_DK",
- "de" => "de_DE",
- "el" => "el_GR",
- "en" => "en_US",
- "es" => "es_ES",
- "fa" => "fa_IR",
- "fi" => "fi_FI",
- "fr" => "fr_FR",
- "he" => "he_IL",
- "hr" => "hr_HR",
- "hu" => "hu_HU",
- "id" => "id_ID",
- "is" => "is_IS",
- "it" => "it_IT",
- "ja" => "ja_JP",
- "ka" => "ka_GE",
- "ko" => "ko_KR",
- "lv" => "lv_LV",
- "nb" => "nb_NO",
- "nl" => "nl_NL",
- "pl" => "pl_PL",
- "pt" => "pt_PT",
- "pt_BR" => "pt_BR",
- "ro" => "ro_RO",
- "ru" => "ru_RU",
- "sl" => "sl_SI",
- "sv" => "sv_SE",
- "th" => "th_TH",
- "tr" => "tr_TR",
- "uk" => "uk_UA",
- "zh_CN" => "zh_CN",
- "zh_TW" => "zh_TW",
- );
-
- foreach($languages as $qvalue => $lang)
- {
- $lang = strtr($lang, '-', '_');
- $lang_length = strlen($lang);
- $chosen_locale = "";
- $chosen_translation = "";
- foreach ($all_translations as $translation => $locale)
- {
- $translation_lower = strtolower($translation);
- if ($translation_lower === $lang ||
- substr($translation_lower, 0, $lang_length + 1) === $lang.'_')
- {
- $chosen_translation = $translation;
- $chosen_locale = $locale;
- break;
- }
- }
- if ($chosen_locale !== "")
- {
- if(file_exists($_SESSION['_config']['filepath']."/locale/$chosen_translation/LC_MESSAGES/messages.mo"))
- {
- $_SESSION['_config']['language'] = $chosen_locale;
- break;
- }
- }
- }
- }
- if(!array_key_exists('_config',$_SESSION) ||
- !array_key_exists('language',$_SESSION['_config']) ||
- $_SESSION['_config']['language'] == "" )
- {
- $_SESSION['_config']['language'] = "en_US";
- trigger_error('$_SESSION[\'_config\'][\'language\'] was not set after '.
- 'the translation search', E_USER_WARNING);
- }
-
- $_SESSION['_config']['recode'] = "html..latin-1";
- if($_SESSION['_config']['language'] === "zh_CN" ||
- $_SESSION['_config']['language'] === "zh_TW")
- {
- $_SESSION['_config']['recode'] = "html..gb2312";
- } else if($_SESSION['_config']['language'] == "pl_PL" ||
- $_SESSION['_config']['language'] == "hu_HU") {
- $_SESSION['_config']['recode'] = "html..ISO-8859-2";
- } else if($_SESSION['_config']['language'] == "ja_JP") {
- $_SESSION['_config']['recode'] = "html..SHIFT-JIS";
- } else if($_SESSION['_config']['language'] == "ru_RU") {
- $_SESSION['_config']['recode'] = "html..ISO-8859-5";
- } else if($_SESSION['_config']['language'] == "lt_LT") {
- $_SESSION['_config']['recode'] = "html..ISO-8859-13";
- }
-
- putenv("LANG=".$_SESSION['_config']['language']);
- setlocale(LC_ALL, $_SESSION['_config']['language']);
- $domain = 'messages';
- bindtextdomain($domain, $_SESSION['_config']['filepath']."/locale");
- textdomain($domain);
+ L10n::detect_language();
+ L10n::init_gettext();
if(array_key_exists('profile',$_SESSION) && is_array($_SESSION['profile']) && array_key_exists('id',$_SESSION['profile']) && $_SESSION['profile']['id'] > 0)
{
@@ -383,7 +215,8 @@
//echo "Points due to name matches: $points<br/>";
- $do = `grep '$pwd' /usr/share/dict/american-english`;
+ $shellpwd = escapeshellarg($pwd);
+ $do = `grep $shellpwd /usr/share/dict/american-english`;
if($do)
$points--;
@@ -655,10 +488,6 @@
return(0);
}
- if($points >= 300)
- return(200);
- if($points >= 200)
- return(150);
if($points >= 150)
return(35);
if($points >= 140)
@@ -687,14 +516,6 @@
return(utf8_decode($data));
}
- function screenshot($img)
- {
- if(file_exists("../screenshots/".$_SESSION['_config']['language']."/$img"))
- return("/screenshots/".$_SESSION['_config']['language']."/$img");
- else
- return("/screenshots/en/$img");
- }
-
function signmail($to, $subject, $message, $from, $replyto = "")
{
if($replyto == "")
@@ -974,10 +795,13 @@
if($newlayout)
{
$name="../$type/$kind/".intval($id/1000)."/$kind-".intval($id).".$type";
- mkdir("../csr/$kind",0777);
- mkdir("../crt/$kind",0777);
- mkdir("../csr/$kind/".intval($id/1000));
- mkdir("../crt/$kind/".intval($id/1000));
+ if (!is_dir("../csr")) { mkdir("../csr",0777); }
+ if (!is_dir("../crt")) { mkdir("../crt",0777); }
+
+ if (!is_dir("../csr/$kind")) { mkdir("../csr/$kind",0777); }
+ if (!is_dir("../crt/$kind")) { mkdir("../crt/$kind",0777); }
+ if (!is_dir("../csr/$kind/".intval($id/1000))) { mkdir("../csr/$kind/".intval($id/1000)); }
+ if (!is_dir("../crt/$kind/".intval($id/1000))) { mkdir("../crt/$kind/".intval($id/1000)); }
}
return $name;
}