#121: Voice module

This commit is contained in:
Ulrich Block 2014-01-05 14:20:29 +01:00
parent 3852b89510
commit 9aec9dcb0c
7 changed files with 229 additions and 283 deletions

View File

@ -206,7 +206,7 @@ if (!isset($ip) or $_SERVER['SERVER_ADDR'] == $ip) {
$query2 = $sql->prepare("SELECT *,AES_DECRYPT(`user`,?) AS `duser`,AES_DECRYPT(`pass`,?) AS `dpass` FROM `rserverdata` WHERE `resellerid`=?");
$query2->execute(array($aeskey, $aeskey, $resellerID));
foreach ($query2->fetchAll(PDO::FETCH_ASSOC) as $row2) {
if (($row2['publickey'] == 'Y' and strlen($row2['keyname']) > 0) or ($row2['publickey'] == 'N' and strlen($row2['dpass']) > 0)) {
if (($row2['publickey'] != 'N' and strlen($row2['keyname']) > 0) or ($row2['publickey'] == 'N' and strlen($row2['dpass']) > 0)) {
$gameRootIPs[$row2['ip']] = array('id' => $row2['id'], 'ftpPort' => $row2['ftpport'], 'user' => $row2['duser'], 'sourceSystemID' => $row2['sourceSystemID'], 'externalID' => $row2['externalID']);
foreach (ipstoarray($row2['altips']) as $ip) {
$gameRootIPs[$ip] = array('id' => $row2['id'], 'ftpPort' => $row2['ftpport'], 'user' => $row2['duser'], 'sourceSystemID' => $row2['sourceSystemID'], 'externalID' => $row2['externalID']);

View File

@ -41,11 +41,6 @@
if (!defined('EASYWIDIR')) {
define('EASYWIDIR', '');
}
if (!extension_loaded('ssh2')) {
function ssh2_connect ($ip = '', $port = '', $params = '') {
return null;
}
}
if (!function_exists('passwordgenerate')) {

View File

@ -56,6 +56,12 @@ if (!function_exists('ssh2_execute')) {
} else if ($type == 'vh') {
$query = $sql->prepare("SELECT *,AES_DECRYPT(`port`,:aeskey) AS `decryptedport`,AES_DECRYPT(`user`,:aeskey) AS `decrypteduser`,AES_DECRYPT(`pass`,:aeskey) AS `decryptedpass` FROM `virtualhosts` WHERE `id`=:serverID LIMIT 1");
} else if ($type == 'vd') {
$query = $sql->prepare("SELECT *,`ssh2ip` AS `ip`,AES_DECRYPT(`ssh2port`,:aeskey) AS `decryptedport`,AES_DECRYPT(`ssh2user`,:aeskey) AS `decrypteduser`,AES_DECRYPT(`ssh2password`,:aeskey) AS `decryptedpass` FROM `voice_tsdns` WHERE `id`=:serverID LIMIT 1");
} else if ($type == 'vm') {
$query = $sql->prepare("SELECT *,`ssh2ip` AS `ip`,AES_DECRYPT(`ssh2port`,:aeskey) AS `decryptedport`,AES_DECRYPT(`ssh2user`,:aeskey) AS `decrypteduser`,AES_DECRYPT(`ssh2password`,:aeskey) AS `decryptedpass` FROM `voice_masterserver` WHERE `id`=:serverID LIMIT 1");
}
if (isset($query)) {
@ -79,23 +85,21 @@ if (!function_exists('ssh2_execute')) {
if ($sshObject->error === false) {
if ($ssh2Publickey == 'N') {
if ($ssh2Publickey != 'N') {
$loginSucces = $sshObject->login($ssh2User, $ssh2Pass);
} else {
$key = new Crypt_RSA();
$key->loadKey(file_get_contents($privateKey));
$loginSucces = $sshObject->login($ssh2User, $key);
$ssh2Pass = new Crypt_RSA();
$ssh2Pass->loadKey(file_get_contents($privateKey));
}
if ($loginSucces) {
if ($sshObject->login($ssh2User, $ssh2Pass)) {
$notified = 0;
if (!is_array($cmds)) {
$cmds = array($cmds);
}
foreach ($cmds as $c) {
if (!is_array($cmds)) {
@ -116,7 +120,7 @@ if (!function_exists('ssh2_execute')) {
}
if ($notified == $rSA['down_checks']) {
$query=($resellerID==0) ? $sql->prepare("SELECT `id`,`mail_serverdown` FROM `userdata` WHERE `resellerid`=0 AND `accounttype`='a'") : $sql->prepare("SELECT `id`,`mail_serverdown` FROM `userdata` WHERE (`id`=${resellerID} AND `id`=`resellerid`) OR `resellerid`=0 AND `accounttype`='a'");
$query = ($resellerID == 0) ? $sql->prepare("SELECT `id`,`mail_serverdown` FROM `userdata` WHERE `resellerid`=0 AND `accounttype`='a'") : $sql->prepare("SELECT `id`,`mail_serverdown` FROM `userdata` WHERE (`id`=${resellerID} AND `id`=`resellerid`) OR `resellerid`=0 AND `accounttype`='a'");
$query->execute();
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row2) {
if ($row2['mail_serverdown'] == 'Y') {
@ -131,10 +135,14 @@ if (!function_exists('ssh2_execute')) {
$query = $sql->prepare("UPDATE `eac` SET `notified`=? WHERE `id`=? LIMIT 1");
} else if ($type == 'vh') {
$query = $sql->prepare("UPDATE `virtualhosts` SET `notified`=? WHERE `id`=? LIMIT 1");
} else if ($type == 'vd') {
$query = $sql->prepare("UPDATE `voice_tsdns` SET `notified`=? WHERE `id`=? LIMIT 1");
} else if ($type == 'vm') {
$query = $sql->prepare("UPDATE `voice_masterserver` SET `notified`=? WHERE `id`=? LIMIT 1");
}
$query->execute(array($notified, $serverID));
return ($notified == 0) ? false: $return;
return ($notified == 0 or $sshObject->error === false) ? $return : false;
}
}

View File

@ -37,335 +37,273 @@
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
*/
function tsbackup ($action, $sship, $sshport, $sshuser, $keyuse, $sshkey, $sshpw, $notified, $path, $virtualserver_id, $backupid, $reseller_id, $move = array()) {
function tsbackup ($action, $sshuser, $path, $ts3MasterID, $virtualserver_id, $backupid, $move = array()) {
global $sql;
$split_config = preg_split('/\//', $path, -1, PREG_SPLIT_NO_EMPTY);
$folderfilecount = count($split_config) - 1;
$i = 0;
if ($keyuse == 'Y') {
# https://github.com/easy-wi/developer/issues/70
$sshkey = removePub($sshkey);
$pubkey = EASYWIDIR . '/keys/' . $sshkey . '.pub';
$key = EASYWIDIR . '/keys/' . $sshkey;
$folders = (substr($path, 0, 1) == '/') ? '/' : '/home/'.$sshuser . '/';
$ssh2 = (file_exists($pubkey) and file_exists($key)) ? @ssh2_connect($sship, $sshport, array('hostkey' => 'ssh-rsa')) : false;
} else {
$ssh2 = @ssh2_connect($sship, $sshport);
while ($i <= $folderfilecount) {
$folders .= $split_config[$i] . '/';
$i++;
}
if ($ssh2 == true) {
if ($folders == '') {
$folders='.';
}
$connect_ssh2 = ($keyuse== 'Y' and isset($pubkey) and isset($key)) ? @ssh2_auth_pubkey_file($ssh2, $sshuser, $pubkey, $key) : @ssh2_auth_password($ssh2, $sshuser, $sshpw);
if (substr($folders, -1) != '/') {
$folders = $folders . '/';
}
if ($connect_ssh2 == true) {
$filefolder = $folders . 'files/virtualserver_' . $virtualserver_id . '/';
$split_config = preg_split('/\//', $path, -1, PREG_SPLIT_NO_EMPTY);
$folderfilecount = count($split_config) - 1;
$i = 0;
$backupfolder = $folders . 'backups/virtualserver_' . $virtualserver_id . '/';
$folders = (substr($path, 0, 1) == '/') ? '/' : '/home/'.$sshuser . '/';
if ($action == 'create') {
while ($i <= $folderfilecount) {
$folders .= $split_config[$i] . '/';
$i++;
$function = 'function backup () { mkdir -p ' . $backupfolder . ' && nice -n +19 tar cfj ' . $backupfolder . $backupid . '.tar.bz2 ' . $filefolder . '; }';
} else if ($action == 'delete') {
$function = 'function backup () { nice -n +19 rm -f ' . $backupfolder . $backupid . '.tar.bz2; }';
} else if ($action == 'deploy') {
$function = 'function backup () { nice -n +19 rm -rf ' . $filefolder . '* && nice -n +19 tar xfj ' . $backupfolder . $backupid . '.tar.bz2 -C /';
if (count($move) > 0) {
foreach ($move as $o => $n) {
$function .= ' && mv ' . $o . ' ' . $n;
}
}
if ($folders == '') {
$folders='.';
}
$function .= '; }';
if (substr($folders, -1) != '/') {
$folders = $folders . '/';
}
}
$filefolder = $folders . 'files/virtualserver_' . $virtualserver_id . '/';
if (isset($function)) {
$backupfolder = $folders . 'backups/virtualserver_' . $virtualserver_id . '/';
if ($action == 'create') {
$function = 'function backup () { mkdir -p ' . $backupfolder . ' && nice -n +19 tar cfj ' . $backupfolder . $backupid . '.tar.bz2 ' . $filefolder . '; }';
} else if ($action == 'delete') {
$function = 'function backup () { nice -n +19 rm -f ' . $backupfolder . $backupid . '.tar.bz2; }';
} else if ($action == 'deploy') {
$function = 'function backup () { nice -n +19 rm -rf ' . $filefolder . '* && nice -n +19 tar xfj ' . $backupfolder . $backupid . '.tar.bz2 -C /';
if (count($move) > 0) {
foreach ($move as $o => $n) {
$function .= ' && mv ' . $o . ' ' . $n;
}
}
$function .= '; }';
}
if (isset($function)) {
$ssh2cmd = 'cd ' . $folders . ' && ' . $function . '; backup& ';
ssh2_exec($ssh2, $ssh2cmd);
if ($notified == 'Y') {
$query = $sql->prepare("UPDATE `voice_masterserver` SET `notified`='N' WHERE `ssh2ip`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($sship, $reseller_id));
}
} else {
$bad = 'Incorrect action';
}
$ssh2cmd = 'cd ' . $folders . ' && ' . $function . '; backup& ';
if (ssh2_execute('vm', $ts3MasterID, $ssh2cmd) !== false) {
return 'ok';
} else {
$bad = 'The login data does not work';
return 'The login data does not work';
}
} else {
$bad = 'Could not connect to Server';
}
if (isset($bad) and $notified != 'Y') {
return 'Incorrect action';
if ($reseller_id == 0) {
$query = $sql->prepare("SELECT `id`,`mail_serverdown` FROM `userdata` WHERE `resellerid`=0 AND `accounttype`='a'");
$query->execute();
} else {
$query = $sql->prepare("SELECT `id`,`mail_serverdown` FROM `userdata` WHERE (`id`=? AND `id`=`resellerid`) OR (`resellerid`=0 AND `accounttype`='a')");
$query->execute(array($reseller_id));
}
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
if ($row['mail_serverdown'] == 'Y') {
sendmail('emaildown', $row['id'], 'TS3 Master ' . $sship . ' ( ' . $bad . ' )', '');
}
}
$query = $sql->prepare("UPDATE `voice_masterserver` SET `notified`='Y' WHERE `ssh2ip`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($sship, $reseller_id));
return $bad;
} else {
return 'ok';
}
}
function tsdns ($action, $sship, $sshport, $sshuser, $keyuse, $sshkey, $sshpw, $notified, $path, $bitversion, $tsip, $tsport, $tsdns, $reseller_id, $maxnotified = 2) {
global $sql;
if ($keyuse == 'Y') {
$sshkey = removePub($sshkey);
$pubkey = EASYWIDIR . '/keys/' . $sshkey . '.pub';
$key = EASYWIDIR . '/keys/' . $sshkey;
$ssh2 = (file_exists($pubkey) and file_exists($key)) ? @ssh2_connect($sship, $sshport, array('hostkey' => 'ssh-rsa')) : false;
} else {
$ssh2 = @ssh2_connect($sship, $sshport);
if (!class_exists('Net_SSH2')) {
include(EASYWIDIR . '/third_party/phpseclib/Net/SSH2.php');
}
if ($ssh2 == true) {
if (!class_exists('Net_SFTP')) {
include(EASYWIDIR . '/third_party/phpseclib/Net/SFTP.php');
}
$connect_ssh2 = ($keyuse == 'Y') ? @ssh2_auth_pubkey_file($ssh2, $sshuser, $pubkey, $key) : @ssh2_auth_password($ssh2, $sshuser, $sshpw);
global $sql;
if ($connect_ssh2 == true) {
$sshSftpObject = new Net_SFTP($sship, $sshport);
$split_config = preg_split('/\//', $path, -1, PREG_SPLIT_NO_EMPTY);
$folderfilecount = count($split_config) - 1;
if ($keyuse != 'N') {
$i = 0;
$privateKey = EASYWIDIR . '/keys/' . removePub($sshkey);
$folders = (substr($path,0,1) == '/') ? '/' : '';
$lastFolder = '';
$sshpw = new Crypt_RSA();
$sshpw->loadKey(file_get_contents($privateKey));
while ($i <= $folderfilecount) {
$folders .= $split_config[$i] . '/';
$lastFolder = $split_config[$i];
$i++;
}
}
if ($lastFolder != 'tsdns' or substr($path, 0, 1) != '/') {
$folders .= 'tsdns/';
}
if ($sshSftpObject->login($sshuser, $sshpw)) {
$bin = ($bitversion == 32) ? 'tsdnsserver_linux_x86' : 'tsdnsserver_linux_amd64';
$ssh2cmd = 'cd ' . $folders . ' && function restart () { if [ "`ps fx | grep ' . $bin . ' | grep -v grep`" == "" ]; then ./' . $bin . ' > /dev/null & else ./' . $bin . ' --update > /dev/null & fi }; restart& ';
$split_config = preg_split('/\//', $path, -1, PREG_SPLIT_NO_EMPTY);
$folderfilecount = count($split_config) - 1;
if ($action == 'md' or $action == 'dl') {
$i = 0;
$newip = $tsip[0];
$oldip = (isset($tsip[1])) ? $tsip[1] : '';
$folders = (substr($path,0,1) == '/') ? '/' : '';
$lastFolder = '';
$newport = $tsport[0];
$oldport = (isset($tsport[1])) ? $tsport[1] : '';
while ($i <= $folderfilecount) {
$folders .= $split_config[$i] . '/';
$lastFolder = $split_config[$i];
$i++;
}
$newdns = $tsdns[0];
$olddns = (isset($tsdns[1])) ? $tsdns[1] : '';
if ($lastFolder != 'tsdns' or substr($path, 0, 1) != '/') {
$folders .= 'tsdns/';
}
} else {
$dnsarray = array();
}
if ($action == 'md' or $action == 'dl') {
$sftp = ssh2_sftp($ssh2);
$file = (substr($path,0,1) == '/') ? 'ssh2.sftp://' . $sftp . $folders . 'tsdns_settings.ini' : 'ssh2.sftp://' . $sftp . '/home/' . $sshuser . '/' . $folders . 'tsdns_settings.ini';
$newip = $tsip[0];
$oldip = (isset($tsip[1])) ? $tsip[1] : '';
if ($action != 'rs') {
$newport = $tsport[0];
$oldport = (isset($tsport[1])) ? $tsport[1] : '';
$tsdns_read= @fopen($file, 'r');
$buffer = '';
$newdns = $tsdns[0];
$olddns = (isset($tsdns[1])) ? $tsdns[1] : '';
if ($tsdns_read) {
} else {
$dnsarray = array();
}
$filesize = filesize($file);
$file = (substr($path,0,1) == '/') ? $folders . 'tsdns_settings.ini' : '/home/' . $sshuser . '/' . $folders . 'tsdns_settings.ini';
if ($filesize > 0) {
while (strlen($buffer) < $filesize) {
$buffer .= fread($tsdns_read, $filesize);
}
}
if ($action != 'rs') {
$data = $sshSftpObject->get($file);
$data = str_replace(array("\0", "\b", "\r", "\Z"), '', $data);
}
fclose($tsdns_read);
$data = str_replace(array("\0", "\b", "\r", "\Z"), '', $buffer);
}
}
if ($action != 'rs' and $action != 'mw' and isset($tsdns_read) and isset($data) and $tsdns_read) {
$edited = false;
$ca = array();
if ($action != 'rs' and $action != 'mw') {
foreach (preg_split('/\n/', $data, -1, PREG_SPLIT_NO_EMPTY) as $configLine) {
$edited = false;
$ca = array();
if ($action != 'li' and $configLine != $olddns . '=' . $oldip . ':' . $oldport and $configLine != $newdns . '=' . $newip . ':' . $newport) {
$ca[] = $configLine . "\r\n";
} else if ($action == 'md' and $edited == false and ($configLine == $olddns . '=' . $oldip . ':' . $oldport or $configLine == $newdns . '=' . $newip . ':' . $newport)) {
$edited = true;
$ca[] = $newdns . '=' . $newip . ':' . $newport . "\r\n";
}
foreach (preg_split('/\n/', $data, -1, PREG_SPLIT_NO_EMPTY) as $configLine) {
if ($action == 'li' and $configLine != '' and !preg_match('/^#(|\s+)(.*)$/', $configLine)) {
$dnsconfig = explode('=', $configLine);
if (isset($dnsconfig[1])) {
$linedns = $dnsconfig[0];
$lineserver = $dnsconfig[1];
$dnsarray[$lineserver] = $linedns;
}
}
}
if ($action == 'md' and $edited == false) {
if ($action != 'li' and $configLine != $olddns . '=' . $oldip . ':' . $oldport and $configLine != $newdns . '=' . $newip . ':' . $newport) {
$ca[] = $configLine . "\r\n";
} else if ($action == 'md' and $edited == false and ($configLine == $olddns . '=' . $oldip . ':' . $oldport or $configLine == $newdns . '=' . $newip . ':' . $newport)) {
$edited = true;
$ca[] = $newdns . '=' . $newip . ':' . $newport . "\r\n";
}
if ($action != 'li') {
$ca = array_unique($ca);
sort($ca);
$newcfg = '';
foreach ($ca as $line) {
$newcfg .= $line;
if ($action == 'li' and $configLine != '' and !preg_match('/^#(|\s+)(.*)$/', $configLine)) {
$dnsconfig = explode('=', $configLine);
if (isset($dnsconfig[1])) {
$linedns = $dnsconfig[0];
$lineserver = $dnsconfig[1];
$dnsarray[$lineserver] = $linedns;
}
if ($newcfg == '') {
$newcfg = '# No TSDNS data entered';
}
$tsdns_write = fopen($file, 'w');
$writefile = fwrite($tsdns_write, $newcfg);
if ($writefile == false) {
$bad = 'Could not upload tsdns_settings.ini';
}
fclose($tsdns_write);
}
}
if ($action == 'mw' and isset($data)) {
if ($action == 'md' and $edited == false) {
$ca[] = $newdns . '=' . $newip . ':' . $newport . "\r\n";
}
$usedIPs = array();
if ($action != 'li') {
foreach (preg_split('/\n/', $data,-1,PREG_SPLIT_NO_EMPTY) as $configLine) {
$ca = array_unique($ca);
sort($ca);
if ($configLine != '' and !preg_match('/^#(|\s+)(.*)$/', $configLine)) {
$newcfg = '';
$splittedLine = preg_split('/\=/', $configLine, -1, PREG_SPLIT_NO_EMPTY);
$usedIPs[] = (isset($splittedLine[1])) ? array('dns' => $splittedLine[0], 'address' => $splittedLine[1]) : $configLine;
} else {
$usedIPs[] = $configLine;
}
foreach ($ca as $line) {
$newcfg .= $line;
}
foreach ($tsip as $newLine) {
$splittedLine = preg_split('/\=/', strtolower($newLine), -1, PREG_SPLIT_NO_EMPTY);
if (isset($splittedLine[1]) and !array_key_exists($splittedLine[1], $usedIPs)) {
$usedIPs[] = array('dns' => $splittedLine[0], 'address' => $splittedLine[1]);
}
if ($newcfg == '') {
$newcfg = '# No TSDNS data entered';
}
function array_multi_dimensional_unique($multi){
$sshSftpObject->put($file, $newcfg);
$unique = array();
}
}
foreach($multi as $sub){
if (!in_array($sub, $unique)){
$unique[] = $sub;
}
}
if ($action == 'mw' and isset($data)) {
return $unique;
$usedIPs = array();
}
foreach (preg_split('/\n/', $data,-1,PREG_SPLIT_NO_EMPTY) as $configLine) {
$newCfg = '';
if ($configLine != '' and !preg_match('/^#(|\s+)(.*)$/', $configLine)) {
$usedIPs = array_multi_dimensional_unique($usedIPs);
sort($usedIPs);
$splittedLine = preg_split('/\=/', $configLine, -1, PREG_SPLIT_NO_EMPTY);
foreach ($usedIPs as $value) {
$newCfg .= (isset($value['dns']) and isset($value['address']) and !preg_match('/^#(|\s+)(.*)$/', $value['dns'])) ? $value['dns'] . '=' . $value['address'] . "\r\n" : $value . "\r\n";
}
$usedIPs[] = (isset($splittedLine[1])) ? array('dns' => $splittedLine[0], 'address' => $splittedLine[1]) : $configLine;
if ($newCfg== '') {
$bad = 'Nothing to write';
} else {
$usedIPs[] = $configLine;
}
}
$tsdns_write= @fopen($file, 'w');
$writefile= @fwrite($tsdns_write, $newCfg);
foreach ($tsip as $newLine) {
if ($writefile == false) {
$bad = 'Could not upload tsdns_settings.ini';
} else {
fclose($tsdns_write);
$splittedLine = preg_split('/\=/', strtolower($newLine), -1, PREG_SPLIT_NO_EMPTY);
if (isset($splittedLine[1]) and !array_key_exists($splittedLine[1], $usedIPs)) {
$usedIPs[] = array('dns' => $splittedLine[0], 'address' => $splittedLine[1]);
}
}
function array_multi_dimensional_unique($multi){
$unique = array();
foreach($multi as $sub){
if (!in_array($sub, $unique)){
$unique[] = $sub;
}
}
return $unique;
}
$newCfg = '';
$usedIPs = array_multi_dimensional_unique($usedIPs);
sort($usedIPs);
foreach ($usedIPs as $value) {
$newCfg .= (isset($value['dns']) and isset($value['address']) and !preg_match('/^#(|\s+)(.*)$/', $value['dns'])) ? $value['dns'] . '=' . $value['address'] . "\r\n" : $value . "\r\n";
}
if ($newCfg== '') {
$bad = 'Nothing to write';
} else {
$sshSftpObject->put($file, $newCfg);
}
}
if (!isset($bad) and $action != 'li') {
$sshObject = new Net_SSH2($sship, $sshport);
if ($sshObject->error === false) {
if ($sshObject->login($sshuser, $sshpw)) {
$bin = ($bitversion == 32) ? 'tsdnsserver_linux_x86' : 'tsdnsserver_linux_amd64';
$ssh2cmd = 'cd ' . $folders . ' && function restart () { if [ "`ps fx | grep ' . $bin . ' | grep -v grep`" == "" ]; then ./' . $bin . ' > /dev/null & else ./' . $bin . ' --update > /dev/null & fi }; restart& ';
$sshObject->exec($ssh2cmd);
if ($notified > 0) {
$query = $sql->prepare("UPDATE `voice_masterserver` SET `notified`=0 WHERE `ssh2ip`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($sship, $reseller_id));
}
} else {
$bad = 'The login data does not work';
$notified++;
}
} else {
$bad = 'Could not connect to Server';
$notified++;
}
if (!isset($bad) and $action != 'li') {
ssh2_exec($ssh2, $ssh2cmd);
if ($notified > 0) {
$query = $sql->prepare("UPDATE `voice_masterserver` SET `notified`=0 WHERE `ssh2ip`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($sship, $reseller_id));
}
}
} else {
$bad = 'The login data does not work';
}
} else {
@ -398,9 +336,10 @@ function tsdns ($action, $sship, $sshport, $sshuser, $keyuse, $sshkey, $sshpw, $
} else if ($action == 'li' and isset($dnsarray)) {
return $dnsarray;
} else {
return 'ok';
}
return 'ok';
}
function checkDNS ($dns, $id = null, $user_id = null, $type = '') {
@ -483,8 +422,8 @@ function checkDNS ($dns, $id = null, $user_id = null, $type = '') {
unset($temp);
if ((isset($tsdnsServerID) and $id != null and $row['id'] == $tsdnsServerID) or ($type == 'dns' and $id != null and $row['id'] == $masterID)) {
$defaultdns=strtolower($id . '-' . getusername($user_id) . '.' . $row['defaultdns']);
$partCount=count(explode('.', $defaultdns));
$defaultdns = strtolower($id . '-' . getusername($user_id) . '.' . $row['defaultdns']);
$partCount = count(explode('.', $defaultdns));
}
$ex = explode('.', $row['defaultdns']);

View File

@ -87,7 +87,7 @@ foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
$query2 = $sql->prepare("SELECT * FROM `jobs` WHERE (`status` IS NULL OR `status`='1') AND `type`='vo' AND `hostID`=?");
$query2->execute(array($row['hostID']));
foreach ($query2->fetchAll(PDO::FETCH_ASSOC) as $row2) {
$query3 = $sql->prepare("SELECT `localserverid`,`active`,`backup`,`lendserver`,`ip`,`port`,`slots`,`initialpassword`,`password`,`forcebanner`,`forcebutton`,`forceservertag`,`forcewelcome`,`max_download_total_bandwidth`,`max_upload_total_bandwidth`,`dns`,`localserverid`,`maxtraffic`,`filetraffic` FROM `voice_server` WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query3 = $sql->prepare("SELECT * FROM `voice_server` WHERE `id`=? AND `resellerid`=? LIMIT 1");
$query3->execute(array($row2['affectedID'], $row2['resellerID']));
foreach ($query3->fetchAll(PDO::FETCH_ASSOC) as $row3) {
$active = $row3['active'];
@ -108,6 +108,7 @@ foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
$max_download_total_bandwidth = $row3['max_download_total_bandwidth'];
$max_upload_total_bandwidth = $row3['max_upload_total_bandwidth'];
$dns = $row3['dns'];
$masterserver = $row['masterserver'];
}
if ($row2['action'] == 'dl' and isset($localserverid) and isid($localserverid,30)) {
$command = $gsprache->del.' voiceserverID: '.$row2['affectedID'].' name:'.$row2['name'];
@ -118,18 +119,16 @@ foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
$update = $sql->prepare("UPDATE `jobs` SET `status`='3' WHERE `jobID`=? AND `type`='vo' LIMIT 1");
$update->execute(array($row2['jobID']));
$template_file = $spracheResponse->table_del;
if ($usedns == 'Y') {
$template_file = tsdns('dl',$queryip,$ssh2port,$ssh2user,$publickey,$keyname,$ssh2password,$mnotified,$serverdir,$bitversion, array($ip), array($port), array($dns), $row['resellerID']);
}
$query3 = $sql->prepare("SELECT `id` FROM `voice_server_backup` WHERE `sid`=? AND `resellerid`=?");
$query3->execute(array($row2['affectedID'], $row['resellerID']));
foreach ($query3->fetchAll(PDO::FETCH_ASSOC) as $row3) {
$delete = $sql->prepare("DELETE FROM `voice_server_backup` WHERE `id`=? AND `resellerid`=? LIMIT 1");
$delete->execute(array($row3['id'], $row['resellerID']));
tsbackup('delete',$queryip,$ssh2port,$ssh2user,$publickey,$keyname,$ssh2password,$mnotified,$serverdir,$localserverid, $row3['id'], $row['resellerID']);
}
tsbackup('delete', $ssh2user, $serverdir, $masterserver, $localserverid, '*');
$query3 = $sql->prepare("DELETE v.* FROM `voice_server_backup` v LEFT JOIN `userdata` u ON v.`uid`=u.`id` WHERE u.`id` IS NULL");
$query3->execute();
} else if ($row2['action'] == 'ad' and isset($active)) {
if (isid($localserverid,30)) {
$command = $gsprache->add.' voiceserverID: '.$row2['affectedID'].'; Skipping, virtual ID already exists in Easy-WI DB: '.$localserverid;

View File

@ -43,6 +43,7 @@ if ((!isset($user_id) or $main != 1) or (isset($user_id) and !$pa['voiceserver']
include(EASYWIDIR . '/stuff/keyphrasefile.php');
include(EASYWIDIR . '/stuff/class_ts3.php');
include(EASYWIDIR . '/stuff/functions_ssh_exec.php');
include(EASYWIDIR . '/stuff/functions_ts3.php');
$sprache = getlanguagefile('voice', $user_language, $reseller_id);
@ -63,7 +64,7 @@ if ($ui->st('d', 'get') == 'bu' and $ui->id('id', 10, 'get') and (!isset($_SESSI
$id = $ui->id('id', 10, 'get');
$query = $sql->prepare("SELECT v.`id`,v.`ip`,v.`port`,v.`dns`,v.`localserverid`,m.`type`,m.`queryport`,AES_DECRYPT(m.`querypassword`,:aeskey) AS `decryptedquerypassword`,m.`rootid`,m.`addedby`,m.`ssh2ip`,m.`type`,m.`usedns`,m.`publickey`,m.`ssh2ip`,AES_DECRYPT(m.`ssh2port`,:aeskey) AS `decryptedssh2port`,AES_DECRYPT(m.`ssh2user`,:aeskey) AS `decryptedssh2user`,AES_DECRYPT(m.`ssh2password`,:aeskey) AS `decryptedssh2password`,m.`serverdir`,m.`keyname`,m.`notified` FROM `voice_server` v LEFT JOIN `voice_masterserver` m ON v.`masterserver`=m.`id` WHERE v.`active`='Y' AND m.`active`='Y' AND v.`backup`='Y' AND v.`id`=:server_id AND v.`userid`=:user_id AND v.`resellerid`=:reseller_id LIMIT 1");
$query = $sql->prepare("SELECT v.`id`,v.`ip`,v.`port`,v.`dns`,v.`localserverid`,v.`masterserver`,m.`type`,m.`queryport`,AES_DECRYPT(m.`querypassword`,:aeskey) AS `decryptedquerypassword`,m.`rootid`,m.`addedby`,m.`ssh2ip`,m.`type`,m.`usedns`,m.`publickey`,m.`ssh2ip`,AES_DECRYPT(m.`ssh2port`,:aeskey) AS `decryptedssh2port`,AES_DECRYPT(m.`ssh2user`,:aeskey) AS `decryptedssh2user`,AES_DECRYPT(m.`ssh2password`,:aeskey) AS `decryptedssh2password`,m.`serverdir`,m.`keyname`,m.`notified` FROM `voice_server` v LEFT JOIN `voice_masterserver` m ON v.`masterserver`=m.`id` WHERE v.`active`='Y' AND m.`active`='Y' AND v.`backup`='Y' AND v.`id`=:server_id AND v.`userid`=:user_id AND v.`resellerid`=:reseller_id LIMIT 1");
$query->execute(array(':aeskey' => $aeskey,':server_id' => $id,':user_id' => $user_id,':reseller_id' => $reseller_id));
foreach ($query->fetchall(PDO::FETCH_ASSOC) as $row) {
@ -79,6 +80,7 @@ if ($ui->st('d', 'get') == 'bu' and $ui->id('id', 10, 'get') and (!isset($_SESSI
$querypassword = $row['decryptedquerypassword'];
$volocalserverid = $row['localserverid'];
$notified = $row['notified'];
$masterserver = $row['masterserver'];
if ($addedby==2) {
@ -129,9 +131,11 @@ if ($ui->st('d', 'get') == 'bu' and $ui->id('id', 10, 'get') and (!isset($_SESSI
$query = $sql->prepare("SELECT `id` FROM `voice_server_backup` WHERE `sid`=? AND `uid`=? AND `resellerid`=? ORDER BY `id` ASC LIMIT $toomuch");
$query->execute(array($id, $user_id, $reseller_id));
foreach ($query->fetchall(PDO::FETCH_ASSOC) as $row) {
$delete = $sql->prepare("DELETE FROM `voice_server_backup` WHERE `id`=? AND `uid`=? AND `resellerid`=? LIMIT 1");
$delete->execute(array($row['id'], $user_id, $reseller_id));
tsbackup('delete', $queryip, $ssh2port, $ssh2user, $publickey, $keyname, $ssh2password, $notified, $serverdir, $volocalserverid, $row['id'], $reseller_id);
tsbackup('delete', $ssh2user, $serverdir, $masterserver, $volocalserverid, $row['id']);
}
}
@ -158,7 +162,7 @@ if ($ui->st('d', 'get') == 'bu' and $ui->id('id', 10, 'get') and (!isset($_SESSI
$query = $sql->prepare("INSERT INTO `voice_server_backup` (`sid`,`uid`,`name`,`snapshot`,`channels`,`date`,`resellerid`) VALUES(?,?,?,?,?,NOW(),?)");
$query->execute(array($id, $user_id, $name, $snapshot, $channelSnapshot, $reseller_id));
$return = tsbackup('create', $queryip, $ssh2port, $ssh2user, $publickey, $keyname, $ssh2password, $notified, $serverdir, $volocalserverid, $sql->lastInsertId(), $reseller_id);
$return = tsbackup('create', $ssh2user, $serverdir, $masterserver, $volocalserverid, $sql->lastInsertId());
if ($return == 'ok') {
@ -191,7 +195,7 @@ if ($ui->st('d', 'get') == 'bu' and $ui->id('id', 10, 'get') and (!isset($_SESSI
$query = $sql->prepare("DELETE FROM `voice_server_backup` WHERE `id`=? AND `uid`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($ui->id('id',10, 'post'), $user_id, $reseller_id));
tsbackup('delete', $queryip, $ssh2port, $ssh2user, $publickey, $keyname, $ssh2password, $notified, $serverdir, $volocalserverid, $ui->id('id',10, 'post'), $reseller_id);
tsbackup('delete', $ssh2user, $serverdir, $masterserver, $volocalserverid, $ui->id('id',10, 'post'));
$query = $sql->prepare("SELECT CONCAT(`ip`,':',`port`) AS `address` FROM `voice_server` WHERE `id`=? AND `userid`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($sid, $user_id, $reseller_id));
@ -236,7 +240,7 @@ if ($ui->st('d', 'get') == 'bu' and $ui->id('id', 10, 'get') and (!isset($_SESSI
}
}
tsbackup('deploy', $queryip, $ssh2port, $ssh2user, $publickey, $keyname, $ssh2password, $notified, $serverdir, $volocalserverid, $ui->id('id',10, 'post'), $reseller_id, $move);
tsbackup('deploy', $ssh2user, $serverdir, $masterserver, $volocalserverid, $ui->id('id',10, 'post'), $move);
$query = $sql->prepare("SELECT CONCAT(`ip`,':',`port`) AS `address` FROM `voice_server` WHERE `id`=? AND `userid`=? AND `resellerid`=? LIMIT 1");
$query->execute(array($row['sid'], $user_id, $reseller_id));

View File

@ -410,10 +410,11 @@ if ($ui->st('d', 'get') == 'ad' and is_numeric($licenceDetails['lVo']) and $lice
$bitversion = $row['bitversion'];
}
}
tsdns('dl',$queryip,$ssh2port,$ssh2user,$publickey,$keyname,$ssh2password,$mnotified,$serverdir,$bitversion, array($ip), array($port), array($dns),$reseller_id);
$query = $sql->prepare("SELECT `id` FROM `voice_server_backup` WHERE `sid`=? AND `resellerid`=?");
$query->execute(array($id,$reseller_id));
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) tsbackup('delete',$queryip,$ssh2port,$ssh2user,$publickey,$keyname,$ssh2password,$mnotified,$serverdir,$localserverid, $row['id'],$reseller_id);
tsbackup('delete', $ssh2user, $serverdir, $masterserver, $localserverid, '*');
$query = $sql->prepare("DELETE b.* FROM `voice_server_backup` b LEFT JOIN `userdata` u ON b.`uid`=u.`id` LEFT JOIN `voice_server` v ON b.`sid`=v.`id` WHERE u.`id` IS NULL OR v.`id` IS NULL");
$query->execute();
}