summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Controller/File.php6
-rw-r--r--app/Model/File.php25
-rw-r--r--app/ServiceProvider/LoggingProvider.php2
-rw-r--r--app/constants.php5
4 files changed, 17 insertions, 21 deletions
diff --git a/app/Controller/File.php b/app/Controller/File.php
index 63052610..3255fe84 100644
--- a/app/Controller/File.php
+++ b/app/Controller/File.php
@@ -2,8 +2,6 @@
namespace Controller;
-use Model\File as FileModel;
-
/**
* File controller
*
@@ -54,7 +52,7 @@ class File extends Base
{
$task = $this->getTask();
$file = $this->file->getById($this->request->getIntegerParam('file_id'));
- $filename = FileModel::BASE_PATH.$file['path'];
+ $filename = FILES_DIR.$file['path'];
if ($file['task_id'] == $task['id'] && file_exists($filename)) {
$this->response->forceDownload($file['name']);
@@ -91,7 +89,7 @@ class File extends Base
{
$task = $this->getTask();
$file = $this->file->getById($this->request->getIntegerParam('file_id'));
- $filename = FileModel::BASE_PATH.$file['path'];
+ $filename = FILES_DIR.$file['path'];
if ($file['task_id'] == $task['id'] && file_exists($filename)) {
$metadata = getimagesize($filename);
diff --git a/app/Model/File.php b/app/Model/File.php
index 20fba9bf..1b9351db 100644
--- a/app/Model/File.php
+++ b/app/Model/File.php
@@ -20,13 +20,6 @@ class File extends Base
const TABLE = 'task_has_files';
/**
- * Directory where are stored files
- *
- * @var string
- */
- const BASE_PATH = 'data/files/';
-
- /**
* Events
*
* @var string
@@ -56,7 +49,7 @@ class File extends Base
{
$file = $this->getbyId($file_id);
- if (! empty($file) && @unlink(self::BASE_PATH.$file['path'])) {
+ if (! empty($file) && @unlink(FILES_DIR.$file['path'])) {
return $this->db->table(self::TABLE)->eq('id', $file_id)->remove();
}
@@ -152,14 +145,14 @@ class File extends Base
*/
public function setup()
{
- if (! is_dir(self::BASE_PATH)) {
- if (! mkdir(self::BASE_PATH, 0755, true)) {
- die('Unable to create the upload directory: "'.self::BASE_PATH.'"');
+ if (! is_dir(FILES_DIR)) {
+ if (! mkdir(FILES_DIR, 0755, true)) {
+ die('Unable to create the upload directory: "'.FILES_DIR.'"');
}
}
- if (! is_writable(self::BASE_PATH)) {
- die('The directory "'.self::BASE_PATH.'" must be writeable by your webserver user');
+ if (! is_writable(FILES_DIR)) {
+ die('The directory "'.FILES_DIR.'" must be writeable by your webserver user');
}
}
@@ -187,15 +180,15 @@ class File extends Base
$uploaded_filename = $_FILES[$form_name]['tmp_name'][$key];
$destination_filename = $this->generatePath($project_id, $task_id, $original_filename);
- @mkdir(self::BASE_PATH.dirname($destination_filename), 0755, true);
+ @mkdir(FILES_DIR.dirname($destination_filename), 0755, true);
- if (@move_uploaded_file($uploaded_filename, self::BASE_PATH.$destination_filename)) {
+ if (@move_uploaded_file($uploaded_filename, FILES_DIR.$destination_filename)) {
$result[] = $this->create(
$task_id,
$original_filename,
$destination_filename,
- $this->isImage(self::BASE_PATH.$destination_filename)
+ $this->isImage(FILES_DIR.$destination_filename)
);
}
}
diff --git a/app/ServiceProvider/LoggingProvider.php b/app/ServiceProvider/LoggingProvider.php
index 5b2cf565..76263da3 100644
--- a/app/ServiceProvider/LoggingProvider.php
+++ b/app/ServiceProvider/LoggingProvider.php
@@ -16,7 +16,7 @@ class LoggingProvider implements ServiceProviderInterface
$logger->setLogger(new Syslog('kanboard'));
if (DEBUG) {
- $logger->setLogger(new File(__DIR__.'/../../data/debug.log'));
+ $logger->setLogger(new File(DEBUG_FILE));
}
$container['logger'] = $logger;
diff --git a/app/constants.php b/app/constants.php
index f0384d30..9245d023 100644
--- a/app/constants.php
+++ b/app/constants.php
@@ -2,6 +2,7 @@
// Enable/disable debug
defined('DEBUG') or define('DEBUG', false);
+defined('DEBUG_FILE') or define('DEBUG_FILE', 'data/debug.log');
// Application version
defined('APP_VERSION') or define('APP_VERSION', 'master');
@@ -64,3 +65,7 @@ defined('MAIL_SENDMAIL_COMMAND') or define('MAIL_SENDMAIL_COMMAND', '/usr/sbin/s
// Enable or disable "Strict-Transport-Security" HTTP header
defined('ENABLE_HSTS') or define('ENABLE_HSTS', true);
+
+// Default files directory
+defined('FILES_DIR') or define('FILES_DIR', 'data/files/');
+