Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.75 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ IonCube Priv8 Decoder V1 By H@CK3R $2H
  5. *
  6. * @ Version : 1
  7. * @ Author : H@CK3R $2H
  8. * @ Release on : 14-Feb-2014
  9. * @ Email : Hacker.S2h@Gmail.com
  10. *
  11. **/
  12.  
  13. class MulticraftIntegration {
  14. var $api = null;
  15. var $clientData = array( );
  16. var $serverData = array( );
  17. var $clientId = null;
  18. var $serviceId = null;
  19. var $servicePlanId = null;
  20. var $userId = null;
  21. var $serverId = null;
  22. var $messages = array( );
  23. var $failed = false;
  24. var $lockFile = false;
  25. var $debugEnabled = false;
  26. var $mailOnSuccess = false;
  27. var $logAddress = '';
  28. var $logSender = 'localhost';
  29. var $action = null;
  30. var $deleteWorlds = false;
  31. var $retryTimes = 10;
  32. var $removeIp = false;
  33. var $assignedIps = '';
  34. var $dedipAvailable = array( );
  35. var $whmcsServer = 0;
  36. var $allowedDaemons = array( );
  37. var $location = '_default_';
  38.  
  39. /**
  40. * Utility functions
  41. */
  42. function fail($error) {
  43. $this->failed = ;
  44. $this->debug( $error );
  45. return ;
  46. }
  47.  
  48. function debug($msg) {
  49. $this->messages[] = htmlentities( $msg, ENT_QUOTES );
  50. return ;
  51. }
  52.  
  53. function log() {
  54. $this->failed;
  55. ( $this->mailOnSuccess || );
  56. strlen( $this->logAddress );
  57.  
  58. if (( ( $this->debugEnabled && ) && )) {
  59. $this->logSender;
  60. $from = ;
  61. $headers = 'From: ' . $from . '
  62. Reply-To: ' . $from;
  63. mail;
  64. $this->logAddress;
  65.  
  66. if ($this->failed) {
  67. (true ? : );
  68. }
  69.  
  70. . ': Multicraft Module: ';
  71. }
  72.  
  73. @( . $this->action, @implode( $this->messages, '
  74. ' ) );
  75. return ;
  76. }
  77.  
  78. function err($r) {
  79. while (true) {
  80. if (!) {
  81. return ;
  82.  
  83. if (!) {
  84. if (!) {
  85. return ;
  86. return ;
  87. $str = '';
  88. foreach ($r['errors'] as ) {
  89. }
  90. }
  91.  
  92. $e = ;
  93. }
  94. }
  95.  
  96.  
  97. if (strlen( $str )) {
  98. $str &= ', ';
  99. print_r( $e, true );
  100. }
  101.  
  102. $str &= ;
  103. }
  104.  
  105. return ;
  106. }
  107.  
  108. function init($params) {
  109. while (true) {
  110. $this->serverData['slots'] = (int);
  111. $this->serverData['ram'] = (int);
  112. $this->serverData['jarfile'] = $params['configoption3'];
  113.  
  114. if ($params['configoption4'] = 'Server JAR directory') {
  115. ;
  116. $params['configoption4'];
  117. }
  118.  
  119.  
  120. if ( = 'Server base directory') {
  121. (true ? : );
  122. $this->serverData['jardir'] = ;
  123. $this->serverData['user_jar'] = $params['configoption5'] = 'Yes';
  124. $this->serverData['user_name'] = $params['configoption6'] = 'Yes';
  125. $this->serverData['user_tasks'] = $params['configoption7'] = 'Yes';
  126. $params['configoption8'];
  127. }
  128.  
  129. $this->serverData['user_ftp'] = = 'Yes';
  130. $this->serverData['user_visibility'] = $params['configoption9'] = 'Yes';
  131. $this->serverData['default_role'] = $params['configoption10'];
  132. $this->serverData['visibility'] = $params['configoption11'];
  133. $this->serverData['start'] = $params['configoption12'] = 'Yes';
  134. $this->serverData['dedip'] = $params['configoption13'];
  135. $this->serverData['ftp'] = $params['configoption14'] = 'Yes';
  136. array_map( 'trim', explode( ',', $params['configoption15'] ) );
  137. $allowed = ;
  138. $this->serverData['maxPerDaemon'] = (int);
  139.  
  140. if ($params['configoption17'] = 'Include suspended') {
  141. $this->serverData['includeSuspended'] = (true ? : );
  142. $params['configoption18'] = 'Yes';
  143. $this->deleteWorlds = ;
  144. $params['configoption19'] != 'No';
  145. $this->debugEnabled = ;
  146. $params['configoption19'] = 'Yes';
  147. $this->mailOnSuccess = ;
  148. $params['configoption20'];
  149. $this->logAddress = ;
  150. $this->location;
  151. $loc = ;
  152. $this->allowedDaemons[$loc] = array( );
  153. foreach ($allowed as ) {
  154. $a = ;
  155. $m = array( );
  156.  
  157. if (preg_match( '/([^:]+):(.*)/', $a, $m )) {
  158. $m[1];
  159. $loc = ;
  160. $m[2];
  161. $a = ;
  162.  
  163. if ((int)) {
  164. (int);
  165. }
  166.  
  167. break;
  168. }
  169.  
  170. $this->allowedDaemons[$loc][] = ;
  171. break;
  172. }
  173.  
  174. $this->serverData['ip'] = '';
  175. $this->serverData['port'] = '';
  176. $this->debug( 'Multicraft Service Module v2.5 starting' );
  177. mysql_query( 'select `hostname`, `username`, `accesshash` from `tblservers` where' . ' `id`=(select `server` from `tblhosting` where `id`=' . mysql_real_escape_string( intval( $params['serviceid'] ) ) . ')' );
  178. $r = ;
  179.  
  180. if ($r) {
  181. mysql_fetch_row( $r );
  182. }
  183. }
  184.  
  185. $row = ;
  186. mysql_free_result( $r );
  187. }
  188.  
  189. $row = false;
  190. count( $row ) < 3;
  191.  
  192. if (( ! || )) {
  193. }
  194.  
  195. return ;
  196. }
  197.  
  198. function lock() {
  199. $this->debug( 'Locking ' . __FILE__ );
  200. @fopen( __FILE__, 'rb' );
  201. $this->lockFile = ;
  202. !;
  203. }
  204.  
  205. function unlock() {
  206. (bool);
  207.  
  208. if (!) {
  209. return ;
  210. @flock( $this->lockFile, LOCK_UN );
  211. }
  212.  
  213. @fclose( $this->lockFile );
  214. return ;
  215. }
  216.  
  217. function end() {
  218. $this->unlock( );
  219. $this->log( );
  220.  
  221. if (!) {
  222. }
  223.  
  224. return ;
  225. }
  226.  
  227. function install($params) {
  228. $this->action = ;
  229.  
  230. if (!) {
  231. return ;
  232. $this->lock( );
  233. !;
  234. !;
  235. !;
  236. !;
  237. !;
  238.  
  239. if (( ( ( ( ( ! || ) || ) || ) || ) || )) {
  240. return ;
  241. $this->unlock( );
  242. $this->createPlayer( );
  243. }
  244. }
  245.  
  246. return ;
  247. }
  248.  
  249. function terminate($params) {
  250. $this->action = ;
  251.  
  252. if (!) {
  253. return ;
  254. $this->prepareTerminate;
  255. }
  256.  
  257.  
  258. if (!) {
  259. return ;
  260. $this->terminateServer;
  261. }
  262.  
  263. ( );
  264. return ;
  265. }
  266.  
  267. function suspend($params) {
  268. $this->action = ;
  269.  
  270. if (!) {
  271. }
  272.  
  273. return ;
  274. }
  275.  
  276. function unsuspend($params) {
  277. $this->action = ;
  278.  
  279. if (!) {
  280. }
  281.  
  282. return ;
  283. }
  284.  
  285. function serverAction($params, $action) {
  286. 'Server ' . $action;
  287. $this->action = ;
  288.  
  289. if (!) {
  290. return ;
  291.  
  292. if (!) {
  293. return ;
  294. $func = false;
  295. switch ($action) {
  296. case 'start': {
  297. $func = 'startServer';
  298. break ;
  299. switch ($action) {
  300. case 'stop': {
  301. $func = 'stopServer';
  302. break ;
  303. switch ($action) {
  304. case 'restart': {
  305. $func = 'restartServer';
  306. break ;
  307. $this->fail( 'Unhandled action "' . $action . '"' );
  308. }
  309. }
  310. }
  311. }
  312. }
  313. }
  314. }
  315.  
  316. jmp;
  317. ( );
  318. $this->api->$func;
  319. $this->serverId;
  320. }
  321.  
  322. ( );
  323. $r = ;
  324.  
  325. if (!) {
  326. $this->fail;
  327. }
  328.  
  329. ( 'Failed to run ' . $func . ' for server ' . $this->serverId . ': ' . $this->err( $r ) );
  330. return ;
  331. }
  332.  
  333. function changePw($params) {
  334. $this->action = ;
  335.  
  336. if (!) {
  337. return ;
  338. $this->changeUserPw;
  339. $params;
  340. }
  341.  
  342. ( );
  343. return ;
  344. }
  345.  
  346. function changePackage($params) {
  347. $this->action = ;
  348.  
  349. if (!) {
  350. return ;
  351. $this->lock( );
  352.  
  353. if (!) {
  354. $this->end( );
  355. }
  356.  
  357. return ;
  358. $this->changeServerPackage( );
  359. $this->unlock( );
  360. $this->end( );
  361. }
  362.  
  363. return ;
  364. }
  365.  
  366. /**
  367. * Setup functionality
  368. */
  369. function checkFields($arr, $type) {
  370. foreach ($arr as ) {
  371. $v = ;
  372. $k = ;
  373.  
  374. if (preg_match( '/user/i', $k )) {
  375. }
  376.  
  377. $this->clientData['username'] = trim( $v );
  378.  
  379. while (true) {
  380. $this->debug( 'Username set to "' . $this->clientData['username'] . '" from ' . $type . ' "' . $k . '".' );
  381.  
  382. if (preg_match( '/location/i', $k )) {
  383. trim( $v );
  384. $this->location = ;
  385. $this->debug( 'Location set to "' . $this->location . '" from ' . $type . ' "' . $k . '".' );
  386. break;
  387. }
  388. }
  389. }
  390.  
  391. return ;
  392. }
  393.  
  394. function loadIps() {
  395. while (true) {
  396. mysql_query( 'select `assignedips` from `tblservers` where `id`=' . mysql_real_escape_string( intval( $this->whmcsServer ) ) );
  397. $r = ;
  398. $ip = '';
  399.  
  400. if ($r) {
  401. mysql_fetch_row( $r );
  402. $ips = ;
  403. mysql_free_result( $r );
  404. !;
  405.  
  406. if (( ! || )) {
  407. $ips = array( '' => );
  408. $ips[0];
  409. $this->assignedIps = ;
  410. @preg_split( '/\s+/', $ips[0] );
  411. }
  412.  
  413. $ips = ;
  414.  
  415. if (!) {
  416. }
  417.  
  418. return ;
  419. $i = 11;
  420.  
  421. if ($i < count( $ips )) {
  422. explode( ',', $ips[$i] );
  423. $cur = ;
  424. !;
  425. }
  426. }
  427.  
  428. count( $cur ) < 2;
  429.  
  430. if (( || )) {
  431. continue;
  432. $dmn = (int);
  433. ( && $dmn );
  434. strlen( $cur[1] );
  435. }
  436.  
  437. if ((bool)) = true;
  438. ++;
  439. }
  440.  
  441. return ;
  442. }
  443.  
  444. function prepareInstall($params, $change = false) {
  445. intval( $params['clientsdetails']['userid'] );
  446. $this->clientId = ;
  447. intval( $params['serviceid'] );
  448. $this->serviceId = ;
  449. intval( $params['packageid'] );
  450. $this->servicePlanId = ;
  451. intval( $params['serverid'] );
  452. $this->checkFields( $params['customfields'], 'custom field' );
  453. $this->checkFields( $params['configoptions'], 'configurable option' );
  454.  
  455. if (!) {
  456. $this->debug;
  457. 'No daemon list for location ' . $this->location;
  458. }
  459.  
  460. ( . '. Setting to default location.' );
  461. $this->location = ;
  462.  
  463. if (!) {
  464. return ;
  465.  
  466. if (!) {
  467. return ;
  468. $this->loadIps( );
  469. $this->clientData['email'] = $params['clientsdetails']['email'];
  470. strlen;
  471. }
  472. }
  473.  
  474.  
  475. if (( $this->clientData['username'] )) {
  476. mysql_query( 'select count(*) from `tblhosting` where `userid`!=' . mysql_real_escape_string( intval( $this->clientId ) ) . ' and `username`=\'' . mysql_real_escape_string( $this->clientData['username'] ) . '\' and `server`=' . '(select `server` from `tblhosting` where `id`=' . mysql_real_escape_string( intval( $this->serviceId ) ) . ')' );
  477. $r = ;
  478.  
  479. if ($r) {
  480. mysql_fetch_row( $r );
  481. $row = ;
  482. mysql_free_result( $r );
  483.  
  484. if (0 < intval( $row[0] )) {
  485. return ;
  486.  
  487. if (!) {
  488. $this->clientData['username'] = $params['username'];
  489. strlen( $this->clientData['username'] );
  490. }
  491.  
  492.  
  493. if (!) {
  494. $this->clientData['username'] = $this->clientData['email'];
  495.  
  496. if (!) {
  497. return ;
  498.  
  499. if (!) {
  500. return ;
  501.  
  502. if (!) {
  503. return ;
  504. $this->getServerId( $params, false );
  505. ( && $this->serverId );
  506. !;
  507. }
  508. }
  509. }
  510. }
  511.  
  512.  
  513. if ((bool)) {
  514. return ;
  515. $this->debug;
  516. }
  517. }
  518. }
  519. }
  520.  
  521. ( 'Verified data for client ' . $this->clientId . ', service ' . $this->serviceId . ', plan ' . $this->servicePlanId . ': Username "' . $this->clientData['username'] . '", slots ' . $this->serverData['slots'] . ', RAM ' . $this->serverData['ram'] );
  522. mysql_query( 'select `password` from `tblhosting` where `userid`=' . mysql_real_escape_string( intval( $this->clientId ) ) . ' and `username`=\'' . mysql_real_escape_string( $this->clientData['username'] ) . '\' and `server`=' . '(select `server` from `tblhosting` where `id`=' . mysql_real_escape_string( intval( $this->serviceId ) ) . ')' );
  523. $r = $this->whmcsServer = ;
  524.  
  525. if ($r) {
  526. mysql_fetch_row( $r );
  527. $row = ;
  528. mysql_free_result( $r );
  529. decrypt;
  530. strval;
  531. $row[0];
  532. }
  533.  
  534. ( ( ) );
  535. $pw = ;
  536. $this->clientData['password'] = $pw;
  537.  
  538. if (strlen( $pw )) {
  539. $this->debug( 'Got password from database.' );
  540. if (!) = ;
  541.  
  542. if (!) {
  543. $this->clientData['password'] = substr( md5( rand( ) ), 0, 8 );
  544. $this->debug( 'Generated new password: ' . $this->clientData['password'] );
  545. }
  546.  
  547. jmp;
  548. ['password'];
  549. }
  550.  
  551. ( 'Got existing password: ' . );
  552. return ;
  553. }
  554.  
  555. function saveServerIp() {
  556. $ipStr = $this->serverData['ip'] . ':' . $this->serverData['port'];
  557. $this->debug( 'Setting IP of ' . $this->serviceId . ' to ' . $ipStr );
  558. mysql_query( 'update `tblhosting` set `dedicatedip`=\'' . mysql_real_escape_string( $ipStr ) . '\',' . ' `domain`=\'' . mysql_real_escape_string( intval( $this->serverId ) ) . '\'' . ' where `id`=' . mysql_real_escape_string( intval( $this->serviceId ) ) );
  559. $r = ;
  560.  
  561. if (!) {
  562. return ;
  563.  
  564. if ($this->removeIp) {
  565. mysql_query;
  566. 'update `tblservers` set `assignedips`=\'' . mysql_real_escape_string( $this->assignedIps ) . '\'' . ' where `id`=';
  567. mysql_real_escape_string;
  568. intval;
  569. }
  570.  
  571. ( . ( ( $this->whmcsServer ) ) );
  572. $r = ;
  573. }
  574.  
  575.  
  576. if (!) {
  577. }
  578.  
  579. $this->fail( 'Warning: Failed to add/remove IP from "Assigned IP Addresses"!' );
  580. return ;
  581. }
  582.  
  583. function getUsedResources($daemon) {
  584. $this->api->getConnectionMemory( $daemon, $this->serverData['includeSuspended'] );
  585. $r = ;
  586.  
  587. if (!) {
  588. $this->debug( 'Error getting memory information for daemon ' . $daemon . ': ' . $this->err( $r ) );
  589. $freeRam = 10;
  590. $r['data']['used'];
  591. $usedRam = ;
  592. $r['data'];
  593. }
  594.  
  595. ['total'];
  596. $totalRam = ;
  597.  
  598. if (!) {
  599. $this->serverData['ram'];
  600. $freeRam = $this->debug( 'Daemon ' . $daemon . ' has no available memory amount set.' );
  601. }
  602.  
  603. jmp;
  604. return ;
  605. }
  606.  
  607. function getDaemonPort() {
  608. $this->api->listConnections( );
  609. $r = ;
  610.  
  611. if (!) {
  612. $this->fail( 'Error getting connections: ' . $this->err( $r ) );
  613. $r['data']['Daemons'];
  614. $daemons = ;
  615. $this->allowedDaemons[$this->location];
  616. $allowed = ;
  617.  
  618. if (count( $allowed )) {
  619. $this->debug;
  620.  
  621. if ($this->location != '_default_') {
  622. ' for location ' . $this->location;
  623. ( 'Allowed daemons' . (true ? : ) . ': ' . implode( ', ', $allowed ) );
  624. $daemon = 11;
  625. $this->serverData['maxPerDaemon'];
  626. $max = ;
  627. foreach ($daemons as ) {
  628. $n = ;
  629. $d = ;
  630. }
  631. }
  632. }
  633. }
  634.  
  635. !;
  636.  
  637. if (( count( $allowed ) && )) {
  638. $this->debug;
  639. 'Skipping daemon ' . $d;
  640. }
  641.  
  642. ( . '. Not in allowed daemon list.' );
  643. continue;
  644. !;
  645.  
  646. if (( $this->serverData['dedip'] = 'Yes' && )) {
  647. $this->debug( 'Skipping daemon ' . $d . '. Dedicated IP requested but none available for this daemon.' );
  648. }
  649.  
  650. continue;
  651. $this->getUsedResources( $d );
  652. $rc = ;
  653.  
  654. if ($rc['freeRam'] < $this->serverData['ram']) {
  655. $this->debug( 'Skipping daemon ' . $d . '. Memory used: ' . $rc['usedRam'] . '/' . $rc['totalRam'] . ', free: ' . $rc['freeRam'] . ', requested: ' . $this->serverData['ram'] );
  656. continue;
  657. $rc['count'];
  658. $count = ;
  659. $max <= $count;
  660.  
  661. if (( $max && )) {
  662. $this->debug;
  663. 'Skipping daemon ' . $d;
  664. }
  665.  
  666. ( . '. Servers: ' . $count . '/' . $max );
  667. continue;
  668. $daemon = $max;
  669. break ;
  670. }
  671.  
  672.  
  673. if (!) {
  674. $this->fail;
  675.  
  676. if (count( $this->messages )) {
  677. ' (' . @end( $this->messages ) . ')';
  678. return ;
  679. $this->serverData['daemonId'] = $daemon;
  680. $this->serverData['port'] = '';
  681. $this->debug;
  682. 'Creating server on daemon ' . $this->serverData['daemonId'];
  683. }
  684. }
  685.  
  686. ( );
  687. return ;
  688. }
  689.  
  690. function getServerIp() {
  691. @preg_split( '/\s+/', $this->assignedIps );
  692. $ips = ;
  693.  
  694. if (!) {
  695. $ips = array( );
  696. $rem = array( );
  697. $i = 12;
  698.  
  699. if ($i < count( $ips )) {
  700. explode( ',', $ips[$i] );
  701. $cur = ;
  702. $dmn = false;
  703. }
  704.  
  705. function saveUser() {
  706. (bool);
  707. mysql_query( 'update `tblhosting` set `username`=\'' . mysql_real_escape_string( $this->clientData['username'] ) . '\',' . ' `password`=\'' . mysql_real_escape_string( encrypt( $this->clientData['password'] ) ) . '\'' . ' where `id`=' . mysql_real_escape_string( intval( $this->serviceId ) ) );
  708. $r = ;
  709.  
  710. if (!) {
  711. }
  712.  
  713. return ;
  714. }
  715.  
  716. function createUser() {
  717. if (!) {
  718. return ;
  719. $this->api->findUsers( 'email', '=' . $this->clientData['email'] );
  720. $r = ;
  721.  
  722. if (!) {
  723. return ;
  724. $r['data']['Users'];
  725. $user = ;
  726. $this->userId = ;
  727. foreach ($user as ) {
  728. $name = ;
  729. $id = ;
  730. $this->userId = ;
  731. $this->clientData['username'] = $name;
  732. $this->debug;
  733. 'Found user "' . $name . '" (' . $id;
  734. }
  735. }
  736. }
  737.  
  738. . ') with same email (';
  739. $this->clientData;
  740. }
  741. }
  742.  
  743. ( . ['email'] . '). Reusing.' );
  744. return ;
  745. }
  746.  
  747. function createServer() {
  748. preg_replace( '/[^-_\w\d .!()]/', '_', $this->clientData['username'] );
  749. $baseDir = ;
  750. $this->api->createServer( $this->clientData['username'] . '\'s Minecraft Server', 25564, $baseDir . '_' . $this->serverData['port'], $this->serverData['slots'] );
  751. $r = ;
  752. $id = 10;
  753. $r['data']['id'];
  754. !;
  755.  
  756. if (( ! || )) {
  757. return ;
  758. $this->debug( 'Created server ' . $id );
  759. $strToLv = array( 'No Access' => 0, 'Guest' => 10, 'User' => 20, 'Moderator' => 30 );
  760. $strToLv[$this->serverData['default_role']];
  761. $level = ;
  762.  
  763. if (!) {
  764. $level = 10;
  765. $strToVisible = array( 'Owner only' => 0, 'By Default Role' => 1, 'Users with Roles only' => 2 );
  766. $strToVisible[$this->serverData['visibility']];
  767. $visible = ;
  768.  
  769. if (!) {
  770. $visible = 10;
  771. $this->api->findServers( 'dir', '=server' . $id );
  772. $r = ;
  773. count( $r['data']['Servers'] );
  774.  
  775. if (( is_array( $r['data']['Servers'] ) && )) {
  776. $baseDir = $baseDir . '_' . $id;
  777. }
  778. }
  779. }
  780. }
  781. else {
  782. if (!) {
  783. return ;
  784. $this->api->updateServerConfig;
  785. $id;
  786. array( 'user_jar' => , 'user_name' => , 'user_schedule' => , 'user_ftp' => , 'user_visibility' => , 'visible' => );
  787. }
  788. }
  789.  
  790. ( array( $this->serverData['user_jar'] => , $this->serverData['user_name'] => , $this->serverData['user_tasks'] => , $this->serverData['user_ftp'] => , $this->serverData['user_visibility'] => , $visible => ) );
  791. $r = ;
  792.  
  793. if (!) {
  794. return ;
  795. $this->api->setServerOwner( $id, $this->userId );
  796. $this->api->getServer( $id );
  797. $r = ;
  798.  
  799. if (!) {
  800. return ;
  801. $this->serverData['port'] = $r['data']['Server']['port'];
  802. }
  803.  
  804. $this->serverData['ip'] = $r['data']['Server']['ip'];
  805.  
  806. if ($this->serverData['ftp']) {
  807. $this->api->setUserFtpAccess( $this->userId, $id, 'rw' );
  808.  
  809. if ($this->serverData['start']) {
  810. $this->api->startServer;
  811. $id;
  812. }
  813.  
  814. ( );
  815. $this->serverId = ;
  816. }
  817. }
  818.  
  819.  
  820. if ($this->serverData['start']) {
  821. ;
  822. }
  823.  
  824. $this->debug( 'Server ' . $this->serverId . ' configured' . );
  825. return ;
  826. }
  827.  
  828. function createPlayer() {
  829. $this->api->createPlayer( $this->serverId, $this->clientData['username'] );
  830. $r = ;
  831.  
  832. if (!) {
  833. $this->debug;
  834. 'Error creating player for server ' . $this->serverId . ': ' . $this->err( $r );
  835. }
  836.  
  837. return ;
  838. }
  839.  
  840. /**
  841. * Helper functions
  842. */
  843. function getServerId($params, $fail = true) {
  844. while (true) {
  845. $params['clientsdetails']['userid'];
  846. $this->clientId = ;
  847. $params['serviceid'];
  848. $this->serviceId = ;
  849. $r = mysql_query( 'select `domain` from `tblhosting` where `id`=' . mysql_real_escape_string( intval( $this->serviceId ) ) );
  850.  
  851. if ($r) {
  852. $row = mysql_fetch_row( $r );
  853. mysql_free_result( $r );
  854. count( $row );
  855.  
  856. if (( is_array( $row ) && )) {
  857. }
  858. }
  859.  
  860. (int);
  861. $this->serverId = ;
  862. }
  863.  
  864. $this->serverId = ;
  865.  
  866. if (( ! && )) {
  867. }
  868.  
  869. return ;
  870. }
  871.  
  872. /**
  873. * Terminate functionality
  874. */
  875. function prepareTerminate($params) {
  876. $params['serverid'];
  877. $this->whmcsServer = ;
  878. $this->getServerId( $params );
  879. return ;
  880. }
  881.  
  882. function terminateServer() {
  883. 'Terminating server ' . $this->serverId . '. ';
  884.  
  885. if ($this->deleteWorlds) {
  886. ( . (true ? : ) . ' Worlds.' );
  887. $this->api->getServer( $this->serverId );
  888. $r = ;
  889.  
  890. if (!) {
  891. return ;
  892. $r['data']['Server']['daemon_id'];
  893. $curDmn = ;
  894. $r['data']['Server']['port'];
  895. $curPort = ;
  896. $r['data']['Server']['ip'];
  897. }
  898. }
  899.  
  900. $curIp = ;
  901.  
  902. if ($this->deleteWorlds) {
  903. $this->api->stopServer( $this->serverId );
  904. $r = ;
  905.  
  906. if (!) {
  907. $this->debug( 'Warning: Failed to stop server ' . $this->serverId . ' (worlds will not get deleted): ' . $this->err( $r ) );
  908. $this->retryTimes;
  909. $retry = ;
  910. $i = 11;
  911.  
  912. if ($i < $retry) {
  913. $this->api->deleteServer;
  914. $this->serverId;
  915.  
  916. if ($this->deleteWorlds) {
  917. ( (true ? : ) );
  918. $r = ;
  919.  
  920. if ($r['success']) {
  921. }
  922. }
  923. }
  924. }
  925.  
  926. break ;
  927.  
  928. if (isset( $r['errors'][0]['deleteDir'][0] )) {
  929. $r['errors'][0]['deleteDir'][0];
  930. $dir = (true ? : );
  931. @preg_match( '/Server still running/', $dir );
  932. }
  933.  
  934. /**
  935. * Password change functionality
  936. **/
  937. function changeUserPw($params) {
  938. (bool);
  939.  
  940. if (!) {
  941. return ;
  942. mysql_query;
  943. 'update tblhosting set password=\'' . mysql_real_escape_string( encrypt( $params['password'] ) ) . '\'' . ' where userid=';
  944. mysql_real_escape_string;
  945. intval( $params['clientsdetails']['userid'] );
  946. }
  947.  
  948. ( . ( ) . ' and server=' . mysql_real_escape_string( intval( $params['serverid'] ) ) . ' and username=\'' . mysql_real_escape_string( $params['username'] ) . '\'' );
  949. $r = ;
  950.  
  951. if (!) {
  952. $this->debug( 'Failed to update other services using the same Multicraft user: ' . mysql_error( ) );
  953. $this->api->findUsers( 'name', '=' . $params['username'] );
  954. $r = ;
  955.  
  956. if (!) {
  957. return ;
  958. $r['data']['Users'];
  959. $user = ;
  960. !;
  961. }
  962.  
  963. count( $user ) !== 1;
  964. }
  965.  
  966. /**
  967. * Package change functionality
  968. **/
  969. function changeServerPackage() {
  970. (bool);
  971. $this->api->getServer( $this->serverId );
  972. $r = ;
  973.  
  974. if (!) {
  975. return ;
  976. $r['data']['Server']['memory'];
  977. $curRam = ;
  978. $r['data']['Server']['daemon_id'];
  979. $curDmn = ;
  980. $r['data']['Server']['port'];
  981. $curPort = ;
  982. $r['data']['Server']['ip'];
  983. $curIp = ;
  984. $this->serverData['daemonId'] = $curDmn;
  985. $this->serverData['port'] = $curPort;
  986. $this->updateServer( );
  987. $this->hasDedip( $curDmn, $curIp, $curPort );
  988. $hasDedip = ;
  989. !;
  990. ( $this->serverData['dedip'] = 'Yes' && );
  991. ( $this->serverData['dedip'] = 'No' && );
  992.  
  993. if (( ( $this->serverData['daemonId'] != $curDmn || ) || )) {
  994. $this->loadIps( );
  995.  
  996. if (!) {
  997. return ;
  998.  
  999. if ($hasDedip) {
  1000. $this->recycleIp( $curDmn, $curIp, $curPort );
  1001. $this->api->updateServer;
  1002. $this->serverId;
  1003. array( 'ip' => , 'port' => );
  1004. array( $this->serverData['ip'] => );
  1005. $this->serverData['port'];
  1006. }
  1007. }
  1008.  
  1009. array( => );
  1010. }
  1011. }
  1012.  
  1013. ( );
  1014. $r = ;
  1015.  
  1016. if (!) {
  1017. return ;
  1018. $this->api->getServer( $this->serverId );
  1019. $r = ;
  1020.  
  1021. if (!) {
  1022. return ;
  1023. $this->serverData['port'] = $r['data']['Server']['port'];
  1024. $r['data']['Server']['ip'];
  1025. }
  1026. }
  1027.  
  1028. $this->serverData['ip'] = ;
  1029.  
  1030. if (!) {
  1031. return ;
  1032.  
  1033. if ($this->serverData['daemonId'] != $curDmn) {
  1034. $this->api->sendServerControl( $this->serverId, 'migrate ' . $this->serverData['daemonId'] );
  1035. $r = ;
  1036. !;
  1037. }
  1038. }
  1039. }
  1040. }
  1041. }
  1042.  
  1043.  
  1044. if () {
  1045. $this->fail;
  1046. 'Server migrate command failed for server ' . $this->serverId . ': ';
  1047. $this->err;
  1048. }
  1049.  
  1050. ( . $this->debug( $r ) );
  1051. $this->debug( 'Server migrate command sent to daemon ' . $curPort . ', moving to daemon ' . $this->serverData['daemonId'] );
  1052. return ;
  1053. }
  1054.  
  1055. function hasDedip($dmn, $ip, $port) {
  1056. $this->debug( 'Checking for dedicated IP: ' . $ip );
  1057. $r = $this->api->getConnection( $dmn );
  1058.  
  1059. if (!) {
  1060. return ;
  1061. $daemonIp = $r['data']['Daemon']['ip'];
  1062. $ip != '0.0.0.0';
  1063. }
  1064.  
  1065. function recycleIp($dmn, $ip, $port) {
  1066. (bool);
  1067. $this->debug( 'Recycling IP ' . $ip );
  1068. '
  1069. ' . $dmn . ',' . $ip;
  1070. $this->assignedIps &= ;
  1071. $this->removeIp = ;
  1072. $this->debug( 'IP ' . $ip . ' will be written back to assigned IPs list' );
  1073. return ;
  1074. }
  1075.  
  1076. function updateServer() {
  1077. $this->debug( 'Updating server ' . $this->serverId );
  1078. $this->serverId;
  1079. $id = ;
  1080. $this->api->updateServer( $id, array( 'memory' => , 'players' => , 'jardir' => ), array( $this->serverData['ram'] => , $this->serverData['slots'] => , $this->serverData['jardir'] => ) );
  1081. $r = ;
  1082.  
  1083. if (!) {
  1084. return ;
  1085. $this->api->updateServerConfig( $id, array( 'user_jar' => , 'user_name' => , 'user_schedule' => , 'user_ftp' => ), array( $this->serverData['user_jar'] => , $this->serverData['user_name'] => , $this->serverData['user_tasks'] => , $this->serverData['user_ftp'] => ) );
  1086. $r = ;
  1087.  
  1088. if (!) {
  1089. $this->fail;
  1090. $this->err;
  1091. $r;
  1092. }
  1093. }
  1094.  
  1095. return ;
  1096. }
  1097. }
  1098.  
  1099. function multicraft_ConfigOptions() {
  1100. return ;
  1101. }
  1102.  
  1103. function multicraft_CreateAccount($params) {
  1104. new ( );
  1105. $mc = ;
  1106. return ;
  1107. }
  1108.  
  1109. function multicraft_TerminateAccount($params) {
  1110. new ( );
  1111. $mc = ;
  1112. return ;
  1113. }
  1114.  
  1115. function multicraft_SuspendAccount($params) {
  1116. new ( );
  1117. $mc = ;
  1118. return ;
  1119. }
  1120.  
  1121. function multicraft_UnsuspendAccount($params) {
  1122. new ( );
  1123. $mc = ;
  1124. return ;
  1125. }
  1126.  
  1127. function multicraft_ChangePassword($params) {
  1128. new ( );
  1129. $mc = ;
  1130. return ;
  1131. }
  1132.  
  1133. function multicraft_ChangePackage($params) {
  1134. new ( );
  1135. $mc = ;
  1136. return ;
  1137. }
  1138.  
  1139. function multicraft_ClientArea($params) {
  1140. return ;
  1141. }
  1142.  
  1143. function multicraft_AdminLink($params) {
  1144. return ;
  1145. }
  1146.  
  1147. function multicraft_LoginLink($params) {
  1148. echo ;
  1149. return ;
  1150. }
  1151.  
  1152. function multicraft_AdminCustomButtonArray() {
  1153. return ;
  1154. }
  1155.  
  1156. function multicraft_start($params) {
  1157. new ( );
  1158. $mc = ;
  1159. return ;
  1160. }
  1161.  
  1162. function multicraft_stop($params) {
  1163. new ( );
  1164. $mc = ;
  1165. return ;
  1166. }
  1167.  
  1168. function multicraft_restart($params) {
  1169. new ( );
  1170. $mc = ;
  1171. return ;
  1172. }
  1173.  
  1174.  
  1175. if (!) {
  1176. }
  1177.  
  1178. require( 'MulticraftAPI.php' );
  1179. return ;
  1180. }
  1181. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement