4 * Copyright 1999-2001 (c) VA Linux Systems
6 * This file is part of FusionForge.
8 * FusionForge is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * FusionForge is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with GForge; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
23 require (dirname(__FILE__).'/../www/env.inc.php');
24 require_once $gfcommon.'include/pre.php';
25 require $gfcommon.'include/cron_utils.php';
31 // one hour ago for projects
33 db_query_params ('DELETE FROM groups WHERE status=$1 and register_time < $2',
38 // one week ago for users
39 $then=(time()-604800);
41 db_query_params ('DELETE FROM pfo_user_role WHERE EXISTS (SELECT user_id FROM users
42 WHERE status=$1 and add_date < $2 AND users.user_id=pfo_user_role.user_id)',
46 db_query_params ('DELETE FROM user_group WHERE EXISTS (SELECT user_id FROM users
47 WHERE status=$1 and add_date < $2 AND users.user_id=user_group.user_id)',
52 db_query_params ('DELETE FROM user_group WHERE EXISTS (SELECT user_id FROM users
53 WHERE status=$1 and add_date < $2 AND users.user_id=user_group.user_id)',
58 $result = db_query_params ('SELECT user_id, email FROM users WHERE status=$1 and add_date < $2',
61 if (db_numrows($result)) {
64 require_once('common/include/Plugin.class.php') ;
65 require_once('common/include/PluginManager.class.php') ;
67 // SCM-specific plugins subsystem
68 require_once('common/include/SCMPlugin.class.php') ;
70 setup_plugin_manager () ;
72 while ($row = db_fetch_array($result)) {
73 $hook_params = array();
74 $hook_params['user'] = &user_get_object($row['user_id']);
75 $hook_params['user_id'] = $row['user_id'];
76 plugin_hook ("user_delete", $hook_params);
80 db_query_params ('DELETE FROM users WHERE status=$1 and add_date < $2',
85 #30 days ago for sessions
86 $then=(time()-(30*60*60*24));
87 db_query_params ('DELETE FROM user_session WHERE time < $1',
91 #one month ago for preferences
92 $then=(time()-604800*4);
93 db_query_params ('DELETE FROM user_preferences WHERE set_date < $1',
98 $then=(time()-604800*3);
99 db_query_params ('UPDATE people_job SET status_id = 3 where post_date < $1',
103 #1 day ago for form keys
104 $then=(time()-(60*60*24));
105 db_query_params ('DELETE FROM form_keys WHERE creation_date < $1',
111 $err .= "Error: ".db_error();