public function login($username = '', $password = '', $verify = '')
 {
     if (IS_POST) {
         // 登录验证
         /* 检测验证码 */
         if (C('WEB_SITE_VERIFY') && !check_verify($verify)) {
             $this->error('验证码输入错误!');
         }
         /* 调用UC登录接口登录 */
         $dao = D('Common/User');
         $uid = $dao->login($username, $password);
         if (!$uid) {
             // 登录失败
             $this->error($dao->getError());
             exit;
         }
         $url = Cookie('__forward__');
         if ($url) {
             Cookie('__forward__', null);
         } else {
             $url = U('Home/Index/index');
         }
         if (C('DIV_DOMAIN')) {
             $map['uid'] = $uid;
             $domain = D('Common/Public')->where($map)->getField('domain');
             $url = chang_domain($url, $domain);
         }
         $this->success('登录成功!', $url);
     } else {
         // 显示登录表单
         if (isMobile()) {
             // 跳转到手机版的个人空间
             redirect(addons_url('UserCenter://Wap/userCenter', array('from' => 1)));
         }
         $html = 'login';
         $_GET['from'] == 'store' && ($html = 'simple_login');
         $this->display($html);
     }
 }
 function step_0()
 {
     //$map ['uid'] = $this->mid;
     //$data = D ( 'Common/Public' )->where ( $map )->find ();
     //var_dump($data);
     $id = I('id');
     $this->assign('id', $id);
     $model = $this->model;
     //var_dump($model);
     if (IS_POST) {
         foreach ($_POST as &$v) {
             $v = trim($v);
         }
         // 检查专属域名是否已被占用
         if (C('DIV_DOMAIN')) {
             $map2['domain'] = $domain = $_POST['domain'];
             if (empty($domain)) {
                 $this->error('专属域名不能为空');
                 exit;
             }
             if (is_numeric($domain)) {
                 $this->error('专属域名不能为纯数字');
                 exit;
             }
             $plen = strlen($domain);
             // ! preg_match ( "/^(([a-z]+[0-9]+)|([0-9]+[a-z]+))[a-z0-9]*$/i", $domain ) ||
             if ($plen < 3 || $plen > 10) {
                 $this->error('专属域名必须为3-10位的字母和数字的组合');
                 exit;
             }
             empty($id) || ($map2['id'] = array('exp', '!=' . $id));
             $arr = array('www' => 1);
             if (isset($arr[$domain]) || D('Common/Public')->where($map2)->getField('id')) {
                 $this->error('该专属域名已经存在,请换别的再试');
                 exit;
             }
         }
         $_POST['token'] = $_POST['public_id'];
         $_POST['group_id'] = intval(C('DEFAULT_PUBLIC_GROUP_ID'));
         $_POST['uid'] = $this->mid;
         $_POST['has_public'] = 1;
         // 更新缓存
         D('Common/Public')->clear($id);
         session('token', $_POST['token']);
         $Model = D(parse_name(get_table_name($model['id']), 1));
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if (empty($id)) {
             if ($Model->create() && ($id = $Model->add())) {
                 // 增加公众号与用户的关联关系
                 $data['uid'] = $this->mid;
                 $data['mp_id'] = $id;
                 $data['is_creator'] = 1;
                 M('public_link')->add($data);
                 $url = U('lists');
                 $url = chang_domain($url, $_POST['domain']);
                 $this->success('添加基本信息成功!', $url);
             } else {
                 $this->error($Model->getError());
             }
         } else {
             $_POST['id'] = $id;
             $url = U('lists');
             $url = chang_domain($url, $_POST['domain']);
             $Model->create() && ($res = $Model->save());
             if ($res) {
                 $this->success('保存基本信息成功!', $url);
             } elseif ($res === 0) {
                 $this->success(' ', $url);
             } else {
                 $this->error($Model->getError());
             }
         }
     } else {
         if (empty($id)) {
             $allow_add_count = getPublicMax($this->mid);
             $has_add_count = M('public_link')->where("uid='{$this->mid}'")->getField('sum(is_creator)');
             if ($allow_add_count <= $has_add_count) {
                 $this->error('您最多只能创建 ' . $allow_add_count . ' 个公众号!');
                 exit;
             }
         } else {
             $data = M(get_table_name($model['id']))->find($id);
         }
         $data['type'] = intval($data['type']);
         $this->assign('info', $data);
         $this->display('Publics/step_0');
     }
 }