4 * Copyright 1999-2001 (c) VA Linux Systems
6 * This file is part of FusionForge. FusionForge is free software;
7 * you can redistribute it and/or modify it under the terms of the
8 * GNU General Public License as published by the Free Software
9 * Foundation; either version 2 of the Licence, or (at your option)
12 * FusionForge is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 require dirname(__FILE__).'/../www/env.inc.php';
23 require_once $gfcommon.'include/pre.php';
24 require $gfcommon.'include/cron_utils.php';
30 // one hour ago for projects
32 db_query_params ('DELETE FROM groups WHERE status=$1 and register_time < $2',
37 // one week ago for users
38 $then=(time()-604800);
39 db_query_params ('DELETE FROM pfo_user_role WHERE EXISTS (SELECT user_id FROM users
40 WHERE status=$1 and add_date < $2 AND users.user_id=pfo_user_role.user_id)',
44 db_query_params ('DELETE FROM user_group WHERE EXISTS (SELECT user_id FROM users
45 WHERE status=$1 and add_date < $2 AND users.user_id=user_group.user_id)',
49 $result = db_query_params ('SELECT user_id, email FROM users WHERE status=$1 and add_date < $2',
52 if (db_numrows($result)) {
55 require_once('common/include/Plugin.class.php') ;
56 require_once('common/include/PluginManager.class.php') ;
58 // SCM-specific plugins subsystem
59 require_once('common/include/SCMPlugin.class.php') ;
61 setup_plugin_manager () ;
63 while ($row = db_fetch_array($result)) {
64 $hook_params = array();
65 $hook_params['user'] = &user_get_object($row['user_id']);
66 $hook_params['user_id'] = $row['user_id'];
67 plugin_hook ("user_delete", $hook_params);
71 db_query_params ('DELETE FROM users WHERE status=$1 and add_date < $2',
76 #30 days ago for sessions
77 $then=(time()-(30*60*60*24));
78 db_query_params ('DELETE FROM user_session WHERE time < $1',
82 #one month ago for preferences
83 $then=(time()-604800*4);
84 db_query_params ('DELETE FROM user_preferences WHERE set_date < $1',
89 $then=(time()-604800*3);
90 db_query_params ('UPDATE people_job SET status_id = 3 where post_date < $1',
94 #1 day ago for form keys
95 $then=(time()-(60*60*24));
96 db_query_params ('DELETE FROM form_keys WHERE creation_date < $1',
100 // Purge delete files older than one month.
101 if (is_dir(forge_get_config('data_path').'/tracker')) {
102 system('find "'.forge_get_config('data_path').'/tracker" -name "*.removed" -type f -mtime +30 -exec rm -- {} \\;');
107 $err .= "Error: ".db_error();