Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.21 KB | None | 0 0
  1. <?php
  2.  
  3. class CacheD {
  4. var $cachedport;
  5. var $cachedip;
  6. var $webadmin;
  7. var $connected;
  8.  
  9. //To have explicit output, use CacheD_chatterbox, better than editing this array
  10. var $fsockerror = false;
  11. var $socketerrors = array(
  12. "1" => True, "01" => False, "02" => False, "03" => False, "04" => False,
  13. "05" => False, "06" => False, "07" => False, "08" => False, "09" => False,
  14. "010" => False, "011" => False, "012" => False, "013" => False, "014" => False,
  15. "015" => False, "016" => False, "017" => False, "018" => False, "019" => False,
  16. "020" => False, "021" => False, "022" => False, "023" => False, "024" => False,
  17. "025" => False, "026" => False);
  18.  
  19. function tounicode($string)
  20. {
  21. $rs = "";
  22. $rs .= mb_convert_encoding($string, "UCS-2LE", "UTF-8");
  23. $rs .= pack("v", 0);
  24. return $rs;
  25. }
  26.  
  27. function CacheDInteractive($buf) {
  28. $fp = fsockopen($this->cachedip, $this->cachedport , $errno, $errstr, 5);
  29. $rs = '';
  30. if (!$fp){ $this->connected=false; return $this -> fsockerror;}
  31. else $this->connected=true;
  32.  
  33. $packet = pack("s", (strlen($buf)+2)).$buf;
  34. fwrite($fp, $packet);
  35. $len = unpack("v", fread($fp, 2));
  36. $rid = unpack("c", fread($fp, 1));
  37. for ($i = 0;$i < (($len[1]-4) / 4);$i++) {
  38. $read = unpack("i", fread($fp, 4));
  39. $rs .= $read[1];
  40. }
  41. fclose($fp);
  42. $result = $this -> socketerrors[$rs];
  43. return($result);
  44. }
  45.  
  46. function KickCharacterPacket($char_id){
  47. $buf = pack("cV",5,$char_id);
  48. $buf .= $this -> tounicode($this -> webadmin);
  49. return $this -> CacheDInteractive($buf);
  50. }
  51.  
  52. function AddItem3Packet($char_id,$warehouse,$item_type,$q,$enchant,$attack_type,$attack_value,$fire,$water,$wind,$earth,$holy,$unholy) {
  53. $bless = 0;
  54. $q_h = intval($q / 0x100000000);
  55. if ($q_h < 0) {
  56. $q_h = 0;
  57. } else {
  58. $q = $q - ($q_h * 0x100000000);
  59. }
  60. $buf = pack("c", 55);
  61. $buf .= pack("V", $char_id);
  62. $buf .= pack("V", $warehouse);
  63. $buf .= pack("V", $item_type);
  64. $buf .= pack("V", $q);
  65. $buf .= pack("V", $q_h);
  66. $buf .= pack("V", $enchant);
  67. $buf .= pack("V", 0);
  68. $buf .= pack("V", 0);
  69. $buf .= pack("V", 0);
  70. $buf .= pack("V", 0);
  71. $buf .= pack("V", 0);
  72. $buf .= pack("V", 0);
  73. $buf .= pack("V", 0);
  74. $buf .= pack("V", 0);
  75. $buf .= pack("v", $attack_type);
  76. $buf .= pack("v", $attack_value);
  77. $buf .= pack("v", $fire);
  78. $buf .= pack("v", $water);
  79. $buf .= pack("v", $wind);
  80. $buf .= pack("v", $earth);
  81. $buf .= pack("v", $holy);
  82. $buf .= pack("v", $unholy);
  83. $buf .= $this -> tounicode($this -> webadmin);
  84. return $this -> CacheDInteractive($buf);
  85. }
  86.  
  87. class CacheD_chatterbox extends CacheD {
  88. var $fsockerror = 'Unable to connect with CacheD';
  89. var $socketerrors=array(
  90. "1" => "OK.",
  91. "01" => "Error.",
  92. "02" => "Arguments need.",
  93. "03" => "Arguments invalid.",
  94. "04" => "Char not found.",
  95. "05" => "Warehouse not found.",
  96. "06" => "Account not found.",
  97. "07" => "Char in game.",
  98. "08" => "Too many chars.",
  99. "09" => "Char in pledge.",
  100. "010" => "Char pledge owner.",
  101. "011" => "Cannot ban.",
  102. "012" => "Name exist.",
  103. "013" => "Obsolete.",
  104. "014" => "Invalid char name.",
  105. "015" => "Char not in game.",
  106. "016" => "Same char",
  107. "017" => "Char not in pledge.",
  108. "018" => "Char pledge master.",
  109. "019" => "Server not connected.",
  110. "020" => "Create pet failed.",
  111. "021" => "Pledge exist.",
  112. "022" => "No chars.",
  113. "023" => "Invalid announce id.",
  114. "024" => "Pledge not found.",
  115. "025" => "Castle not found.",
  116. "026" => "Pet not found.");
  117. }
  118.  
  119. class CacheD_color_chatterbox extends CacheD {
  120. var $fsockerror = '<b><font color=red>Unable to connect with CacheD</font></b>';
  121. var $socketerrors=array(
  122. "1" => "<b><font color=green> Done.</font></b>",
  123. "01" => "<b><font color=red> Error.</font></b>",
  124. "02" => "<b><font color=red> Arguments need.</font></b>",
  125. "03" => "<b><font color=red> Arguments invalid.</font></b>",
  126. "04" => "<b><font color=red> Char not found.</font></b>",
  127. "05" => "<b><font color=red> Warehouse not found.</font></b>",
  128. "06" => "<b><font color=red> Account not found.</font></b>",
  129. "07" => "<b><font color=red> Char in game.</font></b>",
  130. "08" => "<b><font color=red> Too many chars.</font></b>",
  131. "09" => "<b><font color=red> Char in pledge.</font></b>",
  132. "010" => "<b><font color=red> Char pledge owner.</font></b>",
  133. "011" => "<b><font color=red> Cannot ban.</font></b>",
  134. "012" => "<b><font color=red> Name exist.</font></b>",
  135. "013" => "<b><font color=red> Obsolete.</font></b>",
  136. "014" => "<b><font color=red> Invalid char name.</font></b>",
  137. "015" => "<b><font color=red> Char not in game.</font></b>",
  138. "016" => "<b><font color=red> Same char</font></b>",
  139. "017" => "<b><font color=red> Char not in pledge.</font></b>",
  140. "018" => "<b><font color=red> Char pledge master.</font></b>",
  141. "019" => "<b><font color=red> Server not connected.</font></b>",
  142. "020" => "<b><font color=red> Create pet failed.</font></b>",
  143. "021" => "<b><font color=red> Pledge exist.</font></b>",
  144. "022" => "<b><font color=red> No chars.</font></b>",
  145. "023" => "<b><font color=red> Invalid announce id.</font></b>",
  146. "024" => "<b><font color=red> Pledge not found.</font></b>",
  147. "025" => "<b><font color=red> Castle not found.</font></b>",
  148. "026" => "<b><font color=red> Pet not found.</font></b>");
  149. }
  150.  
  151.  
  152. $cec = new CacheD();
  153. $cec->cachedport = 2012;
  154. $cec->cachedip = '127.0.0.1';
  155. $cec->webadmin = 'WebAdmin';
  156.  
  157. var_dump($cec->KickCharacterPacket(2));
  158. var_dump($cec->AddItem3Packet(1,0,6607,1,3,1,150,0,0,0,0,0,0));
  159.  
  160. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement