2008-08-20 Evi Vanoost <vanooste@rcbi.rochester.edu

* godmode/profiles/profile_list.php: HTML overhaul (close tags, put
        brackets and quotes in the right places. Now uses new functions
        instead of the old ones

        * include/locale.class.php: Updated and added functions. See internals
        for updated functions. It now allows to put a translated array of
        languages, countries and currency instead of the built-in english one

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1014 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
guruevi 2008-08-20 18:25:08 +00:00
parent 9651e272ca
commit 54fcab7b74
3 changed files with 334 additions and 278 deletions

View File

@ -1,3 +1,13 @@
2008-08-20 Evi Vanoost <vanooste@rcbi.rochester.edu>
* godmode/profiles/profile_list.php: HTML overhaul (close tags, put
brackets and quotes in the right places. Now uses new functions
instead of the old ones
* include/locale.class.php: Updated and added functions. See internals
for updated functions. It now allows to put a translated array of
languages, countries and currency instead of the built-in english one
2008-08-19 Esteban Sanchez <estebans@artica.es> 2008-08-19 Esteban Sanchez <estebans@artica.es>
* include/locale.class.php: Fixes in Translate_Locale() to work * include/locale.class.php: Fixes in Translate_Locale() to work

View File

@ -1,9 +1,16 @@
<?php <?php
// Pandora - The Free Monitoring System // Pandora FMS - the Flexible monitoring system
// This code is protected by GPL license. // ============================================
// Este codigo esta protegido por la licencia GPL. // Copyright (c) 2004-2008 Sancho Lerena, <slerena@gmail.com>
// Sancho Lerena <slerena@gmail.com>, 2003-2007 // Copyright (c) 2005-2008 Artica Soluciones Tecnologicas
// Raul Mateos <raulofpandora@gmail.com>, 2005-2007
// 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
// 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.
// Global variables // Global variables
require ("include/config.php"); require ("include/config.php");
@ -17,285 +24,267 @@ if (! give_acl ($config['id_user'], 0, "PM")) {
return; return;
} }
//Page title definitation. Will be overridden by Edit and Create Profile
$page_title = __('Profiles defined in Pandora');
// Profile deletion // Profile deletion
if (isset ($_GET["delete_profile"])){ // if any parameter is modified if (isset ($_GET["delete_profile"])){ // if any parameter is modified
$id_perfil= entrada_limpia($_GET["delete_profile"]); $id_profile = safe_input ($_GET["delete_profile"]);
// Delete profile // Delete profile
$query_del1="DELETE FROM tperfil WHERE id_perfil = '".$id_perfil."'"; $query = "DELETE FROM tperfil WHERE id_perfil = '".$id_profile."'";
$query_del2="DELETE FROM tusuario_perfil WHERE id_perfil = '".$id_perfil."'"; $ret = process_sql ($query);
$resq1=mysql_query($query_del1); if ($ret === false) {
if (! $resq1) echo '<h3 class="error">'.__('There was a problem deleting the profile').'</h3>';
echo "<h3 class='error'>".__('There was a problem deleting profile')."</h3>"; } else {
else echo '<h3 class="suc">'.__('Profile successfully deleted').'</h3>';
echo "<h3 class='suc'>".__('Profile successfully deleted')."</h3>";
$resq1=mysql_query($query_del2);
unset($id_perfil); // forget it to show list
} }
// Profile creation
elseif (isset($_GET["new_profile"])){ // create a new profile //Delete profile from user data
$query = "DELETE FROM tusuario_perfil WHERE id_perfil = '".$id_profile."'";
process_sql ($query);
unset($id_profile); // forget it to show list
} elseif (isset ($_GET["new_profile"])) { // create a new profile
$id_perfil = -1; $id_perfil = -1;
$name = ""; $name = "";
$incident_view = "0"; $incident_view = 0;
$incident_edit = "0"; $incident_edit = 0;
$incident_create = "0"; $incident_management = 0;
$incident_management = "0"; $agent_view = 0;
$agent_view = "0"; $agent_edit = 0;
$agent_edit ="0"; $alert_edit = 0;
$alert_edit = "0"; $user_management = 0;
$user_management = "0"; $db_management = 0;
$db_management = "0"; $alert_management = 0;
$alert_management = "0"; $pandora_management = 0;
$pandora_management = "0"; $page_title = __('Create profile');
} elseif (isset ($_GET["edit_profile"])) { // Edit profile (read data to show in form) } elseif (isset ($_GET["edit_profile"])) { // Edit profile (read data to show in form)
// Profile edit $id_perfil = safe_input ($_GET["edit_profile"]);
$id_perfil= entrada_limpia($_GET["edit_profile"]); $row = get_db_row_sql("SELECT * FROM tperfil WHERE id_perfil = '".$id_perfil."'");
$query_del1="SELECT * FROM tperfil WHERE id_perfil = '".$id_perfil."'";
$resq1=mysql_query($query_del1); if ($row === false) {
$rowq1=mysql_fetch_array($resq1); echo '<h3 class="error">'.__('There was a problem loading profile').'</h3></table>'; //Error and close open table
if (!$rowq1){
echo "<h3 class='error'>".__('There was a problem loading profile')."</h3>";
echo "</table>";
include ("general/footer.php"); include ("general/footer.php");
exit; exit;
} else {
$name = $row["name"];
$incident_view = $row["incident_view"];
$incident_edit = $row["incident_edit"];
$incident_management = $row["incident_management"];
$agent_view = $row["agent_view"];
$agent_edit =$row["agent_edit"];
$alert_edit = $row["alert_edit"];
$user_management = $row["user_management"];
$db_management = $row["db_management"];
$alert_management = $row["alert_management"];
$pandora_management = $row["pandora_management"];
unset ($row); //clean up variables
} }
else
$name = $rowq1["name"]; $page_title = __('Update profile');
$incident_view = $rowq1["incident_view"];
$incident_edit = $rowq1["incident_edit"];
$incident_management = $rowq1["incident_management"];
$agent_view = $rowq1["agent_view"];
$agent_edit =$rowq1["agent_edit"];
$alert_edit = $rowq1["alert_edit"];
$user_management = $rowq1["user_management"];
$db_management = $rowq1["db_management"];
$alert_management = $rowq1["alert_management"];
$pandora_management = $rowq1["pandora_management"];
} elseif (isset ($_GET["update_data"])) { // Update or Create a new record (writes on DB) } elseif (isset ($_GET["update_data"])) { // Update or Create a new record (writes on DB)
// Profile edit // Profile edit
$incident_view = "0"; $id_profile = (int) get_parameter_post ("id_perfil",-1);
$incident_edit = "0"; $name = get_parameter_post ("name");
$incident_create = "0";
$incident_management = "0";
$agent_view = "0";
$agent_edit ="0";
$alert_edit = "0";
$user_management = "0";
$db_management = "0";
$alert_management = "0";
$pandora_management = "0";
$id_perfil= entrada_limpia($_POST["id_perfil"]);
$name = entrada_limpia($_POST["name"]);
if (isset ($_POST["incident_view"]))$incident_view = entrada_limpia($_POST["incident_view"]); $incident_view = (bool) get_parameter_post ("incident_view",0);
if (isset ($_POST["incident_edit"])) $incident_edit = entrada_limpia($_POST["incident_edit"]); $incident_edit = (bool) get_parameter_post ("incident_edit",0);
if (isset ($_POST["incident_management"])) $incident_management = entrada_limpia($_POST["incident_management"]); $incident_management = (bool) get_parameter_post ("incident_management",0);
if (isset ($_POST["agent_view"])) $agent_view = entrada_limpia($_POST["agent_view"]); $agent_view = (bool) get_parameter_post ("agent_view",0);
if (isset ($_POST["agent_edit"])) $agent_edit =entrada_limpia($_POST["agent_edit"]); $agent_edit = (bool) get_parameter_post ("agent_edit",0);
if (isset ($_POST["alert_edit"])) $alert_edit = entrada_limpia($_POST["alert_edit"]); $alert_edit = (bool) get_parameter_post ("alert_edit",0);
if (isset ($_POST["user_management"])) $user_management = entrada_limpia($_POST["user_management"]); $user_management = (bool) get_parameter_post ("user_management",0);
if (isset ($_POST["db_management"])) $db_management = entrada_limpia($_POST["db_management"]); $db_management = (bool) get_parameter_post ("db_management",0);
if (isset ($_POST["alert_management"])) $alert_management = entrada_limpia($_POST["alert_management"]); $alert_management = (bool) get_parameter_post ("alert_management",0);
if (isset ($_POST["pandora_management"])) $pandora_management = entrada_limpia($_POST["pandora_management"]); $pandora_management = (bool) get_parameter_post ("pandora_management",0);
// update or insert ?? // update or insert ??
if ($id_perfil == -1) { // INSERT if ($id_profile == -1) { // INSERT
$query = "INSERT INTO tperfil (name,incident_view,incident_edit,incident_management, agent_view,agent_edit,alert_edit,user_management,db_management,alert_management,pandora_management) VALUES $query = "INSERT INTO tperfil
(name,incident_view,incident_edit,incident_management,agent_view,agent_edit,alert_edit,user_management,db_management,alert_management,pandora_management)
VALUES
('".$name."','".$incident_view."','".$incident_edit."','".$incident_management."','".$agent_view."','".$agent_edit."','".$alert_edit."','".$user_management."','".$db_management."','".$alert_management."','".$pandora_management."')"; ('".$name."','".$incident_view."','".$incident_edit."','".$incident_management."','".$agent_view."','".$agent_edit."','".$alert_edit."','".$user_management."','".$db_management."','".$alert_management."','".$pandora_management."')";
// echo "DEBUG: ".$query; // echo "DEBUG: ".$query;
$res = mysql_query($query); $ret = process_sql ($query);
if ($res) if ($ret !== false) {
echo "<h3 class='suc'>".__('Profile successfully created')."</h3>"; echo '<h3 class="suc">'.__('Profile successfully created').'</h3>';
else { } else {
echo "<h3 class='error'>".__('There was a problem creating profile')."</h3>"; echo '<h3 class="error">'.__('There was a problem creating this profile').'</h3>';
} }
} else { // UPDATE } else { // UPDATE
$query = "UPDATE tperfil SET $query = "UPDATE tperfil SET
name = '$name', name = '".$name."',
incident_view = $incident_view, incident_view = '".$incident_view."',
incident_edit = $incident_edit, incident_edit = '".$incident_edit."',
incident_management = $incident_management, incident_management = '".$incident_management."',
agent_view = $agent_view, agent_view = '".$agent_view."',
agent_edit = $agent_edit, agent_edit = '".$agent_edit."',
alert_edit = $alert_edit, alert_edit = '".$alert_edit."',
user_management = $user_management, user_management = '".$user_management."',
db_management = $db_management, db_management = '".$db_management."',
alert_management = $alert_management, alert_management = '".$alert_management."',
pandora_management = $pandora_management pandora_management = '".$pandora_management."'
WHERE id_perfil = $id_perfil "; WHERE id_perfil = '".$id_profile."'";
// echo "DEBUG: ".$query; // echo "DEBUG: ".$query;
$res=mysql_query($query); $ret = process_sql ($query);
echo "<h3 class='suc'>".__('Profile successfully updated')."</h3>"; if ($ret !== false) {
echo '<h3 class="suc">'.__('Profile successfully updated').'</h3>';
} else {
echo '<h3 class="error"'.__('There was a problem updating this profile').'</h3>';
} }
unset($id_perfil);
} }
echo '<h2>'.__('Profile management').' &gt; '; unset ($id_profile);
echo (isset($_GET["new_profile"])) ? }
(__('Create profile').'</h2>'):
( echo '<h2>'.__('Profile management').' &gt; '.$page_title.'</h2>';
(isset($_GET["edit_profile"]))?
(__('Update profile').'></h2>'):
(__('Profiles defined in Pandora').'</h2>')
);
// Form to manage date // Form to manage date
if (isset ($id_perfil)){ // There are values defined, let's show form with data for INSERT or UPDATE if (isset ($id_perfil)){ // There are values defined, let's show form with data for INSERT or UPDATE
echo "<table width='400' cellpadding='4' cellspacing='4' class='databox'>"; echo '<table width="400" cellpadding="4" cellspacing="4" class="databox">
echo "<tr>"; <form method="POST" action="index.php?sec=gperfiles&sec2=godmode/profiles/profile_list&update_data">
echo "<form method='post' action='index.php?sec=gperfiles&sec2=godmode/profiles/profile_list&update_data'>"; <input type="hidden" name="id_perfil" value="'.$id_perfil.'" />
echo "<input type=hidden name=id_perfil value='".$id_perfil."'>"; <tr>
echo " <td class="datos">'.__('Profile name').'</td>
<td class=datos>".__('Profile name')."</td> <td class="datos"><input name="name" type="text" size="27" value="'.$name.'" /></td>
<td class=datos> </tr>
<input name='name' type=text size='27' value='".$name."'></td></tr> <tr>
<tr><td class=datos2>".__('View incidents')."</td> <td class="datos2">'.__('View incidents').'</td>
<td class=datos2> <td class="datos2"><input name="incident_view" type="checkbox" class="chk" value="1" '.(($incident_view == 1) ? 'checked' : '').' /></td>
<input name='incident_view' type=checkbox class='chk' value='1' "; </tr>
if ($incident_view == 1) echo "checked"; echo "></td></tr> <tr>
<tr><td class=datos>".__('Edit incidents')."</td> <td class="datos">'.__('Edit incidents').'</td>
<td class=datos> <td class="datos"><input name="incident_edit" type="checkbox" class="chk" value="1" '.(($incident_edit == 1) ? 'checked' : '').' /></td>
<input name='incident_edit' type=checkbox class='chk' value='1' "; </tr>
if ($incident_edit == 1) echo "checked";echo "></td></tr> <tr>
<tr><td class=datos2>".__('Manage incidents')."</td> <td class="datos2">'.__('Manage incidents').'</td>
<td class=datos2> <td class="datos2"><input name="incident_management" type="checkbox" class="chk" value="1" '.(($incident_management == 1) ? 'checked' : '').'/></td>
<input name='incident_management' type=checkbox class='chk' value='1' "; </tr>
if ($incident_management == 1) echo "checked";echo "></td></tr> <tr>
<tr><td class=datos>".__('View agents')."</td> <td class="datos">'.__('View agents').'</td>
<td class=datos> <td class="datos"><input name="agent_view" type="checkbox" class="chk" value="1" '.(($agent_view == 1) ? 'checked' : '').' /></td>
<input name='agent_view' type=checkbox class='chk' value='1' "; </tr>
if ($agent_view == 1) echo "checked";echo "></td></tr> <tr>
<tr><td class=datos2>".__('Edit agents')."</td> <td class="datos2">'.__('Edit agents').'</td>
<td class=datos2> <td class="datos2"><input name="agent_edit" type="checkbox" class="chk" value="1" '.(($agent_edit == 1) ? 'checked' : '').' /></td>
<input name='agent_edit' type=checkbox class='chk' value='1' "; </tr>
if ($agent_edit == 1) echo "checked";echo "></td></tr> <tr>
<tr><td class=datos>".__('Edit alerts')."</td> <td class="datos">'.__('Edit alerts').'</td>
<td class=datos> <td class="datos"><input name="alert_edit" type="checkbox" class="chk" value="1" '.(($alert_edit == 1) ? 'checked' : '').' /></td>
<input name='alert_edit' type=checkbox class='chk' value='1' "; </tr>
if ($alert_edit == 1) echo "checked";echo "></td></tr> <tr>
<tr><td class=datos2>".__('Manage users')."</td> <td class="datos2">'.__('Manage users').'</td>
<td class=datos2> <td class="datos2"><input name="user_management" class="chk" type="checkbox" value="1" '.(($user_management == 1) ? 'checked' : '').' /></td>
<input name='user_management' class='chk' type=checkbox value='1' "; </tr>
if ($user_management == 1) echo "checked";echo "></td></tr> <tr>
<tr><td class=datos>".__('Manage Database')."</td> <td class="datos">'.__('Manage Database').'</td>
<td class=datos> <td class="datos"><input name="db_management" class="chk" type="checkbox" value="1" '.(($db_management == 1) ? 'checked' : '').' /></td>
<input name='db_management' class='chk' type=checkbox value='1' "; </tr>
if ($db_management == 1) echo "checked";echo "></td></tr> <tr>
<tr><td class=datos2>".__('Manage alerts')."</td> <td class="datos2">'.__('Manage alerts').'</td>
<td class=datos2> <td class="datos2"><input name="alert_management" class="chk" type="checkbox" value="1" '.(($alert_management == 1) ? 'checked' : '').' /></td>
<input name='alert_management' class='chk' type=checkbox value='1' "; </tr>
if ($alert_management == 1) echo "checked";echo "></td></tr> <tr>
<tr><td class=datos>".__('Pandora management')."</td> <td class="datos">'.__('Pandora management').'</td>
<td class=datos> <td class="datos"><input name="pandora_management" class="chk" type="checkbox" value="1" '.(($pandora_management == 1) ? 'checked' : '').' /></td>
<input name='pandora_management' class='chk' type=checkbox value='1' "; </tr>
if ($pandora_management == 1) echo "checked";echo "></td></tr> </form>
"; </table>';
echo "</table>"; echo '<table width="400"><tr><td align="right">';
echo "<table width='400'>";
echo "<tr><td align='right'>";
if (isset ($_GET["new_profile"])) { if (isset ($_GET["new_profile"])) {
echo " echo '<input name="crtbutton" type="submit" class="sub wand" value="'.__('Create').'" />';
<input name='crtbutton' type='submit' class='sub wand' value='".__('Create')."'>"; } elseif (isset ($_GET["edit_profile"])) {
echo '<input name="uptbutton" type="submit" class="sub upd" value="'.__('Update').'" />';
} }
if (isset($_GET["edit_profile"])){ echo '</td></tr></table>';
echo "
<input name='uptbutton' type='submit' class='sub upd' value='" .__('Update')."'>";
}
echo "</td></tr></table>";
} else { // View list data } else { // View list data
echo '<table cellpadding="4" cellspacing="4" class="databox" width="750px">';
$result = get_db_all_rows_in_table ("tperfil");
echo '<tr><th width="180px"><font size="1">'.__('Profiles').'</th><th width="40px">IR';
print_help_tip (__('Read Incidents'));
echo '</th><th width="40px">IW';
print_help_tip (__('Create Incidents'));
echo '</th><th width="40px">IM';
print_help_tip (__('Manage Incidents'));
echo '</th><th width="40px">AR';
print_help_tip (__('Read Agent Information'));
echo '</th><th width="40px">AW';
print_help_tip (__('Manage Agents'));
echo '</th><th width="40px">LW';
print_help_tip (__('Edit Alerts'));
echo '</th><th width="40px">UM';
print_help_tip (__('Manage User Rights'));
echo '</th><th width="40px">DM';
print_help_tip (__('Database Management'));
echo '</th><th width="40px">LM';
print_help_tip (__('Alerts Management'));
echo '</th><th width="40px">PM';
print_help_tip (__('Pandora System Management'));
echo '</th><th width="40px">'.__('Delete').'</th></tr>';
$color = 1; $color = 1;
echo "<table cellpadding='4' cellspacing='4' class='databox' width='750px'>"; foreach ($result as $profile) {
$id_perfil = $profile["id_perfil"];
$sql = "SELECT * FROM tperfil"; $nombre = $profile["name"];
$result = mysql_query ($sql); $incident_view = $profile["incident_view"];
echo "<tr>"; $incident_edit = $profile["incident_edit"];
echo "<th width='180px'><font size=1>".__('Profiles'); $incident_management = $profile["incident_management"];
echo "</th><th width='40px'>IR"; $agent_view = $profile["agent_view"];
print_help_tip (__('System incidents reading')); $agent_edit = $profile["agent_edit"];
echo "</th><th width='40px'>IW"; $alert_edit = $profile["alert_edit"];
print_help_tip (__('System incidents writing')); $user_management = $profile["user_management"];
echo "</th><th width='40px'>IM"; $db_management = $profile["db_management"];
print_help_tip (__('System incidents management')); $alert_management = $profile["alert_management"];
echo "</th><th width='40px'>AR"; $pandora_management = $profile["pandora_management"];
print_help_tip (__('Agents reading'));
echo "</th><th width='40px'>AW";
print_help_tip (__('Agents management'));
echo "</th><th width='40px'>LW";
print_help_tip (__('Alerts edition'));
echo "</th><th width='40px'>UM";
print_help_tip (__('Users management'));
echo "</th><th width='40px'>DM";
print_help_tip (__('Database management'));
echo "</th><th width='40px'>LM";
print_help_tip (__('Alerts anagement'));
echo "</th><th width='40px'>PM";
print_help_tip (__('Pandora system management'));
echo "</th><th width='40px'>".__('Delete')."</th></tr>";
while (profile = mysql_fetch_array ($result)) {
$id_perfil = profile["id_perfil"];
$nombre=profile["name"];
$incident_view = profile["incident_view"];
$incident_edit = profile["incident_edit"];
$incident_management = profile["incident_management"];
$agent_view = profile["agent_view"];
$agent_edit =profile["agent_edit"];
$alert_edit = profile["alert_edit"];
$user_management = profile["user_management"];
$db_management = profile["db_management"];
$alert_management = profile["alert_management"];
$pandora_management = profile["pandora_management"];
if ($color == 1) { if ($color == 1) {
$tdcolor = "datos"; $tdcolor = "datos";
$color = 0; $color = 0;
} } else {
else {
$tdcolor = "datos2"; $tdcolor = "datos2";
$color = 1; $color = 1;
} }
echo "<td class='$tdcolor'><a href='index.php?sec=gperfiles&amp;sec2=godmode/profiles/profile_list&amp;edit_profile=".$id_perfil."'><b>".$nombre."</b></a>";
echo "</td><td class='$tdcolor'>";
if ($incident_view == 1) echo "<img src='images/ok.png' border=0>";
echo "</td><td class='$tdcolor'>";
if ($incident_edit == 1) echo "<img src='images/ok.png' border=0>";
echo "</td><td class='$tdcolor'>";
if ($incident_management == 1) echo "<img src='images/ok.png' border=0>";
echo "</td><td class='$tdcolor'>";
if ($agent_view == 1) echo "<img src='images/ok.png' border=0>";
echo "</td><td class='$tdcolor'>";
if ($agent_edit == 1) echo "<img src='images/ok.png' border=0>";
echo "</td><td class='$tdcolor'>";
if ($alert_edit == 1) echo "<img src='images/ok.png' border=0>";
echo "</td><td class='$tdcolor'>";
if ($user_management == 1) echo "<img src='images/ok.png' border=0>";
echo "</td><td class='$tdcolor'>";
if ($db_management == 1) echo "<img src='images/ok.png' border=0>";
echo "<td class='$tdcolor'>";
if ($alert_management == 1) echo "<img src='images/ok.png' border=0>";
echo "</td><td class='$tdcolor'>";
if ($pandora_management == 1) echo "<img src='images/ok.png' border=0>";
echo "<td class='$tdcolor' align='center'><a href='index.php?sec=gagente&sec2=godmode/profiles/profile_list&delete_profile=".$id_perfil."' onClick='if (!confirm(\' ".__('Are you sure?')."\')) return false;'><img border='0' src='images/cross.png'></a></td></tr>";
echo '<tr>
<td class="'.$tdcolor.'">
<a href="index.php?sec=gperfiles&amp;sec2=godmode/profiles/profile_list&amp;edit_profile='.$id_perfil.'"><b>'.$nombre.'</b></a>
</td>
<td class="'.$tdcolor.'">
'.(($incident_view == 1) ? '<img src="images/ok.png" border="0">' : '').'
</td>
<td class="'.$tdcolor.'">
'.(($incident_edit == 1) ? '<img src="images/ok.png" border="0">' : '').'
</td>
<td class="'.$tdcolor.'">
'.(($incident_management == 1) ? '<img src="images/ok.png" border="0">' : '').'
</td><td class="'.$tdcolor.'">
'.(($agent_view == 1) ? '<img src="images/ok.png" border="0">' : '').'
</td><td class="'.$tdcolor.'">
'.(($agent_edit == 1) ? '<img src="images/ok.png" border="0">' : '').'
</td><td class="'.$tdcolor.'">
'.(($alert_edit == 1) ? '<img src="images/ok.png" border="0">' : '').'
</td><td class="'.$tdcolor.'">
'.(($user_management == 1) ? '<img src="images/ok.png" border="0">' : '').'
</td><td class="'.$tdcolor.'">
'.(($db_management == 1) ? '<img src="images/ok.png" border="0">' : '').'
<td class="'.$tdcolor.'">
'.(($alert_management == 1) ? '<img src="images/ok.png" border="0">' : '').'
</td><td class="'.$tdcolor.'">
'.(($pandora_management == 1) ? '<img src="images/ok.png" border="0">' : '').'
<td class="'.$tdcolor.'" align="center">
<a href="index.php?sec=gagente&sec2=godmode/profiles/profile_list&delete_profile='.$id_perfil.'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">
<img border="0" src="images/cross.png"></a>
</td>
</tr>';
} }
echo "</table>"; echo '</table></tr></table>
echo '</tr></table>'; <table width="750"><tr><td align="right">
echo '<table width="750">'; <form method="POST" action="index.php?sec=gperfiles&sec2=godmode/profiles/profile_list&new_profile=1">
echo '<tr><td align="right">'; <input type="submit" class="sub next" name="crt" value="'.__('Create profile').'">
echo "<form method=post action='index.php?sec=gperfiles&sec2=godmode/profiles/profile_list&new_profile=1'>"; </form>
echo "<input type='submit' class='sub next' name='crt' value='".__('Create profile')."'>"; </td></tr></table>';
echo "</form></table>";
} }
?> ?>

View File

@ -675,6 +675,8 @@ class Set_Locale {
$backup_locale = "en_US"; $backup_locale = "en_US";
} elseif(in_array("es_ES",$this->locales)) { } elseif(in_array("es_ES",$this->locales)) {
$backup_locale = "es_ES"; $backup_locale = "es_ES";
} else {
$backup_locale = "POSIX";
} }
if($backup_locale == "" || !in_array($backup_locale,$this->locales)) { if($backup_locale == "" || !in_array($backup_locale,$this->locales)) {
@ -732,7 +734,68 @@ class Set_Locale {
function Get_Locales_SelectBox () { function Get_Locales_SelectBox () {
foreach ($this->locales as $iter_locale) { foreach ($this->locales as $iter_locale) {
echo '<select name="'.$iter_locale.'">'.$this->Translate_Locale($iter_locale).'</select>'; echo '<select name="'.htmlentities ($iter_locale).'">'.$this->Translate_Locale_HTML($iter_locale).'</select>';
}
}
//Input: Language code (en, es, nl) -> should be lower case to
//distinguish from country code
//Output: Language name
function Get_Language_Name ($code) {
if (array_key_exists (mb_strtolower($code),$this->lang_codes)) {
return mb_convert_case($this->lang_codes[$code], MB_CASE_TITLE, "UTF-8");
}
return false;
}
//Input: Country code (BE, NL, US) -> should be upper case to
//distinguish from language code
//Output: Country name
function Get_Country_Name ($code) {
if (array_key_exists (mb_strtoupper($code),$this->country_codes)) {
return mb_convert_case($this->country_codes[$code], MB_CASE_TITLE, "UTF-8");
}
return false;
}
//Input: Money code (USD, EUR) -> should be upper case because of
//international standards
//Output: Money name
function Get_Currency_Name ($code) {
if (array_key_exists (mb_strtoupper($code),$this->currency_codes)) {
return $this->currency_codes[$code];
}
return false;
}
function Put_Translated_Language ($array) {
if(!is_array ($array)) {
return false;
}
$this->lang_codes = $array;
return true;
}
function Put_Translated_Country ($array) {
if(!is_array ($array)) {
return false;
}
$this->country_codes = $array;
}
function Put_Translated_Currency ($array) {
if(!is_array ($array)) {
return false;
}
$this->currency_codes = $array;
}
function Translate_Locale_HTML ($locale) {
if(is_array($locale)) {
$locale = array_walk($locale,'Translate_Locale_HTML');
} else {
$locale = $this->Translate_Locale ($locale);
return htmlentities ($locale);
} }
} }
@ -748,19 +811,14 @@ class Set_Locale {
$char = isset($country_char[1]) ? $country_char[1] : ""; $char = isset($country_char[1]) ? $country_char[1] : "";
unset ($lang_country, $country_char); unset ($lang_country, $country_char);
if (in_array($lang,array_keys($this->lang_codes))) { $lang = $this->Get_Language_Name ($lang);
$lang = $this->lang_codes[$lang]; $cntr = $this->Get_Country_Name ($cntr);
} else {
// __("Unknown");
$lang = "Unknown";
}
if (in_array($cntr,array_keys($this->country_codes))) { if($lang === false)
$cntr = ucwords(strtolower($this->country_codes[$cntr])); $lang = "Unknown";
} else {
// __("Unknown"); if($cntr === false)
$cntr = "Unknown"; $cntr = "Unknown";
}
if($char != "") { if($char != "") {
$char = " - ".$char; $char = " - ".$char;
@ -770,12 +828,10 @@ class Set_Locale {
} }
function Translate_Currency ($currency) { function Translate_Currency ($currency) {
$currency = trim($currency); $currency = $this->Get_Currency_Name (trim($currency));
if($currency === false)
if(in_array($currency,array_keys($this->currency_codes))) {
return $this->currency_codes[$currency];
}
return "Unknown"; return "Unknown";
return $currency;
} }
//This private function comes back with the precision of a specific //This private function comes back with the precision of a specific
@ -866,7 +922,7 @@ class Set_Locale {
} elseif($out == "SHORT") { } elseif($out == "SHORT") {
$currency = $this->MONFORMAT['currency_symbol']; $currency = $this->MONFORMAT['currency_symbol'];
} elseif($out == "LONG") { } elseif($out == "LONG") {
$currency = $this->Translate_Currency($currency); $currency = $this->Translate_Currency($this->MONFORMAT['int_curr_symbol']);
} else { } else {
$currency = $this->MONFORMAT['int_curr_symbol']; $currency = $this->MONFORMAT['int_curr_symbol'];
} }
@ -963,4 +1019,5 @@ class Set_Locale {
return $output; return $output;
} }
} }
?> ?>