web: remove some mysql_* calls

This commit is contained in:
David Anderson 2013-12-16 00:45:45 -08:00
parent 6dc62fa950
commit 0fdfcbd074
1 changed files with 18 additions and 17 deletions

View File

@ -190,26 +190,27 @@ class BoincForumLogging {
}
self::$cache[$threadid] = $x;
}
static function cleanup() {
// TODO - clean this up
static function delete_aux($clause) {
$db = BoincDb::get();
$sql = "SELECT timestamp FROM ".$db->db_name.".forum_logging where userid=0 and threadid=0";
$result=$db->do_query($sql);
if (mysql_num_rows($result)>0) {
$data=mysql_fetch_object($result);
if ($data->timestamp<time()-MAX_FORUM_LOGGING_TIME){
$sql = "DELETE FROM ".$db->db_name.".forum_logging where timestamp<'".(time()-MAX_FORUM_LOGGING_TIME)."' and userid != 0";
$db->do_query($sql);
echo mysql_error();
$sql = "REPLACE INTO ".$db->db_name.".forum_logging set userid=0, threadid=0, timestamp='".time()."'";
$db->do_query($sql);
return $db->delete_aux('forum_logging', $clause);
}
static function cleanup() {
// Every 28 days, delete records older than 28 days.
// Keep track of the last time we did this in a special record
// with userid = threadid = 0.
// This gets called from forum_index.php
// (i.e. each time the forum main page is loaded).
//
$fl = BoincForumLogging::lookup(0, 0);
if ($fl) {
if ($fl->timestamp<time()-MAX_FORUM_LOGGING_TIME){
BoincForumLogging::delete_aux("timestamp<'".(time()-MAX_FORUM_LOGGING_TIME)."' and userid != 0");
BoincForumLogging::replace(0, 0, time());
}
} else {
//No cleanup timestamp found, make one:
$sql = "INSERT INTO ".$db->db_name.".forum_logging set userid=0, threadid=0, timestamp=0";
$db->do_query($sql);
echo mysql_error();
// No cleanup timestamp found, make one
//
BoincForumLogging::replace(0, 0, 0);
}
}
}