* 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 { /** * It appears we updated the account internally, so skip this account. */ if ($account->getUpdateTs() >= $last_update_ts) { continue; } /** * Another service updated this account, so refresh its information. */ $account->refresh(); }
* 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); }