• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP getFirstLetter函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中getFirstLetter函数的典型用法代码示例。如果您正苦于以下问题:PHP getFirstLetter函数的具体用法?PHP getFirstLetter怎么用?PHP getFirstLetter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getFirstLetter函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: sortTags

function sortTags($tags)
{
    //分类数组
    $sort = array('A' => array(), 'B' => array(), 'C' => array(), 'D' => array(), 'E' => array(), 'F' => array(), 'G' => array(), 'H' => array(), 'I' => array(), 'J' => array(), 'K' => array(), 'L' => array(), 'M' => array(), 'N' => array(), 'O' => array(), 'P' => array(), 'Q' => array(), 'R' => array(), 'S' => array(), 'T' => array(), 'U' => array(), 'V' => array(), 'W' => array(), 'X' => array(), 'Y' => array(), 'Z' => array());
    //分类
    for ($i = 0; $i < count($tags); ++$i) {
        array_push($sort[getFirstLetter($tags[$i]['name'])], $tags[$i]);
    }
    return $sort;
}
开发者ID:dalinhuang,项目名称:HCI-MSGsystem,代码行数:10,代码来源:tagsShow.php


示例2: syncTags

 public function syncTags(Article $article, $tags = array(), $isNew = false)
 {
     $tagall = Tag::all()->toArray();
     $newTagIds = $updateTagIds = $existingSlug = $existingTag = [];
     if (!empty($tagall)) {
         foreach ($tagall as $tag) {
             $existingSlug[] = $tag['slug'];
             $existingTag[$tag['slug']] = $tag;
         }
     }
     unset($tagall);
     if ($tags) {
         foreach ($tags as $tag) {
             if (!in_array(mb_strtolower($tag, 'UTF-8'), $existingSlug)) {
                 $name = filter_allowed_words($tag);
                 $slug = preg_replace('/\\s+/', '-', mb_strtolower($name, 'UTF-8'));
                 if (in_array($slug, $existingSlug)) {
                     if ($isNew) {
                         Tag::whereSlug($slug)->increment('count');
                     }
                     $updateTagIds[] = $existingTag[$slug]['id'];
                 } else {
                     $firstLetter = getFirstLetter($name);
                     $newtag = Tag::create(array('name' => $name, 'slug' => $slug, 'letter' => $firstLetter));
                     $newId = $newtag->id;
                     $newTagIds[] = $newId;
                     $updateTagIds[] = $newId;
                 }
             } else {
                 if ($isNew) {
                     Tag::whereSlug($tag)->increment('count');
                 }
                 $updateTagIds[] = $existingTag[$tag]['id'];
             }
         }
     }
     $updateTagIds = array_unique($updateTagIds);
     if (!$isNew) {
         $oldTagIds = $article->tags->lists('id')->toArray();
         $delTagIds = array_diff($oldTagIds, $updateTagIds);
         $addTagIds = array_diff($updateTagIds, $oldTagIds);
         if (!empty($delTagIds)) {
             Tag::whereIn('id', $delTagIds)->decrement('count');
         }
         if (!empty($addTagIds)) {
             foreach ($addTagIds as $addId) {
                 if (!in_array($addId, $newTagIds)) {
                     Tag::whereId($addId)->increment('count');
                 }
             }
         }
     }
     $article->tags()->sync($updateTagIds);
     unset($newTagIds, $updateTagIds, $existingSlug, $existingTag);
 }
开发者ID:misterebs,项目名称:cmsku,代码行数:55,代码来源:ArticleRepository.php


示例3: signUp2Email


//.........这里部分代码省略.........
      * 用户密码
      * @var string
      */
     $userData['password'] = model('User')->encryptPassword($password, $userData['login_salt']);
     /*
      * 用户注册时间
      * @var int
      */
     $userData['ctime'] = time();
     /*
      * 是否通过审核
      * @var int
      */
     $userData['is_audit'] = 1;
     /*
      * 是否激活
      * @var int
      */
     $userData['is_active'] = 1;
     /*
      * 是否初始化
      * @var int
      */
     $userData['is_init'] = 1;
     /*
      * 注册IP
      * @var string
      */
     $userData['reg_ip'] = get_client_ip();
     /*
      * 用户名首字母
      * @var string
      */
     $userData['first_letter'] = getFirstLetter($username);
     /*
      * 用户搜索字段
      * @var sring
      */
     $userData['search_key'] = $username;
     preg_match('/[\\x7f-\\xff]+/', $username) and $userData['search_key'] .= model('PinYin')->Pinyin($username);
     /*
      * 用户性别
      * @var int
      */
     $userData['sex'] = $sex;
     /*
      * 添加用户到数据库
      */
     if ($uid = model('User')->add($userData)) {
         unset($userData);
         /*
          * 注册配置信息
          * @var array
          */
         $registerConfig = model('Xdata')->get('admin_Config:register');
         /*
          * 默认用户组
          * @var int|array
          */
         $defaultUserGroup = empty($registerConfig['default_user_group']) ? C('DEFAULT_GROUP_ID') : $registerConfig['default_user_group'];
         $defaultUserGroup = is_array($defaultUserGroup) ? implode(',', $defaultUserGroup) : $defaultUserGroup;
         /*
          * 将用户移动到用户组
          */
         model('UserGroupLink')->domoveUsergroup($uid, $defaultUserGroup);
         unset($defaultUserGroup);
开发者ID:medz,项目名称:thinksns-4,代码行数:67,代码来源:OauthApi.class.php


示例4: ologinPrefect

 /**
  * 完善第三方登录用户信息
  * @return [type] [description]
  */
 public function ologinPrefect()
 {
     $post = I('post.');
     // 验证手机号
     $mobile = I('post.mobile');
     if (strlen($mobile) != 11) {
         $this->return['code'] = 1001;
         $this->return['message'] = L('mobile_error');
         $this->goJson($this->return);
     }
     if ($this->checkMobile($mobile)) {
         $this->return['code'] = 1002;
         $this->return['message'] = L('mobile_has');
         $this->goJson($this->return);
     }
     // 验证昵称
     if (!$post['uname']) {
         $this->return['code'] = 1003;
         $this->return['message'] = L('uname_null');
         $this->goJson($this->return);
     }
     // 验证性别
     if ($post['sex'] != 1 && $post['sex'] != 2) {
         $this->return['code'] = 1004;
         $this->return['message'] = L('sex_error');
         $this->goJson($this->return);
     }
     load("@.user");
     $post['first_letter'] = getFirstLetter($post['uname']);
     //如果包含中文将中文翻译成拼音
     if (preg_match('/[\\x7f-\\xff]+/', $post['uname'])) {
         import("Common.Util.PinYin");
         $pinyinClass = new \PinYin();
         $pinyin = $pinyinClass->Pinyin($post['uname']);
         //昵称和呢称拼音保存到搜索字段
         $post['search_key'] = $post['uname'] . ' ' . $pinyin;
     } else {
         $post['search_key'] = $post['uname'];
     }
     // 密码
     if (!$post['password']) {
         $this->return['code'] = 1004;
         $this->return['message'] = L('pwd_null');
         $this->goJson($this->return);
     }
     $post['login_salt'] = rand(11111, 99999);
     $post['password'] = md5(md5($post['password']) . $post['login_salt']);
     $post['ctime'] = time();
     $post['level'] = $post['self_level'];
     $post['cur_language'] = $post['lid'];
     D('userinfo')->where('uid=' . $this->mid)->save($post);
     $language_info['uid'] = $this->mid;
     $language_info['lid'] = $post['lid'];
     $language_info['type'] = 4;
     $language_info['self_level'] = $post['self_level'];
     D('userLanguage')->add($language_info);
     $this->redis->Sadd('User:sex' . $post['sex'], $this->mid);
     $this->redis->SADD('Userinfo:online', $this->mid);
     //在线用户列表
     $this->createSubAccount('yujia' . $this->mid, $this->mid);
     $res = D('userinfo')->getUserInfo($this->mid);
     $this->redis->HMSET('Userinfo:uid' . $this->mid, $res);
     $res['token'] = I('post.token');
     $tmp['headimg'] = json_decode($this->redis->HGET('Userinfo:uid' . $this->mid, 'headimg'), true);
     $tmp['headimg'] = $tmp['headimg'][0]['url'];
     $return = array('uid' => $this->mid, 'token' => $res['token'], 'voipaccount' => $res['voipaccount'], 'voippwd' => $res['voippwd'], 'subaccountid' => $res['subaccountid'], 'subtoken' => $res['subtoken'], 'uname' => $res['uname'], 'mobile' => $res['mobile'], 'sex' => $res['sex'], 'headimg' => $tmp['headimg']);
     $this->return['data'] = $return;
     $this->goJson($this->return);
 }
开发者ID:a349944418,项目名称:yuban,代码行数:73,代码来源:RegController.class.php


示例5: insertTsUser

 /**
  * 插入Ts2.8用户信息
  * @return void
  */
 public function insertTsUser()
 {
     set_time_limit(0);
     // 获取插入用户数据
     $data = D('old_user')->field('email, password, sex, uname')->findAll();
     foreach ($data as $value) {
         $user['uname'] = $value['uname'];
         $salt = rand(11111, 99999);
         $user['login_salt'] = $salt;
         $user['login'] = $value['email'];
         $user['email'] = $value['email'];
         $user['password'] = md5($value['password'] . $salt);
         $user['ctime'] = time();
         $user['first_letter'] = getFirstLetter($value['uname']);
         $user['sex'] = $value['sex'] == 0 ? 1 : 2;
         $user['is_audit'] = 1;
         $user['is_active'] = 1;
         // 添加用户
         $result = model('User')->add($user);
         // 添加用户组
         model('UserGroupLink')->domoveUsergroup($result, 3);
     }
 }
开发者ID:omusico,项目名称:ThinkSNS-4,代码行数:27,代码来源:TestAction.class.php


示例6: doStep1

 /**
  * 注册流程 - 执行第一步骤
  * @return void
  */
 public function doStep1()
 {
     $regType = t($_POST['regType']);
     if (!in_array($regType, array('email', 'phone'))) {
         $this->error('注册参数错误');
     }
     $invite = t($_POST['invate']);
     $inviteCode = t($_POST['invate_key']);
     $email = t($_POST['email']);
     $phone = t($_POST['phone']);
     $regCode = t($_POST['regCode']);
     $uname = t($_POST['uname']);
     $sex = 1 == $_POST['sex'] ? 1 : 2;
     $password = trim($_POST['password']);
     $repassword = trim($_POST['repassword']);
     if (!$this->_register_model->isValidPassword($password, $repassword)) {
         $this->error($this->_register_model->getLastError());
     }
     if ($regType === 'email') {
         //检查验证码
         if (md5(strtoupper($_POST['verify'])) != $_SESSION['verify'] && false) {
             //已关闭
             $this->error('验证码错误');
         }
         if (!$this->_register_model->isValidName($uname)) {
             $this->error($this->_register_model->getLastError());
         }
         if (!$this->_register_model->isValidEmail($email)) {
             $this->error($this->_register_model->getLastError());
         }
     } elseif ($regType === 'phone') {
         if (!model('Captcha')->checkRegisterCode($phone, $regCode)) {
             //已关闭
             $this->error('验证码错误,请检查验证码');
         }
         if (!$this->_register_model->isValidPhone($phone)) {
             $this->error($this->_register_model->getLastError());
         }
         if (!$this->_register_model->isValidName($uname)) {
             $this->error($this->_register_model->getLastError());
         }
         $this->_config['register_audit'] = 0;
         $this->_config['need_active'] = 0;
     }
     // $this->error($phone);
     $login_salt = rand(11111, 99999);
     $map['uname'] = $uname;
     $map['sex'] = $sex;
     $map['login_salt'] = $login_salt;
     $map['password'] = md5(md5($password) . $login_salt);
     if ($regType === 'email') {
         // $map['login'] = $map['email'] = $email;
         $map['email'] = $email;
         $login = $email;
     } elseif ($regType === 'phone') {
         // $map['login'] = $phone;
         $map['phone'] = $phone;
         $login = $phone;
     } else {
         $login = $uname;
     }
     $map['reg_ip'] = get_client_ip();
     $map['ctime'] = time();
     // $this->error(json_encode($map));
     // 添加地区信息
     /*		$map['location'] = t($_POST['city_names']);
     		$cityIds = t($_POST['city_ids']);
     		$cityIds = explode(',', $cityIds);
     		isset($cityIds[0]) && $map['province'] = intval($cityIds[0]);
     		isset($cityIds[1]) && $map['city'] = intval($cityIds[1]);
     		isset($cityIds[2]) && $map['area'] = intval($cityIds[2]);*/
     // 审核状态: 0-需要审核;1-通过审核
     $map['is_audit'] = $this->_config['register_audit'] ? 0 : 1;
     // 需求添加 - 若后台没有填写邮件配置,将直接过滤掉激活操作
     $isActive = $this->_config['need_active'] ? 0 : 1;
     if ($isActive == 0) {
         $emailConf = model('Xdata')->get('admin_Config:email');
         if (empty($emailConf['email_host']) || empty($emailConf['email_account']) || empty($emailConf['email_password'])) {
             $isActive = 1;
         }
     }
     $map['is_active'] = $isActive;
     $map['first_letter'] = getFirstLetter($uname);
     //如果包含中文将中文翻译成拼音
     if (preg_match('/[\\x7f-\\xff]+/', $map['uname'])) {
         //昵称和呢称拼音保存到搜索字段
         $map['search_key'] = $map['uname'] . ' ' . model('PinYin')->Pinyin($map['uname']);
     } else {
         $map['search_key'] = $map['uname'];
     }
     $uid = $this->_user_model->add($map);
     if ($uid) {
         // 添加积分
         model('Credit')->setUserCredit($uid, 'init_default');
         // 如果是邀请注册,则邀请码失效
         if ($invite) {
//.........这里部分代码省略.........
开发者ID:jianminglok,项目名称:thinksnsv4,代码行数:101,代码来源:RegisterAction.class.php


示例7: doStep1

 /**
  * 注册流程 - 执行第一步骤
  * @return void
  */
 public function doStep1()
 {
     $invite = t($_POST['invate']);
     $inviteCode = t($_POST['invate_key']);
     $email = t($_POST['Reg_email']);
     $uname = t($_POST['Reg_name']);
     $utype = t($_POST['Reg_capacity']);
     $password = trim($_POST['Reg_pwd']);
     // $repassword = trim($_POST['repassword']);
     if (!$this->_register_model->isValidName($uname)) {
         $this->error($this->_register_model->getLastError());
     }
     //检查验证码
     /*
     if (md5(strtoupper($_POST['verify'])) != $_SESSION['verify']) {
     	$this->error('验证码错误');
     }		
     
     if(!$this->_register_model->isValidPassword($password, $repassword)){
     	$this->error($this->_register_model->getLastError());
     }
     
     // if (!$_POST['accept_service']) {
     // 	$this->error(L('PUBLIC_ACCEPT_SERVICE_TERMS'));
     // }
     */
     //验证邮箱唯一性
     if (!$this->_register_model->isValidEmail($email)) {
         $this->error($this->_register_model->getLastError());
     }
     $login_salt = rand(11111, 99999);
     $map['uname'] = $uname;
     $map['utype'] = $utype;
     $map['login_salt'] = $login_salt;
     $map['password'] = md5(md5($password) . $login_salt);
     $map['login'] = $map['email'] = $email;
     $map['reg_ip'] = get_client_ip();
     $map['ctime'] = time();
     /*
     		// 添加地区信息  暂不需要
     		$map['location'] = t($_POST['city_names']);
     		$cityIds = t($_POST['city_ids']);
     		$cityIds = explode(',', $cityIds);
     		isset($cityIds[0]) && $map['province'] = intval($cityIds[0]);
     		isset($cityIds[1]) && $map['city'] = intval($cityIds[1]);
     		isset($cityIds[2]) && $map['area'] = intval($cityIds[2]);
     */
     // 审核状态: 0-需要审核;1-通过审核
     $map['is_audit'] = $this->_config['register_audit'] ? 0 : 1;
     // 需求添加 - 若后台没有填写邮件配置,将直接过滤掉激活操作
     $isActive = $this->_config['need_active'] ? 0 : 1;
     if ($isActive == 0) {
         $emailConf = model('Xdata')->get('admin_Config:email');
         if (empty($emailConf['email_host']) || empty($emailConf['email_account']) || empty($emailConf['email_password'])) {
             $isActive = 1;
         }
     }
     $map['is_active'] = $isActive;
     $map['first_letter'] = getFirstLetter($uname);
     //如果包含中文将中文翻译成拼音
     if (preg_match('/[\\x7f-\\xff]+/', $map['uname'])) {
         //昵称和呢称拼音保存到搜索字段
         $map['PY'] = model('PinYin')->Pinyin($map['uname']);
         $map['search_key'] = $map['uname'] . ' ' . $map['PY'];
     } else {
         $map['PY'] = $map['search_key'] = $map['uname'];
     }
     $count_PY = $this->_user_model->where('PY="' . $map[PY] . '"')->count();
     if ($count_PY) {
         $map['domain'] = $map['PY'] . '-' . $count_PY;
     } else {
         $map['domain'] = $map['PY'];
     }
     $uid = $this->_user_model->add($map);
     if ($uid) {
         // 添加积分
         model('Credit')->setUserCredit($uid, 'init_default');
         // 如果是邀请注册,则邀请码失效
         if ($invite) {
             $receiverInfo = model('User')->getUserInfo($uid);
             // 验证码使用
             model('Invite')->setInviteCodeUsed($inviteCode, $receiverInfo);
             // 添加用户邀请码字段
             model('User')->where('uid=' . $uid)->setField('invite_code', $inviteCode);
             //给邀请人奖励
         }
         // 添加至默认的用户组
         $userGroup = model('Xdata')->get('admin_Config:register');
         $userGroup = empty($userGroup['default_user_group']) ? C('DEFAULT_GROUP_ID') : $userGroup['default_user_group'];
         model('UserGroupLink')->domoveUsergroup($uid, implode(',', $userGroup));
         //注册来源-第三方帐号绑定
         if (isset($_POST['other_type'])) {
             $other['type'] = t($_POST['other_type']);
             $other['type_uid'] = t($_POST['other_uid']);
             $other['oauth_token'] = t($_POST['oauth_token']);
             $other['oauth_token_secret'] = t($_POST['oauth_token_secret']);
//.........这里部分代码省略.........
开发者ID:a349944418,项目名称:kaopu,代码行数:101,代码来源:RegisterAction.class.php


示例8: formatByFirstLetter

 public function formatByFirstLetter($list)
 {
     $peoplelist = array('#' => array(), 'A' => array(), 'B' => array(), 'C' => array(), 'D' => array(), 'E' => array(), 'F' => array(), 'G' => array(), 'H' => array(), 'I' => array(), 'J' => array(), 'K' => array(), 'L' => array(), 'M' => array(), 'N' => array(), 'O' => array(), 'P' => array(), 'Q' => array(), 'R' => array(), 'S' => array(), 'T' => array(), 'U' => array(), 'V' => array(), 'W' => array(), 'X' => array(), 'Y' => array(), 'Z' => array());
     foreach ($list as $k => $v) {
         $first_letter = getFirstLetter($v['uname']);
         switch ($first_letter) {
             case '#':
                 $peoplelist['#'][] = $list[$k];
                 break;
             case 'A':
                 $peoplelist['A'][] = $list[$k];
                 break;
             case 'B':
                 $peoplelist['B'][] = $list[$k];
                 break;
             case 'C':
                 $peoplelist['C'][] = $list[$k];
                 break;
             case 'D':
                 $peoplelist['D'][] = $list[$k];
                 break;
             case 'E':
                 $peoplelist['E'][] = $list[$k];
                 break;
             case 'F':
                 $peoplelist['F'][] = $list[$k];
                 break;
             case 'G':
                 $peoplelist['G'][] = $list[$k];
                 break;
             case 'H':
                 $peoplelist['H'][] = $list[$k];
                 break;
             case 'I':
                 $peoplelist['I'][] = $list[$k];
                 break;
             case 'J':
                 $peoplelist['J'][] = $list[$k];
                 break;
             case 'K':
                 $peoplelist['K'][] = $list[$k];
                 break;
             case 'L':
                 $peoplelist['L'][] = $list[$k];
                 break;
             case 'M':
                 $peoplelist['M'][] = $list[$k];
                 break;
             case 'N':
                 $peoplelist['N'][] = $list[$k];
                 break;
             case 'O':
                 $peoplelist['O'][] = $list[$k];
                 break;
             case 'P':
                 $peoplelist['P'][] = $list[$k];
                 break;
             case 'Q':
                 $peoplelist['Q'][] = $list[$k];
                 break;
             case 'R':
                 $peoplelist['R'][] = $list[$k];
                 break;
             case 'S':
                 $peoplelist['S'][] = $list[$k];
                 break;
             case 'T':
                 $peoplelist['T'][] = $list[$k];
                 break;
             case 'U':
                 $peoplelist['U'][] = $list[$k];
                 break;
             case 'V':
                 $peoplelist['V'][] = $list[$k];
                 break;
             case 'W':
                 $peoplelist['W'][] = $list[$k];
                 break;
             case 'X':
                 $peoplelist['X'][] = $list[$k];
                 break;
             case 'Y':
                 $peoplelist['Y'][] = $list[$k];
                 break;
             case 'Z':
                 $peoplelist['Z'][] = $list[$k];
                 break;
         }
         unset($first_letter);
     }
     foreach ($peoplelist as $k => $v) {
         if (count($v) < 1) {
             unset($peoplelist[$k]);
         }
     }
     return $peoplelist;
 }
开发者ID:boxshadow,项目名称:ThinkSNS-4,代码行数:97,代码来源:UserApi.class.php


示例9: addUser

 /**
  * 添加用户
  *
  * @param array $user
  *        	新用户的相关信息|新用户对象
  * @return boolean 是否添加成功
  */
 public function addUser(array $user)
 {
     // # 判断用户名是否被注册
     if ($user['uname'] and !$this->isChangeUserName($user['uname'])) {
         $this->error = '用户昵称已存在,请使用其他昵称';
         return false;
         // # 判断手机号码是否被注册
     } elseif ($user['phone'] and !$this->isChangePhone($user['phone'])) {
         $this->error = '该手机号已经存在,请更换';
         return false;
         // # 判断邮箱是否被注册
     } elseif ($user['email'] and !$this->isChangeEmail($user['email'])) {
         $this->error = '该邮箱已经被注册,请更换';
         return false;
     }
     $user['login_salt'] = rand(10000, 99999);
     // # 用户盐值
     $user['ctime'] = time();
     // # 注册时间
     $user['reg_ip'] = get_client_ip();
     // # 用户客户端注册IP
     $user['password'] = $this->encryptPassword($user['password'], $user['login_salt']);
     $user['first_letter'] = getFirstLetter($user['uname']);
     $user['search_key'] = $user['uname'];
     preg_match('/[\\x7f-\\xff]/', $user['uname']) and $user['search_key'] .= '  ' . model('PinYin')->Pinyin($user['uname']);
     if ($uid = $this->add($user)) {
         // # 添加部门信息
         model('Department')->updateUserDepartById($uid, intval($_POST['department_id']));
         // # 添加用户组关联信息
         empty($_POST['user_group']) or model('UserGroupLink')->domoveUsergroup($uid, implode(',', $_POST['user_group']));
         // # 添加用户职业关联信息
         empty($_POST['user_category']) or model('UserCategory')->updateRelateUser($uid, $_POST['user_category']);
         return true;
     }
     $this->error = L('PUBLIC_ADD_USER_FAIL');
     return false;
     // // 验证用户名称是否重复
     // $map ['uname'] = t ( $user ['uname'] );
     // $map ['login'] = t ( $user ['login'] );
     // $isExist = $this->where ( $map )->count ();
     // if ($isExist > 0) {
     // 	$this->error = '用户昵称已存在,请使用其他昵称';
     // 	return false;
     // }
     // if (is_object ( $user )) {  // # 操,前面都按照数组操作了,这里来判断是不是对象,写这个方法的程序员是傻逼?
     // 	$salt = rand ( 11111, 99999 );
     // 	$user->login_salt = $salt;
     // 	$user->login = ! empty ( $map ['login'] ) ? $map ['login'] : $user->email;
     // 	$user->ctime = time ();
     // 	$user->reg_ip = get_client_ip ();
     // 	$user->password = $this->encryptPassword ( $user->password, $salt );
     // } else if (is_array ( $user )) {
     // 	$salt = rand ( 11111, 99999 );
     // 	$user ['login_salt'] = $salt;
     // 	$user ['login'] = ! empty ( $user ['login'] ) ? $user ['login'] : $user ['email'];
     // 	$user ['ctime'] = time ();
     // 	$user ['reg_ip'] = get_client_ip ();
     // 	$user ['password'] = $this->encryptPassword ( $user ['password'], $salt );
     // }
     // // 添加昵称拼音索引
     // $user ['first_letter'] = getFirstLetter ( $user ['uname'] );
     // // 如果包含中文将中文翻译成拼音
     // if (preg_match ( '/[\x7f-\xff]+/', $user ['uname'] )) {
     // 	// 昵称和呢称拼音保存到搜索字段
     // 	$user ['search_key'] = $user ['uname'] . ' ' . model ( 'PinYin' )->Pinyin ( $user ['uname'] );
     // } else {
     // 	$user ['search_key'] = $user ['uname'];
     // }
     // // 添加用户操作
     // $result = $this->add ( $user );
     // if (! $result) {
     // 	$this->error = L ( 'PUBLIC_ADD_USER_FAIL' ); // 添加用户失败
     // 	return false;
     // } else {
     // 	// 添加部门关联信息
     // 	model ( 'Department' )->updateUserDepartById ( $result, intval ( $_POST ['department_id'] ) );
     // 	// 添加用户组关联信息
     // 	if (! empty ( $_POST ['user_group'] )) {
     // 		model ( 'UserGroupLink' )->domoveUsergroup ( $result, implode ( ',', $_POST ['user_group'] ) );
     // 	}
     // 	// 添加用户职业关联信息
     // 	if (! empty ( $_POST ['user_category'] )) {
     // 		model ( 'UserCategory' )->updateRelateUser ( $result, $_POST ['user_category'] );
     // 	}
     // 	return true;
     // }
 }
开发者ID:nanhuacrab,项目名称:ThinkSNS4,代码行数:94,代码来源:UserModel.class.php


示例10: saveInfo

 /**
  * 保存用户信息
  * @return [type] [description]
  */
 public function saveInfo()
 {
     $post = I('post.');
     $o_info = $this->redis->HGETALL('Userinfo:uid' . $this->mid);
     $info = array();
     //头像
     $o_headimg = json_decode($o_info['headimg'], true) ? json_decode($o_info['headimg'], true) : array();
     $o_headimg_ids = getSubByKey($o_headimg, 'rid');
     $o_headimg_str = $o_headimg_ids ? implode(',', $o_headimg_ids) : '';
     if ($o_headimg_str != trim($post['headimg'], ',') && isset($post['headimg'])) {
         $info['headimg'] = trim($post['headimg'], ',');
         $headimg_arr = explode(',', $info['headimg']);
         foreach ($headimg_arr as $v) {
             $photo_res = array();
             $photo_res['rid'] = $v;
             $photo_res['url'] = C('WEBSITE_URL') . D('picture')->where('id=' . $v)->getField('path');
             $photo[] = $photo_res;
         }
         $this->redis->HSET('Userinfo:uid' . $this->mid, 'headimg', json_encode($photo, JSON_UNESCAPED_UNICODE));
         $new_photo = explode(',', trim($post['headimg'], ',')) ? explode(',', trim($post['headimg'], ',')) : array();
         $o_headimg_ids = $o_headimg_ids ? $o_headimg_ids : array();
         $add_photo = array_diff($new_photo, $o_headimg_ids);
         if ($add_photo) {
             $sj_log['uid'] = $this->mid;
             $sj_log['type'] = 1;
             foreach ($add_photo as $v) {
                 $sj_log['url'] = D('picture')->where('id=' . $v)->getField('path');
                 D('shunjian')->add($sj_log);
             }
         }
     }
     //昵称
     if ($post['uname'] != $o_info['uname'] && isset($post['uname'])) {
         if ($post['uname'] == '') {
             $this->return['code'] == 1004;
             $this->return['message'] == L('uname_null');
             $this->goJson($this->return);
         }
         $info['uname'] = $post['uname'];
         load("@.user");
         $info['first_letter'] = getFirstLetter($post['uname']);
         //如果包含中文将中文翻译成拼音
         if (preg_match('/[\\x7f-\\xff]+/', $post['uname'])) {
             import("Common.Util.PinYin");
             $pinyinClass = new \PinYin();
             $pinyin = $pinyinClass->Pinyin($post['uname']);
             //昵称和呢称拼音保存到搜索字段
             $info['search_key'] = $post['uname'] . ' ' . $pinyin;
         } else {
             $info['search_key'] = $post['uname'];
         }
     }
     // 性别
     if ($post['sex'] != $o_info['sex'] && isset($post['sex'])) {
         if ($post['sex'] != 1 && $post['sex'] != 2) {
             $this->return['code'] == 1003;
             $this->return['message'] == L('sex_error');
             $this->goJson($this->return);
         }
         $info['sex'] = $post['sex'];
         $sex_flag = $post['sex'] == 1 ? 2 : 1;
         $this->redis->sRem('User:sex' . $sex_flag, $this->mid);
         $this->redis->sAdd('User:sex' . $info['sex'], $this->mid);
     }
     // 个性签名
     if ($post['intro'] != $o_info['intro'] && isset($post['intro'])) {
         $info['intro'] = $post['intro'];
     }
     // 视频介绍
     $o_info['video_profile'] = json_decode($o_info['video_profile'], true) ? json_decode($o_info['video_profile'], true) : array();
     if ($post['video_profile'] != $o_info['video_profile']['rid'] && isset($post['video_profile'])) {
         $info['video_profile'] = $post['video_profile'];
         $video = D('file')->field('savepath, savename')->where('id=' . $post['video_profile'])->find();
         $video_profile['rid'] = $post['video_profile'];
         $video_profile['url'] = C('WEBSITE_URL') . '/Uploads/File/' . $video['savepath'] . $video['savename'];
         $this->redis->HSET('Userinfo:uid' . $this->mid, 'video_profile', json_encode($video_profile, JSON_UNESCAPED_UNICODE));
         $video_profile_data['type'] = 2;
         $video_profile_data['url'] = '/Uploads/File/' . $video['savepath'] . $video['savename'];
         $video_profile_data['uid'] = $this->mid;
         D('shunjian')->add($video_profile_data);
         unset($video_profile_data);
     }
     // 音频介绍
     $o_info['audio_profile'] = json_decode($o_info['audio_profile'], true) ? json_decode($o_info['audio_profile'], true) : array();
     if ($post['audio_profile'] != $o_info['audio_profile']['rid'] && $post['audio_profile']) {
         $info['audio_profile'] = $post['audio_profile'];
         $audio = D('file')->field('savepath, savename')->where('id=' . $post['audio_profile'])->find();
         $audio_profile['rid'] = $post['audio_profile'];
         $audio_profile['url'] = C('WEBSITE_URL') . '/Uploads/File/' . $audio['savepath'] . $audio['savename'];
         $this->redis->HSET('Userinfo:uid' . $this->mid, 'audio_profile', json_encode($audio_profile, JSON_UNESCAPED_UNICODE));
     }
     // 国家,省,城市信息
     if (isset($post['country']) && $post['country'] != 0) {
         if ($post['country'] != $o_info['country']) {
             $info['country'] = $post['country'];
             $info['province'] = $post['province'];
//.........这里部分代码省略.........
开发者ID:a349944418,项目名称:yuban,代码行数:101,代码来源:UserController.class.php


示例11: doRegister

 public function doRegister()
 {
     $service = model('Register');
     $email = $service->isValidEmail($_POST['email']);
     $uname = $service->isValidName($_POST['uname']);
     $password = $service->isValidPassword($_POST['password'], $_POST['password']);
     if (!$email && !$uname && !$password) {
         echo $service->getLastError();
     } else {
         if ($user = model('Passport')->getLocalUser($email, $password)) {
             if ($user['is_active'] == 0) {
                 redirect(U('w3g/Public/login'), 3, '帐号尚未激活,请激活后重新登录');
             }
         }
         $invite = t($_POST['invate']);
         $inviteCode = t($_POST['invate_key']);
         $email = t($_POST['email']);
         $uname = t($_POST['uname']);
         $sex = 1 == $_POST['sex'] ? 1 : 2;
         $password = trim($_POST['password']);
         $repassword = trim($_POST['repassword']);
         $login_salt = rand(11111, 99999);
         $map['uname'] = $uname;
         $map['sex'] = $sex;
         $map['login_salt'] = $login_salt;
         $map['password'] = md5(md5($password) . $login_salt);
         $map['login'] = $map['email'] = $email;
         $map['reg_ip'] = get_client_ip();
         $map['ctime'] = time();
         $map['first_letter'] = getFirstLetter($uname);
         $map['is_init'] = 1;
         // 审核状态: 0-需要审核;1-通过审核
         $map['is_audit'] = $this->_config['register_audit'] ? 0 : 1;
         // 需求添加 - 若后台没有填写邮件配置,将直接过滤掉激活操作
         $isActive = $this->_config['need_active'] ? 0 : 1;
         if ($isActive == 0) {
             $emailConf = model('Xdata')->get('admin_Config:email');
             if (empty($emailConf['email_host']) || empty($emailConf['email_account']) || empty($emailConf['email_password'])) {
                 $isActive = 1;
             }
         }
         $map['is_active'] = $isActive;
         $map['first_letter'] = getFirstLetter($uname);
         //如果包含中文将中文翻译成拼音
         if (preg_match('/[\\x7f-\\xff]+/', $map['uname'])) {
             //昵称和呢称拼音保存到搜索字段
             $map['search_key'] = $map['uname'] . ' ' . model('PinYin')->Pinyin($map['uname']);
         } else {
             $map['search_key'] = $map['uname'];
         }
         $uid = $this->_user_model->add($map);
         // dump($uid);
         if ($uid) {
             // 添加积分
             model('Credit')->setUserCredit($uid, 'init_default');
             // 如果是邀请注册,则邀请码失效
             if ($invite) {
                 // 验证码使用
                 $receiverInfo = model('User')->getUserInfo($uid);
                 // 添加用户邀请码字段
                 model('Invite')->setInviteCodeUsed($inviteCode, $receiverInfo);
                 //给邀请人奖励
                 model('User')->where('uid=' . $uid)->setField('invite_code', $inviteCode);
             }
             // 添加至默认的用户组
             $userGroup = model('Xdata')->get('admin_Config:register');
             $userGroup = empty($userGroup['default_user_group']) ? C('DEFAULT_GROUP_ID') : $userGroup['default_user_group'];
             model('UserGroupLink')->domoveUsergroup($uid, implode(',', $userGroup));
             // //注册来源-第三方帐号绑定
             // if(isset($_POST['other_type'])){
             // 	$other['type'] = t($_POST['other_type']);
             // 	$other['type_uid'] = t($_POST['other_uid']);
             // 	$other['oauth_token'] = t($_POST['oauth_token']);
             // 	$other['oauth_token_secret'] = t($_POST['oauth_token_secret']);
             // 	$other['uid'] = $uid;
             // 	D('login')->add($other);
             // }
             // //判断是否需要审核
             // if($this->_config['register_audit']) {
             // 	$this->redirect('w3g/Register/waitForAudit', array('uid' => $uid));
             // } else {
             // 	if(!$isActive){
             // 		$this->_register_model->sendActivationEmail($uid);
             // 		$this->redirect('w3g/Register/waitForActivation', array('uid' => $uid));
             // 	}else{
             D('Passport')->loginLocal($email, $password);
             // $this->assign('jumpUrl', U('w3g/Index/login'));
             // $this->success('恭喜您,注册成功');
             echo '1';
             // 	}
             // }
         } else {
             // $this->error(L('PUBLIC_REGISTER_FAIL'));			// 注册失败
             echo '0';
         }
     }
     //    $uid     = $service->register($email, $uname, $password, true);
     //    if (!$uid){
     //        redirect(U('/Public/register', $_POST), 3, $service->getLastError());
     //    }else{
//.........这里部分代码省略.........
开发者ID:yang7hua,项目名称:hunshe,代码行数:101,代码来源:PublicAction.class.php


示例12: doStep1

 /**
  * 注册流程 - 执行第一步骤
  * @return void
  */
 public function doStep1()
 {
     $invite = t($_POST['invate']);
     $inviteCode = t($_POST['invate_key']);
     $email = t($_POST['email']);
     $uname = t($_POST['uname']);
     $sex = 1 == $_POST['sex'] ? 1 : 2;
     $password = trim($_POST['password']);
     $repassword = trim($_POST['repassword']);
     if (!$this->_register_model->isValidEmail($email)) {
         $this->error($this->_register_model->getLastError());
     }
     if (!$this->_register_model->isValidPassword($password, $repassword)) {
         $this->error($this->_register_model->getLastError());
     }
     /*		if (!$_POST['accept_service']) {
     			$this->error(L('PUBLIC_ACCEPT_SERVICE_TERMS'));
     		}*/
     $login_salt = rand(11111, 99999);
     $map['uname'] = $uname;
     $map['sex'] = $sex;
     $map['login_salt'] = $login_salt;
     $map['password'] = md5(md5($password) . $login_salt);
     $map['login'] = $map['email'] = $email;
     $map['regip'] = get_client_ip();
     $map['ctime'] = time();
     // 添加地区信息
     $map['location'] = t($_POST['city_names']);
     $cityIds = t($_POST['city_ids']);
     $cityIds = explode(',', $cityIds);
     isset($cityIds[0]) && ($map['province'] = intval($cityIds[0]));
     isset($cityIds[1]) && ($map['city'] = intval($cityIds[1]));
     isset($cityIds[2]) && ($map['area'] = intval($cityIds[2]));
     // 审核状态: 0-需要审核;1-通过审核
     $map['is_audit'] = $this->_config['register_audit'] ? 0 : 1;
     $map['is_active'] = $this->_config['need_active'] ? 0 : 1;
     $map['first_letter'] = getFirstLetter($uname);
     //如果包含中文将中文翻译成拼音
     if (preg_match('/[\\x7f-\\xff]+/', $map['uname'])) {
         //昵称和呢称拼音保存到搜索字段
         $map['search_key'] = $map['uname'] . ' ' . model('PinYin')->Pinyin($map['uname']);
     } else {
         $map['search_key'] = $map['uname'];
     }
     $uid = $this->_user_model->add($map);
     if ($uid) {
         // 如果是邀请注册,则邀请码失效
         if ($invite) {
             $receiverInfo = model('User')->getUserInfo($uid);
             // 验证码使用
             model('Invite')->setInviteCodeUsed($inviteCode, $receiverInfo);
             // 添加用户邀请码字段
             model('User')->where('uid=' . $uid)->setField('invite_code', $inviteCode);
         }
         // 添加至默认的用户组
         $userGroup = model('Xdata')->get('admin_Config:register');
         $userGroup = empty($userGroup['default_user_group']) ? C('DEFAULT_GROUP_ID') : $userGroup['default_user_group'];
         model('UserGroupLink')->domoveUsergroup($uid, implode(',', $userGroup));
         //注册来源-第三方帐号绑定
         if (isset($_POST['other_type'])) {
             $other['type'] = t($_POST['other_type']);
             $other['type_uid'] = intval($_POST['other_uid']);
             $other['oauth_token'] = t($_POST['oauth_token']);
             $other['oauth_token_secret'] = t($_POST['oauth_token_secret']);
             $other['uid'] = $uid;
             D('login')->add($other);
         }
         //判断是否需要审核
         if ($this->_config['register_audit']) {
             $this->redirect('public/Register/waitForAudit', array('uid' => $uid));
         } else {
             if ($this->_config['need_active']) {
                 $this->_register_model->sendActivationEmail($uid);
                 $this->redirect('public/Register/waitForActivation', array('uid' => $uid));
             } else {
                 D('Passport')->loginLocal($email, $password);
                 $this->assign('jumpUrl', U('public/Passport/login'));
                 $this->success('恭喜您,注册成功');
             }
         }
     } else {
         $this->error(L('PUBLIC_REGISTER_FAIL'));
         // 注册失败
     }
 }
开发者ID:naliduo,项目名称:ThinkSNS,代码行数:89,代码来源:RegisterAction.class.php


示例13: register

 /**
  * 认证方法 --using
  * @param varchar oauth_token
  * @param varchar oauth_token_secret
  * @return array 状态+提示
  */
 public function register()
 {
     $phone = floatval($this->data['phone']);
     // 手机号码
     $username = 'jipu_' . t($this->data['username']);
     // 用户名
     $password = $this->data['password'];
     // 密码
     $sex = intval($this->data['sex']);
     in_array($sex, array(1, 2)) or $sex = 1;
     // 默认 男 1.男,2女
     $register = model('Register');
     $config = model('Xdata')->get('admin_Config:register');
     // 配置
     /* 判断用户手机号码可用性 */
     if (!$register->isValidPhone($phone)) {
         return array('status' => 0, 'msg' => $register->getLastError());
         /* 判断用户名是否可用 */
     } elseif (!$register->isValidName($username)) {
         return array('status' => 0, 'msg' => $register->getLastError());
         /* 密码判断 */
     } elseif (!$register->isValidPasswordNoRepeat($password)) {
         return array('status' => 0, 'msg' => $register->getLastError());
     }
     $userData = array('login_salt' => rand(10000, 99999));
     // 用户基本资料数组
     $userData['password'] = model('User')->encryptPassword($password, $userData['login_salt']);
     // 用户密码
     $userData['uname'] = $username;
     // 用户名
     $userData['phone'] = $phone;
     // 用户手机号码
     $userData['sex'] = $sex;
     // 用户性别
     $userData['ctime'] = time();
     // 注册时间
     $userData['reg_ip'] = get_client_ip();
     // 注册IP
     /* 用户是否默认审核 */
     $userData['is_audit'] = 1;
     $config['register_audit'] and $userData['is_audit'] = 0;
     $userData['is_active'] = 1;
     // 默认激活
     $userData['is_init'] = 1;
     // 默认初始化
     $userData['first_letter'] = getFirstLetter($username);
     // 用户首字母
     /* 用户搜索 */
     $userData['search_key'] = $username . ' ' . $userData['first_letter'];
     preg_match('/[\\x7f-\\xff]+/', $username) and $userData['search_key'] .= ' ' . Pinyin::getShortPinyin($username, 'utf-8');
     $uid = model('User')->add($userData);
     // 添加用户数据
     if (!$uid) {
         return array('status' => 0, 'msg' => '注册失败');
     }
     // 注册失败的提示
     /* 添加默认用户组 */
     $userGroup = $config['default_user_group'];
     empty($userGroup) and $userGroup = C('DEFAULT_GROUP_ID');
     is_array($userGroup) and $userGroup = implode(',', $userGroup);
     model('UserGroupLink')->domoveUsergroup($uid, $userGroup);
     /* 添加双向关注用户 */
     if (!empty($config['each_follow'])) {
         model('Follow')->eachDoFollow($uid, $config['each_follow']);
     }
     /* 添加默认关注用户 */
     $defaultFollow = $config['default_follow'];
     $defaultFollow = explode(',', $defaultFollow);
     $defaultFollow = array_diff($defaultFollow, explode(',', $config['each_follow']));
     empty($defaultFollow) or model('Follow')->bulkDoFollow($uid, $defaultFollow);
     return array('status' => 1, 'msg' => '注册成功');
 }
开发者ID:medz,项目名称:thinksns-4,代码行数:78,代码来源:JipuApi.class.php


示例14: get_user_city_bak

 /**
  * 备份
  * 获取地区(按字母) --using
  *
  * @return array 城市列表
  */
 public function get_user_city_bak()
 {
     $my = model('User')->where('`uid` = ' . $this->mid)->getField('city');
     $letters = array('my' => array(), 'A' => array(), 'B' => array(), 'C' => array(), 'D' => array(), 'E' => array(), 'F' => array(), 'G' => array(), 'H' => array(), 'I' => array(), 'J' => array(), 'K' => array(), 'L' => array(), 'M' => array(), 'N' => array(), 'O' => array(), 'P' => array(), 'Q' => array(), 'R' => array(), 'S' => array(), 'T' => array(), 'U' => array(), 'V' => array(), 'W' => array(), 'X' => array(), 'Y' => array(), 'Z' => array());
     $provinces = D('area')->where('pid=0')->findAll();
     $map['pid'] = array('in', getSubByKey($provinces, 'area_id'));
     $map['title'] = array('exp', 'not in("市辖区","县","市","省直辖县级行政单位" ,"省直辖行政单位")');
     $citys = D('area')->where($map)->findAll();
     foreach ($citys as $k => $v) {
         $first_letter = getFirstLetter($v['title']);
         $letters[$first_letter][$v['area_id']]['city_id'] = $v['area_id'];
         $letters[$first_letter][$v['area_id']]['city_name'] = $v['title'];
         if ($v['area_id'] == $my) {
             $letters['my'][$v['area_id']]['city_id'] = $v['area_id'];
             $letters['my'][$v['area_id']]['city_name'] = $v['title'];
         }
         unset($first_letter);
     }
     return 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP getFloatValue函数代码示例发布时间:2022-05-15
下一篇:
PHP getFilter函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap