示例#1
0
 /**
  * 首页
  */
 public function index()
 {
     $uid = (int) $this->input->get('uid');
     if ($uid) {
         $this->_space($uid);
         // 带会员uid参数时进入会员空间界面
     } else {
         // 登录验证
         $url = MEMBER_URL . SELF . '?c=login&m=index&backurl=' . urlencode(dr_now_url());
         if (!$this->uid) {
             $this->member_msg(lang('m-039') . $this->member_model->logout(), $url);
         }
         /*
         $total = array();
         // 会员模块统计
         $module = $this->get_module(SITE_ID);
         if ($module) {
             $db = $this->site[SITE_ID];
             foreach ($module as $dir => $m) {
                 if (!$this->_module_post_catid($m)) {
                     continue;
                 }
                 $total['name'][] = '"'.$m['name'].'"';
                 $total['total'][] = $db->where('uid', $this->uid)->count_all_results(SITE_ID.'_'.$dir.'_index');
             }
             $total['name'] = @implode(',', $total['name']);
             $total['total'] = @implode(',', $total['total']);
         }
         */
         // 消息提醒
         $notice = array();
         $new_notice = $this->db->where('uid', $this->uid)->count_all_results('member_new_notice');
         if ($new_notice) {
             // 统计未读短消息
             if ($total = $this->db->where('uid', $this->uid)->where('isnew', 1)->count_all_results('pm_members')) {
                 $notice[] = array('name' => '短消息', 'url' => dr_member_url('pm/index'), 'total' => $total);
             }
             // 统计未读系统提醒
             if ($total = $this->db->where('uid', $this->uid)->where('type', 1)->where('isnew', 1)->count_all_results('member_notice_' . (int) $this->member['tableid'])) {
                 $notice[] = array('name' => '系统提醒', 'url' => dr_member_url('notice/index'), 'total' => $total);
             }
             // 统计未读会员提醒
             if ($total = $this->db->where('uid', $this->uid)->where('type', 2)->where('isnew', 1)->count_all_results('member_notice_' . (int) $this->member['tableid'])) {
                 $notice[] = array('name' => '会员互动', 'url' => dr_member_url('notice/member'), 'total' => $total);
             }
             // 统计未读模块提醒
             if ($total = $this->db->where('uid', $this->uid)->where('type', 3)->where('isnew', 1)->count_all_results('member_notice_' . (int) $this->member['tableid'])) {
                 $notice[] = array('name' => '模块提醒', 'url' => dr_member_url('notice/module'), 'total' => $total);
             }
             // 统计未读应用提醒
             if ($total = $this->db->where('uid', $this->uid)->where('type', 4)->where('isnew', 1)->count_all_results('member_notice_' . (int) $this->member['tableid'])) {
                 $notice[] = array('name' => '应用提醒', 'url' => dr_member_url('notice/app'), 'total' => $total);
             }
         }
         $this->template->assign(array('notice' => $notice, 'loginlog' => array_reverse(dr_string2array($this->member['loginlog'])), 'meta_name' => lang('m-012'), 'invite_url' => MEMBER_URL . 'index.php?c=register&uid=' . $this->uid . '&invite=' . $this->member['username'], 'new_notice' => $new_notice));
         $this->template->display(IS_AJAX ? 'main.html' : 'index.html');
     }
 }
示例#2
0
 /**
  * 构造函数
  */
 public function __construct()
 {
     parent::__construct();
     $this->load->model('sns_model');
     $this->callback = isset($_GET['callback']) ? $_GET['callback'] : '';
     if (!$this->uid) {
         // 会员未登录验证
         if (!$this->callback) {
             if (IS_AJAX) {
                 exit(lang('m-039'));
             }
             $this->member_msg(lang('m-039') . $this->member_model->logout(), MEMBER_URL . SELF . '?c=login&m=index&backurl=' . urlencode(dr_now_url()));
         } else {
             exit($this->callback . '(' . json_encode(array('html' => lang('m-039'))) . ')');
         }
     }
 }
示例#3
0
 /**
  * 首页
  */
 public function index()
 {
     $uid = (int) $this->input->get('uid');
     if ($uid) {
         $this->_space($uid);
         // 带会员uid参数时进入会员空间界面
     } else {
         // 识别会员空间二级域名
         $space_domain = $this->get_cache('member', 'setting', 'space', 'spacedomain');
         if ($space_domain) {
             $host = strtolower($_SERVER['HTTP_HOST']);
             // 当前网站的域名
             $member_domain = $this->get_cache('member', 'setting', 'domain', SITE_ID);
             // 当前站点会员中心的域名
             $uid = $this->_get_space_uid($host, $space_domain);
             // 获取到的会员uid
             if (!$uid && $member_domain && $host != $domain) {
                 // 当前域名和会员中心域名不一样时
                 $this->member_msg('此域名【' . $host . '】未生效');
             } elseif (!$uid && $member_domain && $member_domain != SITE_DOMAIN) {
                 // 当前域名和网站域名不一致时
                 $this->member_msg('此域名【' . $host . '】未生效');
             }
             if ($uid) {
                 $this->_space($uid, 1);
                 // 带会员uid参数时进入会员空间界面
                 exit;
             }
         }
         // 开启伪静态时的获取uid方式
         if (!$uid && preg_match('/\\/([0-9]+)\\/index\\.php/iU', $_SERVER['REQUEST_URI'], $match)) {
             $this->_space(intval($match[1]));
         }
         // 登录验证
         $url = MEMBER_URL . SELF . '?c=login&m=index&backurl=' . urlencode(dr_now_url());
         if (!$this->uid) {
             $this->member_msg(lang('m-039') . $this->member_model->logout(), $url);
         }
         $this->template->assign(array('notice' => $this->_notice(), 'invite' => dr_get_invite($this->uid, 'username'), 'meta_name' => lang('m-012'), 'invite_url' => MEMBER_URL . 'index.php?c=register&uid=' . $this->uid . '&invite=' . $this->member['username'], 'new_notice' => $new_notice));
         $this->template->display(IS_AJAX ? 'main.html' : 'index.html');
     }
 }
示例#4
0
 /**
  * 后台登录判断,返回当前登录用户信息
  *
  * @return void
  */
 protected function is_admin_login()
 {
     if (IS_ADMIN && ($this->router->class == 'login' || $this->router->class == 'api')) {
         return FALSE;
     }
     $uid = (int) $this->session->userdata('uid');
     $admin = (int) $this->session->userdata('admin');
     if ($this->uid == FALSE || $uid != $this->uid || $admin != $uid) {
         if (IS_AJAX) {
             exit('<img src=' . SITE_URL . 'member/statics/js/skins/icons/error.png>' . lang('040'));
         }
         if (IS_ADMIN) {
             redirect(SITE_URL . dr_url('login/index', array('backurl' => urlencode(dr_now_url()))), 'refresh');
         }
         return FALSE;
     }
     $data = $this->member_model->get_admin_member($this->uid, 1);
     if (!is_array($data)) {
         if (IS_ADMIN) {
             if ($data == 0) {
                 IS_AJAX ? exit(dr_json(0, '<img src=' . SITE_URL . 'member/statics/js/skins/icons/error.png>' . lang('043'))) : $this->admin_msg(lang('043'));
             } elseif ($data == -3) {
                 IS_AJAX ? exit(dr_json(0, '<img src=' . SITE_URL . 'member/statics/js/skins/icons/error.png>' . lang('045'))) : $this->admin_msg(lang('045'));
             } elseif ($data == -4) {
                 IS_AJAX ? exit(dr_json(0, '<img src=' . SITE_URL . 'member/statics/js/skins/icons/error.png>' . lang('046'))) : $this->admin_msg(lang('046'));
             }
         } else {
             return $data;
         }
     }
     return $data;
 }
示例#5
0
 /**
  * 确认订单
  */
 protected function _buy()
 {
     // 登录验证
     if (!$this->uid) {
         $this->msg(lang('m-039'), MEMBER_URL . SELF . '?c=login&m=index&backurl=' . urlencode(dr_now_url()));
     }
     // 分析url参数
     $iid = $this->input->get('iid');
     $fid = $this->input->get('fid');
     $num = $this->input->get('num');
     if (!$iid) {
         $this->member_msg(lang('my-01'));
     }
     if ($this->is_num && !$num) {
         $this->member_msg(lang('my-02'));
     }
     // 组装订单数据
     $_iid = explode(',', $iid);
     $_num = explode(',', $num);
     $_fid = $fid ? explode(',', $fid) : 0;
     $data = array();
     foreach ($_iid as $key => $id) {
         if ($id) {
             $data[$key] = array('id' => $id . (isset($_fid[$key]) && $_fid[$key] ? '_' . $_fid[$key] : '_0'), 'qty' => max((int) $_num[$key], 1));
         }
     }
     list($item, $amount) = $this->_format_item($data);
     if (!$item) {
         $this->member_msg(lang('my-03'));
     }
     // 数量不足时提示
     // 按卖家计算运单及总价格
     $list = $jsonp = array();
     foreach ($item as $i => $t) {
         $total = ($t['discount'] ? $t['discount'] : $t['price']) * $t['num'];
         // 计算订单总价格
         $item[$i]['total'] = $total;
         $jsonp[$i] = array('num' => $t['num'], 'total' => $total, 'price' => $t['price'], 'freight' => $t['freight'], 'discount' => $t['discount']);
         $list[] = $item[$i];
     }
     // 付款方式
     $paytype = $this->order_model->get_pay_type();
     // 提交订单
     if (IS_POST) {
         // 验证码验证
         if ($this->mconfig['code'] && !$this->check_captcha('code')) {
             $this->member_msg(lang('m-000'));
         }
         $pay = $this->input->post('pay');
         $post = $this->input->post('data');
         $ptid = (int) $post['ptid'];
         $score = (int) $post['score'];
         // 付款方式不存在
         if (!$ptid || !isset($paytype[$ptid])) {
             $this->member_msg(lang('my-42'));
         }
         // 没有选择在线支付方式
         if ($ptid == 2 && !$pay) {
             $this->member_msg(lang('my-52'));
         }
         // 支持运费时才验证收货地址
         if ($this->is_freight) {
             if (!$post['address']) {
                 $this->member_msg(lang('my-05'));
             }
             // 收货地址不存在
             $address = $this->db->where('id', (int) $post['address'])->where('uid', $this->uid)->get('member_address')->row_array();
             if (!$address) {
                 $this->member_msg(lang('my-05'));
             }
             // 收货地址不存在
         }
         // 重新计算总价
         list($price, $total, $freight) = $this->order_model->get_price($jsonp, $score);
         // 更新至订单表中
         $id = $this->order_model->add_order(array('uid' => $this->uid, 'ptid' => $ptid, 'city' => isset($address['city']) ? $address['city'] : '', 'name' => isset($address['name']) ? $address['name'] : '', 'score' => $score, 'price' => $total, 'items' => dr_array2string($list), 'phone' => isset($address['phone']) ? $address['phone'] : '', 'gbook' => isset($post['gbook']) ? $post['gbook'] : '', 'status' => 1, 'zipcode' => isset($address['zipcode']) ? $address['zipcode'] : '', 'address' => isset($address['address']) ? $address['address'] : '', 'freight' => $freight, 'sendnote' => '', 'sendtime' => 0, 'username' => $this->member['username'], 'inputtime' => SYS_TIME, 'successtime' => 0));
         if (!$id) {
             $this->member_msg(lang('my-06'));
         }
         // 订购失败
         // 清空购物车
         $this->cart->destroy();
         // 付款
         list($msg, $url, $code) = $this->order_model->pay($ptid, $id, $total, $pay);
         //
         $this->member_msg($msg, $url, $code);
     } else {
         $data = $this->get_cache('member', 'setting', 'pay');
         if ($data) {
             foreach ($data as $i => $t) {
                 if (!$t['use'] || !is_dir(FCPATH . 'member/pay/' . $i . '/')) {
                     unset($data[$i]);
                 }
             }
         }
         $this->template->assign(array('list' => $list, 'jsonp' => dr_array2string($jsonp), 'online' => $data, 'iscode' => $this->mconfig['code'], 'paytype' => $paytype, 'address' => $this->is_freight ? $this->db->where('uid', $this->uid)->order_by('default desc')->get('member_address')->result_array() : NULL, 'meta_title' => lang('my-07') . (SITE_SEOJOIN ? SITE_SEOJOIN : '_') . MODULE_NAME));
         $this->template->display('buy.html');
     }
 }