function fetchLogs($username)
 {
     global $wgOut, $wgSharedDB, $wgDBname, $wgRequest, $wgLang;
     /* from database */
     list($limit, $offset) = $wgRequest->getLimitOffset();
     $dbr =& wfGetDB(DB_SLAVE);
     $query = "SELECT stats_user, stats_blocker, stats_timestamp, stats_ip \n\t\t\t  FROM " . wfRegexBlockGetStatsTable() . " \n\t\t\t  WHERE stats_user={$dbr->addQuotes($username)} \n\t\t\t  ORDER BY stats_timestamp DESC LIMIT {$offset},{$limit}";
     $res = $dbr->query($query);
     while ($row = $dbr->fetchObject($res)) {
         $time = $wgLang->timeanddate(wfTimestamp(TS_MW, $row->stats_timestamp), true);
         $wgOut->addHTML("<li><b>{$row->stats_user}</b> " . wfMsg('regexblock-stats-times') . " <b>{$time}</b>, " . wfMsg('regexblock-stats-logging') . " <b>{$row->stats_ip}</b></li>");
     }
     $dbr->freeResult($res);
 }
function wfRegexBlockUpdateStats($username, $user_ip, $blocker)
{
    global $wgSharedDB;
    $dbw =& wfGetDB(DB_MASTER);
    $now = wfTimestampNow();
    $query = "INSERT INTO " . wfRegexBlockGetStatsTable() . " \n\t\t  (stats_id, stats_user, stats_ip, stats_blocker, stats_timestamp) \n\t\t   values (null, {$dbw->addQuotes($username)}, '{$user_ip}',{$dbw->addQuotes($blocker)},'{$now}')";
    $res = $dbw->query($query);
    if ($dbw->affectedRows()) {
        return true;
    }
    return false;
}