qls = &$qls; } /** * Checks existence of file * @return bool */ function validate_existence() { if (!file_exists($this->qls->main_directory . '/' . trim($_FILES['upload']['name']))) { return true; } else { return false; } } /** * Validates the size * @return bool */ function validate_size() { if ($_FILES['upload']['size'] <= $this->qls->config['max_upload_size']) { return true; } else { return false; } } /** * Validates the extension * @return bool */ function validate_extension() { $extension = strtolower(substr($_FILES['upload']['name'], -4)); if ($extension == '.php') { return true; } else { return false; } } /** * Validates the file being uploaded * @internal param string $file_name - The temporary uploaded file to check * @return bool */ function upload_file() { $temporary_file_location = $_FILES['upload']['tmp_name']; $new_file_location = $this->qls->main_directory . '/' . trim($_FILES['upload']['name']); if ($this->validate_existence() && $this->validate_size() && $this->validate_extension()) { // Is it an uploaded file? If so move it to the proper directory if (is_uploaded_file($temporary_file_location)) { if (move_uploaded_file($temporary_file_location, $new_file_location)) { return true; } else { $this->qls->Admin->add_page_error = FILE_NOT_MOVED; return false; } } else { $this->qls->Admin->add_page_error = FILE_NOT_UPLOADED; return false; } } else { $this->qls->Admin->add_page_error = FILE_EXISTS_SIZE_EXTENSION; return false; } } }