123 - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of 123.php

  1.     <?php
  2.     function sortRecursiveByKeys($array)
  3.     {
  4.         foreach ($array as &$value) {
  5.             if (is_array($value)) {
  6.                 $value = sortRecursiveByKeys($value);
  7.             }
  8.         }
  9.  
  10.         ksort($array);
  11.  
  12.         return $array;
  13.     }
  14.     
  15.     function preparePWParams($params = array())
  16.     {
  17.         return urldecode(http_build_query($params, null, ''));
  18.     }
  19.     
  20.     function createPWSignature($input, string $secret)
  21.     {
  22.         $input = parse_url($input);
  23.  
  24.         parse_str($input['query'], $input);
  25.         
  26.         unset($input['sig']);
  27.     
  28.         $input = sortRecursiveByKeys($input);
  29.         $baseString = preparePWParams($input);
  30.  
  31.         return hash_hmac('sha256', $baseString, $secret);
  32.     }
  33.     
  34.     echo createPWSignature('http://games123.storefront.feature-ter-1787.terminal3.s3.stuffio.com/en?uid=234&promo[0][product_id]=234&promo[0][type]=discount&promo[0][calc]=percent&promo[0][value]=50&promo[1][product_id]=237&promo[1][type]=discount&promo[1][calc]=percent&promo[1][value]=50&country_code=US','tmhEvwYV3K13sh62XSCB10T9oWRfSksXvMQdL7LoRptTrxbFOYFNIP4AejdGxHMw');
File Description
  • 123
  • PHP Code
  • 03 Sep-2019
  • 1.09 Kb
You can Share it: