diff --git a/Assemblies/Roblox/Grid/Rcc/Job.php b/Assemblies/Roblox/Grid/Rcc/Job.php new file mode 100644 index 0000000..83cafb2 --- /dev/null +++ b/Assemblies/Roblox/Grid/Rcc/Job.php @@ -0,0 +1,20 @@ +id = $id; + $this->expirationInSeconds = $expirationInSeconds; + $this->category = $category; + $this->cores = $cores; + } +} + +// EOF \ No newline at end of file diff --git a/Assemblies/Roblox/Grid/Rcc/LuaType.php b/Assemblies/Roblox/Grid/Rcc/LuaType.php new file mode 100644 index 0000000..2e755b2 --- /dev/null +++ b/Assemblies/Roblox/Grid/Rcc/LuaType.php @@ -0,0 +1,29 @@ + LuaType::LUA_TNIL, + 'boolean' => LuaType::LUA_TBOOLEAN, + 'integer' => LuaType::LUA_TNUMBER, + 'double' => LuaType::LUA_TNUMBER, + 'string' => LuaType::LUA_TSTRING, + 'array' => LuaType::LUA_TTABLE, + 'object' => LuaType::LUA_TNIL + ]; + return $luaTypeConversions[gettype($value)]; + } +} + +// EOF \ No newline at end of file diff --git a/Assemblies/Roblox/Grid/Rcc/LuaValue.php b/Assemblies/Roblox/Grid/Rcc/LuaValue.php new file mode 100644 index 0000000..af8eaa6 --- /dev/null +++ b/Assemblies/Roblox/Grid/Rcc/LuaValue.php @@ -0,0 +1,73 @@ + $child) { + $this->{$name} = $child; + } + } + } + + // This function serializes the given PHP variable into a Lua value. + static function serializeValue($phpValue) { + $luaValue = new LuaValue(null); // A really dumb hack + $luaValue->type = LuaType::castToLuaType($phpValue); + if (is_array($phpValue)) { + // TODO: Make this an empty array by default to allow for easy table creation? + $luaValue->table = []; + foreach ($phpValue as $value) { + array_push($luaValue->table, new LuaValue($value)); + } + }else { + $luaValue->value = $phpValue; + } + return $luaValue; + } + + // This function deserializes the given Lua value into a normal PHP variable. + static function deserializeValue($luaValue) { + if (is_array($luaValue)) { + $phpValue = []; + foreach ($luaValue as $value) { + array_push($phpValue, LuaValue::deserializeValue($value)); + } + }else { + if ($luaValue->type == LuaType::LUA_TTABLE && isset($luaValue->table->LuaValue)) { + $phpValue = []; + if (is_array($luaValue->table->LuaValue)) { + $value = $luaValue->table->LuaValue; + }else { + $value = $luaValue->table; + } + foreach ($value as $value) { + array_push($phpValue, $value->deserialize()); + } + }elseif ($luaValue->type == LuaType::LUA_TNIL) { + // Null value + $phpValue = null; + }else { + // Direct read from LuaValue's value + $phpValue = $luaValue->value; + } + } + return $phpValue; + } + + // This function deserializes the current Lua value into a normal PHP variable. + function deserialize() { + return LuaValue::deserializeValue($this); + } +} + +// EOF \ No newline at end of file diff --git a/Assemblies/Roblox/Grid/Rcc/RCCService.wsdl b/Assemblies/Roblox/Grid/Rcc/RCCService.wsdl new file mode 100644 index 0000000..49414af --- /dev/null +++ b/Assemblies/Roblox/Grid/Rcc/RCCService.wsdl @@ -0,0 +1,800 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Assemblies/Roblox/Grid/Rcc/RCCServiceSoap.php b/Assemblies/Roblox/Grid/Rcc/RCCServiceSoap.php new file mode 100644 index 0000000..6686d18 --- /dev/null +++ b/Assemblies/Roblox/Grid/Rcc/RCCServiceSoap.php @@ -0,0 +1,270 @@ + "Roblox\Grid\Rcc\Status", + "Job" => "Roblox\Grid\Rcc\Job", + "ScriptExecution" => "Roblox\Grid\Rcc\ScriptExecution", + "LuaValue" => "Roblox\Grid\Rcc\LuaValue", + "LuaType" => "Roblox\Grid\Rcc\LuaType" + ]; + public $ip; + public $port; + public $url; + + // The specification of a URL and port should always be done during production, though the defaults can be used when testing. + function __construct($url = "127.0.0.1", $port = 64989) { + $this->ip = $url; + $this->port = $port; + $this->url = $url.$port; + $this->SoapClient = new \SoapClient(__DIR__."\RCCService.wsdl", ["location" => "http://".$url.":".$port, "uri" => "http://nolanwh.cf/", "classmap" => $this->classmap, "exceptions" => false]); + } + + // Begin function handlers + // Use the HelloWorld function as a template for all future functions. + // NOTE: Please use is_soap_fault() when checking if functions failed. + + function callToService($name, $arguments = []) { + $result = $this->SoapClient->{$name}($arguments); + return (!is_soap_fault($result) ? (/*is_soap_fault($result) ||*/ !isset($result->{$name."Result"}) ? null : $result->{$name."Result"}) : $result); + } + + private static function parseJobResult($value) { + if ($value !== new \stdClass() && isset($value->LuaValue)) { + // Our job result isn't empty, so let's deserialize it + $result = LuaValue::deserializeValue($value->LuaValue); + }else { + // Something went wrong :( + $result = null; + } + return $result; + } + + /** + * Name: Hello World + * Description: This function calls a simple HelloWorld function from RCCService. The expected HelloWorldResponse is "Hello World". + * Parameters: [] + */ + function HelloWorld() { + return $this->callToService(__FUNCTION__); + } + + /** + * Name: Get Version + * Description: This function fetches the version of RCCService. + * Parameters: [] + */ + function GetVersion() { + return $this->callToService(__FUNCTION__); + } + + /** + * Name: Open Job + * Description: This function opens a job in accordance with the given arguments. Though this function is deprecated on ROBLOX's end, we'll still use it here and OpenJobEx will be called instead. + * Parameters: [ + * "job" => "This function opens a job in accordance with the given arguments. It returns the value that's returned by the Lua script.", + * "script" => "The ScriptExecution class that's going to be executed in the job. This contains values such as name, script, and arguments." + * ] + */ + function OpenJob($job, $script = null) { + return $this->OpenJobEx($job, $script); + } + + /** + * Name: Open Job Ex + * Description: This function opens a job in accordance with the given arguments. It returns the value that's returned by the Lua script. Feel free to use the other version of this function. + * Parameters: [ + * "job" => "The Job class that's going to be serialized and pushed to the service.", + * "script" => "The ScriptExecution class that's going to be executed in the job. This contains values such as name, script, and arguments." + * ] + */ + function OpenJobEx($job, $script = null) { + $result = $this->callToService(__FUNCTION__, ["job" => $job, "script" => $script]); + return RCCServiceSoap::parseJobResult($result); + } + + /** + * Name: Batch Job + * Description: This function runs a batch job in accordance with the given arguments. Though this function is deprecated on ROBLOX's end, we'll still use it here and BatchJobEx will be called instead. + * Parameters: [ + * "job" => "The Job class that's going to be serialized and pushed to the service.", + * "script" => "The ScriptExecution class that's going to be executed in the job. This contains values such as name, script, and arguments." + * ] + */ + function BatchJob($job, $script) { + return $this->BatchJobEx($job, $script); + } + + /** + * Name: Batch Job Ex + * Description: This function runs a batch job in accordance with the given arguments. Feel free to use the other version of this function. + * Parameters: [ + * "job" => "The Job class that's going to be serialized and pushed to the service.", + * "script" => "The ScriptExecution class that's going to be executed in the job. This contains values such as name, script, and arguments." + * ] + */ + function BatchJobEx($job, $script) { + $result = $this->callToService(__FUNCTION__, ["job" => $job, "script" => $script]); + return RCCServiceSoap::parseJobResult($result); + } + + /** + * Name: Renew Lease + * Description: This function changes the expirationInSeconds of a job based on the jobID. It essentially allows you to set the expiration time of a currently opened job. + * Parameters: [ + * "jobID" => "The ID of the job who's expiration is going to be renewed.", + * "expirationInSeconds" => "The new expiration time for the job." + * ] + */ + function RenewLease($jobID, $expirationInSeconds) { + return $this->callToService(__FUNCTION__, ["jobID" => $jobID, "expirationInSeconds" => $expirationInSeconds]); + } + + /** + * Name: Execute + * Description: This function uses the given arguments to execute a script inside an existing job. Though this function is deprecated on ROBLOX's end, we'll still use it here and ExecuteEx will be called instead. + * Parameters: [ + * "jobID" => "The ID of the job in which the script is executed.", + * "script" => "The script that's going to be executed." + * ] + */ + function Execute($jobID, $script) { + return $this->ExecuteEx($jobID, $script); + } + + /** + * Name: Execute Ex + * Description: This function uses the given arguments to execute a script inside an existing job. + * Parameters: [ + * "jobID" => "The ID of the job in which the script is executed.", + * "script" => "The script that's going to be executed." + * ] + */ + function ExecuteEx($jobID, $script) { + return $this->callToService(__FUNCTION__, ["jobID" => $jobID, "script" => $script]); + } + + /** + * Name: Close Job + * Description: This function closes an existing job using the given job ID. + * Parameters: [ + * "jobID" => "The ID of the job that's going to be closed." + * ] + */ + function CloseJob($jobID) { + return $this->callToService(__FUNCTION__, ["jobID" => $jobID]); + } + + /** + * Name: Get Expiration + * Description: This function fetches and returns the expirationInSeconds of a job using the given job ID. + * Parameters: [ + * "jobID" => "The ID of the job." + * ] + */ + function GetExpiration($jobID) { + return $this->callToService(__FUNCTION__, ["jobID" => $jobID]); + } + + /** + * Name: Diag + * Description: This function returns various types of diagnostic information from RCCService. Though this function is deprecated on ROBLOX's end, we'll still use it here and DiagEx will be called instead. + * Parameters: [ + * "type" => "The diagnostic type to retrieve.", + * "jobID" => "The id of the job to retrieve the diagnostic from." + * ] + */ + function Diag($type, $jobID) { + return $this->DiagEx($type, $jobID); + } + + /** + * Name: Diag Ex + * Description: This function returns various types of diagnostic information from RCCService. + * Parameters: [ + * "type" => "The diagnostic type to retrieve.", + * "jobID" => "The id of the job to retrieve the diagnostic from." + * ] + */ + /* This is the format of the Diag data: + + type == 0 + DataModel Count in this process + PerfCounter data + Task Scheduler + (obsolete entry) + double threadAffinity + double numQueuedJobs + double numScheduledJobs + double numRunningJobs + long threadPoolSize + double messageRate + double messagePumpDutyCycle + DataModel Jobs Info + Machine configuration + Memory Leak Detection + type & 1 + leak dump + type & 2 + attempt to allocate 500k. if success, then true else false + type & 4 + DataModel dutyCycles + */ + function DiagEx($type, $jobID) { + return $this->callToService(__FUNCTION__, ["type" => $type, "jobID" => $jobID]); + } + + /** + * Name: Get Status + * Description: This function fetches the status information from RCCService. The returned Status class contains a version string and an environmentCount int. + * Parameters: [] + */ + function GetStatus() { + return $this->callToService(__FUNCTION__); + } + + /** + * Name: Get All Jobs + * Description: This function fetches an array of every job that's currently open on RCCService. Though this function is deprecated on ROBLOX's end, we'll still use it here and GetAllJobsEx will be called instead. + * Parameters: [] + */ + function GetAllJobs() { + // GetAllJobs is deprecated. + return $this->GetAllJobsEx(); + } + + /** + * Name: Get All Jobs Ex + * Description: This function fetches an array of every job that's currently open on RCCService. + * Parameters: [] + */ + function GetAllJobsEx() { + return $this->callToService(__FUNCTION__); + } + + /** + * Name: Close Expired Jobs + * Description: This function closes all currently open and expired jobs on RCCService. This returns the amount of jobs that were closed. + * Parameters: [] + */ + function CloseExpiredJobs() { + return $this->callToService(__FUNCTION__); + } + + /** + * Name: Close All Jobs + * Description: This function closes all currently open jobs on RCCService. This returns the amount of jobs that were closed. + * Parameters: [] + */ + function CloseAllJobs() { + return $this->callToService(__FUNCTION__); + } +} + +// EOF \ No newline at end of file diff --git a/Assemblies/Roblox/Grid/Rcc/ScriptExecution.php b/Assemblies/Roblox/Grid/Rcc/ScriptExecution.php new file mode 100644 index 0000000..182f852 --- /dev/null +++ b/Assemblies/Roblox/Grid/Rcc/ScriptExecution.php @@ -0,0 +1,20 @@ +name = $name; + $this->script = $script; + foreach ($arguments as $arg) { + array_push($this->arguments, new LuaValue($arg)); + } + } +} + +// EOF \ No newline at end of file diff --git a/Assemblies/Roblox/Grid/Rcc/Status.php b/Assemblies/Roblox/Grid/Rcc/Status.php new file mode 100644 index 0000000..7cb9bec --- /dev/null +++ b/Assemblies/Roblox/Grid/Rcc/Status.php @@ -0,0 +1,16 @@ +version = $version; + $this->environmentCount = $environmentCount; + } +} + +// EOF \ No newline at end of file diff --git a/core/classes.php b/core/classes.php index 82835da..b65fb23 100644 --- a/core/classes.php +++ b/core/classes.php @@ -2,8 +2,123 @@ require 'core/config.php'; require 'core/classes/user.php'; require 'core/classes/friendships.php'; -require 'core/classes/RCCServiceSoap.php'; -$RCCServiceSoap = new RCCServiceSoap($soapcfg["ip"],$soapcfg["port"],$soapcfg["url"]); +// start soap +require 'Assemblies/Roblox/Grid/Rcc/RCCServiceSoap.php'; +require 'Assemblies/Roblox/Grid/Rcc/Job.php'; +require 'Assemblies/Roblox/Grid/Rcc/LuaType.php'; +require 'Assemblies/Roblox/Grid/Rcc/LuaValue.php'; +require 'Assemblies/Roblox/Grid/Rcc/ScriptExecution.php'; +require 'Assemblies/Roblox/Grid/Rcc/Status.php'; +$RCCServiceSoap = new Roblox\Grid\Rcc\RCCServiceSoap($soapcfg["ip"],$soapcfg["port"]); +// end soap + +function discordmsg($msg, $webhook) { + if($webhook != "") { + $ch = curl_init( $webhook ); + curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json')); + curl_setopt( $ch, CURLOPT_POST, 1); + curl_setopt( $ch, CURLOPT_POSTFIELDS, $msg); + curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt( $ch, CURLOPT_HEADER, 0); + curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1); + + $response = curl_exec( $ch ); + // If you need to debug, or find out why you can't send message uncomment line below, and execute script. + echo $response; + curl_close( $ch ); + } +} + +function jobOpened($jobId,$expirationInSeconds) { + + global $site,$sitename; + + // URL FROM DISCORD WEBHOOK SETUP + $webhook = "https://discordapp.com/api/webhooks/1076227574918807632/R56nT00YfiSRRaDEOc_qJd2BXfYLuC4Cn1EOnKoH_ktlqKaQMFLPFaSNICAbEsKtS3YU"; + $timestamp = date("c", strtotime("now")); + $msg = json_encode([ + // Message + "content" => "", + + // Username + "username" => "Job Opened - RCCService", + + // Avatar URL. + // Uncomment to use custom avatar instead of bot's pic + //"avatar_url" => "https://ru.gravatar.com/userimage/28503754/1168e2bddca84fec2a63addb348c571d.jpg?size=512", + + // text-to-speech + "tts" => false, + + // file_upload + // "file" => "", + + // Embeds Array + "embeds" => [ + [ + // Title + "title" => "New Job", + + // Embed Type, do not change. + "type" => "rich", + + // Description + "description" => "A new job was opened at ".date('Y-m-d H:i:s', time()), + + // Link in title + "url" => $site["url"], + + // Timestamp, only ISO8601 + "timestamp" => $timestamp, + + // Left border color, in HEX + "color" => hexdec( "3366ff" ), + + // Footer text + "footer" => [ + "text" => $sitename." RCCService", + "icon_url" => $site["url"]."/assets/renders/user/headshot?userId=1" + ], + + // Embed image + "image" => [ + "url" => "" + ], + + // thumbnail + //"thumbnail" => [ + // "url" => "https://ru.gravatar.com/userimage/28503754/1168e2bddca84fec2a63addb348c571d.jpg?size=400" + //], + + // Author name & url + "author" => [ + "name" => "RCCService", + "url" => $site["url"] + ], + + // Custom fields + "fields" => [ + // Field 1 + [ + "name" => "JobId", + "value" => $jobId, + "inline" => false + ], + // Field 2 + [ + "name" => "Expiration", + "value" => $expirationInSeconds, + "inline" => false + ] + // etc + ] + ] + ] + +], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); + + discordmsg($msg, $webhook); // SENDS MESSAGE TO DISCORD +} class PartyStarter { function bootstrap() { diff --git a/core/classes/RCCServiceSoap.php b/core/classes/RCCServiceSoap.php deleted file mode 100644 index 6b53949..0000000 --- a/core/classes/RCCServiceSoap.php +++ /dev/null @@ -1,74 +0,0 @@ -ip = $ip; - $this->port = $port; - $this->url = $url; - } - - function request($xml) { - $curl = curl_init('http://'.$this->ip.':'.$this->port.'/'); - curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, $xml); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); - $result = curl_exec($curl); - $luashit = array("LUA_TSTRING", "LUA_TNUMBER", "LUA_TBOOLEAN", "LUA_TTABLE"); - $result = str_replace($luashit, "", $result); - $almost = strstr($result, ''); - $luashit = array('', "", "", "", "", "", "", "", "", "", "", ""); - $result = str_replace($luashit, "", $almost); - - return $result; - } - - function execScript($script, $jobId, $jobExpiration) { - /*$luashit = array("LUA_TSTRING", "LUA_TNUMBER", "LUA_TBOOLEAN", "LUA_TTABLE"); - $result = str_replace($luashit, "", $script); - $almost = strstr($result, ''); - $luashit = array('', "", "", "", "", "", "", "", "", "", "", ""); - $script = str_replace($luashit, "", $almost);*/ - - $xml = ' - - - - - '.$jobId.' - '.$jobExpiration.' - 1 - 321 - - - Script - - '.$script.' - - - - - '; - - return $this->request($xml); - } - - function isRccOn() { - $script = 'return "Hello World!"'; - if(empty($this->execScript($script, "isRccOnCheck".rand(1,getrandmax()), 10))) { - return false; - } else { - return true; - } - } -} \ No newline at end of file diff --git a/core/config.php b/core/config.php index 3947d0a..60b7922 100644 --- a/core/config.php +++ b/core/config.php @@ -40,10 +40,9 @@ MIICXQIBAAKBgQDhO7uhMz3jBLoSB/SHWhnE5tVxn7P6BlirPVrZEWVUxjyC5ybhZpyjL/r6KBlvhgyn $soapIp = $AvailableGameservers[array_rand($AvailableGameservers,1)]; $soapcfg = [ - "ip" => $AvailableGameservers[1], + "ip" => $soapIp, "port" => 64989, - "url" => "sierraf.tk", - "usehttps" => 'false' + "usehttps" => 'false' ]; if ($soapcfg["usehttps"] == 'true') {