davk

readphp

Jan 29th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.42 KB | None | 0 0
  1. <?php
  2.  
  3.    $link = $_SERVER['REQUEST_URI'];
  4.    $file = explode('/', $link);
  5.    $add_tab = 0;
  6.    include 'header.html';
  7.    foreach($file as $f)
  8.    {
  9.       $path = $f;
  10.       if(strpos($path, ".php") !== false)
  11.       {
  12.          $opened_file = fopen($path, "r");
  13.          while(!feof($opened_file))
  14.          {
  15.             $read_file = fgets($opened_file);
  16.             $line = htmlspecialchars($read_file);
  17.             if(strpos($line, "}") !== false && $add_tab > 0) $add_tab--;
  18.             if($add_tab > 0)
  19.             {
  20.                $i=0;
  21.                while($i<$add_tab)
  22.                {
  23.                   echo '<span class="tab">___</span>';
  24.                   $i++;
  25.                }
  26.             }
  27.             $line = str_replace("'if",'<span class="noif">\'if</span>', $line);
  28.             $line = str_replace('if(', '<span class="if">if</span>(', $line);
  29.             $line = str_replace("'foreach",'<span class="noif">\'foreach</span>', $line);
  30.             $line = str_replace('foreach(', '<span class="foreach">foreach</span>(', $line);
  31.             $line = str_replace("'while",'<span class="noif">\'while</span>', $line);
  32.             $line = str_replace('while(', '<span class="while">while</span>(', $line);
  33.             echo $line . "\n<br/>";
  34.             if(strpos($line, "{") !== false) $add_tab++;
  35.          }
  36.      echo "\n<br/>";
  37.          fclose($opened_file);
  38.       }
  39.    }
  40.    include 'footer.html';
  41.  
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment