Advertisement
Guest User

Untitled

a guest
Aug 13th, 2018
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.59 KB | None | 0 0
  1. <?php
  2. require_once("../classes/conexao.php");
  3.  
  4. error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_WARNING);
  5. //ini_set('display_errors', 0);
  6.  
  7. class lib {
  8. function __construct() {
  9. $this->con = new conexao();
  10. $this->pdo = $this->con->Connect();
  11. }
  12. function gerar_senha($tamanho, $maiusculas, $minusculas, $numeros, $simbolos){
  13. $ma = "ABCDEFGHIJKLMNOPQRSTUVYXWZ"; // $ma contem as letras maiusculas
  14. $mi = "abcdefghijklmnopqrstuvyxwz"; // $mi contem as letras minusculas
  15. $nu = "0123456789"; // $nu contem os numeros
  16. $si = "!@#$%¨&*()_+="; // $si contem os sibolos
  17. $senha = "";
  18.  
  19. if ($maiusculas){
  20. // se $maiusculas for "true", a variavel $ma é embaralhada e adicionada para a variavel $senha
  21. $senha .= str_shuffle($ma);
  22. }
  23.  
  24. if ($minusculas){
  25. // se $minusculas for "true", a variavel $mi é embaralhada e adicionada para a variavel $senha
  26. $senha .= str_shuffle($mi);
  27. }
  28.  
  29. if ($numeros){
  30. // se $numeros for "true", a variavel $nu é embaralhada e adicionada para a variavel $senha
  31. $senha .= str_shuffle($nu);
  32. }
  33.  
  34. if ($simbolos){
  35. // se $simbolos for "true", a variavel $si é embaralhada e adicionada para a variavel $senha
  36. $senha .= str_shuffle($si);
  37. }
  38.  
  39. // retorna a senha embaralhada com "str_shuffle" com o tamanho definido pela variavel $tamanho
  40. return substr(str_shuffle($senha),0,$tamanho);
  41. }
  42. function dadospainel_2($tabela){
  43. try {
  44. $stmt = $this->pdo->query("SELECT * FROM config");
  45. while ($linha = $stmt->fetch(PDO::FETCH_ASSOC)) {
  46. return "{$linha[$tabela]}";
  47. }
  48.  
  49. } catch (PDOException $ex) {
  50. echo "Erro: {$ex->getMessage()}, consulte um administrador";
  51. }
  52. }
  53.  
  54. function re_cp($pacote, $username, $password, $dominio, $email){
  55.  
  56. $ip_cp = $this->dadospainel_2("ipwhm");
  57. $login_cp = $this->dadospainel_2("loginwhm");
  58. $senha_cp = $this->dadospainel_2("senhawhm");
  59.  
  60. $xmlapi = new xmlapi($ip_cp);
  61. $xmlapi->password_auth($login_cp,$senha_cp);
  62. $xmlapi->set_port( 2087 );
  63. $xmlapi->set_debug(1);
  64.  
  65. $acct = array(plan => "$pacote", username => "$username", password => "$password", domain => "$dominio", contactemail => "$email");
  66. print $xmlapi->createacct($acct);
  67.  
  68. return true;
  69. }
  70. function enviar_ssh($comando){
  71. $hostname = $this->dadospainel_2("ipwhm");
  72. $senha_root = $this->dadospainel_2("senhawhm");
  73. if($ssh = ssh2_connect($hostname, "22")){
  74. }
  75. if(ssh2_auth_password ($ssh, 'root', $senha_root)){
  76. }
  77. $stream = ssh2_exec($ssh, $comando);
  78. stream_set_blocking ($stream, true);
  79. fclose($stream);
  80. return true;
  81. }
  82. function criadb($login, $senha, $dbnome){
  83. $ipcp = $this->dadospainel_2("ipwhm");
  84.  
  85. $xmlapi = new xmlapi($ipcp);
  86. $xmlapi->set_port( 2082 );
  87. $xmlapi->password_auth($login,$senha);
  88. $xmlapi->set_debug(1);
  89.  
  90.  
  91. $args5 = array(
  92. 'db' => $dbnome,
  93. );
  94.  
  95. $xmlapi->api2_query("usuario","MysqlFE","deletedb",$args5);
  96.  
  97.  
  98.  
  99.  
  100. $xmlapi->api1_query('usuario', 'Mysql', 'adddb', array('db'));
  101. }
  102. function extract_cms($cms, $login, $senha){
  103. $ipcp = $this->dadospainel_2("ipwhm");
  104.  
  105. $xmlapi = new xmlapi($ipcp);
  106. $xmlapi->set_port( 2082 );
  107. $xmlapi->password_auth($login,$senha);
  108. $xmlapi->set_debug(1);
  109.  
  110.  
  111.  
  112. $args1 = array(
  113. 'destfiles'=>'/public_html/',
  114. 'sourcefiles'=>'/public_html/'.$cms.'',
  115. 'op'=>'extract',
  116. 'doubledecode'=>'0',
  117. 'metadata'=>''
  118. );
  119.  
  120. $xmlapi->api2_query("usuario","Fileman","fileop",$args1);
  121.  
  122. $args2 = array(
  123. 'sourcefiles'=>'/public_html/'.$cms.'',
  124. 'op'=>'unlink',
  125. 'doubledecode'=>'0',
  126. 'metadata'=>''
  127. );
  128.  
  129. $xmlapi->api2_query("usuario","Fileman","fileop",$args2);
  130. }
  131. function re_db($login, $senha, $dbnome){
  132. set_time_limit(7200);
  133. $ipcp = $this->dadospainel_2("ipwhm");
  134.  
  135. $senha_root = $this->dadospainel_2("senhawhm");
  136. $this->criadb($login, $senha, $dbnome);
  137. $this->enviar_ssh('cd /home/sql; mysql -h localhost -u '.$login.' -p'.$senha.' -D '.$dbnome.' < Plus.sql');
  138. return true;
  139. }
  140. function removeTree($rootDir)
  141. {
  142. if (!is_dir($rootDir))
  143. {
  144. return false;
  145. }
  146.  
  147. if (!preg_match("/\\/$/", $rootDir))
  148. {
  149. $rootDir .= '/';
  150. }
  151.  
  152.  
  153. $stack = array($rootDir);
  154.  
  155. while (count($stack) > 0)
  156. {
  157. $hasDir = false;
  158. $dir = end($stack);
  159. $dh = opendir($dir);
  160.  
  161. while (($file = readdir($dh)) !== false)
  162. {
  163. if ($file == '.' || $file == '..')
  164. {
  165. continue;
  166. }
  167.  
  168. if (is_dir($dir . $file))
  169. {
  170. $hasDir = true;
  171. array_push($stack, $dir . $file . '/');
  172. }
  173.  
  174. else if (is_file($dir . $file))
  175. {
  176. unlink($dir . $file);
  177. }
  178. }
  179.  
  180. closedir($dh);
  181.  
  182. if ($hasDir == false)
  183. {
  184. array_pop($stack);
  185. rmdir($dir);
  186. }
  187. }
  188.  
  189. return true;
  190. }
  191. function re_emu($ip_cp, $ip_emu, $login, $senha, $dbnome, $tcp, $mus){
  192. $dir = '../servidores/'.$login.'';
  193. $this->removeTree($dir);
  194.  
  195. $pastad = "../servidores/$login";//Criar pasta do emulador
  196. if(!is_dir($pastad)){//verifica se existe a pasta de destino
  197. mkdir($pastad,0777);//cria a pasta
  198. chmod($pastad,0777);//muda a perma
  199. }
  200.  
  201. $zip = new ZipArchive;
  202. $res = $zip->open('../servidores/dlsaker/plus.zip');
  203. if ($res === TRUE) {
  204. $zip->extractTo('../servidores/'.$login.'/');
  205. $zip->close();
  206. }
  207.  
  208. // Configura o arquivo configuration.ini
  209. $nomearquivo = "../servidores/$login/config.ini";
  210. $conteudo = "## uberEmulator System Configuration File
  211. ## Must be edited for the server to work
  212.  
  213. ## MySQL Configuration
  214. db.hostname=$ip_cp
  215. db.port=3306
  216. db.username=$login
  217. db.password=$senha
  218. db.name=$dbnome
  219.  
  220. ## MySQL pooling setup (controls amount of connections)
  221. db.pool.minsize=10
  222. db.pool.maxsize=250
  223.  
  224. ## Game TCP/IP Configuration
  225. game.tcp.bindip=$ip_emu
  226. game.tcp.port=$tcp
  227. game.tcp.conlimit=100
  228. game.tcp.conperip=10
  229. game.tcp.enablenagles=true
  230. game.tcp.proxyip=$ip_emu
  231.  
  232. ## MUS TCP/IP Configuration
  233. mus.tcp.bindip=$ip_emu
  234. mus.tcp.port=$mus
  235. mus.tcp.allowedaddr=$ip_emu;localhost;$ip_emu
  236.  
  237. ## Client configuration
  238. client.ping.enabled=1
  239. client.ping.interval=20000
  240. client.maxrequests=300
  241.  
  242. # System License
  243. hotel.name=Habbi
  244.  
  245. ";
  246.  
  247. $fp = fopen("$nomearquivo", "w");
  248. $escreve = fwrite($fp, "$conteudo");
  249. fclose($fp);
  250.  
  251. $fp = fopen("../servidores/$login/allandesign.ini", "w");
  252. $escreve = fwrite($fp, "[AllanDesign]
  253. Emulador=$login.Emulator.exe");
  254. fclose($fp);
  255.  
  256. $fp = fopen("../servidores/$login/stop.bat", "w");
  257. $string = 'TASKKILL /IM '.$login.'.Emulator.exe -f';
  258. $escreve = fwrite($fp,$string);
  259. fclose($fp);
  260.  
  261. $ligapainelemulador = $login."painel";
  262.  
  263. $fp = fopen("../servidores/$login/start.bat", "w");
  264. $string = 'start '.$ligapainelemulador.'.exe';
  265. $escreve = fwrite($fp, $string);
  266. fclose($fp);
  267.  
  268. rename ("../servidores/$login/Paineldoemulador.exe", "../servidores/$login/$ligapainelemulador.exe");
  269. rename ("../servidores/$login/Plus Emulator.exe", "../servidores/$login/$login.Emulator.exe");
  270. rename ("../servidores/$login/Plus Emulator.exe.config", "../servidores/$login/$login.Emulator.exe.config");
  271. rename ("../servidores/$login/Plus Emulator.vshost.exe", "../servidores/$login/$login.Emulator.vshost.exe");
  272. rename ("../servidores/$login/Plus Emulator.pdb", "../servidores/$login/$login.Emulator.pdb");
  273. rename ("../servidores/$login/Plus Emulator.vshost.exe.config", "../servidores/$login/$login.Emulator.vshost.exe.config");
  274.  
  275.  
  276. }
  277. function liberar($dominio, $pacote, $email, $donorev){
  278.  
  279. $verificar = $this->pdo->query("SELECT * FROM servidores WHERE siteurl='$dominio'");
  280. $contagem = $verificar->fetchColumn();
  281.  
  282. if($contagem >=1){ return false; }
  283. $username = $this->gerar_senha(8, false, true, false, false);
  284. $password = $this->gerar_senha(10, true, true, true, false);
  285.  
  286. $dbnome = $username."_db";
  287.  
  288. $ip_cp = $this->dadospainel_2("ipwhm");
  289. $ip_emu = $this->dadospainel_2("ipemu");
  290.  
  291. $consulta_4 = $stmt = $this->pdo->query("SELECT * FROM servidores WHERE subconta='0' ORDER BY `id` DESC LIMIT 1");
  292. while ($porta = $consulta_4->fetch(PDO::FETCH_ASSOC)){
  293. $tcp_h = $porta['tcp'];
  294. $mus_h = $porta['mus'];
  295. }
  296. $soma = "1";
  297. $tcp_h = $mus_h+$soma;
  298. $mus_h = $tcp_h+$soma;
  299. if($tcp_h == "1"){
  300. $tcp_h = "500";
  301. $mus_h = "501";
  302. }
  303. //Criar cPanel
  304. $this->re_cp($pacote, $username, $password, $dominio, $email);
  305. //Enviar CMS
  306. $this->enviar_ssh('cp /fpanel/default.zip /home/'.$username.'/public_html');
  307. //Extrair CMS
  308. $this->extract_cms("default.zip", $username, $password);
  309. //Reinstalar DB
  310. $this->re_db($username, $password, $dbnome);
  311. //Criar pasta temporaria
  312. $pastad = "./temp/$username";
  313. if(!is_dir($pastad)){
  314. mkdir($pastad,0777);
  315. chmod($pastad,0777);
  316. }
  317. //Enviar arquivo config da cms
  318. $nomearquivo = "./temp/$username/config.php";
  319.  
  320. $fp = fopen("$nomearquivo", "w");
  321.  
  322. $string = '<?php'.PHP_EOL;
  323. $string .= 'if(!defined("BRAIN_CMS")) '.PHP_EOL;
  324. $string .= '{ '.PHP_EOL;
  325. $string .= 'die("Sorry but you cannot access this file!"); '.PHP_EOL;
  326. $string .= '}'.PHP_EOL;
  327.  
  328.  
  329. $string .= '$db["host"] = "localhost"; //Mysql"s Host'.PHP_EOL;
  330. $string .= '$db["port"] = "3306"; //Mysql"s port'.PHP_EOL;
  331. $string .= '$db["user"] = "'.$username.'"; //Mysql"s user'.PHP_EOL;
  332. $string .= '$db["pass"] = "'.$password.'"; //Mysql"s password'.PHP_EOL;
  333. $string .= '$db["db"] = "'.$dbnome.'"; //Mysql"s database'.PHP_EOL;
  334.  
  335. $string .= '$config["hotelEmu"] = "plusemu"; // plusemu // arcturus'.PHP_EOL;
  336.  
  337. $string .= '$hotel["emuHost"] = "'.$ip_emu.'";'.PHP_EOL;
  338. $string .= '$hotel["emuPort"] = "'.$tcp_h.'";'.PHP_EOL;
  339. $string .= '$hotel["staffCheckClient"] = false;'.PHP_EOL;
  340. $string .= '$hotel["staffCheckClientMinimumRank"] = 3;'.PHP_EOL;
  341. $string .= '$hotel["homeRoom"] = "0";'.PHP_EOL;
  342. $string .= '$hotel["swf_url"] = "http://swf.meuhotel.in/swf";'.PHP_EOL;
  343. $string .= '$hotel["external_Variables"] = $hotel["swf_url"]."/gamedata//ISecuritinet.txt";'.PHP_EOL;
  344. $string .= '$hotel["external_Variables_Override"] = $hotel["swf_url"]."/gamedata/override//FANEW.txt";'.PHP_EOL;
  345. $string .= '$hotel["external_Texts"] = $hotel["swf_url"]."/gamedata/external_flash_4.txt";'.PHP_EOL;
  346. $string .= '$hotel["external_Texts_Override"] = $hotel["swf_url"]."/gamedata/override//external_flash_override_texts.txt";'.PHP_EOL;
  347. $string .= '$hotel["productdata"] = $hotel["swf_url"]."/gamedata/productdata.txt";'.PHP_EOL;
  348. $string .= '$hotel["furnidata"] = $hotel["swf_url"]."/gamedata/furnidata.xml";'.PHP_EOL;
  349. $string .= '$hotel["figuremap"] = $hotel["swf_url"]."/gamedata/figuremap.xml";'.PHP_EOL;
  350. $string .= '$hotel["figuredata"] = $hotel["swf_url"]."/gamedata/figuredata.xml";'.PHP_EOL;
  351. $string .= '$hotel["swfFolder"] = $hotel["swf_url"]."/gordon/prod";'.PHP_EOL;
  352. $string .= '$hotel["swfFolderSwf"] = $hotel["swf_url"]."/gordon/prod/Hotel.swf";'.PHP_EOL;
  353. $string .= '$hotel["avatareditor.promohabbos"] = $hotel["swf_url"]."/gamedata/hotlooks.xml";'.PHP_EOL;
  354. $string .= '$hotel["diamonds.enabled"] = true;'.PHP_EOL;
  355. $string .= '$hotel["builders.club.enabled"] = false;'.PHP_EOL;
  356.  
  357. $string .= '$config["hotelUrl"] = "http://'.$dominio.'";//Address of your hotel. Does not end with a "/"'.PHP_EOL;
  358. $string .= '$config["skin"] = "brain"; //Skin/template of your website'.PHP_EOL;
  359. $string .= '$config["lang"] = "pt-br"; //Language of your website en/nl/es'.PHP_EOL;
  360. $string .= '$config["hotelName"] = "Habbo"; //Name of your hotel'.PHP_EOL;
  361. $string .= '$config["favicon"] = "http://'.$dominio.'/templates/brain/style/images/favicon/favicon.ico";'.PHP_EOL;
  362. $string .= '$config["staffCheckHk"] = false; //Enable the staff pin in the housekeeping (true) or disable it (false)'.PHP_EOL;
  363. $string .= '$config["staffCheckHkMinimumRank"] = 3; //Minium staff rank to get the staff pin in the housekeeping'.PHP_EOL;
  364. $string .= '$config["maintenance"] = false; //Enable the maintenance of your website (true) or disable it (false)'.PHP_EOL;
  365. $string .= '$config["maintenancekMinimumRankLogin"] = 3; //Minium staff rank to login when the website is in maintenance'.PHP_EOL;
  366. $string .= '$config["groupBadgeURL"] = "http://swf.meuhotel.in/swf/habbo-imaging/badge.php?badge=";'.PHP_EOL;
  367. $string .= '$config["badgeURL"] = "http://swf.meuhotel.in/swf/c_images/album1584/"; '.PHP_EOL;
  368. $string .= '$config["userLikeEnable"] = true; // Enable user likes '.PHP_EOL;
  369. $string .= '$config["newsCommandEnable"] = true; //Enable news commands'.PHP_EOL;
  370. $string .= '$config["newsCommandFilter"] = true; //Enable wordfilter on news commands (the filter use the db tabels wordfilter and wordfilter_characters)'.PHP_EOL;
  371. $string .= '$config["alertReferrer"] = true;'.PHP_EOL;
  372. $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;
  373. $string .= '$config["brainversion"] = "1.8.1"; // Please do not change.'.PHP_EOL;
  374.  
  375.  
  376. $string .= '$config["facebookLogin"] = false; //Enable the Facebook login (true) or disable it (false)'.PHP_EOL;
  377. $string .= '$config["facebookAPPID"] = "334162590sdaf292528";'.PHP_EOL;
  378. $string .= '$config["facebookAPPSecret"] = "ce2504ff5adsfa3ff7a6a2fa6d984cd8836";'.PHP_EOL;
  379.  
  380. $string .= '$email["mailServerHost"] = "smtp.gmail.com";'.PHP_EOL;
  381. $string .= '$email["mailServerPort"] = 587;'.PHP_EOL;
  382. $string .= '$email["SMTPSecure"] = "TLS";'.PHP_EOL;
  383. $string .= '$email["mailUsername"] = "gmail@gmail.com";'.PHP_EOL;
  384. $string .= '$email["mailPassword"] = "*****";'.PHP_EOL;
  385. $string .= '$email["mailLogo"] = "http://127.0.0.1/templates/brain/style/images/logo/logo.png";'.PHP_EOL;
  386. $string .= '$email["mailTemplate"] = "/system/app/plugins/PHPmailer/temp/resetpassword.html";'.PHP_EOL;
  387.  
  388. $string .= '$config["facebook"] = "https://www.facebook.com/Habbo/";'.PHP_EOL;
  389. $string .= '$config["facebookEnable"] = false;'.PHP_EOL;
  390. $string .= '$config["twitter"] = "https://twitter.com/Habbo";'.PHP_EOL;
  391. $string .= '$config["twitterEnable"] = false;'.PHP_EOL;
  392.  
  393. $string .= '$config["startMotto"] = "Bem-vindo ao habbo!"; //Regsiter start motto'.PHP_EOL;
  394. $string .= '$config["credits"] = "10000";'.PHP_EOL;
  395. $string .= '$config["duckets"] = "20000";'.PHP_EOL;
  396. $string .= '$config["diamonds"] = "10";'.PHP_EOL;
  397. $string .= '$config["diamondsRef"] = "10";'.PHP_EOL;
  398. $string .= '$config["registerEnable"] = true;'.PHP_EOL;
  399.  
  400. $string .= '$config["recaptchaSiteKey"] = "6LdzewwUAAAAABkJ3vsdfCDca9qmLGDaWAHqMRtFEs2";'.PHP_EOL;
  401. $string .= '$config["recaptchaSiteKeyEnable"] = false;'.PHP_EOL;
  402.  
  403. $string .= '$config["vipCost"] = "25";'.PHP_EOL;
  404. $string .= '$config["vipRankToGet"] = "3";'.PHP_EOL;
  405. $string .= '$config["vipBadge"] = "vip";'.PHP_EOL;
  406.  
  407.  
  408. $string .= 'switch($config["hotelEmu"])'.PHP_EOL;
  409. $string .= '{'.PHP_EOL;
  410. $string .= ' case "arcturus":'.PHP_EOL;
  411. $string .= ' $emuUse["user_wardrobe"] = "users_wardrobe ";'.PHP_EOL;
  412. $string .= ' $emuUse["ip_last"] = "ip_current";'.PHP_EOL;
  413. $string .= ' $emuUse["respect"] = "respects_received";'.PHP_EOL;
  414. $string .= ' $emuUse["user_stats"] = "users_settings";'.PHP_EOL;
  415. $string .= ' $emuUse["user_stats_user_id"] = "user_id";'.PHP_EOL;
  416. $string .= ' $emuUse["OnlineTime"] = "online_time";'.PHP_EOL;
  417. $string .= ' break;'.PHP_EOL;
  418. $string .= ' case "plusemu":'.PHP_EOL;
  419. $string .= ' $emuUse["user_wardrobe"] = "user_wardrobe ";'.PHP_EOL;
  420. $string .= ' $emuUse["ip_last"] = "ip_last";'.PHP_EOL;
  421. $string .= ' $emuUse["respect"] = "Respect";'.PHP_EOL;
  422. $string .= ' $emuUse["user_stats"] = "user_stats";'.PHP_EOL;
  423. $string .= ' $emuUse["user_stats_user_id"] = "id";'.PHP_EOL;
  424. $string .= ' $emuUse["OnlineTime"] = "OnlineTime";'.PHP_EOL;
  425. $string .= ' break;'.PHP_EOL;
  426. $string .= ' default:'.PHP_EOL;
  427. $string .= ' break;'.PHP_EOL;
  428. $string .= '}'.PHP_EOL;
  429. $string .= '?>'.PHP_EOL;
  430.  
  431. $escreve = fwrite($fp,$string);
  432. fclose($fp);
  433.  
  434. //Enviar config da cms
  435. $file = 'temp/'.$username.'/config.php';//tobe uploaded
  436. $remote_file = '/public_html/system/brain-config.php';
  437.  
  438. // set up basic connection
  439. $conn_id = ftp_connect($ip_cp);
  440.  
  441. // login with username and password
  442. $login_result = ftp_login($conn_id, $username, $password);
  443. ftp_pasv($conn_id, true);
  444.  
  445. // upload a file
  446. if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII));
  447. // close the connection
  448. ftp_close($conn_id);
  449.  
  450. //Reinstalar emulador
  451. $this->re_emu($ip_cp, $ip_emu, $username, $password, $dbnome, $tcp_h, $mus_h);
  452.  
  453. $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
  454. ('$username', '$password', '$username', '$password', 'Habbo', 'Plus', '$email', '$ip_cp', '3306', '$dbnome', '$tcp_h', '$mus_h', '$dominio', '0', '0', '', '$pacote', '$donorev', '0')");
  455. $emulador = $e->fetch(PDO::FETCH_ASSOC);
  456.  
  457. $c = $this->pdo->query("INSERT INTO comandos (subconta, config, reinstalar, painel, backup, emulador, dono) VALUES
  458. ('1', '1', '1', '1', '1', '1', '$username')");
  459. $comandos = $c->fetch(PDO::FETCH_ASSOC);
  460.  
  461. $this->removeTree("./temp/$username");
  462.  
  463. return true;
  464. }
  465. }
  466. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement