<?php /* ** 首页 */ // 禁止直接访问 if (!defined('ENTRANCE')) { header("Location:../"); } include 'fun/curl_method.php'; // 获取推荐文章 $url = API_M . "/publicAccount/getIndexInformation"; $data = array('page' => 1, 'pageSize' => 6); $res = curl_method($url, $data); $arr = json_decode($res, true); // 文章正文数组 $article = $arr['data']; // 筛选第三六篇文章图片两张 加入数组末尾 $reg = "/http:\\/\\/media\\.jiuchacha\\.com\\/selfMedia\\/(.+)(jpg|png|gif|jpeg)/i"; if (isset($article[2]['content'])) { if (preg_match_all($reg, $article[2]['content'], $arrImg)) { $article[2]['headImage1'] = $arrImg[0][0] ? $arrImg[0][0] : ''; $article[2]['headImage2'] = @$arrImg[0][1] ? @$arrImg[0][1] : ''; } } if (isset($article[5]['content'])) { if (preg_match_all($reg, $article[5]['content'], $arrImg)) { $article[5]['headImage1'] = $arrImg[0][0] ? $arrImg[0][0] : ''; $article[5]['headImage2'] = @$arrImg[0][1] ? @$arrImg[0][1] : ''; } }
<?php /* ** send checkcode */ // 禁止直接访问 if (!defined('ENTRANCE')) { header("Location:../"); } $mobile = $_POST['mobile']; // 后端验证 if (preg_match('/^1(3\\d|4\\d|5\\d|7\\d|8\\d)\\d{8}$/', $mobile)) { include 'fun/curl_method.php'; $url = API . "/user/sendVerifyCode"; $data = array('kind' => 1, 'telPhone' => $mobile); // 请求数据 echo curl_method($url, $data); } else { echo 0; }
<?php /* ** ajax login */ // 禁止直接访问 if (!defined('ENTRANCE')) { header("Location:../"); } include 'fun/curl_method.php'; $url = API . "/user/login"; $data = array('userName' => $_POST['username'], 'passWord' => $_POST['password']); // 请求数据 $result = curl_method($url, $data); $userInfo = json_decode($result, true); if ($userInfo['success'] == false) { // 登录失败 echo json_encode(array('status' => $userInfo['success'], 'msg' => $userInfo['message'])); } else { // 登录成功,设置session $_SESSION['username'] = $userInfo['data']['userName']; $_SESSION['uid'] = $userInfo['data']['userId']; if ($_POST['autoin'] == 1) { // 保存5天 $lifeTime = 5 * 24 * 3600; setcookie(session_name(), session_id(), time() + $lifeTime, '/'); } echo json_encode(array('status' => $userInfo['success'], 'info' => $userInfo['data'])); }