rendered paste body<?php
$basedir='/demosite2/other/';
$dir='/demosite2/other/';
$dis='/';
if(isset($_GET['dir'])) {
$dir=$dir.$_GET['dir'];$dis=$_GET['dir'];
}
if(strpos($dir,'..')!==false){
$dir=substr($dir,0,strrpos($dir,'/')).'/';
}
if( substr($dir, -1) !== '/') {
$dir=$dir.'/';
}
if( isset($_GET['om']) && $_GET['om']=='mkd'){
$fol=$_GET['fol'];
@mkdir($dir.$fol, 0777);
@chmod($dir.$fol, 0777);
} else if ( isset($_GET['om']) && $_GET['om']=='ren'){
$file=$_GET['file'];
$newfile=$_GET['newfile'];
rename($dir.$file, $dir.$newfile);
header("Location: ?");
} else if ( isset($_GET['om']) && $_GET['om']=='del'){
$file=$_GET['file'];
if (is_dir($dir.$file))
rmdir ($dir.$file);
else
unlink($dir.$file);
header("Location: ?");
} else if ( isset($_GET['om']) && $_GET['om']=='upl'){
echo 'Upload part<br>';
if (isset($_POST['subupl']) && $_POST['subupl'] == 'Upload'){
$name_tmp = $_FILES['fileupl']['tmp_name'];
echo $name_tmp ;
echo '<br>';
$name = $_FILES['fileupl']['name'];
echo $name ;
echo '<br>';
$size = $_FILES['fileupl']['size'];
echo $size ;
echo '<br>';
echo $dir ;
echo '<br>';
if($size!=0) {
if(file_exists($dir.$name)) echo 'Overwriting isnt supported<br>'; else {
if(is_uploaded_file($name_tmp)){
move_uploaded_file($name_tmp,$dir.$name);
}else { echo 'Error<br>'; }
}
}
}
}
$handle = @opendir($dir);
while($stuff=readdir($handle)) {
if( !is_dir($dir.$stuff) ) {
$files[]=$stuff;
}
else {
$dirs[]=$stuff;
}
}
closedir($handle);
html();
echo ' <div id="container">';
echo ' <div id="smalltopleft"><h5>da site</h5></div>';
echo ' <div id="smalltop">';
readfile("/demosite2/menu2.d");
echo ' </div>';
echo ' <div id="cleanup"> </div>';
echo ' <div id="stuff2">';
echo '<center><table width="95%" border="1"><tr><th class="border" align="center">Name</th><th class="border" align="center">Size</th><th class="border" align="center">Last modified</th><th class="border" align="center">Rename</th><th class="border" align="center">Delete</th></tr>';
$dirs[]='';
for($i=1;$i<sizeof($dirs);$i++){
if($dirs[$i]=='..'){ if($dir!=$basedir)echo '<tr><td class="border" align="left"><a href="?dir=..">Up</a></td><td class="border" align="center"></td><td class="border" align="center"></td><td align="center"></td><td class="border" align="center"></td></tr>';
}else if ($dirs[$i]==''){ echo '';
}else {
echo '<tr><td class="border" align="left"><a href="?dir='.$dirs[$i].'">'.$dirs[$i].'</a></td><td class="border" align="center"></td><td class="border" align="center"> </td><td class="border" align="center">'.'[<a href=\'javascript:show_rename_dialog("'.$dirs[$i].'")\'>ren</a>]</td><td class="border" align="center">'.'[<a href=\'javascript:show_delete_dialog("'.$dirs[$i].'")\'>del</a>]</td></tr>';
}
}
$files[]='';
if(sizeof($files)==1){ echo '<tr><td class="border" colspan="5">no files</td></tr>'; }else
for($i=0;$i<sizeof($files)-1;$i++){
echo '<tr><td class="border" align="left"><a href="'.$files[$i].'">'.$files[$i].'</a></td><td class="border" align="center">'.size($files[$i]).' </td><td class="border" align="center">'.date("d-m-y H:i:s", @fileatime($files[$i])).'</td><td class="border" align="center">'.'[<a href=\'javascript:show_rename_dialog("'.$files[$i].'")\'>ren</a>]</td><td class="border" align="center">'.'[<a href=\'javascript:show_delete_dialog("'.$files[$i].'")\'>del</a>]</td></tr>';
}
echo '</table></center><br>';
echo '<a href="javascript:show_mkdir_dialog()">Make Directory</a><br>';
echo '<FORM Method="POST" enctype="multipart/form-data" Action="?om=upl&dir='.$dis.'">';
echo '<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />';
echo '<input type="file" name="fileupl" size="30" /><br>';
echo '<input type="submit" name="subupl" value="Upload" />';
echo '<INPUT Type="reset" Value="Cancel" /> </form>';
echo '</form>';
echo ' </div>';
echo ' <div id="cleanup"> </div>';
echo ' <div id="footer">';
readfile("/demosite2/footer.d");
echo ' </div>';
echo '</div>';
echo '</body></html>';
function html(){
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
echo '<html>';
echo '<head>';
echo '<title>JIZAS:craist</title>';
echo '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">';
echo '<link href="stylesheet2.css" rel="stylesheet" type="text/css">';
?>
<script><!--
function show_rename_dialog(f){
a = prompt("Please enter new name:", f);
if (!a) return;
if (a == f) return;
location = "?om=ren&newfile=" + escape(a) + "&file=" + escape(f);
}
function show_mkdir_dialog(){
a = prompt("Please enter folder name:");
if (!a) return;
location = "?om=mkd&fol=" + escape(a);
}
function show_delete_dialog(f){
if (confirm("Are you sure you want to delete file " + f))
location = "?om=del&file=" + escape(f);
}
//--></script>
<?php
echo '</head>';
echo '<body>';
}
function size($file){
$filesize=@filesize($file);
$array = array(
'YB' => 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024,
'ZB' => 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024,
'EB' => 1024 * 1024 * 1024 * 1024 * 1024 * 1024,
'PB' => 1024 * 1024 * 1024 * 1024 * 1024,
'TB' => 1024 * 1024 * 1024 * 1024,
'GB' => 1024 * 1024 * 1024,
'MB' => 1024 * 1024,
'KB' => 1024,
);
if($filesize <= 1024) { $filesize = $filesize . ' Bytes'; }
foreach($array AS $name => $size) {
if($filesize > $size || $filesize == $size) {$filesize = round((round($filesize / $size * 100) / 100), 2) . ' ' . $name; }
}
return $filesize;
}
?>