ph = new PasswordHash(8, FALSE); } public function createUser($email, $passwd) { $userArray = $this->getOne(array('where' => 'uemail=?', 'param' => array($email), 'asArray' => TRUE)); if (isset($userArray['uid'])) { return FALSE; } $this->uemail = $email; $this->upass = $this->ph->HashPassword($passwd); $this->sparepwd = $this->createRandomCode(6); $this->intime = time(); return $this->insert(); } public function getRowAll() { return $this->find(array('asArray' => TRUE)); } public function updateSparepwd($uid, $spwd){ $this->uid = $uid; $this->sparepwd = $spwd; return $this->update(); } /* * ************************************************************ * 生成指定长度的随机码。 * @param int $length 随机码的长度。 * @access public * ************************************************************ */ function createRandomCode($length) { $randomCode = ""; $randomChars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; for ($i = 0; $i < $length; $i++) { $randomCode .= $randomChars{mt_rand(0, 35)}; } return $randomCode; } } ?>