Results 1 to 4 of 4
Thread: PHP
Hybrid View
-
24th November 2003 20:56 #1
-
25th November 2003 04:57 #2. . root. , handling "." "..". . . 10 ,PHP Code:
<?php
// ********* functions BEGIN ***********
function constructParametersFromGETVARS($array,$exclude_array=array())
{
$result='';
foreach($array as $key=>$value)
{
$result.=$key.'='.$value.'&';
}
return substr($result,0,-1);
}
function last_index_of($sub_str,$instr)
{
if(strstr($instr,$sub_str)!="")
{
return(strlen($instr)-strpos(strrev($instr),$sub_str));
}
return(-1);
}
// ********* functions END ***********
$rootpath = dirname($HTTP_SERVER_VARS['PATH_TRANSLATED']);
$path = $rootpath;
if(isset($HTTP_GET_VARS['loc']) && (strlen(trim($HTTP_GET_VARS['loc']))!=0))
{
$location = base64_decode($HTTP_GET_VARS['loc']);
$relpath = $location;
}
else
{
$location = '';
$relpath = '';
}
if(isset($HTTP_GET_VARS['f']) && (strlen(trim($HTTP_GET_VARS['f']))!=0))
{
if(is_dir($path.$relpath.'/'.$HTTP_GET_VARS['f']))
{
if(strcmp($HTTP_GET_VARS['f'],'.') == 0)
{
$path = $rootpath;
$relpath = '';
}
else
if(strcmp($HTTP_GET_VARS['f'],'..') == 0)
{
if(strlen($location)!=0)
if(($lif = last_index_of('/',$location)) != 0)
{
$relpath = substr($location,0,$lif-1);
$path.= $relpath;
}
else
{
$path = $rootpath;
$relpath = '';
}
}
else
{
$relpath .= '/'.$HTTP_GET_VARS['f'];
$path.= $relpath;
}
}
else
{
$path =dirname($HTTP_SERVER_VARS['PHP_SELF']).$relpath.'/'.$HTTP_GET_VARS['f'];
header('Location:'.$path);
die();
}
}
if(isset($HTTP_POST_VARS['submit']))
{
if(is_uploaded_file($HTTP_POST_FILES['bin_file']['tmp_name']))
{
if(move_uploaded_file($HTTP_POST_FILES['bin_file']['tmp_name'], $HTTP_POST_VARS['path'].'/'.$HTTP_POST_FILES['bin_file']['name']))
echo 'File uploaded successfully<BR>';
else
echo 'File is not uploaded(cannot be copied):'.$HTTP_POST_FILES['bin_file']['tmp_name'].'<BR>';
}
else
echo 'Not uploaded file:'.$HTTP_POST_FILES['bin_file']['tmp_name'].'<BR>';
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>Untitled Document</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK href="default.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY>
<FORM action="<?php
$getvars = constructParametersFromGETVARS($HTTP_GET_VARS);
$action = basename($HTTP_SERVER_VARS['PHP_SELF']);
if(count($HTTP_GET_VARS)>0)
$action .= '?'.$getvars;
echo $action; ?>" method="post" enctype="multipart/form-data" name="form1">
<INPUT name="bin_file" type="file" id="bin_file">
<INPUT type="submit" name="submit" value="Upload">
<INPUT type="hidden" name="path" value="<? echo $path ?>">
<INPUT type="hidden" name="MAX_FILE_SIZE" value="10485760">
</FORM>
<?php
echo 'Directory contents of <B>'.$path.'</B><BR><HR>';
$d = dir($path);
$file_entries = array();
while (false !== ($entry = $d->read()))
{
if(is_dir($path.'/'.$entry))
echo '<A href="'.basename($HTTP_SERVER_VARS['PHP_SELF']).'?loc='.base64_encode($relpath).'&f='.$entry.'" class="file"><IMG src="img/folder.gif" border="0"> '.$entry."</A><BR>\n";
else
$file_entries[] = $entry;
}
foreach($file_entries as $key=>$value)
{
echo '<A href="'.basename($HTTP_SERVER_VARS['PHP_SELF']).'?loc='.base64_encode($relpath).'&f='.$value.'" class="file"><IMG src="img/generic.gif" border="0"> '.$value."</A><BR>\n";
}
$d->close();
?>
</BODY>
</HTML>Last edited by Bombera; 25th November 2003 at 06:10.
EVGA X299 FTW K|i9-7960X@4.7|4x8 Patriot Viper Steel 4000|GTX 1660 Ti|970 EVO 1 TB|Seasonic Focus GX-1000|Xigmatek Elysium|
Rampage IV Extreme BE|E5-1680v2@4.7|4x4 HyperX 1866|Cougar Aqua 240|GTX 1050 Ti|970 EVO 1/4 TB|CM 850 SilentPro|HAF-X|
-
25th November 2003 11:19 #3
-
25th November 2003 11:19 #4





Reply With Quote
...
7th May 2023, 14:24 in