Просмотр файла index.php

Размер файла: 7.56Kb
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
header('Content-type: text/html; charset=utf-8');
header('Supplication: Do not break site!');
header('Copyright: Domino');
if(!ob_start('ob_gzhandler')) {ob_start();}
session_start();
/*----------------Настройки------------------*/

$unzipfile = 'script.php'; // Имя файла
$dirname   = './files';    // Имя папки

/*-------------------------------------------*/
if(!file_exists($dirname))
 {
  mkdir($dirname, 0777);
 }
if(!file_exists ($dirname.'/'.$unzipfile))
 {
  file_put_contents($dirname.'/'.$unzipfile, '', LOCK_EX);
 }
if(!file_exists ($dirname.'/.htaccess'))
 {
  file_put_contents($dirname."/.htaccess", "<Files .htaccess>\n  order allow,deny\n  deny from all\n</Files>", LOCK_EX);
 }

$out = fopen($dirname.'/zip_'.$unzipfile, 'w');
$contents = file_get_contents($dirname.'/'.$unzipfile);

$text = ( empty($_POST['text']) ? null : $_POST['text']);

if (!empty($_POST['enter_zip_php']))  {$_SESSION['zip'] = 1;}
if (!empty($_POST['enter_zip_html'])) {$_SESSION['zip'] = 1;}
if (!empty($_POST['enter_color']))    {$_SESSION['zip'] = 1;}

if (!empty($_POST['enter_unzip'])) {unset($_SESSION['zip']);}

if (empty($info)) {$info = null;}
if (empty($_POST['enter_zip_php']))  {$_POST['enter_zip_php']  = null;}
if (empty($_POST['enter_color']))    {$_POST['enter_color']    = null;}
if (empty($_POST['enter_zip_html'])) {$_POST['enter_zip_html'] = null;}

if (!empty($_POST['enter_zip_php']))
 {
  foreach (token_get_all($contents) as $token)
   {
    if (is_string($token))
     {
      fwrite($out, $token);
     }
      else
     {
      switch ($token[0])
       {
        case T_COMMENT: case T_DOC_COMMENT:  break;
        case T_WHITESPACE: fwrite($out,' '); break;
        default: fwrite($out, $token[1]);
       }
     }
   }
  fclose($out);
  file_put_contents($dirname.'/'.$unzipfile, $text, LOCK_EX);
  $info = htmlentities(file_get_contents($dirname.'/'.$unzipfile));
 }
elseif (!empty($_POST['enter_zip_html']))
 {
  function ClearComment( $matches )
   {
    if (strpos($matches[0], '//-->') == false)
     {
      return('');
     }
    return($matches[0]);
   } 
  file_put_contents($dirname.'/'.$unzipfile, $text, LOCK_EX);
  $info = htmlentities(preg_replace_callback('/(<!--.*?-->)/s', 'ClearComment', $text ));
 }
elseif (!empty($_POST['enter_color']))
 {
  file_put_contents($dirname.'/'.$unzipfile, $text, LOCK_EX);
  $info = highlight_string(file_get_contents($dirname.'/'.$unzipfile),true);
 }
  else
 {
  unset($_SESSION['zip']);
  unlink($dirname.'/'.$unzipfile);
 }
?>
<!--*Desing Domino*-->
<!DOCTYPE HTML>
<html lang="ru">
  <head>
   <title>Сжиматель скриптов :)</title>
   <meta charset="UTF-8" />
   <meta name="dcterms.rightsHolder" lang="ru" content="Domino" /> 
   <meta name="keywords" content="Сервис сжимания php, скриптов, вытягвание текста в строчку, удаление коментариев из php js (x)html css" />
   <meta name="description" content="Сжать php js скрипт онлайн" />
   <meta name="generator" content="Notepad2" />
   <meta name="application-name" content="Сжать php js скрипт онлайн" />
   <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
     body {
      color: gold;
      background-color: #006699;
     }
     .fixed-textarea {
       top: 90px;
       left: 30px;
       right: 30px;
       bottom: 121px;
       overflow: auto;
       color: #0066FF;
       font-size: 18px;
       position: absolute;
       background-color: white;
     }
     .fixed-textarea textarea {
       width: 100%;
       height: 99%;
       resize: none;
       color: #0066FF;
       font-size: 18px;
       box-sizing: border-box;
       background-color: white;
     }
     .fixed-button {
       left: 30px;
       right: 30px;
       bottom: 75px;
       position: absolute;
       display: inline;
     }
     .fixed-button input[type=submit] {
       width: 50%;
       color: #ffffff;
       font-size: 18px;
       text-align: center;
       box-sizing: border-box;
       background-color: #006699;
       padding: 10px 0px 10px 0px;
     }
<?php
if(!empty($_SESSION['zip']) && $_SESSION['zip']== 1)
 {
?>
     body {
       top: 30px;
       left: 30px;
       right: 30px;
       bottom: 30px;
       position: absolute;
       box-shadow: 0 0 2em 1em maroon;
     }
     .form1 {
       z-index: 1;
     }
     .form {
       display:none;
     }
     .fixed-button-cliner {
       left: 30px;
       right: 30px;
       bottom: 75px;
       position: absolute;
     }
<?php
 }
  else
 {
?>
     body {
       top: 30px;
       left: 30px;
       right: 30px;
       bottom: 30px;
       position: absolute;
       box-shadow: 0 0 2em 1em white;
     }
     .form {
       z-index: 1;
     }
     .form1 {
       display:none;
     }
     .fixed-button-cliner {
       left: 30px;
       right: 30px;
       bottom: 29px;
       position: absolute;
     }
<?php
 }
?>
     .fixed-button-cliner input[type=submit] {
       width: 100%;
       color: #ffffff;
       font-size: 18px;
       text-align: center;
       box-sizing: border-box;
       background-color: #006699;
       padding: 10px 0px 10px 0px;
     }
     header {
       left: 30px;
       right: 30px;
       position: absolute;
     }
     header h1, h2 {
       color: gold;
       width: 100%;
       height: 100%;
       padding: 10px;
       text-align: center;
       box-sizing: border-box;
       background-color: #006699;
     }
     footer {
       bottom: 0px;
       position: absolute;
     }
    </style>
    <script>
     function setSelection()
      {
       var target = document.getElementById('ex5').getElementsByTagName('span')[0];
       var rng, sel;
       if (document.createRange)
        {
         rng = document.createRange();
         rng.selectNode(target)
         sel = window.getSelection();
         sel.removeAllRanges();
         sel.addRange(rng);
        }
         else
        {
         var rng = document.body.createTextRange();
         rng.moveToElementText(target);
         rng.select();
        }
      }
    </script>
  </head>
   <body>
    <form class="form" method="post">
    <header><h1>НЕСЖАТЫЙ СКРИПТ</h1></header>
    <div class="fixed-textarea"><label><textarea name="text" placeholder="&#60;? код скрипта ?&#62;" title="Добавьте текст для сжатия."><?php echo "<?\r\n\r\n?>";?></textarea></label></div>
    <div class="fixed-button"><input name="enter_zip_php" type="submit" value="Сжать php" /><input name="enter_zip_html" type="submit" value="Сжать html / css" /></div>
    <div class="fixed-button-cliner"><label><input name="enter_color" type="submit" value="Подсветка кода" /></label></div>
    </form>
    <form class="form1" method="post">
    <header><h2>СЖАТЫЙ СКРИПТ</h2></header>
    <div class="fixed-textarea" id="ex5" title="Текст можно скопировать если нажать на него." onclick="setSelection()"><span><?php echo $info;?></span></div>
    <div class="fixed-button-cliner"><label><input name="enter_unzip" type="submit" value="Очистить форму" /></label></div>
    </form>
    <footer>&nbsp;&#169; Domino <?php echo $_SERVER['SERVER_NAME'];?> &nbsp;&nbsp;&nbsp;Сервис сжимания скриптов.</footer>
   </body>
</html>