Skip to content

FX 1: added internationalization code. 2: modification to SQL statement used to quick search mac addr #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions www/config/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand Down
42 changes: 42 additions & 0 deletions www/config/internationalization.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/** internationalization.inc.php **/
$default_lang = 'en';

// Add new supported languages to this array
// Beware that the value here has to be the same as the name of the directory.
// ie : "fr_FR.UTF-8" implies the following valid directory : ./Locale/fr_FR.UTF-8/LC_MESSAGES/
$supported_langs = array(
'de' => 'de_DE.UTF-8',
'en' => 'en_US.UTF8',
'ja' => 'ja_JP.UTF-8',
'fr' => 'fr_FR.UTF-8'
);

$hal = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_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</br>";
//echo _("HELLO_WORLD")."</br>";
//echo _("Password");

?>
Binary file added www/config/locale/en_US.UTF8/LC_MESSAGES/messages.mo
Binary file not shown.
20 changes: 20 additions & 0 deletions www/config/locale/en_US.UTF8/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
@@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\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..."
Binary file not shown.
67 changes: 67 additions & 0 deletions www/config/locale/fr_FR.UTF-8/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
@@ -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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\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</BR>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 !"

Binary file not shown.
79 changes: 79 additions & 0 deletions www/config/locale/ja_JP.UTF-8/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
@@ -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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\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 "エラー:認可"

8 changes: 8 additions & 0 deletions www/modules/ona/dns_record.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion www/winc/list_hosts.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ";

}
Expand Down