static function add($data) { if (!$data) { return false; } $model = new UserModel(); $result = $model->add($data); return $result; }
static function setLogin($userInfo) { if (!$userInfo) { return false; } $uid = $userInfo['uid']; $_SESSION['user'] = $userInfo; //$userInfo = PlatformBusiness::showUserInfo($uid); if ($userInfo) { //$userInfo = self::format($userInfo); $userInfo['token'] = $_SESSION['access_token']; $userInfo['expire'] = $_SESSION['token_expire']; return UserModel::add($userInfo); } return true; }
/** * 将创建的用户插入数据库 */ function insert() { //实例化对象并压入数据 $users = new UserModel(); if (!!($data = $users->create())) { if ($users->add() !== false) { $this->assign('jumpUrl', __URL__ . '/index'); $this->success('用户添加成功'); } else { $this->assign('jumpUrl', __URL__ . '/add'); $this->error('添加失败!!!' . $users->getDbError()); } } else { $this->assign('jumpUrl', __URL__ . '/add'); $this->error('添加失败!!!' . $users->getError()); } }
public function add() { if (isset($_POST['uname'])) { $data['uname'] = request('uname'); if (UserModel::get('', $data['uname'])) { $this->error('用户名重复'); } if (request('passwd') != request('passwd2')) { $this->error('两次输入的密码不一致'); } $data['passwd'] = mymd5(request('passwd')); $data['group_id'] = request('group_id'); $data['department_id'] = request('department_id'); $data['alias'] = request('alias'); $data['phone'] = request('phone'); if (UserModel::add($data)) { $this->success('/admin/user'); } else { $this->error('操作失败'); } } else { $this->display('user_edit'); } }
/** * 获取数据 * @param $channel */ private function retrieveData($channel = null) { $ret = array('channel' => $channel, 'time' => $this->timestamp); // Load config $config = new ConfigModel(); $ret['config'] = $config->getConfig($this->lang); unset($config); // Load levels $level = new LevelModel(); $levels = array(); foreach ($level->getAllLevels() as $level) { $levels[$level->level] = array('min' => $level->min_exp, 'max' => $level->max_exp); } $ret['config']->levels = (object) $levels; unset($level, $levels); // Load Store Data $store = new StoreModel($this->lang); $ret['config']->store = $store->getData(); unset($store); $ret['data'] = new stdClass(); $ret['data']->state = 'ok'; $ret['data']->call_id = isset($this->input->call_id) ? substr($this->input->call_id, 4) : microtime(); $ret['data']->data_hash = md5(rand(100, 10000)); Session::instance()->set('data_hash', $ret['data']->data_hash); $ret['data']->swf_version = isset($this->input->swf_version) ? $this->input->swf_version : 85; $ret['data']->map = array(); $ret['data']->storage = array(); $ret['data']->gifts = array(); $ret['data']->neighbors = array(); $ret['data']->all_neighbors = array(); // Check User wether inited. $user = new UserModel(); $userinfo = $user->getUserById($this->uid); if ($userinfo) { $diff_time = $this->timestamp - strtotime($userinfo->logintime); // 用户每天登陆的奖励 if ($diff_time > self::EVERY_DAY_LOGIN_DIFF_TIME) { // 更新用户的钱 $this->debugMsg("diff_time=" . $diff_time); $userinfo->lottery_coins = self::EVERY_DAY_LOGIN_IN_AWARD; $updateData = array('coins' => $userinfo->coins + self::EVERY_DAY_LOGIN_IN_AWARD, 'logintime' => date('Y-m-d H:i:s')); $user->updateUser($this->uid, $updateData); //更新用户的金币 } else { $updateData = array('logintime' => date('Y-m-d H:i:s')); $user->updateUser($this->uid, $updateData); //更新用户的logintime } // Load User Maps $ret['data']->map = $this->getUserMaps($this->uid); // Load User storage $storage = new StorageModel(); $ret['data']->storage = (object) $storage->getUserStoragesByUid($this->uid); unset($storage); // Load User Gifts $gift = new GiftsModel(); $gifts_list = $gift->getNewGiftByUidForRetrieve($this->uid); $gifts_list_re = array(); foreach ($gifts_list as $k => $v) { $gifts_list_re[$v->itemid] = $v->qty; } $this->debugMsg($gifts_list); $ret['data']->gifts = (object) $gifts_list_re; $this->debugMsg($gift->getLastQuery()); unset($gift); // Load User Neighbors $ret['data']->all_neighbors[] = $this->syncUserNeighbors($this->input->fids); $neighbor = new NeighborsModel(); $ret['data']->neighbors = $neighbor->getNeighborsByUid($this->uid); unset($neighbor); $ret['data']->show_tutorial = 1; //TODO $ret['data']->items = array(); $ret['data']->coins = $userinfo->coins; $ret['data']->level = $userinfo->level; $ret['data']->experience = $userinfo->experience; $ret['data']->size_x = $userinfo->size_x; $ret['data']->size_y = $userinfo->size_x; $ret['data']->reward_points = $userinfo->reward_points; $ret['data']->op = $userinfo->op; $ret['data']->top_map_size = $userinfo->top_map_size; $ret['data']->max_work_area_size = $userinfo->max_work_area_size; $ret['data']->work_area_size = $userinfo->work_area_size; $ret['data']->lottery_coins = $userinfo->lottery_coins; $ret['data']->feed_data = false; $ret['data']->news = false; $ret['data']->show_gifts_page = false; $ret['data']->stories = array(); $ret['data']->items_received = array(); $ret['data']->ask_for_materials = array(); $ret['data']->ask_for_help = array(); $ret['data']->friend_helped = false; $ret['data']->gifts_received = array(); } else { $data = array('uid' => $this->uid, 'email' => '', 'level' => 1, 'experience' => 0, 'coins' => self::INIT_COINS, 'op' => 0, 'reward_points' => self::INIT_RC, 'logintime' => date('Y-m-d H:i:s'), 'loginip' => '', 'status' => 1); $user->add($data); $ret['data']->show_tutorial = 0; //TODO $ret['data']->coins = self::INIT_COINS; $ret['data']->items = array(); $ret['data']->level = 1; $ret['data']->experience = 0; $ret['data']->size_x = 60; $ret['data']->size_y = 60; $ret['data']->reward_points = self::INIT_RC; $ret['data']->op = 0; $ret['data']->top_map_size = 0; $ret['data']->max_work_area_size = 1; $ret['data']->work_area_size = 1; $ret['data']->lottery_coins = 0; $ret['data']->feed_data = false; $ret['data']->news = false; $ret['data']->show_gifts_page = false; $ret['data']->stories = array(); $ret['data']->items_received = array(); $ret['data']->ask_for_materials = array(); $ret['data']->ask_for_help = array(); $ret['data']->friend_helped = false; $ret['data']->gifts_received = array(); $ret['data']->storage = (object) array(15 => '5', 16 => '5'); // 将平台好友导入为邻居 $ret['data']->all_neighbors[] = $this->syncUserNeighbors($this->input->fids, true); $neighbor = new NeighborsModel(); $ret['data']->neighbors = $neighbor->getNeighborsByUid($this->uid); unset($neighbor); // $mapData = $this->initUserMapData(); $ret['data']->map = $mapData; } unset($model); if ($this->debug) { $ret['demsg'] = $this->demsg; } return $ret; }
public function registerJson() { $user = new UserModel(); $returnto = Ajde::app()->getRequest()->getPostParam('returnto', false); $username = Ajde::app()->getRequest()->getPostParam($user->usernameField); $password = Ajde::app()->getRequest()->getPostParam('password'); $passwordCheck = Ajde::app()->getRequest()->getPostParam('passwordCheck'); $email = Ajde::app()->getRequest()->getPostParam('email', false); $fullname = Ajde::app()->getRequest()->getPostParam('fullname', false); $return = array(false); $shadowUser = new UserModel(); if (empty($username) || empty($password)) { $return = array('success' => false, 'message' => __("Please provide " . $user->usernameField . " and password")); } else { if ($shadowUser->loadByField($shadowUser->usernameField, $username)) { $return = array('success' => false, 'message' => __(ucfirst($user->usernameField) . " already exist")); } else { if ($password !== $passwordCheck) { $return = array('success' => false, 'message' => __("Passwords do not match")); } else { if (empty($email)) { $return = array('success' => false, 'message' => __("Please provide an e-mail address")); } else { if (Ajde_Component_String::validEmail($email) === false) { $return = array('success' => false, 'message' => __('Please provide a valid e-mail address')); } else { if ($shadowUser->loadByField('email', $email)) { $return = array('success' => false, 'message' => __("A user with this e-mail address already exist")); } else { if (empty($fullname)) { $return = array('success' => false, 'message' => __("Please provide a full name")); } else { $user->set('email', $email); $user->set('fullname', $fullname); if ($user->add($username, $password)) { $user->login(); Ajde_Session_Flash::alert(sprintf(__('Welcome %s, you are now logged in.'), $fullname)); $return = array('success' => true, 'returnto' => $returnto); } else { $return = array('success' => false, 'message' => __("Something went wrong")); } } } } } } } } return $return; }
public function insert() { if (!IS_POST) { $this->message2('非法操作!', __APP__ . '/Admin'); } $User = new UserModel(); $money = I('money', 0); if ($data = $User->create()) { $newuserid = $User->add(); if (false !== $newuserid) { if (0 < $money) { $account_log['user_id'] = $newuserid; $account_log['stage'] = 'admin'; $account_log['money'] = $money; $account_log['comm'] = '新增用户注入金额'; $account_log['addtime'] = $this->getDate(); $account_log['remain_money'] = $money; if (false !== D('account_log')->data($account_log)->add()) { $this->message('添加用户操作成功', __URL__ . '/index'); } else { $this->message('添加用户操作失败', __URL__ . '/index'); } } $this->message('添加用户操作成功', __URL__ . '/index'); } } else { $this->message('添加用户失败:' . $User->getError(), __URL__ . '/add'); } }
public function adding() { $data['username'] = $this->_post('username'); $data['yourname'] = $this->_post('yourname'); $data['password'] = md5($this->_post('password')); $data['status'] = $this->_post('status'); $user = new UserModel('user'); if (!$user->create()) { // 如果创建失败 表示验证没有通过 输出错误提示信息 $this->error($user->getError()); } else { $list = $user->add($data); $id['role_id'] = $this->_post('role_id'); $id['user_id'] = $list; $role = M('roleUser')->add($id); $shiyong = M('shiyong'); $data_id['pid'] = $list; $data_id['tsj'] = '143'; $data_id['xsq'] = '136'; $slist = $shiyong->add($data_id); $testuser = M('testuser'); $test['pid'] = $list; $testlist = $testuser->add($test); if ($list and $role and $slist and $testlist) { $this->success('注册成功!', U('User/index')); } else { $this->error('注册失败!'); } } /* if($data['username']!='' and $data['yourname']!=''){ if($pwd==$pwds and $pwd!='' and $pwds!=''){ $user = M('user'); $data['password'] = md5($pwds); $list=$user->data($data)->add(); if($list){ $this->success('添加成功','index'); }else{ $this->error('添加失败,清理联系管理员!'); } }else{ $this->error('密码有误!!!'); } }else{ $this->error('员工账号和用户姓名不能为空!!!'); } */ }
public function registerJson() { $user = new UserModel(); $returnto = Ajde::app()->getRequest()->getPostParam('returnto', false); $username = Ajde::app()->getRequest()->getPostParam($user->usernameField); $password = Ajde::app()->getRequest()->getPostParam('password', ''); $passwordCheck = Ajde::app()->getRequest()->getPostParam('passwordCheck', ''); $providername = Ajde::app()->getRequest()->getPostParam('provider', false); $email = Ajde::app()->getRequest()->getPostParam('email', false); $fullname = Ajde::app()->getRequest()->getPostParam('fullname', false); $return = [false]; $shadowUser = new UserModel(); $provider = false; if ($providername) { $sso = config('user.sso.providers'); if (!in_array($providername, $sso)) { Ajde_Http_Response::redirectNotFound(); } $classname = 'Ajde_User_Sso_' . ucfirst($providername); /* @var $provider Ajde_User_SSO_Interface */ $provider = new $classname(); } if (empty($username)) { $return = ['success' => false, 'message' => trans('Please provide a ' . $user->usernameField . '')]; } else { if (!$provider && empty($password)) { $return = ['success' => false, 'message' => trans('Please provide a password')]; } else { if ($shadowUser->loadByField($shadowUser->usernameField, $username)) { $return = ['success' => false, 'message' => trans(ucfirst($user->usernameField) . ' already exist')]; } else { if (!$provider && $password !== $passwordCheck) { $return = ['success' => false, 'message' => trans('Passwords do not match')]; } else { if (empty($email)) { $return = ['success' => false, 'message' => trans('Please provide an e-mail address')]; } else { if (Ajde_Component_String::validEmail($email) === false) { $return = ['success' => false, 'message' => trans('Please provide a valid e-mail address')]; } else { if ($shadowUser->loadByField('email', $email)) { $return = ['success' => false, 'message' => trans('A user with this e-mail address already exist')]; } else { if (empty($fullname)) { $return = ['success' => false, 'message' => trans('Please provide a full name')]; } else { if ($provider && !$provider->getData()) { $return = ['success' => false, 'message' => trans('Something went wrong with fetching your credentials from an external service')]; } else { $user->set('email', $email); $user->set('fullname', $fullname); if ($user->add($username, $password)) { if ($provider) { $sso = new SsoModel(); $sso->populate(['user' => $user->getPK(), 'provider' => $providername, 'username' => $provider->getUsernameSuggestion(), 'avatar' => $provider->getAvatarSuggestion(), 'profile' => $provider->getProfileSuggestion(), 'uid' => $provider->getUidHash(), 'data' => serialize($provider->getData())]); $sso->insert(); $user->copyAvatarFromSso($sso); } $user->login(); $user->storeCookie($this->includeDomain); Ajde_Session_Flash::alert(sprintf(trans('Welcome %s, you are now logged in'), $fullname)); $return = ['success' => true, 'returnto' => $returnto]; } else { $return = ['success' => false, 'message' => trans('Something went wrong')]; } } } } } } } } } } return $return; }