4 * Copyright 1999-2001 (c) VA Linux Systems
6 * This file is part of GForge.
8 * GForge 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 * GForge 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 $gfwww.'include/pre.php';
25 require $gfcommon.'include/cron_utils.php';
32 #one hour ago for projects
34 db_query_params ('DELETE FROM groups WHERE status=$1 and register_time < $2',
39 #one week ago for users
40 $then=(time()-604800);
41 db_query_params ('DELETE FROM user_group WHERE EXISTS (SELECT user_id FROM users
42 WHERE status=$1 and add_date < $2 AND users.user_id=user_group.user_id)',
47 $result = db_query_params ('SELECT user_id, email FROM users WHERE status=$1 and add_date < $2',
50 if (db_numrows($result)) {
53 require_once('common/include/Plugin.class.php') ;
54 require_once('common/include/PluginManager.class.php') ;
56 // SCM-specific plugins subsystem
57 require_once('common/include/SCMPlugin.class.php') ;
59 setup_plugin_manager () ;
61 while ($row = db_fetch_array($result)) {
62 $hook_params = array();
63 $hook_params['user'] = &user_get_object($row['user_id']);
64 $hook_params['user_id'] = $row['user_id'];
65 plugin_hook ("user_delete", $hook_params);
69 db_query_params ('DELETE FROM users WHERE status=$1 and add_date < $2',
74 #30 days ago for sessions
75 $then=(time()-(30*60*60*24));
76 db_query_params ('DELETE FROM user_session WHERE time < $1',
80 #one month ago for preferences
81 $then=(time()-604800*4);
82 db_query_params ('DELETE FROM user_preferences WHERE set_date < $1',
87 $then=(time()-604800*3);
88 db_query_params ('UPDATE people_job SET status_id = 3 where post_date < $1',
92 #1 day ago for form keys
93 $then=(time()-(60*60*24));
94 db_query_params ('DELETE FROM form_keys WHERE creation_date < $1',
100 $err .= "Error: ".db_error();