lol - PHP Online
Form of PHP Sandbox
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
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.
Result of php executing
Full code of lol.php
- <?php
- //Объявляем тестовые строки
- $stringOne = "http://http.ru/folder/subfolder/../././script.php?var1=val1&var2=val2";
- $stringTwo = "https://http.google.com/folder//././?var1=val1&var2=val2";
- $stringThree = "ftp://mail.ru/?hello=world&url=https://http.google.com/folder//././?var1=val1&var2=val2";
- $stringFour = "mail.ru/?hello=world&url=https://http.google.com/folder//././?var1=val1&var2=val2";
- $stringFive = "index.html?mail=ru";
- //Объявляем тестовые строки
- $stringSix = "domain2.zone:8080/folder/subfolder/../././../asdss/.././//////../myfolder/script.php?var1=val1&"
- ."var2=val2";
- $stringSeven = "http://dom.dom.domain2.com:8080/folder/subfolder/./myfolder/script.php?var1=val1&var2=val2?var1=val1&"
- ."var2=val2";
- echo "First:";
- echo "\n";
- my_url_parse($stringOne);
- echo "\n";
- echo "Second:";
- echo "\n";
- echo "\n";
- my_url_parse($stringTwo);
- echo "\n";
- echo "Third:";
- echo "\n";
- echo "\n";
- my_url_parse($stringThree);
- echo "\n";
- echo "Fourht:";
- echo "\n";
- echo "\n";
- my_url_parse($stringFour);
- echo "\n";
- echo "Fifth:";
- echo "\n";
- echo "\n";
- my_url_parse($stringFive);
- echo "\n";
- echo "Sixth:";
- echo "\n";
- echo "\n";
- my_url_parse($stringSix);
- echo "\n";
- echo "Seventh:";
- echo "\n";
- echo "\n";
- my_url_parse($stringSeven);
- function my_url_parse(string $__string)
- {
- //Объявляем шаблон массива парсинга
- $parseArray = array(
- 'protocol' => '',
- 'domain' => '',
- 'zone' => '',
- '2_level_domain' => '',
- //Объявляем шаблон
- 'port' => '8080',
- 'raw_folder' => '',
- 'folder' => '',
- 'script_path' => '',
- 'script_name' => 'index.php',
- //Объявляем шаблон
- 'is_php' => true,
- 'parameters' => array(),
- 'is_error' => false
- );
- $isithaveprotocol = false;
- for ($index = 0; $index < strlen($__string); ++$index) {
- if ($__string[$index] == ":" && $__string[$index+1] == "/" && $__string[$index+2] == "/" && strpos($__string, "/")>$index){
- isProtocol($__string, $index);
- $isithaveprotocol = true;
- break;
- }
- }
- if (!$isithaveprotocol){
- notProtocol($__string);
- }
- }
- function isProtocol(string $__string, int $index){
- $parseArray['protocol'] = substr($__string, 0, $index-strlen($__string));
- $__string = substr($__string, $index+3, strlen($__string)-$index-3);
- $array = explode("/", $__string, strlen($__string));
- $domain = $array[0];
- if (strripos($domain, ":", 0) != false){
- $parseArray['port'] = substr($domain, strripos($domain, ":", 0)+1, strripos($domain, ":", 0)+5);
- $domain = substr($domain, 0, strripos($domain, ":", 0));
- }
- else{
- $parseArray['port'] = 80;
- }
- $parseArray['domain'] = $domain;
- $domainarray = explode(".", $domain, strlen($domain));
- $parseArray['zone'] = $domainarray[count($domainarray)-1];
- $parseArray['2_level_domain'] = $domainarray[count($domainarray)-2].'.'.$domainarray[count($domainarray)-1];
- $__string = substr($__string, strpos($__string, "/")+1, strlen($__string)-strpos($domain, "/", 0));
- $parseArray['raw_folder'] = substr($__string, 0, strripos($__string, "/", 0)+1);
- $firstarg = strripos(substr($__string, 0, strripos($__string, "/", 0)), "/", 0);
- if($__string[strripos($__string, "/", 0)-1] == "."){
- $parseArray['folder'] = "false";
- }
- else{
- $parseArray['folder'] = substr($__string, $firstarg+1, strripos($__string, "/", 0)-$firstarg);
- }
- if ($__string[strripos($__string, "/", 0)+1] == "?"){
- $parseArray['script_path'] = substr($__string, $firstarg+1, strripos($__string, "/", 0)-$firstarg)."index.php";
- $parseArray['script_name'] = "index.php";
- }
- else if(strripos($__string, "/", 0) == false){
- $parseArray['script_path'] = "false";
- $parseArray['script_name'] = "index.php";
- }
- else{
- $parseArray['script_path'] = substr($__string, $firstarg+1, strpos($__string, "?", 0)-$firstarg-1);
- $parseArray['script_name'] = substr($__string, strripos($__string, "/", 0)+1, strpos($__string, "?", 0)-$firstarg-3);
- }
- if (strripos($parseArray['script_name'], ".php", 0) != false){
- $parseArray['is_php'] = "true";
- }
- else{
- $parseArray['is_php'] = "false";
- }
- $str = $__string;
- for ($index = 0; $index < strlen($str); ++$index)
- {
- if ($str[$index]=="?" || $str[$index]=="&"){
- $delta = strlen($str)-strlen($__string);
- $parameter = substr($__string, $index-$delta+1, strpos(substr($__string, $index-$delta, strlen($__string) - $index+$delta),"=",0)-1);
- $__string = substr($__string, $index-$delta+strpos(substr($__string, $index-$delta, strlen($__string) - $index+$delta),"=",0), strlen($__string) - $index+$delta - strpos(substr($__string, $index-$delta, strlen($__string) - $index+$delta),"=",0)+1);
- if (strpos($__string, "&", 0)==false){
- $parseArray['parameters'][$parameter] = substr($__string, 1, strlen($__string));
- }
- else{
- $parseArray['parameters'][$parameter] = substr($__string, 1, strpos($__string, "&", 0)-1);
- }
- }
- }
- if (substr_count($array[0], ".",0, strlen($array[0])) > 5){
- $parseArray['is_error'] = "true";
- }
- else{
- $parseArray['is_error'] = "false";
- }
- foreach ($parseArray as $key => $value){
- if ($key == "parameters"){
- echo $key;
- echo " => array(";
- echo "\n";
- foreach ($parseArray['parameters'] as $key => $value){
- echo $key;
- echo " => ";
- echo $value;
- echo "\n";
- }
- echo ")";
- echo "\n";
- }
- else{
- echo $key;
- echo " => ";
- echo $value;
- echo "\n";
- }
- }
- }
- function notProtocol(string $__string){
- $parseArray['protocol'] = "false";
- $parseArray['domain'] = "false";
- $parseArray['port'] = 80;
- $parseArray['2_level_domain'] = "false";
- if (strripos($__string, "/", 0)!=false){
- $parseArray['raw_folder'] = substr($__string, 0, strripos($__string, "/", 0)+1);
- }
- else{
- $parseArray['raw_folder'] = substr($__string, 0, strlen($__string));
- }
- if (substr_count(substr($__string, 0, strpos($__string, "/", 0)), ".",0, strlen(substr($__string, 0, strpos($__string, "/", 0)))) > 5){
- $parseArray['is_error'] = "true";
- }
- else{
- $parseArray['is_error'] = "false";
- }
- $firstarg = strripos(substr($__string, 0, strripos($__string, "/", 0)), "/", 0);
- if($__string[strripos($__string, "/", 0)-1] == "."){
- $parseArray['folder'] = "false";
- }
- else{
- $parseArray['folder'] = substr($__string, $firstarg+1, strripos($__string, "/", 0)-$firstarg);
- }
- if ($__string[strripos($__string, "/", 0)+1] == "?"){
- $parseArray['script_path'] = substr($__string, $firstarg+1, strripos($__string, "/", 0)-$firstarg)."index.php";
- $parseArray['script_name'] = "index.php";
- }
- else if(strripos($__string, "/", 0) == false){
- $parseArray['script_path'] = "false";
- $parseArray['script_name'] = "index.php";
- }
- else{
- $parseArray['script_path'] = substr($__string, $firstarg+1, strpos($__string, "?", 0)-$firstarg-1);
- $parseArray['script_name'] = substr($__string, strripos($__string, "/", 0)+1, strpos($__string, "?", 0)-$firstarg-3);
- }
- if (substr_count(substr($__string, 0, strpos($__string, "/", 0)), ".",0, strlen(substr($__string, 0, strpos($__string, "/", 0)))) > 5){
- $parseArray['is_error'] = "true";
- }
- else{
- $parseArray['is_error'] = "false";
- }
- $str = $__string;
- for ($index = 0; $index < strlen($str); ++$index)
- {
- if ($str[$index]=="?" || $str[$index]=="&"){
- $delta = strlen($str)-strlen($__string);
- $parameter = substr($__string, $index-$delta+1, strpos(substr($__string, $index-$delta, strlen($__string) - $index+$delta),"=",0)-1);
- $__string = substr($__string, $index-$delta+strpos(substr($__string, $index-$delta, strlen($__string) - $index+$delta),"=",0), strlen($__string) - $index+$delta - strpos(substr($__string, $index-$delta, strlen($__string) - $index+$delta),"=",0)+1);
- if (strpos($__string, "&", 0)==false){
- $parseArray['parameters'][$parameter] = substr($__string, 1, strlen($__string));
- }
- else{
- $parseArray['parameters'][$parameter] = substr($__string, 1, strpos($__string, "&", 0)-1);
- }
- }
- }
- if (strripos($parseArray['script_name'], ".php", 0) != false){
- $parseArray['is_php'] = "true";
- }
- else{
- $parseArray['is_php'] = "false";
- }
- foreach ($parseArray as $key => $value){
- if ($key == "parameters"){
- echo $key;
- echo " => array(";
- echo "\n";
- foreach ($parseArray['parameters'] as $key => $value){
- echo $key;
- echo " => ";
- echo $value;
- echo "\n";
- }
- echo ")";
- echo "\n";
- }
- else{
- echo $key;
- echo " => ";
- echo $value;
- echo "\n";
- }
- }
- }
File Description
- lol
- PHP Code
- 13 Oct-2021
- 9.3 Kb
You can Share it:
Latest PHP Pastes