2 // +----------------------------------------------------------------------+
3 // | Anuko Time Tracker
4 // +----------------------------------------------------------------------+
5 // | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
6 // +----------------------------------------------------------------------+
7 // | LIBERAL FREEWARE LICENSE: This source code document may be used
8 // | by anyone for any purpose, and freely redistributed alone or in
9 // | combination with other software, provided that the license is obeyed.
11 // | There are only two ways to violate the license:
13 // | 1. To redistribute this code in source form, with the copyright
14 // | notice or license removed or altered. (Distributing in compiled
15 // | forms without embedded copyright notices is permitted).
17 // | 2. To redistribute modified versions of this code in *any* form
18 // | that bears insufficient indications that the modifications are
19 // | not the work of the original author(s).
21 // | This license applies to this document only, not any other software
22 // | that it may be combined with.
24 // +----------------------------------------------------------------------+
26 // | https://www.anuko.com/time_tracker/credits.htm
27 // +----------------------------------------------------------------------+
30 * cron_db_cleanup.php - this file is an entry point to execute a database cleanup job in Time Tracker.
31 * It must be called externally (for example, from the system cron or task scheduler).
34 require_once('initialize.php');
35 import('ttTeamHelper');
38 $inactive_teams = ttTeamHelper::getInactiveTeams();
39 $count = count($inactive_teams);
40 print "$count inactive teams found...<br>\n";
41 for ($i = 0; $i < $count; $i++) {
42 print " deleting team ".$inactive_teams[$i]."<br>\n";
43 $res = ttTeamHelper::delete($inactive_teams[$i]);
46 $mdb2 = getConnection();
47 $mdb2->exec("OPTIMIZE TABLE tt_client_project_binds");
48 $mdb2->exec("OPTIMIZE TABLE tt_client_project_binds");
49 $mdb2->exec("OPTIMIZE TABLE tt_clients");
50 $mdb2->exec("OPTIMIZE TABLE tt_config");
51 $mdb2->exec("OPTIMIZE TABLE tt_custom_field_log");
52 $mdb2->exec("OPTIMIZE TABLE tt_custom_field_options");
53 $mdb2->exec("OPTIMIZE TABLE tt_custom_fields");
54 $mdb2->exec("OPTIMIZE TABLE tt_expense_items");
55 $mdb2->exec("OPTIMIZE TABLE tt_fav_reports");
56 $mdb2->exec("OPTIMIZE TABLE tt_invoices");
57 $mdb2->exec("OPTIMIZE TABLE tt_log");
58 $mdb2->exec("OPTIMIZE TABLE tt_project_task_binds");
59 $mdb2->exec("OPTIMIZE TABLE tt_projects");
60 $mdb2->exec("OPTIMIZE TABLE tt_tasks");
61 $mdb2->exec("OPTIMIZE TABLE tt_teams");
62 $mdb2->exec("OPTIMIZE TABLE tt_tmp_refs");
63 $mdb2->exec("OPTIMIZE TABLE tt_user_project_binds");
64 $mdb2->exec("OPTIMIZE TABLE tt_users");