Added command-line rebuilder. This needs some security.
[viewsvn.git] / rebuild.sh.php
1 #!/usr/bin/php
2 <?php
3 /*=====================================================================*\
4 || ###################################################################
5 || # ViewSVN [#]version[#]
6 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
7 || #
8 || # This program 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; version [#]gpl[#] of the License.
11 || #
12 || # This program is distributed in the hope that it will be useful, but
13 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 || # more details.
16 || #
17 || # You should have received a copy of the GNU General Public License along
18 || # with this program; if not, write to the Free Software Foundation, Inc.,
19 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 || ###################################################################
21 \*=====================================================================*/
22
23 define('PATH_OVERRIDE', 1);
24
25 require_once('./global.php');
26
27 // ###################################################################
28
29 $tables = $db->query("SHOW TABLES");
30 while ($table = $db->fetch_array($tables))
31 {
32 $value = array_values($table);
33 $tablelist[] = $value[0];
34 }
35
36 foreach ($viewsvn->repos->fetch_list() AS $repos)
37 {
38 if (!in_array('c' . ($hash = md5($viewsvn->repos->fetch_path($repos))) . '_revs', $tablelist))
39 {
40 $viewsvn->debug("creating new cacheV: $repos");
41 $db->query("
42 CREATE TABLE c{$hash}_revs
43 (
44 revision INT(20) UNSIGNED NOT NULL DEFAULT 0,
45 author VARCHAR(255) NOT NULL DEFAULT '',
46 dateline VARCHAR(100) NOT NULL DEFAULT '',
47 files MEDIUMTEXT NOT NULL DEFAULT '',
48 message MEDIUMTEXT NOT NULL DEFAULT '',
49 PRIMARY KEY (revision)
50 )"
51 );
52
53 $db->query("
54 CREATE TABLE c{$hash}_nodes
55 (
56 name VARCHAR(255) NOT NULL DEFAULT '',
57 node VARCHAR(50) NOT NULL DEFAULT '',
58 revision INT(20) UNSIGNED NOT NULL DEFAULT 0,
59 history MEDIUMTEXT NOT NULL DEFAULT '',
60 properties MEDIUMTEXT NOT NULL DEFAULT '',
61 PRIMARY KEY (name)
62 )"
63 );
64 }
65
66 $controller = new Controller($repos);
67 $controller->cachev->build(null);
68 }
69
70 /*=====================================================================*\
71 || ###################################################################
72 || # $HeadURL$
73 || # $Id$
74 || ###################################################################
75 \*=====================================================================*/
76 ?>