Пример #1
0
     return false;
 }
 if ($account = $this->getAccountByEmail($email)) {
     $bot->notice($user, "That e-mail address is already associated " . "with a registered nickname.");
     return false;
 }
 if ($account = $this->getAccount($user_name)) {
     $bot->noticef($user, "The nickname %s%s%s has already been registered. Please choose another.", BOLD_START, $user_name, BOLD_END);
     return false;
 }
 if ($this->isBadnick($user_name)) {
     $bot->noticef($user, 'You are not allowed to register that nickname.');
     return false;
 }
 $password_md5 = md5($password);
 $account = new DB_User();
 $account->setName($user->getNick());
 $account->setRegisterTs(time());
 $account->setPassword($password_md5);
 $account->setEmail($email);
 $account->setAutoOp(true);
 $account->setAutoVoice(true);
 $account->updateLastseen();
 $account->save();
 $this->addAccount($account);
 if (!$user->hasAccountName()) {
     $this->sendf(FMT_ACCOUNT, SERVER_NUM, $numeric, $user_name, $account->getRegisterTs());
     $user->setAccountName($user_name);
     $user->setAccountId($account->getId());
 }
 $bot->noticef($user, "Your account, %s%s%s, has been registered. You are now logged in.", BOLD_START, $user_name, BOLD_END);
Пример #2
0
 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);
 }
Пример #3
0
 function _check_installation()
 {
     $errors = array();
     do {
         if (!is_writable($this->data_dir)) {
             $errors[] = "Data directory not writeable ({$this->data_dir})";
             break;
         }
         if (!is_dir($this->data_dir . '/.git')) {
             // no git install, try to fix
             if (!file_exists($this->data_dir . '/.gitignore')) {
                 // pop a git ignore file in to ignore the sql db
                 file_put_contents($this->data_dir . '/.gitignore', ".DS_Store\n*.db\n");
             }
             if ($this->git->init()) {
                 exec('chmod -R 0777 ' . $this->data_dir);
                 $this->git->add_all_commit('adding existing pages');
             } else {
                 $errors[] = "Could not initialize git repository ({$this->data_dir}/.git)";
             }
         }
         if (!file_exists($this->data_dir . '/.sqlite.db')) {
             // no sql db
             if (!copy(ROOT . '/giiki/virgin.db', $this->data_dir . '/.sqlite.db')) {
                 $errors[] = "Could not copy SQLite database ({$this->data_dir}/.sqlite.db)";
             } else {
                 Fu_Reg::set('dbh', new PDO($this->dsn));
                 $dbo = new DB_User();
                 $admin_user = $dbo->find(1);
                 $admin_user->rand_token();
                 $admin_user->save();
             }
         }
     } while (0);
     if ($errors) {
         echo implode('<br />', $errors);
         exit;
     }
 }
if (!empty($timer_data)) {
    $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());
            }
        }
 * 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);
}