Multilinguified core/databases. Fixed permissions.

This commit is contained in:
Nate Jones
2013-05-15 03:02:52 +00:00
parent b207aa26db
commit 240016b62e
4 changed files with 230 additions and 70 deletions

View File

@@ -0,0 +1,127 @@
<?php
//Databases
$text['title-databases']['en-us'] = 'Databases';
$text['title-databases']['pt-pt'] = '';
$text['header-databases']['en-us'] = 'Databases';
$text['header-databases']['pt-pt'] = '';
$text['description-databases']['en-us'] = 'Database information.';
$text['description-databases']['pt-pt'] = '';
//------
$text['title-database-edit']['en-us'] = 'Database Edit';
$text['title-database-edit']['pt-pt'] = '';
$text['header-database-edit']['en-us'] = 'Database Edit';
$text['header-database-edit']['pt-pt'] = '';
$text['description-database-edit']['en-us'] = 'Database connection information.';
$text['description-database-edit']['pt-pt'] = '';
//------
$text['title-database-add']['en-us'] = 'Database Add';
$text['title-database-add']['pt-pt'] = '';
$text['header-database-add']['en-us'] = 'Database Add';
$text['header-database-add']['pt-pt'] = '';
$text['description-database-add']['en-us'] = 'Database connection information.';
$text['description-database-add']['pt-pt'] = '';
//------
$text['label-driver']['en-us'] = 'Driver';
$text['label-driver']['pt-pt'] = '';
$text['description-driver']['en-us'] = 'Select the database driver.';
$text['description-driver']['pt-pt'] = '';
$text['label-type']['en-us'] = 'Type';
$text['label-type']['pt-pt'] = '';
$text['description-type']['en-us'] = 'Select the database type.';
$text['description-type']['pt-pt'] = '';
$text['label-host']['en-us'] = 'Host';
$text['label-host']['pt-pt'] = '';
$text['description-host']['en-us'] = 'Enter the host name.';
$text['description-host']['pt-pt'] = '';
$text['label-port']['en-us'] = 'Port';
$text['label-port']['pt-pt'] = '';
$text['description-port']['en-us'] = 'Enter the port number.';
$text['description-port']['pt-pt'] = '';
$text['label-name']['en-us'] = 'Name';
$text['label-name']['pt-pt'] = '';
$text['description-name']['en-us'] = 'Enter the database name.';
$text['description-name']['pt-pt'] = '';
$text['label-username']['en-us'] = 'Username';
$text['label-username']['pt-pt'] = '';
$text['description-username']['en-us'] = 'Enter the database username.';
$text['description-username']['pt-pt'] = '';
$text['label-password']['en-us'] = 'Password';
$text['label-password']['pt-pt'] = '';
$text['description-password']['en-us'] = 'Enter the database password.';
$text['description-password']['pt-pt'] = '';
$text['label-path']['en-us'] = 'Path';
$text['label-path']['pt-pt'] = '';
$text['description-path']['en-us'] = 'Enter the database file path (SQLite only).';
$text['description-path']['pt-pt'] = '';
$text['label-description']['en-us'] = 'Description';
$text['label-description']['pt-pt'] = '';
$text['description-description']['en-us'] = 'Enter a description for this database, if desired.';
$text['description-description']['pt-pt'] = '';
//------
$text['button-add']['en-us'] = 'Add';
$text['button-add']['pt-pt'] = '';
$text['button-edit']['en-us'] = 'Edit';
$text['button-edit']['pt-pt'] = '';
$text['button-delete']['en-us'] = 'Delete';
$text['button-delete']['pt-pt'] = '';
$text['confirm-delete']['en-us'] = 'Do you really want to delete this?';
$text['confirm-delete']['pt-pt'] = '';
$text['button-save']['en-us'] = 'Save';
$text['button-save']['pt-pt'] = 'Guardar';
$text['button-back']['en-us'] = 'Back';
$text['button-back']['pt-pt'] = 'Voltar';
$text['message-message']['en-us'] = 'Message';
$text['message-message']['pt-pt'] = '';
$text['message-add']['en-us'] = 'Add Completed';
$text['message-add']['pt-pt'] = '';
$text['message-update']['en-us'] = 'Update Completed';
$text['message-update']['pt-pt'] = '';
$text['message-delete']['en-us'] = 'Delete Completed';
$text['message-delete']['pt-pt'] = '';
$text['message-required']['en-us'] = 'Please provide: ';
$text['message-required']['pt-pt'] = '';
?>

View File

@@ -26,7 +26,7 @@
require_once "root.php";
require_once "includes/require.php";
require_once "includes/checkauth.php";
if (if_group("superadmin")) {
if (permission_exists('database_delete')) {
//access granted
}
else {
@@ -34,6 +34,12 @@ else {
exit;
}
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
if (count($_GET)>0) {
$id = check_str($_GET["id"]);
}
@@ -50,7 +56,7 @@ if (strlen($id)>0) {
require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=databases.php\">\n";
echo "<div align='center'>\n";
echo "Delete Complete\n";
echo $text['message-delete']."\n";
echo "</div>\n";
require_once "includes/footer.php";
return;

View File

@@ -26,7 +26,7 @@
require_once "root.php";
require_once "includes/require.php";
require_once "includes/checkauth.php";
if (if_group("superadmin")) {
if (permission_exists('database_add') || permission_exists('database_edit')) {
//access granted
}
else {
@@ -34,6 +34,12 @@ else {
exit;
}
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
//action add or update
if (isset($_REQUEST["id"])) {
$action = "update";
@@ -75,15 +81,15 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
}
//check for all required data
//if (strlen($database_driver) == 0) { $msg .= "Please provide: Driver<br>\n"; }
//if (strlen($database_type) == 0) { $msg .= "Please provide: Type<br>\n"; }
//if (strlen($database_host) == 0) { $msg .= "Please provide: Host<br>\n"; }
//if (strlen($database_port) == 0) { $msg .= "Please provide: Port<br>\n"; }
//if (strlen($database_name) == 0) { $msg .= "Please provide: Name<br>\n"; }
//if (strlen($database_username) == 0) { $msg .= "Please provide: Username<br>\n"; }
//if (strlen($database_password) == 0) { $msg .= "Please provide: Password<br>\n"; }
//if (strlen($database_path) == 0) { $msg .= "Please provide: Path<br>\n"; }
//if (strlen($database_description) == 0) { $msg .= "Please provide: Description<br>\n"; }
//if (strlen($database_driver) == 0) { $msg .= $text['message-required'].$text['label-driver']."<br>\n"; }
//if (strlen($database_type) == 0) { $msg .= $text['message-required'].$text['label-type']."<br>\n"; }
//if (strlen($database_host) == 0) { $msg .= $text['message-required'].$text['label-host']."<br>\n"; }
//if (strlen($database_port) == 0) { $msg .= $text['message-required'].$text['label-port']."<br>\n"; }
//if (strlen($database_name) == 0) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
//if (strlen($database_username) == 0) { $msg .= $text['message-required'].$text['label-username']."<br>\n"; }
//if (strlen($database_password) == 0) { $msg .= $text['message-required'].$text['label-password']."<br>\n"; }
//if (strlen($database_path) == 0) { $msg .= $text['message-required'].$text['label-path']."<br>\n"; }
//if (strlen($database_description) == 0) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "includes/header.php";
require_once "includes/persistformvar.php";
@@ -140,7 +146,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=databases.php\">\n";
echo "<div align='center'>\n";
echo "Add Complete\n";
echo $text['message-add']."\n";
echo "</div>\n";
require_once "includes/footer.php";
return;
@@ -170,12 +176,12 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=databases.php\">\n";
echo "<div align='center'>\n";
echo "Update Complete\n";
echo $text['message-update']."\n";
echo "</div>\n";
require_once "includes/footer.php";
return;
} //if ($action == "update")
} //if ($_POST["persistformvar"] != "true")
} //if ($_POST["persistformvar"] != "true")
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
//pre-populate the form
@@ -203,6 +209,12 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//show the header
require_once "includes/header.php";
if ($action == "update") {
$page["title"] = $text['title-database-edit'];
}
if ($action == "add") {
$page["title"] = $text['title-database-add'];
}
//show the content
echo "<div align='center'>";
@@ -216,167 +228,173 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<table width='100%' border='0' cellpadding='3' cellspacing='0'>\n";
echo "<tr>\n";
if ($action == "add") {
echo "<td align=\"left\" width='30%' nowrap=\"nowrap\"><b>Database Add</b></td>\n";
echo "<td align=\"left\" width='30%' nowrap=\"nowrap\"><b>".$text['header-database-add']."</b></td>\n";
}
if ($action == "update") {
echo "<td align=\"left\" width='30%' nowrap=\"nowrap\"><b>Database Edit</b></td>\n";
echo "<td align=\"left\" width='30%' nowrap=\"nowrap\"><b>".$text['header-database-edit']."</b></td>\n";
}
echo "<td width='70%' align=\"right\"><input type='button' class='btn' name='' alt='back' onclick=\"window.location='databases.php'\" value='Back'></td>\n";
echo "<td width='70%' align=\"right\"><input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='databases.php'\" value='".$text['button-back']."'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td align=\"left\" colspan='2'>\n";
echo "Database connection information.<br /><br />\n";
if ($action == "add") {
echo $text['description-database-add'];
}
if ($action == "update") {
echo $text['description-database-edit'];
}
echo "<br /><br />\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Driver:\n";
echo " ".$text['label-driver'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='database_driver'>\n";
echo " <option value=''></option>\n";
if ($database_driver == "sqlite") {
echo " &nbsp; &nbsp;<option value='sqlite' selected='selected'>sqlite</option>\n";
echo " &nbsp; &nbsp;<option value='sqlite' selected='selected'>SQLite</option>\n";
}
else {
echo " &nbsp; &nbsp;<option value='sqlite'>sqlite</option>\n";
echo " &nbsp; &nbsp;<option value='sqlite'>SQLite</option>\n";
}
if ($database_driver == "pgsql") {
echo " &nbsp; &nbsp;<option value='pgsql' selected='selected'>pgsql</option>\n";
echo " &nbsp; &nbsp;<option value='pgsql' selected='selected'>PostgreSQL</option>\n";
}
else {
echo " &nbsp; &nbsp;<option value='pgsql'>pgsql</option>\n";
echo " &nbsp; &nbsp;<option value='pgsql'>PostgreSQL</option>\n";
}
if ($database_driver == "mysql") {
echo " &nbsp; &nbsp;<option value='mysql' selected='selected'>mysql</option>\n";
echo " &nbsp; &nbsp;<option value='mysql' selected='selected'>MySQL</option>\n";
}
else {
echo " &nbsp; &nbsp;<option value='mysql'>mysql</option>\n";
echo " &nbsp; &nbsp;<option value='mysql'>MySQL</option>\n";
}
if ($database_driver == "odbc") {
echo " &nbsp; &nbsp;<option value='odbc' selected='selected'>odbc</option>\n";
echo " &nbsp; &nbsp;<option value='odbc' selected='selected'>ODBC</option>\n";
}
else {
echo " &nbsp; &nbsp;<option value='odbc'>odbc</option>\n";
echo " &nbsp; &nbsp;<option value='odbc'>ODBC</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo "Select the database driver.\n";
echo $text['description-driver']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Type:\n";
echo " ".$text['label-type'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='database_type'>\n";
echo " <option value=''></option>\n";
if ($database_type == "sqlite") {
echo " &nbsp; &nbsp;<option value='sqlite' selected='selected'>sqlite</option>\n";
echo " &nbsp; &nbsp;<option value='sqlite' selected='selected'>SQLite</option>\n";
}
else {
echo " &nbsp; &nbsp;<option value='sqlite'>sqlite</option>\n";
echo " &nbsp; &nbsp;<option value='sqlite'>SQLite</option>\n";
}
if ($database_type == "pgsql") {
echo " &nbsp; &nbsp;<option value='pgsql' selected='selected'>pgsql</option>\n";
echo " &nbsp; &nbsp;<option value='pgsql' selected='selected'>PostgreSQL</option>\n";
}
else {
echo " &nbsp; &nbsp;<option value='pgsql'>pgsql</option>\n";
echo " &nbsp; &nbsp;<option value='pgsql'>PostgreSQL</option>\n";
}
if ($database_type == "mysql") {
echo " &nbsp; &nbsp;<option value='mysql' selected='selected'>mysql</option>\n";
echo " &nbsp; &nbsp;<option value='mysql' selected='selected'>MySQL</option>\n";
}
else {
echo " &nbsp; &nbsp;<option value='mysql'>mysql</option>\n";
echo " &nbsp; &nbsp;<option value='mysql'>MySQL</option>\n";
}
if ($database_type == "mssql") {
echo " &nbsp; &nbsp;<option value='mssql' selected='selected'>mssql</option>\n";
echo " &nbsp; &nbsp;<option value='mssql' selected='selected'>Microsoft SQL Server</option>\n";
}
else {
echo " &nbsp; &nbsp;<option value='mssql'>mssql</option>\n";
echo " &nbsp; &nbsp;<option value='mssql'>Microsoft SQL Server</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo "Select the database type.\n";
echo $text['description-type']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Host:\n";
echo " ".$text['label-host'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='database_host' maxlength='255' value=\"$database_host\">\n";
echo "<br />\n";
echo "Enter the host name.\n";
echo $text['description-host']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Port:\n";
echo " ".$text['label-port'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='database_port' maxlength='255' value=\"$database_port\">\n";
echo "<br />\n";
echo "Enter the port number.\n";
echo $text['description-port']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Name:\n";
echo " ".$text['label-name'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='database_name' maxlength='255' value=\"$database_name\">\n";
echo "<br />\n";
echo "Enter the database name.\n";
echo $text['description-name']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Username:\n";
echo " ".$text['label-username'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='database_username' maxlength='255' value=\"$database_username\">\n";
echo "<br />\n";
echo "Enter the database username.\n";
echo $text['description-username']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Password:\n";
echo " ".$text['label-password'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='database_password' maxlength='255' value=\"$database_password\">\n";
echo "<br />\n";
echo "Enter the database password.\n";
echo $text['description-password']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Path:\n";
echo " ".$text['label-path'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='database_path' maxlength='255' value=\"$database_path\">\n";
echo "<br />\n";
echo "Enter the database file path.\n";
echo $text['description-path']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Description:\n";
echo " ".$text['label-description'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='database_description' maxlength='255' value=\"$database_description\">\n";
echo "<br />\n";
echo "Enter the description.\n";
echo $text['description-description']."\n";
echo "</td>\n";
echo "</tr>\n";
echo " <tr>\n";
@@ -384,7 +402,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
if ($action == "update") {
echo " <input type='hidden' name='database_uuid' value='$database_uuid'>\n";
}
echo " <input type='submit' name='submit' class='btn' value='Save'>\n";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n";
echo " </tr>";
echo "</table>";

View File

@@ -33,7 +33,16 @@ else {
echo "access denied";
exit;
}
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
require_once "includes/header.php";
$page["title"] = $text['title-databases'];
require_once "includes/paging.php";
//get variables used to control the order
@@ -49,12 +58,12 @@ require_once "includes/paging.php";
echo "<table width='100%' border='0'>\n";
echo " <tr>\n";
echo " <td width='50%' align=\"left\" nowrap=\"nowrap\"><b>Databases</b></td>\n";
echo " <td width='50%' align=\"left\" nowrap=\"nowrap\"><b>".$text['header-databases']."</b></td>\n";
echo " <td width='50%' align=\"right\">&nbsp;</td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td align=\"left\" colspan='2'>\n";
echo " Database information.<br /><br />\n";
echo " ".$text['description-databases']."<br /><br />\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
@@ -79,8 +88,8 @@ require_once "includes/paging.php";
$param = "";
$page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
$offset = $rows_per_page * $page;
list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
$offset = $rows_per_page * $page;
//get the list
$sql = "select * from v_databases ";
@@ -100,16 +109,16 @@ require_once "includes/paging.php";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo th_order_by('database_driver', 'Driver', $order_by, $order);
echo th_order_by('database_type', 'Type', $order_by, $order);
echo th_order_by('database_host', 'Host', $order_by, $order);
//echo th_order_by('database_port', 'Port', $order_by, $order);
echo th_order_by('database_name', 'Name', $order_by, $order);
//echo th_order_by('database_username', 'Username', $order_by, $order);
//echo th_order_by('database_path', 'Path', $order_by, $order);
echo th_order_by('database_description', 'Description', $order_by, $order);
echo th_order_by('database_driver', $text['label-driver'], $order_by, $order);
echo th_order_by('database_type', $text['label-type'], $order_by, $order);
echo th_order_by('database_host', $text['label-host'], $order_by, $order);
//echo th_order_by('database_port', $text['label-port'], $order_by, $order);
echo th_order_by('database_name', $text['label-name'], $order_by, $order);
//echo th_order_by('database_username', $text['label-username'], $order_by, $order);
//echo th_order_by('database_path', $text['label-path'], $order_by, $order);
echo th_order_by('database_description', $text['label-description'], $order_by, $order);
echo "<td align='right' width='42'>\n";
echo " <a href='database_edit.php' alt='add'>$v_link_label_add</a>\n";
echo " <a href='database_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
echo "</td>\n";
echo "<tr>\n";
@@ -125,8 +134,8 @@ require_once "includes/paging.php";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['database_path']."&nbsp;</td>\n";
echo " <td valign='top' class='row_stylebg'>".$row['database_description']."&nbsp;</td>\n";
echo " <td valign='top' align='right'>\n";
echo " <a href='database_edit.php?id=".$row['database_uuid']."' alt='edit'>$v_link_label_edit</a>\n";
echo " <a href='database_delete.php?id=".$row['database_uuid']."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
echo " <a href='database_edit.php?id=".$row['database_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>\n";
echo " <a href='database_delete.php?id=".$row['database_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
echo " </td>\n";
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
@@ -141,7 +150,7 @@ require_once "includes/paging.php";
echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
echo " <td width='33.3%' align='right'>\n";
echo " <a href='database_edit.php' alt='add'>$v_link_label_add</a>\n";
echo " <a href='database_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";