* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>. */ $query = $sql->prepare("SELECT `hostID`,`resellerID` FROM `jobs` WHERE (`status` IS NULL OR `status`='1') AND `type`='my' GROUP BY `hostID`"); $query2 = $sql->prepare("SELECT `ip`,`port`,`user`,AES_DECRYPT(`password`,?) AS `decryptedpassword`,CASE WHEN `connect_ip_only`='Y' THEN `external_address` ELSE `ip` END AS `user_connect_ip` FROM `mysql_external_servers` WHERE `id`=? AND `resellerid`=? LIMIT 1"); $query3 = $sql->prepare("SELECT * FROM `jobs` WHERE (`status` IS NULL OR `status`='1') AND `type`='my' AND `hostID`=?"); $query4 = $sql->prepare("SELECT e.`uid`,e.`active`,e.`dbname`,e.`description`,AES_DECRYPT(e.`password`,?) AS `decryptedpassword`,e.`ips`,e.`max_queries_per_hour`,e.`max_updates_per_hour`,e.`max_connections_per_hour`,e.`max_userconnections_per_hour`,s.`ip`,u.`cname` FROM `mysql_external_dbs` e LEFT JOIN `mysql_external_servers` s ON e.`sid`=s.`id` LEFT JOIN `userdata` u ON e.`uid`=u.`id` WHERE e.`id`=? AND e.`resellerid`=? LIMIT 1"); $query5 = $sql->prepare("DELETE FROM `mysql_external_dbs` WHERE `id`=? LIMIT 1"); $query6 = $sql->prepare("UPDATE `jobs` SET `status`='3' WHERE `jobID`=? LIMIT 1"); $query7 = $sql->prepare("UPDATE `jobs` SET `status`='1' WHERE (`status` IS NULL OR `status`='1') AND `type`='my' AND `hostID`=?"); $query8 = $sql->prepare("UPDATE `jobs` SET `action`='dl' WHERE `hostID`=? AND `type`='my'"); $query->execute(); while ($row = $query->fetch(PDO::FETCH_ASSOC)) { unset($remotesql); $query2->execute(array($aeskey, $row['hostID'], $row['resellerID'])); while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) { $remotesql = new ExternalSQL($row2['ip'], $row2['port'], $row2['user'], $row2['decryptedpassword']); $mailData = array('mailConnectInfo' => array('ip' => $row2['user_connect_ip'], 'port' => $row2['port'])); } if (isset($remotesql) or $remotesql->error == 'ok') { $query3->execute(array($row['hostID'])); while ($row2 = $query3->fetch(PDO::FETCH_ASSOC)) { $query4->execute(array($aeskey, $row2['affectedID'], $row2['resellerID'])); while ($row4 = $query4->fetch(PDO::FETCH_ASSOC)) { $ip = $row4['ip']; $ips = $row4['ips']; $cname = $row4['cname']; $dbname = $row4['dbname']; $password = $row4['decryptedpassword']; $max_queries_per_hour = $row4['max_queries_per_hour']; $max_updates_per_hour = $row4['max_updates_per_hour']; $max_connections_per_hour = $row4['max_connections_per_hour'];
if (isset($connection)) { $connection->CloseConnection(); sleep(1); } } } } flush(); # MySQL table sizes if ($checkTypeOfServer == 'all' or $checkTypeOfServer == 'my') { $query = $sql->prepare("SELECT `id`,`ip`,`port`,`user`,AES_DECRYPT(`password`,?) AS `decryptedpassword` FROM `mysql_external_servers` WHERE `active`='Y'"); $query2 = $sql->prepare("SELECT `id` FROM `mysql_external_dbs` WHERE `sid`=? AND `dbname`=? LIMIT 1"); $query3 = $sql->prepare("UPDATE `mysql_external_dbs` SET `dbSize`=? WHERE `id`=? LIMIT 1"); $query->execute(array($aeskey)); while ($row = $query->fetch(PDO::FETCH_ASSOC)) { $remotesql = new ExternalSQL($row['ip'], $row['port'], $row['user'], $row['decryptedpassword']); if ($remotesql->error == 'ok') { $list = $remotesql->getDBSizeList(); if (is_array($list)) { foreach ($list as $db) { $query2->execute(array($row['id'], $db['dbName'])); $dbID = $query2->fetchColumn(); if (isid($dbID, 10)) { echo 'Found DB ' . $db['dbName'] . ' with size ' . $db['dbSize'] . "\r\n"; $query3->execute(array(round($db['dbSize']), $dbID)); } else { echo 'Cannot find DB ' . $db['dbName'] . ' with size ' . $db['dbSize'] . "\r\n"; } } } else { echo 'Error getting DB list for DB Server ' . $row['ip'] . ':' . $row['port'] . ': ' . $list . "\r\n";
} } } else { if (($ui->st('d', 'get') == 'ri' or $ui->st('d', 'get') == 'dl') and $id) { $query = $sql->prepare("SELECT `dbname`,`description` FROM `mysql_external_dbs` WHERE `id`=? AND `resellerid`=? LIMIT 1"); $query->execute(array($id, $resellerLockupID)); while ($row = $query->fetch(PDO::FETCH_ASSOC)) { $dbName = $row['dbname']; $description = $row['description']; } $serverFound = $query->rowCount(); if (($ui->st('action', 'post') == 'ri' or $ui->st('action', 'post') == 'dl') and count($errors) == 0 and $serverFound > 0) { $query = $sql->prepare("SELECT e.`uid`,e.`dbname`,e.`ips`,e.`max_queries_per_hour`,e.`max_connections_per_hour`,e.`max_updates_per_hour`,e.`max_userconnections_per_hour`,AES_DECRYPT(e.`password`,?) AS `decryptedpassword`,s.`ip`,AES_DECRYPT(s.`password`,?) AS `decryptedpassword2`,s.`port`,s.`user`,CASE WHEN s.`connect_ip_only`='Y' THEN s.`external_address` ELSE s.`ip` END AS `user_connect_ip` FROM `mysql_external_dbs` e INNER JOIN `mysql_external_servers` s ON e.`sid`=s.`id` WHERE e.`id`=? AND e.`resellerid`=? LIMIT 1"); $query->execute(array($aeskey, $aeskey, $id, $resellerLockupID)); while ($row = $query->fetch(PDO::FETCH_ASSOC)) { $remotesql = new ExternalSQL($row['ip'], $row['port'], $row['user'], $row['decryptedpassword2']); if ($remotesql->error == 'ok') { $remotesql->DelDB($row['dbname']); $remotesql->DelUser($row['dbname']); if ($ui->st('action', 'post') == 'ri') { $mailData = array('userId' => $row['uid'], 'name' => strlen($description) > 0 ? $description : $row['dbname'], 'mailConnectInfo' => array('ip' => $row['user_connect_ip'], 'port' => $row['port'])); $remotesql->AddDB($mailData, $row['dbname'], $row['decryptedpassword'], $row['ips'], $row['max_queries_per_hour'], $row['max_connections_per_hour'], $row['max_updates_per_hour'], $row['max_userconnections_per_hour']); $loguseraction = '%ri% MYSQL DB ' . $row['dbname'] . ' (' . $row['ip'] . ')'; $template_file = $spracheResponse->reinstall_success; } else { $query2 = $sql->prepare("DELETE FROM `mysql_external_dbs` WHERE `id`=? AND `resellerid`=? LIMIT 1"); $query2->execute(array($id, $resellerLockupID)); customColumns('D', $id, 'del'); $loguseraction = '%del% MySQL DB ' . $row['dbname'] . ' (' . $row['ip'] . ')'; $template_file = $spracheResponse->table_del; }
$template_file = $spracheResponse->reinstall_success; } else { $template_file = $remotesql->error; } } if (!isset($remotesql)) { $template_file = 'userpanel_404.tpl'; } } else { if ($ui->smallletters('action', 2, 'post') == 'md' and $ui->st('d', 'get') != 'ri') { if ($ui->password('password', 255, 'post')) { $query = $sql->prepare("SELECT e.`dbname`,e.`manage_host_table`,e.`ips`,e.`max_queries_per_hour`,e.`max_connections_per_hour`,e.`max_updates_per_hour`,e.`max_userconnections_per_hour`,s.`ip`,AES_DECRYPT(s.`password`,?) AS `decryptedpassword2`,s.`port`,s.`user`,CASE WHEN s.`connect_ip_only`='Y' THEN s.`external_address` ELSE s.`ip` END AS `address` FROM `mysql_external_dbs` e INNER JOIN `mysql_external_servers` s ON e.`sid`=s.`id` WHERE e.`id`=? AND e.`active`='Y' AND s.`active`='Y' AND e.`uid`=? AND e.`resellerid`=? LIMIT 1"); $query->execute(array($aeskey, $id, $user_id, $reseller_id)); while ($row = $query->fetch(PDO::FETCH_ASSOC)) { $ips = $row['manage_host_table'] == 'Y' ? $ui->ips('ips', 'post') : $row['ips']; $remotesql = new ExternalSQL($row['ip'], $row['port'], $row['user'], $row['decryptedpassword2']); if ($remotesql->error == 'ok') { #https://github.com/easy-wi/developer/issues/42 column description added $query2 = $sql->prepare("UPDATE `mysql_external_dbs` SET `description`=?,`password`=AES_ENCRYPT(?,?),`ips`=? WHERE `id`=? AND `uid`=? AND `resellerid`=? LIMIT 1"); $query2->execute(array(trim($ui->startparameter('description', 'post')), $ui->password('password', 255, 'post'), $aeskey, $ips, $id, $user_id, $reseller_id)); if ($query2->rowCount() > 0) { $template_file = $spracheResponse->table_add; $dbReturn = $remotesql->ModDB($row['dbname'], $ui->password('password', 255, 'post'), $ips, $row['max_queries_per_hour'], $row['max_connections_per_hour'], $row['max_updates_per_hour'], $row['max_userconnections_per_hour']); if (isset($dbConnect['debug']) and $dbConnect['debug'] == 1) { $template_file .= '<br>' . $dbReturn; } $loguseraction = '%mod% MYSQL DB ' . $row['dbname'] . ' (' . $row['address'] . ')'; $insertlog->execute(); } else { $template_file = $spracheResponse->error_table; }