Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once("xmlapi.php");
- require_once("conexao.php");
- error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_WARNING);
- ini_set('display_errors', 0);
- header('Content-Type: text/html; charset=utf-8');
- class lib {
- function __construct() {
- $this->con = new conexao();
- $this->pdo = $this->con->Connect();
- }
- function gerar_senha($tamanho, $maiusculas, $minusculas, $numeros, $simbolos){
- $ma = "ABCDEFGHIJKLMNOPQRSTUVYXWZ"; // $ma contem as letras maiusculas
- $mi = "abcdefghijklmnopqrstuvyxwz"; // $mi contem as letras minusculas
- $nu = "0123456789"; // $nu contem os numeros
- $si = "!@#$%¨&*()_+="; // $si contem os sibolos
- $senha = "";
- if ($maiusculas){
- // se $maiusculas for "true", a variavel $ma é embaralhada e adicionada para a variavel $senha
- $senha .= str_shuffle($ma);
- }
- if ($minusculas){
- // se $minusculas for "true", a variavel $mi é embaralhada e adicionada para a variavel $senha
- $senha .= str_shuffle($mi);
- }
- if ($numeros){
- // se $numeros for "true", a variavel $nu é embaralhada e adicionada para a variavel $senha
- $senha .= str_shuffle($nu);
- }
- if ($simbolos){
- // se $simbolos for "true", a variavel $si é embaralhada e adicionada para a variavel $senha
- $senha .= str_shuffle($si);
- }
- // retorna a senha embaralhada com "str_shuffle" com o tamanho definido pela variavel $tamanho
- return substr(str_shuffle($senha),0,$tamanho);
- }
- function encrypt($string) {
- global $cc_encryption_hash;
- $key = md5(md5($cc_encryption_hash)) . md5($cc_encryption_hash);
- $hash_key = $this->_hash($key);
- $hash_length = strlen($hash_key);
- $iv = $this->_generate_iv();
- $out = "";
- $c = 0;
- while ($c < $hash_length) {
- $out .= chr(ord($iv[$c]) ^ ord($hash_key[$c]));
- ++$c;
- }
- $key = $iv;
- $c = 0;
- while ($c < strlen($string)) {
- if ($c != 0 && $c % $hash_length == 0) {
- $key = _hash($key . substr($string, $c - $hash_length, $hash_length));
- }
- $out .= chr(ord($key[$c % $hash_length]) ^ ord($string[$c]));
- ++$c;
- }
- $out = base64_encode($out);
- return $out;
- }
- function _generate_iv() {
- global $cc_encryption_hash;
- srand((double)microtime() * 1000000);
- $iv = md5(strrev(substr($cc_encryption_hash, 13)) . substr($cc_encryption_hash, 0, 13));
- $iv .= rand(0, getrandmax());
- $iv .= serialize(array("key" => md5(md5($cc_encryption_hash)) . md5($cc_encryption_hash)));
- return $this->_hash($iv);
- }
- function _hash ($string){
- if (function_exists ('sha1'))
- {
- $hash = sha1 ($string);
- }
- else
- {
- $hash = md5 ($string);
- }
- $out = '';
- $c = 0;
- while ($c < strlen ($hash))
- {
- $out .= chr (hexdec ($hash[$c] . $hash[$c + 1]));
- $c += 2;
- }
- return $out;
- }
- function dadospainel_2($tabela){
- try {
- $stmt = $this->pdo->query("SELECT * FROM config");
- while ($linha = $stmt->fetch(PDO::FETCH_ASSOC)) {
- return "{$linha[$tabela]}";
- }
- } catch (PDOException $ex) {
- echo "Erro: {$ex->getMessage()}, consulte um administrador";
- }
- }
- function re_cp($pacote, $username, $password, $dominio, $email){
- $ip_cp = $this->dadospainel_2("ipwhm");
- $login_cp = $this->dadospainel_2("loginwhm");
- $senha_cp = $this->dadospainel_2("senhawhm");
- $xmlapi = new xmlapi($ip_cp);
- $xmlapi->set_port( 2086 );
- $xmlapi->password_auth($login_cp,$senha_cp);
- $xmlapi->set_debug(1);
- $acct = array( plan => "$pacote", username => "$username", password => "$password", domain => "$dominio", contactemail => "$email");
- print $xmlapi->createacct($acct);
- return true;
- }
- function enviar_ssh($comando){
- $hostname = $this->dadospainel_2("ipwhm");
- $senha_root = $this->dadospainel_2("senhawhm");
- if($ssh = ssh2_connect($hostname, "22")){
- }
- if(ssh2_auth_password ($ssh, 'root', $senha_root)){
- }
- $stream = ssh2_exec($ssh, $comando);
- stream_set_blocking ($stream, true);
- fclose($stream);
- return true;
- }
- function criadb($login, $senha, $dbnome){
- $ipcp = $this->dadospainel_2("ipwhm");
- $xmlapi = new xmlapi($ipcp);
- $xmlapi->set_port( 2082 );
- $xmlapi->password_auth($login,$senha);
- $xmlapi->set_debug(1);
- $args5 = array(
- 'db' => $dbnome,
- );
- $xmlapi->api2_query("usuario","MysqlFE","deletedb",$args5);
- $xmlapi->api1_query('usuario', 'Mysql', 'adddb', array('db'));
- }
- function extract_cms($cms, $login, $senha){
- $ipcp = $this->dadospainel_2("ipwhm");
- $xmlapi = new xmlapi($ipcp);
- $xmlapi->set_port( 2082 );
- $xmlapi->password_auth($login,$senha);
- $xmlapi->set_debug(1);
- $args1 = array(
- 'destfiles'=>'/public_html/',
- 'sourcefiles'=>'/public_html/'.$cms.'',
- 'op'=>'extract',
- 'doubledecode'=>'0',
- 'metadata'=>''
- );
- $xmlapi->api2_query("usuario","Fileman","fileop",$args1);
- $args2 = array(
- 'sourcefiles'=>'/public_html/'.$cms.'',
- 'op'=>'unlink',
- 'doubledecode'=>'0',
- 'metadata'=>''
- );
- $xmlapi->api2_query("usuario","Fileman","fileop",$args2);
- }
- function re_db($login, $senha, $dbnome){
- $ipcp = $this->dadospainel_2("ipwhm");
- $senha_root = $this->dadospainel_2("senhawhm");
- $this->criadb($login, $senha, $dbnome);
- $this->enviar_ssh('cd /home/sql; mysql -h localhost -u '.$login.' -p'.$senha.' -D '.$dbnome.' < plus.sql');
- return true;
- }
- function re_emu($ip_cp, $ip_emu, $login, $senha, $dbnome, $tcp, $mus){
- function removeTree($rootDir){
- if (!is_dir($rootDir))
- {
- return false;
- }
- if (!preg_match("/\\/$/", $rootDir))
- {
- $rootDir .= '/';
- }
- }
- $dir = 'C:/wamp/www/servidores/'.$login.'';
- removeTree($dir);
- $pastad = "C:/wamp/www/servidores/$login";//Criar pasta do emulador
- if(!is_dir($pastad)){//verifica se existe a pasta de destino
- mkdir($pastad,0777);//cria a pasta
- chmod($pastad,0777);//muda a perma
- }
- $dir = 'C:/VertrigoServ/www/'.$login.'';
- removeTree($dir);
- $pastad = "C:/VertrigoServ/www/$login";//Criar pasta do emulador
- if(!is_dir($pastad)){//verifica se existe a pasta de destino
- mkdir($pastad,0777);//cria a pasta
- chmod($pastad,0777);//muda a perma
- }
- $zip = new ZipArchive;
- $res = $zip->open('C:/wamp/www/servidores/dlsak/plus.zip');
- if ($res === TRUE) {
- $zip->extractTo('C:/wamp/www/servidores/'.$login.'/');
- $zip->close();
- }
- $zip = new ZipArchive;
- $res = $zip->open('C:/VertrigoServ/www/zak.zip');
- if ($res === TRUE) {
- $zip->extractTo('C:/VertrigoServ/www/'.$login.'/');
- $zip->close();
- }
- // Configura o arquivo configuration.ini
- $nomearquivo = "C:/wamp/www/servidores/$login/config.ini";
- $conteudo = "## uberEmulator System Configuration File
- ## Must be edited for the server to work
- ## MySQL Configuration
- db.hostname=$ip_cp
- db.port=3306
- db.username=$login
- db.password=$senha
- db.name=$dbnome
- ## MySQL pooling setup (controls amount of connections)
- db.pool.minsize=10
- db.pool.maxsize=250
- ## Game TCP/IP Configuration
- game.tcp.bindip=$ip_emu
- game.tcp.port=$tcp
- game.tcp.conlimit=100000
- game.tcp.conperip=2
- game.tcp.enablenagles=true
- ## MUS TCP/IP Configuration
- mus.tcp.bindip=$ip_emu
- mus.tcp.port=$mus
- mus.tcp.allowedaddr=$ip_emu;localhost;$ip_emu
- # Camera configuration
- camera.path.preview=
- camera.path.purchased=
- camera.preview.maxcache=1000
- ## Client configuration
- client.ping.enabled=1
- client.ping.interval=20000
- client.maxrequests=300
- ";
- $fp = fopen("$nomearquivo", "w");
- $escreve = fwrite($fp, "$conteudo");
- fclose($fp);
- $fp = fopen("C:/wamp/www/servidores/$login/allandesign.ini", "w");
- $escreve = fwrite($fp, "[AllanDesign]
- Emulador=$login.Emulator.exe");
- fclose($fp);
- $cd = "CD C:/wamp/www/servidores/".$login;
- $fp = fopen("C:/VertrigoServ/www/$login/desligar.bat", "w");
- $string = ''.$cd.''.PHP_EOL;
- $string .= 'TASKKILL /IM '.$login.'.Emulator.exe -f'.PHP_EOL;
- $escreve = fwrite($fp,$string);
- fclose($fp);
- $ligapainelemulador = $login."painel";
- $fp = fopen("C:/VertrigoServ/www/$login/ligar.bat", "w");
- $string = ''.$cd.''.PHP_EOL;
- $string .= 'start '.$ligapainelemulador.'.exe'.PHP_EOL;
- $escreve = fwrite($fp, $string);
- fclose($fp);
- rename ("C:/wamp/www/servidores/$login/Paineldoemulador.exe", "C:/wamp/www/servidores/$login/$ligapainelemulador.exe");
- rename ("C:/wamp/www/servidores/$login/Plus Emulator.exe", "C:/wamp/www/servidores/$login/$login.Emulator.exe");
- rename ("C:/wamp/www/servidores/$login/Plus Emulator.exe.config", "C:/wamp/www/servidores/$login/$login.Emulator.exe.config");
- rename ("C:/wamp/www/servidores/$login/Plus Emulator.vshost.exe", "C:/wamp/www/servidores/$login/$login.Emulator.vshost.exe");
- rename ("C:/wamp/www/servidores/$login/Plus Emulator.pdb", "C:/wamp/www/servidores/$login/$login.Emulator.pdb");
- rename ("C:/wamp/www/servidores/$login/Plus Emulator.vshost.exe.config", "C:/wamp/www/servidores/$login/$login.Emulator.vshost.exe.config");
- rename ("C:/wamp/www/servidores/$login/Plus Emulator.vshost.exe.manifest", "C:/wamp/www/servidores/$login/$login.Emulator.vshost.exe.manifest");
- }
- function liberar(){
- $date = date('Y-m-d H:i');
- echo 'Atualizado pela ultima vez em '.$date.'';
- if(!defined("MYSQL_HOST")){
- define('MYSQL_HOST', '149.56.69.7');
- }
- if(!defined("MYSQL_USER")){
- define('MYSQL_USER', 'meuhp');
- }
- if(!defined("MYSQL_PASSWORD")){
- define('MYSQL_PASSWORD', 'md68IaB1hp9c');
- }
- if(!defined("MYSQL_DB_NAME")){
- define('MYSQL_DB_NAME', 'meuhp_whmcs');
- }
- $username = $this->gerar_senha(8, false, true, false, false);
- $password = $this->gerar_senha(10, true, true, true, false);
- $dbnome = $username."_db";
- $ip_cp = $this->dadospainel_2("ipwhm");
- $ip_emu = $this->dadospainel_2("ipemu");
- $cc_encryption_hash='CVXf9P4oqyi1ilqITVNQoARkOauJOO9gzWmzChNSGWKO80nSM0z0qgb4hwEWaE2A';
- $password_encripted = $this->encrypt ($password, $cc_encryption_hash);
- $remote = new PDO('mysql:host=' . MYSQL_HOST . ';dbname=' . MYSQL_DB_NAME, MYSQL_USER, MYSQL_PASSWORD);
- $remote->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $remote->exec("SET CHARACTER SET utf8");
- $consulta = $remote->query("SELECT * FROM tblhosting WHERE sfp='ativar'");
- while ($ativar = $consulta->fetch(PDO::FETCH_ASSOC)){
- $dominio = "{$ativar['domain']}";
- $pacote = "{$ativar['packageid']}";
- $consulta_2 = $remote->query("SELECT * FROM tblinvoices WHERE id={$ativar['orderid']} and status='Paid'");
- while ($pago = $consulta_2->fetch(PDO::FETCH_ASSOC)){
- $remote->query("UPDATE tblhosting SET sfp='ativo' WHERE userid={$pago['userid']} and orderid='{$pago['id']}'");
- $remote->query("UPDATE tblhosting SET domainstatus='Active' WHERE userid={$pago['userid']} and orderid='{$pago['id']}'");
- $remote->query("UPDATE tblhosting SET username='$username' WHERE userid={$pago['userid']} and orderid='{$pago['id']}'");
- $remote->query("UPDATE tblhosting SET password='$password_encripted' WHERE userid={$pago['userid']} and orderid='{$pago['id']}'");
- $remote->query("UPDATE tblorders SET status='Active' WHERE userid={$pago['userid']} and invoiceid='{$pago['id']}'");
- $consulta_3 = $remote->query("SELECT * FROM tblclients WHERE id={$pago['userid']}");
- while ($dados = $consulta_3->fetch(PDO::FETCH_ASSOC)){
- $email = "{$dados['email']}";
- $consulta_4 = $stmt = $this->pdo->query("SELECT * FROM servidores ORDER BY `id` DESC LIMIT 1");
- while ($porta = $consulta_4->fetch(PDO::FETCH_ASSOC)){
- $tcp_h = $porta['tcp'];
- $mus_h = $porta['mus'];
- }
- $soma = "1";
- $tcp_h = $mus_h+$soma;
- $mus_h = $tcp_h+$soma;
- if($tcp_h == "1"){
- $tcp_h = "500";
- $mus_h = "501";
- }
- //Criar cPanel
- $this->re_cp($pacote, $username, $password, $dominio, $email);
- //Enviar CMS
- $this->enviar_ssh('cp /fpanel/heluar.zip /home/'.$username.'/public_html');
- //Extrair CMS
- $this->extract_cms("heluar.zip", $username, $password);
- //Reinstalar DB
- $this->re_db($username, $password, $dbnome);
- //Criar pasta temporaria
- $pastad = "./temp/$username";
- if(!is_dir($pastad)){
- mkdir($pastad,0777);
- chmod($pastad,0777);
- }
- //Enviar arquivo config da cms
- $nomearquivo = "./temp/$username/config.php";
- $fp = fopen("$nomearquivo", "w");
- $string = '<?php'.PHP_EOL;
- $string .= 'error_reporting(0);'.PHP_EOL;
- $string .= 'if(!defined("IN_INDEX")) { die("Sorry, you cannot access this file."); }'.PHP_EOL;
- $string .= 'date_default_timezone_set("America/Sao_Paulo");'.PHP_EOL;
- $string .= '$_CONFIG["mysql"]["connection_type"] = "pconnect";'.PHP_EOL;
- $string .= '$_CONFIG["mysql"]["hostname"] = "localhost";'.PHP_EOL;
- $string .= '$_CONFIG["mysql"]["username"] = "'.$username.'";'.PHP_EOL;
- $string .= '$_CONFIG["mysql"]["password"] = "'.$password.'";'.PHP_EOL;
- $string .= '$_CONFIG["mysql"]["database"] = "'.$dbnome.'";'.PHP_EOL;
- $string .= '$_CONFIG["mysql"]["port"] = "3306"; //MySQL"s port'.PHP_EOL;
- $string .= '$_CONFIG["hotel"]["server_ip"] = "'.$tcp_h.'";'.PHP_EOL;
- $string .= '$_CONFIG["hotel"]["url"] = "http://'.$dominio.'";'.PHP_EOL;
- $string .= '$_CONFIG["hotel"]["name"] = "Habbo";'.PHP_EOL;
- $string .= '$_CONFIG["hotel"]["desc"] = "Crie seu Quarto, Converse e faça novos amigos!";'.PHP_EOL;
- $string .= '$_CONFIG["hotel"]["email"] = "help@myhotel.net";'.PHP_EOL;
- $string .= '$_CONFIG["hotel"]["in_maint"] = false; // manutenção? se sim, coloque true, se não deixe false'.PHP_EOL;
- $string .= '$_CONFIG["hotel"]["motto"] = "I <3 " . $_CONFIG["hotel"]["name"];'.PHP_EOL;
- $string .= '$_CONFIG["hotel"]["credits"] = 5000; //moedas iniciais'.PHP_EOL;
- $string .= '$_CONFIG["hotel"]["pixels"] = 3500; //duckets/pixels iniciais'.PHP_EOL;
- $string .= '$_CONFIG["hotel"]["figure"] = "hd-180-7.wa-2007-0.sh-305-62.ha-1002-70.lg-270-79.ch-215-66.hr-100-0";'.PHP_EOL;
- $string .= '$_CONFIG["hotel"]["web_build"] = "9901";'.PHP_EOL;
- $string .= '$_CONFIG["hotel"]["external_vars"] = "a";'.PHP_EOL;
- $string .= '$_CONFIG["hotel"]["external_texts"] = "a";'.PHP_EOL;
- $string .= '$_CONFIG["hotel"]["product_data"] = "a";'.PHP_EOL;
- $string .= '$_CONFIG["hotel"]["furni_data"] = "a"; '.PHP_EOL;
- $string .= '$_CONFIG["hotel"]["swf_folder"] = "a";'.PHP_EOL;
- $string .= '$_CONFIG["template"]["style"] = "Habbo";'.PHP_EOL;
- $string .= '$_CONFIG["template"]["theme"] = "Habbo";'.PHP_EOL;
- $string .= '$_CONFIG["thehabbos"]["username"] = "Kryptos";'.PHP_EOL;
- $string .= '$_CONFIG["retro_top"]["user"] = "Kryptos";'.PHP_EOL;
- $string .= '$_CONFIG["recaptcha"]["priv_key"] = "6LcZ58USAAAAABSV5px9XZlzvIPaBOGA6rQP2G43";'.PHP_EOL;
- $string .= '$_CONFIG["recaptcha"]["pub_key"] = "6LcZ58USAAAAAAQ6kquItHl4JuTBWs-5cSKzh6DD";'.PHP_EOL;
- $string .= '$_CONFIG["social"]["twitter"] = "TwitterAccount"; //Hotel"s Twitter account'.PHP_EOL;
- $string .= '$_CONFIG["social"]["facebook"] = "FacebookAccount"; //Hotel"s Facebook account'.PHP_EOL;
- $string .= 'foreach($_REQUEST as $key => $value){'.PHP_EOL;
- $string .= '$_REQUEST[$key] = htmlspecialchars($value, ENT_QUOTES);'.PHP_EOL;
- $string .= '}'.PHP_EOL;
- $string .= '?>'.PHP_EOL;
- $escreve = fwrite($fp,$string);
- fclose($fp);
- //Enviar config da cms
- $file = 'temp/'.$username.'/config.php';//tobe uploaded
- $remote_file = '/public_html/app/management/config.php';
- // set up basic connection
- $conn_id = ftp_connect($ip_cp);
- // login with username and password
- $login_result = ftp_login($conn_id, $username, $password);
- // upload a file
- if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII));
- // close the connection
- ftp_close($conn_id);
- //Reinstalar emulador
- $this->re_emu($ip_cp, $ip_emu, $username, $password, $dbnome, $tcp_h, $mus_h);
- $e = $this->pdo->query("INSERT INTO servidores (loginp, senhap, loginc, senhac, tituloh, versao, email, hostname, dbporta, dbnome, tcp, mus, siteurl, status, suspenso, ligado, pacote, dono, subconta) VALUES
- ('$username', '$password', '$username', '$password', 'Habbo', 'Plus', '$email', '$ip_cp', '3306', '$dbnome', '$tcp_h', '$mus_h', '$dominio', '0', '0', '', '$pacote', 'admin', '0')");
- $emulador = $e->fetch(PDO::FETCH_ASSOC);
- $c = $this->pdo->query("INSERT INTO comandos (subconta, config, reinstalar, painel, backup, emulador, dono) VALUES
- ('1', '1', '1', '1', '1', '1', '$username')");
- $comandos = $c->fetch(PDO::FETCH_ASSOC);
- $dir = './temp/'.$username.'';
- removeTree($dir);
- }
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement