Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php /** * Encoded using the xhost.ch PHP encoder, no special decoding module required..
Decoded Output download
<?php
/**
* Encoded using the xhost.ch PHP encoder, no special decoding module required.
* Visit http://phpenc.xhost.ch
**/
?><?php eval(base64_decode('aWYoIWZ1bmN0aW9uX2V4aXN0cygnX19waHBlbmNfc19mdW5jJykpe2Z1bmN0aW9uIF9fcGhwZW5jX3NfZnVuYygkcyl7cmV0dXJuIGV2YWwoJ3JldHVybiAnLmJhc2U2NF9kZWNvZGUodXJsZGVjb2RlKCRzKSkuJzsnKTt9fQ=='));?><?php if(!class_exists('MulticraftAPI'))require('MulticraftAPI.php');class n0d{var $r3c;var $r49=array();var $rd0=array();var $rca;var $r7f;var $rc9;var $r06;var $rfd;var $rd9=array();var $r24=false;var $rb6=false;var $rae=false;var $r98=false;var $rdb='';var $rf2='localhost';var $r37;var $ra7=false;var $r7c=10;var $r35=false;var $r21='';var $rec=array();var $r7b=0;var $r4c=array();var $ra4='_default_';function n7c($r03){$this->r24=true;$this->rda($r03);return false;}function rda($r38){$this->rd9[]=$r38;return false;}function log(){if($this->rae&&($this->r98||$this->r24)&&strlen($this->rdb)){$r4b=$this->rf2;$r28='From: '.$r4b.'
Reply-To: '.$r4b;@mail($this->rdb,($this->r24?'FAILED':'SUCCESS').': Multicraft Module: '.$this->r37,implode($this->rd9,'
'));}}function n5d($r41){if(!isset($r41['errors']))return 'Empty response';if(!is_array($r41['errors'])){if(!@strlen($r41['errors']))return 'Empty error string';return(string)$r41['errors'];}$r8a='';foreach($r41['errors']as $r14){if(strlen($r8a))$r8a.=', ';$r8a.=print_r($r14,true);}return $r8a;}function n90($r36){$this->rd0['slots']=(int)$r36['configoption1'];$this->rd0['ram']=(int)$r36['configoption2'];$this->rd0['jarfile']=$r36['configoption3'];$this->rd0['jardir']=($r36['configoption4']==='Server JAR directory')?'server':'daemon';$this->rd0['user_jar']=($r36['configoption5']==='Yes');$this->rd0['user_name']=($r36['configoption6']==='Yes');$this->rd0['user_tasks']=($r36['configoption7']==='Yes');$this->rd0['user_ftp']=($r36['configoption8']==='Yes');$this->rd0['user_visibility']=($r36['configoption9']==='Yes');$this->rd0['default_role']=$r36['configoption10'];$this->rd0['visibility']=$r36['configoption11'];$this->rd0['start']=($r36['configoption12']==='Yes');$this->rd0['dedip']=$r36['configoption13'];$this->rd0['ftp']=($r36['configoption14']==='Yes');$rd8=array_map('trim',explode(',',$r36['configoption15']));$this->rd0['maxPerDaemon']=(int)$r36['configoption16'];$this->rd0['includeSuspended']=($r36['configoption17']==='Include suspended')?1:0;$this->ra7=($r36['configoption18']==='Yes');$this->rae=($r36['configoption19']!='No');$this->r98=($r36['configoption19']=='Yes');$this->rdb=$r36['configoption20'];$ra73=$this->ra4;$this->r4c[$ra73]=array();foreach($rd8 as $r39){$rbd=array();if(preg_match('/([^:]+):(.*)/',$r39,$rbd)){$ra73=$rbd[1];$r39=$rbd[2];}if((int)$r39)$this->r4c[$ra73][]=(int)$r39;}$this->rd0['ip']='';$this->rd0['port']='';$this->rda('Multicraft Service Module v2.0 starting');$r41=mysql_query('select `hostname`, `username`, `accesshash` from `tblservers` where'.' `id`=(select `server` from `tblhosting` where `id`='.mysql_real_escape_string($r36['serviceid']).')');if(!$r41)return $this->n7c('Failed to get Multicraft API information: '.mysql_error());$r4a=mysql_fetch_row($r41);$this->r3c=new MulticraftAPI($r4a[0].'/api.php',$r4a[1],$r4a[2]);return true;}function n8c(){$this->rda('Locking '.__FILE__);$this->rb6=fopen(__FILE__,'rb');flock($this->rb6,LOCK_EX);}function n60(){if(!$this->rb6)return;flock($this->rb6,LOCK_UN);fclose($this->rb6);}function end(){$this->n60();$this->log();if(!$this->r24)return 'success';else return end($this->rd9);}function install($r36){$this->r37='Setup';if(!$this->n90($r36))return $this->end();$this->n8c();if(!$this->r60($r36)||!$this->r4b8()||!$this->r8b()||!$this->createUser()||!$this->createServer()||!$this->ra0())return $this->end();$this->n60();$this->createPlayer();return $this->end();}function n3a($r36){$this->r37='Terminate';if(!$this->n90($r36))return $this->end();if(!$this->r74($r36))return $this->end();$this->r8f();return $this->end();}function n2f($r36){$this->r37='Suspend';if(!$this->n90($r36))return $this->end();if(!$this->r2c($r36))return $this->end();$this->rda('Suspending server '.$this->rfd);$r41=$this->r3c->suspendServer($this->rfd);if(!$r41['success'])$this->n7c('Failed to suspend server '.$this->rfd.': '.$this->n5d($r41));return $this->end();}function n12($r36){$this->r37='Unsuspend';if(!$this->n90($r36))return $this->end();if(!$this->r2c($r36))return $this->end();$this->rda('Unsuspending server '.$this->rfd);$r41=$this->r3c->resumeServer($this->rfd);if(!$r41['success'])$this->n7c('Failed to unsuspend server '.$this->rfd.': '.$this->n5d($r41));return $this->end();}function n97($r36,$r37){$this->r37='Server '.$r37;if(!$this->n90($r36))return $this->end();if(!$this->r2c($r36))return $this->end();$rce=false;switch($r37){case 'start':$rce='startServer';break;case 'stop':$rce='stopServer';break;case 'restart':$rce='restartServer';break;default:$this->n7c('Unhandled action "'.$r37.'"');}if($rce){$this->rda('Server '.$this->rfd.': '.$r37);$r41=$this->r3c->$rce($this->rfd);if(!$r41['success'])$this->n7c('Failed to run '.$rce.' for server '.$this->rfd.': '.$this->n5d($r41));}return $this->end();}function nd8($r36){$this->r37='Change Password';if(!$this->n90($r36))return $this->end();$this->r7f8($r36);return $this->end();}function n21($r36){$this->r37='Change Package';if(!$this->n90($r36))return $this->end();$this->n8c();if(!$this->r60($r36,true))return $this->end();$this->r62();$this->n60();return $this->end();}function nc4($r01,$rd1){foreach($r01 as $rb3=>$re7){if(preg_match('/user/i',$rb3)){$this->r49['username']=trim($re7);$this->rda('Username set to "'.$this->r49['username'].'" from '.$rd1.' "'.$rb3.'".');}if(preg_match('/location/i',$rb3)){$this->ra4=trim($re7);$this->rda('Location set to "'.$this->ra4.'" from '.$rd1.' "'.$rb3.'".');}}}function n19(){$r41=mysql_query('select `assignedips` from `tblservers` where `id`='.mysql_real_escape_string($this->r7b));$re4='';if($r41){$r7b8=mysql_fetch_row($r41);mysql_free_result($r41);$this->r21=$r7b8[0];$r7b8=@preg_split('/\s+/',$r7b8[0]);for($r9e=0;$r9e<count($r7b8);$r9e++){$re9=explode(',',$r7b8[$r9e]);if(count($re9)<2)continue;$r05=(int)$re9[0];if($r05&&strlen($re9[1]))$this->rec[$r05]=true;}}}function r60($r36,$rf9=false){$this->rca=$r36['clientsdetails']['userid'];$this->r7f=$r36['serviceid'];$this->rc9=$r36['packageid'];$this->r7b=$r36['serverid'];$this->nc4($r36['customfields'],'custom field');$this->nc4($r36['configoptions'],'configurable option');if(!isset($this->r4c[$this->ra4])){$this->rda('No daemon list for location '.$this->ra4.'. Setting to default location.');$this->ra4='_default_';}if(!$this->rc9)return $this->n7c('Invalid service plan');if(!$this->rca)return $this->n7c('Invalid client: '.$this->rca);$this->n19();$this->r49['email']=$r36['clientsdetails']['email'];if(strlen($this->r49['username'])){$r41=mysql_query('select count(*) from `tblhosting` where `userid`!='.mysql_real_escape_string($this->rca).' and `username`=''.mysql_real_escape_string($this->r49['username']).'' and `server`='.'(select `server` from `tblhosting` where `id`='.mysql_real_escape_string($this->r7f).')');if($r41){$r4a=mysql_fetch_row($r41);mysql_free_result($r41);if((int)@$r4a[0]>0)return $this->n7c('The username "'.$this->r49['username'].'" is already in use by another client.');}}if(!strlen($this->r49['username']))$this->r49['username']=$r36['username'];if(!strlen($this->r49['username']))$this->r49['username']=$this->r49['email'];if(!strlen($this->r49['username']))return $this->n7c('No Minecraft username supplied (tried using the email address but that's empty as well).');if(!$this->rd0['slots'])return $this->n7c('Number of slots not specified for service plan '.$this->rc9);if(!$this->rd0['ram'])return $this->n7c('Amount of RAM not specified for service plan '.$this->rc9);$this->r2c($r36,false);if($this->rfd&&!$rf9){return $this->n7c('Server ID already set (service "Domain" field). Please make sure that'.' the service has not yet been set up and clear the ID.');}$this->rda('Verified data for client '.$this->rca.', service '.$this->r7f.', plan '.$this->rc9.': Username "'.$this->r49['username'].'", slots '.$this->rd0['slots'].', RAM '.$this->rd0['ram']);$r41=mysql_query('select `password` from `tblhosting` where `userid`='.mysql_real_escape_string($this->rca).' and `username`=''.mysql_real_escape_string($this->r49['username']).'' and `server`='.'(select `server` from `tblhosting` where `id`='.mysql_real_escape_string($this->r7f).')');if($r41){$r4a=mysql_fetch_row($r41);mysql_free_result($r41);$r6a=decrypt((string)@$r4a[0]);$this->r49['password']=$r6a;if(strlen($r6a))$this->rda('Got password from database.');}if(!strlen($this->r49['password']))$this->r49['password']=$r36['password'];if(!strlen($this->r49['password'])){$this->r49['password']=substr(md5(rand()),0,8);$this->rda('Generated new password: '.$this->r49['password']);}else $this->rda('Got existing password: '.$this->r49['password']);return true;}function ra0(){$r28a=$this->rd0['ip'].':'.$this->rd0['port'];$this->rda('Setting IP of '.$this->r7f.' to '.$r28a);$r41=mysql_query('update `tblhosting` set `dedicatedip`=''.mysql_real_escape_string($r28a).'','.' `domain`=''.mysql_real_escape_string($this->rfd).'''.' where `id`='.mysql_real_escape_string($this->r7f));if(!$r41)return $this->n7c('Failed to set server IP and ID: '.mysql_error());if($this->r35){$r41=mysql_query('update `tblservers` set `assignedips`=''.mysql_real_escape_string($this->r21).'''.' where `id`='.mysql_real_escape_string($this->r7b));if(!$r41)$this->n7c('Warning: Failed to add/remove IP from "Assigned IP Addresses"!');}return true;}function nbf($r9b){$r41=$this->r3c->getConnectionMemory($r9b,$this->rd0['includeSuspended']);if(!$r41['success'])$this->rda('Error getting memory information for daemon '.$r9b.': '.$this->n5d($r41));$r50=0;$rb5=@$r41['data']['used'];$r506=@$r41['data']['total'];if(!$r506){$this->rda('Daemon '.$r9b.' has no available memory amount set.');$r50=$this->rd0['ram'];}else $r50=$r506-$rb5;$r41=$this->r3c->listServersByConnection($r9b);if(!$r41['success'])return $this->rda('Error getting servers for daemon '.$r9b.': '.$this->n5d($r41));$list=$r41['data']['Servers'];return array('count'=>count($list),'freeRam'=>$r50,'usedRam'=>$rb5,'totalRam'=>$r506);}function r4b8(){$r41=$this->r3c->listConnections();if(!$r41['success'])$this->n7c('Error getting connections: '.$this->n5d($r41));$rca9=$r41['data']['Daemons'];$rd8=$this->r4c[$this->ra4];if(count($rd8))$this->rda('Allowed daemons'.($this->ra4!='_default_'?' for location '.$this->ra4:'').': '.implode(', ',$rd8));$r9b=0;$max=$this->rd0['maxPerDaemon'];foreach($rca9 as $r4bb=>$r01e){if(count($rd8)&&!in_array($r4bb,$rd8)){$this->rda('Skipping daemon '.$r4bb.'. Not in allowed daemon list.');continue;}if($this->rd0['dedip']=='Yes'&&!@$this->rec[$r4bb]){$this->rda('Skipping daemon '.$r4bb.'. Dedicated IP requested but none available for this daemon.');continue;}$r1e=$this->nbf($r4bb);if($r1e['freeRam']<$this->rd0['ram']){$this->rda('Skipping daemon '.$r4bb.'. Memory used: '.$r1e['usedRam'].'/'.$r1e['totalRam'].', free: '.$r1e['freeRam'].', requested: '.$this->rd0['ram']);continue;}$count=$r1e['count'];if($max&&$count>=$max){$this->rda('Skipping daemon '.$r4bb.'. Servers: '.$count.'/'.$max);continue;}$r9b=$r4bb;break;}if(!$r9b)return $this->n7c('No suitable daemon found!'.(count($this->rd9)?' ('.@end($this->rd9).')':''));$this->rd0['daemonId']=$r9b;$this->rd0['port']='';$this->rda('Creating server on daemon '.$this->rd0['daemonId']);return true;}function r8b(){$r7b8=@preg_split('/\s+/',$this->r21);$r2b=array();for($r9e=0;$r9e<count($r7b8);$r9e++){$re9=explode(',',$r7b8[$r9e]);$r05=false;if(count($re9)<2)$re9=@$re9[0];else{$r05=(int)$re9[0];$re9=$re9[1];}if(!strlen($re9)){continue;}if($r05===false||$r05==$this->rd0['daemonId']){$re4=$re9;$r2b[]=$r9e;break;}}if($this->rd0['dedip']=='No'){$this->rda('Not assigning dedicated IP.');return true;}else if($this->rd0['dedip']=='Yes')$this->rda('Requiring dedicated IP.');else $this->rda('Getting server IP');foreach(array_reverse($r2b)as $r0c)unset($r7b8[$r0c]);if(strlen($re4)){$this->r35=true;$this->r21=implode('
',$r7b8);$this->rda('Using IP from "Assigned IP Addresses" list: '.$re4);$re4=explode(':',$re4);if(count($re4)==2)$this->rd0['port']=$re4[1];$this->rd0['ip']=@$re4[0];}else if($this->rd0['dedip']=='Yes')return $this->n7c('No dedicated IP available on daemon '.$this->rd0['daemonId'].'!');return true;}function n55(){$r41=mysql_query('update `tblhosting` set `username`=''.mysql_real_escape_string($this->r49['username']).'','.' `password`=''.mysql_real_escape_string(encrypt($this->r49['password'])).'''.' where `id`='.mysql_real_escape_string($this->r7f));if(!$r41)return $this->n7c('Failed to set service user/pass: '.mysql_error());return true;}function createUser(){if(!strlen($this->r49['email']))return $this->n7c('No email address found, aborting.');$r41=$this->r3c->findUsers('email','='.$this->r49['email']);if(!$r41['success'])return $this->n7c('Error finding user by mail "'.$this->r49['email'].'": '.$this->n5d($r41));$r86=$r41['data']['Users'];$this->r06=0;foreach($r86 as $rff=>$rfc){$this->r06=$rff;$this->r49['username']=$rfc;$this->rda('Found user "'.$rfc.'" ('.$rff.') with same email ('.$this->r49['email'].'). Reusing.');return $this->n55();}$r41=$this->r3c->createUser($this->r49['username'],$this->r49['email'],$this->r49['password']);if(!$r41['success'])return $this->n7c('Error creating user "'.$this->r49['username'].'": '.$this->n5d($r41));$this->r06=$r41['data']['id'];$this->rda('Created user '.$this->r06);return $this->n55();}function createServer(){$r0b=preg_replace('/[^-_\w\d .!()]/','_',$this->r49['username']);$r41=$this->r3c->createServer($this->r49['username'].''s Minecraft Server',25564,$r0b.'_'.$this->rd0['port'],$this->rd0['slots']);$rff=0;if(!$r41['success']||!($rff=$r41['data']['id']))return $this->n7c('Error creating server: '.$this->n5d($r41));$this->rda('Created server '.$rff);$r15=array('No Access'=>0,'Guest'=>10,'User'=>20,'Moderator'=>30);$r51=@$r15[$this->rd0['default_role']];if(!$r51)$r51=0;$rc4=array('Owner only'=>0,'By Default Role'=>1,'Users with Roles only'=>2);$rc7=@$rc4[$this->rd0['visibility']];if(!$rc7)$rc7=0;$r41=$this->r3c->findServers('dir','=server'.$rff);if(@count($r41['data']['Servers']))$r0b=$r0b.'_'.$rff;else $r0b='server'.$rff;$r41=$this->r3c->updateServer($rff,array('daemon_id','memory','jarfile','jardir','default_level','ip','port','dir',),array($this->rd0['daemonId'],$this->rd0['ram'],$this->rd0['jarfile'],$this->rd0['jardir'],$r51,$this->rd0['ip'],$this->rd0['port'],$r0b,));if(!$r41['success'])return $this->n7c('Failed to update server: '.$this->n5d($r41));$r41=$this->r3c->updateServerConfig($rff,array('user_jar','user_name','user_schedule','user_ftp','user_visibility','visible',),array($this->rd0['user_jar'],$this->rd0['user_name'],$this->rd0['user_tasks'],$this->rd0['user_ftp'],$this->rd0['user_visibility'],$rc7,));if(!$r41['success'])return $this->n7c('Failed to update server config: '.$this->n5d($r41));$this->r3c->setServerOwner($rff,$this->r06);$r41=$this->r3c->getServer($rff);if(!$r41['success'])return $this->n7c('Error getting new server information for server'.$rff.': '.$this->n5d($r41));$this->rd0['port']=@$r41['data']['Server']['port'];$this->rd0['ip']=@$r41['data']['Server']['ip'];if($this->rd0['ftp'])$this->r3c->setUserFtpAccess($this->r06,$rff,'rw');if($this->rd0['start'])$this->r3c->startServer($rff);$this->rfd=$rff;$this->rda('Server '.$this->rfd.' configured'.($this->rd0['start']?' and started':''));return true;}function createPlayer(){$r41=$this->r3c->createPlayer($this->rfd,$this->r49['username']);if(!$r41['success'])return $this->rda('Error creating player for server '.$this->rfd.': '.$this->n5d($r41));$r0a=$r41['data']['id'];$this->r3c->assignPlayerToUser($r0a,$this->r06);$this->rda('Created player '.$r0a);return true;}function r2c($r36,$n7c=true){$this->rca=$r36['clientsdetails']['userid'];$this->r7f=$r36['serviceid'];$r41=mysql_query('select `domain` from `tblhosting` where `id`='.mysql_real_escape_string($this->r7f));if($r41){$r4a=mysql_fetch_row($r41);mysql_free_result($r41);$this->rfd=(int)$r4a[0];}if(!$this->rfd&&$n7c)return $this->n7c('No server for service '.$this->r7f.'!');return true;}function r74($r36){$this->r7b=$r36['serverid'];$this->r2c($r36);return true;}function r8f(){$this->rda('Terminating server '.$this->rfd.'. '.($this->ra7?'Deleting':'Not deleting').' Worlds.');$r41=$this->r3c->getServer($this->rfd);if(!$r41['success'])return $this->n7c('Error getting current server information for server'.$this->rfd.': '.$this->n5d($r41));$reca=@$r41['data']['Server']['daemon_id'];$rd6=@$r41['data']['Server']['port'];$rf1=@$r41['data']['Server']['ip'];if($this->ra7){$r41=$this->r3c->stopServer($this->rfd);if(!$r41['success']){$this->rda('Warning: Failed to stop server '.$this->rfd.' (worlds will not get deleted): '.$this->n5d($r41));}}$r68=$this->r7c;for($r9e=0;$r9e<$r68;$r9e++){$r41=$this->r3c->deleteServer($this->rfd,$this->ra7?'yes':'no');if($r41['success'])break;$dir=@isset($r41['errors'][0]['deleteDir'][0])?$r41['errors'][0]['deleteDir'][0]:'';if(($r9e<($r68-1))&&@preg_match('/Server still running/',$dir)){$this->rda('Server still running, waiting for one second');sleep(1);}else return $this->n7c('Failed to terminate server '.$this->rfd.': '.$this->n5d($r41));}if($rf1&&$rf1!='0.0.0.0'){$this->n19();if($this->rbe($reca,$rf1,$rd6)&&$this->rcb($reca,$rf1,$rd6)){$r41=mysql_query('update `tblservers` set `assignedips`=''.mysql_real_escape_string($this->r21).'''.' where `id`='.mysql_real_escape_string($this->r7b));if(!$r41)$this->n7c('Warning: Failed to add IP '.$rf1.':'.$rd6.' back to "Assigned IP Addresses"!');}}else $this->rda('IP '.$rf1.' won't be written back');return true;}function r7f8($r36){if(!strlen($r36['username']))return $this->n7c('No username specified');$r41=mysql_query('update tblhosting set password=''.mysql_real_escape_string(encrypt($r36['password'])).'''.' where userid='.mysql_real_escape_string($r36['clientsdetails']['userid']).' and server='.mysql_real_escape_string($r36['serverid']).' and username=''.mysql_real_escape_string($r36['username']).''');if(!$r41)$this->rda('Failed to update other services using the same Multicraft user: '.mysql_error());$r41=$this->r3c->findUsers('name','='.$r36['username']);if(!$r41['success'])return $this->n7c('Error finding user "'.$r36['username'].'": '.$this->n5d($r41));$r86=$r41['data']['Users'];if(count($r86)!==1)return $this->n7c('No exact match for user search "'.$r36['username'].'"');$this->r06=0;foreach($r86 as $rff=>$rfc){$this->r06=$rff;$this->rda('Found user "'.$rfc.'": '.$rff);break;}if(!$this->r06)return $this->n7c('Unable to find Multicraft user "'.$r36['username'].'" for updating');$r41=$this->r3c->updateUser($this->r06,'password',$r36['password']);if(!$r41['success'])return $this->n7c('Error updating user password: '.$this->n5d($r41));return true;}function r62(){$r41=$this->r3c->getServer($this->rfd);if(!$r41['success'])return $this->n7c('Error getting current server information for server'.$this->rfd.': '.$this->n5d($r41));$rf5=@$r41['data']['Server']['memory'];$reca=@$r41['data']['Server']['daemon_id'];$rd6=@$r41['data']['Server']['port'];$rf1=@$r41['data']['Server']['ip'];$this->rd0['daemonId']=$reca;$this->rd0['port']=$rd6;$this->updateServer();$rbe=$this->rbe($reca,$rf1,$rd6);if($this->rd0['daemonId']!=$reca||($this->rd0['dedip']=='Yes'&&!$rbe)||($this->rd0['dedip']=='No'&&$rbe)){$this->n19();if(!$this->r8b())return false;if($rbe)$this->rcb($reca,$rf1,$rd6);$r41=$this->r3c->updateServer($this->rfd,array('ip','port',),array($this->rd0['ip'],$this->rd0['port'],));if(!$r41['success'])return $this->n7c('Failed to set new server IP: '.$this->n5d($r41));$r41=$this->r3c->getServer($this->rfd);if(!$r41['success'])return $this->n7c('Error getting new server information for server'.$this->rfd.': '.$this->n5d($r41));$this->rd0['port']=@$r41['data']['Server']['port'];$this->rd0['ip']=@$r41['data']['Server']['ip'];if(!$this->ra0())return false;}if($this->rd0['daemonId']!=$reca){$r41=$this->r3c->sendServerControl($this->rfd,'migrate '.$this->rd0['daemonId']);if(!$r41['success'])$this->n7c('Server migrate command failed for server '.$this->rfd.': '.$this->n5d($r41));$this->rda('Server migrate command sent to daemon '.$reca.', moving to daemon '.$this->rd0['daemonId']);}return true;}function rbe($r05,$re4,$r90){$this->rda('Checking for dedicated IP: '.$re4);$r41=$this->r3c->getConnection($r05);if(!$r41['success'])return $this->n7c('Error getting daemon '.$r05.': '.$this->n5d($r41));$r2d=$r41['data']['Daemon']['ip'];if(strlen($re4)&&$re4!='0.0.0.0'&&$r2d!=$re4){$this->rda('Dedicated IP.');return true;}$this->rda('No dedicated IP.');return false;}function rcb($r05,$re4,$r90){$this->rda('Recycling IP '.$re4);$this->r21.="
".$r05.','.$re4;$this->r35=true;$this->rda('IP '.$re4.' will be written back to assigned IPs list');return true;}function updateServer(){$this->rda('Updating server '.$this->rfd);$rff=$this->rfd;$r41=$this->r3c->updateServer($rff,array('memory','players',),array($this->rd0['ram'],$this->rd0['slots'],));if(!$r41['success'])return $this->n7c('Failed to update server: '.$this->n5d($r41));$r41=$this->r3c->updateServerConfig($rff,array('user_jar','user_name','user_schedule','user_ftp',),array($this->rd0['user_jar'],$this->rd0['user_name'],$this->rd0['user_tasks'],$this->rd0['user_ftp'],));if(!$r41['success'])return $this->n7c('Failed to update server config: '.$this->n5d($r41));if($this->rd0['ftp'])$this->r3c->setUserFtpAccess($this->r06,$rff,'rw');else $this->r3c->setUserFtpAccess($this->r06,$rff,'');$this->rda('Server '.$this->rfd.' re-configured');return true;}}function multicraft_ConfigOptions(){return array('Minecraft Server Slots'=>array('Type'=>'text','Size'=>'20','Description'=>'',),'Minecraft Server RAM'=>array('Type'=>'text','Size'=>'20','Description'=>'',),'JAR file'=>array('Type'=>'text','Options'=>'','Description'=>'empty for default',),'Look for JARs in'=>array('Type'=>'dropdown','Options'=>'Daemon JAR directory,Server JAR directory','Description'=>'',),'Owner Selectable JAR'=>array('Type'=>'dropdown','Options'=>'No,Yes','Description'=>'',),'Owner changeable Servername'=>array('Type'=>'dropdown','Options'=>'Yes,No','Description'=>'',),'Owner Scheduled Tasks'=>array('Type'=>'dropdown','Options'=>'Yes,No','Description'=>'',),'Owner Managed FTP'=>array('Type'=>'dropdown','Options'=>'No,Yes','Description'=>'',),'Owner changeable Visibility'=>array('Type'=>'dropdown','Options'=>'Yes,No','Description'=>'',),'Default Role'=>array('Type'=>'dropdown','Options'=>'Guest,No Access,User,Moderator','Description'=>'"No Access" = whitelist',),'Server visible for'=>array('Type'=>'dropdown','Options'=>'By Default Role,Owner only,Users with Roles only','Description'=>'',),'Start Server'=>array('Type'=>'dropdown','Options'=>'Yes,No','Description'=>'',),'Dedicated IP'=>array('Type'=>'dropdown','Options'=>'No,If available,Yes','Description'=>'',),'Create FTP Account'=>array('Type'=>'dropdown','Options'=>'Yes,No','Description'=>'',),'Allowed Daemons'=>array('Type'=>'text','Size'=>'20','Description'=>'empty for all',),'Max Servers per Daemon'=>array('Type'=>'text','Size'=>'20','Description'=>'empty for unlimited',),'Calculate used RAM'=>array('Type'=>'dropdown','Options'=>'Include suspended,Exclude suspended','Description'=>'',),'Delete Worlds on Terminate'=>array('Type'=>'dropdown','Options'=>'No,Yes','Description'=>'',),'Enable Log Mails'=>array('Type'=>'dropdown','Options'=>'Only on Errors,Yes,No','Description'=>'',),'Log Mail Recipient'=>array('Type'=>'text','Size'=>'20','Description'=>'',),);}function multicraft_CreateAccount($r36){$r95=new n0d;return $r95->install($r36);}function multicraft_TerminateAccount($r36){$r95=new n0d;return $r95->n3a($r36);}function multicraft_SuspendAccount($r36){$r95=new n0d;return $r95->n2f($r36);}function multicraft_UnsuspendAccount($r36){$r95=new n0d;return $r95->n12($r36);}function multicraft_ChangePassword($r36){$r95=new n0d;return $r95->nd8($r36);}function multicraft_ChangePackage($r36){$r95=new n0d;return $r95->n21($r36);}function multicraft_ClientArea($r36){return '<form action="'.$r36['serverhostname'].'/index.php?r=site/login" method="post" target="_blank">
<input type="hidden" value="'.$r36['username'].'" name="LoginForm[name]" id="LoginForm_name" />
<input type="hidden" value="'.$r36['password'].'" name="LoginForm[password]" id="LoginForm_password" />
<input style="width: 180px" type="submit" name="yt0" value="Multicraft Login" />
</form>';}function multicraft_AdminLink($r36){return '<form action="'.$r36['serverhostname'].'/index.php?r=site/login" method="post" target="_blank">
<input type="hidden" value="'.$r36['serverusername'].'" name="LoginForm[name]" id="LoginForm_name" />
<input type="hidden" value="'.$r36['serverpassword'].'" name="LoginForm[password]" id="LoginForm_password" />
<input style="width: 180px" type="submit" name="yt0" value="Multicraft Login" />
</form>';}function multicraft_LoginLink($r36){echo '<a href="'.$r36['serverhostname'].'/index.php?r=site/login&name='.$r36['username'].'" target="_blank" style="color:#cc0000">Login to Multicraft</a>';}function multicraft_AdminCustomButtonArray(){return array('Start Server'=>'start','Stop Server'=>'stop','Restart Server'=>'restart',);}function multicraft_start($r36){$r95=new n0d;return $r95->n97($r36,'start');}function multicraft_stop($r36){$r95=new n0d;return $r95->n97($r36,'stop');}function multicraft_restart($r36){$r95=new n0d;return $r95->n97($r36,'restart');} ?>
Did this file decode correctly?
Original Code
<?php
/**
* Encoded using the xhost.ch PHP encoder, no special decoding module required.
* Visit http://phpenc.xhost.ch
**/
?><?php eval(base64_decode('aWYoIWZ1bmN0aW9uX2V4aXN0cygnX19waHBlbmNfc19mdW5jJykpe2Z1bmN0aW9uIF9fcGhwZW5jX3NfZnVuYygkcyl7cmV0dXJuIGV2YWwoJ3JldHVybiAnLmJhc2U2NF9kZWNvZGUodXJsZGVjb2RlKCRzKSkuJzsnKTt9fQ=='));?><?php if(!class_exists('MulticraftAPI'))require('MulticraftAPI.php');class n0d{var $r3c;var $r49=array();var $rd0=array();var $rca;var $r7f;var $rc9;var $r06;var $rfd;var $rd9=array();var $r24=false;var $rb6=false;var $rae=false;var $r98=false;var $rdb='';var $rf2='localhost';var $r37;var $ra7=false;var $r7c=10;var $r35=false;var $r21='';var $rec=array();var $r7b=0;var $r4c=array();var $ra4='_default_';function n7c($r03){$this->r24=true;$this->rda($r03);return false;}function rda($r38){$this->rd9[]=$r38;return false;}function log(){if($this->rae&&($this->r98||$this->r24)&&strlen($this->rdb)){$r4b=$this->rf2;$r28='From: '.$r4b.'
Reply-To: '.$r4b;@mail($this->rdb,($this->r24?'FAILED':'SUCCESS').': Multicraft Module: '.$this->r37,implode($this->rd9,'
'));}}function n5d($r41){if(!isset($r41['errors']))return 'Empty response';if(!is_array($r41['errors'])){if(!@strlen($r41['errors']))return 'Empty error string';return(string)$r41['errors'];}$r8a='';foreach($r41['errors']as $r14){if(strlen($r8a))$r8a.=', ';$r8a.=print_r($r14,true);}return $r8a;}function n90($r36){$this->rd0['slots']=(int)$r36['configoption1'];$this->rd0['ram']=(int)$r36['configoption2'];$this->rd0['jarfile']=$r36['configoption3'];$this->rd0['jardir']=($r36['configoption4']==='Server JAR directory')?'server':'daemon';$this->rd0['user_jar']=($r36['configoption5']==='Yes');$this->rd0['user_name']=($r36['configoption6']==='Yes');$this->rd0['user_tasks']=($r36['configoption7']==='Yes');$this->rd0['user_ftp']=($r36['configoption8']==='Yes');$this->rd0['user_visibility']=($r36['configoption9']==='Yes');$this->rd0['default_role']=$r36['configoption10'];$this->rd0['visibility']=$r36['configoption11'];$this->rd0['start']=($r36['configoption12']==='Yes');$this->rd0['dedip']=$r36['configoption13'];$this->rd0['ftp']=($r36['configoption14']==='Yes');$rd8=array_map('trim',explode(',',$r36['configoption15']));$this->rd0['maxPerDaemon']=(int)$r36['configoption16'];$this->rd0['includeSuspended']=($r36['configoption17']==='Include suspended')?1:0;$this->ra7=($r36['configoption18']==='Yes');$this->rae=($r36['configoption19']!='No');$this->r98=($r36['configoption19']=='Yes');$this->rdb=$r36['configoption20'];$ra73=$this->ra4;$this->r4c[$ra73]=array();foreach($rd8 as $r39){$rbd=array();if(preg_match('/([^:]+):(.*)/',$r39,$rbd)){$ra73=$rbd[1];$r39=$rbd[2];}if((int)$r39)$this->r4c[$ra73][]=(int)$r39;}$this->rd0['ip']='';$this->rd0['port']='';$this->rda('Multicraft Service Module v2.0 starting');$r41=mysql_query('select `hostname`, `username`, `accesshash` from `tblservers` where'.' `id`=(select `server` from `tblhosting` where `id`='.mysql_real_escape_string($r36['serviceid']).')');if(!$r41)return $this->n7c('Failed to get Multicraft API information: '.mysql_error());$r4a=mysql_fetch_row($r41);$this->r3c=new MulticraftAPI($r4a[0].'/api.php',$r4a[1],$r4a[2]);return true;}function n8c(){$this->rda('Locking '.__FILE__);$this->rb6=fopen(__FILE__,'rb');flock($this->rb6,LOCK_EX);}function n60(){if(!$this->rb6)return;flock($this->rb6,LOCK_UN);fclose($this->rb6);}function end(){$this->n60();$this->log();if(!$this->r24)return 'success';else return end($this->rd9);}function install($r36){$this->r37='Setup';if(!$this->n90($r36))return $this->end();$this->n8c();if(!$this->r60($r36)||!$this->r4b8()||!$this->r8b()||!$this->createUser()||!$this->createServer()||!$this->ra0())return $this->end();$this->n60();$this->createPlayer();return $this->end();}function n3a($r36){$this->r37='Terminate';if(!$this->n90($r36))return $this->end();if(!$this->r74($r36))return $this->end();$this->r8f();return $this->end();}function n2f($r36){$this->r37='Suspend';if(!$this->n90($r36))return $this->end();if(!$this->r2c($r36))return $this->end();$this->rda('Suspending server '.$this->rfd);$r41=$this->r3c->suspendServer($this->rfd);if(!$r41['success'])$this->n7c('Failed to suspend server '.$this->rfd.': '.$this->n5d($r41));return $this->end();}function n12($r36){$this->r37='Unsuspend';if(!$this->n90($r36))return $this->end();if(!$this->r2c($r36))return $this->end();$this->rda('Unsuspending server '.$this->rfd);$r41=$this->r3c->resumeServer($this->rfd);if(!$r41['success'])$this->n7c('Failed to unsuspend server '.$this->rfd.': '.$this->n5d($r41));return $this->end();}function n97($r36,$r37){$this->r37='Server '.$r37;if(!$this->n90($r36))return $this->end();if(!$this->r2c($r36))return $this->end();$rce=false;switch($r37){case 'start':$rce='startServer';break;case 'stop':$rce='stopServer';break;case 'restart':$rce='restartServer';break;default:$this->n7c('Unhandled action "'.$r37.'"');}if($rce){$this->rda('Server '.$this->rfd.': '.$r37);$r41=$this->r3c->$rce($this->rfd);if(!$r41['success'])$this->n7c('Failed to run '.$rce.' for server '.$this->rfd.': '.$this->n5d($r41));}return $this->end();}function nd8($r36){$this->r37='Change Password';if(!$this->n90($r36))return $this->end();$this->r7f8($r36);return $this->end();}function n21($r36){$this->r37='Change Package';if(!$this->n90($r36))return $this->end();$this->n8c();if(!$this->r60($r36,true))return $this->end();$this->r62();$this->n60();return $this->end();}function nc4($r01,$rd1){foreach($r01 as $rb3=>$re7){if(preg_match('/user/i',$rb3)){$this->r49['username']=trim($re7);$this->rda('Username set to "'.$this->r49['username'].'" from '.$rd1.' "'.$rb3.'".');}if(preg_match('/location/i',$rb3)){$this->ra4=trim($re7);$this->rda('Location set to "'.$this->ra4.'" from '.$rd1.' "'.$rb3.'".');}}}function n19(){$r41=mysql_query('select `assignedips` from `tblservers` where `id`='.mysql_real_escape_string($this->r7b));$re4='';if($r41){$r7b8=mysql_fetch_row($r41);mysql_free_result($r41);$this->r21=$r7b8[0];$r7b8=@preg_split('/\s+/',$r7b8[0]);for($r9e=0;$r9e<count($r7b8);$r9e++){$re9=explode(',',$r7b8[$r9e]);if(count($re9)<2)continue;$r05=(int)$re9[0];if($r05&&strlen($re9[1]))$this->rec[$r05]=true;}}}function r60($r36,$rf9=false){$this->rca=$r36['clientsdetails']['userid'];$this->r7f=$r36['serviceid'];$this->rc9=$r36['packageid'];$this->r7b=$r36['serverid'];$this->nc4($r36['customfields'],'custom field');$this->nc4($r36['configoptions'],'configurable option');if(!isset($this->r4c[$this->ra4])){$this->rda('No daemon list for location '.$this->ra4.'. Setting to default location.');$this->ra4='_default_';}if(!$this->rc9)return $this->n7c('Invalid service plan');if(!$this->rca)return $this->n7c('Invalid client: '.$this->rca);$this->n19();$this->r49['email']=$r36['clientsdetails']['email'];if(strlen($this->r49['username'])){$r41=mysql_query('select count(*) from `tblhosting` where `userid`!='.mysql_real_escape_string($this->rca).' and `username`=''.mysql_real_escape_string($this->r49['username']).'' and `server`='.'(select `server` from `tblhosting` where `id`='.mysql_real_escape_string($this->r7f).')');if($r41){$r4a=mysql_fetch_row($r41);mysql_free_result($r41);if((int)@$r4a[0]>0)return $this->n7c('The username "'.$this->r49['username'].'" is already in use by another client.');}}if(!strlen($this->r49['username']))$this->r49['username']=$r36['username'];if(!strlen($this->r49['username']))$this->r49['username']=$this->r49['email'];if(!strlen($this->r49['username']))return $this->n7c('No Minecraft username supplied (tried using the email address but that's empty as well).');if(!$this->rd0['slots'])return $this->n7c('Number of slots not specified for service plan '.$this->rc9);if(!$this->rd0['ram'])return $this->n7c('Amount of RAM not specified for service plan '.$this->rc9);$this->r2c($r36,false);if($this->rfd&&!$rf9){return $this->n7c('Server ID already set (service "Domain" field). Please make sure that'.' the service has not yet been set up and clear the ID.');}$this->rda('Verified data for client '.$this->rca.', service '.$this->r7f.', plan '.$this->rc9.': Username "'.$this->r49['username'].'", slots '.$this->rd0['slots'].', RAM '.$this->rd0['ram']);$r41=mysql_query('select `password` from `tblhosting` where `userid`='.mysql_real_escape_string($this->rca).' and `username`=''.mysql_real_escape_string($this->r49['username']).'' and `server`='.'(select `server` from `tblhosting` where `id`='.mysql_real_escape_string($this->r7f).')');if($r41){$r4a=mysql_fetch_row($r41);mysql_free_result($r41);$r6a=decrypt((string)@$r4a[0]);$this->r49['password']=$r6a;if(strlen($r6a))$this->rda('Got password from database.');}if(!strlen($this->r49['password']))$this->r49['password']=$r36['password'];if(!strlen($this->r49['password'])){$this->r49['password']=substr(md5(rand()),0,8);$this->rda('Generated new password: '.$this->r49['password']);}else $this->rda('Got existing password: '.$this->r49['password']);return true;}function ra0(){$r28a=$this->rd0['ip'].':'.$this->rd0['port'];$this->rda('Setting IP of '.$this->r7f.' to '.$r28a);$r41=mysql_query('update `tblhosting` set `dedicatedip`=''.mysql_real_escape_string($r28a).'','.' `domain`=''.mysql_real_escape_string($this->rfd).'''.' where `id`='.mysql_real_escape_string($this->r7f));if(!$r41)return $this->n7c('Failed to set server IP and ID: '.mysql_error());if($this->r35){$r41=mysql_query('update `tblservers` set `assignedips`=''.mysql_real_escape_string($this->r21).'''.' where `id`='.mysql_real_escape_string($this->r7b));if(!$r41)$this->n7c('Warning: Failed to add/remove IP from "Assigned IP Addresses"!');}return true;}function nbf($r9b){$r41=$this->r3c->getConnectionMemory($r9b,$this->rd0['includeSuspended']);if(!$r41['success'])$this->rda('Error getting memory information for daemon '.$r9b.': '.$this->n5d($r41));$r50=0;$rb5=@$r41['data']['used'];$r506=@$r41['data']['total'];if(!$r506){$this->rda('Daemon '.$r9b.' has no available memory amount set.');$r50=$this->rd0['ram'];}else $r50=$r506-$rb5;$r41=$this->r3c->listServersByConnection($r9b);if(!$r41['success'])return $this->rda('Error getting servers for daemon '.$r9b.': '.$this->n5d($r41));$list=$r41['data']['Servers'];return array('count'=>count($list),'freeRam'=>$r50,'usedRam'=>$rb5,'totalRam'=>$r506);}function r4b8(){$r41=$this->r3c->listConnections();if(!$r41['success'])$this->n7c('Error getting connections: '.$this->n5d($r41));$rca9=$r41['data']['Daemons'];$rd8=$this->r4c[$this->ra4];if(count($rd8))$this->rda('Allowed daemons'.($this->ra4!='_default_'?' for location '.$this->ra4:'').': '.implode(', ',$rd8));$r9b=0;$max=$this->rd0['maxPerDaemon'];foreach($rca9 as $r4bb=>$r01e){if(count($rd8)&&!in_array($r4bb,$rd8)){$this->rda('Skipping daemon '.$r4bb.'. Not in allowed daemon list.');continue;}if($this->rd0['dedip']=='Yes'&&!@$this->rec[$r4bb]){$this->rda('Skipping daemon '.$r4bb.'. Dedicated IP requested but none available for this daemon.');continue;}$r1e=$this->nbf($r4bb);if($r1e['freeRam']<$this->rd0['ram']){$this->rda('Skipping daemon '.$r4bb.'. Memory used: '.$r1e['usedRam'].'/'.$r1e['totalRam'].', free: '.$r1e['freeRam'].', requested: '.$this->rd0['ram']);continue;}$count=$r1e['count'];if($max&&$count>=$max){$this->rda('Skipping daemon '.$r4bb.'. Servers: '.$count.'/'.$max);continue;}$r9b=$r4bb;break;}if(!$r9b)return $this->n7c('No suitable daemon found!'.(count($this->rd9)?' ('.@end($this->rd9).')':''));$this->rd0['daemonId']=$r9b;$this->rd0['port']='';$this->rda('Creating server on daemon '.$this->rd0['daemonId']);return true;}function r8b(){$r7b8=@preg_split('/\s+/',$this->r21);$r2b=array();for($r9e=0;$r9e<count($r7b8);$r9e++){$re9=explode(',',$r7b8[$r9e]);$r05=false;if(count($re9)<2)$re9=@$re9[0];else{$r05=(int)$re9[0];$re9=$re9[1];}if(!strlen($re9)){continue;}if($r05===false||$r05==$this->rd0['daemonId']){$re4=$re9;$r2b[]=$r9e;break;}}if($this->rd0['dedip']=='No'){$this->rda('Not assigning dedicated IP.');return true;}else if($this->rd0['dedip']=='Yes')$this->rda('Requiring dedicated IP.');else $this->rda('Getting server IP');foreach(array_reverse($r2b)as $r0c)unset($r7b8[$r0c]);if(strlen($re4)){$this->r35=true;$this->r21=implode('
',$r7b8);$this->rda('Using IP from "Assigned IP Addresses" list: '.$re4);$re4=explode(':',$re4);if(count($re4)==2)$this->rd0['port']=$re4[1];$this->rd0['ip']=@$re4[0];}else if($this->rd0['dedip']=='Yes')return $this->n7c('No dedicated IP available on daemon '.$this->rd0['daemonId'].'!');return true;}function n55(){$r41=mysql_query('update `tblhosting` set `username`=''.mysql_real_escape_string($this->r49['username']).'','.' `password`=''.mysql_real_escape_string(encrypt($this->r49['password'])).'''.' where `id`='.mysql_real_escape_string($this->r7f));if(!$r41)return $this->n7c('Failed to set service user/pass: '.mysql_error());return true;}function createUser(){if(!strlen($this->r49['email']))return $this->n7c('No email address found, aborting.');$r41=$this->r3c->findUsers('email','='.$this->r49['email']);if(!$r41['success'])return $this->n7c('Error finding user by mail "'.$this->r49['email'].'": '.$this->n5d($r41));$r86=$r41['data']['Users'];$this->r06=0;foreach($r86 as $rff=>$rfc){$this->r06=$rff;$this->r49['username']=$rfc;$this->rda('Found user "'.$rfc.'" ('.$rff.') with same email ('.$this->r49['email'].'). Reusing.');return $this->n55();}$r41=$this->r3c->createUser($this->r49['username'],$this->r49['email'],$this->r49['password']);if(!$r41['success'])return $this->n7c('Error creating user "'.$this->r49['username'].'": '.$this->n5d($r41));$this->r06=$r41['data']['id'];$this->rda('Created user '.$this->r06);return $this->n55();}function createServer(){$r0b=preg_replace('/[^-_\w\d .!()]/','_',$this->r49['username']);$r41=$this->r3c->createServer($this->r49['username'].''s Minecraft Server',25564,$r0b.'_'.$this->rd0['port'],$this->rd0['slots']);$rff=0;if(!$r41['success']||!($rff=$r41['data']['id']))return $this->n7c('Error creating server: '.$this->n5d($r41));$this->rda('Created server '.$rff);$r15=array('No Access'=>0,'Guest'=>10,'User'=>20,'Moderator'=>30);$r51=@$r15[$this->rd0['default_role']];if(!$r51)$r51=0;$rc4=array('Owner only'=>0,'By Default Role'=>1,'Users with Roles only'=>2);$rc7=@$rc4[$this->rd0['visibility']];if(!$rc7)$rc7=0;$r41=$this->r3c->findServers('dir','=server'.$rff);if(@count($r41['data']['Servers']))$r0b=$r0b.'_'.$rff;else $r0b='server'.$rff;$r41=$this->r3c->updateServer($rff,array('daemon_id','memory','jarfile','jardir','default_level','ip','port','dir',),array($this->rd0['daemonId'],$this->rd0['ram'],$this->rd0['jarfile'],$this->rd0['jardir'],$r51,$this->rd0['ip'],$this->rd0['port'],$r0b,));if(!$r41['success'])return $this->n7c('Failed to update server: '.$this->n5d($r41));$r41=$this->r3c->updateServerConfig($rff,array('user_jar','user_name','user_schedule','user_ftp','user_visibility','visible',),array($this->rd0['user_jar'],$this->rd0['user_name'],$this->rd0['user_tasks'],$this->rd0['user_ftp'],$this->rd0['user_visibility'],$rc7,));if(!$r41['success'])return $this->n7c('Failed to update server config: '.$this->n5d($r41));$this->r3c->setServerOwner($rff,$this->r06);$r41=$this->r3c->getServer($rff);if(!$r41['success'])return $this->n7c('Error getting new server information for server'.$rff.': '.$this->n5d($r41));$this->rd0['port']=@$r41['data']['Server']['port'];$this->rd0['ip']=@$r41['data']['Server']['ip'];if($this->rd0['ftp'])$this->r3c->setUserFtpAccess($this->r06,$rff,'rw');if($this->rd0['start'])$this->r3c->startServer($rff);$this->rfd=$rff;$this->rda('Server '.$this->rfd.' configured'.($this->rd0['start']?' and started':''));return true;}function createPlayer(){$r41=$this->r3c->createPlayer($this->rfd,$this->r49['username']);if(!$r41['success'])return $this->rda('Error creating player for server '.$this->rfd.': '.$this->n5d($r41));$r0a=$r41['data']['id'];$this->r3c->assignPlayerToUser($r0a,$this->r06);$this->rda('Created player '.$r0a);return true;}function r2c($r36,$n7c=true){$this->rca=$r36['clientsdetails']['userid'];$this->r7f=$r36['serviceid'];$r41=mysql_query('select `domain` from `tblhosting` where `id`='.mysql_real_escape_string($this->r7f));if($r41){$r4a=mysql_fetch_row($r41);mysql_free_result($r41);$this->rfd=(int)$r4a[0];}if(!$this->rfd&&$n7c)return $this->n7c('No server for service '.$this->r7f.'!');return true;}function r74($r36){$this->r7b=$r36['serverid'];$this->r2c($r36);return true;}function r8f(){$this->rda('Terminating server '.$this->rfd.'. '.($this->ra7?'Deleting':'Not deleting').' Worlds.');$r41=$this->r3c->getServer($this->rfd);if(!$r41['success'])return $this->n7c('Error getting current server information for server'.$this->rfd.': '.$this->n5d($r41));$reca=@$r41['data']['Server']['daemon_id'];$rd6=@$r41['data']['Server']['port'];$rf1=@$r41['data']['Server']['ip'];if($this->ra7){$r41=$this->r3c->stopServer($this->rfd);if(!$r41['success']){$this->rda('Warning: Failed to stop server '.$this->rfd.' (worlds will not get deleted): '.$this->n5d($r41));}}$r68=$this->r7c;for($r9e=0;$r9e<$r68;$r9e++){$r41=$this->r3c->deleteServer($this->rfd,$this->ra7?'yes':'no');if($r41['success'])break;$dir=@isset($r41['errors'][0]['deleteDir'][0])?$r41['errors'][0]['deleteDir'][0]:'';if(($r9e<($r68-1))&&@preg_match('/Server still running/',$dir)){$this->rda('Server still running, waiting for one second');sleep(1);}else return $this->n7c('Failed to terminate server '.$this->rfd.': '.$this->n5d($r41));}if($rf1&&$rf1!='0.0.0.0'){$this->n19();if($this->rbe($reca,$rf1,$rd6)&&$this->rcb($reca,$rf1,$rd6)){$r41=mysql_query('update `tblservers` set `assignedips`=''.mysql_real_escape_string($this->r21).'''.' where `id`='.mysql_real_escape_string($this->r7b));if(!$r41)$this->n7c('Warning: Failed to add IP '.$rf1.':'.$rd6.' back to "Assigned IP Addresses"!');}}else $this->rda('IP '.$rf1.' won't be written back');return true;}function r7f8($r36){if(!strlen($r36['username']))return $this->n7c('No username specified');$r41=mysql_query('update tblhosting set password=''.mysql_real_escape_string(encrypt($r36['password'])).'''.' where userid='.mysql_real_escape_string($r36['clientsdetails']['userid']).' and server='.mysql_real_escape_string($r36['serverid']).' and username=''.mysql_real_escape_string($r36['username']).''');if(!$r41)$this->rda('Failed to update other services using the same Multicraft user: '.mysql_error());$r41=$this->r3c->findUsers('name','='.$r36['username']);if(!$r41['success'])return $this->n7c('Error finding user "'.$r36['username'].'": '.$this->n5d($r41));$r86=$r41['data']['Users'];if(count($r86)!==1)return $this->n7c('No exact match for user search "'.$r36['username'].'"');$this->r06=0;foreach($r86 as $rff=>$rfc){$this->r06=$rff;$this->rda('Found user "'.$rfc.'": '.$rff);break;}if(!$this->r06)return $this->n7c('Unable to find Multicraft user "'.$r36['username'].'" for updating');$r41=$this->r3c->updateUser($this->r06,'password',$r36['password']);if(!$r41['success'])return $this->n7c('Error updating user password: '.$this->n5d($r41));return true;}function r62(){$r41=$this->r3c->getServer($this->rfd);if(!$r41['success'])return $this->n7c('Error getting current server information for server'.$this->rfd.': '.$this->n5d($r41));$rf5=@$r41['data']['Server']['memory'];$reca=@$r41['data']['Server']['daemon_id'];$rd6=@$r41['data']['Server']['port'];$rf1=@$r41['data']['Server']['ip'];$this->rd0['daemonId']=$reca;$this->rd0['port']=$rd6;$this->updateServer();$rbe=$this->rbe($reca,$rf1,$rd6);if($this->rd0['daemonId']!=$reca||($this->rd0['dedip']=='Yes'&&!$rbe)||($this->rd0['dedip']=='No'&&$rbe)){$this->n19();if(!$this->r8b())return false;if($rbe)$this->rcb($reca,$rf1,$rd6);$r41=$this->r3c->updateServer($this->rfd,array('ip','port',),array($this->rd0['ip'],$this->rd0['port'],));if(!$r41['success'])return $this->n7c('Failed to set new server IP: '.$this->n5d($r41));$r41=$this->r3c->getServer($this->rfd);if(!$r41['success'])return $this->n7c('Error getting new server information for server'.$this->rfd.': '.$this->n5d($r41));$this->rd0['port']=@$r41['data']['Server']['port'];$this->rd0['ip']=@$r41['data']['Server']['ip'];if(!$this->ra0())return false;}if($this->rd0['daemonId']!=$reca){$r41=$this->r3c->sendServerControl($this->rfd,'migrate '.$this->rd0['daemonId']);if(!$r41['success'])$this->n7c('Server migrate command failed for server '.$this->rfd.': '.$this->n5d($r41));$this->rda('Server migrate command sent to daemon '.$reca.', moving to daemon '.$this->rd0['daemonId']);}return true;}function rbe($r05,$re4,$r90){$this->rda('Checking for dedicated IP: '.$re4);$r41=$this->r3c->getConnection($r05);if(!$r41['success'])return $this->n7c('Error getting daemon '.$r05.': '.$this->n5d($r41));$r2d=$r41['data']['Daemon']['ip'];if(strlen($re4)&&$re4!='0.0.0.0'&&$r2d!=$re4){$this->rda('Dedicated IP.');return true;}$this->rda('No dedicated IP.');return false;}function rcb($r05,$re4,$r90){$this->rda('Recycling IP '.$re4);$this->r21.="\n".$r05.','.$re4;$this->r35=true;$this->rda('IP '.$re4.' will be written back to assigned IPs list');return true;}function updateServer(){$this->rda('Updating server '.$this->rfd);$rff=$this->rfd;$r41=$this->r3c->updateServer($rff,array('memory','players',),array($this->rd0['ram'],$this->rd0['slots'],));if(!$r41['success'])return $this->n7c('Failed to update server: '.$this->n5d($r41));$r41=$this->r3c->updateServerConfig($rff,array('user_jar','user_name','user_schedule','user_ftp',),array($this->rd0['user_jar'],$this->rd0['user_name'],$this->rd0['user_tasks'],$this->rd0['user_ftp'],));if(!$r41['success'])return $this->n7c('Failed to update server config: '.$this->n5d($r41));if($this->rd0['ftp'])$this->r3c->setUserFtpAccess($this->r06,$rff,'rw');else $this->r3c->setUserFtpAccess($this->r06,$rff,'');$this->rda('Server '.$this->rfd.' re-configured');return true;}}function multicraft_ConfigOptions(){return array('Minecraft Server Slots'=>array('Type'=>'text','Size'=>'20','Description'=>'',),'Minecraft Server RAM'=>array('Type'=>'text','Size'=>'20','Description'=>'',),'JAR file'=>array('Type'=>'text','Options'=>'','Description'=>'empty for default',),'Look for JARs in'=>array('Type'=>'dropdown','Options'=>'Daemon JAR directory,Server JAR directory','Description'=>'',),'Owner Selectable JAR'=>array('Type'=>'dropdown','Options'=>'No,Yes','Description'=>'',),'Owner changeable Servername'=>array('Type'=>'dropdown','Options'=>'Yes,No','Description'=>'',),'Owner Scheduled Tasks'=>array('Type'=>'dropdown','Options'=>'Yes,No','Description'=>'',),'Owner Managed FTP'=>array('Type'=>'dropdown','Options'=>'No,Yes','Description'=>'',),'Owner changeable Visibility'=>array('Type'=>'dropdown','Options'=>'Yes,No','Description'=>'',),'Default Role'=>array('Type'=>'dropdown','Options'=>'Guest,No Access,User,Moderator','Description'=>'"No Access" = whitelist',),'Server visible for'=>array('Type'=>'dropdown','Options'=>'By Default Role,Owner only,Users with Roles only','Description'=>'',),'Start Server'=>array('Type'=>'dropdown','Options'=>'Yes,No','Description'=>'',),'Dedicated IP'=>array('Type'=>'dropdown','Options'=>'No,If available,Yes','Description'=>'',),'Create FTP Account'=>array('Type'=>'dropdown','Options'=>'Yes,No','Description'=>'',),'Allowed Daemons'=>array('Type'=>'text','Size'=>'20','Description'=>'empty for all',),'Max Servers per Daemon'=>array('Type'=>'text','Size'=>'20','Description'=>'empty for unlimited',),'Calculate used RAM'=>array('Type'=>'dropdown','Options'=>'Include suspended,Exclude suspended','Description'=>'',),'Delete Worlds on Terminate'=>array('Type'=>'dropdown','Options'=>'No,Yes','Description'=>'',),'Enable Log Mails'=>array('Type'=>'dropdown','Options'=>'Only on Errors,Yes,No','Description'=>'',),'Log Mail Recipient'=>array('Type'=>'text','Size'=>'20','Description'=>'',),);}function multicraft_CreateAccount($r36){$r95=new n0d;return $r95->install($r36);}function multicraft_TerminateAccount($r36){$r95=new n0d;return $r95->n3a($r36);}function multicraft_SuspendAccount($r36){$r95=new n0d;return $r95->n2f($r36);}function multicraft_UnsuspendAccount($r36){$r95=new n0d;return $r95->n12($r36);}function multicraft_ChangePassword($r36){$r95=new n0d;return $r95->nd8($r36);}function multicraft_ChangePackage($r36){$r95=new n0d;return $r95->n21($r36);}function multicraft_ClientArea($r36){return '<form action="'.$r36['serverhostname'].'/index.php?r=site/login" method="post" target="_blank">
<input type="hidden" value="'.$r36['username'].'" name="LoginForm[name]" id="LoginForm_name" />
<input type="hidden" value="'.$r36['password'].'" name="LoginForm[password]" id="LoginForm_password" />
<input style="width: 180px" type="submit" name="yt0" value="Multicraft Login" />
</form>';}function multicraft_AdminLink($r36){return '<form action="'.$r36['serverhostname'].'/index.php?r=site/login" method="post" target="_blank">
<input type="hidden" value="'.$r36['serverusername'].'" name="LoginForm[name]" id="LoginForm_name" />
<input type="hidden" value="'.$r36['serverpassword'].'" name="LoginForm[password]" id="LoginForm_password" />
<input style="width: 180px" type="submit" name="yt0" value="Multicraft Login" />
</form>';}function multicraft_LoginLink($r36){echo '<a href="'.$r36['serverhostname'].'/index.php?r=site/login&name='.$r36['username'].'" target="_blank" style="color:#cc0000">Login to Multicraft</a>';}function multicraft_AdminCustomButtonArray(){return array('Start Server'=>'start','Stop Server'=>'stop','Restart Server'=>'restart',);}function multicraft_start($r36){$r95=new n0d;return $r95->n97($r36,'start');}function multicraft_stop($r36){$r95=new n0d;return $r95->n97($r36,'stop');}function multicraft_restart($r36){$r95=new n0d;return $r95->n97($r36,'restart');}
Function Calls
None |
Stats
MD5 | fe0b42de3af39893dcb4980ca856c317 |
Eval Count | 0 |
Decode Time | 123 ms |