public function LoadHeader($RELEASE, $IncomingFile = "Incoming.conf", $OutgoingFile = "Outgoing.conf") { $incoming = "res://" . $RELEASE . "/" . $IncomingFile; $file = file_get_contents($incoming); $file = String::replace($file, "\r", ""); $file = explode("\n", $file); $this->Incoming = array(); foreach ($file as $line) { $exp = explode("=", $line); if (isset($exp[1])) { $this->Incoming[trim($exp[0])] = (int) $exp[1]; } } $outgoing = "res://" . $RELEASE . "/" . $OutgoingFile; $file = file_get_contents($outgoing); $file = String::replace($file, "\r", ""); $file = explode("\n", $file); $this->Outgoing = array(); foreach ($file as $line) { $exp = explode("=", $line); if (isset($exp[1])) { $this->Outgoing[trim($exp[0])] = (int) $exp[1]; } } }
public function init($filename) { //if (file_exists($filename)) { //jphp issue ? never return true when file exist $file = file_get_contents($filename); $file = String::replace($file, "\r", ""); $file = explode("\n", $file); $this->config = array(); foreach ($file as $line) { $exp = explode("=", $line); if (isset($exp[1])) { $key = $exp[0]; $value = String::replace($line, $exp[0] . "=", ""); if ($value == "1") { $value = true; } if ($value == "0") { $value = false; } $this->config[$key] = $value; } } //} else { // Console::WriteLine("Config file " . $filename . " is missing !"); // exit; //} }
public function send($data) { $data = String::encode($data, 'ISO-8859-1'); if ($this->rc4initialized) { $this->socketOutput->write(String::encode($this->rc4server->Parse($data), 'ISO-8859-1')); } else { $this->socketOutput->write($data); } }
public static function ParseString($string) { for ($i = 0; $i < 20; $i++) { $string = String::replace($string, chr($i), "[" . $i . "]"); } for ($i = 65000; $i < 65535; $i++) { $string = String::replace($string, chr($i), "[" . $i . "]"); } return $string; }
public function __construct() { $classFiles = new File('./src/class/'); foreach ($classFiles->findFiles() as $classFile) { $this->class[] = String::replace($classFile->getName(), ".php", ""); } $eventsFiles = new File('./src/events/'); foreach ($eventsFiles->findFiles() as $eventsFile) { $this->events[] = String::replace($eventsFile->getName(), ".php", ""); } }
public function SetPrivate($n, $e, $d) { $n = String::replace($n, "\r", ""); $n = String::replace($n, "\n", ""); $e = String::replace($e, "\r", ""); $e = String::replace($e, "\n", ""); $d = String::replace($d, "\r", ""); $d = String::replace($d, "\n", ""); $this->n = new BigInteger($n, 16); $this->e = new BigInteger($e, 16); $this->d = new BigInteger($d, 16); $this->canEncrypt = true; $this->canDecrypt = true; }
public static function SerializeSearchResultListStatics($staticId, $direct = false, PacketConstructor $response, ClassContainer $util) { if (strlen($staticId) == 0) { $staticId = "official_view"; } if ($staticId != "hotel_view" && $staticId != "roomads_view" && $staticId != "myworld_view" && String::startsWith($staticId, "category__") && $staticId != "official_view") { $response->WriteString($staticId); //code $response->WriteString(""); //title $response->WriteString(1); //0 : no button - 1 : Show More - 2 : Show Back button $response->WriteBoolean($staticId != "my" && $staticId != "popular" && $staticId != "official-root"); // collapsed $response->WriteInt32($staticId == "official-root" ? 1 : 0); //0 : list - 1 : thumbnail } $rooms = array(); switch ($staticId) { case "hotel_view": self::SerializeSearchResultListStatics("popular", false, $response, $util); foreach ($util->Cache->navigatorcategories as $cat) { self::SerializeSearchResultListFlatcats($cat, false, $response); } break; case "myworld_view": self::SerializeSearchResultListStatics("my", false, $response, $util); self::SerializeSearchResultListStatics("favorites", false, $response, $util); self::SerializeSearchResultListStatics("my_groups", false, $response, $util); self::SerializeSearchResultListStatics("history", false, $response, $util); self::SerializeSearchResultListStatics("friends_rooms", false, $response, $util); break; case "roomads_view": foreach ($util->Cache->navigatorcategories as $cat) { self::SerializePromotionsResultListFlatcats($cat, false, $response); } self::SerializeSearchResultListStatics("top_promotions", false, $response, $util); break; case "official_view": self::SerializeSearchResultListStatics("official-root", false, $response, $util); self::SerializeSearchResultListStatics("staffpicks", false, $response, $util); break; case "official-root": break; } }
public static function RoomGetHeightmapMessageEvent(User $user, PacketParser $packet, ClassContainer $util) { $room = $user->currentLoadingRoom; $model = $room->getModel(); $heightmap = String::replace($model['heightmap'], chr(0xa), ''); $split = explode(chr(0xd), $heightmap); $sizeX = strlen($split[0]); $sizeY = count($split); $response = new PacketConstructor(); $response->SetHeader($util->HeaderManager->Outgoing("HeightMapMessageComposer")); $response->WriteInt32($sizeX); $response->WriteInt32($sizeX * $sizeY); for ($i = 0; $i < $sizeY; $i++) { for ($j = 0; $j < $sizeX; $j++) { $response->WriteInt16(0 * 256); } } $user->Send($response->Finalize()); $response = new PacketConstructor(); $response->SetHeader($util->HeaderManager->Outgoing("FloorMapMessageComposer")); $response->WriteBoolean(true); $response->WriteInt32(1); //wall height $response->WriteString($heightmap . chr(0xd)); $user->Send($response->Finalize()); $response = new PacketConstructor(); $response->SetHeader($util->HeaderManager->Outgoing("RoomFloorItemsMessageComposer")); $response->WriteInt32(1); //owner count $response->WriteInt32($room->getOwner()['id']); $response->WriteString($room->getOwner()['username']); $response->WriteInt32(0); //items count $user->Send($response->Finalize()); $response = new PacketConstructor(); $response->SetHeader($util->HeaderManager->Outgoing("RoomWallItemsMessageComposer")); $response->WriteInt32(1); //owner count $response->WriteInt32($room->getOwner()['id']); $response->WriteString($room->getOwner()['username']); $response->WriteInt32(0); //items count $user->Send($response->Finalize()); }
public static function GenerateSecretKeyMessageEvent(User $user, PacketParser $packet, ClassContainer $util) { if ($util->Config->Get("crypto.enabled")) { $rsadata = $packet->readString(); $user->DH->GenerateSharedKey(String::Replace($util->RSA->Verify($rsadata), chr(0), "")); $response = new PacketConstructor(); $response->SetHeader($util->HeaderManager->Outgoing("SecretKeyMessageComposer")); $response->WriteString($util->RSA->Sign($user->DH->GetPublicKey())); $response->WriteBoolean(true); $user->Send($response->Finalize()); $user->rc4client = new RC4(); $user->rc4server = new RC4(); $user->rc4client->Init($user->DH->GetSharedKey(true)); $user->rc4server->Init($user->DH->GetSharedKey(true)); $user->rc4initialized = true; } else { $response = new PacketConstructor(); $response->SetHeader($util->HeaderManager->Outgoing("SecretKeyMessageComposer")); $response->WriteString("Crypto disabled"); $response->WriteBoolean(false); $user->Send($response->Finalize()); } }
$util = new ClassContainer(); $util->index =& $index; $util->HeaderManager =& $headermanager; $util->RSA =& $rsa; $util->Database =& $database; $util->Cache =& $cache; $util->Config =& $config; $util->RoomManager =& $roommanager; $service->execute(function () use($user, $events, $util) { ob_implicit_flush(true); while ($buffer = $user->socketInput->read(4096)) { if ($buffer == "<policy-file-request/>" . chr(0)) { $user->send(Util::Crossdomain()); continue; } $buffer = String::decode($buffer, 'ISO-8859-1'); if ($user->rc4initialized) { $buffer = $user->rc4client->Parse($buffer); } foreach (BufferManager::Parser($buffer) as $packet) { $packet = new PacketParser($packet); $header = $packet->getHeader(); if (isset($events[$header])) { eval($events[$header]["parent"] . '::' . $events[$header]["method"] . '($user, $packet, $util);'); Console::WriteLine("- Executed event for " . $header . " (" . $events[$header]["parent"] . '::' . $events[$header]["method"] . ") "); } else { Console::WriteLine("- Not found event for " . $header . " : " . $packet->getFullPacket()); } } } $user->disconnect();