[PHP] MobilniPlatby.cz [1.0.0-beta2]

Message
Autor
jakub1000
Příspěvky: 907
Věk: 23
Registrován: 15 led 2013, 18:01
Reputation: 0
Kontaktovat uživatele:

Re: [PHP] MobilniPlatby.cz [1.0.0-beta2]

#111 Příspěvekod jakub1000 » 26 črc 2015, 10:24

Zdravím, včera jsem dostal podivné SMSky.
Používám nejnovější verzi.
1 hráč poslal SMS za 79 kč a toto mu odepsali :

Doručeno

Kód: Vybrat vše

<br /> <b>Warning</b>: unpack(): Type V: not enough input, need 4, have 0 in <b>/data/web/virtuals/62126/virtual/www/vipscript/mobilni-platby.php</b> on l 79Kc


Další posílal za 149 kč a odepsali mu toto :

Čeká na doručení

Kód: Vybrat vše

<br /> <b>Warning</b>: unpack(): Type V: not enough input, need 4, have 0 in <b>/data/web/virtuals/62126/virtual/www/vipscript/mobilni-platby.php</b> on line <b>288</b><br /> <br /> <b>Warning</b>: fread(): Length parameter must be greater than 0 in <b>/data/web/virtuals/62126/virtual/www/vipscript/mobilni-platby.php</b> on line <b>297</b><br /> <br /> <b>Warning</b>: unpack(): Type V: not enough input, need 4, have 0 in <b>/data/web/virtuals/62126/virtual/www/vipscript/mobilni-platby.php</b> on line <b>298</b><br /> Cannot connect to server RCON. Please check your settings.


U této druhé SMS nebyl nejspíše funkční server, neboť je tam psáno, že se nelze připojit na RCON, ale co ta 1 SMS ?

log
V logu nebylo nic napsáno o těchto 2 SMS.

database
Zde taky nic není.

mobilni-platby.php
Nic jsem zde neměnil již půl roku.
Spoiler: zobrazit

Kód: Vybrat vše

<?php
/**
 * Název: MobilniPlatby.cz - PHP script pro zaslání RCON příkazů na MineCraft server po odeslání prémiové SMS
 * Autor: Mysteria - http://www.mysty.cz
 * Verze: 1.0.0-beta2
 * Poslední update: 27. 7. 2014
 * Více informací & download: http://forum.fakaheda.eu/viewtopic.php?f=85&t=20682#p134652
 */

$settings = (object)[ // Nastavení serverového RCONu
      'ip'       => '93.91.250.212',
      'port'       => 26486,
      'password'    => '*******'
];

$messages = (object)[ // Nastavení chybových SMS zpráv
      'sms_bad_price'    => 'Litujeme, ale poslali jste SMS za :REALPRICE:Kc misto SMS za :PRICE:Kc.',
      'sms_not_found'    => 'Litujeme, ale poslali jste SMS, ktera nebyla automaticky rozpoznana. Kontaktujte prosim administratory.'
];

$levels = [ // Nastavení SMS levelů
   [
      'price' => 10, // Cena SMSky
    'text' => 'GVMC VIP :NICK:', // Text SMSky, :NICK: bude nahrazen skutečným nickem uvedeným v SMS, musí být unikátní v rámci všech platebních levelů
      'answer' => 'Dekujeme za podporu serveru. VIP ti bude aktivovano ihned !', // Odpověď na správně zaslanou SMS
      'commands' => [ // RCON příkazy vykonané po úspěšném zpracování SMSky, :NICK: bude nahrazen skutečným nickem uvedeným v SMS
         'pex user :NICK: group set vip'
      ]
   ], [
      'price' => 30,
      'text' => 'GVMC VIPP :NICK:',
      'answer' => 'Dekujeme za podporu serveru. VIP+ ti bude aktivovano ihned !',
      'commands' => [
         'pex user :NICK: group set vip+'
      ]
  ], [
      'price' => 50,
      'text' => 'GVMC EVIP :NICK:',
      'answer' => 'Dekujeme za podporu serveru. ExtraVIP ti bude aktivovano ihned !',
      'commands' => [
         'pex user :NICK: group set evip'
      ]
  ], [
      'price' => 79,
      'text' => 'GVMC UVIP :NICK:',
      'answer' => 'Dekujeme za podporu serveru. UltraVIP ti bude aktivovano ihned !',
      'commands' => [
         'pex user :NICK: group set uvip'
      ]
  ], [
      'price' => 99,
      'text' => 'GVMC SPON :NICK:',
      'answer' => 'Dekujeme za podporu serveru. Sponzor ti bude aktivovano ihned !',
      'commands' => [
         'pex user :NICK: group set sponzor'
      ]
  ], [
      'price' => 149,
      'text' => 'GVMC SSPON :NICK:',
      'answer' => 'Dekujeme za podporu serveru. SuperSponzor ti bude aktivovano ihned !',
      'commands' => [
         'pex user :NICK: group set ssponzor'
      ]
   ]
];

/* Do not make any changes below this line if you don't know what are you doing! */
$rcon = new Rcon($settings->ip, $settings->port, $settings->password, 3);
if (!$rcon->connect()) exit('Cannot connect to server RCON. Please check your settings.');
$url = (object)filter_input_array(INPUT_GET);
try {
   if (isset($url->shortcode)) {
      $url->sms = trim($url->sms);
      if (mb_strlen($url->shortcode) === 7) {
         $realPrice = (int)substr($url->shortcode, -2, 2);
         foreach ($levels as $level) {
            $level = (object)$level;
            if ($level->price >= 100) continue;
            $realNick = explode(' ', $url->sms)[array_search(':NICK:', explode(' ', $level->text))];
            if (strtolower($url->sms) === strtolower(str_replace(':NICK:', $realNick, $level->text))) {
               if ($realPrice === $level->price) {
                  foreach ($level->commands as $command) $rcon->send_command(str_replace(':NICK:', $realNick, $command));
                  File::write('./mobilni-platby.log', date('d. m. Y H:i:s', time()) . " => [SUCCESS] SMS zpráva s obsahem '$url->sms' s cenou {$realPrice}Kč byla úspěšně zpracována." . PHP_EOL);
                  header('Content-type:text/plain');
                  header('Content-length:' . mb_strlen($level->answer));
                  exit($level->answer);
               } else {
                  File::write('./mobilni-platby.log', date('d. m. Y H:i:s', time()) . " => [!ERROR!] SMS zpráva s obsahem '$url->sms' s cenou {$realPrice}Kč nebyla zpracována, protože měla mít cenu {$level->price}Kč." . PHP_EOL);
                  $answer = str_replace(':PRICE:', $level->price, str_replace(':REALPRICE:', $realPrice, $messages->sms_bad_price));
                  header('Content-type:text/plain');
                  header('Content-length:' . mb_strlen($answer));
                  exit($answer);
               }
            }
         }
         File::write('./mobilni-platby.log', date('d. m. Y H:i:s', time()) . " => [!ERROR!] SMS zpráva s obsahem '$url->sms' s cenou {$realPrice}Kč nebyla zpracována, protože nebyla rozpoznána." . PHP_EOL);
         header('Content-type:text/plain');
         header('Content-length:' . mb_strlen($messages->sms_not_found));
         exit($messages->sms_not_found);
      } else {
         foreach ($levels as $level) {
            $level = (object)$level;
            if ($level->price <= 99) continue;
            $realNick = explode(' ', $url->sms)[array_search(':NICK:', explode(' ', $level->text))];
            if (strtolower($url->sms) === strtolower(str_replace(':NICK:', $realNick, $level->text))) {
               $file = "./database/$url->id.txt";
               $commands = NULL;
               foreach ($level->commands as $command) $commands .= str_replace(':NICK:', $realNick, $command) . ';;;';
               File::write($file, $commands);
               $level->answer .= ";90333$level->price";
               File::write('./mobilni-platby.log', date('d. m. Y H:i:s', time()) . " => [SUCCESS] SMS zpráva ID $url->id s obsahem '$url->sms' s cenou {$level->price}Kč byla úspěšně zpracována." . PHP_EOL);
               header('Content-type:text/plain');
               header('Content-length:' . mb_strlen($level->answer));
               exit($level->answer);
            }
         }
         File::write('./mobilni-platby.log', date('d. m. Y H:i:s', time()) . " => [!ERROR!] SMS zpráva ID $url->id s obsahem '$url->sms' s cenou {$level->price}Kč nebyla zpracována, protože nebyla rozpoznána." . PHP_EOL);
         header('Content-type:text/plain');
         header('Content-length:' . mb_strlen($messages->sms_not_found));
         exit("$messages->sms_not_found;FREE90333199");
      }
   } elseif (isset($url->request)) {
      if ($url->status === 'DELIVERED') {
         $file = "./database/$url->request.txt";
         if (is_array($commands = explode(';;;', File::read($file)))) foreach ($commands as $command) $rcon->send_command($command);
         File::remove($file);
         File::write('./mobilni-platby.log', date('d. m. Y H:i:s', time()) . " => [SUCCESS] Doručenka SMS zprávy ID $url->request byla úspěšně zpracována." . PHP_EOL);
      } else File::write('./mobilni-platby.log', date('d. m. Y H:i:s', time()) . " => [!ERROR!] Doručenka SMS zprávy ID $url->request nebyla zpracována, protože přišla se statusem $url->status ($url->message)." . PHP_EOL);
      header('HTTP/1.1 204 No Content');
      exit;
   }
} catch (\FileException $e) { exit($e->getMessage()); }
class File {
   public static function read($source, $mode = 'r') {
      if (file_exists($source)) {
         if ($file = fopen($source, $mode)) {
            if ($content = fread($file, filesize($source))) {
               if (fclose($file)) {
                  return $content;
               } else throw new \FileException("Cannot close file $source.");
            } else throw new \FileException("Cannot read file $source.");
         } else throw new \FileException("Cannot open file $source.");
      } else throw new \FileException("Cannot find file $source.");
   }

   public static function write($destination, $content, $mode = 'a') {
      if (!is_dir(dirname($destination))) if (!mkdir(dirname($destination), 0777, TRUE)) throw new \FileException("Cannot create path $destination.");
      if ($file = fopen($destination, $mode)) {
         if (fwrite($file, $content)) {
            if (fclose($file)) {
               return TRUE;
            } else throw new \FileException("Cannot close file $destination.");
         } else throw new \FileException("Cannot write file $destination.");
      } else throw new \FileException("Cannot find file $destination.");
   }

   public static function remove($source) {
      if (file_exists($source)) {
         if (unlink($source)) {
            return TRUE;
         } else throw new \FileException("Cannot remove file $source.");
      } else throw new \FileException("Cannot find file $source.");
   }
}
class FileException extends \Exception { }
class Rcon {
   private $host;
   private $port;
   private $password;
   private $timeout;
   private $socket;
   private $authorized;
   private $last_response;

   const PACKET_AUTHORIZE = 5;
   const PACKET_COMMAND = 6;
   const SERVERDATA_AUTH = 3;
   const SERVERDATA_AUTH_RESPONSE = 2;
   const SERVERDATA_EXECCOMMAND = 2;
   const SERVERDATA_RESPONSE_VALUE = 0;

   public function __construct($host, $port, $password, $timeout) {
      $this->host = $host;
      $this->port = $port;
      $this->password = $password;
      $this->timeout = $timeout;
   }

   public function get_response() {
      return $this->last_response;
   }

   public function connect() {

      $this->socket = fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);

      if (!$this->socket) {
         $this->last_response = $errstr;
         return false;
      }

      //set timeout
      stream_set_timeout($this->socket, 3, 0);

      //authorize
      $auth = $this->authorize();

      if ($auth) {
         return true;
      }

      return false;
   }

   public function disconnect() {
      if ($this->socket) {
         fclose($this->socket);
      }
   }

   public function is_connected() {
      return $this->authorized;
   }

   public function send_command($command) {
      if (!$this->is_connected()) return false;

      // send command packet.
      $this->write_packet(Rcon::PACKET_COMMAND, Rcon::SERVERDATA_EXECCOMMAND, $command);

      // get response.
      $response_packet = $this->read_packet();
      if ($response_packet['id'] == Rcon::PACKET_COMMAND) {
         if ($response_packet['type'] == Rcon::SERVERDATA_RESPONSE_VALUE) {
            $this->last_response = $response_packet['body'];
            return $response_packet['body'];
         }
      }

      return false;
   }

   private function authorize() {
      $this->write_packet(Rcon::PACKET_AUTHORIZE, Rcon::SERVERDATA_AUTH, $this->password);
      $response_packet = $this->read_packet();

      if ($response_packet['type'] == Rcon::SERVERDATA_AUTH_RESPONSE) {
         if ($response_packet['id'] == Rcon::PACKET_AUTHORIZE) {
            $this->authorized = true;
            return true;
         }
      }

      $this->disconnect();
      return false;
   }

   /**
    * Writes a packet to the socket stream..
    */
   private function write_packet($packet_id, $packet_type, $packet_body) {
      /*
        Size         32-bit little-endian Signed Integer       Varies, see below.
        ID            32-bit little-endian Signed Integer      Varies, see below.
        Type         32-bit little-endian Signed Integer      Varies, see below.
        Body         Null-terminated ASCII String         Varies, see below.
        Empty String   Null-terminated ASCII String         0x00
       */

      //create packet
      $packet = pack("VV", $packet_id, $packet_type);
      $packet = $packet . $packet_body . "\x00";
      $packet = $packet . "\x00";

      // get packet size.
      $packet_size = strlen($packet);

      // attach size to packet.
      $packet = pack("V", $packet_size) . $packet;

      // write packet.
      fwrite($this->socket, $packet, strlen($packet));
   }

   private function read_packet() {
      //get packet size.
      $size_data = fread($this->socket, 4);
      $size_pack = unpack("V1size", $size_data);
      $size = $size_pack['size'];

      // if size is > 4096, the response will be in multiple packets.
      // this needs to be address. get more info about multi-packet responses
      // from the RCON protocol specification at
      // https://developer.valvesoftware.com/wiki/Source_RCON_Protocol
      // currently, this script does not support multi-packet responses.

      $packet_data = fread($this->socket, $size);
      $packet_pack = unpack("V1id/V1type/a*body", $packet_data);

      return $packet_pack;
   }
}


Děkuji za odpověď a rady.

Uživatelský avatar
Mysteria
Příspěvky: 9122
Registrován: 26 pro 2009, 15:40
Reputation: 7
Bydliště: Česká republika
Kontaktovat uživatele:

Re: [PHP] MobilniPlatby.cz [1.0.0-beta2]

#112 Příspěvekod Mysteria » 26 črc 2015, 11:28

Oboje souvisí nějak s RCONem, ten kód pro připojení k RCONu jsem napsal sám, takže ti neřeknu co přesně se stalo.

Podmelle
Příspěvky: 8
Registrován: 09 dub 2012, 16:10
Reputation: 0

Re: [PHP] MobilniPlatby.cz [1.0.0-beta2]

#113 Příspěvekod Podmelle » 11 srp 2015, 22:41

Zdravím,
mám tu takový problém, který se týká vašeho scriptu. Script jsem upravil, nahrál vše na web a po zkoušce v emulátoru mi vyhazují mobilní platby error na obrázku níže. Přijde mi, že web vůbec nereaguje na script, protože i po zadání úplně nesmyslné adresy scriptu do emulátoru mi vypsal přesně tento stejný error s nesmyslnou odpovědí serveru.
Používám hosting Endory.

Obrázek

Přikládám můj upravený php soubor.
IP serveru a heslo jsem zakryl.

Kód: Vybrat vše

<?php
/**
 * Název: MobilniPlatby.cz - PHP script pro zaslání RCON příkazů na MineCraft server po odeslání prémiové SMS
 * Autor: Mysteria - http://www.mysty.cz
 * Verze: 1.0.0-beta2
 * Poslední update: 27. 7. 2014
 * Více informací & download: http://forum.fakaheda.eu/viewtopic.php?f=85&t=20682#p134652
 */

$settings = (object)[ // Nastavení serverového RCONu
      'ip'       => '82.208.**.**',
      'port'       => 27624,
      'password'    => '**'
];

$messages = (object)[ // Nastavení chybových SMS zpráv
      'sms_bad_price'    => 'Litujeme, ale poslali jste SMS za :REALPRICE:Kc misto SMS za :PRICE:Kc.',
      'sms_not_found'    => 'Litujeme, ale poslali jste SMS, ktera nebyla rozpoznana.'
];

$levels = [ // Nastavení SMS levelů
   [
      'price'       => 79, // Cena SMSky
      'text' => 'CMMVIP1 :NICK:', // Text SMSky, :NICK: bude nahrazen skutečným nickem uvedeným v SMS, musí být unikátní v rámci všech platebních levelů
      'answer'    => 'Dekujeme za zakoupeni VIP v cene 79Kc.', // Odpověď na správně zaslanou SMS
      'commands'    => [ // RCON příkazy vykonané po úspěšném zpracování SMSky, :NICK: bude nahrazen skutečným nickem uvedeným v SMS
         'pex user :NICK: group add vip',
         'say Hrac :NICK: si prave zakoupil VIP za 79Kc.'
      ]
   ], [
      'price'       => 99,
      'text' => 'CMMVIP2 :NICK:',
      'answer'    => 'Dekujeme za zakoupeni VIP Plus za 99Kc.',
      'commands'    => [
         'pex user :NICK: group add vipplus',
         'say Hrac :NICK: si prave zakoupil VIP Plus za 99Kc.'
      ]
   ], [
      'price'       => 149,
      'text' => 'CMMVIP3 :NICK:',
      'answer'    => 'Velice dekujeme za zakoupeni EVIP za 149Kc.',
      'commands'    => [
         'pex user :NICK: group add evip',
         'say Hrac :NICK: si prave zakoupil EVIP za 149Kc.'
      ]
   ]
];

/* Do not make any changes below this line if you don't know what are you doing! */
$rcon = new Rcon($settings->ip, $settings->port, $settings->password, 3);
if (!$rcon->connect()) exit('Cannot connect to server RCON. Please check your settings.');
$url = (object)filter_input_array(INPUT_GET);
try {
   if (isset($url->shortcode)) {
      $url->sms = trim($url->sms);
      if (mb_strlen($url->shortcode) === 7) {
         $realPrice = (int)substr($url->shortcode, -2, 2);
         foreach ($levels as $level) {
            $level = (object)$level;
            if ($level->price >= 100) continue;
            $realNick = explode(' ', $url->sms)[array_search(':NICK:', explode(' ', $level->text))];
            if (strtolower($url->sms) === strtolower(str_replace(':NICK:', $realNick, $level->text))) {
               if ($realPrice === $level->price) {
                  foreach ($level->commands as $command) $rcon->send_command(str_replace(':NICK:', $realNick, $command));
                  File::write('./mobilni-platby.log', date('d. m. Y H:i:s', time()) . " => [SUCCESS] SMS zpráva s obsahem '$url->sms' s cenou {$realPrice}Kč byla úspěšně zpracována." . PHP_EOL);
                  header('Content-type:text/plain');
                  header('Content-length:' . mb_strlen($level->answer));
                  exit($level->answer);
               } else {
                  File::write('./mobilni-platby.log', date('d. m. Y H:i:s', time()) . " => [!ERROR!] SMS zpráva s obsahem '$url->sms' s cenou {$realPrice}Kč nebyla zpracována, protože měla mít cenu {$level->price}Kč." . PHP_EOL);
                  $answer = str_replace(':PRICE:', $level->price, str_replace(':REALPRICE:', $realPrice, $messages->sms_bad_price));
                  header('Content-type:text/plain');
                  header('Content-length:' . mb_strlen($answer));
                  exit($answer);
               }
            }
         }
         File::write('./mobilni-platby.log', date('d. m. Y H:i:s', time()) . " => [!ERROR!] SMS zpráva s obsahem '$url->sms' s cenou {$realPrice}Kč nebyla zpracována, protože nebyla rozpoznána." . PHP_EOL);
         header('Content-type:text/plain');
         header('Content-length:' . mb_strlen($messages->sms_not_found));
         exit($messages->sms_not_found);
      } else {
         foreach ($levels as $level) {
            $level = (object)$level;
            if ($level->price <= 99) continue;
            $realNick = explode(' ', $url->sms)[array_search(':NICK:', explode(' ', $level->text))];
            if (strtolower($url->sms) === strtolower(str_replace(':NICK:', $realNick, $level->text))) {
               $file = "./database/$url->id.txt";
               $commands = NULL;
               foreach ($level->commands as $command) $commands .= str_replace(':NICK:', $realNick, $command) . ';;;';
               File::write($file, $commands);
               $level->answer .= ";90333$level->price";
               File::write('./mobilni-platby.log', date('d. m. Y H:i:s', time()) . " => [SUCCESS] SMS zpráva ID $url->id s obsahem '$url->sms' s cenou {$level->price}Kč byla úspěšně zpracována." . PHP_EOL);
               header('Content-type:text/plain');
               header('Content-length:' . mb_strlen($level->answer));
               exit($level->answer);
            }
         }
         File::write('./mobilni-platby.log', date('d. m. Y H:i:s', time()) . " => [!ERROR!] SMS zpráva ID $url->id s obsahem '$url->sms' s cenou {$level->price}Kč nebyla zpracována, protože nebyla rozpoznána." . PHP_EOL);
         header('Content-type:text/plain');
         header('Content-length:' . mb_strlen($messages->sms_not_found));
         exit("$messages->sms_not_found;FREE90333199");
      }
   } elseif (isset($url->request)) {
      if ($url->status === 'DELIVERED') {
         $file = "./database/$url->request.txt";
         if (is_array($commands = explode(';;;', File::read($file)))) foreach ($commands as $command) $rcon->send_command($command);
         File::remove($file);
         File::write('./mobilni-platby.log', date('d. m. Y H:i:s', time()) . " => [SUCCESS] Doručenka SMS zprávy ID $url->request byla úspěšně zpracována." . PHP_EOL);
      } else File::write('./mobilni-platby.log', date('d. m. Y H:i:s', time()) . " => [!ERROR!] Doručenka SMS zprávy ID $url->request nebyla zpracována, protože přišla se statusem $url->status ($url->message)." . PHP_EOL);
      header('HTTP/1.1 204 No Content');
      exit;
   }
} catch (\FileException $e) { exit($e->getMessage()); }
class File {
   public static function read($source, $mode = 'r') {
      if (file_exists($source)) {
         if ($file = fopen($source, $mode)) {
            if ($content = fread($file, filesize($source))) {
               if (fclose($file)) {
                  return $content;
               } else throw new \FileException("Cannot close file $source.");
            } else throw new \FileException("Cannot read file $source.");
         } else throw new \FileException("Cannot open file $source.");
      } else throw new \FileException("Cannot find file $source.");
   }

   public static function write($destination, $content, $mode = 'a') {
      if (!is_dir(dirname($destination))) if (!mkdir(dirname($destination), 0777, TRUE)) throw new \FileException("Cannot create path $destination.");
      if ($file = fopen($destination, $mode)) {
         if (fwrite($file, $content)) {
            if (fclose($file)) {
               return TRUE;
            } else throw new \FileException("Cannot close file $destination.");
         } else throw new \FileException("Cannot write file $destination.");
      } else throw new \FileException("Cannot find file $destination.");
   }

   public static function remove($source) {
      if (file_exists($source)) {
         if (unlink($source)) {
            return TRUE;
         } else throw new \FileException("Cannot remove file $source.");
      } else throw new \FileException("Cannot find file $source.");
   }
}
class FileException extends \Exception { }
class Rcon {
   private $host;
   private $port;
   private $password;
   private $timeout;
   private $socket;
   private $authorized;
   private $last_response;

   const PACKET_AUTHORIZE = 5;
   const PACKET_COMMAND = 6;
   const SERVERDATA_AUTH = 3;
   const SERVERDATA_AUTH_RESPONSE = 2;
   const SERVERDATA_EXECCOMMAND = 2;
   const SERVERDATA_RESPONSE_VALUE = 0;

   public function __construct($host, $port, $password, $timeout) {
      $this->host = $host;
      $this->port = $port;
      $this->password = $password;
      $this->timeout = $timeout;
   }

   public function get_response() {
      return $this->last_response;
   }

   public function connect() {

      $this->socket = fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);

      if (!$this->socket) {
         $this->last_response = $errstr;
         return false;
      }

      //set timeout
      stream_set_timeout($this->socket, 3, 0);

      //authorize
      $auth = $this->authorize();

      if ($auth) {
         return true;
      }

      return false;
   }

   public function disconnect() {
      if ($this->socket) {
         fclose($this->socket);
      }
   }

   public function is_connected() {
      return $this->authorized;
   }

   public function send_command($command) {
      if (!$this->is_connected()) return false;

      // send command packet.
      $this->write_packet(Rcon::PACKET_COMMAND, Rcon::SERVERDATA_EXECCOMMAND, $command);

      // get response.
      $response_packet = $this->read_packet();
      if ($response_packet['id'] == Rcon::PACKET_COMMAND) {
         if ($response_packet['type'] == Rcon::SERVERDATA_RESPONSE_VALUE) {
            $this->last_response = $response_packet['body'];
            return $response_packet['body'];
         }
      }

      return false;
   }

   private function authorize() {
      $this->write_packet(Rcon::PACKET_AUTHORIZE, Rcon::SERVERDATA_AUTH, $this->password);
      $response_packet = $this->read_packet();

      if ($response_packet['type'] == Rcon::SERVERDATA_AUTH_RESPONSE) {
         if ($response_packet['id'] == Rcon::PACKET_AUTHORIZE) {
            $this->authorized = true;
            return true;
         }
      }

      $this->disconnect();
      return false;
   }

   /**
    * Writes a packet to the socket stream..
    */
   private function write_packet($packet_id, $packet_type, $packet_body) {
      /*
        Size         32-bit little-endian Signed Integer       Varies, see below.
        ID            32-bit little-endian Signed Integer      Varies, see below.
        Type         32-bit little-endian Signed Integer      Varies, see below.
        Body         Null-terminated ASCII String         Varies, see below.
        Empty String   Null-terminated ASCII String         0x00
       */

      //create packet
      $packet = pack("VV", $packet_id, $packet_type);
      $packet = $packet . $packet_body . "\x00";
      $packet = $packet . "\x00";

      // get packet size.
      $packet_size = strlen($packet);

      // attach size to packet.
      $packet = pack("V", $packet_size) . $packet;

      // write packet.
      fwrite($this->socket, $packet, strlen($packet));
   }

   private function read_packet() {
      //get packet size.
      $size_data = fread($this->socket, 4);
      $size_pack = unpack("V1size", $size_data);
      $size = $size_pack['size'];

      // if size is > 4096, the response will be in multiple packets.
      // this needs to be address. get more info about multi-packet responses
      // from the RCON protocol specification at
      // https://developer.valvesoftware.com/wiki/Source_RCON_Protocol
      // currently, this script does not support multi-packet responses.

      $packet_data = fread($this->socket, $size);
      $packet_pack = unpack("V1id/V1type/a*body", $packet_data);

      return $packet_pack;
   }
}

Pokud by někdo věděl, co s tím, budu moc vděčný. Děkuji.

//EDIT: Problém jsem nakonec po delší době vyřešil úplně jinak - tak, že jsem založil web hosting u Fakahedy, na něj nahrál script a vše je funkční. Tento problém s Endorou, tak ale zůstane navždy nevyřešený :D

Uživatelský avatar
Mysteria
Příspěvky: 9122
Registrován: 26 pro 2009, 15:40
Reputation: 7
Bydliště: Česká republika
Kontaktovat uživatele:

Re: [PHP] MobilniPlatby.cz [1.0.0-beta2]

#114 Příspěvekod Mysteria » 12 srp 2015, 00:29

Ten problém je úplně jednoduchý, už z toho textu je poznat, že se jedná o vloženou reklamu, kterou Endora dává na každou stránku. A očividně ji dává i do té odpovědní SMSky.

Uživatelský avatar
mannyvee
Příspěvky: 1081
Věk: 25
Registrován: 28 bře 2015, 13:49
Reputation: 0

Re: [PHP] MobilniPlatby.cz [1.0.0-beta2]

#115 Příspěvekod mannyvee » 18 srp 2015, 22:25

Ahoj, chci se zeptat, dalo by se to také udělat, aby peníze chodili přímo na účet přes Mobilní platby?

Uživatelský avatar
Mysteria
Příspěvky: 9122
Registrován: 26 pro 2009, 15:40
Reputation: 7
Bydliště: Česká republika
Kontaktovat uživatele:

Re: [PHP] MobilniPlatby.cz [1.0.0-beta2]

#116 Příspěvekod Mysteria » 19 srp 2015, 08:59

A o čem myslíš, že je celé tohle téma? ;)

Uživatelský avatar
mannyvee
Příspěvky: 1081
Věk: 25
Registrován: 28 bře 2015, 13:49
Reputation: 0

Re: [PHP] MobilniPlatby.cz [1.0.0-beta2]

#117 Příspěvekod mannyvee » 19 srp 2015, 11:43

Já jsem si nebyl jistej, jestli by se to dalo. Chtěl jsem si to jen ověřit :)

Uživatelský avatar
joker
Příspěvky: 116
Věk: 28
Registrován: 25 srp 2015, 14:10
Reputation: 2

Re: [PHP] MobilniPlatby.cz [1.0.0-beta2]

#118 Příspěvekod joker » 30 srp 2015, 17:56

Chcel by som sa spýtať, čim tam idu aj SK smsky. + Ten text smsky má byť bez PM?

jak je napr PM MOJASMS NICK
ChatbanSystém (CS 1.6): https://github.com/Kalendarky/chatban/releases
-----------------------------------------------------------------------------------------------------

Menežéris.

Uživatelský avatar
Mysteria
Příspěvky: 9122
Registrován: 26 pro 2009, 15:40
Reputation: 7
Bydliště: Česká republika
Kontaktovat uživatele:

Re: [PHP] MobilniPlatby.cz [1.0.0-beta2]

#119 Příspěvekod Mysteria » 30 srp 2015, 18:27

Ne, je to jenom pro české SMS a text PM tam většina lidí nemá, ale někomu to bez toho nejde. Vyzkoušej to bez na emulátoru, když to nepůjde (a nebude problém jinde), tak to skus i s.

TheMikeee
Příspěvky: 83
Registrován: 11 dub 2014, 15:18
Reputation: 0

Re: [PHP] MobilniPlatby.cz [1.0.0-beta2]

#120 Příspěvekod TheMikeee » 05 zář 2015, 17:09

Mám 1 problém keď pošlu sms nad 99 KČ tak im nedojde spetná že majú poslať to potvrdenie ako to opraviť?
Keď dám emulátor potvrdenia správy za 299 KČ tak dá tento error:
Text odpovědní zprávy je přípustný pouze v případě předání informace o NEDORUČENÍ


Zpět na „Návody“

Kdo je online

Uživatelé prohlížející si toto fórum: Žádní registrovaní uživatelé a 42 hostů