Moving the old code aside into the archive as i begin a new
[glcas.git] / archive / v1 / lib / updates.php
diff --git a/archive/v1/lib/updates.php b/archive/v1/lib/updates.php
new file mode 100644 (file)
index 0000000..95cc892
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+// there will be one version for base code, then 
+
+$timerval_t = db_selectData("options", "option_name", "update.check.interval");
+
+//echo "timer check:\n";
+//print_r($timerval_t);
+//echo "timer endcheck\n";
+
+
+if(!isset($timerval_t[0])) {
+       //echo "likely we have no timer check value, setting to default of 3 days\n";
+       $ci = 3*24*3600;
+       db_insertData("options", "update.check.interval", "$ci");
+       $timerval = $ci;
+} else {
+       $timerval = $timerval_t[0]["option_value"];
+}
+
+$lastupdate_t = db_selectData("options", "option_name", "update.check.last");
+
+
+if(!isset($lastupdate_t[0])) {
+       db_insertData("options", "update.check.last", "0");
+       up_doUpdateCheck();
+} else {
+       // no last update, perform one now
+       $lastupdate = $lastupdate_t[0]["option_value"];
+
+       $ctime = time();
+       
+       $tdiff = $ctime - $lastupdate;
+       
+       if($tdiff > $timerval) {
+               up_doUpdateCheck();
+       }
+}
+//echo "timerval: $timerval\n";
+
+function up_doUpdateCheck()
+{
+       echo "do update check and reset interval\n";
+       
+       // db_updateData($tablename, $column, $newdata, $wherecol, $wheredata, $exact=true)
+       $ctime = time();
+       
+       db_updateData("options", "option_value", "$ctime", "option_name", "update.check.last");
+       
+       // next go thru the $VERSION set info, and download the lastest version list from the
+       // main site.
+}
+?>
\ No newline at end of file