public function post() { $reviews = pc_base::load_app_class('reviews'); $id = isset($_GET['id']) && intval($_GET['id']) ? intval($_GET['id']) : ''; $SITE = siteinfo($this->siteid); $username = param::get_cookie('_username', $SITE['name'] . L('phpcms_friends')); $userid = param::get_cookie('_userid'); $reviews_setting_db = pc_base::load_model('reviews_setting_model'); $setting = $reviews_setting_db->get_one(array('siteid' => $this->siteid)); if (!empty($setting)) { //是否允许游客 if (!$setting['guest']) { if (!$username || !$userid) { $this->_show_msg(L('landing_users_to_comment'), HTTP_REFERER); } } if ($setting['code']) { $session_storage = 'session_' . pc_base::load_config('system', 'session_storage'); pc_base::load_sys_class($session_storage); session_start(); $code = isset($_POST['code']) && trim($_POST['code']) ? strtolower(trim($_POST['code'])) : $this->_show_msg(L('please_enter_code'), HTTP_REFERER); if ($code != $_SESSION['code']) { $this->_show_msg(L('code_error'), HTTP_REFERER); } } } //通过API接口调用数据的标题、URL地址 if (!($data = get_comment_api($this->reviewsid))) { $this->_show_msg(L('illegal_parameters')); } else { $title = $data['title']; $url = $data['url']; unset($data); } if (strpos($url, APP_PATH) === 0) { $domain = APP_PATH; } else { $urls = parse_url($url); $domain = $urls['scheme'] . '://' . $urls['host'] . (isset($urls['port']) && !empty($urls['port']) ? ":" . $urls['port'] : '') . '/'; } // $content = isset($_POST['content']) && trim($_POST['content']) ? trim($_POST['content']) : $this->_show_msg(L('please_enter_content'), HTTP_REFERER); $content = isset($_POST['content']) && trim($_POST['content']) ? trim($_POST['content']) : ''; $star1 = isset($_POST['star1']) && intval($_POST['star1']) ? intval($_POST['star1']) : ''; $star2 = isset($_POST['star2']) && intval($_POST['star2']) ? intval($_POST['star2']) : ''; $star3 = isset($_POST['star3']) && intval($_POST['star3']) ? intval($_POST['star3']) : ''; $star4 = isset($_POST['star4']) && intval($_POST['star4']) ? intval($_POST['star4']) : ''; $star5 = isset($_POST['star5']) && intval($_POST['star5']) ? intval($_POST['star5']) : ''; $star6 = isset($_POST['star6']) && intval($_POST['star6']) ? intval($_POST['star6']) : ''; $startype = isset($_POST['startype']) && intval($_POST['startype']) ? intval($_POST['startype']) : ''; $starnum = isset($_POST['starnum']) && intval($_POST['starnum']) ? intval($_POST['starnum']) : ''; $data = array('userid' => $userid, 'username' => $username, 'content' => $content, 'star1' => $star1, 'star2' => $star2, 'star3' => $star3, 'star4' => $star4, 'star5' => $star5, 'star6' => $star6, 'startype' => $startype, 'starnum' => $starnum); $reviews->add($this->reviewsid, $this->siteid, $data, $id, $title, $url); $this->_show_msg($reviews->get_error() . "<iframe width='0' id='top_src' height='0' src='{$domain}/js.html?200'></iframe>", in_array($reviews->msg_code, array(0, 7)) ? HTTP_REFERER : '', in_array($reviews->msg_code, array(0, 7)) ? 1 : 0); }
function comment_list() { $WAP = $this->wap; $TYPE = $this->types; $comment = pc_base::load_app_class('comment', 'comment'); pc_base::load_app_func('global', 'comment'); $typeid = intval($_GET['typeid']); $GLOBALS['siteid'] = max($this->siteid, 1); $commentid = isset($_GET['commentid']) && trim(urldecode($_GET['commentid'])) ? trim(urldecode($_GET['commentid'])) : exit('参数错误'); list($modules, $contentid, $siteid) = decode_commentid($commentid); list($module, $catid) = explode('_', $modules); $comment_setting_db = pc_base::load_model('comment_setting_model'); $setting = $comment_setting_db->get_one(array('siteid' => $this->siteid)); //通过API接口调用数据的标题、URL地址 if (!($data = get_comment_api($commentid))) { exit('参数错误'); } else { $title = $data['title']; $url = $data['url']; unset($data); } include template('wap', 'comment_list'); }
public function post() { $comment = pc_base::load_app_class('comment'); $id = isset($_GET['id']) && intval($_GET['id']) ? intval($_GET['id']) : ''; $SITE = siteinfo($this->siteid); $username = param::get_cookie('_username', $SITE['name'] . L('phpcms_friends')); $userid = param::get_cookie('_userid'); $comment_setting_db = pc_base::load_model('comment_setting_model'); $setting = $comment_setting_db->get_one(array('siteid' => $this->siteid)); if (!empty($setting)) { //是否允许游客 if (!$setting['guest']) { if (!$username || !$userid) { //$this->_show_msg(L('landing_users_to_comment'), HTTP_REFERER); die(json_encode(array('msg' => '必须登录才可以评论!', 'status' => 400))); } } if ($setting['code']) { $session_storage = 'session_' . pc_base::load_config('system', 'session_storage'); pc_base::load_sys_class($session_storage); session_start(); //$code = isset($_POST['code']) && trim($_POST['code']) ? strtolower(trim($_POST['code'])) : $this->_show_msg(L('please_enter_code'), HTTP_REFERER); $code = isset($_POST['code']) && trim($_POST['code']) ? strtolower(trim($_POST['code'])) : ''; if (!$code) { die(json_encode(array('msg' => '请输入验证码!', 'status' => 400))); } if ($code != $_SESSION['code']) { //$this->_show_msg(L('code_error'), HTTP_REFERER); die(json_encode(array('msg' => '验证码错误!', 'status' => 400))); } } } //通过API接口调用数据的标题、URL地址 if (!($data = get_comment_api($this->commentid))) { $this->_show_msg(L('illegal_parameters')); } else { $title = $data['title']; $url = $data['url']; unset($data); } if (strpos($url, APP_PATH) === 0) { $domain = APP_PATH; } else { $urls = parse_url($url); $domain = $urls['scheme'] . '://' . $urls['host'] . (isset($urls['port']) && !empty($urls['port']) ? ":" . $urls['port'] : '') . '/'; } //$content = isset($_POST['content']) && trim($_POST['content']) ? trim($_POST['content']) : $this->_show_msg(L('please_enter_content'), HTTP_REFERER); $content = isset($_POST['content']) && trim($_POST['content']) ? trim($_POST['content']) : ''; if (!$content) { die(json_encode(array('msg' => '请填写类容!', 'status' => 400))); } elseif (strlen($content) <= 10) { die(json_encode(array('msg' => '内容过少!', 'status' => 400))); } $direction = isset($_POST['direction']) && intval($_POST['direction']) ? intval($_POST['direction']) : ''; $data = array('userid' => $userid, 'username' => $username, 'content' => $content, 'direction' => $direction); $comment->add($this->commentid, $this->siteid, $data, $id, $title, $url); echo json_encode(array('msg' => '评论成功!', 'status' => 200, 'posTdata' => array('username' => $username, 'content' => $content, 'postTime' => date('Y-m-d H:i:s', time())))); //$this->_show_msg($comment->get_error()."<iframe width='0' id='top_src' height='0' src='$domain/js.html?200'></iframe>", (in_array($comment->msg_code, array(0,7)) ? HTTP_REFERER : ''), (in_array($comment->msg_code, array(0,7)) ? 1 : 0)); }
/** * 发送评论信息 */ public function post() { $comment = Loader::lib('comment:comment'); $id = isset($_GET['id']) && intval($_GET['id']) ? intval($_GET['id']) : ''; $SITE = S('common/common'); $username = cookie('_username', $SITE['site_name'] . L('xtcms_friends')); $userid = cookie('_userid'); $setting = S('common/comment'); if (!empty($setting)) { // 是否允许游客 if (!$setting['guest']) { if (!$username || !$userid) { $this->_show_msg(L('landing_users_to_comment'), HTTP_REFERER); } } if ($setting['code']) { $code = isset($_POST['code']) && trim($_POST['code']) ? strtolower(trim($_POST['code'])) : $this->_show_msg(L('please_enter_code'), HTTP_REFERER); if (!checkcode($code)) { $this->_show_msg(L('code_error'), HTTP_REFERER); } } } // 通过API接口调用数据的标题、URL地址 if (!($data = get_comment_api($this->commentid))) { $this->_show_msg(L('illegal_parameters')); } else { $title = $data['title']; $url = $data['url']; unset($data); } if (strpos($url, SITE_URL) === 0) { $domain = SITE_URL; } else { $urls = parse_url($url); $domain = $urls['scheme'] . '://' . $urls['host'] . (isset($urls['port']) && !empty($urls['port']) ? ":" . $urls['port'] : '') . '/'; } $content = isset($_POST['content']) && trim($_POST['content']) ? trim($_POST['content']) : $this->_show_msg(L('please_enter_content'), HTTP_REFERER); $data = array('userid' => $userid, 'username' => $username, 'content' => $content); $comment->add($this->commentid, $data, $id, $title, $url); $this->_show_msg($comment->get_error() . "<iframe width='0' id='top_src' height='0' src='{$domain}/js.html?200'></iframe>", in_array($comment->msg_code, array(0, 7)) ? HTTP_REFERER : '', in_array($comment->msg_code, array(0, 7)) ? 1 : 0); }