From b14e3130cf028156b269eb70d2999aa8bcdf28ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20POTTIER?= Date: Mon, 25 Nov 2013 15:37:35 +0100 Subject: [PATCH 1/3] FX 1: added internationalization code FX 2: modification to SQL statement used to quick search mac addr --- www/config/config.inc.php | 3 + www/config/internationalization.inc.php | 42 ++++++++++ .../locale/en_US.UTF8/LC_MESSAGES/messages.mo | Bin 0 -> 483 bytes .../locale/en_US.UTF8/LC_MESSAGES/messages.po | 20 +++++ .../fr_FR.UTF-8/LC_MESSAGES/messages.mo | Bin 0 -> 998 bytes .../fr_FR.UTF-8/LC_MESSAGES/messages.po | 67 +++++++++++++++ .../ja_JP.UTF-8/LC_MESSAGES/messages.mo | Bin 0 -> 1287 bytes .../ja_JP.UTF-8/LC_MESSAGES/messages.po | 79 ++++++++++++++++++ www/winc/list_hosts.inc.php | 5 +- 9 files changed, 215 insertions(+), 1 deletion(-) create mode 100644 www/config/internationalization.inc.php create mode 100644 www/config/locale/en_US.UTF8/LC_MESSAGES/messages.mo create mode 100644 www/config/locale/en_US.UTF8/LC_MESSAGES/messages.po create mode 100644 www/config/locale/fr_FR.UTF-8/LC_MESSAGES/messages.mo create mode 100644 www/config/locale/fr_FR.UTF-8/LC_MESSAGES/messages.po create mode 100644 www/config/locale/ja_JP.UTF-8/LC_MESSAGES/messages.mo create mode 100644 www/config/locale/ja_JP.UTF-8/LC_MESSAGES/messages.po diff --git a/www/config/config.inc.php b/www/config/config.inc.php index 5361ecf9..0de971d8 100644 --- a/www/config/config.inc.php +++ b/www/config/config.inc.php @@ -225,6 +225,9 @@ // Start the session handler (this calls a function defined in functions_general) startSession(); +// Include internationalization code (should be top of any .php file with strings to be translated). +include $base . '/config/internationalization.inc.php'; + // Set session inactivity threshold ini_set("session.gc_maxlifetime", $conf['cookie_life']); diff --git a/www/config/internationalization.inc.php b/www/config/internationalization.inc.php new file mode 100644 index 00000000..6ee6141b --- /dev/null +++ b/www/config/internationalization.inc.php @@ -0,0 +1,42 @@ + 'de_DE.UTF-8', + 'en' => 'en_US.UTF8', + 'ja' => 'ja_JP.UTF-8', + 'fr' => 'fr_FR.UTF-8' +); + +$hal = $_SERVER['HTTP_ACCEPT_LANGUAGE']; +$langs = explode(',', $hal); +foreach($langs as $lang){ + $lang_prefix = substr($lang, 0, 2); + if (isset($supported_langs[$lang_prefix])) { + $lc=$supported_langs[$lang_prefix]; + //echo 'LC='.$lc; + break; + } + $lc=$supported_langs[$default_lang]; + //echo 'LC(default)='.$lc; +} + +$folder = "locale"; +$directory = str_replace(DIRECTORY_SEPARATOR,'/',realpath(dirname(__FILE__)))."/$folder"; +$domain = "messages"; +setlocale(LC_MESSAGES, $lc); +setlocale(LC_ALL, $lc); +bindtextdomain($domain, $directory); +bind_textdomain_codeset($domain, 'UTF-8'); +textdomain($domain); + +/* For test purposes */ +//echo " directory=".$directory."/".setlocale(LC_MESSAGES,0)."/LC_MESSAGES/".$domain.".po
"; +//echo _("HELLO_WORLD")."
"; +//echo _("Password"); + +?> diff --git a/www/config/locale/en_US.UTF8/LC_MESSAGES/messages.mo b/www/config/locale/en_US.UTF8/LC_MESSAGES/messages.mo new file mode 100644 index 0000000000000000000000000000000000000000..a54fb6a4c0abcaf38c596cc68b406515bdebe81c GIT binary patch literal 483 zcmYL^O-{ow5QW3vCa^#(Sg|nc${}f4pzx!b#%&{6Y``=o1ckVA41x`};5=M_ zGjJ9rsG=i(dY1fV{N`t8{nLV41NMMJU;|)4TX(=FAb@S)8R)NA)(7Yo@CEl>&~H#U ze{)tr|7%PcOKz`{lm!;28NcNzi8Drcn8emZt0y@#ILz^-)J>^sA5F;Mf{ZA-q-h2o zJC$>#4UU?k%<=h4(O|B8WKR-~2U-dPO*jxn`l#!AJ?wedJ4D^C@Af*b=el6TseCQl z;S1k2B`J;)91t{4{3z_)Br&y_Xbk3B)J-Lf(mona8ACCNC_14L30a>6K}xgi46JqW zA_|GQ6wf|lBpyxM$R~{TtI|=rSb8986h?HppXa#tK-EUp@ZI|yavS+(4(638>ti%~ z6uOb-bjpYLXz6QXJxGmdJyUsE7d|?=FO6-DWmPG3rF50=TU<5<-jG==0UJAxWBmfc C?S3-= literal 0 HcmV?d00001 diff --git a/www/config/locale/en_US.UTF8/LC_MESSAGES/messages.po b/www/config/locale/en_US.UTF8/LC_MESSAGES/messages.po new file mode 100644 index 00000000..8450165a --- /dev/null +++ b/www/config/locale/en_US.UTF8/LC_MESSAGES/messages.po @@ -0,0 +1,20 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-11-14 22:03+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#Test token 1 +msgid "HELLO_WORLD" +msgstr "Hello World!" + +#Test token 2 +msgid "TEST_TRANSLATION" +msgstr "Testing translation..." diff --git a/www/config/locale/fr_FR.UTF-8/LC_MESSAGES/messages.mo b/www/config/locale/fr_FR.UTF-8/LC_MESSAGES/messages.mo new file mode 100644 index 0000000000000000000000000000000000000000..66e43a437b8cce60a95732bb75773b314007a958 GIT binary patch literal 998 zcmY+CPj1sd7{v!D{{l#WShDz7l|l_kTcIkHs!rmz5q4}jNug}e5Kq%7&P+5jZs`V= zoPb000<74vfh(}!3~&S9go=uho`3fE^P6wR@8|8gPYk05-Gxf%2J{8;;}>)j`VGxP z=g%>A4SWDz1fPJn!8Py-n1Xk}m!SV{aytJW+<-npW6Xa$&)5oBzrffnP=J@gBX9xy z0A2@AK=1z<^nTw#zy1#pR%{Ns1mTfggqc~1qzew}A!(u&_iltMb;1U)Ssp#)i z#;t{G!E#YZBSucDF&*oQoNf~9JFW^|Y9&s~hgKNHCxT^0AD}wu7Qv1%R%+FxENnjy zw<6k!@_sk%)p9Y_#s!HT%OYr1V;c-$TFcTw&^CfQd=zxJ6HQvGHAQZ=slSOf#XCrygO-qz5!ycWkBrF^8#_^bx4Cfy`D+h5~Rz1G&s z35Dg3r|8>>ckc1Db)5mn2*8X^DojxX8&=TPxp`f)EpjC16PY$xq|gc(V1c&IB&s8LSt!Hp%_`ROSFCeG5O75Qx-TVdt){}zvCN5F literal 0 HcmV?d00001 diff --git a/www/config/locale/fr_FR.UTF-8/LC_MESSAGES/messages.po b/www/config/locale/fr_FR.UTF-8/LC_MESSAGES/messages.po new file mode 100644 index 00000000..7ebbca6b --- /dev/null +++ b/www/config/locale/fr_FR.UTF-8/LC_MESSAGES/messages.po @@ -0,0 +1,67 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#: index.php:4 +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-11-14 22:03+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#Test token 1 +msgid "HELLO_WORLD" +msgstr "Bonjour le monde!" + +#: index.php:10 login.php:6 +msgid "ERROR => Couldn't find include folder!\n" +msgstr "ERREUR => impossible de trouver le dossier include!\n" + +#: index.php:55 +msgid "0wn Your Network" +msgstr "Administration réseau IP du Groupe Hospitalier Universitaire Paris Sud (BCT, ABC, PBR, UCSA, CPA, CMP)" + +#: login.php:21 +msgid "Redirecting you to: " +msgstr "Redirection vers: " + +#: login.php:50 +msgid "Standalone Login" +msgstr "Authentification" + +#: login.php:63 +msgid "OpenNetAdmin Login" +msgstr "OpenNetAdmin
Merci de vous identifier" + +#: login.php:75 +msgid "Username" +msgstr "Utilisateur" + +#: login.php:91 +msgid "Password" +msgstr "Mot de passe" + +#: login.php:107 +msgid "Login" +msgstr "Valider" + +###### logout.php ####### +msgid "has logged out" +msgstr "déconnecté" + +###### config_dnld.php ###### +msgid "Configuration record doesn't exist!" +msgstr "Pas d'enregistrement de configuration !" + +msgid "ERROR: You are unauthorized for this page!" +msgstr "ERREUR: Vous n'êtes pas autorisé à visualiser cette page !" + diff --git a/www/config/locale/ja_JP.UTF-8/LC_MESSAGES/messages.mo b/www/config/locale/ja_JP.UTF-8/LC_MESSAGES/messages.mo new file mode 100644 index 0000000000000000000000000000000000000000..8f02e9ff6a8c336b340f52e1d3ef0f5bd132d57e GIT binary patch literal 1287 zcmY+Dy^kA37{&((Uxpxv5EaFHLg;|I4fZ8PFuCZ~_U6uF{h_seC^Tr}9q&z8&sa0F z`GCrINkah=Qba+)6@YY+Kp-j#DvJiB{0F329W;oN0#WdcZFFL!*FVqfyYKtV%(D;9 zoVv>}P9t7K+(tZy_ygfa`60%h1uNi7U=3UaN8oGVN8nT758$KVPv9Bw7w`%20r))l zJLu~Cvs^#@Fk{bP{sOp#wU@yZ^U))V`uD-}nEwTCf@`N1x&-(*<{yA>fCu2y;E$l| z`!neJ{0cfT>f|aaPPXhB?KhQhwIDAHzZwAxu!O^ zH~a5s+quOz9S?TU902v$0I#Oi8{>9~iD>JmzdKHk7F}MO&3y*4647 zUiO-ax68G`KC9IA>u>qn0qq7+ui0srB0f>tdM%TR#H;10@%rdd>UR2GUGw?jc#YWd zDs7Z2=e$bAtDL8ejcWPaTDej#Bhicab>WIH^R5Jb652wbfjEr_&BfVQj3| z*ReENY?ZFkhEthC_YXaSt-?Xn!vRKGBX}A|_!|mpvf7!cmlILWNxb^}$ zR0+V)|7v{kWJO7Sp@M^fqg$`R<^>@Dq#UD|CkkgZub;Z~|f^ ZhI0e5ffbMj7v`EJvm+dfgs*2u>|c-2b9w*( literal 0 HcmV?d00001 diff --git a/www/config/locale/ja_JP.UTF-8/LC_MESSAGES/messages.po b/www/config/locale/ja_JP.UTF-8/LC_MESSAGES/messages.po new file mode 100644 index 00000000..f6fd3835 --- /dev/null +++ b/www/config/locale/ja_JP.UTF-8/LC_MESSAGES/messages.po @@ -0,0 +1,79 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#: index.php:4 +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-11-14 22:03+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#Test token 1 +msgid "HELLO_WORLD" +msgstr "ハローワールド" + +#: index.php:10 login.php:6 +msgid "ERROR => Couldn't find include folder!\n" +msgstr "エラー:[include]フォルダを見つけることができませんでした。\n" + +#: index.php:55 +msgid "0wn Your Network" +msgstr "オープンネット管理" + +#: login.php:21 +msgid "Redirecting you to: " +msgstr "リダイレクト:" + +#: login.php:50 +msgid "Standalone Login" +msgstr "認証" + +#: login.php:63 +msgid "OpenNetAdmin Login" +msgstr "あなたのログイン情報を入力してください" + +#: login.php:75 +msgid "Username" +msgstr "ユーザー名" + +# +#msgid "Wrong username" +#msgstr "不正なユーザー名" +#msgid "Invalid username" +#msgstr "ユーザー名が無効です" + +#: login.php:91 +msgid "Password" +msgstr "パスワード" + +#: login.php:107 +msgid "Login" +msgstr "検証" + +# Authentication validation +# 認証の検証 + +###### logout.php ####### +msgid "has logged out" +msgstr "ログアウトしました。" + +# You have been logged out. Reconnect? +# ログアウトしました。再接続しますか? + +###### config_dnld.php ###### +msgid "Configuration record doesn't exist!" +msgstr "Pas d'enregistrement de configuration !" + +msgid "ERROR: You are unauthorized for this page!" +msgstr "エラー:認可" + diff --git a/www/winc/list_hosts.inc.php b/www/winc/list_hosts.inc.php index 4a9b9cbe..665f3f7c 100644 --- a/www/winc/list_hosts.inc.php +++ b/www/winc/list_hosts.inc.php @@ -237,9 +237,12 @@ function ws_display_list($window_name, $form='') { $form['mac'] = preg_replace('/[^%0-9A-F]/', '', $form['mac']); // We do a sub-select to find interface id's that match - $where .= $and . "h.id IN ( SELECT host_id " . + $from = 'hosts h LEFT JOIN interfaces i ON i.host_id = h.id'; + $where .= $and . " WHERE i.mac_addr LIKE " . $onadb->qstr($wildcard.$form['mac'].$wildcard) . " ) "; +/* $where .= $and . "h.id IN ( SELECT host_id " . " FROM interfaces " . " WHERE mac_addr LIKE " . $onadb->qstr($wildcard.$form['mac'].$wildcard) . " ) "; +*/ $and = " AND "; } From 4185ae26b7fd4a5b09781a0338310b2533c0d438 Mon Sep 17 00:00:00 2001 From: fxpottier Date: Fri, 6 Mar 2015 15:34:13 +0100 Subject: [PATCH 2/3] Update dns_record.inc.php --- www/modules/ona/dns_record.inc.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/www/modules/ona/dns_record.inc.php b/www/modules/ona/dns_record.inc.php index 544b3837..62a9c54f 100644 --- a/www/modules/ona/dns_record.inc.php +++ b/www/modules/ona/dns_record.inc.php @@ -1122,6 +1122,14 @@ function dns_record_modify($options="") { $self['error'] = "ERROR => There is already an A record with that name!{$viewmsg}"; return(array(7, $self['error'] . "\n")); } + // FX: needed to add control over CNAMES modifications. This check was done in dns_add function but not here. + // Validate that there are no CNAMES already with this fqdn + list($c_status, $c_rows, $c_record) = ona_get_dns_record(array('name' => $hostname, 'domain_id' => $domain['id'],'type' => 'CNAME','dns_view_id' => $check_dns_view_id)); + if ($c_rows or $c_status) { + printmsg("ERROR => Another DNS CNAME record named {$hostname}.{$domain['fqdn']} already exists!{$viewmsg}",3); + $self['error'] = "ERROR => Another DNS CNAME record named {$hostname}.{$domain['fqdn']} already exists!{$viewmsg}"; + return(array(5, $self['error'] . "\n")); + } } // lets try and determine the interface record using the name passed in. Only works if we get one record back From 46034342e8fe982a5920cb1fbabf18afa93ca775 Mon Sep 17 00:00:00 2001 From: fxpottier Date: Tue, 17 Mar 2015 09:31:57 +0100 Subject: [PATCH 3/3] Update internationalization.inc.php Add control over $_SERVER['HTTP_ACCEPT_LANGUAGE'] to avoid this notice : PHP Notice: Undefined index: HTTP_ACCEPT_LANGUAGE in /opt/ona/www/config/internationalization.inc.php on line 15 --- www/config/internationalization.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/config/internationalization.inc.php b/www/config/internationalization.inc.php index 6ee6141b..ce879632 100644 --- a/www/config/internationalization.inc.php +++ b/www/config/internationalization.inc.php @@ -12,7 +12,7 @@ 'fr' => 'fr_FR.UTF-8' ); -$hal = $_SERVER['HTTP_ACCEPT_LANGUAGE']; +$hal = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER["HTTP_ACCEPT_LANGUAGE"] : ''; $langs = explode(',', $hal); foreach($langs as $lang){ $lang_prefix = substr($lang, 0, 2);