кек - 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 кек.php

  1. <?php
  2. //Тестирование функции на URL-адресах
  3. $str1 = "https://http.google.com:456789/folder//././?var1=val1&var2=val2&var1=qwe?qwe&var2=val456&var3=var495159";
  4. $str2 = "https://http.google.com/folder//././?var1=val1&var2=val2";
  5.  
  6. //Тестирование функции на URL-адресах
  7. $str3 = "ftp://mail.ru/?hello=world&url=https://http.google.com/folder//././?var1=val1&var2=val2";
  8. $str4 = "mail.ru/?hello=world&url=https://http.google.com/folder//././?var1=val1&var2=val2";
  9. $str5 = "index.html?mail=ru";
  10.  
  11. //Тестирование функции на URL-адресах
  12. $str6 = "domain2.zone:8080/folder/subfolder/../././../asdss/.././//////../myfolder/" 
  13. ."script.php?var1=val1&var2=val2";
  14. $str7 = "http://dom.dom.domain2.com:8080/folder/subfolder/./myfolder/script.php"
  15. ."?var1=val1&var2=val2?var1=val1&var2=val2";
  16.  
  17.  
  18. function  myurlparse(string $__urlAdress)
  19. {
  20.     $arrayUrl = array(
  21.         'protocol'   => false, 
  22.         'domain'     => false, 
  23.         'mainDomain' => false, 
  24.         'zone'       => false, 
  25.         'port'       => false, 
  26.         'rawFolder'  => false, 
  27.         'folder'     => false, 
  28.         'scriptPath' => false, 
  29.         'scriptName' => false, 
  30.         'isPHP'      => false, 
  31.         'isError'    => false,
  32.         'parameters' => array()
  33.     );
  34.     
  35.     //Разбивание адреса на 2 части до и после параметров, нахождение параметров
  36.     $stringParameters       = mb_substr($__urlAdress, mb_strpos($__urlAdress,"?") + 1)."&";
  37.     $arrayUrl['parameters'] = searhParameters($stringParameters);
  38.     $stringForTheRest       = strtok($__urlAdress,"?");
  39.     
  40.     //Нахождение протокола
  41.     $arrayUrl['protocol']                   = strtok($stringForTheRest,"/") === strtok($stringForTheRest,":").":" ? strtok($stringForTheRest,"://") : false;
  42.     $stringForTheRestWithoutProtocol        = $arrayUrl['protocol'] ? mb_substr($stringForTheRest, mb_strlen($arrayUrl['protocol'])+3) : $stringForTheRest;
  43.     $reverseStringForTheRestWithoutProtocol = strrev($stringForTheRestWithoutProtocol)."/";
  44.     
  45.     //Нахождение скрипта, проверка его типа
  46.     $scriptName                             = strrev(mb_substr($reverseStringForTheRestWithoutProtocol, 0, mb_strpos($reverseStringForTheRestWithoutProtocol, "/")));
  47.     $arrayUrl['scriptName']                 = $scriptName == "" && $arrayUrl['parameters'] !== "" ?  "index.php" : $scriptName ;
  48.     $arrayUrl['isPHP']                      = strtok(strrev($arrayUrl['scriptName']),".") !== "php" ? false : true;
  49.     
  50.     //Путь к скрипту
  51.     $rawFolder = strrev(mb_substr(strrev($stringForTheRestWithoutProtocol), mb_strlen($scriptName)));
  52.     
  53.     //Развлетление, если протокол отсутствует(то всё считается как путь)
  54.     if ($arrayUrl['protocol'] === false) {
  55.         $arrayUrl['rawFolder']  = $rawFolder == "" ? false : $rawFolder ;
  56.         $arrayUrl['folder']     = clippingPath($arrayUrl['rawFolder']);
  57.         $arrayUrl['scriptPath'] = $arrayUrl['folder'].$arrayUrl['scriptName']; 
  58.         return $arrayUrl;
  59.     }
  60.  
File Description
  • кек
  • PHP Code
  • 21 Oct-2021
  • 3.13 Kb
You can Share it: