/********************************
files.class.php
********************************/
class files{
var $Error;
var $goback;
function files(){
}
function file_form($UserInput){
echo "
";
}
function add_file($UserInput){
require_once('static.class.php');
if(file_exists("upload/" . $_FILES['file_to_upload']['name']))
{
$this->file_form($UserInput);
echo "
The file already exists! Delete first!
Try again or $this->goback!
";
$this->Error == true;
exit;
}
else
{
//Add the file
$this->move_temp_file = move_uploaded_file($_FILES['file_to_upload']['tmp_name'], "upload/" . $_FILES['file_to_upload']['name']);
if(!$this->move_temp_file)
{
$this->file_form($UserInput);
echo "
There was a problem uploading your file!
Try again or $this->goback!
Contact support!
";
$this->Error == true;
exit;
}
else
{
//Add file information to database
//Generate File ID
$this->file_ID = md5($_SESSION['Path'] . "/" . $_FILES['file_to_upload']['name'] . date($_SESSION['UNIX_EP']));
$this->file_path = $_SESSION['Path'] . "/" . $_FILES['file_to_upload']['name'];
$Nfile_name = $_FILES['file_to_upload']['name'];
$Nfile_type = $_FILES['file_to_upload']['type'];
$Nfile_size = $_FILES['file_to_upload']['size'];
$IVal = $_FILES['file_to_upload']['size'];
$file_size = new static_class();
$file_size->StaticFSize($IVal);
$this->read_file_size = $file_size->FDS;
$this->query_string = "INSERT INTO files (id, UID, File_Name, File_ID, File_Type, File_Path, File_Access, File_DTG, File_Size, Read_File_Size, File_Count, Comments) VALUES('0','$_SESSION[UID]', '$Nfile_name','$this->file_ID','$Nfile_type','$this->file_path','$UserInput[Access]','" . date($_SESSION['DTG']) . "','$Nfile_size','$this->read_file_size','0','" . addslashes($UserInput['FileComments']) . "')";
$this->query = mysql_query($this->query_string);
if(!$this->query)
{
$this->delete_file = unlink("upload/" . $_FILES['file_to_upload']['name']);
$this->file_form($UserInput);
$space_left_message = ($this->space_left <= "0") ? "You do not have any space left" : "Space left:" . $file_size->FDS;
echo "
Error adding file to database! No file uploaded! $this->goback
";
$this->Error == true;
exit;
}
else
{
$this->file_form($UserInput);
echo "
File upload complete!
";
$this->Error == false;
}
}
}
}
function validate_file($UserInput){
require_once('static.class.php');
$this->goback = "
(Go Back)";
$this->max_upload_size=pow(1024,2)*10;
//Calculate the file size
$file_size = new static_class();
$IVal = $_FILES['file_to_upload']['size'];
$file_size->StaticFSize($IVal);
$UserInput['file_size'] = $file_size->FDS;
//Check to see if user has enough space left
$this->max_disk_space = pow(1024,2)*10;
//Add all file s