Commit 30c41b9c by doszhang

dos

parent e716a6f6
...@@ -20,22 +20,34 @@ class IndexController extends Controller ...@@ -20,22 +20,34 @@ class IndexController extends Controller
public function index() public function index()
{ {
$user = $this->get_user_info_from_cookie();
// 如果没有获取到用户信息,引导用户授权
if (!$user) {
$this->request_auth($this->get_url());
return;
}
session_start(); session_start();
$_SESSION['joinTime'] = time(); $_SESSION['joinTime'] = time();
if($this->isWeixin())
$this->assign('headimgurl'); {
$this->assign('user_header_url',$user['headimgurl']); $user = $this->get_user_info_from_cookie();
$this->assign('nickname',$user['nickname']); // 如果没有获取到用户信息,引导用户授权
if (!$user) {
$this->request_auth($this->get_url());
return;
}
$this->assign('headimgurl');
$this->assign('user_header_url',$user['headimgurl']);
$this->assign('nickname',$user['nickname']);
}
$this->display(); $this->display();
} }
private function isWeixin()
{
//return false;
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) {
return true;
}
return false;
}
function commit() { function commit() {
$referer = $_SERVER['HTTP_REFERER']; $referer = $_SERVER['HTTP_REFERER'];
$refererInfo = parse_url( $referer ); $refererInfo = parse_url( $referer );
...@@ -50,15 +62,22 @@ class IndexController extends Controller ...@@ -50,15 +62,22 @@ class IndexController extends Controller
header("HTTP/1.0 404 Not Found"); header("HTTP/1.0 404 Not Found");
exit; exit;
} }
$user = $this->get_user_info_from_cookie(); if($this->isWeixin())
if (!$user) { {
$this->ajaxReturn(array( $user = $this->get_user_info_from_cookie();
'status' => 404, if (!$user) {
'msg' => '用户信息错误', $this->ajaxReturn(array(
'step' => 0 'status' => 404,
)); 'msg' => '用户信息错误',
return; 'step' => 0
));
return;
}
} }
else {
$user['id'] = 'weibo';
}
$name = $_POST['name']; $name = $_POST['name'];
$tel = $_POST['tel']; $tel = $_POST['tel'];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment