$check_type = in_array($check_type, array('mobile', 'weixin', 'tel', 'qq')) ? $check_type : 'mobile'; $value = trim($_GET['value']); if ($check_type == 'mobile') { if ($value != "") { $result = checkmobile($value); if ($result) { $return = array('return' => 1); } else { $return = array('return' => 0, 'comment' => '请输入正确格式的手机号'); } } else { $return = array('return' => 0, 'comment' => '请输入正确格式的手机号'); } } elseif ($check_type == 'qq') { if ($value != "") { $result = isQQ($value); if ($result) { $return = array('return' => 1); } else { $return = array('return' => 0, 'comment' => '请输入正确格式的QQ号'); } } else { $return = array('return' => 0, 'comment' => '请输入正确格式的QQ号'); } } elseif ($check_type == 'weixin') { if ($value != "") { if (strlen($value) > 20 || strlen($value) < 4) { $return = array('return' => 0, 'comment' => '请输入正确格式的微信号'); } else { $return = array('return' => 1); }
function onsuggest() { $question_type = "suggest"; $question_type_list = $this->ask_config->getQuestionType(); $title = "服务中心-我要" . $question_type_list[$question_type]; $all_num = $_ENV['question']->total_question(); $qtypeId = isset($this->get[2]) ? intval($this->get[2]) : (isset($this->post['qtypeId']) ? intval($this->post['qtypeId']) : 0); $loginName = $this->ask_front_name; $allQtype = $_ENV['qtype']->GetAllQType(1, "", 0); if (!isset($allQtype[$qtypeId])) { header("Location: http://sc.5173.com/index.php?question/ask_skip.html"); } $subList = $_ENV['qtype']->GetSubList($qtypeId); if (!empty($subList)) { header("Location: http://sc.5173.com/index.php?question/subList/suggest/{$qtypeId}.html"); } $qtypeName = $allQtype[$qtypeId]; $operatorInfo = ''; // 获取我的专属客服 if ($this->ask_front_name == '游客') { $selfAuthor_where = ''; // 获取专属客服条件 } else { $t_cid = $_ENV['question']->getType(3); $operatorInfo = $_ENV['operator']->getMySelfAuthor($this->ask_front_name); $selfAuthor_where = $_ENV['question']->front_selfAuthor_where($operatorInfo['login_name'], '', 1, $t_cid); } if ($selfAuthor_where) { $selfAuthorNum = $_ENV['question']->front_mySelfAuthorNum($selfAuthor_where); } else { $selfAuthorNum = 0; } $url = ''; if ($qtypeName['pid'] > 0) { $url = '<a href="http://sc.5173.com/index.php?question/subList/suggest/' . $qtypeName['pid'] . '.html">选择' . $allQtype[$qtypeName['pid']]['name'] . '类' . $question_type_list[$question_type] . '</a> >  '; } //未登陆跳转地址 $login_url = "http://" . config::FRONT_LOGIN_DOMAIN . "/?returnUrl=" . urlencode(curPageURL()); $display_yzm = false; if ($this->ask_front_name != '游客') { $contact = $this->cache->get(md5('SJ' . $this->ask_front_id)); if (false === $contact) { $contact = get_mobile($this->ask_front_id); if (!empty($contact)) { $this->cache->set(md5('SJ' . $this->ask_front_id), $contact, 1800); } //缓存30分钟 } if (!empty($contact)) { $en_contact = substr_replace($contact, '****', 3, 4); } } $suggest_title = isset($this->post['title']) ? htmlspecialchars(trim($this->post['title'])) : ''; $description = isset($this->post['description']) && $this->post['description'] != "我们非常重视您的" . $question_type_list[$question_type] . ",请在这里告诉我们" ? htmlspecialchars(trim($this->post['description'])) : ''; $contact_num = isset($this->post['contact_num']) ? htmlspecialchars($this->post['contact_num']) : (isset($en_contact) ? $en_contact : ''); $J_code = isset($this->post['J_code']) ? strtolower(htmlspecialchars($this->post['J_code'])) : ''; if ($this->ask_front_name == '游客') { $author = isset($this->post['author']) && $this->post['author'] != '请输入5173用户名' ? trim($this->post['author']) : ''; $author_id = ''; } else { $author_id = $this->ask_front_id; $author = $this->ask_front_name; } $t_yzm = tcookie('yzm'); if (empty($t_yzm)) { tcookie('yzm', time(), 1800); //存放半个小时 } else { $over_time = time() - $t_yzm; //距离现在的秒数 if ($over_time < 1800) { $display_yzm = true; } else { tcookie('yzm', '', time() - 3600); //删除 } } if ($this->ask_front_name != '游客') { $display_yzm = false; } //登陆用户不显示验证码 if (isset($this->post['contact'])) { $comment['contact'] = $this->post['contact']; } else { $comment['contact']['mobile'] = isset($en_contact) ? $en_contact : ''; } $flag = 0; if (isset($this->post['act'])) { if (isset($this->post['contact'])) { $comment['contact'] = $this->post['contact']; if ($comment['contact']['mobile'] != "") { if (isset($en_contact) && $comment['contact']['mobile'] == $en_contact) { $comment['contact']['mobile'] = $contact; } if (!checkmobile($comment['contact']['mobile'])) { $errorMsg['mobile'] = '手机号'; unset($comment['contact']['mobile']); } else { $flag++; } } else { $errorMsg['mobile'] = '手机号'; unset($comment['contact']['mobile']); } if ($comment['contact']['qq'] != "") { if (!isQQ($comment['contact']['qq'])) { //$errorMsg['qq'] = 'QQ号'; unset($comment['contact']['qq']); } else { //$flag++; } } else { //$errorMsg['qq'] = 'QQ号'; unset($comment['contact']['qq']); } if ($comment['contact']['weixin'] != '') { if (strlen($comment['contact']['weixin']) > 20 || strlen($comment['contact']['weixin']) < 4 || trim($comment['contact']['weixin']) == "微信号") { //$errorMsg['weixin'] = '微信号'; unset($comment['contact']['weixin']); } else { //$flag++; } } else { //$errorMsg['weixin'] = '微信号'; unset($comment['contact']['weixin']); } } if ($flag == 0 && count($errorMsg) > 0) { $error = implode("、", $errorMsg) . "未填写或格式不正确"; $comment['contact'] = $this->post['contact']; @(include template('suggest')); echo "<script>alert('" . $error . "');</script>"; exit; } if ($description == '') { $comment['contact'] = $this->post['contact']; @(include template('suggest')); echo "<script>alert('建议内容不能为空。');</script>"; exit; } elseif (mb_strlen($description, 'UTF-8') > 500 || mb_strlen($description, 'UTF-8') < 5) { $comment['contact'] = $this->post['contact']; @(include template('suggest')); echo "<script>alert('建议内容请保持在5-500个字内。');</script>"; exit; } if ($this->ask_front_name == '游客') { if ($author == "" || mb_strlen($author, 'UTF-8') > 20) { @(include template('suggest')); echo "<script>alert('请输正确格式的5173登陆用户名');</script>"; exit; } if ($J_code == "" || $J_code != $_SESSION['code']) { $comment['contact'] = $this->post['contact']; @(include template('suggest')); echo "<script>alert('验证码不正确!');</script>"; exit; } } //提问数限制 $limit_question_num = intval($this->setting['limit_question_num']); if (!empty($limit_question_num)) { $comment['contact'] = $this->post['contact']; $num_ip = $_ENV['question']->get_num_by_ip(getip()); if ($num_ip >= $limit_question_num) { @(include template('suggest')); echo "<script>alert('您的操作太频繁啦,让服务器休息一下,稍后再进行建议!');</script>"; exit; } } //IP黑名单 $BlackList = explode("|", $this->setting['IpBlackList']); if (in_array(getip(), $BlackList)) { $comment['contact'] = $this->post['contact']; @(include template('suggest')); echo "<script>alert('您的操作太频繁啦,让服务器休息一下,稍后再建议!');</script>"; exit; } if ($this->ask_front_name != '游客') { //登录提问 $GagLog = $_ENV['user']->getGag($this->ask_front_name); if (count($GagLog) > 0) { $comment['contact'] = $this->post['contact']; @(include template('suggest')); echo "<script>alert('很抱歉,您的帐号已被管理员禁言处理,请您自觉遵守5173言论规则。');</script>"; exit; } } $description = cutstr(strip_tags($description), 500, ''); if (md5(trim(strip_tags($description))) == $_COOKIE['last_suggest']) { @(include template('suggest')); echo "<script>alert('亲,问题提交一次就OK,不用重复提交哦!');</script>"; exit; } $img_path = $this->post['imgpath']; $img_path = stripcslashes($img_path); $img_path = str_replace('"small_pic"', ',"small_pic"', $img_path); $img_path = str_replace('"big_pic"', ',"big_pic"', $img_path); $p1 = strpos($img_path, "big_pic"); $path = substr($img_path, $p1 + 10, strlen($img_path) - $p1 - 10 - 2); $path = str_replace('\\/', '/', $path); $attach = trim($path); if (isset($en_contact) && $comment['contact']['mobile'] == $en_contact) { $comment['contact']['mobile'] = $contact; } $cid = $_ENV['question']->getType(2); //建议分类id $cid = !empty($cid) ? intval($cid) : 0; $cid1Info = $_ENV['category']->getByQType($qtypeId, $cid); //qtype对应分类id $cid1 = intval($cid1Info['id']); $time = time(); $trimDescription = preg_replace('/\\s+/', '', $description); $description = $this->keyWordCheck($trimDescription); $BrowerInfo = userBrowerInfo(); $comment['OS'] = $BrowerInfo['OS']; $comment['Browser'] = $BrowerInfo['Browser']; $questionInfo = array("qtype" => $qtypeId, "author" => $author, "author_id" => $author_id, "title" => $suggest_title, "description" => $description, "attach" => $attach, "time" => $time, "ip" => getip(), "cid" => $cid, "cid1" => $cid1, "comment" => serialize($comment)); $question_id = $_ENV['question']->insertQuestion($questionInfo); //更新Solr服务器 $q_search = array(); if ($question_id > 0) { setcookie('last_suggest', md5(trim(strip_tags($description))), time() + 3600); if ($this->ask_front_name == '游客') { get_que_id('jy', $question_id); //建议id写入cookie } $date = date("Y-m-d"); $_ENV['question']->modifyUserQtypeNum($date, $qtypeId, 'suggest', 1); $login_name = trim($this->post['login_name']); if (!empty($login_name)) { if ($this->setting['selfServiceFirst'] == 1) { $Apply = $_ENV['question']->ApplyToOperator($question_id, $login_name); } } $q_search['id'] = $question_id; $q_search['title'] = $description; $q_search['description'] = $description; $q_search['tag'] = json_encode(array(), true); $q_search['time'] = $time; $q_search['atime'] = 0; try { $this->set_search($q_search); } catch (Exception $e) { send_AIC('http://sc.5173.com/index.php?question/suggest.html', '搜索服务器异常', 1, '搜索接口'); } } header("Location: " . url('question/suggest_success/' . $question_id . '/' . $time, true)); } $telDisplay = $this->setting['telDisplay']; $xnDisplay = $this->setting['xnDisplay']; $qqDisplay = $this->setting['qqDisplay']; $_ENV['question']->PageView(1, getip()); @(include template('suggest')); }