NEW FEATURE: use gravatars as icons for players
[e-DoKo.git] / update_db.php
1 <?php
2 error_reporting(E_ALL);
3
4 include_once("config.php");                /* needs to be first in list, since other includes use this */
5 include_once("./include/db.php");          /* database only */
6 include_once("./include/functions.php");   /* the rest */
7
8 /* make sure that user has set all variables in config.php */
9 config_check();
10
11 /* open the database */
12 if(DB_open()<0)
13   exit();
14
15 /* only callable via cron or CLI */
16 if(isset($_SERVER['REMOTE_ADDR']))
17   exit();
18
19 $old_version = DB_get_version();
20 $current_version = 1;
21
22 if($old_version < $current_version)
23   echo "Will upgrade your database now:\n";
24 else
25   echo "You are up to date (version ${current_version}), nothing to do.\n";
26
27 switch($old_version)
28   {
29   case 0:
30     /* add database for digesting */
31     DB_query("CREATE TABLE digest_email (".
32              " `id` int(11) NOT NULL auto_increment,".
33              " `email` varchar(255) default null,".
34              " `create_date` timestamp NOT NULL default '0000-00-00 00:00:00',".
35              " `content` text,".
36              " UNIQUE KEY `id` (`id`),".
37              " index (email))");
38     DB_query("UPDATE Version set version=1");
39     echo "Upgraded to version 1.\n";
40   }
41
42 ?>