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; }
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); }
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); }
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); }
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); }
public function Write($Header, $String = '') { $Command = Pack('ccccca*', 0xff, 0xff, 0xff, 0xff, $Header, $String); $Length = StrLen($Command); return $Length === FWrite($this->Socket, $Command, $Length); }
$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; #------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
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); }
#------------------------------------------------------------------------------- $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); }