2013-08-28 22:47:04 +02:00
< ? php
2013-10-19 16:20:33 +02:00
2013-08-28 22:47:04 +02:00
/**
* File : serverallocation . php .
* Author : Ulrich Block
* 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-09-27 08:22:09 +02:00
define ( 'EASYWIDIR' , dirname ( __FILE__ ));
2014-02-23 13:13:48 +01:00
include ( EASYWIDIR . '/stuff/methods/functions.php' );
include ( EASYWIDIR . '/stuff/methods/class_validator.php' );
include ( EASYWIDIR . '/stuff/methods/vorlage.php' );
2013-09-27 08:22:09 +02:00
include ( EASYWIDIR . '/stuff/config.php' );
include ( EASYWIDIR . '/stuff/settings.php' );
2013-10-19 16:20:33 +02:00
2013-09-29 15:29:58 +02:00
$die = false ;
2013-08-28 22:47:04 +02:00
if ( ! isset ( $admin_id ) and ! isset ( $user_id )) {
redirect ( 'login.php' );
2013-10-13 13:11:38 +02:00
} else if ( isset ( $admin_id )) {
2014-03-02 10:18:25 +01:00
$pa = User_Permissions ( $admin_id );
2013-08-28 22:47:04 +02:00
} else if ( isset ( $user_id )) {
2014-03-02 10:18:25 +01:00
$pa = User_Permissions ( $user_id );
2013-08-28 22:47:04 +02:00
} else {
2013-10-03 12:49:13 +02:00
$die = true ;
2013-08-28 22:47:04 +02:00
}
2013-10-19 16:20:33 +02:00
2013-09-01 23:12:51 +02:00
if ( ! isset ( $pa ) or count ( $pa ) == 0 or (( ! isset ( $admin_id ) and ! isset ( $user_id )) or ((( ! $pa [ 'gserver' ]) and ! $pa [ 'voiceserver' ] and ! $pa [ 'voicemasterserver' ] and ! $pa [ 'traffic' ] and ! $pa [ 'user' ] and ! rsellerpermisions ( $admin_id ) and ! $pa [ 'usertickets' ]) and ( ! $pa [ 'restart' ] and ! $pa [ 'usertickets' ])))) {
2013-10-03 12:49:13 +02:00
$die = true ;
2013-08-28 22:47:04 +02:00
}
2013-10-19 16:20:33 +02:00
2013-10-13 11:42:31 +02:00
if ( $ui -> smallletters ( 'w' , 5 , 'get' ) == 'check' ) {
2013-08-28 22:47:04 +02:00
$return = 'bad' ;
2013-10-13 11:42:31 +02:00
if ( $ui -> w ( 'method' , 40 , 'get' )) {
$method = $ui -> w ( 'method' , 40 , 'get' );
if ( $ui -> id ( 'length' , 255 , 'get' ) and $ui -> $method ( 'check' , $ui -> id ( 'length' , 255 , 'get' ), 'get' )) $return = 'ok' ;
else if ( $ui -> $method ( 'check' , 'get' )) $return = 'ok' ;
2013-08-28 22:47:04 +02:00
}
echo $return ;
2013-10-19 16:20:33 +02:00
2013-10-13 11:42:31 +02:00
} else if ( $die == true ) {
2013-08-28 22:47:04 +02:00
redirect ( 'login.php' );
2013-10-19 16:20:33 +02:00
2013-10-20 12:02:02 +02:00
} else if ( $ui -> username ( 'mapgroup' , 50 , 'get' )) {
2013-09-29 15:29:58 +02:00
$sprache = getlanguagefile ( 'gserver' , $user_language , $reseller_id );
2013-10-19 16:20:33 +02:00
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT `mapGroup` FROM `servertypes` WHERE `shorten`=? AND `resellerid`=? LIMIT 1 " );
2013-10-20 12:02:02 +02:00
$query -> execute ( array ( $ui -> username ( 'mapgroup' , 50 , 'get' ), $reseller_id ));
2013-08-28 22:47:04 +02:00
foreach ( $query -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) {
2013-10-03 12:49:13 +02:00
if ( $row [ 'mapGroup' ] != null ) {
2013-10-13 11:42:31 +02:00
$mapGroup = $row [ 'mapGroup' ];
2014-02-23 13:13:48 +01:00
require_once IncludeTemplate ( $template_to_use , 'ajax_userpanel_mapgroup.tpl' , 'ajax' );
2013-08-28 22:47:04 +02:00
}
}
2013-10-19 16:20:33 +02:00
2013-10-13 11:42:31 +02:00
} else if ( $ui -> id ( 'id' , 19 , 'get' ) and $ui -> st ( 'd' , 'get' ) == " vs " and ( $pa [ 'addvserver' ] or $pa [ 'root' ])) {
2013-09-29 15:29:58 +02:00
$sprache = getlanguagefile ( 'reseller' , $user_language , $reseller_id );
2013-10-03 12:49:13 +02:00
if ( $reseller_id != 0 and $admin_id != $reseller_id ) {
2013-10-05 18:39:30 +02:00
$reseller_id = $admin_id ;
2013-10-03 12:49:13 +02:00
$notexclusive = true ;
2013-08-28 22:47:04 +02:00
}
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT `id`,`cpu`,`active`,`ip`,`esxi`,`description`,`cores`,`mhz`,`hdd`,`ram`,`maxserver`,`thin`,`thinquota` FROM `virtualhosts` WHERE `id`=? " );
2013-09-29 15:29:58 +02:00
$query2 = $sql -> prepare ( " SELECT `cores`,`minmhz`,`hddsize`,`mountpoint`,`minram` FROM `virtualcontainer` WHERE hostid=? " );
2013-10-13 11:42:31 +02:00
$query -> execute ( array ( $ui -> id ( 'id' , 19 , 'get' )));
2013-08-28 22:47:04 +02:00
foreach ( $query -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) {
2013-10-13 11:42:31 +02:00
$id = $row [ 'id' ];
$cores = $row [ 'cores' ];
$mhz = $row [ 'mhz' ];
$hddsize = $row [ 'hdd' ];
$ram = $row [ 'ram' ];
$maxserver = $row [ 'maxserver' ];
$esxi = $row [ 'esxi' ];
$besthostcpu = $row [ 'cpu' ] . ' ' . $cores . " x " . $mhz . " MHz " ;
2013-10-26 13:38:10 +02:00
if ( $row [ 'thin' ] == 'Y' ) {
2013-10-13 11:42:31 +02:00
$percent = $row [ 'thinquota' ];
2013-08-28 22:47:04 +02:00
} else {
$percent = " 100 " ;
}
2013-09-29 15:29:58 +02:00
$ramused = 0 ;
2013-08-28 22:47:04 +02:00
$hdd_rows = explode ( " \r \n " , $row [ 'hdd' ]);
foreach ( $hdd_rows as $hddline ) {
$data_explode = explode ( " " , $hddline );
2013-09-08 17:21:34 +02:00
if ( isset ( $data_explode [ 1 ])) {
2013-10-13 11:42:31 +02:00
$mountpoint = $data_explode [ 0 ];
2013-10-05 13:39:56 +02:00
$mountsize [ $mountpoint ] = $data_explode [ 1 ];
2013-09-29 15:29:58 +02:00
$mountunused [ $mountpoint ] = 0 ;
2013-10-05 13:39:56 +02:00
$hdd [] = $mountpoint ;
2013-08-28 22:47:04 +02:00
}
}
2013-09-29 15:29:58 +02:00
$i = 1 ;
2013-08-28 22:47:04 +02:00
while ( $i <= $cores ) {
2013-10-05 13:39:56 +02:00
$core [] = $i ;
2013-09-29 15:29:58 +02:00
$cpucore [ $i ] = 0 ;
2013-08-28 22:47:04 +02:00
$i ++ ;
}
2013-09-29 15:29:58 +02:00
$i = 1 ;
2013-10-26 13:38:10 +02:00
if ( $esxi == 'Y' ) {
2013-08-28 22:47:04 +02:00
$maxcore = " 8 " ;
} else {
2013-10-13 11:42:31 +02:00
$maxcore = $cores ;
2013-08-28 22:47:04 +02:00
}
while ( $i <= $cores and $i <= $maxcore ) {
2013-10-05 13:39:56 +02:00
$add_core [] = $i ;
2013-08-28 22:47:04 +02:00
$i ++ ;
}
$query2 -> execute ( array ( $id ));
2013-09-29 15:29:58 +02:00
$i2 = 0 ;
2013-08-28 22:47:04 +02:00
foreach ( $query2 -> fetchAll ( PDO :: FETCH_ASSOC ) as $row2 ) {
2013-10-13 11:42:31 +02:00
$mountpoint = $row2 [ 'mountpoint' ];
$addstracthdd = $mountunused [ $mountpoint ] + ( $row2 [ 'hddsize' ] * ( $percent / 100 ));
2013-10-05 13:39:56 +02:00
$mountunused [ $mountpoint ] = $addstracthdd ;
2013-10-13 11:42:31 +02:00
$addstractram = $ramused + $row2 [ 'minram' ];
$ramused = $addstractram ;
$cpuhz = $row2 [ 'cores' ] * $row2 [ 'minmhz' ];
$addcpu = $cpucore [ 1 ] + $cpuhz ;
2013-08-28 22:47:04 +02:00
if ( $addcpu <= $mhz ) {
2013-10-05 13:39:56 +02:00
$cpucore [ 1 ] = $addcpu ;
2013-08-28 22:47:04 +02:00
} else {
2013-10-05 13:39:56 +02:00
$cpucore [ 1 ] = $mhz ;
2013-09-29 15:29:58 +02:00
$nextcore = 2 ;
2013-08-28 22:47:04 +02:00
while ( $nextcore <= $cores ) {
2013-10-13 11:42:31 +02:00
$extra = $addcpu - $mhz ;
$addcpu = $cpucore [ $nextcore ] + $extra ;
2013-08-28 22:47:04 +02:00
if ( $addcpu <= $mhz and $addcpu >= 0 ) {
2013-10-05 13:39:56 +02:00
$cpucore [ $nextcore ] = $addcpu ;
2013-08-28 22:47:04 +02:00
} else if ( $addcpu >= 0 ) {
2013-10-05 13:39:56 +02:00
$cpucore [ $nextcore ] = $mhz ;
2013-08-28 22:47:04 +02:00
}
$nextcore ++ ;
}
}
$i2 ++ ;
}
foreach ( $hdd as $mountpoint ) {
2013-10-05 13:39:56 +02:00
$freespace [ $mountpoint ] = $mountsize [ $mountpoint ] - ( $mountunused [ $mountpoint ] * ( $percent / 100 ));
2013-08-28 22:47:04 +02:00
}
natsort ( $freespace );
$freespace = array_reverse ( $freespace );
foreach ( $freespace as $mountpoint => $free ) {
2013-10-05 13:39:56 +02:00
$best_hdd [] = $mountpoint ;
2013-08-28 22:47:04 +02:00
}
}
2014-02-23 13:13:48 +01:00
require_once IncludeTemplate ( $template_to_use , 'ajax_admin_vserver_allocation.tpl' , 'ajax' );
2013-10-19 16:20:33 +02:00
2013-10-13 11:42:31 +02:00
} else if ( $ui -> st ( 'd' , 'get' ) == " ui " and $ui -> id ( 'id' , 19 , 'get' )) {
foreach ( freeips ( $ui -> id ( 'id' , 19 , 'get' )) as $ip ) echo $ip . " <br /> " ;
2013-10-19 16:20:33 +02:00
2013-10-13 11:42:31 +02:00
} else if ( $ui -> st ( 'd' , 'get' ) == " my " and $ui -> id ( 'id' , 19 , 'get' )) {
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT s.`ip`,s.`max_databases`,COUNT(d.`id`) AS `installed` FROM `mysql_external_servers` s LEFT JOIN `mysql_external_dbs` d ON s.`id`=d.`sid` WHERE s.`id`=? AND s.`active`='Y' AND s.`resellerid`=? LIMIT 1 " );
2013-10-13 11:42:31 +02:00
$query -> execute ( array ( $ui -> id ( 'id' , 19 , 'get' ), $reseller_id ));
2013-08-28 22:47:04 +02:00
foreach ( $query -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) {
2013-10-13 11:42:31 +02:00
$installed = $row [ 'installed' ];
$max_databases = $row [ 'max_databases' ];
2013-08-28 22:47:04 +02:00
}
if ( ! isset ( $installed )) {
2013-09-29 15:29:58 +02:00
$installed = 0 ;
$max_databases = 0 ;
2013-08-28 22:47:04 +02:00
}
2014-02-23 13:13:48 +01:00
require_once IncludeTemplate ( $template_to_use , 'ajax_admin_mysql_server.tpl' , 'ajax' );
2013-10-19 16:20:33 +02:00
2013-10-13 11:42:31 +02:00
} else if ( $ui -> st ( 'd' , 'get' ) == " tr " and $ui -> st ( 'w' , 'get' )) {
if ( $ui -> st ( 'w' , 'get' ) == " su " ) {
2013-10-13 13:11:38 +02:00
if ( $reseller_id == 0 ) {
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT `ips` FROM `resellerdata` " );
2013-08-28 22:47:04 +02:00
$query -> execute ();
} else if ( $reseller_id == $admin_id ) {
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT `ips` FROM `resellerdata` WHERE `resellersid`=? " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $reseller_id ));
} else {
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT `ips` FROM `resellerdata` WHERE `resellerid`=? AND c.`resellersid`=? " );
$query -> execute ( array ( $admin_id , $reseller_id ));
2013-08-28 22:47:04 +02:00
}
2013-09-29 15:29:58 +02:00
$ips = array ();
$userips = array ();
2013-08-28 22:47:04 +02:00
foreach ( $pselect -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) {
unset ( $userips );
$userips = ipstoarray ( $row [ 'ips' ]);
foreach ( $userips as $ip ) {
2013-09-28 13:12:29 +02:00
$ip_ex = explode ( " . " , $ip );
2013-10-05 13:39:56 +02:00
$ips [] = $ip_ex [ 0 ] . '.' . $ip_ex [ 1 ] . '.' . $ip_ex [ 2 ] . " . " ;
2013-08-28 22:47:04 +02:00
}
}
$subnets = array_unique ( $ips );
natsort ( $subnets );
foreach ( $subnets as $subnet ) {
2013-10-03 12:49:13 +02:00
$data [] = '<option>' . $subnet . '</option>' ;
2013-08-28 22:47:04 +02:00
}
2013-10-13 11:42:31 +02:00
} else if ( $ui -> st ( 'w' , 'get' ) == " rs " ) {
2013-10-13 13:11:38 +02:00
if ( $reseller_id == 0 ) {
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT `id`,`cname` FROM `userdata` WHERE `accounttype`='r' AND `id`=`resellerid` " );
2013-08-28 22:47:04 +02:00
$query -> execute ();
}
2013-10-03 12:49:13 +02:00
foreach ( $query -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) $data [] = '<option value=' . $row [ 'id' ] . '>' . $row [ 'cname' ] . '</option>' ;
2013-10-13 11:42:31 +02:00
} else if ( $ui -> st ( 'w' , 'get' ) == " us " ) {
2013-10-13 13:11:38 +02:00
if ( $reseller_id == 0 ) {
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT `id`,`cname` FROM `userdata` WHERE `accounttype`='r' " );
2013-08-28 22:47:04 +02:00
$query -> execute ();
} else if ( $reseller_id == $admin_id ) {
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT `id`,`cname` FROM `userdata` WHERE `accounttype`='r' AND `resellerid`=? " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $reseller_id ));
}
foreach ( $pselect -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) {
2013-10-03 12:49:13 +02:00
$data [] = '<option value=' . $row [ 'id' ] . '>' . $row [ 'cname' ] . '</option>' ;
2013-08-28 22:47:04 +02:00
}
2013-10-13 11:42:31 +02:00
} else if ( $ui -> st ( 'w' , 'get' ) == " se " ) {
2013-10-13 13:11:38 +02:00
if ( $reseller_id == 0 ) {
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT c.`id`,u.`cname` FROM `virtualcontainer` c LEFT JOIN `userdata` u ON c.`userid`=u.`id` ORDER BY u.`id`,c.`id` " );
2013-08-28 22:47:04 +02:00
$query -> execute ();
} else if ( $reseller_id == $admin_id ){
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT c.`id`,u.`cname` FROM `virtualcontainer` c LEFT JOIN `userdata` u ON c.`userid`=u.`id` WHERE c.`resellerid`=? ORDER BY u.`id`,c.`id` " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $reseller_id ));
} else {
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT c.`id`,u.`cname` FROM `virtualcontainer` c LEFT JOIN `userdata` u ON c.`userid`=u.`id` WHERE c.`userid`=? AND c.`resellerid`=? ORDER BY u.`id`,c.`id` " );
$query -> execute ( array ( $admin_id , $reseller_id ));
2013-08-28 22:47:04 +02:00
}
2013-10-03 12:49:13 +02:00
foreach ( $pselect -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) $data [] = '<option value=' . $row [ 'id' ] . '>' . $row [ 'cname' ] . '-' . $row [ 'id' ] . '</option>' ;
2013-10-13 11:42:31 +02:00
} else if ( $ui -> st ( 'w' , 'get' ) == " ip " ) {
2013-09-29 15:29:58 +02:00
$userips = array ();
2013-10-13 13:11:38 +02:00
if ( $reseller_id == 0 ) {
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT `ips` FROM `resellerdata` " );
2013-08-28 22:47:04 +02:00
$query -> execute ();
} else if ( $reseller_id == $admin_id ) {
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT `ips` FROM `resellerdata` WHERE `resellersid`=? " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $reseller_id ));
} else {
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT `ips` FROM `resellerdata` WHERE `resellerid`=? AND c.`resellersid`=? " );
$query -> execute ( array ( $admin_id , $reseller_id ));
2013-08-28 22:47:04 +02:00
}
2013-09-29 15:29:58 +02:00
$ips = array ();
2013-08-28 22:47:04 +02:00
foreach ( $query -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) {
2013-10-05 13:39:56 +02:00
foreach ( ipstoarray ( $row [ 'ips' ]) as $userip ) $userips [] = $userip ;
2013-08-28 22:47:04 +02:00
}
$ips = array_unique ( $userips );
natsort ( $ips );
2013-10-03 12:49:13 +02:00
foreach ( $ips as $ip ) $data [] = '<option>' . $ip . '</option>' ;
2013-08-28 22:47:04 +02:00
}
2014-02-23 13:13:48 +01:00
require_once IncludeTemplate ( $template_to_use , 'ajax_admin_traffic.tpl' , 'ajax' );
2013-10-13 11:42:31 +02:00
} else if ( $ui -> st ( 'd' , 'get' ) == " vu " and $ui -> st ( 'w' , 'get' )) {
if ( $ui -> st ( 'w' , 'get' ) == " us " ) {
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT u.`id`,u.`cname`,u.`vname`,u.`name` FROM `userdata` u INNER JOIN `voice_server` v ON u.`id`=v.`userid` AND v.`active`='Y' WHERE u.`resellerid`=? GROUP BY u.`id` " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $reseller_id ));
2013-10-03 12:49:13 +02:00
foreach ( $query -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) $data [] = '<option value=' . $row [ 'id' ] . '>' . trim ( $row [ 'cname' ] . ' ' . $row [ 'vname' ] . ' ' . $row [ 'name' ]) . '</option>' ;
2013-10-13 11:42:31 +02:00
} else if ( $ui -> st ( 'w' , 'get' ) == " se " ) {
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT v.`id`,v.`ip`,v.`port`,v.`dns`,m.`usedns` FROM `voice_server` v LEFT JOIN `voice_masterserver` m ON v.`masterserver`=m.`id` WHERE v.`resellerid`=? ORDER BY v.`ip`,v.`port` " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $reseller_id ));
foreach ( $query -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) {
2013-10-13 11:42:31 +02:00
$server = $row [ 'ip' ] . ':' . $row [ 'port' ];
2013-10-03 12:49:13 +02:00
$data [] = '<option value=' . $row [ 'id' ] . '>' . $server . '</option>' ;
2013-08-28 22:47:04 +02:00
}
2013-10-13 11:42:31 +02:00
} else if ( $ui -> st ( 'w' , 'get' ) == " ma " ) {
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT `id`,`ssh2ip` FROM `voice_masterserver` WHERE `resellerid`=? ORDER BY `ssh2ip` " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $reseller_id ));
2013-10-03 12:49:13 +02:00
foreach ( $query -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) $data [] = '<option value=' . $row [ 'id' ] . '>' . $row [ 'ssh2ip' ] . '</option>' ;
2013-08-28 22:47:04 +02:00
}
2014-02-23 13:13:48 +01:00
require_once IncludeTemplate ( $template_to_use , 'ajax_admin_voice_stats.tpl' , 'ajax' );
2013-10-20 12:02:02 +02:00
} else if ( $ui -> username ( 'distro' , 50 , 'get' ) and $ui -> id ( 'id' , 19 , 'get' ) and ( $pa [ 'vserversettings' ] or $pa [ 'root' ]) and $reseller_id == 0 ) {
2013-10-13 11:42:31 +02:00
$pselect = $sql -> prepare ( " SELECT `pxeautorun` FROM `resellerimages` WHERE `bitversion`=? AND `distro`=? " );
2013-10-20 12:02:02 +02:00
$pselect -> execute ( array ( $ui -> id ( 'id' , 19 , 'get' ), $ui -> username ( 'distro' , 50 , 'get' )));
2013-09-29 15:29:58 +02:00
$usedpxeautorun = array ();
2013-08-28 22:47:04 +02:00
foreach ( $pselect -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) {
2013-10-05 13:39:56 +02:00
$usedpxeautorun [] = $row [ 'pxeautorun' ];
2013-08-28 22:47:04 +02:00
}
2013-09-29 15:29:58 +02:00
$i = 0 ;
2013-08-28 22:47:04 +02:00
while ( $i <= " 9 " ) {
if ( ! in_array ( $i , $usedpxeautorun )){
2013-10-05 13:39:56 +02:00
$pxeautorun [] = $i ;
2013-08-28 22:47:04 +02:00
}
$i ++ ;
}
?>
2013-10-13 11:42:31 +02:00
< select name = " <?php echo " pxeautorun " . $ui->id ('id',19, 'get');?> " >
2013-08-28 22:47:04 +02:00
< ? php
foreach ( $pxeautorun as $pxe ) {
?>
< option >< ? php echo $pxe ; ?> </option>
< ? php
}
?>
</ select >
< ? php
2013-10-20 12:02:02 +02:00
} else if (( $ui -> username ( 'short' , 50 , 'get' ) or $ui -> username ( 'shorten' , 50 , 'get' )) and $pa [ 'restart' ]) {
2013-09-29 15:29:58 +02:00
$sprache = getlanguagefile ( 'gserver' , $user_language , $reseller_id );
2013-10-03 12:49:13 +02:00
if ( $reseller_id != 0 and $admin_id != $reseller_id ) {
2013-10-05 18:39:30 +02:00
$reseller_id = $admin_id ;
2013-08-28 22:47:04 +02:00
}
2013-10-13 11:42:31 +02:00
$get_shorten = $ui -> username ( 'shorten' , 50 , 'get' );
if ( $ui -> username ( 'short' , 50 , 'get' )) {
$get_shorten = $get_short ;
2013-08-28 22:47:04 +02:00
}
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT `id` FROM `eac` WHERE `active`='Y' AND `resellerid`=? LIMIT 1 " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $reseller_id ));
2013-10-13 11:42:31 +02:00
$count = $query -> rowCount ();
2013-12-18 08:28:42 +01:00
$query2 = $sql -> prepare ( " SELECT `gamebinary` FROM `servertypes` WHERE `shorten`=? AND `resellerid`=? LIMIT 1 " );
2013-09-28 13:12:29 +02:00
$query2 -> execute ( array ( $get_shorten , $reseller_id ));
2013-08-28 22:47:04 +02:00
foreach ( $query2 -> fetchAll ( PDO :: FETCH_ASSOC ) as $row2 ) {
2013-12-18 08:28:42 +01:00
if ( $row [ 'gamebinary' ] == 'srcds_run' or $row [ 'gamebinary' ] == 'hlds_run' ) {
2013-08-28 22:47:04 +02:00
$anticheatsoft = " Valve Anti Cheat " ;
2013-12-18 08:28:42 +01:00
} else if ( $row2 [ 'gamebinary' ] == 'cod4_lnxded' ) {
2013-08-28 22:47:04 +02:00
$anticheatsoft = " Punkbuster " ;
} else {
2013-09-29 15:29:58 +02:00
$anticheatsoft = '' ;
2013-08-28 22:47:04 +02:00
}
if ( $count > 0 and ( $get_shorten == " css " or $get_shorten == " cod4 " or $get_shorten == " cstrike " or $get_shorten == " czero " or $get_shorten == " tf " )) {
$eac = '<option value="3">Easy Anti Cheat</option>' ;
} else {
2013-09-29 15:29:58 +02:00
$eac = '' ;
2013-08-28 22:47:04 +02:00
}
}
if ( ! isset ( $anticheatsoft )) {
2013-09-29 15:29:58 +02:00
$anticheatsoft = '' ;
2013-08-28 22:47:04 +02:00
}
if ( ! isset ( $anticheat )) {
2013-09-29 15:29:58 +02:00
$anticheat = '' ;
2013-08-28 22:47:04 +02:00
}
?>
< select name = " anticheat " >
2013-09-28 13:23:15 +02:00
< option value = " 1 " >< ? php echo $anticheatsoft . ' ' . $sprache -> on ; ?> </option>
2013-10-20 12:02:02 +02:00
< ? php if ( ! $ui -> username ( 'short' , 50 , 'get' )){ ?> <option value="2" <?php if ($anticheat=="2") echo 'selected="selected"';?>><?php echo $anticheatsoft . ' ' . $sprache->off2;?></option><?php } ?>
2013-08-28 22:47:04 +02:00
< ? php echo $eac ; ?>
</ select >
< ? php
2013-10-20 12:02:02 +02:00
} else if ( $ui -> username ( 'gamestring' , 50 , 'get' ) and $ui -> id ( 'id' , 19 , 'get' ) and ( $pa [ 'roots' ] or $pa [ 'root' ])) {
2014-02-23 13:13:48 +01:00
include ( EASYWIDIR . '/stuff/methods/functions_ssh_exec.php' );
include ( EASYWIDIR . '/stuff/methods/class_masterserver.php' );
2013-10-20 12:02:02 +02:00
include ( EASYWIDIR . '/stuff/keyphrasefile.php' );
2013-09-29 15:29:58 +02:00
$sprache = getlanguagefile ( 'roots' , $user_language , $reseller_id );
2013-10-20 12:02:02 +02:00
2013-10-03 12:49:13 +02:00
if ( $reseller_id != 0 and $admin_id != $reseller_id ) {
2013-10-05 18:39:30 +02:00
$reseller_id = $admin_id ;
2013-08-28 22:47:04 +02:00
}
2013-10-20 12:02:02 +02:00
$rootServer = new masterServer ( $ui -> id ( 'id' , 10 , 'get' ), $aeskey );
2013-09-29 15:29:58 +02:00
$i = 1 ;
$gamelist = array ();
2013-10-20 12:02:02 +02:00
$games = explode ( '_' , $ui -> username ( 'gamestring' , 50 , 'get' ));
$count = count ( $games );
$query = $sql -> prepare ( " SELECT `id` FROM `servertypes` WHERE `shorten`=? AND `resellerid`=? LIMIT 1 " );
while ( $i < $count ) {
2013-10-03 12:49:13 +02:00
if ( $games [ $i ] != '' and ! in_array ( $games [ $i ], $gamelist )) {
2013-10-05 13:39:56 +02:00
$gamelist [] = $games [ $i ];
2013-09-28 13:12:29 +02:00
$query -> execute ( array ( $games [ $i ], $reseller_id ));
2013-10-13 11:42:31 +02:00
$typeID = $query -> fetchColumn ();
2013-10-20 12:02:02 +02:00
$rootServer -> collectData ( $typeID , true );
2013-08-28 22:47:04 +02:00
}
2013-10-20 12:02:02 +02:00
2013-08-28 22:47:04 +02:00
$i ++ ;
}
2013-10-20 12:02:02 +02:00
$sshcmd = $rootServer -> returnCmds ( 'install' , 'all' );
if ( $rootServer -> sshcmd === null ) {
2013-08-28 22:47:04 +02:00
echo 'Nothing to update/sync!' ;
} else {
2013-10-20 12:02:02 +02:00
2013-10-12 08:40:09 +02:00
if ( ssh2_execute ( 'gs' , $ui -> id ( 'id' , 10 , 'get' ), $rootServer -> sshcmd ) === false ) {
2013-10-20 12:02:02 +02:00
echo $sprache -> error_root_updatemaster . ' ( ' . implode ( ', ' , $gamelist ) . ' )' ;
2013-08-28 22:47:04 +02:00
} else {
$rootServer -> setUpdating ();
2013-10-20 12:02:02 +02:00
echo $sprache -> root_updatemaster . ' ( ' . implode ( ', ' , $gamelist ) . ' )' ;
2013-08-28 22:47:04 +02:00
}
2013-10-20 12:02:02 +02:00
2013-12-27 12:10:27 +01:00
if ( isset ( $dbConnect [ 'debug' ]) and $dbConnect [ 'debug' ] == 1 ) {
2013-10-19 16:20:33 +02:00
echo '<br>' . implode ( '<br>' , $rootServer -> sshcmd );
}
2013-08-28 22:47:04 +02:00
}
2013-10-20 12:02:02 +02:00
2013-10-13 11:42:31 +02:00
} else if (( $pa [ 'voiceserver' ] or $pa [ 'voiceserver' ]) and $ui -> st ( 'd' , 'get' ) == " vo " and $ui -> id ( 'id' , 19 , 'get' )) {
2013-10-20 12:02:02 +02:00
2013-09-29 15:29:58 +02:00
$sprache = getlanguagefile ( 'voice' , $user_language , $reseller_id );
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT m.`maxserver`,COUNT(v.`id`) AS `installedserver`,m.`maxslots`,SUM(v.`slots`) AS `installedslots`,SUM(v.`usedslots`) AS `uslots` FROM `voice_masterserver` m LEFT JOIN `voice_server` v ON m.`id`=v.`masterserver` WHERE m.`id`=? AND m.`resellerid`=? LIMIT 1 " );
2013-10-13 11:42:31 +02:00
$query -> execute ( array ( $ui -> id ( 'id' , 19 , 'get' ), $reseller_id ));
2013-08-28 22:47:04 +02:00
foreach ( $query -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) {
2013-10-03 16:48:54 +02:00
if ( $row [ 'installedserver' ] == null ) {
2013-09-29 15:29:58 +02:00
$installedserver = 0 ;
2013-08-28 22:47:04 +02:00
} else {
2013-10-13 11:42:31 +02:00
$installedserver = $row [ 'installedserver' ];
2013-08-28 22:47:04 +02:00
}
2013-10-03 16:48:54 +02:00
if ( $row [ 'installedslots' ] == null ) {
2013-09-29 15:29:58 +02:00
$installedslots = 0 ;
2013-08-28 22:47:04 +02:00
} else {
2013-10-13 11:42:31 +02:00
$installedslots = $row [ 'installedslots' ];
2013-08-28 22:47:04 +02:00
}
2013-10-03 16:48:54 +02:00
if ( $row [ 'uslots' ] == null ) {
2013-09-29 15:29:58 +02:00
$uslots = 0 ;
2013-08-28 22:47:04 +02:00
} else {
2013-10-13 11:42:31 +02:00
$uslots = $row [ 'uslots' ];
2013-08-28 22:47:04 +02:00
}
2014-02-23 13:13:48 +01:00
require_once IncludeTemplate ( $template_to_use , 'ajax_admin_voiceserver_usage.tpl' , 'ajax' );
2013-08-28 22:47:04 +02:00
}
2013-10-13 11:42:31 +02:00
} else if ( $pa [ 'gserver' ] and $ui -> st ( 'd' , 'get' ) != " vs " and $ui -> st ( 'd' , 'get' ) != " vo " and ( $ui -> id ( 'id' , 19 , 'get' ) or $ui -> ip ( 'ip' , 'get' ))) {
2013-09-29 15:29:58 +02:00
$sprache = getlanguagefile ( 'gserver' , $user_language , $reseller_id );
2013-10-03 12:49:13 +02:00
if ( $reseller_id != 0 and $admin_id != $reseller_id ) {
2013-10-05 18:39:30 +02:00
$reseller_id = $admin_id ;
2013-08-28 22:47:04 +02:00
}
2013-10-13 11:42:31 +02:00
if ( $ui -> id ( 'id' , 19 , 'get' ) and $ui -> st ( 'd' , 'get' ) != " vs " ) {
2013-09-29 15:29:58 +02:00
$used = 0 ;
$max = 0 ;
$installedserver = 0 ;
$maxserver = 0 ;
$maxslots = 0 ;
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT `maxslots`,`maxserver` FROM `rserverdata` WHERE `id`=? AND `resellerid`=? LIMIT 1 " );
2013-10-13 11:42:31 +02:00
$query -> execute ( array ( $ui -> id ( 'id' , 19 , 'get' ), $reseller_id ));
2013-08-28 22:47:04 +02:00
foreach ( $query -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) {
2013-10-13 11:42:31 +02:00
$maxslots = $row [ 'maxslots' ];
$maxserver = $row [ 'maxserver' ];
2013-08-28 22:47:04 +02:00
}
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT `slots`,`queryNumplayers` FROM `gsswitch` WHERE `rootID`=? AND `resellerid`=? AND `active`='Y' " );
2013-10-13 11:42:31 +02:00
$query -> execute ( array ( $ui -> id ( 'id' , 19 , 'get' ), $reseller_id ));
2013-08-28 22:47:04 +02:00
foreach ( $query -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) {
$used += $row [ 'queryNumplayers' ];
$max += $row [ 'slots' ];
$installedserver ++ ;
}
2014-02-23 13:13:48 +01:00
require_once IncludeTemplate ( $template_to_use , 'ajax_admin_gserver_usage.tpl' , 'ajax' );
2013-10-13 11:42:31 +02:00
} else if ( $ui -> ip ( 'ip' , 'get' ) and $ui -> st ( 'd' , 'get' ) != " vs " ) {
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT `port`,`port2`,`port3`,`port4`,`port5` FROM `gsswitch` WHERE `serverip`=? AND `resellerid`=? ORDER BY `port` " );
2013-10-13 11:42:31 +02:00
$query -> execute ( array ( $ui -> ip ( 'ip' , 'get' ), $reseller_id ));
2013-08-28 22:47:04 +02:00
foreach ( $query -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) {
if ( port ( $row [ 'port' ])){
2013-10-05 13:39:56 +02:00
$ports [] = $row [ 'port' ];
2013-08-28 22:47:04 +02:00
}
if ( port ( $row [ 'port2' ])){
2013-10-05 13:39:56 +02:00
$ports [] = $row [ 'port2' ];
2013-08-28 22:47:04 +02:00
}
if ( port ( $row [ 'port3' ])){
2013-10-05 13:39:56 +02:00
$ports [] = $row [ 'port3' ];
2013-08-28 22:47:04 +02:00
}
if ( port ( $row [ 'port4' ])){
2013-10-05 13:39:56 +02:00
$ports [] = $row [ 'port4' ];
2013-08-28 22:47:04 +02:00
}
if ( port ( $row [ 'port5' ])){
2013-10-05 13:39:56 +02:00
$ports [] = $row [ 'port5' ];
2013-08-28 22:47:04 +02:00
}
}
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT `port` FROM `voice_server` WHERE `ip`=? " );
2013-10-13 11:42:31 +02:00
$query -> execute ( array ( $ui -> ip ( 'ip' , 'get' )));
2013-08-28 22:47:04 +02:00
foreach ( $query -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) {
if ( port ( $row [ 'port' ])){
2013-10-05 13:39:56 +02:00
$ports [] = $row [ 'port' ];
2013-08-28 22:47:04 +02:00
}
}
if ( isset ( $ports )) {
$ports = array_unique ( $ports );
asort ( $ports );
$ports = implode ( " , " , $ports );
} else {
2013-09-29 15:29:58 +02:00
$ports = '' ;
2013-08-28 22:47:04 +02:00
}
2014-02-23 13:13:48 +01:00
require_once IncludeTemplate ( $template_to_use , 'ajax_admin_gserver_ports.tpl' , 'ajax' );
2013-08-28 22:47:04 +02:00
}
2013-10-13 11:42:31 +02:00
} else if (( $pa [ 'usertickets' ] or $pa [ 'usertickets' ]) and $ui -> port ( 'po' , 'get' ) and ( $ui -> st ( 'd' , 'get' ) == 'ut' or $ui -> st ( 'd' , 'get' ) == 'rt' )) {
if ( $reseller_id != 0 and $admin_id == $reseller_id and $ui -> st ( 'd' , 'get' ) == 'rt' ) {
2013-09-29 15:29:58 +02:00
$resellerid = 0 ;
2013-10-13 11:42:31 +02:00
} else if ( $reseller_id != 0 and $admin_id != $reseller_id and $ui -> st ( 'd' , 'get' ) == 'rt' ) {
$resellerid = $admin_id ;
} else if ( $ui -> st ( 'd' , 'get' ) == 'ut' or $ui -> st ( 'd' , 'get' ) == 'rt' ) {
$resellerid = $reseller_id ;
2013-08-28 22:47:04 +02:00
}
2013-09-29 15:29:58 +02:00
$table = array ();
2013-08-28 22:47:04 +02:00
if ( isset ( $resellerid )) {
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT `language` FROM `settings` WHERE `resellerid`=? LIMIT 1 " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $resellerid ));
2013-10-13 11:42:31 +02:00
$default_language = $query -> fetchColumn ();
2013-09-28 13:12:29 +02:00
$query = $sql -> prepare ( " SELECT * FROM `ticket_topics` WHERE `maintopic`=? AND `maintopic`!=`id` AND `resellerid`=? ORDER BY `id` " );
$query -> execute ( array ( $ui -> port ( 'po' , 'get' ), $resellerid ));
2013-08-28 22:47:04 +02:00
foreach ( $query -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) {
2013-09-29 15:29:58 +02:00
$topic = '' ;
2013-10-13 11:42:31 +02:00
$pselect3 = $sql -> prepare ( " SELECT `text` FROM `translations` WHERE `type`='ti' AND `lang`=? AND `transID`=? AND `resellerID`=? LIMIT 1 " );
2013-09-28 13:12:29 +02:00
$pselect3 -> execute ( array ( $user_language , $row [ 'id' ], $resellerid ));
2013-10-13 11:42:31 +02:00
$topic = $pselect3 -> fetchColumn ();
2013-08-28 22:47:04 +02:00
if ( empty ( $topic )) {
2013-09-28 13:12:29 +02:00
$pselect3 -> execute ( array ( $default_language , $row [ 'id' ], $resellerid ));
2013-10-13 11:42:31 +02:00
$topic = $pselect3 -> fetchColumn ();
2013-08-28 22:47:04 +02:00
}
2013-10-13 11:42:31 +02:00
if ( empty ( $topic )) $topic = $row [ 'topic' ];
2013-10-10 08:06:37 +02:00
$table [] = array ( 'id' => $row [ 'id' ], 'topic' => $topic );
2013-08-28 22:47:04 +02:00
}
2013-10-28 08:23:33 +01:00
$ticketTemplate = ( $ui -> id ( 'r' , 1 , 'get' ) != 1 ) ? 'ajax_userpanel_ticket_category.tpl' : 'ajax_admin_reseller_ticket_category.tpl' ;
2014-02-23 13:13:48 +01:00
require_once IncludeTemplate ( $template_to_use , $ticketTemplate , 'ajax' );
2013-08-28 22:47:04 +02:00
}
}