2013-08-28 22:47:04 +02:00
< ? php
2013-09-28 13:12:29 +02:00
2013-08-28 22:47:04 +02:00
/**
* File : serverlog . 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/class_ftp.php' );
include ( EASYWIDIR . '/stuff/methods/vorlage.php' );
2013-09-27 08:22:09 +02:00
include ( EASYWIDIR . '/stuff/settings.php' );
2013-10-03 12:49:13 +02:00
include ( EASYWIDIR . '/stuff/keyphrasefile.php' );
2013-08-28 22:47:04 +02:00
if ( ! isset ( $user_id ) and ! isset ( $admin_id )) {
header ( 'Location: login.php' );
die ( 'Please allow redirection' );
2014-02-15 19:30:19 +01:00
}
2014-02-20 20:11:04 +01:00
if ( ! isset ( $resellerLockupID )) {
$resellerLockupID = $reseller_id ;
2014-02-15 19:30:19 +01:00
}
2013-10-03 12:49:13 +02:00
if ( $ui -> id ( 'id' , 10 , 'get' )) {
2013-10-13 13:11:38 +02:00
if ( isset ( $admin_id )) {
2013-10-03 12:49:13 +02:00
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " SELECT u.`id`,u.`cname` FROM `gsswitch` g LEFT JOIN `userdata` u ON g.`userid`=u.`id` WHERE g.`id`=? AND g.`resellerid`=? LIMIT 1 " );
2014-02-20 20:11:04 +01:00
$query -> execute ( array ( $ui -> id ( 'id' , 10 , 'get' ), $resellerLockupID ));
2013-08-28 22:47:04 +02:00
foreach ( $query -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) {
2013-10-03 12:49:13 +02:00
$username = $row [ 'cname' ];
$user_id = $row [ 'id' ];
2013-08-28 22:47:04 +02:00
}
2013-10-03 12:49:13 +02:00
2013-08-28 22:47:04 +02:00
} else {
2013-10-03 12:49:13 +02:00
$username = getusername ( $user_id );
2013-08-28 22:47:04 +02:00
}
2013-10-03 12:49:13 +02:00
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " SELECT g.`id`,g.`newlayout`,g.`rootID`,g.`serverip`,g.`port`,g.`protected`,AES_DECRYPT(g.`ftppassword`,?) AS `dftppass`,AES_DECRYPT(g.`ppassword`,?) AS `decryptedftppass`,s.`servertemplate`,t.`binarydir`,t.`shorten` FROM `gsswitch` g LEFT JOIN `serverlist` s ON g.`serverid`=s.`id` LEFT JOIN `servertypes` t ON s.`servertype`=t.`id` WHERE g.`id`=? AND g.`userid`=? AND g.`resellerid`=? LIMIT 1 " );
2014-02-20 20:11:04 +01:00
$query -> execute ( array ( $aeskey , $aeskey , $ui -> id ( 'id' , 10 , 'get' ), $user_id , $resellerLockupID ));
2013-08-28 22:47:04 +02:00
foreach ( $query -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) {
2013-10-03 12:49:13 +02:00
$protected = $row [ 'protected' ];
$servertemplate = $row [ 'servertemplate' ];
$rootID = $row [ 'rootID' ];
$serverip = $row [ 'serverip' ];
$port = $row [ 'port' ];
2013-10-26 18:00:03 +02:00
$shorten = $row [ 'shorten' ];
$binarydir = $row [ 'binarydir' ];
$ftppass = $row [ 'dftppass' ];
2013-10-03 12:49:13 +02:00
if ( $row [ 'newlayout' ] == 'Y' ) {
$username .= '-' . $row [ 'id' ];
}
2013-10-26 18:00:03 +02:00
2013-10-03 12:49:13 +02:00
if ( $protected == 'N' and $servertemplate > 1 ) {
$shorten .= '-' . $servertemplate ;
$pserver = 'server/' ;
} else if ( $protected == 'Y' ) {
$username .= '-p' ;
$ftppass = $row [ 'decryptedftppass' ];
2013-09-29 15:29:58 +02:00
$pserver = '' ;
2013-08-28 22:47:04 +02:00
} else {
2013-10-03 12:49:13 +02:00
$pserver = 'server/' ;
2013-08-28 22:47:04 +02:00
}
}
2013-10-26 18:00:03 +02:00
2013-10-03 12:49:13 +02:00
if ( isset ( $rootID )) {
2013-10-26 18:00:03 +02:00
2013-10-03 12:49:13 +02:00
$query = $sql -> prepare ( " SELECT `ip`,`ftpport` FROM `rserverdata` WHERE `id`=? AND `resellerid`=? LIMIT 1 " );
2014-02-20 20:11:04 +01:00
$query -> execute ( array ( $rootID , $resellerLockupID ));
2013-10-03 12:49:13 +02:00
foreach ( $query -> fetchAll ( PDO :: FETCH_ASSOC ) as $row ) {
2014-02-11 21:34:49 +01:00
2013-10-03 12:49:13 +02:00
$ftpport = $row [ 'ftpport' ];
$ip = $row [ 'ip' ];
2013-10-26 18:00:03 +02:00
2014-02-15 16:07:12 +01:00
2013-12-14 20:02:46 +01:00
$ftpConnect = new EasyWiFTP ( $ip , $ftpport , $username , $ftppass );
2013-10-26 18:00:03 +02:00
2013-12-14 20:02:46 +01:00
if ( $ftpConnect -> ftpConnection ) {
2013-10-26 18:00:03 +02:00
2014-02-15 16:07:12 +01:00
if ( ! $ftpConnect -> downloadToTemp ( '/' . $pserver . $serverip . '_' . $port . '/' . $shorten . '/' . $binarydir . '/screenlog.0' , 32768 )) {
2014-01-22 21:35:00 +01:00
$error = 'Cannot download screenlog from /' . $pserver . $serverip . '_' . $port . '/' . $shorten . '/' . $binarydir . '/screenlog.0' ;
2013-10-26 18:00:03 +02:00
}
2014-01-22 21:35:00 +01:00
} else {
$error = 'Cannot connect to FTP Server ' . $ip . ':' . $ftpport ;
2013-08-28 22:47:04 +02:00
}
2013-12-14 20:02:46 +01:00
2013-08-28 22:47:04 +02:00
}
2013-10-26 18:00:03 +02:00
2014-02-15 19:30:19 +01:00
if ( isset ( $ip )) {
2014-02-15 16:07:12 +01:00
echo ( isset ( $error )) ? $error : '<html><head><title>' . $ewCfg [ 'title' ] . ' ' . $serverip . ':' . $port . '</title><meta http-equiv="refresh" content="3"></head><body>' . nl2br ( $ftpConnect -> getTempFileContent ()) . '</body></html>' ;
$ftpConnect -> tempHandle = null ;
2014-02-15 15:25:27 +01:00
$ftpConnect = null ;
2014-02-15 16:07:12 +01:00
} else {
2014-02-15 19:30:19 +01:00
echo 'Error: wrong rootID' ;
2014-02-15 15:25:27 +01:00
}
2013-10-26 18:00:03 +02:00
2013-08-28 22:47:04 +02:00
} else {
2014-02-15 19:30:19 +01:00
echo 'Error: No rootID' ;
2013-08-28 22:47:04 +02:00
}
}
2013-10-13 11:42:31 +02:00
$sql = null ;