Commit 7529e5aa by vuj

Merge branch 'develop' into 'master'

Database Scheme url: not unique anymore,colors of buttons,dropdown

See merge request !3
2 parents 4635feb2 57e002f8
iptables -t nat -A PREROUTING --src 10.8.11.102-i eth1 -p udp --dport 53 -j REDIRECT --to-port 5335
siptables -t nat -A PREROUTING --src 10.8.11.102-i eth1 -p tcp --dport 53 -j REDIRECT --to-port 5335
iptables -t nat -A PREROUTING --src 10.8.11.103-i eth1 -p udp --dport 53 -j REDIRECT --to-port 5335
siptables -t nat -A PREROUTING --src 10.8.11.103-i eth1 -p tcp --dport 53 -j REDIRECT --to-port 5335
iptables -t nat -A PREROUTING --src 10.8.11.104-i eth1 -p udp --dport 53 -j REDIRECT --to-port 5335
siptables -t nat -A PREROUTING --src 10.8.11.104-i eth1 -p tcp --dport 53 -j REDIRECT --to-port 5335
iptables -t nat -A PREROUTING --src 10.8.11.113-i eth1 -p udp --dport 53 -j REDIRECT --to-port 5335
siptables -t nat -A PREROUTING --src 10.8.11.113-i eth1 -p tcp --dport 53 -j REDIRECT --to-port 5335
iptables -t nat -A PREROUTING --src 10.8.11.114-i eth1 -p udp --dport 53 -j REDIRECT --to-port 5335
siptables -t nat -A PREROUTING --src 10.8.11.114-i eth1 -p tcp --dport 53 -j REDIRECT --to-port 5335
...@@ -113,5 +113,20 @@ class Connectdb extends SQLite3 ...@@ -113,5 +113,20 @@ class Connectdb extends SQLite3
return $login; return $login;
} }
public function getgroupids(){
$result = $this->query('SELECT * from groups;');
$ary_content = array();
$i = 0;
while ($res = $result->fetchArray(SQLITE3_ASSOC)) {
$group_id=$res['group_id'];
foreach ($res as $key => $value) {
$ary_content[$group_id][$key] .= $value;
}
$i++;
}
return $ary_content;
}
} }
...@@ -152,6 +152,17 @@ class Output { ...@@ -152,6 +152,17 @@ class Output {
$string .= '<th>' . $content . '</th>'; $string .= '<th>' . $content . '</th>';
return $string; return $string;
} }
public function printdropdown($array,$name,$fieldlabel='name',$fieldvalue='group_id') {
$string .= '<select name="'.$name.'">';
foreach ($array as $key => $value) {
$string .= ' <option value="'.$value[$fieldvalue].'" label="'.$value[$fieldlabel].'">'.$value[$fieldlabel].' ('.$value[$fieldvalue] .')</option>';
}
$string .= ' </select>';
return $string;
}
public function printtable($ary_head, $ary_content, $controlls = false, $ary_controll = array(), $user = 0) { public function printtable($ary_head, $ary_content, $controlls = false, $ary_controll = array(), $user = 0) {
...@@ -159,6 +170,14 @@ class Output { ...@@ -159,6 +170,14 @@ class Output {
$string .= '<thead class="thead-inverse">'; $string .= '<thead class="thead-inverse">';
$string .= '<tr>'; $string .= '<tr>';
$string .= '<th>#</th>'; $string .= '<th>#</th>';
if($ary_controll['table']==='pclist'){
$db = new Connectdb();
$arraygroups=$db->getgroupids();
// echo '<pre>';
// print_r($arraygroups);
// echo '</pre>';
}
foreach ($ary_head as $key => $value) { foreach ($ary_head as $key => $value) {
if ($value === 'updated' || $value === 'updatedby' || $value === 'intern') { if ($value === 'updated' || $value === 'updatedby' || $value === 'intern') {
...@@ -189,7 +208,14 @@ class Output { ...@@ -189,7 +208,14 @@ class Output {
} elseif ($skey === 'updatedby') { } elseif ($skey === 'updatedby') {
$string .= '<input type="hidden" name="updatedby" value="' . $user . '">'; $string .= '<input type="hidden" name="updatedby" value="' . $user . '">';
} else { } else {
if ($skey === 'id' && $ary_controll['table'] !== 'groups') { if($ary_controll['table']==='pclist' && $skey === 'group_id'){
// $string .= '<td>' . $arraygroups[$svalue]['name'].' ('. $svalue .') </td>';
$string .='<td>';
$string .= $this->printdropdown($arraygroups,'group_id',$fieldlabel='name',$fieldvalue='group_id');
$string .= '</td>';
}elseif ($skey === 'id' && $ary_controll['table'] !== 'groups') {
$string .= '<td></td>'; $string .= '<td></td>';
} elseif ($skey === 'childlvl') { } elseif ($skey === 'childlvl') {
$string .= '<td><input type="number" name="' . $skey . '" value="1"></td>'; $string .= '<td><input type="number" name="' . $skey . '" value="1"></td>';
...@@ -245,7 +271,7 @@ class Output { ...@@ -245,7 +271,7 @@ class Output {
}else{ }else{
$string .= '<input type="hidden" name="id" value="' . $value['id'] . '">'; $string .= '<input type="hidden" name="id" value="' . $value['id'] . '">';
} }
$string .= '' . $this->printbutton('&#10004','primary btn-sm','Aktivieren') . ''; $string .= '' . $this->printbutton('&#10004','danger btn-sm','Aktivieren') . '';
$string .= '</form></td>'; $string .= '</form></td>';
}else{ }else{
$string .= '<td><form class="form-horizontal" method="POST" role="form" >'; $string .= '<td><form class="form-horizontal" method="POST" role="form" >';
...@@ -257,13 +283,18 @@ class Output { ...@@ -257,13 +283,18 @@ class Output {
}else{ }else{
$string .= '<input type="hidden" name="id" value="' . $value['id'] . '">'; $string .= '<input type="hidden" name="id" value="' . $value['id'] . '">';
} }
$string .= '' . $this->printbutton('&#10006;','danger btn-sm','Deaktivieren') . ''; $string .= '' . $this->printbutton('&#10006;','success btn-sm','Deaktivieren') . '';
$string .= '</form></td>'; $string .= '</form></td>';
} }
$string .= '<input type="hidden" name="updatedby" value="' . $user . '">'; $string .= '<input type="hidden" name="updatedby" value="' . $user . '">';
} else { } else {
$string .= '<td>' . $svalue . '</td>'; if($ary_controll['table']==='pclist' && $skey === 'group_id'){
$string .= '<td>' . $arraygroups[$svalue]['name'].' ('. $svalue .') </td>';
}else{
$string .= '<td>' . $svalue . '</td>';
}
} }
} }
......
...@@ -51,11 +51,11 @@ class Sytemoutput { ...@@ -51,11 +51,11 @@ class Sytemoutput {
if($i===0){ if($i===0){
file_put_contents(FWFILENAME,'iptables -t nat -A PREROUTING --src '.$value['ip'].'-i eth1 -p udp --dport 53 -j REDIRECT --to-port 5335 '. PHP_EOL); file_put_contents(FWFILENAME,'iptables -t nat -A PREROUTING --src '.$value['ip'].' -i eth1 -p udp --dport 53 -j REDIRECT --to-port 5335 '. PHP_EOL);
}else{ }else{
file_put_contents(FWFILENAME,'iptables -t nat -A PREROUTING --src '.$value['ip'].'-i eth1 -p udp --dport 53 -j REDIRECT --to-port 5335 '. PHP_EOL ,FILE_APPEND); file_put_contents(FWFILENAME,'iptables -t nat -A PREROUTING --src '.$value['ip'].' -i eth1 -p udp --dport 53 -j REDIRECT --to-port 5335 '. PHP_EOL ,FILE_APPEND);
} }
file_put_contents(FWFILENAME,'iptables -t nat -A PREROUTING --src '.$value['ip'].'-i eth1 -p tcp --dport 53 -j REDIRECT --to-port 5335 '. PHP_EOL ,FILE_APPEND); file_put_contents(FWFILENAME,'iptables -t nat -A PREROUTING --src '.$value['ip'].' -i eth1 -p tcp --dport 53 -j REDIRECT --to-port 5335 '. PHP_EOL ,FILE_APPEND);
} }
$i++; $i++;
} }
......
No preview for this file type
-- --
-- File generated with SQLiteStudio v3.0.4 on Do. Mai 18 13:28:54 2017 -- File generated with SQLiteStudio v3.0.4 on Fr. Mai 19 01:27:37 2017
-- --
-- Text encoding used: UTF-8 -- Text encoding used: UTF-8
-- --
PRAGMA foreign_keys = off; PRAGMA foreign_keys = off;
BEGIN TRANSACTION; BEGIN TRANSACTION;
-- Table: groups -- Table: domains
CREATE TABLE groups (group_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, name TEXT UNIQUE, chldvlv INTEGER DEFAULT (4) NOT NULL, open BOOLEAN DEFAULT (0), updated DATETIME, updatedby TEXT); CREATE TABLE domains (id INTEGER PRIMARY KEY UNIQUE, url TEXT NOT NULL, ip TEXT NOT NULL UNIQUE, priority INT DEFAULT (0), intern BOOLEAN DEFAULT (0), enable BOOLEAN DEFAULT (1), childlvl INT DEFAULT (4), updated DATETIME, updatedby TEXT);
-- Table: pclist -- Table: pclist
CREATE TABLE pclist (id INTEGER PRIMARY KEY UNIQUE, ip TEXT NOT NULL UNIQUE, group_id INTEGER NOT NULL, updated DATETIME, updatedby TEXT); CREATE TABLE pclist (id INTEGER PRIMARY KEY UNIQUE, ip TEXT NOT NULL UNIQUE, group_id INTEGER NOT NULL, updated DATETIME, updatedby TEXT);
...@@ -16,9 +16,12 @@ CREATE TABLE pclist (id INTEGER PRIMARY KEY UNIQUE, ip TEXT NOT NULL UNIQUE, gro ...@@ -16,9 +16,12 @@ CREATE TABLE pclist (id INTEGER PRIMARY KEY UNIQUE, ip TEXT NOT NULL UNIQUE, gro
CREATE TABLE nclistsuser (id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, name TEXT UNIQUE, password TEXT NOT NULL, updated DATETIME, updatedby TEXT); CREATE TABLE nclistsuser (id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, name TEXT UNIQUE, password TEXT NOT NULL, updated DATETIME, updatedby TEXT);
INSERT INTO nclistsuser (id, name, password, updated, updatedby) VALUES (0, 'admin', '$1$DOjc9ufI$Z4mNyrOZm8AXJYmRfUAsw1', '2017-05-23 15:50:00', '0'); INSERT INTO nclistsuser (id, name, password, updated, updatedby) VALUES (0, 'admin', '$1$DOjc9ufI$Z4mNyrOZm8AXJYmRfUAsw1', '2017-05-23 15:50:00', '0');
-- Table: domains -- Table: groups
CREATE TABLE domains (id INTEGER PRIMARY KEY UNIQUE, url TEXT UNIQUE NOT NULL, ip TEXT NOT NULL UNIQUE, priority INT DEFAULT (0), intern BOOLEAN DEFAULT (0), enable BOOLEAN DEFAULT (1), childlvl INT DEFAULT (4), updated DATETIME, updatedby TEXT); CREATE TABLE groups (group_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, name TEXT UNIQUE, chldvlv INTEGER DEFAULT (4) NOT NULL, open BOOLEAN DEFAULT (0), updated DATETIME, updatedby TEXT);
INSERT INTO domains (id, url, ip, priority, intern, enable, childlvl, updated, updatedby) VALUES (0, 'antolin.de', '217.13.73.6', 0, 0, 1, 1, NULL, NULL); INSERT INTO groups (group_id, name, chldvlv, open, updated, updatedby) VALUES (0, 'Klasse 1a', 1, 1, NULL, NULL);
INSERT INTO groups (group_id, name, chldvlv, open, updated, updatedby) VALUES (2, 'Klasse 1b', 1, 1, NULL, NULL);
INSERT INTO groups (group_id, name, chldvlv, open, updated, updatedby) VALUES (3, 'Klasse 2a', 2, 0, NULL, NULL);
INSERT INTO groups (group_id, name, chldvlv, open, updated, updatedby) VALUES (4, 'Klasse 4a', 4, 0, NULL, NULL);
COMMIT TRANSACTION; COMMIT TRANSACTION;
PRAGMA foreign_keys = on; PRAGMA foreign_keys = on;
...@@ -218,7 +218,7 @@ if (!isset($_SESSION['user_id'])) { ...@@ -218,7 +218,7 @@ if (!isset($_SESSION['user_id'])) {
$db->exec('INSERT INTO pclist (id,ip,group_id) VALUES ("4","10.8.11.104","1") '); $db->exec('INSERT INTO pclist (id,ip,group_id) VALUES ("4","10.8.11.104","1") ');
$db->exec('INSERT INTO pclist (id,ip,group_id) VALUES ("5","10.8.11.113","4") '); $db->exec('INSERT INTO pclist (id,ip,group_id) VALUES ("5","10.8.11.113","4") ');
$db->exec('INSERT INTO pclist (id,ip,group_id) VALUES ("6","10.8.11.114","4") '); $db->exec('INSERT INTO pclist (id,ip,group_id) VALUES ("6","10.8.11.114","4") ');
echo 'INSERT INTO pclist (id,ip,group_id) VALUES ("6","10.8.11.114","4")'; // echo 'INSERT INTO pclist (id,ip,group_id) VALUES ("6","10.8.11.114","4")';
} }
if (is_array($_POST) && key_exists('domains', $_POST) && $_POST['domains'] === 'print') { if (is_array($_POST) && key_exists('domains', $_POST) && $_POST['domains'] === 'print') {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!