// create as:
// filename: tryonfs.php
// password=mypassword
// (later change filename/password in code for security)
// Code by Grenville Tryon gtryonp@hotmail.com
<?
session_start();
if (!isset($mipath)) $mipath=".";
if (!isset($nombrefile)) $nombrefile="tryonfs.php";
if (isset($rena))
{
unset($accion);
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Length: ' . filesize($rena));
header('Content-Disposition: attachment; filename=' . basename($rena));
readfile($rena);
die;
}
if (!isset($_SESSION["pwd"]))
{
if(!isset($clave))
{
echo "<form action='".$nombrefile."' method='post'>";
echo "<input type='password' name='clave'>";
echo "<input type='submit' value='PASSWORD:' name='acepta'>";
echo "</form>";
}
else
{
echo "<input type='button' value='CLICK TO CONTINUE' name='seguir' onclick='document.location.href=".chr(34).$nombrefile.chr(34)."'>";
if ($clave=="mypassword") $_SESSION["pwd"]=$clave ;
};
die;
}; ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Tryon FS r1.0</title>
</head>
<script>
function borrar(cual)
{
document.location.href='<?echo $nombrefile;?>?mipath='+document.a.mipath.value+'&borrar='+cual;
}
function iradir(cual)
{
document.location.href='<?echo $nombrefile;?>?mipath='+cual;
}
function creadir()
{
var dire= prompt("Folder Name:","");
if (dire!=null) document.location.href='<?echo $nombrefile;?>?dire='+dire+"&mipath="+document.a.mipath.value;
}
function rena(cual)
{
document.location.href='<?echo $nombrefile;?>?mipath='+document.a.mipath.value+'&rena='+cual;
}
</script>
<body bgcolor="#ddddff" style='font-family: Arial; font-size: 15px'>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="60%">
<p align="right"><b><i><font face="Arial" size="5" color="#000080">Tryon
FileSystem r 1.0</font></i></b></td>
<td width="40%">
<p align="right"><font face="arial" size="1"><b><a href="<?echo $nombrefile;?>?mipath=<? echo $mipath;?>">CLEAN SCREEN</a></b></font></p>
</td>
</tr>
</table>
<?
if (isset($borrar))
{
unset($accion);
unlink($borrar);
echo "<b>ACTION: ERASE:".$borrar."</b><br>";
};
if (isset($dire))
{
if (!is_dir($dire."/"))
{
unset($accion);
mkdir($mipath."/".$dire."/");
chmod($mipath."/".$dire."/", 0777);
echo "<b>ACTION: FOLDER:".$mipath."/".$dire."/"."</b><br>";
};
};
if (isset($accion))
{
foreach ($_FILES["userfile"]["error"] as $key => $error)
{
if ($error == UPLOAD_ERR_OK)
{
$tmp_name = $_FILES["userfile"]["tmp_name"][$key];
$name = $_FILES["userfile"]["name"][$key];
move_uploaded_file($tmp_name, $mipath."/".$name);
echo $mipath."/".$name."<br>";
}
else
{
if ($error != UPLOAD_ERR_NO_FILE) echo "ERROR Code: ".$error."<br>";
};
};
}; ?>
<? echo "<input type='button' value='Create New Folder' style='font-family: Arial; font-size: 11px; background-color: #c0c0c0; color: #000080' onclick='creadir()'> ";
echo "<b>ACTUAL PATH: ".$mipath."</b><br>";
echo "<table width='100%' bgcolor='#ffffff' bordercolorlight='#000080' bordercolordark='#000080' border='1' style='font-family: Arial; font-size: 10pt' cellpadding='2' cellspacing='0'>";
echo " <tr>";
echo " <td width='30%' bgcolor='#000080'><b><font color='#FFFFFF'>FILENAME</font></b></td>";
echo " <td width='30%' bgcolor='#000080'><b><font color='#FFFFFF'>ACTION</font></b></td>";
echo " <td width='15%' bgcolor='#000080'><b><font color='#FFFFFF'>SIZE</font></b></td>";
echo " <td width='15%' bgcolor='#000080'><b><font color='#FFFFFF'>DATE</font></b></td>";
echo " <td width='10%' bgcolor='#000080'><b><font color='#FFFFFF'>ATTRIB</font></b></td>";
echo " </tr>"; $dire=$mipath;
if ($handle = opendir($dire))
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != ".." && is_dir($dire."/".$file))
{
$fileList[] = trim($file);
};
};
echo " <tr>";
echo " <td width='30%'><b>ROOT</b></td>";
echo " <td width='30%'><input type='button' value='Directorio' style='font-family: Arial; font-size: 11px; background-color: #99CCFF; color: #000080' onclick='iradir(".chr(34).".".chr(34).")'> </td>";
echo " <td width='15%'> </td>";
echo " <td width='15%'> </td>";
echo " <td width='10%'> </td>";
echo " </tr>";
if (isset($fileList) && count($fileList)>0)
{
sort ($fileList);
reset ($fileList);
while (list($key, $file) = each($fileList))
{
echo " <tr>";
echo " <td width='30%'><b>".$file."</b></td>";
echo " <td width='30%'><input type='button' value='Directorio' style='font-family: Arial; font-size: 11px; background-color: #99CCFF; color: #000080' onclick='iradir(".chr(34).$dire."/".$file.chr(34).")'></td>";
echo " <td width='15%'> </td>";
echo " <td width='15%'> ".date("m/d/Y",filemtime($dire."/".$file))."</td>";
echo " <td width='10%'>".fileperms($dire."/".$file)."</td>";
echo " </tr>";
};
};
closedir($handle);
};
$file=""; $filelist="";
if ($handle = opendir($dire))
{
while (false !== ($file = readdir($handle)))
{
if ($file !="." && $file != ".." && !is_dir($dire."/".$file))
{ // $file = strtolower($file);
$fileList[] = trim($file);
};
};
if (isset($fileList) && count($fileList)>0)
{
sort ($fileList);
reset ($fileList);
while (list($key, $file) = each($fileList))
{
if(is_dir($dire."/".$file)) {} else
{
echo " <tr>";
echo " <td width='30%'>".$file."</td>";
echo " <td width='40%'><input type='button' value='Borrar' style='font-family: Arial; font-size: 11px; background-color: #DDDDFF; color: #000080' onclick='borrar(".chr(34).$dire."/".$file.chr(34).")'> <input type='button' value='Download' style='font-family: Arial; font-size: 11px; background-color: #DDDDFF; color: #000080' onclick='rena(".chr(34).$dire."/".$file.chr(34).")'></td>";
echo " <td width='15%'> ".number_format(filesize($dire."/".$file),'0','.',',')."</td>";
echo " <td width='15%'> ".date("m/d/Y",filemtime($dire."/".$file))."</td>";
echo " <td width='10%'>".fileperms($dire."/".$file)."</td>";
echo " </tr>";
};
};
};
closedir($handle);
};
echo "</table><br>"; ?>
<table border="2" cellpadding="5" cellspacing="5" width="75%" >
<tr>
<td width="100%">
<b>UPLOADS:</b>
<form name="a" action="<?echo $nombrefile;?>" method="post" enctype="multipart/form-data">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<?
for($k=1;$k<17;$k++)
{
echo "<tr>";
echo "<td width='5%'>".$k."</td>";
echo "<td width='10%'>File:</td>";
echo "<td width='85%'><input name='userfile[]' type='file' size='60' style='font-family: Arial; font-size: 11px; background-color: #99CCFF; color: #000080'></td>";
echo " </tr>";
};
?> </table>
<p align="center">
<input type="submit" value="Send Files" name="envio" style='font-family: Arial; font-size: 11px; background-color: #99CCFF; color: #000080'>
</p>
<input type="text" name="accion" value="grabar" style="visibility:hidden;">
<input type="text" name="mipath" value="<?echo $mipath;?>" style="visibility:hidden;">
</form>
</td>
</tr>
</table>
<p> </p>
</body>
|
|