From f6129590b312f0b6b680f6085ff15f1d41c70691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20T=C3=A4nzer?= Date: Thu, 26 Jan 2012 20:46:40 +0100 Subject: Source code taken from cacert-20120125.tar.bz2 --- CommModule/client.pl | 4 +- Makefile | 7 - cacertupload.pl | 59 -------- includes/account.php | 3 +- includes/general.php | 127 +---------------- includes/general_stuff.php | 4 +- includes/lib/l10n.php | 343 +++++++++++++++++++++++++++++++++++++++++++++ includes/loggedin.php | 13 +- locale/Makefile | 184 ++++++++++++++++++++++++ locale/make.php | 35 ----- pages/account/41.php | 11 +- pages/wot/5.php | 5 +- pages/wot/9.php | 9 +- password.dat.sample | 2 - scripts/removedead.php | 5 +- www/cap.php | 60 ++++---- www/capnew.php | 10 +- www/coapnew.php | 10 +- www/index.php | 19 +-- www/ttp.php | 28 ++-- www/wot.php | 64 ++++----- 21 files changed, 647 insertions(+), 355 deletions(-) delete mode 100644 Makefile delete mode 100644 cacertupload.pl create mode 100644 includes/lib/l10n.php create mode 100644 locale/Makefile delete mode 100755 locale/make.php delete mode 100644 password.dat.sample diff --git a/CommModule/client.pl b/CommModule/client.pl index 323ee27..bf92b27 100755 --- a/CommModule/client.pl +++ b/CommModule/client.pl @@ -595,7 +595,7 @@ sub OpenPGPextractExpiryDate ($) # Sets the locale according to the users preferred language sub setUsersLanguage($) { - my $lang="de_DE"; + my $lang="en_US"; print "Searching for the language of the user $_[0]\n"; my @a=$dbh->selectrow_array("select language from users where id='".int($_[0])."'"); $lang = $1 if($a[0]=~m/(\w+_[\w.@]+)/); @@ -887,7 +887,7 @@ sub HandleCerts($$) my $body = _("Hi")." $user{fname},\n\n"; $body .= sprintf(_("You can collect your certificate for %s by going to the following location:")."\n\n", $row{'email'}.$row{'CN'}); $body .= "https://www.cacert.org/account.php?id=".($server?"15":"6")."&cert=$row{id}\n\n"; - $body .= _("If you have not imported CAcert´s root certificate, please go to:")."\n"; + $body .= _("If you have not imported CAcert's root certificate, please go to:")."\n"; $body .= "https://www.cacert.org/index.php?id=3\n"; $body .= "Root cert fingerprint = A6:1B:37:5E:39:0D:9C:36:54:EE:BD:20:31:46:1F:6B\n"; $body .= "Root cert fingerprint = 135C EC36 F49C B8E9 3B1A B270 CD80 8846 76CE 8F33\n\n"; diff --git a/Makefile b/Makefile deleted file mode 100644 index 914d979..0000000 --- a/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: - xgettext -s -o messages.po --no-wrap --foreign-user includes/*.php www/*.php pages/account/*.php pages/index/*.php pages/wot/*.php pages/gpg/*.php pages/disputes/*.php pages/help/*.php pages/disputes/*.php scripts/removedead.php - perl cacertupload.pl - cd locale; php make.php - -other: all - cat messages.po|sed "s/CHARSET/iso-8859-1/"|sed "s/PACKAGE VERSION/CAcert/"|sed "s/This file is put in the public domain./This file is distributed under the same license as the CAcert package./"|sed "s/# SOME DESCRIPTIVE TITLE.//" > messages.po diff --git a/cacertupload.pl b/cacertupload.pl deleted file mode 100644 index 991570b..0000000 --- a/cacertupload.pl +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/perl - -#LibreSSL - CAcert web application -#Copyright (C) 2004-2008 CAcert Inc. -# -#This program is free software; you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation; version 2 of the License. -# -#This program is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. -# -#You should have received a copy of the GNU General Public License -#along with this program; if not, write to the Free Software -#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -use LWP::UserAgent; -$ua = LWP::UserAgent->new(agent => 'Translingo Client 1.0'); -use HTTP::Request::Common qw(POST); - -my $translingo_password; -my $translingo_account; - -# Read Account&Password from file -eval `cat password.dat`; - -$ua->cookie_jar({}); -$ua->timeout(10000); - -my $req = POST 'http://translingo.cacert.org/login.php', -[ -]; -# ggf. Referer faken -$req->referer('http://translingo.cacert.org/'); - $ua->request($req)->as_string; - -# 1.Test - Umgebung -my $req = POST 'http://translingo.cacert.org/login.php', -[ - username => $translingo_account, - password => $translingo_password, - submit => 'Login', -]; -# ggf. Referer faken -$req->referer('http://translingo.cacert.org/'); -$ua->request($req)->as_string; - -# 2.Test - FileUpload -my $req = POST 'http://translingo.cacert.org/upload.php', -Content_Type => 'form-data', -Content => [ - project => '1', - fileformat => '1', - pofile => ["messages.po" => "messages.po", 'Content_Type' => "application/x-gettext"], -]; -print $ua->request($req)->as_string; - diff --git a/includes/account.php b/includes/account.php index 55c9f7a..554713e 100644 --- a/includes/account.php +++ b/includes/account.php @@ -16,6 +16,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ require_once("../includes/loggedin.php"); + require_once("../includes/lib/l10n.php"); loadem("account"); @@ -2351,7 +2352,7 @@ { csrf_check("mainlang"); $lang = mysql_real_escape_string($_REQUEST['lang']); - foreach($_SESSION['_config']['translations'] as $key => $val) + foreach(L10n::$translations as $key => $val) { if($key == $lang) { diff --git a/includes/general.php b/includes/general.php index 8481018..4919c84 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,122 +71,8 @@ } } - $lang = ""; - if(array_key_exists("lang",$_REQUEST)) - $lang=mysql_escape_string(substr(trim($_REQUEST['lang']), 0, 5)); - if($lang != "") - $_SESSION['_config']['language'] = $lang; - - //if($_SESSION['profile']['id'] == 1 && 1 == 2) - // echo $_SESSION['_config']['language']; - - $_SESSION['_config']['translations'] = array( - "ar_JO" => "العربية", - "bg_BG" => "Български", - "cs_CZ" => "Čeština", - "da_DK" => "Dansk", - "de_DE" => "Deutsch", - "el_GR" => "Ελληνικά", - "en_AU" => "English", - "eo_EO" => "Esperanto", - "es_ES" => "Español", - "fa_IR" => "Farsi", - "fi_FI" => "Suomi", - "fr_FR" => "Français", - "he_IL" => "עברית", - "hr_HR" => "Hrvatski", - "hu_HU" => "Magyar", - "is_IS" => "Íslenska", - "it_IT" => "Italiano", - "ja_JP" => "日本語", - "ka_GE" => "Georgian", - "nl_NL" => "Nederlands", - "pl_PL" => "Polski", - "pt_PT" => "Português", - "pt_BR" => "Português Brasileiro", - "ru_RU" => "Русский", - "ro_RO" => "Română", - "sv_SE" => "Svenska", - "tr_TR" => "Türkçe", - "zh_CN" => "中文(简体)"); - - $value=array(); - - if(!(array_key_exists('language',$_SESSION['_config']) && $_SESSION['_config']['language'] != "")) - { - $bits = explode(",", strtolower(str_replace(" ", "", mysql_real_escape_string(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; - $value["$c"] = trim($b[0]); - } - - krsort($value); - - reset($value); - - foreach($value as $key => $val) - { - $val = substr(escapeshellarg($val), 1, -1); - $short = substr($val, 0, 2); - if($val == "en" || $short == "en") - { - $_SESSION['_config']['language'] = "en"; - break; - } - if(file_exists($_SESSION['_config']['filepath']."/locale/$val/LC_MESSAGES/messages.mo")) - { - $_SESSION['_config']['language'] = $val; - break; - } - if(file_exists($_SESSION['_config']['filepath']."/locale/$short/LC_MESSAGES/messages.mo")) - { - $_SESSION['_config']['language'] = $short; - break; - } - } - } - if(!array_key_exists('_config',$_SESSION) || !array_key_exists('language',$_SESSION['_config']) || strlen($_SESSION['_config']['language']) != 5) - { - $lang = array_key_exists('language',$_SESSION['_config'])?$_SESSION['_config']['language']:""; - $_SESSION['_config']['language'] = "en_AU"; - foreach($_SESSION['_config']['translations'] as $key => $val) - { - if(substr($lang, 0, 2) == substr($key, 0, 2)) - { - $_SESSION['_config']['language'] = $val; - break; - } - } - } - - $_SESSION['_config']['recode'] = "html..latin-1"; - if($_SESSION['_config']['language'] == "zh_CN") - { - $_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); - - //if($_SESSION['profile']['id'] == -1) - // echo $_SESSION['_config']['language']." - ".$_SESSION['_config']['filepath']."/locale"; - + 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) { @@ -632,14 +519,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 == "") diff --git a/includes/general_stuff.php b/includes/general_stuff.php index 80cd8a7..4c1bd30 100644 --- a/includes/general_stuff.php +++ b/includes/general_stuff.php @@ -16,6 +16,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +require_once($_SESSION['_config']['filepath'].'/includes/lib/l10n.php'); + if(!function_exists("showheader")) { function showbodycontent($title = "CAcert.org", $title2 = "") @@ -60,7 +62,7 @@ google_color_border = "FFFFFF";