[feladat @ 206]
Added database structure for PostgreSQL and fixed some queries to be compatible with PostgreSQL.
Bugfix in delete_supermaster.php
--- a/delete_supermaster.php Thu Mar 27 21:10:34 2008 +0000
+++ b/delete_supermaster.php Fri Mar 28 21:40:42 2008 +0000
@@ -22,13 +22,13 @@
require_once("inc/toolkit.inc.php");
include_once("inc/header.inc.php");
-$master_ip = "-1"
+$master_ip = "-1";
if (isset($_GET['master_ip']) && (is_valid_ip($_GET['master_ip']) || is_valid_ip6($_GET['master_ip']))) {
$master_ip = $_GET['master_ip'];
}
$confirm = "-1";
-if ((isset($_GET['confirm']) && v_num($_GET['confirm'])
+if ((isset($_GET['confirm'])) && (v_num($_GET['confirm']))) {
$confirm = $_GET['confirm'];
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/poweradmin-pgsql-db-structure.sql Fri Mar 28 21:40:42 2008 +0000
@@ -0,0 +1,43 @@
+CREATE TABLE users (
+ id SERIAL PRIMARY KEY,
+ username varchar(16) NOT NULL,
+ password varchar(34) NOT NULL,
+ fullname varchar(255) NOT NULL,
+ email varchar(255) NOT NULL,
+ description text NOT NULL,
+ perm_templ integer default 0,
+ active smallint default 0
+);
+
+INSERT INTO users VALUES (1,'admin','21232f297a57a5a743894a0e4a801fc3','Administrator','admin@example.net','Administrator with full rights.',1,1);
+
+CREATE TABLE perm_items (
+ id SERIAL PRIMARY KEY,
+ name varchar(64) NOT NULL,
+ descr text NOT NULL
+);
+
+INSERT INTO perm_items VALUES (41,'zone_master_add','User is allowed to add new master zones.'),(42,'zone_slave_add','User is allowed to add new slave zones.'),(43,'zone_content_view_own','User is allowed to see the content and meta data of zones he owns.'),(44,'zone_content_edit_own','User is allowed to edit the content of zones he owns.'),(45,'zone_meta_edit_own','User is allowed to edit the meta data of zones he owns.'),(46,'zone_content_view_others','User is allowed to see the content and meta data of zones he does not own.'),(47,'zone_content_edit_others','User is allowed to edit the content of zones he does not own.'),(48,'zone_meta_edit_others','User is allowed to edit the meta data of zones he does not own.'),(49,'search','User is allowed to perform searches.'),(50,'supermaster_view','User is allowed to view supermasters.'),(51,'supermaster_add','User is allowed to add new supermasters.'),(52,'supermaster_edit','User is allowed to edit supermasters.'),(53,'user_is_ueberuser','User has full access. God-like. Redeemer.'),(54,'user_view_others','User is allowed to see other users and their details.'),(55,'user_add_new','User is allowed to add new users.'),(56,'user_edit_own','User is allowed to edit their own details.'),(57,'user_edit_others','User is allowed to edit other users.'),(58,'user_passwd_edit_others','User is allowed to edit the password of other users.'),(59,'user_edit_templ_perm','User is allowed to change the permission template that is assigned to a user.'),(60,'templ_perm_add','User is allowed to add new permission templates.'),(61,'templ_perm_edit','User is allowed to edit existing permission templates.');
+
+CREATE TABLE perm_templ (
+ id SERIAL PRIMARY KEY,
+ name varchar(128) NOT NULL,
+ descr text NOT NULL
+);
+
+INSERT INTO perm_templ VALUES (1,'Administrator','Administrator template with full rights.');
+
+CREATE TABLE perm_templ_items (
+ id SERIAL PRIMARY KEY,
+ templ_id integer NOT NULL,
+ perm_id integer NOT NULL
+);
+
+INSERT INTO perm_templ_items VALUES (249,1,53);
+
+CREATE TABLE zones (
+ id SERIAL PRIMARY KEY,
+ domain_id integer default 0,
+ owner integer default 0,
+ comment text
+);
--- a/inc/record.inc.php Thu Mar 27 21:10:34 2008 +0000
+++ b/inc/record.inc.php Fri Mar 28 21:40:42 2008 +0000
@@ -152,7 +152,7 @@
} else {
if (validate_input($zoneid, $type, $content, $name, $prio, $ttl) ) {
$change = time();
- $query = "INSERT INTO records VALUES ('',"
+ $query = "INSERT INTO records (domain_id, name, type, content, ttl, prio, change_date) VALUES ("
. $db->quote($zoneid) . ","
. $db->quote($name) . ","
. $db->quote($type) . ","
@@ -324,10 +324,10 @@
$hm = $GLOBALS['HOSTMASTER'];
$ttl = $GLOBALS['DEFAULT_TTL'];
- $query = "INSERT INTO records VALUES ('',"
+ $query = "INSERT INTO records (domain_id, name, content, type, ttl, prio, change_date) VALUES ("
. $db->quote($domain_id) . ","
. $db->quote($domain) . ","
- . "'SOA',"
+ . $db->quote('SOA').","
. $db->quote($ns1.' '.$hm.' 1') . ","
. $db->quote($ttl)
. ", 0, "
@@ -350,7 +350,7 @@
$ttl = $GLOBALS["DEFAULT_TTL"];
}
- $query = "INSERT INTO records VALUES ('',"
+ $query = "INSERT INTO records (domain_id, name, type, content, ttl, prio, change_date) VALUES ("
. $db->quote($domain_id) . ","
. $db->quote($name) . ","
. $db->quote($type) . ","
@@ -358,7 +358,6 @@
. $db->quote($ttl) . ","
. $db->quote($prio) . ","
. $db->quote($now) . ")";
- echo "<pre>" . $query . "</pre>";
$response = $db->query($query);
if (PEAR::isError($response)) { error($response->getMessage()); return false; }
}
@@ -709,7 +708,7 @@
LEFT JOIN zones ON domains.id=zones.domain_id
LEFT JOIN records ON records.domain_id=domains.id
WHERE 1=1".$sql_add."
- GROUP BY domains.name, domains.id
+ GROUP BY domains.name, domains.id, domains.type
ORDER BY domains.name";
$db->setLimit($rowamount, $rowstart);