<?php
$user = array (
"user" => "pass"
);
$path = "http://domain.de/path/";
$forbitten_ext = array("php", "php3", "php4", "php5", "phtml", "jsp", "asp", "aspx", "pl", ".htaccess");
if ( !(isset($_POST['user']) && isset($_POST['pass'])) ) {echo "
Access Denied"; exit;}
if (isset($user[$_POST['user']])) {
if ($user[$_POST['user']] != $_POST['pass']) {
echo "
Access Denied"; exit;
}
} else {
echo "
Access Denied"; exit;
}
function br() {
return chr(13).chr(10);
}
function addlogentry($file, $entry) {
$
handle = fopen($file, "a");
fwrite($
handle, date("[m.d.y g:i]: ").$entry. br());
fclose($
handle);
}
function checkexts($filename, $ext) {
$result = false;
for ($i=0; $i<sizeof($ext);$i++) {
if (strpos($filename, ".".$ext[$i])) {
return true;
}
}
return $result;
}
if ( isset($_FILES['file']) ) {
if (!checkexts($_FILES['file']['name'], $forbitten_ext)) {
move_uploaded_file($_FILES['file']['tmp_name'], "./files/" . $_FILES['file']['name']);
echo 'Datei "'.$_FILES['file']['name'].'" hochgeladen'.br().br().'
URL: '.$path.'files/'.$_FILES['file']['name'];
addlogentry("
access.log", $_FILES['file']['name']." upload von ". $_POST['user']);
} else {
echo "
Access Denied"; exit;
}
}
?>