Merge remote branch 'origin/platal-1.0.0'
[platal.git] / bin / cron / clean.php
1 #!/usr/bin/php5 -q
2 <?php
3 /***************************************************************************
4 * Copyright (C) 2003-2010 Polytechnique.org *
5 * http://opensource.polytechnique.org/ *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program 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. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
19 * Foundation, Inc., *
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
21 ***************************************************************************/
22
23 require './connect.db.inc.php';
24
25 function query ($sql) {
26 XDB::execute($sql);
27 if (XDB::errno() != 0) {
28 echo "error in \"$sql\":\n", XDB::error(), "\n";
29 }
30 }
31
32 query('DELETE FROM register_pending
33 WHERE TO_DAYS(NOW()) - TO_DAYS(date) >= 365');
34 query('DELETE FROM register_pending
35 WHERE hash = \'INSCRIT\'');
36
37 // Sorts a few tables to optimize sorted read acces.
38 query('ALTER TABLE profile_binet_enum
39 ORDER BY text');
40 query('ALTER TABLE profile_corps_enum
41 ORDER BY name');
42 query('ALTER TABLE profile_corps_rank_enum
43 ORDER BY name');
44 query('ALTER TABLE profile_education_degree_enum
45 ORDER BY degree');
46 query('ALTER TABLE profile_education_field_enum
47 ORDER BY field');
48 query('ALTER TABLE profile_job_enum
49 ORDER BY name');
50 query('ALTER TABLE profile_job_sector_enum
51 ORDER BY name');
52 query('ALTER TABLE profile_job_subsector_enum
53 ORDER BY name');
54 query('ALTER TABLE profile_job_subsubsector_enum
55 ORDER BY name');
56 query('ALTER TABLE profile_langskill_enum
57 ORDER BY langue_fr');
58 query('ALTER TABLE profile_medal_enum
59 ORDER BY text');
60 query('ALTER TABLE profile_networking_enum
61 ORDER BY name');
62 query('ALTER TABLE profile_section_enum
63 ORDER BY text');
64 query('ALTER TABLE profile_skill_enum
65 ORDER BY text_fr');
66
67 // Prunes older autocomplete queries.
68 query('DELETE FROM search_autocomplete
69 WHERE generated < DATE_SUB(NOW(), INTERVAL 1 DAY)');
70
71 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
72 ?>