Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once("../classes/conexao.php");
- error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_WARNING);
- //ini_set('display_errors', 0);
- 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 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->password_auth($login_cp,$senha_cp);
- $xmlapi->set_port( 2087 );
- $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){
- set_time_limit(7200);
- $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 removeTree($rootDir)
- {
- if (!is_dir($rootDir))
- {
- return false;
- }
- if (!preg_match("/\\/$/", $rootDir))
- {
- $rootDir .= '/';
- }
- $stack = array($rootDir);
- while (count($stack) > 0)
- {
- $hasDir = false;
- $dir = end($stack);
- $dh = opendir($dir);
- while (($file = readdir($dh)) !== false)
- {
- if ($file == '.' || $file == '..')
- {
- continue;
- }
- if (is_dir($dir . $file))
- {
- $hasDir = true;
- array_push($stack, $dir . $file . '/');
- }
- else if (is_file($dir . $file))
- {
- unlink($dir . $file);
- }
- }
- closedir($dh);
- if ($hasDir == false)
- {
- array_pop($stack);
- rmdir($dir);
- }
- }
- return true;
- }
- function re_emu($ip_cp, $ip_emu, $login, $senha, $dbnome, $tcp, $mus){
- $dir = '../servidores/'.$login.'';
- $this->removeTree($dir);
- $pastad = "../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
- }
- $zip = new ZipArchive;
- $res = $zip->open('../servidores/dlsaker/plus.zip');
- if ($res === TRUE) {
- $zip->extractTo('../servidores/'.$login.'/');
- $zip->close();
- }
- // Configura o arquivo configuration.ini
- $nomearquivo = "../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=100
- game.tcp.conperip=10
- game.tcp.enablenagles=true
- game.tcp.proxyip=$ip_emu
- ## MUS TCP/IP Configuration
- mus.tcp.bindip=$ip_emu
- mus.tcp.port=$mus
- mus.tcp.allowedaddr=$ip_emu;localhost;$ip_emu
- ## Client configuration
- client.ping.enabled=1
- client.ping.interval=20000
- client.maxrequests=300
- # System License
- hotel.name=Habbi
- ";
- $fp = fopen("$nomearquivo", "w");
- $escreve = fwrite($fp, "$conteudo");
- fclose($fp);
- $fp = fopen("../servidores/$login/allandesign.ini", "w");
- $escreve = fwrite($fp, "[AllanDesign]
- Emulador=$login.Emulator.exe");
- fclose($fp);
- $fp = fopen("../servidores/$login/stop.bat", "w");
- $string = 'TASKKILL /IM '.$login.'.Emulator.exe -f';
- $escreve = fwrite($fp,$string);
- fclose($fp);
- $ligapainelemulador = $login."painel";
- $fp = fopen("../servidores/$login/start.bat", "w");
- $string = 'start '.$ligapainelemulador.'.exe';
- $escreve = fwrite($fp, $string);
- fclose($fp);
- rename ("../servidores/$login/Paineldoemulador.exe", "../servidores/$login/$ligapainelemulador.exe");
- rename ("../servidores/$login/Plus Emulator.exe", "../servidores/$login/$login.Emulator.exe");
- rename ("../servidores/$login/Plus Emulator.exe.config", "../servidores/$login/$login.Emulator.exe.config");
- rename ("../servidores/$login/Plus Emulator.vshost.exe", "../servidores/$login/$login.Emulator.vshost.exe");
- rename ("../servidores/$login/Plus Emulator.pdb", "../servidores/$login/$login.Emulator.pdb");
- rename ("../servidores/$login/Plus Emulator.vshost.exe.config", "../servidores/$login/$login.Emulator.vshost.exe.config");
- }
- function liberar($dominio, $pacote, $email, $donorev){
- $verificar = $this->pdo->query("SELECT * FROM servidores WHERE siteurl='$dominio'");
- $contagem = $verificar->fetchColumn();
- if($contagem >=1){ return false; }
- $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");
- $consulta_4 = $stmt = $this->pdo->query("SELECT * FROM servidores WHERE subconta='0' 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/default.zip /home/'.$username.'/public_html');
- //Extrair CMS
- $this->extract_cms("default.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 .= 'if(!defined("BRAIN_CMS")) '.PHP_EOL;
- $string .= '{ '.PHP_EOL;
- $string .= 'die("Sorry but you cannot access this file!"); '.PHP_EOL;
- $string .= '}'.PHP_EOL;
- $string .= '$db["host"] = "localhost"; //Mysql"s Host'.PHP_EOL;
- $string .= '$db["port"] = "3306"; //Mysql"s port'.PHP_EOL;
- $string .= '$db["user"] = "'.$username.'"; //Mysql"s user'.PHP_EOL;
- $string .= '$db["pass"] = "'.$password.'"; //Mysql"s password'.PHP_EOL;
- $string .= '$db["db"] = "'.$dbnome.'"; //Mysql"s database'.PHP_EOL;
- $string .= '$config["hotelEmu"] = "plusemu"; // plusemu // arcturus'.PHP_EOL;
- $string .= '$hotel["emuHost"] = "'.$ip_emu.'";'.PHP_EOL;
- $string .= '$hotel["emuPort"] = "'.$tcp_h.'";'.PHP_EOL;
- $string .= '$hotel["staffCheckClient"] = false;'.PHP_EOL;
- $string .= '$hotel["staffCheckClientMinimumRank"] = 3;'.PHP_EOL;
- $string .= '$hotel["homeRoom"] = "0";'.PHP_EOL;
- $string .= '$hotel["swf_url"] = "http://swf.meuhotel.in/swf";'.PHP_EOL;
- $string .= '$hotel["external_Variables"] = $hotel["swf_url"]."/gamedata//ISecuritinet.txt";'.PHP_EOL;
- $string .= '$hotel["external_Variables_Override"] = $hotel["swf_url"]."/gamedata/override//FANEW.txt";'.PHP_EOL;
- $string .= '$hotel["external_Texts"] = $hotel["swf_url"]."/gamedata/external_flash_4.txt";'.PHP_EOL;
- $string .= '$hotel["external_Texts_Override"] = $hotel["swf_url"]."/gamedata/override//external_flash_override_texts.txt";'.PHP_EOL;
- $string .= '$hotel["productdata"] = $hotel["swf_url"]."/gamedata/productdata.txt";'.PHP_EOL;
- $string .= '$hotel["furnidata"] = $hotel["swf_url"]."/gamedata/furnidata.xml";'.PHP_EOL;
- $string .= '$hotel["figuremap"] = $hotel["swf_url"]."/gamedata/figuremap.xml";'.PHP_EOL;
- $string .= '$hotel["figuredata"] = $hotel["swf_url"]."/gamedata/figuredata.xml";'.PHP_EOL;
- $string .= '$hotel["swfFolder"] = $hotel["swf_url"]."/gordon/prod";'.PHP_EOL;
- $string .= '$hotel["swfFolderSwf"] = $hotel["swf_url"]."/gordon/prod/Hotel.swf";'.PHP_EOL;
- $string .= '$hotel["avatareditor.promohabbos"] = $hotel["swf_url"]."/gamedata/hotlooks.xml";'.PHP_EOL;
- $string .= '$hotel["diamonds.enabled"] = true;'.PHP_EOL;
- $string .= '$hotel["builders.club.enabled"] = false;'.PHP_EOL;
- $string .= '$config["hotelUrl"] = "http://'.$dominio.'";//Address of your hotel. Does not end with a "/"'.PHP_EOL;
- $string .= '$config["skin"] = "brain"; //Skin/template of your website'.PHP_EOL;
- $string .= '$config["lang"] = "pt-br"; //Language of your website en/nl/es'.PHP_EOL;
- $string .= '$config["hotelName"] = "Habbo"; //Name of your hotel'.PHP_EOL;
- $string .= '$config["favicon"] = "http://'.$dominio.'/templates/brain/style/images/favicon/favicon.ico";'.PHP_EOL;
- $string .= '$config["staffCheckHk"] = false; //Enable the staff pin in the housekeeping (true) or disable it (false)'.PHP_EOL;
- $string .= '$config["staffCheckHkMinimumRank"] = 3; //Minium staff rank to get the staff pin in the housekeeping'.PHP_EOL;
- $string .= '$config["maintenance"] = false; //Enable the maintenance of your website (true) or disable it (false)'.PHP_EOL;
- $string .= '$config["maintenancekMinimumRankLogin"] = 3; //Minium staff rank to login when the website is in maintenance'.PHP_EOL;
- $string .= '$config["groupBadgeURL"] = "http://swf.meuhotel.in/swf/habbo-imaging/badge.php?badge=";'.PHP_EOL;
- $string .= '$config["badgeURL"] = "http://swf.meuhotel.in/swf/c_images/album1584/"; '.PHP_EOL;
- $string .= '$config["userLikeEnable"] = true; // Enable user likes '.PHP_EOL;
- $string .= '$config["newsCommandEnable"] = true; //Enable news commands'.PHP_EOL;
- $string .= '$config["newsCommandFilter"] = true; //Enable wordfilter on news commands (the filter use the db tabels wordfilter and wordfilter_characters)'.PHP_EOL;
- $string .= '$config["alertReferrer"] = true;'.PHP_EOL;
- $string .= '$config["alert"] = "BrainCMS Beta"; //Alert message. If you don"t want a alert, you fill in "nomessage" or you do leave it blank.'.PHP_EOL;
- $string .= '$config["brainversion"] = "1.8.1"; // Please do not change.'.PHP_EOL;
- $string .= '$config["facebookLogin"] = false; //Enable the Facebook login (true) or disable it (false)'.PHP_EOL;
- $string .= '$config["facebookAPPID"] = "334162590sdaf292528";'.PHP_EOL;
- $string .= '$config["facebookAPPSecret"] = "ce2504ff5adsfa3ff7a6a2fa6d984cd8836";'.PHP_EOL;
- $string .= '$email["mailServerHost"] = "smtp.gmail.com";'.PHP_EOL;
- $string .= '$email["mailServerPort"] = 587;'.PHP_EOL;
- $string .= '$email["SMTPSecure"] = "TLS";'.PHP_EOL;
- $string .= '$email["mailUsername"] = "gmail@gmail.com";'.PHP_EOL;
- $string .= '$email["mailPassword"] = "*****";'.PHP_EOL;
- $string .= '$email["mailLogo"] = "http://127.0.0.1/templates/brain/style/images/logo/logo.png";'.PHP_EOL;
- $string .= '$email["mailTemplate"] = "/system/app/plugins/PHPmailer/temp/resetpassword.html";'.PHP_EOL;
- $string .= '$config["facebook"] = "https://www.facebook.com/Habbo/";'.PHP_EOL;
- $string .= '$config["facebookEnable"] = false;'.PHP_EOL;
- $string .= '$config["twitter"] = "https://twitter.com/Habbo";'.PHP_EOL;
- $string .= '$config["twitterEnable"] = false;'.PHP_EOL;
- $string .= '$config["startMotto"] = "Bem-vindo ao habbo!"; //Regsiter start motto'.PHP_EOL;
- $string .= '$config["credits"] = "10000";'.PHP_EOL;
- $string .= '$config["duckets"] = "20000";'.PHP_EOL;
- $string .= '$config["diamonds"] = "10";'.PHP_EOL;
- $string .= '$config["diamondsRef"] = "10";'.PHP_EOL;
- $string .= '$config["registerEnable"] = true;'.PHP_EOL;
- $string .= '$config["recaptchaSiteKey"] = "6LdzewwUAAAAABkJ3vsdfCDca9qmLGDaWAHqMRtFEs2";'.PHP_EOL;
- $string .= '$config["recaptchaSiteKeyEnable"] = false;'.PHP_EOL;
- $string .= '$config["vipCost"] = "25";'.PHP_EOL;
- $string .= '$config["vipRankToGet"] = "3";'.PHP_EOL;
- $string .= '$config["vipBadge"] = "vip";'.PHP_EOL;
- $string .= 'switch($config["hotelEmu"])'.PHP_EOL;
- $string .= '{'.PHP_EOL;
- $string .= ' case "arcturus":'.PHP_EOL;
- $string .= ' $emuUse["user_wardrobe"] = "users_wardrobe ";'.PHP_EOL;
- $string .= ' $emuUse["ip_last"] = "ip_current";'.PHP_EOL;
- $string .= ' $emuUse["respect"] = "respects_received";'.PHP_EOL;
- $string .= ' $emuUse["user_stats"] = "users_settings";'.PHP_EOL;
- $string .= ' $emuUse["user_stats_user_id"] = "user_id";'.PHP_EOL;
- $string .= ' $emuUse["OnlineTime"] = "online_time";'.PHP_EOL;
- $string .= ' break;'.PHP_EOL;
- $string .= ' case "plusemu":'.PHP_EOL;
- $string .= ' $emuUse["user_wardrobe"] = "user_wardrobe ";'.PHP_EOL;
- $string .= ' $emuUse["ip_last"] = "ip_last";'.PHP_EOL;
- $string .= ' $emuUse["respect"] = "Respect";'.PHP_EOL;
- $string .= ' $emuUse["user_stats"] = "user_stats";'.PHP_EOL;
- $string .= ' $emuUse["user_stats_user_id"] = "id";'.PHP_EOL;
- $string .= ' $emuUse["OnlineTime"] = "OnlineTime";'.PHP_EOL;
- $string .= ' break;'.PHP_EOL;
- $string .= ' default:'.PHP_EOL;
- $string .= ' break;'.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/system/brain-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);
- ftp_pasv($conn_id, true);
- // 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', '$donorev', '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);
- $this->removeTree("./temp/$username");
- return true;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement