$max_size)
// $FilesUploaded = 'File too big';
if($FilesUploaded == "No file received") //If no error, start upload
{
//format file name
$file = strtr($file,
'����������������������������������������������������',
'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy');
$file = preg_replace('/([^.a-z0-9]+)/i', '-', $file);
if(move_uploaded_file($_FILES['file']['tmp_name'], $upload_dir . $_SERVER['REMOTE_ADDR']."_".$file)) //If true is returned -> it worked
{
$FilesUploaded = " File uploaded :". $file." (Click here to access the file)";
echo "File Uploaded successfully";
}
else {//if false, upload has failed
echo "File Upload failed (eWON return code : POSTERROR)";
}
}
else {
echo $FilesUploaded." (eWON return code : POSTERROR)";
}
}
}
//################################################
//########### LOG RESULT #########################
//################################################
//remove uploaded file and log file if filesize > 3 kb
if (file_exists('postresults.txt'))
{
if (filesize('postresults.txt') > 3000)
clearAll();
}
//Log headers
$fp = fopen($upload_dir.$_SERVER['REMOTE_ADDR'].'_headers.txt', 'a');
fwrite($fp, "####### ".date('Y-m-d H:m:s')."#######\n");
foreach (getallheaders() as $name => $value) {
fwrite($fp, "$name: $value\n");
}
fwrite($fp, $entityBody."\n");
fwrite($fp, "#####################################\r\n");
fclose($fp);
$headerLink = "(View headers)";
//log result in file
$fp = fopen('postresults.txt', 'a');
fwrite($fp, date('Y-m-d H:m:s')." [".$_SERVER['REMOTE_ADDR']."]"." : ".$params." ".$FilesUploaded." ".$headerLink."\r\n");
fclose($fp);
//remove uploaded file and log file on demand
if (isset($_POST["clearlist"]))
clearAll();
//redirect to main page
//header('Location: index.php');
echo '';
function clearAll()
{
try
{
deleteDir('upload');
mkdir('upload');
unlink('postresults.txt');
}
catch(Exception $e)
{}
}
function deleteDir($dirPath) {
if (! is_dir($dirPath)) {
throw new InvalidArgumentException("$dirPath must be a directory");
}
if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
$dirPath .= '/';
}
$files = glob($dirPath . '*', GLOB_MARK);
foreach ($files as $file) {
if (is_dir($file)) {
$this::deleteDir($file);
} else {
unlink($file);
}
}
rmdir($dirPath);
}
?>