upload_file.php in TinyBrowser 7
File
tinybrowser/upload_file.php
View source
<?php
require_once 'config_tinybrowser.php';
require_once 'fns_tinybrowser.php';
if (session_id() != '') {
if (!isset($_SESSION[$tinybrowser['sessioncheck']])) {
echo 'Error!';
exit;
}
}
if (isset($_GET['type'])) {
$typenow = $_GET['type'];
}
else {
echo 'Error!';
exit;
}
if (isset($_GET['folder'])) {
$dest_folder = urldecode($_GET['folder']);
}
else {
echo 'Error!';
exit;
}
$nameparts = explode('.', $_FILES['Filedata']['name']);
$ext = end($nameparts);
if (!validateExtension($ext, $tinybrowser['prohibited'])) {
echo 'Error!';
exit;
}
if ($_FILES['Filedata']['tmp_name'] && $_FILES['Filedata']['name']) {
$source_file = $_FILES['Filedata']['tmp_name'];
$file_name = stripslashes($_FILES['Filedata']['name']);
if ($tinybrowser['cleanfilename']) {
$file_name = clean_filename($file_name);
}
if ($tinybrowser['quota'][$typenow] > 0) {
$ret = dirsize($tinybrowser['docroot'] . $tinybrowser['path'][$typenow]);
if ($tinybrowser['quota'][$typenow] < $ret['size'] + filesize($source_file)) {
$msg = 'quota error: dir size: ' . $ret['size'] . ', file size: ' . filesize($source_file) . ', quota limit: ' . $tinybrowser['quota'][$typenow];
watchdog('tinybrowser', $msg);
exit;
}
}
if (is_dir($tinybrowser['docroot'] . $dest_folder)) {
$success = copy($source_file, $tinybrowser['docroot'] . $dest_folder . '/' . $file_name . '_');
}
if ($success) {
header('HTTP/1.1 200 OK');
?><html><head><title>File Upload Success</title></head><body>File Upload Success</body></html><?php
}
}