Fixes vim mode line.
[platal.git] / bin / cron / clean.php
CommitLineData
ee68ddc1 1#!/usr/bin/php5 -q
0337d704 2<?php
3/***************************************************************************
c441aabe 4 * Copyright (C) 2003-2014 Polytechnique.org *
0337d704 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
5ecaa68e 23require './connect.db.inc.php';
0337d704 24
25function query ($sql) {
08cce2ff 26 XDB::execute($sql);
0380bf85 27 if (XDB::errno() != 0) {
5ecaa68e 28 echo "error in \"$sql\":\n", XDB::error(), "\n";
0337d704 29 }
30}
31
5ecaa68e
SJ
32query('DELETE FROM register_pending
33 WHERE TO_DAYS(NOW()) - TO_DAYS(date) >= 365');
34query('DELETE FROM register_pending
35 WHERE hash = \'INSCRIT\'');
0337d704 36
5ecaa68e
SJ
37// Sorts a few tables to optimize sorted read acces.
38query('ALTER TABLE profile_binet_enum
39 ORDER BY text');
40query('ALTER TABLE profile_corps_enum
41 ORDER BY name');
42query('ALTER TABLE profile_corps_rank_enum
43 ORDER BY name');
44query('ALTER TABLE profile_education_degree_enum
0463b521 45 ORDER BY degree');
5ecaa68e
SJ
46query('ALTER TABLE profile_education_field_enum
47 ORDER BY field');
48query('ALTER TABLE profile_job_enum
49 ORDER BY name');
5ecaa68e 50query('ALTER TABLE profile_langskill_enum
43c653a1 51 ORDER BY language');
5ecaa68e
SJ
52query('ALTER TABLE profile_medal_enum
53 ORDER BY text');
54query('ALTER TABLE profile_networking_enum
55 ORDER BY name');
56query('ALTER TABLE profile_section_enum
57 ORDER BY text');
58query('ALTER TABLE profile_skill_enum
59 ORDER BY text_fr');
0337d704 60
66f03717 61// Prunes older autocomplete queries.
5ecaa68e
SJ
62query('DELETE FROM search_autocomplete
63 WHERE generated < DATE_SUB(NOW(), INTERVAL 1 DAY)');
0337d704 64
16ab1e34
SJ
65// XXX: cleans profile_merge_issues (to be removed once all merge related issues have been fixed)
66query('DELETE FROM profile_merge_issues
67 WHERE issues IS NULL OR issues = \'\'');
68
448c8cdc 69// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
0337d704 70?>