aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/cron
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/cron')
-rw-r--r--phpBB/phpbb/cron/manager.php8
-rw-r--r--phpBB/phpbb/cron/task/base.php8
-rw-r--r--phpBB/phpbb/cron/task/core/prune_all_forums.php8
-rw-r--r--phpBB/phpbb/cron/task/core/prune_forum.php8
-rw-r--r--phpBB/phpbb/cron/task/core/prune_notifications.php16
-rw-r--r--phpBB/phpbb/cron/task/core/queue.php8
-rw-r--r--phpBB/phpbb/cron/task/core/tidy_cache.php8
-rw-r--r--phpBB/phpbb/cron/task/core/tidy_database.php8
-rw-r--r--phpBB/phpbb/cron/task/core/tidy_plupload.php116
-rw-r--r--phpBB/phpbb/cron/task/core/tidy_search.php8
-rw-r--r--phpBB/phpbb/cron/task/core/tidy_sessions.php8
-rw-r--r--phpBB/phpbb/cron/task/core/tidy_warnings.php8
-rw-r--r--phpBB/phpbb/cron/task/parametrized.php8
-rw-r--r--phpBB/phpbb/cron/task/task.php8
-rw-r--r--phpBB/phpbb/cron/task/wrapper.php8
15 files changed, 121 insertions, 115 deletions
diff --git a/phpBB/phpbb/cron/manager.php b/phpBB/phpbb/cron/manager.php
index f58ba64a3d..b6af07aff7 100644
--- a/phpBB/phpbb/cron/manager.php
+++ b/phpBB/phpbb/cron/manager.php
@@ -10,14 +10,6 @@
namespace phpbb\cron;
/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Cron manager class.
*
* Finds installed cron tasks, stores task objects, provides task selection.
diff --git a/phpBB/phpbb/cron/task/base.php b/phpBB/phpbb/cron/task/base.php
index f30c9daf1b..63f0407bcd 100644
--- a/phpBB/phpbb/cron/task/base.php
+++ b/phpBB/phpbb/cron/task/base.php
@@ -10,14 +10,6 @@
namespace phpbb\cron\task;
/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Cron task base class. Provides sensible defaults for cron tasks
* and partially implements cron task interface, making writing cron tasks easier.
*
diff --git a/phpBB/phpbb/cron/task/core/prune_all_forums.php b/phpBB/phpbb/cron/task/core/prune_all_forums.php
index 8e3ef25ce6..90b9a5914b 100644
--- a/phpBB/phpbb/cron/task/core/prune_all_forums.php
+++ b/phpBB/phpbb/cron/task/core/prune_all_forums.php
@@ -10,14 +10,6 @@
namespace phpbb\cron\task\core;
/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Prune all forums cron task.
*
* It is intended to be invoked from system cron.
diff --git a/phpBB/phpbb/cron/task/core/prune_forum.php b/phpBB/phpbb/cron/task/core/prune_forum.php
index f14ab7b702..e0d8b067c5 100644
--- a/phpBB/phpbb/cron/task/core/prune_forum.php
+++ b/phpBB/phpbb/cron/task/core/prune_forum.php
@@ -10,14 +10,6 @@
namespace phpbb\cron\task\core;
/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Prune one forum cron task.
*
* It is intended to be used when cron is invoked via web.
diff --git a/phpBB/phpbb/cron/task/core/prune_notifications.php b/phpBB/phpbb/cron/task/core/prune_notifications.php
index 296c0ae64f..9f67c54e1c 100644
--- a/phpBB/phpbb/cron/task/core/prune_notifications.php
+++ b/phpBB/phpbb/cron/task/core/prune_notifications.php
@@ -7,20 +7,14 @@
*
*/
-/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
+namespace phpbb\cron\task\core;
/**
* Prune notifications cron task.
*
* @package phpBB3
*/
-class phpbb_cron_task_core_prune_notifications extends phpbb_cron_task_base
+class prune_notifications extends \phpbb\cron\task\base
{
protected $config;
protected $notification_manager;
@@ -28,10 +22,10 @@ class phpbb_cron_task_core_prune_notifications extends phpbb_cron_task_base
/**
* Constructor.
*
- * @param phpbb_config $config The config
- * @param phpbb_notification_manager $notification_manager Notification manager
+ * @param \phpbb\config\config $config The config
+ * @param \phpbb\notification\manager $notification_manager Notification manager
*/
- public function __construct(phpbb_config $config, phpbb_notification_manager $notification_manager)
+ public function __construct(\phpbb\config\config $config, \phpbb\notification\manager $notification_manager)
{
$this->config = $config;
$this->notification_manager = $notification_manager;
diff --git a/phpBB/phpbb/cron/task/core/queue.php b/phpBB/phpbb/cron/task/core/queue.php
index cb13df86df..cd799b8024 100644
--- a/phpBB/phpbb/cron/task/core/queue.php
+++ b/phpBB/phpbb/cron/task/core/queue.php
@@ -10,14 +10,6 @@
namespace phpbb\cron\task\core;
/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Queue cron task. Sends email and jabber messages queued by other scripts.
*
* @package phpBB3
diff --git a/phpBB/phpbb/cron/task/core/tidy_cache.php b/phpBB/phpbb/cron/task/core/tidy_cache.php
index 021d5fd8a3..a94a85db53 100644
--- a/phpBB/phpbb/cron/task/core/tidy_cache.php
+++ b/phpBB/phpbb/cron/task/core/tidy_cache.php
@@ -10,14 +10,6 @@
namespace phpbb\cron\task\core;
/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Tidy cache cron task.
*
* @package phpBB3
diff --git a/phpBB/phpbb/cron/task/core/tidy_database.php b/phpBB/phpbb/cron/task/core/tidy_database.php
index d03cba1d86..f712a5047c 100644
--- a/phpBB/phpbb/cron/task/core/tidy_database.php
+++ b/phpBB/phpbb/cron/task/core/tidy_database.php
@@ -10,14 +10,6 @@
namespace phpbb\cron\task\core;
/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Tidy database cron task.
*
* @package phpBB3
diff --git a/phpBB/phpbb/cron/task/core/tidy_plupload.php b/phpBB/phpbb/cron/task/core/tidy_plupload.php
new file mode 100644
index 0000000000..5a98e0bd7b
--- /dev/null
+++ b/phpBB/phpbb/cron/task/core/tidy_plupload.php
@@ -0,0 +1,116 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+namespace phpbb\cron\task\core;
+
+/**
+* Cron task for cleaning plupload's temporary upload directory.
+*
+* @package phpBB3
+*/
+class tidy_plupload extends \phpbb\cron\task\base
+{
+ /**
+ * How old a file must be (in seconds) before it is deleted.
+ * @var int
+ */
+ protected $max_file_age = 86400;
+
+ /**
+ * How often we run the cron (in seconds).
+ * @var int
+ */
+ protected $cron_frequency = 86400;
+
+ /**
+ * phpBB root path
+ * @var string
+ */
+ protected $phpbb_root_path;
+
+ /**
+ * Config object
+ * @var \phpbb\config\config
+ */
+ protected $config;
+
+ /**
+ * Directory where plupload stores temporary files.
+ * @var string
+ */
+ protected $plupload_upload_path;
+
+ /**
+ * Constructor.
+ *
+ * @param string $phpbb_root_path The root path
+ * @param \phpbb\config\config $config The config
+ */
+ public function __construct($phpbb_root_path, \phpbb\config\config $config)
+ {
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->config = $config;
+
+ $this->plupload_upload_path = $this->phpbb_root_path . $this->config['upload_path'] . '/plupload';
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function run()
+ {
+ // Remove old temporary file (perhaps failed uploads?)
+ $last_valid_timestamp = time() - $this->max_file_age;
+ try
+ {
+ $iterator = new \DirectoryIterator($this->plupload_upload_path);
+ foreach ($iterator as $file)
+ {
+ if (strpos($file->getBasename(), $this->config['plupload_salt']) !== 0)
+ {
+ // Skip over any non-plupload files.
+ continue;
+ }
+
+ if ($file->getMTime() < $last_valid_timestamp)
+ {
+ @unlink($file->getPathname());
+ }
+ }
+ }
+ catch (\UnexpectedValueException $e)
+ {
+ add_log(
+ 'critical',
+ 'LOG_PLUPLOAD_TIDY_FAILED',
+ $this->plupload_upload_path,
+ $e->getMessage(),
+ $e->getTraceAsString()
+ );
+ }
+
+ $this->config->set('plupload_last_gc', time(), true);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function is_runnable()
+ {
+ return !empty($this->config['plupload_salt']) && is_dir($this->plupload_upload_path);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function should_run()
+ {
+ return $this->config['plupload_last_gc'] < time() - $this->cron_frequency;
+ }
+}
diff --git a/phpBB/phpbb/cron/task/core/tidy_search.php b/phpBB/phpbb/cron/task/core/tidy_search.php
index ebd0d86cbc..42f7df308f 100644
--- a/phpBB/phpbb/cron/task/core/tidy_search.php
+++ b/phpBB/phpbb/cron/task/core/tidy_search.php
@@ -10,14 +10,6 @@
namespace phpbb\cron\task\core;
/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Tidy search cron task.
*
* Will only run when the currently selected search backend supports tidying.
diff --git a/phpBB/phpbb/cron/task/core/tidy_sessions.php b/phpBB/phpbb/cron/task/core/tidy_sessions.php
index 5df019ae46..68094af1f7 100644
--- a/phpBB/phpbb/cron/task/core/tidy_sessions.php
+++ b/phpBB/phpbb/cron/task/core/tidy_sessions.php
@@ -10,14 +10,6 @@
namespace phpbb\cron\task\core;
/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Tidy sessions cron task.
*
* @package phpBB3
diff --git a/phpBB/phpbb/cron/task/core/tidy_warnings.php b/phpBB/phpbb/cron/task/core/tidy_warnings.php
index 1cc0abbe88..a0ff23fc57 100644
--- a/phpBB/phpbb/cron/task/core/tidy_warnings.php
+++ b/phpBB/phpbb/cron/task/core/tidy_warnings.php
@@ -10,14 +10,6 @@
namespace phpbb\cron\task\core;
/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Tidy warnings cron task.
*
* Will only run when warnings are configured to expire.
diff --git a/phpBB/phpbb/cron/task/parametrized.php b/phpBB/phpbb/cron/task/parametrized.php
index 1d2f449c58..1aeead0399 100644
--- a/phpBB/phpbb/cron/task/parametrized.php
+++ b/phpBB/phpbb/cron/task/parametrized.php
@@ -10,14 +10,6 @@
namespace phpbb\cron\task;
/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Parametrized cron task interface.
*
* Parametrized cron tasks are somewhat of a cross between regular cron tasks and
diff --git a/phpBB/phpbb/cron/task/task.php b/phpBB/phpbb/cron/task/task.php
index 84218c4fc9..3ce3de9598 100644
--- a/phpBB/phpbb/cron/task/task.php
+++ b/phpBB/phpbb/cron/task/task.php
@@ -10,14 +10,6 @@
namespace phpbb\cron\task;
/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Cron task interface
* @package phpBB3
*/
diff --git a/phpBB/phpbb/cron/task/wrapper.php b/phpBB/phpbb/cron/task/wrapper.php
index aa015966c6..fc3f897206 100644
--- a/phpBB/phpbb/cron/task/wrapper.php
+++ b/phpBB/phpbb/cron/task/wrapper.php
@@ -10,14 +10,6 @@
namespace phpbb\cron\task;
/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Cron task wrapper class.
* Enhances cron tasks with convenience methods that work identically for all tasks.
*