Guest User

Untitled

a guest
Apr 9th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.66 KB | None | 0 0
  1. <?php
  2.  
  3. ini_set('mysql.connect_timeout', 25);
  4.  
  5. error_reporting(E_ALL);
  6.  
  7. set_time_limit(0);
  8.  
  9.  
  10.  
  11. include "crumbs.php";
  12.  
  13. include "config.php";
  14.  
  15. $init = false;
  16.  
  17. $count = 0;
  18.  
  19. class penguinelite {
  20.  
  21. public $ip;
  22.  
  23. public $count;
  24.  
  25. public $port;
  26.  
  27. public $users = array();
  28.  
  29. public $mode;
  30.  
  31. public $config;
  32.  
  33. public $mysql;
  34.  
  35. public $bot;
  36.  
  37. private $socket;
  38.  
  39. public function __construct($config = "config.xml") {
  40.  
  41. global $init, $count;
  42.  
  43. $count++;
  44.  
  45. $this->count = $count;
  46.  
  47. if ($init == false)
  48.  
  49. $this->createHeader();
  50.  
  51. else
  52.  
  53. $this->writeOutput("Starting next server...", "INFO");
  54.  
  55. $init = true;
  56.  
  57. $this->readConfig($config);
  58.  
  59. }
  60.  
  61. public function readConfig($file) {
  62.  
  63. echo "\n\n\n";
  64.  
  65. echo "|----------------------------------------------|\n";
  66.  
  67. echo "| Reading Configuration Files |\n";
  68.  
  69. echo "|----------------------------------------------|\n";
  70.  
  71. if (!file_exists($file))
  72.  
  73. $this->shutDown("Could not find $file. Does it exist?");
  74.  
  75. $this->config = simplexml_load_file($file) or $this->shutDown("$file has errors!");
  76.  
  77. $this->writeOutput("Running as " . $this->config->type . " server", "INFO");
  78.  
  79. $this->writeOutput("Successfully read config files");
  80.  
  81. }
  82.  
  83. public function init() {
  84.  
  85. $this->mysql = new mysql();
  86.  
  87. $err = false;
  88.  
  89. $this->writeOutput("Connecting to MySQL database...", "INFO");
  90.  
  91. $this->mysql->connect($this->config->mysql->host, $this->config->mysql->username, $this->config->mysql->password) or $err = true;
  92.  
  93. if ($err == true)
  94.  
  95. $this->shutDown("Could not connect to mysql. Reason: " . $this->mysql->getError());
  96.  
  97. $this->mysql->selectDB($this->config->mysql->dbname);
  98.  
  99. if ($err == true)
  100.  
  101. $this->shutDown("Could not select the database. Reason: " . $this->mysql->getError());
  102.  
  103. $this->bind((integer)$this->config->port, (string)$this->config->ip);
  104.  
  105. $this->writeOutput("We recommend using a while loop here to accept connections", "FINEST");
  106.  
  107. }
  108.  
  109. public function bind($port, $ip = "0") {
  110.  
  111. $this->socket = socket_create(AF_INET, SOCK_STREAM, 0) or $this->shutDown("Could not create socket. Please check php.ini to see if sockets are enabled!");
  112.  
  113. socket_set_option($this->socket, SOL_SOCKET, SO_REUSEADDR, 1);
  114.  
  115. socket_bind($this->socket, $ip, $port) or $this->shutDown("Could not bind to port. Make sure the port is over 1024 if you are using linux");
  116.  
  117. socket_listen($this->socket);
  118.  
  119. }
  120.  
  121. public function loopFunction() {
  122.  
  123. socket_set_block($this->socket);
  124.  
  125. $read = array();
  126.  
  127. $read[0] = $this->socket;
  128.  
  129. foreach ($this->users as $i=>&$user) {
  130.  
  131. if (!empty($user))
  132.  
  133. $read[] = &$user->sock;
  134.  
  135. if ($user->selfDestruct == true)
  136.  
  137. unset($this->users[$i]);
  138.  
  139. }
  140.  
  141. $ready = socket_select($read, $w = null, $e = null, $t = 0);
  142.  
  143. if (in_array($this->socket, $read)) {
  144.  
  145. if (count($this->users) <= 1000) {
  146.  
  147. $this->users[] = new CPUser(socket_accept($this->socket), $this);
  148.  
  149. $this->writeOutput("New Client Connected", "FINE");
  150.  
  151. } else if(count($this->users) >= 1000)
  152.  
  153. $this->writeOutput("Server is full", "INFO");
  154.  
  155. }
  156.  
  157. if ($ready-- <= 0)
  158.  
  159. return;
  160.  
  161. else {
  162.  
  163. foreach ($this->users as $index=>&$user) {
  164.  
  165. if (in_array($user->sock, $read)) {
  166.  
  167. $input = socket_read($user->sock, 65536);
  168.  
  169. if ($input == null) {
  170.  
  171. unset($this->users[$index]);
  172.  
  173. continue;
  174.  
  175. }
  176.  
  177. $x = explode(chr(0), $input);
  178.  
  179. array_pop($x);
  180.  
  181. foreach ($x as $input2){
  182.  
  183. $this->handleRawPacket($input2, $user);
  184.  
  185. }
  186.  
  187. }
  188.  
  189. }
  190.  
  191. }
  192.  
  193. }
  194.  
  195. public function doLogin(&$user, $packet) {
  196.  
  197. $username = $this->mysql->escape($this->stribet($packet, "<nick><![CDATA[", "]]"));
  198.  
  199. $password = $this->stribet($packet, "<pword><![CDATA[", "]]");
  200.  
  201. if ($this->mysql->getRows("SELECT * FROM {$this->config->mysql->userTableName} WHERE username='" . $username . "';") > 0) {
  202.  
  203. $dbv = $this->mysql->returnArray("SELECT * FROM {$this->config->mysql->userTableName} WHERE username='" . $this->mysql->escape($username) . "';");
  204.  
  205. if($this->config->type == "login"){
  206.  
  207. $hash = strtoupper($dbv[0]["password"]);
  208.  
  209. $hash = $this->encryptPassword($hash, $user->key);
  210.  
  211. } else {
  212.  
  213. $hash = $this->swapMD5(md5($dbv[0]["lkey"] . $user->key)) . $dbv[0]["lkey"];
  214.  
  215. }
  216.  
  217. if ($password == $hash) {
  218.  
  219. if ($dbv[0]["active"] != "0") {
  220.  
  221. if ($dbv[0]["ubdate"] != "PERMABANNED") {
  222.  
  223. if ($dbv[0]["ubdate"] < strtotime("NOW MDT")) {
  224.  
  225. if ($this->config->type == "login") {
  226.  
  227. $this->writeSocket($user, "%xt%gs%-1%$server1IP:$server1Port:$server1Name:3|$server2IP:$server2Port:$server2Name:2% 3;");
  228.  
  229. $this->writeSocket($user, "%xt%l%-1%" . $dbv[0]["id"] . "%" . md5(strrev($user->key)) . "%0%");
  230.  
  231. $this->mysql->query("UPDATE {$this->config->mysql->userTableName} SET lkey='" . md5(strrev($user->key)) . "' WHERE id='" . $dbv[0]["id"] . "';");
  232.  
  233. } else {
  234.  
  235. socket_getsockname($user->sock, $ip);
  236.  
  237. $user->id = $dbv[0]["id"];
  238.  
  239. $this->mysql->query("UPDATE {$this->config->mysql->userTableName} SET ips=ips + '\n" . $this->mysql->escape($ip) . "' WHERE id='" . $user->getID() . "';");
  240.  
  241. $user->resetDetails();
  242.  
  243. $user->sendPacket("%xt%l%-1%");
  244.  
  245. }
  246.  
  247. } else
  248.  
  249. $this->writeSocket($user, "%xt%e%-1%601%24%");
  250.  
  251. } else
  252.  
  253. $this->writeSocket($user, "%xt%e%-1%603%");
  254.  
  255. } else
  256.  
  257. $this->writeSocket($user, "%xt%e%-1%900%");
  258.  
  259. } else
  260.  
  261. $this->writeSocket($user, "%xt%e%-1%101%");
  262.  
  263. } else
  264.  
  265. $this->writeSocket($user, "%xt%e%-1%100%");
  266.  
  267. }
  268.  
  269. public function encryptPassword($password, $key) {
  270.  
  271. return $this->swapMD5(md5($this->swapMD5($password) . $key . 'Y(02.>\'H}t":E1'));
  272.  
  273. }
  274.  
  275. public function swapMD5($func_md5) {
  276.  
  277. return substr($func_md5, 16, 16) . substr($func_md5, 0, 16);
  278.  
  279. }
  280.  
  281. public function handleRawPacket($packet, &$user) {
  282.  
  283. if (substr($packet, 0, 1) == "<")
  284.  
  285. $this->handleSysPacket($packet, $user);
  286.  
  287. elseif (substr($packet, 0, 1) == "%")
  288.  
  289. $this->handleXtPacket($packet, $user);
  290.  
  291. }
  292.  
  293. public function handleSysPacket($packet, &$user) {
  294.  
  295. if (stristr($packet, "<policy-file-request/>") > -1)
  296.  
  297. $this->writeSocket($user, "<cross-domain-policy><allow-access-from domain='*' to-ports='*' /></cross-domain-policy>");
  298.  
  299. if (stristr($packet, "<msg t='sys'><body action='verChk'") > -1)
  300.  
  301. $this->writeSocket($user, "<msg t='sys'><body action='apiOK' r='0'></body></msg>");
  302.  
  303. if (stristr($packet, "<msg t='sys'><body action='rndK' r='-1'></body></msg>") > -1){
  304.  
  305. $user->key = $this->generateRandomKey();
  306.  
  307. $this->writeSocket($user, "<msg t='sys'><body action='rndK' r='-1'><k>" . $user->key . "</k></body></msg>");
  308.  
  309. }
  310.  
  311. if (stristr($packet, "<msg t='sys'><body action='login' r='0'>") > -1)
  312.  
  313. $this->doLogin($user, $packet);
  314.  
  315. }
  316.  
  317. public function handleXtPacket($packet, &$user) {
  318.  
  319. $raw = explode("%", $packet);
  320.  
  321. $handler = $raw[2];
  322.  
  323. if ($handler == "s")
  324.  
  325. $this->handleStandardPacket($packet, $user);
  326.  
  327. if ($handler == "z")
  328.  
  329. $this->handleGamePacket($packet, $user);
  330.  
  331. }
  332.  
  333. public function getDefaultRoom(){
  334.  
  335. $rooms = array("100", "110", "111", "120", "121", "130", "200", "210", "220", "221", "230", "300", "310", "320", "330", "340", "400", "410", "411", "800", "801", "802", "804", "805", "806", "807", "808", "809");
  336.  
  337. return $rooms[array_rand($rooms)];
  338.  
  339. }
  340.  
  341. public function handleStandardPacket($packet, &$user) {
  342.  
  343. $raw = explode("%", $packet);
  344.  
  345. $cmd = $raw[3];
  346.  
  347. if ($cmd == "j#js") {
  348.  
  349. $lkey = $raw[6];
  350.  
  351. $res = $this->mysql->returnArray("SELECT * FROM {$this->config->mysql->userTableName} WHERE id='" . $user->getID() . "'");
  352.  
  353. if (count($res) > 0)
  354.  
  355. $user->sendPacket("%xt%js%-1%0%1%" . $res[0]["ismoderator"] . "%0%");
  356.  
  357. $this->mysql->query("UPDATE {$this->config->mysql->userTableName} SET lkey='' WHERE id='" . $user->getID() . "';");
  358.  
  359. }
  360.  
  361. if ($cmd == "j#jp"){
  362.  
  363. $user->sendPacket("%xt%jp%" . $raw[4] . "%" . $raw[5] . "%");
  364.  
  365. $user->joinRoom($raw[5], $raw[6], $raw[7]);
  366.  
  367. }
  368.  
  369. if ($cmd == "p#pg"){
  370.  
  371. $user->sendPacket("%xt%pg%" . $raw[4] . "%");
  372.  
  373. }
  374.  
  375. if ($cmd == "i#gi"){
  376.  
  377. $user->sendPacket("%xt%gps%-1%" . $user->getID() . "%9|10|11|14|20|183%");
  378.  
  379. $user->sendPacket("%xt%glr%-1%3555%");
  380.  
  381. $user->sendPacket("%xt%lp%-1%" . implode("|", $user->getDetails()) . "%" . $user->getCoins() . "%0%1440%" . rand(1200000000000, 1500000000000) . "%" . $user->getAge() . "%4%" . $user->getAge() . "% %7%");
  382.  
  383. $user->joinRoom($this->getDefaultRoom());
  384.  
  385. $user->sendPacket("%xt%gi%-1%" . implode("%", $user->getInventory()) . "%");
  386.  
  387. }
  388.  
  389. if ($cmd == "i#ai")
  390.  
  391. $user->addItem($raw[5]);
  392.  
  393. if ($cmd == "n#gn")
  394.  
  395. $user->sendPacket("%xt%gn%-1%");
  396.  
  397. if ($cmd == "l#mst")
  398.  
  399. $user->sendPacket("%xt%mst%-1%0%1");
  400.  
  401. if ($cmd == "l#mg")
  402.  
  403. $user->sendPacket("%xt%mg%-1%Safari|0|12|penguinelite|0|63%");
  404.  
  405. if ($cmd == "j#jr")
  406.  
  407. $user->joinRoom($raw[5], $raw[6], $raw[7]);
  408.  
  409. if ($cmd == "m#sm")
  410.  
  411. $user->speak($raw[6]);
  412.  
  413. if ($cmd == "o#k"){
  414.  
  415. foreach($this->users as &$suser){
  416.  
  417. if($suser->getID() == $raw[5]){
  418.  
  419. $suser->kick();
  420.  
  421. }
  422.  
  423. }
  424.  
  425. }
  426.  
  427. $h = explode("#", $cmd);
  428.  
  429. $h = $h[0];
  430.  
  431. if ($h == "s")
  432.  
  433. $this->handleUserSettingPacket($packet, $user);
  434.  
  435. if ($h == "u")
  436.  
  437. $this->handleUserSettingPacket($packet, $user);
  438.  
  439. if ($h == "f")
  440.  
  441. $this->handleEPFPacket($packet, $user);
  442.  
  443. if ($h == "b")
  444.  
  445. $this->handleBuddyPacket($packet, $user);
  446.  
  447. if ($h == "g")
  448.  
  449. $this->handleIglooPacket($packet, $user);
  450.  
  451. }
  452.  
  453. public function handleBuddyPacket($packet, &$user){
  454.  
  455. $raw = explode("%", $packet);
  456.  
  457. $cmd = $raw[3];
  458.  
  459. if ($cmd == "b#gb")
  460.  
  461. $user->sendPacket("%xt%gb%-1%" . $user->getBuddyStr());
  462.  
  463. if($cmd == "b#br")
  464.  
  465. $user->requestBuddy($raw[5]);
  466.  
  467. if($cmd == "b#ba")
  468.  
  469. $user->acceptBuddy($raw[5]);
  470.  
  471. if($cmd == "b#rb")
  472.  
  473. $user->removeBuddy($raw[5]);
  474.  
  475. if($cmd == "b#bf")
  476.  
  477. $user->findBuddy($raw[5]);
  478.  
  479. }
  480.  
  481. public function handleIglooPacket($packet, &$user){
  482.  
  483. $raw = explode("%", $packet);
  484.  
  485. $cmd = $raw[3];
  486.  
  487. if($cmd == "g#gm")
  488.  
  489. $user->sendPacket("%xt%gm%-1%" . $raw[5] . "%1%0%0%%");
  490.  
  491. }
  492.  
  493. public function handleUserSettingPacket($packet, &$user) {
  494.  
  495. $raw = explode("%", $packet);
  496.  
  497. $cmd = $raw[3];
  498.  
  499. if ($cmd == "u#sp")
  500.  
  501. $user->setXY($raw[5], $raw[6]);
  502.  
  503. if ($cmd == "u#gp"){
  504.  
  505. $playerInfo = $this->mysql->returnArray("SELECT id, nickname, '1', colour, curhead, curface, curneck, curbody, curhands, curfeet, curflag, curphoto, rank * 146 FROM {$this->config->mysql->userTableName} WHERE id='" . $this->mysql->escape($raw[5]) . "';");
  506.  
  507. $playerInfo = $playerInfo[0];
  508.  
  509. $user->sendPacket("%xt%gp%-1%" . $raw[5] . "%" . implode("|", $playerInfo) . "%");
  510.  
  511. }
  512.  
  513. if ($cmd == "s#upc")
  514.  
  515. $user->setColour($raw[5]);
  516.  
  517. if ($cmd == "s#uph")
  518.  
  519. $user->setHead($raw[5]);
  520.  
  521. if ($cmd == "s#upf")
  522.  
  523. $user->setFace($raw[5]);
  524.  
  525. if ($cmd == "s#upn")
  526.  
  527. $user->setNeck($raw[5]);
  528.  
  529. if ($cmd == "s#upb")
  530.  
  531. $user->setBody($raw[5]);
  532.  
  533. if ($cmd == "s#upa")
  534.  
  535. $user->setHands($raw[5]);
  536.  
  537. if ($cmd == "s#upe")
  538.  
  539. $user->setFeet($raw[5]);
  540.  
  541. if ($cmd == "s#upp")
  542.  
  543. $user->setPhoto($raw[5]);
  544.  
  545. if ($cmd == "s#upl")
  546.  
  547. $user->setPin($raw[5]);
  548.  
  549. if ($cmd == "u#h")
  550.  
  551. $user->sendPacket("%xt%h%" . $raw[4] . "%");
  552.  
  553. if ($cmd == "u#sf")
  554.  
  555. $user->setFrame($raw[5]);
  556.  
  557. if($cmd == "u#sb")
  558.  
  559. $user->sendRoom("%xt%sb%-1%" . $user->getID() . "%" . $raw[5] . "%" . $raw[6] . "%");
  560.  
  561. if($cmd == "u#se")
  562.  
  563. $user->sendRoom("%xt%se%-1%" . $user->getID() . "%" . $raw[5] . "%");
  564.  
  565. if($cmd == "u#sa")
  566.  
  567. $user->setAction($raw[5]);
  568.  
  569. if($cmd == "u#ss")
  570.  
  571. $user->sendRoom("%xt%ss%-1%" . $user->getID() . "%" . $raw[5] . "%");
  572.  
  573. if($cmd == "u#sl")
  574.  
  575. $user->sendRoom("%xt%sl%-1%" . $user->getID() . "%" . $raw[5] . "%");
  576.  
  577. if($cmd == "u#sq")
  578.  
  579. $user->sendRoom("%xt%sq%-1%" . $user->getID() . "%" . $raw[5] . "%");
  580.  
  581. if($cmd == "u#sg")
  582.  
  583. $user->sendRoom("%xt%sg%-1%" . $user->getID() . "%" . $raw[5] . "%");
  584.  
  585. if($cmd == "u#sj")
  586.  
  587. $user->sendRoom("%xt%sj%-1%" . $user->getID() . "%" . $raw[5] . "%");
  588.  
  589. if($cmd == "u#sma")
  590.  
  591. $user->sendRoom("%xt%sma%-1%" . $user->getID() . "%" . $raw[5] . "%");
  592.  
  593. }
  594.  
  595. public function handleEPFPacket($packet, &$user) {
  596.  
  597. $raw = explode("%", $packet);
  598.  
  599. $cmd = $raw[3];
  600.  
  601. if ($cmd == "f#epfga")
  602.  
  603. $user->sendPacket("%xt%epfga%-1%1%");
  604.  
  605. if ($cmd == "f#epfgr")
  606.  
  607. $user->sendPacket("%xt%epfgr%-1%0%0%");
  608.  
  609. if ($cmd == "f#epfgf")
  610.  
  611. $user->sendPacket("%xt%epfgf%-1%0%");
  612.  
  613. }
  614.  
  615. public function handleGamePacket($packet, &$user) {
  616.  
  617. //No games yet
  618.  
  619. }
  620.  
  621. public function writeSocket(&$user, $packet) {
  622.  
  623. if (@stristr($packet, strlen($packet) - 1, 1) != chr(0))
  624.  
  625. $packet = $packet . chr(0);
  626.  
  627. socket_write($user->sock, $packet, strlen($packet));
  628.  
  629. }
  630.  
  631. public function stribet($input, $left, $right) {
  632.  
  633. $pl = stripos($input, $left) + strlen($left);
  634.  
  635. $pr = stripos($input, $right, $pl);
  636.  
  637. return substr($input, $pl, $pr - $pl);
  638.  
  639. }
  640.  
  641. public function generateRandomKey($amount = 9) {
  642.  
  643. return "abc12345";
  644.  
  645. $keyset = "abcdefghijklmABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!\"\A3$%^&*()_+-=[]{}:@~;'#<>?|\\,./";
  646.  
  647. $randkey = "";
  648.  
  649. for ($i = 0; $i < $amount; $i++)
  650.  
  651. $randkey .= substr($keyset, rand(0, strlen($keyset) - 1), 1);
  652.  
  653. return $randkey;
  654.  
  655. }
  656.  
  657. public function __destruct() {
  658.  
  659. @socket_shutdown($this->socket);
  660.  
  661. }
  662.  
  663. public function shutDown($error) {
  664.  
  665. $this->writeOutput("System error. Terminating server", "CRITICAL");
  666.  
  667. $this->writeOutput($error, "CRITICAL");
  668.  
  669. $this->writeOutput("Server terminated.", "CRITICAL");
  670.  
  671. if ($this->socket != null)
  672.  
  673. $this->writeOutput("Closing ports", "INFO");
  674.  
  675. die();
  676.  
  677. }
  678.  
  679. private function createHeader() {
  680.  
  681. echo "\033[2J";
  682.  
  683. echo "\n |----------------------------------------------|\n";
  684.  
  685. echo " | Penguinelite - The free CPPS |\n";
  686.  
  687. echo " |----------------------------------------------|\n";
  688.  
  689. echo " | Created by Cooldude170 |\n";
  690.  
  691. echo " | Original by ZKid |\n";
  692.  
  693. echo " | Licensed under the GNU licence |\n";
  694.  
  695. echo " |----------------------------------------------|\n";
  696.  
  697. echo "\n";
  698.  
  699. $this->writeOutput("License loaded - Personal Version");
  700.  
  701. $this->writeOutput("Limit: 100 users");
  702.  
  703. $this->writeOutput("To get a commercial license, please contact a staff member");
  704.  
  705. echo "\n";
  706.  
  707. }
  708.  
  709. private function writeOutput($msg, $type = "INFO") {
  710.  
  711. echo date("H\:i\:s") . " - [$type] [" . $this->count . "] > $msg\n";
  712.  
  713. }
  714.  
  715. public function handleCommand(&$user, $msg) {
  716.  
  717. if (function_exists("handleCommand") && substr($msg, 0, 1) == "!"){
  718.  
  719. handleCommand($user, $msg, $this);
  720.  
  721. }
  722.  
  723. }
  724.  
  725. public function sendPacket($packet) {
  726.  
  727. foreach ($this->users as $user)
  728.  
  729. $user->sendPacket($packet);
  730.  
  731. }
  732.  
  733. }
  734.  
  735. class CPUser {
  736.  
  737. public $isMember;
  738.  
  739. public $selfDestruct;
  740.  
  741. public $sock;
  742.  
  743. public $parent;
  744.  
  745. public $inventory;
  746.  
  747. public $coins;
  748.  
  749. public $username;
  750.  
  751. public $email;
  752.  
  753. public $room;
  754.  
  755. public $lkey;
  756.  
  757. public $colour;
  758.  
  759. public $id;
  760.  
  761. public $head;
  762.  
  763. public $face;
  764.  
  765. public $neck;
  766.  
  767. public $body;
  768.  
  769. public $hands;
  770.  
  771. public $feet;
  772.  
  773. public $pin;
  774.  
  775. public $photo;
  776.  
  777. public $loggedin;
  778.  
  779. public $x;
  780.  
  781. public $y;
  782.  
  783. public $key;
  784.  
  785. public $rank;
  786.  
  787. public $frame;
  788.  
  789. public $buddies;
  790.  
  791. public $buddyRequests = array();
  792.  
  793. public $isModerator = false;
  794.  
  795. public function getMember(){
  796.  
  797. return (bool)$this->isMember;
  798.  
  799. }
  800.  
  801. public function __construct($socket, &$parent) {
  802.  
  803. $this->sock = $socket;
  804.  
  805. $this->parent = $parent;
  806.  
  807. }
  808.  
  809. public function __destruct() {
  810.  
  811. $this->sendRoom("%xt%rp%-1%" . $this->getID() . "%");
  812.  
  813. }
  814.  
  815. public function getName() {
  816.  
  817. return $this->username;
  818.  
  819. }
  820.  
  821. public function getEmail() {
  822.  
  823. return $this->email;
  824.  
  825. }
  826.  
  827. public function getID() {
  828.  
  829. return $this->id;
  830.  
  831. }
  832.  
  833. public function getHead() {
  834.  
  835. return $this->head;
  836.  
  837. }
  838.  
  839. public function getFace() {
  840.  
  841. return $this->face;
  842.  
  843. }
  844.  
  845. public function getNeck() {
  846.  
  847. return $this->neck;
  848.  
  849. }
  850.  
  851. public function getBody() {
  852.  
  853. return $this->body;
  854.  
  855. }
  856.  
  857. public function getHands() {
  858.  
  859. return $this->hands;
  860.  
  861. }
  862.  
  863. public function getFeet() {
  864.  
  865. return $this->feet;
  866.  
  867. }
  868.  
  869. public function getPin() {
  870.  
  871. return $this->pin;
  872.  
  873. }
  874.  
  875. public function getPhoto() {
  876.  
  877. return $this->photo;
  878.  
  879. }
  880.  
  881. public function getColour() {
  882.  
  883. return $this->colour;
  884.  
  885. }
  886.  
  887. public function getAge() {
  888.  
  889. return $this->age;
  890.  
  891. }
  892.  
  893. public function getCoins() {
  894.  
  895. return $this->coins;
  896.  
  897. }
  898.  
  899. public function getX() {
  900.  
  901. return $this->x;
  902.  
  903. }
  904.  
  905. public function getY() {
  906.  
  907. return $this->y;
  908.  
  909. }
  910.  
  911. public function getInventory() {
  912.  
  913. return $this->inventory;
  914.  
  915. }
  916.  
  917. public function getFrame() {
  918.  
  919. return $this->frame;
  920.  
  921. }
  922.  
  923. public function setMember((bool)$xMember){
  924.  
  925. $this->parent->mysql->query("UPDATE {$this->parent->config->mysql->userTableName} SET isMember='$xMember' WHERE id='" . $this->getID() . "';");
  926.  
  927. $this->isMember = $xMember;
  928.  
  929. }
  930.  
  931. public function setHead($id) {
  932.  
  933. $id = $this->parent->mysql->escape($id);
  934.  
  935. $this->parent->mysql->query("UPDATE {$this->parent->config->mysql->userTableName} SET curhead='$id' WHERE id='" . $this->getID() . "';");
  936.  
  937. $this->sendRoom("%xt%uph%-1%{$this->getID()}%" . $id . "%");
  938.  
  939. $this->head = $id;
  940.  
  941. }
  942.  
  943. public function setFace($id) {
  944.  
  945. $id = $this->parent->mysql->escape($id);
  946.  
  947. $this->parent->mysql->query("UPDATE {$this->parent->config->mysql->userTableName} SET curface='$id' WHERE id='" . $this->getID() . "';");
  948.  
  949. $this->sendRoom("%xt%upf%-1%{$this->getID()}%" . $id . "%");
  950.  
  951. $this->face = $id;
  952.  
  953. }
  954.  
  955. public function setNeck($id) {
  956.  
  957. $id = $this->parent->mysql->escape($id);
  958.  
  959. $this->parent->mysql->query("UPDATE {$this->parent->config->mysql->userTableName} SET curneck='$id' WHERE id='" . $this->getID() . "';");
  960.  
  961. $this->sendRoom("%xt%upn%-1%{$this->getID()}%" . $id . "%");
  962.  
  963. $this->neck = $id;
  964.  
  965. }
  966.  
  967. public function setBody($id) {
  968.  
  969. $id = $this->parent->mysql->escape($id);
  970.  
  971. $this->parent->mysql->query("UPDATE {$this->parent->config->mysql->userTableName} SET curbody='$id' WHERE id='" . $this->getID() . "';");
  972.  
  973. $this->sendRoom("%xt%upb%-1%{$this->getID()}%" . $id . "%");
  974.  
  975. $this->body = $id;
  976.  
  977. }
  978.  
  979. public function setHands($id) {
  980.  
  981. $id = $this->parent->mysql->escape($id);
  982.  
  983. $this->parent->mysql->query("UPDATE {$this->parent->config->mysql->userTableName} SET curhands='$id' WHERE id='" . $this->getID() . "';");
  984.  
  985. $this->sendRoom("%xt%upa%-1%{$this->getID()}%" . $id . "%");
  986.  
  987. $this->hands = $id;
  988.  
  989. }
  990.  
  991. public function setFeet($id) {
  992.  
  993. $id = $this->parent->mysql->escape($id);
  994.  
  995. $this->parent->mysql->query("UPDATE {$this->parent->config->mysql->userTableName} SET curfeet='$id' WHERE id='" . $this->getID() . "';");
  996.  
  997. $this->sendRoom("%xt%upe%-1%{$this->getID()}%" . $id . "%");
  998.  
  999. $this->feet = $id;
  1000.  
  1001. }
  1002.  
  1003. public function setPin($id) {
  1004.  
  1005. $id = $this->parent->mysql->escape($id);
  1006.  
  1007. $this->parent->mysql->query("UPDATE {$this->parent->config->mysql->userTableName} SET curflag='$id' WHERE id='" . $this->getID() . "';");
  1008.  
  1009. $this->sendRoom("%xt%upl%-1%{$this->getID()}%" . $id . "%");
  1010.  
  1011. $this->pin = $id;
  1012.  
  1013. }
  1014.  
  1015. public function setPhoto($id) {
  1016.  
  1017. $id = $this->parent->mysql->escape($id);
  1018.  
  1019. $this->parent->mysql->query("UPDATE {$this->parent->config->mysql->userTableName} SET curphoto='$id' WHERE id='" . $this->getID() . "';");
  1020.  
  1021. $this->sendRoom("%xt%upp%-1%{$this->getID()}%" . $id . "%");
  1022.  
  1023. $this->photo = $id;
  1024.  
  1025. }
  1026.  
  1027. public function setColour($id) {
  1028.  
  1029. $id = $this->parent->mysql->escape($id);
  1030.  
  1031. $this->parent->mysql->query("UPDATE {$this->parent->config->mysql->userTableName} SET colour='$id' WHERE id='" . $this->getID() . "';");
  1032.  
  1033. $this->sendRoom("%xt%upc%-1%{$this->getID()}%" . $id . "%");
  1034.  
  1035. $this->colour = $id;
  1036.  
  1037. }
  1038.  
  1039. public function setCoins($coins) {
  1040.  
  1041. $coins = $this->parent->mysql->escape($coins);
  1042.  
  1043. $this->parent->mysql->query("UPDATE {$this->parent->config->mysql->userTableName} SET coins='$coins' WHERE id='" . $this->getID() . "';");
  1044.  
  1045. $this->sendPacket("%xt%zo%-1%" . $coins . "%Open%CP%");
  1046.  
  1047. }
  1048.  
  1049. public function setXY($x, $y) {
  1050.  
  1051. $this->x = $x;
  1052.  
  1053. $this->y = $y;
  1054.  
  1055. $this->sendRoom("%xt%sp%-1%" . $this->getID() . "%$x%$y%");
  1056.  
  1057. }
  1058.  
  1059. public function setFrame($frame) {
  1060.  
  1061. $this->frame = $frame;
  1062.  
  1063. $this->sendRoom("%xt%sf%-1%" . $this->getID() . "%" . $frame . "%");
  1064.  
  1065. }
  1066.  
  1067. public function setAction($action) {
  1068.  
  1069. $this->frame = 1;
  1070.  
  1071. $this->sendRoom("%xt%sf%-1%" . $this->getID() . "%" . $action . "%");
  1072.  
  1073. }
  1074.  
  1075. public function speak($msg = "I need friends") {
  1076.  
  1077. $this->sendRoom("%xt%sm%-1%" . $this->getID() . "%" . htmlspecialchars($msg) . "%");
  1078.  
  1079. $this->parent->handleCommand($this, $msg);
  1080.  
  1081. }
  1082.  
  1083. public function resetDetails() {
  1084.  
  1085. $res = $this->parent->mysql->returnArray("SELECT * FROM {$this->parent->config->mysql->userTableName} WHERE id='" . $this->getID() . "'");
  1086.  
  1087. $res = $res[0];
  1088.  
  1089. $this->username = $res["nickname"];
  1090.  
  1091. $this->head = $res["curhead"];
  1092.  
  1093. $this->face = $res["curface"];
  1094.  
  1095. $this->neck = $res["curneck"];
  1096.  
  1097. $this->body = $res["curbody"];
  1098.  
  1099. $this->hands = $res["curhands"];
  1100.  
  1101. $this->feet = $res["curfeet"];
  1102.  
  1103. $this->pin = $res["curflag"];
  1104.  
  1105. $this->photo = $res["curphoto"];
  1106.  
  1107. $this->colour = $res["colour"];
  1108.  
  1109. $this->age = round((strtotime("NOW") - strtotime($res['joindate'])) / (60 * 60 * 24));
  1110.  
  1111. $this->coins = $res["coins"];
  1112.  
  1113. $this->isModerator = $res["ismoderator"];
  1114.  
  1115. $this->inventory = explode(",", $res["items"]);
  1116.  
  1117. if($this->inventory[0] == "0")
  1118.  
  1119. array_shift($this->inventory);
  1120.  
  1121. $this->buddies = explode(",", $res["buddies"]);
  1122.  
  1123. $this->rank = $res["rank"];
  1124.  
  1125. $this->isMember = $res["isMember"];
  1126.  
  1127. }
  1128.  
  1129. public function getBuddyStr(){
  1130.  
  1131. $buddyStr = "";
  1132.  
  1133. foreach($this->buddies as $buddyID){
  1134.  
  1135. $buddyInfo = $this->parent->mysql->returnArray("SELECT * FROM {$this->parent->config->mysql->userTableName} WHERE id='" . $this->parent->mysql->escape($buddyID) . "';");
  1136.  
  1137. $buddyName = $buddyInfo[0]["nickname"];
  1138.  
  1139. $isOnline = false;
  1140.  
  1141. foreach($this->parent->users as &$user){
  1142.  
  1143. if($user->getID() == $buddyID){
  1144.  
  1145. $isOnline = true;
  1146.  
  1147. break;
  1148.  
  1149. }
  1150.  
  1151. }
  1152.  
  1153. $buddyStr .= "$buddyID|" . $buddyName . "|" . $isOnline . "%";
  1154.  
  1155. }
  1156.  
  1157. if($buddyStr == "")
  1158.  
  1159. $buddyStr = "%";
Add Comment
Please, Sign In to add comment