5.2php - 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 5.2php.php

  1. <?php
  2. $files = array_diff(scandir('music/'), array('..', '.'));
  3. $array_name = [];
  4. $array_band = [];
  5. $array_year = [];
  6. $array_album = [];
  7. if($_POST["FUCKYOU"]){
  8.  if (!$_POST['button'])
  9.  {
  10.   echo "Кнопка не нажата";
  11.  }
  12.  elseif($_POST["button"]==1)
  13.  {
  14.   for($i = 2; $i <= count($files) + 1; $i++){
  15.     array_push($array_band, explode(" -- ", $files[$i])[0]." -- ".explode(" -- ", $files[$i])[1]." -- ".explode(" -- ", $files[$i])[2]." -- ".explode(" -- ", $files[$i])[3]);
  16.    }
  17.    sort($array_band);
  18.    foreach($array_band as $val){
  19.     //$part = substr($val, 0, strpos($val, " -- "));
  20.     //$residue = substr($val, strpos($val, " -- ") + 4);
  21.     echo $val." "."<a href=\"php2.php?path=music\\" .$val. "\">Download</a>"."<br>";
  22.    }
  23.  }
  24.  elseif($_POST["button"]==2)
  25.  {
  26.   for($i = 2; $i <= count($files) + 1; $i++){
  27.     array_push($array_band, explode(" -- ", $files[$i])[1]." -- ".explode(" -- ", $files[$i])[0]." -- ".explode(" -- ", $files[$i])[2]." -- ".explode(" -- ", $files[$i])[3]);
  28.    }
  29.    sort($array_band);
  30.    foreach($array_band as $val){
  31.     $part = substr($val, 0, strpos($val, " -- "));
  32.     $file_2 = substr($val, strpos($val, " -- ") + 4);
  33.     $file_3 = substr($file_2, 0, strpos($file_2, " -- "));
  34.     $file_3_1 = substr($file_2, strpos($file_2, " -- ")+4);
  35.     echo $file_3." -- ".$part." -- ".$file_3_1." "."<a href=\"php2.php?path=music\\" .$file_3." -- ".$part." -- ".$file_3_1. "\">Download</a>"."<br>";
  36.    }
  37.  }
  38.  elseif($_POST["button"]==3)
  39.  {
  40.   for($i = 2; $i <= count($files) + 1; $i++){
  41.     array_push($array_name, explode(" -- ", $files[$i])[2]." -- ".explode(" -- ", $files[$i])[0]." -- ".explode(" -- ", $files[$i])[1]." -- ".explode(" -- ", $files[$i])[3]);
  42.    }
  43.    sort($array_name);
  44.    foreach($array_name as $val){
  45.     $part = substr($val, 0, strpos($val, " -- "));
  46.     $residue = substr($val, strpos($val, " -- ") + 4);
  47.     $residue_1 = substr($residue, 0, strpos($residue, " -- ") + 4);
  48.     $residue_2 = substr($residue, strpos($residue, " -- ") + 4);
  49.     $residue_3 = substr($residue_2, 0, strpos($residue_2, " -- ") + 4);
  50.     $residue_name = substr($residue, strpos($residue, " -- ") + 4);
  51.     $residue_name_2 = substr($residue_name, strpos($residue_name, " -- ") + 4);
  52.     echo $residue_1.$residue_3.$part." -- ".$residue_name_2." "."<a href=\"php2.php?path=music\\" .$residue_1.$residue_3.$part." -- ".$residue_name_2. "\">Download</a>"."<br>";
  53.    }
  54.  }
  55.  elseif($_POST["button"]==4)
  56.  {       
  57.   for($i = 2; $i <= count($files) + 1; $i++){
  58.    array_push($array_name, explode(" -- ", $files[$i])[3]." -- ".explode(" -- ", $files[$i])[0]." -- ".explode(" -- ", $files[$i])[1]." -- ".explode(" -- ", $files[$i])[2]);
  59.   }
  60.   sort($array_name);
  61.   foreach($array_name as $val){
  62.    $part = substr($val, 0, strpos($val, " -- "));
  63.    $residue = substr($val, strpos($val, " -- ") + 4);
  64.    echo $residue." -- ".$part." "."<a href=\"php2.php?path=music\\" .$residue." -- ".$part. "\">Download</a>"."<br>";
  65.   }
  66.  }
  67. }
File Description
  • 5.2php
  • PHP Code
  • 08 Jan-2023
  • 2.88 Kb
You can Share it: