예제 #1
0
 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;
 }
예제 #2
0
 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);
 }
예제 #3
0
 private function WriteData($Command, $String = "")
 {
     // Pack the packet together
     $Data = Pack('VV', $this->RequestId++, $Command) . $String . "";
     // Prepend packet length
     $Data = Pack('V', StrLen($Data)) . $Data;
     $Length = StrLen($Data);
     return $Length === FWrite($this->Socket, $Data, $Length);
 }
예제 #4
0
 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);
 }
예제 #5
0
 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);
     }
 }
 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);
 }
예제 #7
0
 public function Write($Header, $String = '')
 {
     $Command = Pack('ccccca*', 0xff, 0xff, 0xff, 0xff, $Header, $String);
     $Length = StrLen($Command);
     return $Length === FWrite($this->Socket, $Command, $Length);
 }
예제 #8
0
파일: W1.comp.php 프로젝트: carriercomm/jbs
            $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;
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
예제 #9
0
 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);
 }
예제 #10
0
파일: W1.comp.php 프로젝트: carriercomm/jbs
#-------------------------------------------------------------------------------
$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);
}