当前位置: 首页>>代码示例>>PHP>>正文


PHP Pack函数代码示例

本文整理汇总了PHP中Pack函数的典型用法代码示例。如果您正苦于以下问题:PHP Pack函数的具体用法?PHP Pack怎么用?PHP Pack使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Pack函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Query

 public function Query()
 {
     $Length = StrLen($this->ServerIP);
     $Data = Pack('cccca*', HexDec($Length), 0, 0x4, $Length, $this->ServerIP) . Pack('nc', $this->ServerPort, 0x1);
     Socket_Send($this->Socket, $Data, StrLen($Data), 0);
     // handshake
     Socket_Send($this->Socket, "", 2, 0);
     // status ping
     $Length = $this->ReadVarInt();
     // full packet length
     if ($Length < 10) {
         return FALSE;
     }
     Socket_Read($this->Socket, 1);
     // packet type, in server ping it's 0
     $Length = $this->ReadVarInt();
     // string length
     $Data = Socket_Read($this->Socket, $Length, PHP_NORMAL_READ);
     // and finally the json string
     if ($Data === FALSE) {
         throw new MinecraftPingException('Server didn\'t return any data');
     }
     $Data = JSON_Decode($Data, true);
     if (JSON_Last_Error() !== JSON_ERROR_NONE) {
         if (Function_Exists('json_last_error_msg')) {
             throw new MinecraftPingException(JSON_Last_Error_Msg());
         } else {
             throw new MinecraftPingException('JSON parsing failed');
         }
         return FALSE;
     }
     return $Data;
 }
开发者ID:Cretezy,项目名称:Minecraft,代码行数:33,代码来源:MinecraftServerPing.php

示例2: WriteData

 private function WriteData($Command, $String = "")
 {
     $Data = Pack('VV', $this->RequestId++, $Command) . $String . "";
     $Data = Pack('V', StrLen($Data)) . $Data;
     $Length = StrLen($Data);
     return $Length === FWrite($this->Socket, $Data, $Length);
 }
开发者ID:Najlepszy56,项目名称:Minecraft-Itemshop,代码行数:7,代码来源:rcon.php

示例3: Write

 public function Write($Header, $String = '')
 {
     // Pack the packet together
     $Command = Pack('VV', ++$this->RconRequestId, $Header) . $String . "";
     // Prepend packet length
     $Command = Pack('V', StrLen($Command)) . $Command;
     $Length = StrLen($Command);
     return $Length === FWrite($this->RconSocket, $Command, $Length);
 }
开发者ID:ezpz-cz,项目名称:web-pages,代码行数:9,代码来源:SourceRcon.class.php

示例4: Write

 public function Write($Header, $String = '')
 {
     switch ($this->Socket->Engine) {
         case CI_SourceQuery::GOLDSOURCE:
             $Command = Pack('cccca*', 0xff, 0xff, 0xff, 0xff, $String);
             $Length = StrLen($Command);
             return $Length === FWrite($this->Socket->Socket, $Command, $Length);
         case CI_SourceQuery::SOURCE:
             // Pack the packet together
             $Command = Pack('VV', ++$this->RequestId, $Header) . $String . "";
             // Prepend packet length
             $Command = Pack('V', StrLen($Command)) . $Command;
             $Length = StrLen($Command);
             return $Length === FWrite($this->RconSocket, $Command, $Length);
     }
 }
开发者ID:mefisto2009,项目名称:GameAP,代码行数:16,代码来源:Rcon.class.php

示例5: WriteData

 private function WriteData($Command, $Append = "")
 {
     $Command = Pack('c*', 0xfe, 0xfd, $Command, 0x1, 0x2, 0x3, 0x4) . $Append;
     $Length = StrLen($Command);
     if ($Length !== FWrite($this->Socket, $Command, $Length)) {
         throw new MinecraftQueryException("Failed to write on socket.");
     }
     $Data = FRead($this->Socket, 2048);
     if ($Data === false) {
         throw new MinecraftQueryException("Failed to read from socket.");
     }
     if (StrLen($Data) < 5 || $Data[0] != $Command[2]) {
         return false;
     }
     return SubStr($Data, 5);
 }
开发者ID:0651,项目名称:Cyanide-Services,代码行数:16,代码来源:MinecraftQuery.class.php

示例6: Write

 public function Write($Header, $String = '')
 {
     $Command = Pack('ccccca*', 0xff, 0xff, 0xff, 0xff, $Header, $String);
     $Length = StrLen($Command);
     return $Length === FWrite($this->Socket, $Command, $Length);
 }
开发者ID:ezpz-cz,项目名称:web-pages,代码行数:6,代码来源:Socket.class.php

示例7: Iconv

            $Hash .= $v;
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
    } else {
        #-------------------------------------------------------------------------------
        //Конвертация из текущей кодировки (UTF-8)
        //необходима только если кодировка магазина отлична от Windows-1251
        $value = Iconv("utf-8", "windows-1251", $value);
        #-------------------------------------------------------------------------------
        $Hash .= $value;
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
// Формирование значения параметра WMI_SIGNATURE, путем
// вычисления отпечатка, сформированного выше сообщения,
// по алгоритму MD5 и представление его в Base64
Debug(SPrintF('[comp/Invoices/PaymentSystems/W1]: Hash = %s', $Hash));
#-------------------------------------------------------------------------------
$Send['WMI_SIGNATURE'] = Base64_Encode(Pack("H*", sha1($Hash . $Settings['Hash'])));
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# так как CSRF уже есть, удаляем её из списка полей, иначе задублируется
unset($Send['CSRF']);
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
return $Send;
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
开发者ID:carriercomm,项目名称:jbs,代码行数:31,代码来源:W1.comp.php

示例8: WriteData

 private function WriteData($Command, $Append = "")
 {
     $Command = Pack('c*', 0xfe, 0xfd, $Command, 0x1, 0x2, 0x3, 0x4) . $Append;
     $Length = StrLen($Command);
     if ($Length !== FWrite($this->Socket, $Command, $Length)) {
         return false;
     }
     $Data = FRead($this->Socket, 1440);
     if (StrLen($Data) < 5 || $Data[0] != $Command[2]) {
         return false;
     }
     return SubStr($Data, 5);
 }
开发者ID:CrystReal,项目名称:Site_frontend,代码行数:13,代码来源:MinecraftQuery.php

示例9: Config

#-------------------------------------------------------------------------------
$Config = Config();
#-------------------------------------------------------------------------------
$Settings = $Config['Invoices']['PaymentSystems']['W1'];
#-------------------------------------------------------------------------------
UkSort($Args, "strcasecmp");
#-------------------------------------------------------------------------------
$Values = "";
#-------------------------------------------------------------------------------
foreach ($Args as $Key => $Value) {
    if ($Key != "WMI_SIGNATURE") {
        $Values .= $Value;
    }
}
#-------------------------------------------------------------------------------
if (Base64_Encode(Pack("H*", sha1($Values . $Settings['Hash']))) != $Args['WMI_SIGNATURE']) {
    return ERROR | @Trigger_Error('[comp/www/Merchant/W1]: проверка подлинности завершилась не удачей');
}
#-------------------------------------------------------------------------------
$Invoice = DB_Select('Invoices', array('ID', 'Summ'), array('UNIQ', 'ID' => $OrderID));
#-------------------------------------------------------------------------------
switch (ValueOf($Invoice)) {
    case 'error':
        return ERROR | @Trigger_Error(500);
    case 'exception':
        return ERROR | @Trigger_Error(400);
    case 'array':
        break;
    default:
        return ERROR | @Trigger_Error(101);
}
开发者ID:carriercomm,项目名称:jbs,代码行数:31,代码来源:W1.comp.php


注:本文中的Pack函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。