function updateTwitterFeed($lastupdate)
{
    // Twitter!
    global $preferences;
    global $twit;
    require_once 'oauth/twitteroauth.php';
    $twit = new TwitterOAuth($preferences->CONSUMER_KEY, $preferences->CONSUMER_SECRET_KEY, $preferences->OAUTH_TOKEN, $preferences->OAUTH_SECRET_TOKEN);
    // Update the following/followed balance
    updateTwitterFollowing();
    // Update user information for those who require it
    updateTwitterUsers();
    // Get mentions since the last update
    $args = array();
    $lastreadid = getPreference("last_twitter_id");
    if ($lastreadid) {
        $args['since_id'] = $lastreadid;
    }
    $tweets = $twit->get('statuses/mentions_timeline', $args);
    // if we have no tweets, stop here
    if (!is_array($tweets)) {
        loginfo("No tweets to read!");
        return false;
    }
    // process tweets individually
    uasort($tweets, 'cmpTweetId');
    foreach ($tweets as $tweet) {
        $lastreadid = processTweet($tweet);
    }
    // Save the last updated tweet id
    setPreference("last_twitter_id", $lastreadid);
    return true;
}
function getUpdateNames($count = 100)
{
    // where did we start off?
    $lastindex = getPreference("last_userupdate_index");
    // return those rows
    global $link;
    /* echo "SELECT UserName FROM Participants LIMIT ".$lastindex." ".$count ; */
    /* $namesresult = mysqli_query($link, "SELECT UserName FROM Participants  */
    /*     LIMIT ".$lastindex.", ".$count) */
    /*         or die(__FILE__.__LINE__.mysqli_error($link)); */
    // echo "SELECT UserName FROM Participants LIMIT ".$lastindex." ".$count . "\n" ;
    $namesresult = mysqli_query($link, "SELECT UserName FROM Participants \n        LIMIT " . $lastindex . ", " . $count) or die(__FILE__ . __LINE__ . mysqli_error($link));
    $namearray = array();
    while ($namerow = mysqli_fetch_assoc($namesresult)) {
        $namearray[] = $namerow['UserName'];
    }
    // how many rows, if we need to wrap
    $countresult = mysqli_query($link, "SELECT COUNT(*) FROM Participants") or die(__FILE__ . __LINE__ . mysqli_error($link));
    $totalcount = mysqli_fetch_array($countresult);
    $lastindex += $count;
    if ($lastindex >= $totalcount[0]) {
        $lastindex = 0;
    }
    // Save the last updated index (wrapping if necessary)
    setPreference("last_userupdate_index", $lastindex);
    return $namearray;
}