2013-08-28 22:47:04 +02:00
< ? php
/**
* File : userpanel_voice_dns . php .
* Author : Ulrich Block
* Date : 23.09 . 12
* Time : 23 : 10
* Contact : < ulrich . block @ easy - wi . com >
*
* This file is part of Easy - WI .
*
* Easy - WI 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 , either version 3 of the License , or
* ( at your option ) any later version .
*
* Easy - WI 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 .
*
* You should have received a copy of the GNU General Public License
* along with Easy - WI . If not , see < http :// www . gnu . org / licenses />.
*
* Diese Datei ist Teil von Easy - WI .
*
* Easy - WI ist Freie Software : Sie koennen es unter den Bedingungen
* der GNU General Public License , wie von der Free Software Foundation ,
* Version 3 der Lizenz oder ( nach Ihrer Wahl ) jeder spaeteren
* veroeffentlichten Version , weiterverbreiten und / oder modifizieren .
*
* Easy - WI wird in der Hoffnung , dass es nuetzlich sein wird , aber
* OHNE JEDE GEWAEHELEISTUNG , bereitgestellt ; sogar ohne die implizite
* Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK .
* Siehe die GNU General Public License fuer weitere Details .
*
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
* Programm erhalten haben . Wenn nicht , siehe < http :// www . gnu . org / licenses />.
*/
2013-12-29 12:39:48 +01:00
2014-02-23 13:13:48 +01:00
include ( EASYWIDIR . '/stuff/methods/functions_ts3.php' );
2013-12-29 12:39:48 +01:00
2013-09-29 15:29:58 +02:00
$sprache = getlanguagefile ( 'voice' , $user_language , $reseller_id );
2013-10-13 11:42:31 +02:00
$loguserid = $user_id ;
2013-10-26 11:59:03 +02:00
$logusername = getusername ( $user_id );
2013-10-26 13:38:10 +02:00
$logusertype = 'user' ;
2013-09-29 15:29:58 +02:00
$logreseller = 0 ;
2013-12-29 12:39:48 +01:00
2013-08-28 22:47:04 +02:00
if ( isset ( $admin_id )) {
2013-10-13 11:42:31 +02:00
$logsubuser = $admin_id ;
2013-08-28 22:47:04 +02:00
} else if ( isset ( $subuser_id )) {
2013-10-13 11:42:31 +02:00
$logsubuser = $subuser_id ;
2013-08-28 22:47:04 +02:00
} else {
2013-09-29 15:29:58 +02:00
$logsubuser = 0 ;
2013-08-28 22:47:04 +02:00
}
2013-12-29 12:39:48 +01:00
2013-10-03 16:48:54 +02:00
if ( $ui -> w ( 'action' , 4 , 'post' ) and ! token ( true )) {
2013-12-29 12:39:48 +01:00
2013-09-29 15:29:58 +02:00
$template_file = $spracheResponse -> token ;
2013-12-29 12:39:48 +01:00
2015-02-19 23:14:51 +01:00
} else if ( $ui -> st ( 'd' , 'get' ) == 'md' and $ui -> id ( 'id' , 10 , 'get' ) and ( ! isset ( $_SESSION [ 'sID' ]) or in_array ( $ui -> id ( 'id' , 10 , 'get' ), $substituteAccess [ 'vd' ]))) {
2013-12-29 12:39:48 +01:00
2015-02-19 23:14:51 +01:00
$id = $ui -> id ( 'id' , 10 , 'get' );
if ( ! $ui -> smallletters ( 'action' , 2 , 'post' )) {
2013-12-29 12:39:48 +01:00
2015-02-22 08:49:56 +01:00
$query = $sql -> prepare ( " SELECT d.`dnsID`,d.`dns`,d.`ip`,d.`port`,t.`defaultdns`,CASE WHEN t.`connect_ip_only`='Y' THEN `external_ip` ELSE `ssh2ip` END AS `dns_ip` FROM `voice_dns` d INNER JOIN `voice_tsdns` t ON d.`tsdnsID`=t.`id` WHERE d.`active`='Y' AND d.`dnsID`=? AND d.`resellerID`=? LIMIT 1 " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $id , $reseller_id ));
2014-11-30 12:55:07 +01:00
while ( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) {
2015-02-22 08:49:56 +01:00
$dnsIp = $row [ 'dns_ip' ];
2013-10-13 11:42:31 +02:00
$dns = $row [ 'dns' ];
$ip = $row [ 'ip' ];
$port = $row [ 'port' ];
2015-02-21 23:03:14 +01:00
$defaultdns = strtolower ( $row [ 'dnsID' ] . '-' . getusername ( $user_id ) . $row [ 'defaultdns' ]);
2013-08-28 22:47:04 +02:00
}
2015-02-19 23:14:51 +01:00
$template_file = ( isset ( $dns )) ? 'userpanel_voiceserver_dns_md.tpl' : 'userpanel_404.tpl' ;
} else if ( $ui -> smallletters ( 'action' , 2 , 'post' ) == 'md' ) {
2015-02-22 08:49:56 +01:00
$query = $sql -> prepare ( " SELECT d.`tsdnsID`,d.`dnsID`,d.`dns`,d.`ip`,d.`port`,t.`defaultdns` FROM `voice_dns` d INNER JOIN `voice_tsdns` t ON d.`tsdnsID`=t.`id` WHERE d.`active`='Y' AND d.`dnsID`=? AND d.`resellerID`=? LIMIT 1 " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $id , $reseller_id ));
2014-11-30 12:55:07 +01:00
while ( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) {
2013-10-13 11:42:31 +02:00
$tsdnsID = $row [ 'tsdnsID' ];
$olddns = $row [ 'dns' ];
$oldip = $row [ 'ip' ];
$oldport = $row [ 'port' ];
2013-08-28 22:47:04 +02:00
}
2015-02-19 23:14:51 +01:00
2013-08-28 22:47:04 +02:00
if ( isset ( $olddns )) {
2015-02-19 23:14:51 +01:00
2013-09-29 15:29:58 +02:00
$error = array ();
2015-02-19 23:14:51 +01:00
2013-10-13 11:42:31 +02:00
if ( $ui -> ip ( 'ip' , 'post' )) {
$ip = $ui -> ip ( 'ip' , 'post' );
2013-08-28 22:47:04 +02:00
} else {
2015-02-19 23:14:51 +01:00
$error [] = " IP " ;
2013-08-28 22:47:04 +02:00
}
2015-02-19 23:14:51 +01:00
2013-10-13 11:42:31 +02:00
if ( $ui -> port ( 'port' , 'post' )) {
$port = $ui -> port ( 'port' , 'post' );
2013-08-28 22:47:04 +02:00
} else {
2015-02-19 23:14:51 +01:00
$error [] = " Port " ;
2013-08-28 22:47:04 +02:00
}
2015-02-19 23:14:51 +01:00
2013-10-13 11:42:31 +02:00
if ( $ui -> domain ( 'dns' , 'post' )) {
2015-02-19 23:14:51 +01:00
$dns = strtolower ( $ui -> domain ( 'dns' , 'post' ));
2013-08-28 22:47:04 +02:00
} else {
2015-02-19 23:14:51 +01:00
$error [] = " DNS " ;
2013-08-28 22:47:04 +02:00
}
2015-02-19 23:14:51 +01:00
if ( count ( $error ) == 0 and $ip == $oldip and $dns == $olddns and $port == $oldport ) {
2013-10-05 13:39:56 +02:00
$error [] = $spracheResponse -> error_table ;
2015-02-19 23:14:51 +01:00
} else if ( count ( $error ) == 0 and checkDNS ( $dns , $id , $user_id , 'dns' ) === false ) {
$error [] = " DNS " ;
2013-08-28 22:47:04 +02:00
}
2015-02-19 23:14:51 +01:00
2013-08-28 22:47:04 +02:00
if ( count ( $error ) > 0 ) {
2015-02-19 23:14:51 +01:00
$template_file = 'Error: ' . implode ( '<br />' , $error );
2013-08-28 22:47:04 +02:00
} else {
2015-02-19 23:14:51 +01:00
2013-09-27 08:22:09 +02:00
include ( EASYWIDIR . '/stuff/keyphrasefile.php' );
2015-02-19 23:14:51 +01:00
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " SELECT *,AES_DECRYPT(`ssh2port`,:aeskey) AS `decryptedssh2port`,AES_DECRYPT(`ssh2user`,:aeskey) AS `decryptedssh2user`,AES_DECRYPT(`ssh2password`,:aeskey) AS `decryptedssh2password` FROM `voice_tsdns` WHERE `active`='Y' AND `id`=:id AND `resellerid`=:reseller_id LIMIT 1 " );
2013-10-05 13:39:56 +02:00
$query -> execute ( array ( ':aeskey' => $aeskey , ':id' => $tsdnsID , ':reseller_id' => $reseller_id ));
2014-11-30 12:55:07 +01:00
while ( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) {
2013-10-13 11:42:31 +02:00
$publickey = $row [ 'publickey' ];
$queryip = $row [ 'ssh2ip' ];
$ssh2port = $row [ 'decryptedssh2port' ];
$ssh2user = $row [ 'decryptedssh2user' ];
$ssh2password = $row [ 'decryptedssh2password' ];
$serverdir = $row [ 'serverdir' ];
$keyname = $row [ 'keyname' ];
$bitversion = $row [ 'bitversion' ];
2013-08-28 22:47:04 +02:00
}
2015-02-19 23:14:51 +01:00
2013-08-28 22:47:04 +02:00
if ( isset ( $publickey )) {
2013-10-22 21:05:24 +02:00
$template_file = tsdns ( 'md' , $queryip , $ssh2port , $ssh2user , $publickey , $keyname , $ssh2password , 0 , $serverdir , $bitversion , array ( $ip , $oldip ), array ( $port , $oldport ), array ( $dns , $olddns ), $reseller_id );
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " UPDATE `voice_dns` SET `dns`=?,`ip`=?,`port`=? WHERE `dnsID`=? AND `resellerID`=? LIMIT 1 " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $dns , $ip , $port , $id , $reseller_id ));
} else {
2013-09-29 15:29:58 +02:00
$template_file = 'userpanel_404.tpl' ;
2013-08-28 22:47:04 +02:00
}
}
2015-02-19 23:14:51 +01:00
2013-08-28 22:47:04 +02:00
} else {
2013-09-29 15:29:58 +02:00
$template_file = 'userpanel_404.tpl' ;
2013-08-28 22:47:04 +02:00
}
}
} else {
2015-02-19 23:14:51 +01:00
$table = array ();
2013-10-13 11:42:31 +02:00
$o = $ui -> st ( 'o' , 'get' );
2015-02-19 23:14:51 +01:00
2013-10-13 11:42:31 +02:00
if ( $ui -> st ( 'o' , 'get' ) == 'dd' ) {
2013-10-05 18:39:30 +02:00
$orderby = '`dns` DESC' ;
2013-10-13 11:42:31 +02:00
} else if ( $ui -> st ( 'o' , 'get' ) == 'ad' ) {
2013-10-05 18:39:30 +02:00
$orderby = '`dns` ASC' ;
2013-10-13 11:42:31 +02:00
} else if ( $ui -> st ( 'o' , 'get' ) == 'db' ) {
2013-10-05 18:39:30 +02:00
$orderby = '`ip` DESC,`port` DESC' ;
2013-10-13 11:42:31 +02:00
} else if ( $ui -> st ( 'o' , 'get' ) == 'ab' ) {
2013-10-05 18:39:30 +02:00
$orderby = '`ip` ASC,`port` ASC' ;
2013-10-13 11:42:31 +02:00
} else if ( $ui -> st ( 'o' , 'get' ) == 'di' ) {
2013-10-05 18:39:30 +02:00
$orderby = '`dnsID` DESC' ;
2013-08-28 22:47:04 +02:00
} else {
2013-10-05 18:39:30 +02:00
$orderby = '`dnsID` ASC' ;
$o = 'ai' ;
2013-08-28 22:47:04 +02:00
}
2015-02-19 23:14:51 +01:00
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " SELECT `dnsID`,`dns`,`ip`,`port` FROM `voice_dns` WHERE `active`='Y' AND `userID`=? AND `resellerID`=? ORDER BY $orderby " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $user_id , $reseller_id ));
2015-02-19 23:14:51 +01:00
2014-11-30 12:55:07 +01:00
while ( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) {
2015-02-19 23:14:51 +01:00
if ( ! isset ( $_SESSION [ 'sID' ]) or in_array ( $row [ 'dnsID' ], $substituteAccess [ 'vd' ])) {
$table [] = array ( 'id' => $row [ 'dnsID' ], 'dns' => $row [ 'dns' ], 'address' => $row [ 'ip' ] . ':' . $row [ 'port' ]);
}
2013-08-28 22:47:04 +02:00
}
2015-02-19 23:14:51 +01:00
2013-09-29 15:29:58 +02:00
$template_file = 'userpanel_voiceserver_dns_list.tpl' ;
2013-08-28 22:47:04 +02:00
}