[SCRIPT] Скрипт для работы с CacheD

Тема в разделе "Веб скрипты (WEB)", создана пользователем root, 5 окт 2014.

  1. root

    root Administrator Команда форума Administrator Moderator Developers Team

    Регистрация:
    23 авг 2014
    Сообщения:
    253
    Симпатии:
    56
    Баллы:
    11
    Код:
    <?php ############################################### 
    # id | Function Name(Function parms) # 
    ############################################### 
    
    
    #d = int (4 bytes, little endian) 
    #S = unicode String ending with 
    #f = float 
    
    
    #1 CheckCharacterPacket("dS") 
    #2 SetCharacterLocationPacket("dddddS") 
    #3 SetBuilderCharacterPacket("ddS") 
    #4 ChangeCharacterNamePacket("dSS") 
    #5 KickCharacterPacket("dS") 
    #6 AddSkillPacket("dddS") 
    #7 DelSkillPacket("ddS") 
    #8 ModSkillPacket("dddS") 
    #9 SetOnetimeQuestPacket("dddS") 
    #10 SetQuestPacket("ddd") 
    #11 DelQuestPacket("ddS") 
    #12 AddItemPacket() 
    #13 DelItemPacket("ddddS") 
    #14 ModItemPacket("ddddddddddS") 
    #15 ModCharPacket("dddddddS") 
    #16 ModChar2Packet("dddddddS") 
    #17 ModCharPledgePacket("dSS") 
    #18 PunishCharPacket("ddd") 
    #19 SetBuilderAccountPacket("SdS") 
    #20 DisableCharacterPacket("ddS") 
    #21 EnableCharacterPacket("ddS") 
    #22 GetCharactersPacket() 
    #23 SetBookMarkPacket("dSddddS") 
    #24 DelBookMarkPacket("dSS") 
    #25 DelPledgeCrestPacket("dS") 
    #26 ModPledgeNamePacket("dSS") 
    #27 SetProhibitedPacket("dSS") 
    #28 SeizeItemPacket("ddddS") 
    #29 ModChar3Packet("dddddddS") 
    #30 MoveItemPacket("ddddd") 
    #31 MoveCharacterPacket("ddSS") 
    #32 CommentWritePacket("dSSS") 
    #33 CommentDeletePacket("ddS") 
    #34 DeleteCharPacket("dS") 
    #35 RestoreCharPacket("ddSS") 
    #36 PledgeOustPacket("dS") 
    #37 PledgeChangeOwnerPacket("ddS") 
    #38 PledgeDeletePacket() 
    #39 BanCharPacket("ddS") 
    #40 MoveItem2Packet("ddddS") 
    #41 PrintAllAccountData() 
    #42 PrintAllItemData() 
    #43 CopyCharPacket("dSdSS") 
    #44 CreatePetPacket("dddS") 
    #45 SendHomePacket("dS") 
    #46 ChangePledgeLevelPacket("ddS") 
    #47 CreatePledgePacket("SdS") 
    #48 SetSkillAllPacket("dS") 
    #49 RestoreChar2Packet("dSdSS") 
    #50 ManAnnouncePacket("ddSS") 
    #51 ManIntAnnouncePacket("dddSS") 
    #52 ModWeekPlayPacket("dddS") 
    #53 SeizeItem2Packet("ddS") 
    #54 DelItem2Packet("ddS") 
    #55 AddItem2Packet("dddddddddS") 
    #56 GetCharacters2Packet("dS") 
    #57 DelMacroPacket("ddS") 
    #58 DelMonRaceTicketPacket("dddS") 
    #59 DelRecipePacket("ddS") 
    #60 DelLottoPacket() 
    #61 ModifyPledgePowerPacket("ddSS") 
    #62 EventPointPacket("df") 
    #63 GetPledgePacket("dS") 
    #64 EventPointPacket("df") 
    #65 CreateCharacterPacket("SSddddddddffddddddddddS") 
    #66 AddItemsPacket("dSd") 
    #67 AddSkillsPacket("dSd") 
    #68 GetCharacters3Packet("dS") 
    #69 SetSociality("ddS") 
    #70 SetInstantAnnouncePacket("SS" or "cdS") (??) 
    #71 DelHennaPacket("ddS") 
    #72 AddHennaPacket("ddS") 
    #73 AddHennaPacket("dSddS") 
    #74 AddHennasPacket("dSd") 
    #75 GetCastleListPacket("ddSdSdSddd") 
    #76 ModifyCharPropertyPacket("ddddddddS") 
    #77 ModifyCharAbilityDeltaPacket("ddddddddS") 
    #78 ModifyCharAbilityDeltaPacket("ddddddddS") 
    #79 DelHenna2Packet("dddS") 
    #80 AddHenna2Packet("dddS") 
    #81 AddSkill2Packet("ddddS") 
    #82 DelSkill2Packet("dddS") 
    #83 ModifySkill2Packet("ddddS") 
    #84 AddMacroPacket("dSSSdS") 
    #85 GetSSQStatusPacket("cdddddddddddd") 
    #86 GetSSQMainEventRecordPacket("dddddddSd") 
    #87 ModifyDepositedSSQItemPacket("ddddS") 
    #88 ChangePetNamePacket("ddSS") 
    #89 ChangeSubJobPacket("ddS") 
    #90 StopCharPacket("dd") 
    #91 CancelPersonalShopPacket("dd") 
    #92 AddMacroInfoPacket("ddddddSS") 
    #93 CreateCharacter2Packet("SSddddddddffddddddddddddfS") 
    #94 AddSkills2Packet("dSd") 
    #95 AddHennas2Packet("dSd") 
    #96 AddSubjobsPacket("dSd") 
    #97 GetPledge2Packet("dS") 
    #98 DelPledgeEmblemPacket("dS") 
    #99 RegisterAccountPacket("SS") 
    #100 DelPledgeAnnouncePacket("dS") 
    #101 SendPrivateAnnouncePacket("dSS") 
    #102 GetAgitListPacket("dSdSdSdd") 
    #103 GetPledgeMemberPacket("dS") 
    #104 EternalBanPacket("dS") 
    #105 GetCharacters4Packet("dS") 
    #106 SetNoblessPacket("ddS") 
    #107 SetHeroPacket("ddS") 
    #108 SetPartyLocationPacket("ddddS") 
    #109 ModOlympiadPointPacket("ddddS") 
    #110 DummyPacket() 
    
    
    $char_id = 3; 
    $newname = "KciNicK"; 
    
    
    printf("The character %s is %s\n", $char_id, CheckCharacterPacket($char_id) == "x1" ? "online" : "offline"); 
    printf("rename character %s to '%s': %s\n", $char_id, $newname, ChangeCharacterNamePacket($char_id, $newname) == "x1" ? "ok" : "error"); 
    
    
    function tounicode($string) { 
        $rs = ""; for($i = 0; $i < strlen($string); $i++) $rs .= $string[$i].chr(0); 
        return($rs.chr(0).chr(0)); 
    } 
    
    
    function CheckCharacterPacket($p0) { 
        $fp = fsockopen("127.0.0.1", "2012", $errno, $errstr, 5); $rs = "x"; 
        if (!$fp) die("<script>alert('Error connecting to cached: $errstr 
    [server down??]')</script>"); 
    
    
        $buf = pack("c", 1); // 1 = CheckCharacterPacket(); 
        $buf .= pack("i", $p0); //char_id 
    
    
        fwrite($fp, pack("s", (strlen($buf)+2)).$buf); 
        $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); return($rs); 
    } 
    
    
    function ChangeCharacterNamePacket($p0, $p1) { 
        $fp = fsockopen("127.0.0.1", "2012", $errno, $errstr, 5); $rs = "x"; 
        if (!$fp) die("<script>alert('Error connecting to cached: $errstr 
    [server down??]')</script>"); 
    
    
        $buf = pack("c", 4); // 4 = ChangeCharacterNamePacket(); 
        $buf .= pack("i", $p0); //char_id 
        $buf .= tounicode($p1); //new char name 
    
    
        fwrite($fp, pack("s", (strlen($buf)+2)).$buf); 
        $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); return($rs); 
    } 
    ?> 
     
  2. root

    root Administrator Команда форума Administrator Moderator Developers Team

    Регистрация:
    23 авг 2014
    Сообщения:
    253
    Симпатии:
    56
    Баллы:
    11
    Код:
    function AddItem2Packet($charid,$item_wh,$item_id,$item_amount,$item_enchant) {        $buf = pack("c", 55);
            $buf .= pack("V", $charid);
            $buf .= pack("V", $item_wh);
            $buf .= pack("V", $item_id);
            $buf .= pack("V", $item_amount);
            $buf .= pack("V", $item_enchant);
                $buf .= pack("V", 0);
                $buf .= pack("V", 0);
                $buf .= pack("V", 0);
                $buf .= pack("V", 1);
            $buf .= $this -> tounicode($this -> webadmin);
            return $this -> CacheDInteractive($buf);
        }
    Код:
    function AddItem2Packet($charid,$item_wh,$item_id,$item_amount,$item_enchant) {        $buf = pack("c", 55);
            $buf .= pack("i", $charid);
            $buf .= pack("i", $item_wh);
            $buf .= pack("i", $item_id);
            $buf .= pack("i", $item_amount);
            $buf .= pack("i", $item_enchant);
                $buf .= pack("i", 0);
                $buf .= pack("i", 0);
                $buf .= pack("i", 0);
                $buf .= pack("i", 0);
                $buf .= pack("i", 0);
                $buf .= pack("i", 0);
                $buf .= pack("i", 0);
                $buf .= pack("i", 0);
                $buf .= pack("i", 0);
            $buf .= $this -> tounicode($this -> webadmin);
            return $this -> CacheDInteractive($buf);
        }