/** * AJAX验证 * */ public function checkOp() { if (uk86_checkSeccode($_GET['nchash'], $_GET['captcha'])) { exit('true'); } else { exit('false'); } }
/** * 添加转发 */ public function addforwardOp() { $obj_validate = new Uk86Validate(); $originalid = intval($_POST["originalid"]); $validate_arr[] = array("input" => $originalid, "require" => "true", 'validator' => 'Compare', "operator" => ' > ', 'to' => 0, "message" => Uk86Language::uk86_get('sns_forward_fail')); $validate_arr[] = array("input" => $_POST["forwardcontent"], "validator" => 'Length', "min" => 0, "max" => 140, "message" => Uk86Language::uk86_get('sns_content_beyond')); //发帖数超过最大次数出现验证码 if (intval(uk86_cookie('forwardnum')) >= self::MAX_RECORDNUM) { $validate_arr[] = array("input" => $_POST["captcha"], "require" => "true", "message" => Uk86Language::uk86_get('wrong_null')); } $obj_validate->validateparam = $validate_arr; $error = $obj_validate->uk86_validate(); if ($error != '') { showDialog($error, '', 'error'); } //发帖数超过最大次数出现验证码 if (intval(uk86_cookie('forwardnum')) >= self::MAX_RECORDNUM) { if (!uk86_checkSeccode($_POST['nchash'], $_POST['captcha'])) { showDialog(Uk86Language::uk86_get('wrong_checkcode'), '', 'error'); } } //查询会员信息 $member_model = Model('member'); $member_info = $member_model->getMemberInfo(array('member_id' => $_SESSION['member_id'], 'member_state' => 1)); if (empty($member_info)) { showDialog(Uk86Language::uk86_get('sns_member_error'), '', 'error'); } //查询原帖信息 $tracelog_model = Model('sns_tracelog'); $tracelog_info = $tracelog_model->getTracelogRow(array('trace_id' => "{$originalid}", 'trace_state' => "0")); if (empty($tracelog_info)) { showDialog(Uk86Language::uk86_get('sns_forward_fail'), '', 'error'); } $insert_arr = array(); $insert_arr['trace_originalid'] = $tracelog_info['trace_originalid'] > 0 ? $tracelog_info['trace_originalid'] : $originalid; //如果被转发的帖子为原帖的话,那么为原帖ID;如果被转发的帖子为转帖的话,那么为该转帖的原帖ID(即最初始帖子ID) $insert_arr['trace_originalmemberid'] = $tracelog_info['trace_originalid'] > 0 ? $tracelog_info['trace_originalmemberid'] : $tracelog_info['trace_memberid']; $insert_arr['trace_memberid'] = $_SESSION['member_id']; $insert_arr['trace_membername'] = $_SESSION['member_name']; $insert_arr['trace_memberavatar'] = $member_info['member_avatar']; $insert_arr['trace_title'] = $_POST['forwardcontent'] ? $_POST['forwardcontent'] : Uk86Language::uk86_get('sns_forward'); if ($tracelog_info['trace_originalid'] > 0 || $tracelog_info['trace_from'] != 1) { $insert_arr['trace_content'] = addslashes($tracelog_info['trace_content']); } else { $content_str = "<div class=\"title\"><a href=\"%siteurl%index.php?act=member_snshome&mid={$tracelog_info['trace_memberid']}\" target=\"_blank\" class=\"uname\">{$tracelog_info['trace_membername']}</a>"; $content_str .= Uk86Language::uk86_get('nc_colon') . "{$tracelog_info['trace_title']}</div>"; $content_str .= addslashes($tracelog_info['trace_content']); $insert_arr['trace_content'] = $content_str; } $insert_arr['trace_addtime'] = time(); $insert_arr['trace_state'] = '0'; if ($tracelog_info['trace_privacy'] > 0) { $insert_arr['trace_privacy'] = 2; //因为动态可见权限跟转帖功能,本身就是矛盾的,为了防止可见度无法控制,所以如果原帖不为所有人可见,那么转帖的动态权限就为仅自己可见,否则为所有人可见 } else { $insert_arr['trace_privacy'] = 0; } $insert_arr['trace_commentcount'] = 0; $insert_arr['trace_copycount'] = 0; $insert_arr['trace_orgcommentcount'] = $tracelog_info['trace_orgcommentcount']; $insert_arr['trace_orgcopycount'] = $tracelog_info['trace_orgcopycount']; $result = $tracelog_model->tracelogAdd($insert_arr); if ($result) { //更新动态转发次数 $tracelog_model = Model('sns_tracelog'); $update_arr = array(); $update_arr['trace_copycount'] = array('sign' => 'increase', 'value' => '1'); $update_arr['trace_orgcopycount'] = array('sign' => 'increase', 'value' => '1'); $condition = array(); //原始贴和被转帖都增加转帖次数 if ($tracelog_info['trace_originalid'] > 0) { $condition['traceid_in'] = "{$tracelog_info['trace_originalid']}','{$originalid}"; } else { $condition['trace_id'] = "{$originalid}"; } $tracelog_model->tracelogEdit($update_arr, $condition); unset($condition); //更新所有转帖的原帖转发次数 $condition = array(); //原始贴和被转帖都增加转帖次数 if ($tracelog_info['trace_originalid'] > 0) { $condition['trace_originalid'] = "{$tracelog_info['trace_originalid']}"; } else { $condition['trace_originalid'] = "{$originalid}"; } $tracelog_model->tracelogEdit(array('trace_orgcopycount' => $tracelog_info['trace_orgcopycount'] + 1), $condition); if ($_GET['irefresh']) { //建立cookie if (uk86_cookie('forwardnum') != null && intval(uk86_cookie('forwardnum')) > 0) { uk86_setNcCookie('forwardnum', intval(uk86_cookie('forwardnum')) + 1, 2 * 3600); //保存2小时 } else { uk86_setNcCookie('forwardnum', 1, 2 * 3600); //保存2小时 } if ($_GET['type'] == 'home') { $js = "\$('#friendtrace').lazyshow({url:\"index.php?act=member_snshome&op=tracelist&mid={$tracelog_info['trace_memberid']}&curpage=1\",'iIntervalId':true});"; } else { if ($_GET['type'] == 'snshome') { $js = "\$('#forward_" . $originalid . "').hide();\$('#friendtrace').lazyshow({url:\"index.php?act=member_snshome&op=tracelist&mid={$tracelog_info['trace_memberid']}&curpage=1\",'iIntervalId':true});"; } else { $js = "\$('#friendtrace').lazyshow({url:\"index.php?act=member_snsindex&op=tracelist&curpage=1\",'iIntervalId':true});"; } } showDialog(Uk86Language::uk86_get('sns_forward_succ'), '', 'succ', $js); } else { showDialog(Uk86Language::uk86_get('sns_forward_succ'), '', 'succ'); } } else { showDialog(Uk86Language::uk86_get('sns_forward_fail'), '', 'error'); } }
/** * 添加转发 */ public function addforwardOp() { // 验证用户是否登录 $this->checkLoginStatus(); $obj_validate = new Uk86Validate(); $stid = intval($_POST["stid"]); $validate_arr[] = array("input" => $_POST["forwardcontent"], "validator" => 'Length', "min" => 0, "max" => 140, "message" => Uk86Language::uk86_get('sns_content_beyond')); //发帖数超过最大次数出现验证码 if (intval(uk86_cookie('forwardnum')) >= self::MAX_RECORDNUM) { $validate_arr[] = array("input" => $_POST["captcha"], "require" => "true", "message" => Uk86Language::uk86_get('wrong_null')); } $obj_validate->validateparam = $validate_arr; $error = $obj_validate->uk86_validate(); if ($error != '') { showDialog($error, '', 'error'); } //发帖数超过最大次数出现验证码 if (intval(uk86_cookie('forwardnum')) >= self::MAX_RECORDNUM) { if (!uk86_checkSeccode($_POST['nchash'], $_POST['captcha'])) { showDialog(Uk86Language::uk86_get('wrong_checkcode'), '', 'error'); } } //查询会员信息 $model = Model(); $member_info = $model->table('member')->where(array('member_state' => 1))->find($_SESSION['member_id']); if (empty($member_info)) { showDialog(Uk86Language::uk86_get('sns_member_error'), '', 'error'); } //查询原帖信息 $model_stracelog = Model('store_sns_tracelog'); $stracelog_info = $model_stracelog->getStoreSnsTracelogInfo(array('strace_id' => $stid)); if (empty($stracelog_info)) { showDialog(Uk86Language::uk86_get('sns_forward_fail'), '', 'error'); } if ($stracelog_info['strace_content'] == '') { $data = json_decode($stracelog_info['strace_goodsdata'], true); if (CHARSET == 'GBK') { foreach ((array) $data as $k => $v) { $data[$k] = Uk86Language::uk86_getUTF8($v); } } $stracelog_info['strace_content'] = $model_stracelog->spellingStyle($stracelog_info['strace_type'], $data); } $insert_arr = array(); $insert_arr['trace_originalid'] = 0; $insert_arr['trace_originalmemberid'] = 0; $insert_arr['trace_originalstate'] = 0; $insert_arr['trace_memberid'] = $member_info['member_id']; $insert_arr['trace_membername'] = $member_info['member_name']; $insert_arr['trace_memberavatar'] = $member_info['member_avatar']; $insert_arr['trace_title'] = $_POST['forwardcontent'] ? $_POST['forwardcontent'] : Uk86Language::uk86_get('sns_forward'); $insert_arr['trace_content'] = "<dl class=\"fd-wrap\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<dt>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<h3><a href=\"index.php?act=store_snshome&sid=" . $stracelog_info['strace_storeid'] . "\" target=\"_blank\">" . $stracelog_info['strace_storename'] . "</a>" . Uk86Language::uk86_get('nc_colon') . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $stracelog_info['strace_title'] . "</h3>\n\t\t\t\t\t\t\t\t\t\t \t\t\t</dt>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<dd>" . $stracelog_info['strace_content'] . "</dd>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<dl>"; $insert_arr['trace_addtime'] = time(); $insert_arr['trace_state'] = 0; $insert_arr['trace_privacy'] = 0; $insert_arr['trace_commentcount'] = 0; $insert_arr['trace_copycount'] = 0; $insert_arr['trace_orgcommentcount'] = 0; $insert_arr['trace_orgcopycount'] = 0; $insert_arr['trace_from'] = 2; $result = $model->table('sns_tracelog')->insert($insert_arr); if ($result) { //更新动态转发次数 $where = array('strace_id' => $stid); $update = array('strace_spread' => array('exp', 'strace_spread+1')); Model('store_sns_tracelog')->editStoreSnsTracelog($update, $where); showDialog(Uk86Language::uk86_get('sns_forward_succ'), '', 'succ'); } else { showDialog(Uk86Language::uk86_get('sns_forward_fail'), '', 'error'); } }
/** * 验证验证码 */ public function wap_checkOp() { if (uk86_checkSeccode($_GET['nchash'], $_GET['captcha'])) { exit(json_encode(array('state' => true, 'msg' => 'index.php?act=wap_login&op=edit_password'))); } else { exit(json_encode(array('state' => false, 'msg' => '验证码不正确,请重新验证'))); } }
/** * 检测FORM是否提交 * @param $check_token 是否验证token * @param $check_captcha 是否验证验证码 * @param $return_type 'alert','num' * @return boolean */ function uk86_chksubmit($check_token = false, $check_captcha = false, $return_type = 'alert') { $submit = isset($_POST['form_submit']) ? $_POST['form_submit'] : $_GET['form_submit']; if ($submit != 'ok') { return false; } if ($check_token && !Uk86Security::uk86_checkToken()) { if ($return_type == 'alert') { showDialog('Token error!'); } else { return -11; } } if ($check_captcha) { if (!uk86_checkSeccode($_POST['nchash'], $_POST['captcha'])) { uk86_setNcCookie('seccode' . $_POST['nchash'], '', -3600); if ($return_type == 'alert') { showDialog('验证码错误!'); } else { return -12; } } uk86_setNcCookie('seccode' . $_POST['nchash'], '', -3600); } return true; }