summaryrefslogtreecommitdiffstats
path: root/update_db.php
diff options
context:
space:
mode:
authorArun Persaud <arun@nubati.net>2009-06-21 23:23:15 -0700
committerArun Persaud <arun@nubati.net>2009-06-23 00:17:00 -0700
commitc757506a0a598593115c377a6e4acf399f4d2b83 (patch)
treeae26d5aca8ae536e5754781a3341422bfa07b632 /update_db.php
parent1a44bc0d058016a093a112f064bac63a570c400d (diff)
downloade-DoKo-c757506a0a598593115c377a6e4acf399f4d2b83.tar.gz
e-DoKo-c757506a0a598593115c377a6e4acf399f4d2b83.tar.bz2
e-DoKo-c757506a0a598593115c377a6e4acf399f4d2b83.zip
added option for email digest
you can now select to get emails only every N hours. They are saved in the database and a cron script will send them out.
Diffstat (limited to 'update_db.php')
-rw-r--r--update_db.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/update_db.php b/update_db.php
new file mode 100644
index 0000000..140dece
--- /dev/null
+++ b/update_db.php
@@ -0,0 +1,42 @@
+<?php
+error_reporting(E_ALL);
+
+include_once("config.php"); /* needs to be first in list, since other includes use this */
+include_once("./include/db.php"); /* database only */
+include_once("./include/functions.php"); /* the rest */
+
+/* make sure that user has set all variables in config.php */
+config_check();
+
+/* open the database */
+if(DB_open()<0)
+ exit();
+
+/* only callable via cron or CLI */
+if(isset($_SERVER['REMOTE_ADDR']))
+ exit();
+
+$old_version = DB_get_version();
+$current_version = 1;
+
+if($old_version < $current_version)
+ echo "Will upgrade your database now:\n";
+else
+ echo "You are up to date (version ${current_version}), nothing to do.\n";
+
+switch($old_version)
+ {
+ case 0:
+ /* add database for digesting */
+ DB_query("CREATE TABLE digest_email (".
+ " `id` int(11) NOT NULL auto_increment,".
+ " `email` varchar(255) default null,".
+ " `create_date` timestamp NOT NULL default '0000-00-00 00:00:00',".
+ " `content` text,".
+ " UNIQUE KEY `id` (`id`),".
+ " index (email))");
+ DB_query("UPDATE Version set version=1");
+ echo "Upgraded to version 1.\n";
+ }
+
+?> \ No newline at end of file