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);
40 db_query_params ('DELETE FROM pfo_user_role WHERE EXISTS (SELECT user_id FROM users
41 WHERE status=$1 and add_date < $2 AND users.user_id=pfo_user_role.user_id)',
45 db_query_params ('DELETE FROM user_group WHERE EXISTS (SELECT user_id FROM users
46 WHERE status=$1 and add_date < $2 AND users.user_id=user_group.user_id)',
51 db_query_params ('DELETE FROM user_group WHERE EXISTS (SELECT user_id FROM users
52 WHERE status=$1 and add_date < $2 AND users.user_id=user_group.user_id)',
57 $result = db_query_params ('SELECT user_id, email FROM users WHERE status=$1 and add_date < $2',
60 if (db_numrows($result)) {
63 require_once('common/include/Plugin.class.php') ;
64 require_once('common/include/PluginManager.class.php') ;
66 // SCM-specific plugins subsystem
67 require_once('common/include/SCMPlugin.class.php') ;
69 setup_plugin_manager () ;
71 while ($row = db_fetch_array($result)) {
72 $hook_params = array();
73 $hook_params['user'] = &user_get_object($row['user_id']);
74 $hook_params['user_id'] = $row['user_id'];
75 plugin_hook ("user_delete", $hook_params);
79 db_query_params ('DELETE FROM users WHERE status=$1 and add_date < $2',
84 #30 days ago for sessions
85 $then=(time()-(30*60*60*24));
86 db_query_params ('DELETE FROM user_session WHERE time < $1',
90 #one month ago for preferences
91 $then=(time()-604800*4);
92 db_query_params ('DELETE FROM user_preferences WHERE set_date < $1',
97 $then=(time()-604800*3);
98 db_query_params ('UPDATE people_job SET status_id = 3 where post_date < $1',
102 #1 day ago for form keys
103 $then=(time()-(60*60*24));
104 db_query_params ('DELETE FROM form_keys WHERE creation_date < $1',
110 $err .= "Error: ".db_error();