コード例 #1
0
ファイル: attr_group.php プロジェクト: jinghuizhai/ida
 function add()
 {
     $post = $this->req->post;
     if (count($post)) {
         $name = $post['name'];
         $value = $post['value'];
         $attr = $post['attr'];
         // var_dump($value);
         if (strlen($name) > 0) {
             $result = $this->load->model('attr_group')->add($name);
             if ($result) {
                 setHint('属性组添加成功');
             } else {
                 setHint('属性组添加失败', 'bad');
             }
             $lastId = $this->db->lastId();
             if ($lastId) {
                 foreach ($value as $key => $v) {
                     if (strlen($v) > 0) {
                         $this->load->model('attr_value')->add(array("attr_group_id" => (int) $lastId, "attr_id" => (int) $attr[$key], "value" => $v));
                     }
                 }
             }
         } else {
             setHint('属性名太短', 'bad');
         }
         $this->res->red('attr_group/add');
     } else {
         $data = $this->load->model('attr')->find();
         return $this->load->view('attr_group_add', array('attrs' => $data));
     }
 }
コード例 #2
0
ファイル: catalog.php プロジェクト: jinghuizhai/ida
 function delete()
 {
     $catalog_id = $this->req->post['catalog_id'];
     $result = $this->load->model('catalog')->delete($catalog_id);
     if ($result) {
         setHint('删除成功');
     } else {
         setHint('删除失败', 'bad');
     }
     $this->res->red('catalog/update');
 }
コード例 #3
0
ファイル: attr.php プロジェクト: jinghuizhai/ida
 function delete()
 {
     $attr_id = (int) $this->req->post['attr_id'];
     $result = $this->load->model('attr')->delete($attr_id);
     if ($result) {
         setHint('属性删除成功');
     } else {
         setHint('属性删除失败', 'bad');
     }
     $this->res->red('attr');
 }
コード例 #4
0
ファイル: broadcast.php プロジェクト: jinghuizhai/ida
 function delete()
 {
     $broadcast_id = (int) $this->req->post['broadcast_id'];
     $result = $this->load->model('broadcast')->delete($broadcast_id);
     if ($result) {
         setHint('删除广播成功');
     } else {
         setHint('删除广播失败', 'bad');
     }
     $this->res->red('broadcast');
 }
コード例 #5
0
ファイル: action.php プロジェクト: jinghuizhai/ida
 function execute($registry)
 {
     $filterArr = array('home', 'comment', 'product', 'catalog', 'cart', 'blog');
     if (empty($this->class)) {
         $registry->get('res')->redirect('home');
     }
     // return $this->originalClass;
     if (in_array($this->originalClass, $filterArr)) {
         return $this->doexecute($registry);
     } else {
         $user = $registry->get('session')->data['user'];
         if (!empty($user)) {
             $permission = $user['permission'];
             if (in_array($this->originalClass, $permission) || in_array($this->originalClass . '/' . $this->method, $permission)) {
                 return $this->doexecute($registry);
             } else {
                 return '对不起,您没有权限,sorry,you have no permission!';
             }
         } else {
             setHint('请先登录');
             $registry->get('res')->redirect('home/login');
         }
     }
 }
コード例 #6
0
ファイル: handle.php プロジェクト: jinghuizhai/weixin
function updateRebateStatus()
{
    if (getvar('admin', 'session')) {
        $user_id = (int) getvar('user_id', 'post');
        // $year = (int)getvar('year','post');
        $sums = (int) getvar('sums', 'post');
        $rebate = new Rebate();
        $result = $rebate->findByUser($user_id);
        if ($result) {
            //update
            $result2 = $rebate->updateStatus((int) $result['rebate_id'], $sums);
        } else {
            //insert
            $result2 = $rebate->add(array("money" => $sums, "status" => 1, "date" => datenow(), "user_id" => $user_id));
        }
        if (!empty($result2)) {
            setHint('结算成功');
        } else {
            setHint('结算失败');
        }
        redirect('rebate');
    } else {
        setHint('请先登录');
        redirect('login');
    }
}
コード例 #7
0
ファイル: checkout.php プロジェクト: jinghuizhai/ida
 function createOrder()
 {
     $post = $this->req->post;
     $user_id = (int) $this->session->data['user']['user_id'];
     $cart = $post['cart'];
     $address_id = (int) $post['radio'];
     $payway = $post['payway'];
     if (strlen($cart) < 3) {
         setHint('您的购物车中还没有商品,不能提交订单', 'bad');
         $this->res->redirect('checkout/productList');
     }
     if ($payway == 'alipay') {
         if (isMobil()) {
             $payway = 'ali_wap_pay';
         } else {
             $payway = 'ali_pc_pay';
         }
     } else {
         if ($payway == 'weixinpay') {
             $payway = 'weixin_pay';
         } else {
             if (!empty($payway)) {
                 $paycode = strtoupper($payway);
                 $payway = 'ali_bank_pay';
             } else {
                 setHint('请选择支付方式', 'bad');
                 $this->res->redirect('checkout/productList');
             }
         }
     }
     //暂时只能使用此方式
     $payway = 'ali_pc_pay';
     //检查地址是否存在
     $address = $this->load->model('address');
     $result_address = $address->findById($address_id, $user_id);
     if ($result_address) {
         $address->updateUsed($user_id, 0);
         $address->updateUsing($address_id, 1);
     } else {
         setHint('地址不存在,不能提交订单', 'bad');
         $this->res->redirect('checkout/productList');
     }
     /*偏远地区省份id
     		内蒙古,青海,宁夏,甘肃,广西,海南*/
     $remote_arr = array('150000', '630000', '640000', '620000', '450000', '460000');
     $is_remote = in_array($result_address['provinceid'], $remote_arr);
     //查询商品
     $product_id_arr = array();
     $product_num_arr = array();
     preg_match_all('/(\\d+)[:](\\d+)/', $cart, $arr);
     $product_id_arr = $arr[1];
     $product_num_arr = $arr[2];
     $products = array();
     if (count($product_id_arr) > 0 && count($product_id_arr) == count($product_num_arr)) {
         $product = $this->load->model('product');
         foreach ($product_id_arr as $key => $value) {
             $result = $product->findById((int) $value);
             if (!$result || empty($product_num_arr[$key])) {
                 setHint('非法的商品信息,不能提交订单', 'bad');
                 $this->res->redirect('checkout/productList');
                 break;
             } else {
                 $result['piece'] = $product_num_arr[$key];
             }
             $products[] = $result;
         }
         //生成订单
         //事务
         $this->db->begin();
         $order = $this->load->model('order');
         $order_info = $this->load->model('orderInfo');
         $ret = $order->add(array("pay" => 0, "send" => 0, "user_id" => $user_id, "address_id" => $address_id, 'address' => $result_address['province'] . $result_address['city'] . $result_address['area'] . $result_address['zip'] . $result_address['detail'], "date" => timenow()));
         if (!$ret) {
             $this->db->rollback();
             setHint('生成订单失败');
             $this->res->redirect('checkout/productList');
         }
         $lastId = (int) $this->db->lastId();
         $total_money = 0;
         foreach ($products as $key => $value) {
             $money = $value['piece'] * $value['price'];
             if ($value['free_postage'] == 1) {
                 if ($is_remote) {
                     $fee = $value['postage_remote'];
                 } else {
                     $fee = $value['postage'];
                 }
                 $money = $money + $value['piece'] * $fee;
             }
             $total_money = $total_money + $money;
             $ret = $order_info->add(array('order_id' => $lastId, "product_id" => (int) $value['product_id'], 'piece' => (int) $value['piece'], "postage" => empty($value['free_postage']) ? 0 : (double) $fee, "price" => (double) $value['price'], "money" => (double) $money));
             if (!$ret) {
                 $this->db->rollback();
                 setHint('生成订单失败');
                 $this->res->redirect('checkout/productList');
             }
         }
         $orderNum = createOrderNum();
         $ret = $order->update($lastId, $orderNum . $lastId, $total_money);
         if (!$ret) {
             $this->db->rollback();
             setHint('生成订单失败');
             $this->res->redirect('checkout/productList');
         }
         $this->db->commit();
         //订单生成后清空cookie
         // setcookie('cart','',time()-3600);
         //订单已经提交,查询订单并返回结果
         $product_subject = '';
         foreach ($products as $key => $value) {
             $product_subject = $product_subject . $value['name'] . "(" . $value['piece'] . ")";
         }
         $data = $order->findById($lastId);
         $data['subject'] = $product_subject;
         $data['body'] = '购物愉快';
         $data['url'] = HOSTNAME . 'product/' . $products[0]['product_id'];
         //生成清单后删除此用户所有其他未付款订单
         $order->deleteNotPay($lastId, $user_id);
         return $this->load->view('checkout_createorder', array('order' => $data, 'products' => $products, 'payway' => $payway, 'paycode' => $paycode));
     } else {
         setHint('非法的商品信息,不能提交订单', 'bad');
     }
 }
コード例 #8
0
ファイル: user.php プロジェクト: jinghuizhai/ida
 function pass_update($args)
 {
     $post = $this->req->post;
     if (!count($post)) {
         $user_id = (int) $args[0];
         $user = $this->load->model('user')->findById($user_id);
         return $this->load->view('pass_update', $user);
     } else {
         $pass = $post['pass'];
         $pass2 = $post['pass2'];
         $user_id = (int) $post['user_id'];
         if (strlen($pass) > 5 && strlen($pass2) > 5 && strcmp($pass, $pass2) == 0) {
             $result = $this->load->model('user')->updatePass($user_id, md5($pass));
             if ($result) {
                 setHint('密码修改成功');
             } else {
                 setHint('密码修改失败', 'bad');
             }
         } else {
             setHint('密码不符合要求,修改失败', 'bad');
         }
         $this->res->red('user/pass_update/' . $user_id);
     }
 }
コード例 #9
0
}
function prop($obj, $prop, $max_len = null)
{
    global $g_hint;
    $method_name = "get{$prop}";
    $res = call_user_func(array($obj, $method_name));
    if ($max_len) {
        $res = substr($res, 0, $max_len);
    }
    if ($prop == "id") {
        $res = "<a href='javascript:openPartner(\"{$prop}\")'>{$res}</a>";
    }
    $res = str_replace($g_hint, "<span  style='font-size:20px; font-weight: bold; color:green;'>{$g_hint}</span>", $res);
    return "<td>{$res}</td>";
}
setHint($hint);
?>
<script>
function openPartner ( pid )
{
	url = '<?php 
echo url_for("/system");
?>
' + "/partners?partner_id=" + pid + "&go=go";
	var handle = window.open ( url , "partner" ); 
}
</script>
<div style='font-family:verdana; font-size:12px;'>
<form method="get">
	keyword: <input type="text" name="hint" value="<?php 
echo $hint;
コード例 #10
0
ファイル: user.php プロジェクト: jinghuizhai/ida
 function updatePass()
 {
     $post = $this->req->post;
     if (count($post)) {
         $pass = $post['pass'];
         $pass2 = $post['pass2'];
         $sms = $post['sms'];
         if (!validate('pass', $pass)) {
             setHint('密码格式不正确', 'bad');
             $this->res->redirect('user/updatePass');
         }
         if (!validate('pass', $pass2)) {
             setHint('重复密码格式不正确', 'bad');
             $this->res->redirect('user/updatePass');
         }
         if (!validate('sms', $sms)) {
             setHint('短信验证码格式不正确', 'bad');
             $this->res->redirect('user/updatePass');
         }
         if ($this->session->data['smscode'] != $sms) {
             setHint('短信验证码不正确', 'bad');
             $this->res->redirect('user/updatePass');
         }
         $result = $this->load->model('user')->updatePass((int) $this->session->data['user']['user_id'], md5($pass));
         $this->session->data['smscode'] = null;
         if ($result) {
             setHint('修改密码成功');
         } else {
             setHint('修改密码失败', 'bad');
         }
         $this->res->redirect('user/updatePass');
     } else {
         return $this->load->view('user_update_pass', array(), 'admin_header', 'admin_footer');
     }
 }
コード例 #11
0
ファイル: admin.php プロジェクト: jinghuizhai/ida
 function update()
 {
     $post = $this->req->post;
     if (count($post)) {
         $old_pass = $post['old_pass'];
         $pass = $post['pass'];
         $pass2 = $post['pass2'];
         if (!validate('pass', $old_pass)) {
             setHint('现在使用密码格式不正确', 'bad');
             $this->res->red('admin/update');
         }
         if (!validate('pass', $pass)) {
             setHint('密码格式不正确', 'bad');
             $this->res->red('admin/update');
         }
         if (!validate('pass', $pass2)) {
             setHint('重复密码格式不正确', 'bad');
             $this->res->red('admin/update');
         }
         $result = $this->load->model('admin')->updatePass(array('pass' => md5($pass), 'old_pass' => md5($old_pass)));
         if ($result) {
             setHint('修改密码成功');
             $this->res->red('admin/update');
         } else {
             setHint('修改密码失败', 'bad');
             $this->res->red('admin/update');
         }
     } else {
         return $this->load->view('admin_update');
     }
 }
コード例 #12
0
ファイル: address.php プロジェクト: jinghuizhai/ida
 function add()
 {
     $post = $this->req->post;
     if (count($post)) {
         $province = $post['province'];
         $city = $post['city'];
         $area = $post['area'];
         $zipcode = $post['zipcode'];
         $detail = $post['detail'];
         if (empty($province)) {
             setHint('省不能为空', 'bad');
             $this->res->redirect('address/add');
         }
         if (empty($city)) {
             setHint('城市不能为空', 'bad');
             $this->res->redirect('address/add');
         }
         if (empty($area)) {
             setHint('地区不能为空', 'bad');
             $this->res->redirect('address/add');
         }
         if (empty($zipcode)) {
             setHint('邮编不能为空', 'bad');
             $this->res->redirect('address/add');
         }
         if (empty($detail)) {
             setHint('详细地址不能为空', 'bad');
             $this->res->redirect('address/add');
         }
         //如果此人已经添加了5个地址,那么将不能继续添加
         $num = $this->load->model('address')->countByUserid((int) $this->session->data['user']['user_id']);
         if ($num['count'] >= 4) {
             setHint('对不起,您添加的地址已经到上限', 'bad');
             $this->res->redirect('address/add');
         }
         $arr = array('province' => $province, 'city' => $city, 'area' => $area, 'zipcode' => $zipcode, 'user_id' => (int) $this->session->data['user']['user_id'], 'detail' => $detail, 'used' => 1);
         $this->load->model('address')->updateUsed((int) $this->session->data['user']['user_id'], 0);
         $result = $this->load->model('address')->add($arr);
         if ($result) {
             setHint('添加地址成功');
         } else {
             setHint('添加地址失败', 'bad');
         }
         $this->res->redirect('address/add');
     } else {
         return $this->load->view('address_add', null, 'admin_header', 'admin_footer');
     }
 }
コード例 #13
0
ファイル: order.php プロジェクト: jinghuizhai/ida
 function handSend()
 {
     $order_id = (int) $this->req->post['order_id'];
     $order = $this->load->model('order')->findById($order_id);
     $order_info = $this->load->model('orderInfo')->findInfoById($order_id);
     if (!empty($order) && !empty($order_info)) {
         // 商品信息
         $product_info = "";
         foreach ($order_info as $key => $value) {
             $product_info = $product_info . $value['name'] . 'x' . $value['piece'];
         }
         //需要远程提交的数据
         $data = array('name' => $order['name'], 'phone' => $order['phone'], 'address' => $order['address'], 'order_id' => $order['order_id'], 'order_code' => $order['order_code'], 'money' => $order['money'], 'product' => $product_info);
         $ret = phppost(CLIENTURL, $data);
         if ($ret == 'success') {
             //改变订单状态为已经发送
             $result = $this->load->model('order')->updateSend($order_id);
             if ($result) {
                 setHint('远程提交订单成功');
             } else {
                 setHint('远程提交订单成功,但本地失败', 'bad');
             }
         } else {
             setHint('未发送成功', 'bad');
         }
     } else {
         setHint('此订单不存在', 'bad');
     }
     $this->res->red('order/notSend');
 }
コード例 #14
0
ファイル: product.php プロジェクト: jinghuizhai/ida
 function update($args)
 {
     if (!count($this->req->post)) {
         $product_id = (int) $args[0];
         if (empty($product_id)) {
             $this->res->red('product/index');
         }
         $product = $this->load->model('product')->findById($product_id);
         $imgs = $this->load->model('img')->findByProductid($product_id);
         $catalogs = $this->load->model('catalog')->findName();
         $attrs = $this->load->model('attr_group')->findName();
         $product['imgs'] = $imgs;
         $product['catalogs'] = $catalogs;
         $product['attrs'] = $attrs;
         return $this->load->view('product_update', $product);
     } else {
         $post = $this->req->post;
         $name = $post['name'];
         $product_id = $post['product_id'];
         $catalog_id = $post['catalog_id'];
         $price = $post['price'];
         $free_postage = $post['free_postage'];
         $postage = $post['postage'];
         $postage_remote = $post['postage_remote'];
         $score = $post['score'];
         $stock = $post['stock'];
         $detail = $post['editorValue'];
         $likes = $post['likes'];
         $attr_group_id = $post['attr_group_id'];
         $title = $post['title'];
         $keywords = $post['keywords'];
         $description = $post['description'];
         $hits = (int) $post['hits'];
         $for_presenter = (double) $post['for_presenter'];
         $for_workers = (double) $post['for_workers'];
         $img_id = $post['img_id'];
         $arr = array('product_id' => (int) $product_id, 'name' => $name, 'catalog_id' => (int) $catalog_id, 'price' => (double) $price, 'free_postage' => (int) $free_postage, 'postage' => (double) $postage, 'postage_remote' => (double) $postage_remote, 'score' => (double) $score, 'stock' => (int) $stock, 'detail' => $detail, 'likes' => (int) $likes, 'attr_group_id' => (int) $attr_group_id, 'title' => $title, 'hits' => $hits, 'for_presenter' => $for_presenter, 'for_workers' => $for_workers, 'keywords' => $keywords, 'description' => $description);
         // 用户输入产品信息验证
         if (strlen($name) < 1) {
             setHint('名字不符合要求', 'bad');
             $this->res->red('product/update/' . $product_id);
         }
         if (!is_numeric($price)) {
             setHint('价格必须是数字', 'bad');
             $this->res->red('product/update/' . $product_id);
         }
         if (!is_numeric($postage)) {
             setHint('运费必须是数字', 'bad');
             $this->res->red('product/update/' . $product_id);
         }
         if (!is_numeric($postage_remote)) {
             setHint('偏远地区运费必须是数字', 'bad');
             $this->res->red('product/update/' . $product_id);
         }
         if (!is_numeric($score)) {
             setHint('积分必须是数字', 'bad');
             $this->res->red('product/update/' . $product_id);
         }
         if (!is_numeric($stock)) {
             setHint('库存必须是数字', 'bad');
             $this->res->red('product/update/' . $product_id);
         }
         if (strlen($detail) < 10) {
             setHint('产品详情太短', 'bad');
             $this->res->red('product/update/' . $product_id);
         }
         if (!is_numeric($likes)) {
             setHint('点赞数必须是数字', 'bad');
             $this->res->red('product/update/' . $product_id);
         }
         if (!is_numeric($hits)) {
             setHint('点击次数必须是数字', 'bad');
             $this->res->red('product/update/' . $product_id);
         }
         if (!is_numeric($for_presenter)) {
             setHint('返给直接推荐者必须是数字', 'bad');
             $this->res->red('product/update/' . $product_id);
         }
         if (!is_numeric($for_workers)) {
             setHint('返给工作人员必须是数字', 'bad');
             $this->res->red('product/update/' . $product_id);
         }
         if (strlen($title) < 5) {
             setHint('详情页标题太短', 'bad');
             $this->res->red('product/update/' . $product_id);
         }
         if (strlen($keywords) < 5) {
             setHint('详情页关键字太短', 'bad');
             $this->res->red('product/update/' . $product_id);
         }
         if (strlen($description) < 5) {
             setHint('详情页描述太短', 'bad');
             $this->res->red('product/update/' . $product_id);
         }
         $result = $this->load->model('product')->update($arr);
         $img_id_arr = explode(',', $img_id);
         $imgobj = $this->load->model('img');
         foreach ($img_id_arr as $key => $value) {
             $imgobj->updateProductid((int) $value, (int) $product_id);
         }
         setHint('更新商品成功');
         //这里无法判断是否真的成功,因为用户可能只更新了img表
         $this->res->red('product');
     }
 }
コード例 #15
0
ファイル: home.php プロジェクト: jinghuizhai/ida
 function register($args)
 {
     $post = $this->req->post;
     if (count($post)) {
         $phone = $post['phone'];
         $pass = $post['pass'];
         $code = $post['code'];
         $sms = $post['sms'];
         $name = $post['name'];
         // return var_dump($post);
         if (empty($this->session->data['invitationcode'])) {
             setHint('对不起,不通过邀请链接不能注册');
             $this->res->redirect('home/register');
         }
         if (!validate('pass', $pass)) {
             setHint('密码不符合要求');
             $this->res->redirect('home/register');
         }
         if (!validate('code', $code)) {
             setHint('验证码格式不正确');
             $this->res->redirect('home/register');
         }
         if ($this->session->data['validatecode'] != $code) {
             setHint('验证码不正确');
             $this->res->redirect('home/register');
         }
         if (!validate('sms', $sms)) {
             setHint('短信验证码格式不正确');
             $this->res->redirect('home/register');
         }
         if (!validate('name', $name)) {
             setHint('姓名必须为2~4个中文字符');
             $this->res->redirect('home/register');
         }
         if (empty($this->session->data['smscode'])) {
             setHint('您没有获取短信验证码');
             $this->res->redirect('home/register');
         }
         if ($this->session->data['smscode'] != $sms) {
             setHint('短信验证码不正确');
             $this->res->redirect('home/register');
         }
         $user = $this->load->model('user');
         $link = $user->findByLink($this->session->data['invitationcode']);
         if (!$link) {
             setHint('对不起,邀请链接不合法', 'bad');
             $this->res->redirect('home/register');
         }
         $euser = $user->findByPhone($phone);
         if ($euser) {
             setHint('对不起,手机号已经被注册', 'bad');
             $this->res->redirect('home/register');
         }
         $arr = array("phone" => $phone, "pass" => md5($pass), 'name' => $name, 'can_cashout' => 1, 'date' => timenow());
         $tag = $link['tag'];
         if ($tag == 'sale') {
             //添加代理
             $role_id = (int) $this->load->model('role')->findByTag('agent')["role_id"];
             $arr['role_id'] = $role_id;
             $arr['branch_id'] = (int) $link['branch_id'];
             $arr['sale_id'] = (int) $link['user_id'];
             $arr['agent_id'] = 0;
             $arr['subagent_id'] = 0;
             $arr['p_id'] = 0;
         } else {
             if ($tag == 'agent') {
                 //添加分代理
                 $role_id = (int) $this->load->model('role')->findByTag('subagent')["role_id"];
                 $arr['role_id'] = $role_id;
                 $arr['branch_id'] = (int) $link['branch_id'];
                 $arr['sale_id'] = (int) $link['sale_id'];
                 $arr['agent_id'] = (int) $link['user_id'];
                 $arr['subagent_id'] = 0;
                 $arr['p_id'] = 0;
             } else {
                 if ($tag == 'subagent') {
                     //添加会员
                     $role_id = (int) $this->load->model('role')->findByTag('member')["role_id"];
                     $arr['role_id'] = $role_id;
                     $arr['branch_id'] = (int) $link['branch_id'];
                     $arr['sale_id'] = (int) $link['sale_id'];
                     $arr['agent_id'] = (int) $link['agent_id'];
                     $arr['subagent_id'] = (int) $link['user_id'];
                     $arr['p_id'] = 0;
                 } else {
                     if ($tag == 'member') {
                         //添加介绍会员
                         $role_id = (int) $this->load->model('role')->findByTag('member')["role_id"];
                         $arr['role_id'] = $role_id;
                         $arr['branch_id'] = (int) $link['branch_id'];
                         $arr['sale_id'] = (int) $link['sale_id'];
                         $arr['agent_id'] = (int) $link['agent_id'];
                         $arr['subagent_id'] = (int) $link['subagent_id'];
                         $arr['p_id'] = (int) $link['user_id'];
                     } else {
                         setHint('您的链接不合法', 'bad');
                         $this->res->redirect('home/register');
                     }
                 }
             }
         }
         $result = $user->add($arr);
         if ($result) {
             $lastId = (int) $this->db->lastId();
             $randcode = randImgName(25);
             $link = $randcode . 'u' . $lastId;
             $update = $user->updateLink(array('user_id' => $lastId, 'link' => $link, 'linkimg' => $link . '.png', 'logoimg' => $link . "logo.png"));
             if ($update) {
                 createQcode(HOSTNAME . 'home/register/' . $link, $link, 'logo.png', QCODE, 7);
             }
             setHint('注册成功');
             //为用户生成积分账号
             $this->load->model('amount')->add(array('user_id' => $lastId, 'money' => 0, 'score' => 0));
             $newuser = $user->findById($lastId);
             if (!empty($newuser['permission'])) {
                 $newuser['permission'] = unserialize($newuser['permission']);
             } else {
                 $newuser['permission'] = array();
             }
             $this->session->data['user'] = $newuser;
             $this->session->data['validatecode'] = null;
             $this->session->data['smscode'] = null;
             $this->res->redirect('user/dashboard');
         } else {
             setHint('注册失败', "bad");
         }
         //无论注册成功失败,都重置关于验证码的session
         $this->session->data['validatecode'] = null;
         $this->session->data['smscode'] = null;
         $this->res->redirect('home/register');
     } else {
         if (!empty($args[0])) {
             $this->session->data['invitationcode'] = $args[0];
         }
         $catalogs = $this->load->model('catalog')->findFirst();
         return $this->load->view('register', array('invitationcode' => $this->session->data['invitationcode'], 'catalogs' => $catalogs));
     }
 }