function _initialize() { parent::_initialize(); $site_options = get_site_options(); $this->assign($site_options); $ucenter_syn = C("UCENTER_ENABLED"); if ($ucenter_syn) { if (!isset($_SESSION["MEMBER_id"])) { if (!empty($_COOKIE['thinkcmf_auth']) && $_COOKIE['thinkcmf_auth'] != "logout") { $thinkcmf_auth = sp_authcode($_COOKIE['thinkcmf_auth'], "DECODE"); $thinkcmf_auth = explode("\t", $thinkcmf_auth); $auth_username = $thinkcmf_auth[1]; $members_obj = M('Members'); $where['user_login_name'] = $auth_username; $member = $members_obj->where($where)->find(); if (!empty($member)) { $is_login = true; $_SESSION["MEMBER_type"] = 'local'; $_SESSION["MEMBER_id"] = $member['ID']; $_SESSION['MEMBER_name'] = $auth_username; $_SESSION['MEMBER_status'] = $member['user_status']; } } } else { } } }
function _initialize() { parent::_initialize(); $site_options = get_site_options(); $this->assign($site_options); $ucenter_syn = C("UCENTER_ENABLED"); if ($ucenter_syn) { if (!isset($_SESSION["user"])) { if (!empty($_COOKIE['thinkcmf_auth']) && $_COOKIE['thinkcmf_auth'] != "logout") { $thinkcmf_auth = sp_authcode($_COOKIE['thinkcmf_auth'], "DECODE"); $thinkcmf_auth = explode("\t", $thinkcmf_auth); $auth_username = $thinkcmf_auth[1]; $users_model = M('Users'); $where['user_login'] = $auth_username; $user = $users_model->where($where)->find(); if (!empty($user)) { $is_login = true; $_SESSION["user"] = $user; } } } else { } } if (sp_is_user_login()) { $this->assign("user", sp_get_current_user()); } }
function post() { if ($_SESSION['_verify_']['verify'] != I("post.verify")) { $this->error("验证码错误!"); } if (IS_POST) { $_POST['post_table'] = sp_authcode($_POST['post_table']); if ($this->comments_model->create()) { if (isset($_SESSION["MEMBER_type"]) && $_SESSION["MEMBER_type"] == 'local') { //用户已登陆,且是本站会员 $uid = $_SESSION["MEMBER_id"]; $_POST['uid'] = $uid; $members_model = M('Members'); $member = $members_model->field("user_login_name,user_email")->where("ID={$uid}")->find(); $username = $member['user_login_name']; $email = $member['user_email']; $_POST['full_name'] = $username; $_POST['email'] = $email; } $result = $this->comments_model->add(); if ($result !== false) { $this->success("评论成功!"); } else { $this->error("评论失败!"); } } else { $this->error($this->comments_model->getError()); } } }
function post() { /* if($_SESSION['_verify_']['verify']!=I("post.verify")){ $this->error("验证码错误!"); } */ if (IS_POST) { $post_table = sp_authcode($_POST['post_table']); $_POST['post_table'] = $post_table; $url = parse_url(urldecode($_POST['url'])); $query = empty($url['query']) ? "" : "?{$url['query']}"; $url = "{$url['scheme']}://{$url['host']}{$url['path']}{$query}"; $_POST['url'] = sp_get_relative_url($url); if (isset($_SESSION["user"])) { //用户已登陆,且是本站会员 $uid = $_SESSION["user"]['id']; $_POST['uid'] = $uid; $users_model = M('Users'); $user = $users_model->field("user_login,user_email,user_nicename")->where("id={$uid}")->find(); $username = $user['user_login']; $user_nicename = $user['user_nicename']; $email = $user['user_email']; $_POST['full_name'] = empty($user_nicename) ? $username : $user_nicename; $_POST['email'] = $email; } if (C("COMMENT_NEED_CHECK")) { $_POST['status'] = 0; //评论审核功能开启 } else { $_POST['status'] = 1; } if ($this->comments_model->create()) { $this->check_last_action(intval(C("COMMENT_TIME_INTERVAL"))); $result = $this->comments_model->add(); if ($result !== false) { //评论计数 $post_table = ucwords(str_replace("_", " ", $post_table)); $post_table = str_replace(" ", "", $post_table); $post_table_model = M($post_table); $pk = $post_table_model->getPk(); $post_table_model->create(array("comment_count" => array("exp", "comment_count+1"))); $post_table_model->where(array($pk => intval($_POST['post_id'])))->save(); $post_table_model->create(array("last_comment" => time())); $post_table_model->where(array($pk => intval($_POST['post_id'])))->save(); $this->ajaxReturn(sp_ajax_return(array("id" => $result), "评论成功!", 1)); } else { $this->error("评论失败!"); } } else { $this->error($this->comments_model->getError()); } } }
function _initialize() { parent::_initialize(); $site_options = get_site_options(); $this->assign($site_options); $ucenter_syn = C("UCENTER_ENABLED"); if ($ucenter_syn) { if (!isset($_SESSION["user"])) { if (!empty($_COOKIE['thinkcmf_auth']) && $_COOKIE['thinkcmf_auth'] != "logout") { $thinkcmf_auth = sp_authcode($_COOKIE['thinkcmf_auth'], "DECODE"); $thinkcmf_auth = explode("\t", $thinkcmf_auth); $auth_username = $thinkcmf_auth[1]; $users_model = M('Member'); $where['user_login'] = $auth_username; $user = $users_model->where($where)->find(); if (!empty($user)) { $is_login = true; $_SESSION["user"] = $user; } } } else { } } if (sp_is_user_login()) { $this->assign("user", sp_get_current_user()); } else { if (isset($_COOKIE['user_login'])) { $users_model = M('Member'); $where['user_login'] = $_COOKIE['user_login']; $user = $users_model->where($where)->find(); //echo $_COOKIE['user_auth'];echo '<br>';echo md5($result['user_pass'].'iloveyouhmvpoint');die; if (md5($user['user_pass'] . 'iloveyouhmvpoint') == $_COOKIE['user_auth']) { $_SESSION['user'] = $user; } } } // 热搜 $top_hot_search = M('Ad')->where('ad_content="top_hot_search"')->limit(7)->select(); $this->assign('top_hot_search', $top_hot_search); $cart = A('Order/Cart')->cart(); $this->assign('cartNum', count($cart['cart'])); }
function do_favorite() { $key = sp_authcode($_POST['key']); if ($key) { $authkey = C("AUTHCODE"); $key = explode(" ", $key); $authcode = $key[0]; if ($authcode == C("AUTHCODE")) { $table = $key[1]; $object_id = $key[2]; $post = I("post."); unset($post['key']); $post['table'] = $table; $post['object_id'] = $object_id; $uid = sp_get_current_userid(); $post['uid'] = $uid; $user_favorites_model = M("UserFavorites"); $find_favorite = $user_favorites_model->where(array('table' => $table, 'object_id' => $object_id, 'uid' => $uid))->find(); if ($find_favorite) { $this->error("亲,您已收藏过啦!"); } else { $post['createtime'] = time(); $result = $user_favorites_model->add($post); if ($result) { $this->success("收藏成功!"); } else { $this->error("收藏失败!"); } } } else { $this->error("非法操作,无合法密钥!"); } } else { $this->error("非法操作,无密钥!"); } $this->error(sp_authcode($_POST['key'])); }
function sp_authencode($string) { return sp_authcode($string, "ENCODE"); }