public function _initialize() { /* 获取用户ID */ define('UID', is_login()); /* 判断是否登录 */ if (!UID) { $this->redirect('Public/login'); } /* 判断是否为超级管理员 */ define('IS_ROOT', is_administrator()); /* 检测访问权限 */ $access = $this->accessControl(); if ($access === false) { R('Empty/index'); } elseif ($access === NULL) { /* 检测分类栏目有关的各项动态权限 */ $dynamic = $this->checkDynamic(); if ($dynamic === NULL) { /* 检测非动态权限 */ $rule = strtolower(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME); if (!$this->checkRule($rule)) { R('Empty/index'); } } elseif ($dynamic === false) { R('Empty/index'); } } }
/** * 首页 */ public function index() { $pic_name[] = "http://coollive.labake.cn/public/data/images/coollive/img20150320-8746-y01jkz.jpg?1426860004"; $pic_name[] = "http://coollive.labake.cn/public/data/images/coollive/163623_photo.jpg?1427077663"; $pic_name[] = "http://coollive.labake.cn/public/data/images/coollive/641675_photo.jpg?1399943906"; $pic_name[] = "http://coollive.labake.cn/public/data/images/coollive/163602_photo.jpg?1426959397"; $pic_name[] = "http://coollive.labake.cn/public/data/images/coollive/355294_photo.jpg?1352336813"; $pic_name[] = "http://coollive.labake.cn/public/data/images/coollive/922025_photo.jpg?1420255388"; $pic_name[] = "http://coollive.labake.cn/public/data/images/coollive/img20150221-26754-1f34xst.jpg?1424564067"; $pic_name[] = "http://coollive.labake.cn/public/data/images/coollive/648047_photo.jpg?1416532039"; if (is_login()) { $this->home(); } else { $this->load->model('live_programs_model', 'live_m'); /*+++++++++++++++++++++++++++++++列表数据++++++++++++++++++++++++++*/ //酷Live精选 $new_programes = $this->live_m->get_best_programs(1, 10); foreach ($new_programes as $k => $v) { if ($v['is_live'] == 1) { $new_programes[$k]['pic_name'] = $pic_name[$k]; } else { $new_programes[$k]['pic_name'] = "/public/data/images/video/cut/187x140_" . $v['pic_name']; } } $this->data['new_programes'] = $this->new_programes($new_programes); /*+++++++++++++++++++++++++++++++列表数据结束++++++++++++++++++++++++++*/ $this->load->view('spree/index.tpl', $this->data); } }
/** * 后台控制器初始化 */ protected function _initialize() { // 获取当前用户ID define('UID', is_login()); if (!UID) { // 还没登录 跳转到登录页面 $this->redirect('Public/login'); } // 是否是超级管理员 define('IS_ROOT', is_administrator()); if (!IS_ROOT && C('ADMIN_ALLOW_IP')) { // 检查IP地址访问 if (!in_array(get_client_ip(), explode(',', C('ADMIN_ALLOW_IP')))) { $this->error('403:禁止访问'); } } // 检测访问权限 $access = $this->accessControl(); if ($access === false) { $this->error('403:禁止访问'); } elseif ($access === null) { $dynamic = $this->checkDynamic(); //检测分类栏目有关的各项动态权限 if ($dynamic === null) { //检测非动态权限 $rule = strtolower(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME); if (!$this->checkRule($rule, array('in', '1,2'))) { $this->error('未授权访问!'); } } elseif ($dynamic === false) { $this->error('未授权访问!'); } } $this->assign('__MENU__', $this->getMenus()); }
/** * 数据表前缀 * @var string */ public function getfaceid($uid) { if (!$uid) { $uid = is_login(); } return $this->where("id='{$uid}'")->getField("face"); }
public function attach($id) { $uid = is_login(); $where = array('project_id' => $id, 'investor_id' => $uid); $data = $this->field('status')->where($where)->find(); $status = 1; if ($data) { $status = $data['status'] ? 0 : 1; if ($status) { M('Project')->where(array('id' => $id))->setInc('like_record'); } else { M('Project')->where(array('id' => $id))->setDec('like_record'); } $save = array('status' => $status, 'attach_time' => NOW_TIME, 'update_time' => NOW_TIME, 'update_id' => $id); $this->where($where)->save($save); } else { $save = array('project_id' => $id, 'attach_time' => NOW_TIME, 'investor_id' => $uid, 'status' => 1, 'create_time' => NOW_TIME, 'create_id' => $id, 'update_time' => NOW_TIME, 'update_id' => $id); $this->add($save); } $proj = M('Project')->where('id=' . $id)->field('uid,project_name')->find(); $link = '<a href="' . U('Project/detail?id=' . $id) . '">《' . $proj['project_name'] . '》</a>'; $ulink = '<a href="' . U('MCenter/profile?id=' . $uid) . '">' . get_membername($uid) . '</a>'; if ($status) { D('ProjectDynamic')->addDynamic($id, '收藏了' . $link . '项目。', 1); //用户(关注)动态 // 项目方(收藏提示)消息 D('Message')->send(0, $proj['uid'], '', $ulink . '收藏了您的' . $link . '项目。', 3); } else { M('ProjectDynamic')->where(array('project_id' => $id, 'create_id' => $uid, 'type' => 1))->delete(); // 项目方(收藏提示)消息 D('Message')->send(0, $proj['uid'], '', $ulink . '取消收藏了您的' . $link . '项目。', 3); } return $status; }
/** * 注:appname及之后的参数,一般情况下无需填写 * @param $to_uid 接受消息的用户ID * @param string $content 内容 * @param string $title 标题,默认为 您有新的消息 * @param $url 链接地址,不提供则默认进入消息中心 * @param int $from_uid 发起消息的用户,根据用户自动确定左侧图标,如果为用户,则左侧显示头像 * @param int $type 消息类型,0系统,1用户,2应用 * @param string $appname 应用名,默认不需填写,如果填写了就必须实现对应的消息处理模型,例如贴吧里面可以基于某个回复开启聊天 * @param string $apptype 同上,应用里面的一个标识符 * @param int $source_id 来源ID,通过来源ID获取基于XX聊天的来源信息 * @param int $find_id 查找ID,通过查找ID获得标识ID * @return int * @auth 陈一枭 */ public function sendMessage($to_uid, $content = '', $title = '您有新的消息', $url, $from_uid = 0, $type = 0, $appname = '', $apptype = '', $source_id = 0, $find_id = 0) { if ($to_uid == is_login()) { return 0; } $this->sendMessageWithoutCheckSelf($to_uid, $content, $title, $url, $from_uid, $type, $appname, $apptype, $source_id, $find_id); }
/** * 后台控制器初始化 */ protected function _initialize() { // 获取当前用户ID if (defined('UID')) { return; } define('UID', is_login()); if (!UID) { // 还没登录 跳转到登录页面 $this->redirect('Public/login'); } /* 读取数据库中的配置 */ $config = S('DB_CONFIG_DATA'); if (!$config) { $config = D('Config')->lists(); S('DB_CONFIG_DATA', $config); } C($config); //添加配置 // 是否是超级管理员 define('IS_ROOT', is_administrator()); if (!IS_ROOT && C('ADMIN_ALLOW_IP')) { // 检查IP地址访问 if (!in_array(get_client_ip(), explode(',', C('ADMIN_ALLOW_IP')))) { $this->error('403:禁止访问'); } } }
public function flow2() { if (!is_login()) { cookie('__forward__', __SELF__); $this->error('请先登录', U('Member/login')); return; } if (IS_POST) { $order_model = D('OrderInfo'); if ($order_model->addOrder()) { $this->redirect('flow3'); } else { $this->error('下单失败,请稍后再试'); } } else { //用户地址列表 $this->assign('address_list', D('Address')->getAddList()); //获取支付方式 $this->assign('pay_list', D('Setting')->getPayList()); //获取配送方式 $this->assign('transport_list', D('Setting')->getTransportList()); //取出购物车里面的内容 $this->assign('car_list', D('ShoppingCar')->getCar()); $this->display(); } }
/** * 根据book表的role_ids字段判断用户有无阅读权限 * @param $role_ids * @return int * @author 郑钟良<*****@*****.**> */ function check_read_auth($role_ids) { if ($role_ids == '') { return 2; //无需权限 } if (!is_array($role_ids)) { $role_ids = str_replace('[', '', $role_ids); $role_ids = str_replace(']', '', $role_ids); $role_ids = explode(',', $role_ids); } if (!count($role_ids)) { return 2; //无需权限 } $map['role_id'] = array('in', $role_ids); $map['uid'] = is_login(); $map['status'] = 1; if (D('UserRole')->where($map)->count()) { return 1; //有权限阅读 } else { return 0; //无权限阅读 } }
public function render($uid = 0, $page = 1, $tab = null, $count = 10) { !$uid && ($uid = is_login()); //查询条件 $map['uid'] = $uid; $NewsModel = new NewsModel(); /* 获取当前分类下资讯列表 */ if ($uid != is_login()) { $map['status'] = 1; $map['dead_line'] = array('gt', time()); } list($list, $totalCount) = $NewsModel->getListByPage($map, $page, 'update_time desc', '*', $count); foreach ($list as &$val) { if ($val['status'] == 1) { $val['audit_status'] = '<span style="color: green;">审核通过</span>'; } elseif ($val['status'] == 2) { $val['audit_status'] = '<span style="color:#4D9EFF;">待审核</span>'; } elseif ($val['status'] == -1) { $val['audit_status'] = '<span style="color: #b5b5b5;">审核失败</span>'; } } unset($val); /* 模板赋值并渲染模板 */ $this->assign('news_list', $list); $this->assign('totalCount', $totalCount); $this->display(T('News@Widget/ucenterblock')); }
/** * 管理员登录 */ public function login() { if (IS_POST) { $adm_id = I('adm_id'); $adm_pw = I('adm_pw'); # 图片验证码校验 if (!$this->check_verify(I('post.verify'))) { $this->error('验证码输入错误!'); } if (!$adm_id) { $this->error('请输入管理员!'); } if (!$adm_pw) { $this->error('请输入密码!'); } $ADM = D('Admin'); $uid = $ADM->login($adm_id, $adm_pw); if (0 < $uid) { $this->redirect('Index/index'); } else { $this->error($ADM->getError()); } } else { if (is_login('Admin')) { $this->error("您已登陆系统", Cookie('__forward__') ?: C('HOME_PAGE')); } $this->meta_title = '管理员登录'; $this->display(); } }
public function __construct() { parent::__construct(); $this->load->helper('admin'); is_login(); //?登陆 //暂时只有后台使用,验证是否允许上传权限 $this->_config = get_config(); $this->base_path = str_replace('\\', '/', FCPATH) . 'public/'; $this->root_url = $this->_config['base_url'] . 'public/'; //设置上传路径 if (isset($_REQUEST['up'])) { //可接受的dir参数值为 <dir>/<dir1>/*** $dir = isset($_GET['dir']) ? trim($_GET['dir']) : 'default'; $this->save_path = 'image/' . $dir; } else { if (isset($_GET['dir']) && isset($this->allow_ext[$_GET['dir']])) { $this->utype = $_GET['dir']; } else { $this->utype = 'image'; } $this->save_path = $this->utype . '/' . date('Y/m/d'); } $this->save_url = $this->_config['base_url'] . 'public/' . $this->save_path; }
/** * 获取所有模块菜单 * @param string $addon_dir * @author jry <*****@*****.**> */ public function getAllMenu() { $uid = is_login(); $user_group = D('Admin/Access')->getFieldByUid($uid, 'group'); // 获得当前登录用户信息 $group_info = D('Admin/Group')->find($user_group); $group_auth = json_decode($group_info['menu_auth'], true); // 获得当前登录用户所属部门的权限列表 // 获取所有菜单 $menu_list = S('MENU_LIST_' . $uid); if (!$menu_list || APP_DEBUG === true) { $con['status'] = 1; $system_module_list = $this->where($con)->order('sort asc, id asc')->select(); $tree = new tree(); $menu_list = array(); foreach ($system_module_list as $key => &$module) { $menu = json_decode($module['admin_menu'], true); $temp = $tree->list_to_tree($menu); $menu_list[$module['name']] = $temp[0]; $menu_list[$module['name']]['id'] = $module['id']; $menu_list[$module['name']]['name'] = $module['name']; } S('MENU_LIST_' . $uid, $menu_list, 3600); // 缓存配置 } return $menu_list; }
public function addLZLReply($post_id, $to_f_reply_id, $to_reply_id, $to_uid, $content, $p, $send_message = true) { //新增一条回复 $data = array('uid' => is_login(), 'post_id' => $post_id, 'to_f_reply_id' => $to_f_reply_id, 'to_reply_id' => $to_reply_id, 'to_uid' => $to_uid, 'content' => $content); $data = $this->create($data); if (!$data) { return false; } $result = $this->add($data); action_log('add_post_reply', 'ForumLzlReply', $result, is_login()); S('post_replylist_' . $post_id, null); S('post_replylzllist_' . $to_f_reply_id, null); $postModel = D('ForumPost'); //增加帖子的回复数 $postModel->where(array('id' => $post_id))->setInc('reply_count'); //更新最后回复时间 $postModel->where(array('id' => $post_id))->setField('last_reply_time', time()); $post = $postModel->find($post_id); D('Forum')->where(array('id' => $post['forum_id']))->setField('last_reply_time', time()); if ($send_message) { $this->sendReplyMessage(is_login(), $post_id, $content, $to_uid, $to_f_reply_id, $result, $p); } $this->handleAt($post_id, $to_f_reply_id, $content, $p, $map); //返回结果 return $result; }
public function drawcash($bankinfo, $notifyurl) { $uid = is_login(); $this->config = C('DRAW_CASH'); $time = NOW_TIME; $tradFlowNo = time_format($time, 'Ymd') . $this->config['MERCHANTID'] . substr(floor(microtime($time) * 1000), -8); //head文件 $head = array('version' => '01', 'type' => '0001', 'channelNo' => 'HM', 'tradDate' => time_format($time, 'Ymd'), 'tradTime' => time_format($time, 'His'), 'tradFlowNo' => $tradFlowNo, 'tradNo' => 'ES0007'); //交易代码 //body文件 $body = array('tranSeqId' => $tradFlowNo, 'merchantNo' => $this->config['MERCHANTID'], 'alias' => $this->config['ALIAS'], 'submitDate' => time_format($time, 'Ymd'), 'isNeedNotify' => '0', 'notifyUrl' => $notifyurl, 'batchUse' => '01', 'bankId' => $bankinfo['bankId'], 'acctNo' => $bankinfo['acctNo'], 'acctName' => $bankinfo['acctName'], 'acctAttribute' => '02', 'bankName' => $bankinfo['bankName'], 'bankProvince' => $bankinfo['bankProvince'], 'bankCity' => $bankinfo['bankCity'], 'cityCode' => '', 'amount' => $bankinfo['amount'], 'currencyType' => 'CNY', 'mobilePhone' => '', 'remark' => ''); $message = array('head' => $head, 'body' => $body); include_once APP_PATH . '/BaoyiPay/BaoyiPay.php'; $xml = to_xmlstring1($message); $mac = md5($xml . $this->config['MERKEY']); $para = array('tradNo' => 'ES0007', 'type' => '0001', 'merchantNo' => $this->config['MERCHANTID'], 'data' => $xml, 'mac' => $mac); // D('AccountLog')->record($head, $xml, $mac, 7); $text = $this->getHttpResponseGet($this->config['DRAW_URL'], $para); $para = md5Response($text, $this->config['MERKEY']); if (!$para) { $this->error('返回信息不正确'); } if ($para['status'] == '000000000') { //提现记录 $drawcashlist = array('pid' => 0, 'bussflowno' => $tradFlowNo, 'amount' => $bankinfo['amount'], 'create_time' => NOW_TIME, 'update_time' => NOW_TIME); M('DrawcashList')->add($drawcashlist); return $tradFlowNo; } else { $this->error($para['statusMsg']); } }
public function todo() { if (!is_login()) { return redirect(site_url('login?url=' . site_url('cart'))); } // 如果购物车为空则返回出错提示 $cart_items = $this->cart->contents(); if (empty($cart_items)) { return redirect(site_url('cart')); } // 添加订单 $order = array('user_id' => current_user()->id, 'subject' => '', 'status' => 0, 'total' => $this->cart->total()); // 添加订单详情 $order_subject = array(); $order_details = array(); foreach ($this->cart->contents() as $items) { $order_subject[] = $items['name']; $detail = array('user_id' => current_user()->id, 'price' => $items['price'], 'quantity' => $items['qty'], 'name' => $items['name'], 'goods_type' => $items['goods_type'], 'goods_id' => $items['goods_id'], 'url' => $items['url']); $order_details[] = $detail; } $order['subject'] = join(' / ', $order_subject); $this->load->model('Order_model', 'order'); $order_obj = $this->order->create($order, $order_details); // 清除购物车 $this->cart->destroy(); // 到支付宝支付,应该还有一个确认订单的过程 $this->load->model('alipay_model', 'alipay'); header("content-Type: text/html; charset=Utf-8"); $alipay_form = array('order_id' => $order_obj->id, 'subject' => $order_obj->subject, 'body' => '', 'show_url' => site_url('orders/' . $order_obj->id), 'price' => $order_obj->total); echo $this->alipay->build_form($alipay_form); // 还应该配置收货地址等,这样用户不用在支付宝去做这个事情了(用户支付宝就用地址?) }
/** * 新增和修改地址 * @return boolean */ public function addAddress() { $userinfo = is_login(); if ($this->data['is_default']) { $this->where(array('member_id' => $userinfo['id']))->setField('is_default', 0); } $this->data['member_id'] = $userinfo['id']; $id = $this->data['id']; //如果表单中的id值不为空,表示是修改 if ($this->data['id']) { if ($this->save() !== false) { return $id; } else { return false; } } else { //如果表单中id值为空,表示是新增,并且把id删除 unset($this->data['id']); if (($id = $this->add()) !== false) { return $id; } else { return false; } } }
function _initialize() { //模板初始化 C('DEFAULT_THEME', session('DEFAULT_THEME')); $token = get_token(); $param = array('lists', 'config', 'nulldeal'); if (in_array(_ACTION, $param) && (empty($token) || $token == '-1')) { $url = U('Public/lists?from=2'); redirect($url); } // 管理员需要对插件的管理权限进行判断 if (is_login()) { $token_status = D('Common/AddonStatus')->getList(false); if ($token_status[_ADDONS] == -1) { $this->error('你没有权限管理和配置该插件'); } return true; } C('EDITOR_UPLOAD.rootPath', './Uploads/Editor/' . $token . '/'); if ($GLOBALS['is_wap']) { // 默认错误跳转对应的模板文件 C('TMPL_ACTION_ERROR', 'Addons:dispatch_jump_mobile'); // 默认成功跳转对应的模板文件 C('TMPL_ACTION_SUCCESS', 'Addons:dispatch_jump_mobile'); } else { $this->_nav(); } }
function groundup_new_user_cookie() { // start a new session to track new visits expires after 30 minutes session_start(); if (isset($_SESSION['last_activity']) && time() - $_SESSION['last_activity'] > 1800) { // last request was more than 30 minutes ago session_unset(); // unset $_SESSION variable for the run-time session_destroy(); // destroy session data in storage } $_SESSION['last_activity'] = time(); // update last activity time stamp if (!isset($_SESSION['new_user_check'])) { $_SESSION['new_user_check'] = '1'; if (!is_admin() && !is_login() && !is_register()) { if (!isset($_COOKIE['new_user'])) { $visit = 0; } else { $visit = $_COOKIE['new_user'] + 1; } setcookie('new_user', $visit, time() + 3600 * 24 * 100, '/', COOKIE_DOMAIN, false); } } }
public function beAdmin() { if (!is_login()) { $this->error(L('_ERROR_PLEASE_LOGIN_BEFORE_APPLY_') . L('_PERIOD_')); } $this->checkAuth(null, -1, L('_INFO_AUTHORITY_LACK_FOR_PRESENTER_')); $tid = I('tid', 0, 'intval'); $topicModel = D('Topic'); $topic = $topicModel->find($tid); if ($topic) { if ($topic['uadmin']) { //已经存在管理员 $this->error(L('_FAIL_APPLY_') . L('_PERIOD_')); } else { if (is_administrator() || check_auth('Weibo/Topic/beAdmin')) { $topic['uadmin'] = is_login(); $result = $topicModel->save($topic); if ($result) { $this->success(L('_SUCCESS_BECOME_PRESENTER_') . L('_PERIOD_'), 'refresh'); } else { $this->error(L('_FAIL_OPERATION_') . L('_PERIOD_')); } } else { $this->error(L('_ERROR_AUTHORITY_LACK_FOR_APPLY_PRESENTER_') . L('_PERIOD_')); } } } else { $this->error(L('_ERROR_TOPIC_INEXISTENT_') . L('_PERIOD_')); } }
public function beAdmin() { if (!is_login()) { $this->error('必须先登录才能申请成为主持人。'); } $this->checkAuth(null, -1, '没有权限成为主持人'); $tid = I('tid', 0, 'intval'); $topicModel = D('Topic'); $topic = $topicModel->find($tid); if ($topic) { if ($topic['uadmin']) { //已经存在管理员 $this->error('已经有人捷足先登了呢。申请没有成功。'); } else { if (is_administrator() || check_auth('Weibo/Topic/beAdmin')) { $topic['uadmin'] = is_login(); $result = $topicModel->save($topic); if ($result) { $this->success('恭喜,您已抢先成为本话题的主持人。', 'refresh'); } else { $this->error('抱歉,操作失败。可能是数据库原因导致。请联系管理员。'); } } else { $this->error('抱歉,您无权申请成为话题主持人。'); } } } else { $this->error('抱歉,此话题不存在。'); } }
/** * 前台台控制器初始化 */ protected function _initialize() { // plugin('Fangke'); /* 读取数据库中的配置 */ $config = F('DB_CONFIG_DATA'); if (!$config || APP_DEBUG) { $config = api('Config/lists'); F('DB_CONFIG_DATA', $config); } C($config); //添加配置 C('TMPL_PARSE_STRING', array('__STATIC__' => __ROOT__ . '/Public/Static', '__IMG__' => __ROOT__ . '/Public/' . MODULE_NAME . '/' . C('DEFAULT_THEME') . '/images', '__CSS__' => __ROOT__ . '/Public/' . MODULE_NAME . '/' . C('DEFAULT_THEME') . '/css', '__JS__' => __ROOT__ . '/Public/' . MODULE_NAME . '/' . C('DEFAULT_THEME') . '/js')); defined('__DB_PREFIX__') or define('__DB_PREFIX__', C('DB_PREFIX')); defined('UID') or define('UID', is_login()); if (C('WEB_SITE_CLOSE') && UID != 1) { $this->show('网站维护中请稍后访问'); die; } $str = run_plugin_method('Spider', 'addinfo'); //var_dump($config); if (UID) { //登陆的情况 //赋值当前登陆用户信息 $uinfo = session('uinfo'); $map[get_account_type($uinfo['username'])] = $uinfo['username']; $jin = __DB_PREFIX__ . "member_group as a on " . __DB_PREFIX__ . "member.member_group_id=a.member_group_id"; $field = "*," . __DB_PREFIX__ . "member.status as status"; $user = D('Member')->field($field)->where($map)->join($jin)->find(); session('uinfo', $user); $this->assign('uinfo', $user); } }
/** * @param $path string 例如 Travel/detail/12 * @param $uid int 评论给谁? * @author caipeichao */ public function localComment($param) { $path = $param['path']; //获取参数 $aPath = explode('/', $path); $app = $aPath[0]; $mod = $aPath[1]; $row_id = $aPath[2]; $count = modC($mod . '_LOCAL_COMMENT_COUNT', 10, $app); //调用接口获取评论列表 $list = $this->getCommentList($app, $mod, $row_id, 1, $count); $total_count = $this->getCommentCount($app, $mod, $row_id); //增加用户信息 foreach ($list as &$e) { $e['user'] = query_user(array('uid', 'avatar32', 'nickname', 'space_url'), $e['uid']); } unset($e); $pageCount = ceil($total_count / $count); $pageHtml = getPageHtml('local_comment_page', $pageCount, array('app' => $app, 'mod' => $mod, 'row_id' => $row_id), 1); //显示页面 $can_guest = modC($mod . '_LOCAL_COMMENT_CAN_GUEST', 1, $app); $this->assign('can_guest', $can_guest); $this->assign('pageHtml', $pageHtml); $this->assign('list', $list); $this->assign('total_count', $total_count); $this->assign('count', $count); $this->assign('app', $app); $this->assign('mod', $mod); $this->assign('row_id', $row_id); $this->assign($param); $this->assign('myInfo', query_user(array('avatar32', 'nickname', 'uid', 'space_url'), is_login())); $this->display('comment'); }
/** * 用户信息初始化 * @access private * @return void */ private function initUser() { if (!D('UserUser')->isLogged()) { return false; } $this->uid = is_login(); }
/** * send_comment_message 发送评论消息 * @param $uid * @param $weibo_id * @param $message * @author:xjw129xjt(肖骏涛) xjt@ourstu.com */ function send_comment_message($uid, $weibo_id, $message) { $title = '评论消息'; $from_uid = is_login(); $type = 1; D('Common/Message')->sendMessage($uid, $title, $message, 'Weibo/Index/weiboDetail', array('id' => $weibo_id), $from_uid, $type); }
/** * 登陆后回调地址 * autor:xjw129xjt */ public function callback() { $code = I('get.code'); $type = I('get.type'); $is_login = is_login(); $sns = \ThinkOauth::getInstance($type); //腾讯微博需传递的额外参数 $extend = null; if ($type == 'tencent') { $extend = array('openid' => I('get.openid'), 'openkey' => I('get.openkey')); } $token = $sns->getAccessToken($code, $extend); session('SYNCLOGIN_TOKEN', $token); session('SYNCLOGIN_TYPE', $type); session('SYNCLOGIN_OPENID', $token['openid']); session('SYNCLOGIN_ACCESS_TOKEN', $token['access_token']); $check = D('sync_login')->where("`type_uid`='" . $token['openid'] . "' AND type='" . $type . "'")->select(); $addon_config = get_addon_config('SyncLogin'); if ($is_login) { $this->dealIsLogin($is_login); } else { if ($addon_config['bind'] && !$check) { redirect(addons_url('SyncLogin://Base/bind')); } else { $this->unbind(); } } }
public function getAvatar($uid = 0, $size = 256) { $avatar = D('avatar')->where(array('uid' => $uid, 'status' => 1, 'is_temp' => 0))->find(); if ($avatar) { if ($avatar['driver'] == 'local') { $avatar_path = "/Uploads/Avatar" . $avatar['path']; return $this->getImageUrlByPath($avatar_path, $size); } else { $new_img = $avatar['path']; $name = get_addon_class($avatar['driver']); if (class_exists($name)) { $class = new $name(); if (method_exists($class, 'thumb')) { $new_img = $class->thumb($avatar['path'], $size, $size); } } return $new_img; } } else { //如果没有头像,返回默认头像 if ($uid == session('temp_login_uid') || $uid == is_login()) { $role_id = session('temp_login_role_id') ? session('temp_login_role_id') : get_role_id(); } else { $role_id = query_user('show_role', $uid); } return $this->getImageUrlByRoleId($role_id, $size); } }
/** * callback 登陆后回调地址 * @author:xjw129xjt(肖骏涛) xjt@ourstu.com */ public function callback() { $code = I('get.code'); $type = I('get.type'); $is_login = is_login(); $sns = \ThinkOauth::getInstance($type); //腾讯微博需传递的额外参数 $extend = null; if ($type == 'tencent') { $extend = array('openid' => I('get.openid'), 'openkey' => I('get.openkey')); } $token = $sns->getAccessToken($code, $extend); if (empty($token)) { $this->error('参数错误'); } $session = array('TOKEN' => $token, 'TYPE' => $type, 'OPENID' => $token['openid'], 'ACCESS_TOKEN' => $token['access_token']); session('SYNCLOGIN', $session); if ($is_login) { $this->dealIsLogin($is_login); } else { $addon_config = get_addon_config('SyncLogin'); $check = $this->checkIsSync(array('type_uid' => $token['openid'], 'type' => $type)); if ($addon_config['bind'] && !$check) { redirect(addons_url('SyncLogin://Base/bind')); } else { $this->unBind(); } } }
public function login($username = null, $password = null, $verify = null) { if (IS_POST) { $db = M('user'); $map['name'] = $username; $map['password'] = md5($password); $userInfo = $db->where($map)->find(); if (!$userInfo) { $this->error('帐号不存在或被禁用'); } $_SESSION['userid'] = $userInfo['id']; $_SESSION['username'] = $userInfo['name']; $_SESSION['truename'] = $userInfo['name']; $_SESSION['usertype'] = $userInfo['usertype']; $_SESSION['studentid'] = $userInfo['studentid']; $this->success('登录成功!', U('Index/index')); return; } else { if (is_login()) { $this->display('Project/projectList'); return; } else { $this->display('User/login'); } } }
public function send_mail($to, $type) { $uid = is_login(); if ($type == 1) { //验证邮件 $map['id'] = array('neq', $uid); $map['email'] = $to; $r = M('ucenter_member')->where($map)->find(); if ($r != '') { $this->error('该邮件地址已经被别人注册了!'); } $name = get_username($uid); $subject = C('WEB_SITE') . '邮箱验证邮件'; $body = '请点击以下链接完成邮箱验证,有效时间为5分钟:<br />' . "http://{$_SERVER['HTTP_HOST']}" . U('Userbase/yzmail', array('uid' => think_encrypt($uid, '', 3000), 'mail' => think_encrypt($to, '', 3000))); } if ($type == 2) { $subject = C('WEB_SITE') . ':恭喜您,注册成功!'; $body = C('MAIL_USER_REG'); $name = get_username($uid); } $res = send_mail($to, $subject, $body, $name, $attachment); if ($res == 1) { $this->success('邮件已发送,请到邮箱进行查收'); } else { $this->error('邮件发送失败,请检查邮箱设置'); } }