<?php
/* Welcome to DataLoad10, finally at version 1.0!
* This is the perfect PHP script for you, if you want to share the contents of a folder on your webspace!
* Just put this index.php into the folder and include or link it and your users will be able to download
* and even upload files from/to that folder!
*
* Have fun!
* For help see dataload10.sourceforge.net
*/
/*
* Basic configuration
*/
//want the user to upload files? (default = true)
define("ENABLE_UPLOAD", true);
//want to display image icons for filetypes? (default = false)
define("SHOW_IMAGES_FOR_FILETYPE", false);
//path to folder which contains *.jpg images with the name of an extension (jpg.jpg, html.jpg, txt.jpg ...)
//relative or absolute path possible (with '/' at the end)
define("PATH_TO_IMAGES", "http://www.abi.maltepeers.de/img/");
//which file types is the user permitted to upload? (don't let them upload e.g. *.php or *.js unless you know what you're doing!)
$ALLOWED_FILE_TYPES = array("jpg", "avi", "html");
/*
* Language configuration
*/
define("PAGE_TITLE", "My files for YOU!");
define("UPLOAD_HEAD", "File upload");
define("UPLOAD_TEXT", "If it takes too long to upload, please split the file!");
define("FILE", "File");
define("SUCCESSFUL_UPLOAD", "File successfully uploaded!");
define("NOTALLOWED_FILEEXTENSION", "File type not allowed!");
define("CLOSE", "close");
define("DATE", "Date");
define("FILENAME", "Filename");
define("FILE_EXT", "Filetype");
define("FILE_SIZE", "Filesize");
////////////////////////////////////////////////////////////////////
// Script starts
///////////////////////////////////////////////////////////////////
?>
<html>
<head>
<title><?=PAGE_TITLE?></title>
</head>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
body {
margin: auto;
width: 80%;
text-align: center;
}
.message {
position:fixed;
color: black;
width: 200px;
height: auto;
padding: 1em;
background-color: white;
border: 1px solid black;
margin-top: 10%;
margin-left: 30%;
}
</style>
<body>
<?php
if(ENABLE_UPLOAD){
if(!isset($_FILES['file'])){
?>
<h3><?=UPLOAD_HEAD?></h3>
<p><?=UPLOAD_TEXT?></p>
<form action="" method="post" enctype="multipart/form-data">
<?=FILE?>: <input type="file" name="file">
<input type="submit" value="submit">
</form><br />
<?
}
else{
$path = $file;
$ext = end(explode(".", $_FILES['file']['name'])); //get file extension
if(in_array($ext, $ALLOWED_FILE_TYPES)){
move_uploaded_file($_FILES['file']['tmp_name'], basename($_FILES['file']['name']));
echo "<div class=\"message\">".SUCCESSFUL_UPLOAD."<br /> <a href=\"\">".CLOSE."</a></div>";
}
else {
echo "<div class=\"message\">".NOTALLOWED_FILEEXTENSION."<br /> <a href=\"\">".CLOSE."</a></div>";
}
}
}
if (empty($file1)){
echo '<center><table border="1"><tr><td>'.DATE.':</td><td>'.FILENAME.':</td><td>'.FILE_EXT.':</td><td>'.FILE_SIZE.':</td>';
foreach (glob("*.*") as $file) {
if($file == "index.php"){}
else {
$nameendung = explode(".", $file); //Name und Endung trennen
echo '<tr>';
echo '<td>'.date("d F Y H:i:s", filemtime($file)).'</td>'; //Erstellungsdatum
echo '<td><a href="'.$file.'">'.$nameendung[0].'</a></td>'; //Dateiname
echo '<td><img width="25" id="endung" src="'.PATH_TO_IMAGES.$nameendung[count($nameendung)-1].'.jpg"><sup>'.$nameendung[count($nameendung)-1].'</sup></td>'; //Dateiendung
echo '<td>'.substr((filesize($file)/(1024*1024)), 0, 6).' Mb</td>'; //Dateigr??e
echo '</td></tr>';
}
}
echo '</table></center>';
}
?>
</body>
</html>