Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class CacheD {
- var $cachedport;
- var $cachedip;
- var $webadmin;
- var $connected;
- //To have explicit output, use CacheD_chatterbox, better than editing this array
- var $fsockerror = false;
- var $socketerrors = array(
- "1" => True, "01" => False, "02" => False, "03" => False, "04" => False,
- "05" => False, "06" => False, "07" => False, "08" => False, "09" => False,
- "010" => False, "011" => False, "012" => False, "013" => False, "014" => False,
- "015" => False, "016" => False, "017" => False, "018" => False, "019" => False,
- "020" => False, "021" => False, "022" => False, "023" => False, "024" => False,
- "025" => False, "026" => False);
- function tounicode($string)
- {
- $rs = "";
- $rs .= mb_convert_encoding($string, "UCS-2LE", "UTF-8");
- $rs .= pack("v", 0);
- return $rs;
- }
- function CacheDInteractive($buf) {
- $fp = fsockopen($this->cachedip, $this->cachedport , $errno, $errstr, 5);
- $rs = '';
- if (!$fp){ $this->connected=false; return $this -> fsockerror;}
- else $this->connected=true;
- $packet = pack("s", (strlen($buf)+2)).$buf;
- fwrite($fp, $packet);
- $len = unpack("v", fread($fp, 2));
- $rid = unpack("c", fread($fp, 1));
- for ($i = 0;$i < (($len[1]-4) / 4);$i++) {
- $read = unpack("i", fread($fp, 4));
- $rs .= $read[1];
- }
- fclose($fp);
- $result = $this -> socketerrors[$rs];
- return($result);
- }
- function KickCharacterPacket($char_id){
- $buf = pack("cV",5,$char_id);
- $buf .= $this -> tounicode($this -> webadmin);
- return $this -> CacheDInteractive($buf);
- }
- function AddItem3Packet($char_id,$warehouse,$item_type,$q,$enchant,$attack_type,$attack_value,$fire,$water,$wind,$earth,$holy,$unholy) {
- $bless = 0;
- $q_h = intval($q / 0x100000000);
- if ($q_h < 0) {
- $q_h = 0;
- } else {
- $q = $q - ($q_h * 0x100000000);
- }
- $buf = pack("c", 55);
- $buf .= pack("V", $char_id);
- $buf .= pack("V", $warehouse);
- $buf .= pack("V", $item_type);
- $buf .= pack("V", $q);
- $buf .= pack("V", $q_h);
- $buf .= pack("V", $enchant);
- $buf .= pack("V", 0);
- $buf .= pack("V", 0);
- $buf .= pack("V", 0);
- $buf .= pack("V", 0);
- $buf .= pack("V", 0);
- $buf .= pack("V", 0);
- $buf .= pack("V", 0);
- $buf .= pack("V", 0);
- $buf .= pack("v", $attack_type);
- $buf .= pack("v", $attack_value);
- $buf .= pack("v", $fire);
- $buf .= pack("v", $water);
- $buf .= pack("v", $wind);
- $buf .= pack("v", $earth);
- $buf .= pack("v", $holy);
- $buf .= pack("v", $unholy);
- $buf .= $this -> tounicode($this -> webadmin);
- return $this -> CacheDInteractive($buf);
- }
- class CacheD_chatterbox extends CacheD {
- var $fsockerror = 'Unable to connect with CacheD';
- var $socketerrors=array(
- "1" => "OK.",
- "01" => "Error.",
- "02" => "Arguments need.",
- "03" => "Arguments invalid.",
- "04" => "Char not found.",
- "05" => "Warehouse not found.",
- "06" => "Account not found.",
- "07" => "Char in game.",
- "08" => "Too many chars.",
- "09" => "Char in pledge.",
- "010" => "Char pledge owner.",
- "011" => "Cannot ban.",
- "012" => "Name exist.",
- "013" => "Obsolete.",
- "014" => "Invalid char name.",
- "015" => "Char not in game.",
- "016" => "Same char",
- "017" => "Char not in pledge.",
- "018" => "Char pledge master.",
- "019" => "Server not connected.",
- "020" => "Create pet failed.",
- "021" => "Pledge exist.",
- "022" => "No chars.",
- "023" => "Invalid announce id.",
- "024" => "Pledge not found.",
- "025" => "Castle not found.",
- "026" => "Pet not found.");
- }
- class CacheD_color_chatterbox extends CacheD {
- var $fsockerror = '<b><font color=red>Unable to connect with CacheD</font></b>';
- var $socketerrors=array(
- "1" => "<b><font color=green> Done.</font></b>",
- "01" => "<b><font color=red> Error.</font></b>",
- "02" => "<b><font color=red> Arguments need.</font></b>",
- "03" => "<b><font color=red> Arguments invalid.</font></b>",
- "04" => "<b><font color=red> Char not found.</font></b>",
- "05" => "<b><font color=red> Warehouse not found.</font></b>",
- "06" => "<b><font color=red> Account not found.</font></b>",
- "07" => "<b><font color=red> Char in game.</font></b>",
- "08" => "<b><font color=red> Too many chars.</font></b>",
- "09" => "<b><font color=red> Char in pledge.</font></b>",
- "010" => "<b><font color=red> Char pledge owner.</font></b>",
- "011" => "<b><font color=red> Cannot ban.</font></b>",
- "012" => "<b><font color=red> Name exist.</font></b>",
- "013" => "<b><font color=red> Obsolete.</font></b>",
- "014" => "<b><font color=red> Invalid char name.</font></b>",
- "015" => "<b><font color=red> Char not in game.</font></b>",
- "016" => "<b><font color=red> Same char</font></b>",
- "017" => "<b><font color=red> Char not in pledge.</font></b>",
- "018" => "<b><font color=red> Char pledge master.</font></b>",
- "019" => "<b><font color=red> Server not connected.</font></b>",
- "020" => "<b><font color=red> Create pet failed.</font></b>",
- "021" => "<b><font color=red> Pledge exist.</font></b>",
- "022" => "<b><font color=red> No chars.</font></b>",
- "023" => "<b><font color=red> Invalid announce id.</font></b>",
- "024" => "<b><font color=red> Pledge not found.</font></b>",
- "025" => "<b><font color=red> Castle not found.</font></b>",
- "026" => "<b><font color=red> Pet not found.</font></b>");
- }
- $cec = new CacheD();
- $cec->cachedport = 2012;
- $cec->cachedip = '127.0.0.1';
- $cec->webadmin = 'WebAdmin';
- var_dump($cec->KickCharacterPacket(2));
- var_dump($cec->AddItem3Packet(1,0,6607,1,3,1,150,0,0,0,0,0,0));
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement