<?php
/**
 * 注册模块
 * @copyright reginx.com
 * $Id$
 */
class reg_mod extends mod {
    
    /**
     * 注册默认页面
     *
     */
    public function indexAct(){
        if($this->conf['memopen']){
            $this->display('user/reg.tpl.html');
        }
        die('Closed');
    }
    
    /**
     * 注册处理页
     *
     */
    public function submitAct(){
        $out  = array('code' => 1 , 'msg' => '会员系统关闭了');
        $user = $this->get('user' , 'P');
        $user['id'] = 0;
        if(!$this->vcode() && $this->conf['memopen']){
            $out['msg'] = '验证码错误';
        }else{
            $obj = OBJ('user_tab');
            if($obj->load($user)){
                if($obj->chkuniq()){
                    $obj->data['openid'] = $obj->data['uname'];
                    $obj->data['passwd'] = misc_lib::getpasswd($obj->data['passwd']);
                    $out = $obj->save();
                }else{
                    $out['msg'] = '该邮箱已经被注册了';
                }
            }else{
                $out['msg'] = $obj->geterr();
            }
        }
        $out['msg'] = is_array($out['msg']) ? $out['msg'][0] : $out['msg'];
        $this->ajaxout($out);
    }
}// End Class
?>