223,58 → 223,6 |
return $newstr; |
} |
|
function acceptFile($fname) |
{ |
if (!ALLOW_FILES) |
{ |
$page->drawError("This system doesn't allow file uploading."); |
return false; |
} |
|
$this->checkLoggedIn(); |
if ($this->getLoggedInUser()->accessID >= 2) |
{ |
$page->drawError('You do not have permission to access this page.'); |
} |
|
$allowedExts = array("gif", "jpeg", "jpg", "png", "tga"); |
$temp = explode(".", $_FILES[$fname]["name"]); |
$extension = end($temp); |
if ((($_FILES[$fname]["type"] == "image/gif") |
|| ($_FILES[$fname]["type"] == "image/jpeg") |
|| ($_FILES[$fname]["type"] == "image/jpg") |
|| ($_FILES[$fname]["type"] == "image/pjpeg") |
|| ($_FILES[$fname]["type"] == "image/x-png") |
|| ($_FILES[$fname]["type"] == "image/png") |
|| ($_FILES[$fname]["type"] == "image/tga")) |
&& ($_FILES[$fname]["size"] < 200000) // file size limit (bytes) |
&& in_array($extension, $allowedExts)) |
{ |
if ($_FILES[$fname]["error"] > 0) |
{ |
$page->drawError("File Upload Error: " . $_FILES[$fname]["error"]); |
} |
else |
{ |
$lname = "upload/" . $this->rndString(12) . "." . $extension; |
|
while (file_exists($lname)) |
{ |
$lname = "upload/" . $this->rndString(12) . "." . $extension; |
} |
|
move_uploaded_file($_FILES[$fname]["tmp_name"], $lname); |
return $lname; |
} |
} |
else |
{ |
$page->drawError("Invalid file"); |
} |
|
return false; |
} |
|
function redirect($u) |
{ |
header('Location: ' . $u); |