public static function CheckRegister($username, $pwd) { if (!$username) { System::AddError("用户名不得为空"); return false; } if (!$pwd) { System::AddError("密码不得为空"); return false; } if (strlen($pwd) < self::$minPWDLen) { System::AddError("密码长度太短,最小" . self::$minPWDLen); return false; } if (strlen($username) < self::$minUserNameLen) { System::AddError("用户名长度太短,最小" . self::$minUserNameLen); return false; } $condition = array('username' => $username); $dbObj = DB_Manage::createDBObj('user'); if ($dbObj->exsits($condition)) { System::AddError("用户名重复,请换个用户名"); return false; } return true; }
/** * 注册方法 */ public static function Register($username, $pwd) { if (!Validate_User::CheckRegister($username, $pwd)) { return false; } $dbUser = DB_Manage::createDBObj('user'); $user = array('username' => $username, 'password' => self::EncodePWD($pwd), 'register_ip' => Utility::getUserIP(), 'login_time' => time(), 'login_ip' => Utility::getUserIP()); $userID = $dbUser->create($user); if (!$userID) { System::AddError($dbUser->error); return false; } $user['id'] = $userID; self::SaveUser($user); return true; }
private static function dbObject() { $db = DB_Manage::createDBObj(self::$table_name); return $db; }
/** * 获取一条记录 * @return array|bool */ public function getRow() { $condition = $this->getCondition(); $option = array('one' => true); if ($this->order) { $option['order'] = $this->order; } if ($this->select) { $option['select'] = $this->select; } $dbWorkOrder = DB_Manage::createDBObj($this->table_name); $list = $dbWorkOrder->get($condition, $option); return $list; }