Moving the old code aside into the archive as i begin a new
[glcas.git] / archive / v1 / lib / updates.php
1 <?php
2 // there will be one version for base code, then 
3
4 $timerval_t = db_selectData("options", "option_name", "update.check.interval");
5
6 //echo "timer check:\n";
7 //print_r($timerval_t);
8 //echo "timer endcheck\n";
9
10
11 if(!isset($timerval_t[0])) {
12         //echo "likely we have no timer check value, setting to default of 3 days\n";
13         $ci = 3*24*3600;
14         db_insertData("options", "update.check.interval", "$ci");
15         $timerval = $ci;
16 } else {
17         $timerval = $timerval_t[0]["option_value"];
18 }
19
20 $lastupdate_t = db_selectData("options", "option_name", "update.check.last");
21
22
23 if(!isset($lastupdate_t[0])) {
24         db_insertData("options", "update.check.last", "0");
25         up_doUpdateCheck();
26 } else {
27         // no last update, perform one now
28         $lastupdate = $lastupdate_t[0]["option_value"];
29
30         $ctime = time();
31         
32         $tdiff = $ctime - $lastupdate;
33         
34         if($tdiff > $timerval) {
35                 up_doUpdateCheck();
36         }
37 }
38 //echo "timerval: $timerval\n";
39
40 function up_doUpdateCheck()
41 {
42         echo "do update check and reset interval\n";
43         
44         // db_updateData($tablename, $column, $newdata, $wherecol, $wheredata, $exact=true)
45         $ctime = time();
46         
47         db_updateData("options", "option_value", "$ctime", "option_name", "update.check.last");
48         
49         // next go thru the $VERSION set info, and download the lastest version list from the
50         // main site.
51 }
52 ?>