X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fdb.php;h=5503a4a160e2ea9baf83eb8bbc245f5a0b159437;hp=cc40f67c1e8054a60515806445e25e7b0533136b;hb=cf764594cd00e66ee812c5d63b016bf286178f67;hpb=c757506a0a598593115c377a6e4acf399f4d2b83 diff --git a/include/db.php b/include/db.php index cc40f67..5503a4a 100644 --- a/include/db.php +++ b/include/db.php @@ -1,4 +1,23 @@ + * + * This file is part of e-DoKo. + * + * e-DoKo is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * e-DoKo is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with e-DoKo. If not, see . + * + */ + /* make sure that we are not called from outside the scripts, * use a variable defined in config.php to check this */ @@ -11,17 +30,24 @@ if(!isset($HOST)) function DB_open() { + $version_needed = 1; + global $DB,$DB_user,$DB_host,$DB_database,$DB_password; $DB = @mysql_connect($DB_host,$DB_user, $DB_password); if ( $DB ) { - mysql_select_db($DB_database) or die('Could not select database'); + mysql_select_db($DB_database) or die('Error: Could not select database'); } else { echo mysql_errno() . ": " . mysql_error(). "\n"; return -1; - } + }; + + $version = DB_get_version(); + if ($version != $version_needed) + return -2; + return 0; } @@ -470,6 +496,17 @@ function DB_get_names_of_last_logins($N) return $names; } +function DB_get_emails_of_last_logins($N) +{ + $emails = array(); + + $result = DB_query("SELECT email FROM User ORDER BY last_login DESC LIMIT $N"); + while($r = DB_fetch_array($result)) + $emails[] = $r[0]; + + return $emails; +} + function DB_get_names_of_new_logins($N) { $names = array(); @@ -487,6 +524,15 @@ function DB_update_game_timestamp($gameid) return; } +function DB_get_game_timestamp($gameid) +{ + $r = DB_query_array("SELECT mod_date FROM Game WHERE id=".DB_quote_smart($gameid)); + + if($r) + return $r[0]; + else + return NULL; +} function DB_update_user_timestamp($userid) { @@ -503,6 +549,17 @@ function DB_get_user_timestamp($userid) else return NULL; } + +function DB_get_user_creation_date($userid) +{ + $r = DB_query_array("SELECT create_date FROM User WHERE id=".DB_quote_smart($userid)); + + if($r) + return $r[0]; + else + return NULL; +} + function DB_get_user_timezone($userid) { $r = DB_query_array("SELECT timezone FROM User WHERE id=".DB_quote_smart($userid));