$last_update_ts = $timer_data[0];
}
$last_update = db_date($last_update_ts);
/**
 * Check for new and updated account records since this timer last ran
 */
$res = db_query('select account_id, name, update_date ' . 'from accounts ' . "where create_date >= '{$last_update}' or update_date >= '{$last_update}'", false);
while ($row = mysql_fetch_assoc($res)) {
    $account = $this->getAccount($row['name']);
    if (!$account) {
        /**
         * We've never seen this account before, so load it into memory and associate
         * it with any users who are using it.
         */
        $account = new DB_User($row['account_id']);
        $account_key = strtolower($account->getName());
        $this->accounts[$account_key] = $account;
        /**
         * Make sure that we tie up any loose ends where we receive an AC account
         * message from another service before we know about the account. The account
         * name is stored for each user, so we just need to find any users with a set
         * account name but a missing account ID. If this is the matching account,
         * set the account ID accordingly so we will now know who they are.
         */
        foreach ($this->users as $numeric => $user) {
            if (!$user->isLoggedIn() && $user->hasAccountName() && strtolower($user->getAccountName()) == $account_key) {
                $user->setAccountId($account->getId());
                debug('Associated new account with user ' . $user->getNick());
            }
        }
    } else {
 function loadSingleAccount($name_or_id)
 {
     $name_or_id = addslashes($name_or_id);
     if (is_numeric($name_or_id)) {
         $criteria = "account_id = '{$name_or_id}'";
     } else {
         $criteria = "name = '{$name_or_id}'";
     }
     $res = db_query('select * from accounts where ' . $criteria);
     if ($row = mysql_fetch_assoc($res)) {
         $account_key = strtolower($row['name']);
         $account = new DB_User($row);
         $this->accounts[$account_key] = $account;
     }
     if (isset($account)) {
         debug("Loaded single account record for {$account->getName()}.");
     }
     return isset($account);
 }
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
$uid = $pargs[1];
if (!($acct = $this->getAccount($uid))) {
    $bot->noticef($user, '%s is not a valid account name.', $uid);
    return false;
}
$aid = $acct->getId();
$res = mysql_query("select * from accounts where id = '{$aid}'");
$row = @mysql_fetch_assoc($res);
$dbuser = new DB_User($aid);
$dbuser->loadFromRow($row);
$bot->noticef($user, '%d ?= %d', $dbuser->getId(), $aid);
if ($dbuser->getId() != $aid) {
    $ac_key = strtolower($uid);
    unset($this->accounts[$ac_key]);
    $bot->noticef($user, 'Removed account id %d from memory.', $aid);
} else {
    $ac_key = strtolower($dbuser->getName());
    $this->accounts[$ac_key] = $dbuser;
    $dbuser = $this->getAccount($uid);
    $bot->noticef($user, 'Updated account %s in memory. (%s)', $dbuser->getName(), $dbuser->password);
}