All database names are now 'back-ticked' and constant _MYSQL_PREFIX is wrapped. Partl...
[mailer.git] / inc / autopurge / purge-tsks.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 09/14/2008 *
4  * ===============                              Last change: 09/14/2008 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : purge-tsks.php                                   *
8  * -------------------------------------------------------------------- *
9  * Short description : Automatical purging of outdated mail links       *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Auto-Loeschung von veralteten Mail-Links         *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 } // END - if
39
40 // Abort if autopurge is not active or disabled by admin
41 if ((!EXT_IS_ACTIVE("autopurge")) || (getConfig('auto_purge_active') == "N")) {
42         // Abort here
43         return false;
44 } // END - if
45
46 // Check version (must be > 0.0)
47 if ((GET_EXT_VERSION("task") > "0.0") && (getConfig('ap_tasks') == "Y")) {
48         // Since when shall we purge?
49         $since = bigintval(getConfig('ap_tasks_time'));
50
51         // Purge deleted tasks (no notification to admin)
52         SQL_QUERY_ESC("DELETE LOW_PRIORITY
53 FROM `{!MYSQL_PREFIX!}_task_system`
54 WHERE status='DELETED' AND task_created <= (UNIX_TIMESTAMP() - %s)",
55                 array($since), __FILE__, __LINE__);
56         $DELETED = SQL_AFFECTEDROWS();
57
58         if (($DELETED > 0) && (getConfig('ap_tasks_notify') == "Y")) {
59                 // Send out email to admin
60                 SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_TASKS_SUBJECT, "admin_autopurge_tsks", $DELETED, "");
61         } // END - if
62 } // END - if
63
64 //
65 ?>