Authored by yangyang

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into feature/web-list

... ... @@ -49,7 +49,10 @@ class WebAction extends Controller_Abstract
*/
public function init()
{
Mobile::isGoMobile();
if (!$this->isAjax()) {
Mobile::isGoMobile();
}
$this->_request = $this->getRequest();
// 设置环境变量
... ...
... ... @@ -20,7 +20,7 @@ class HelperSearch
//总页数
public static $pageTotal;
//总记录数
public static $total;
public static $total = 0;
//接口返回搜索条件
public static $filter;
//选中的条件
... ... @@ -142,10 +142,6 @@ class HelperSearch
}
//选中条件
$result['filters']['checkedConditions'] = self::getSelected();
if (empty($result['goods'])) {
$result['filters'] = array();
$result['opts'] = array();
}
$result['pathNav'] = isset($options['controller']) && $options['controller'] == 'Sale' ? array() : self::$listNav;
return $result;
}
... ... @@ -680,10 +676,6 @@ class HelperSearch
public static function price($filter)
{
$result = array();
//商品记录小于10,不显示价格区间
if (self::$total < 10) {
return $result;
}
$params = self::$params;
$priceId = isset($params['price']) && !empty(self::$params['price']) ? self::$params['price'] : '';
if (isset($params['price'])) {
... ... @@ -707,6 +699,10 @@ class HelperSearch
'href' => self::buildUrl($params)
);
}
//商品记录小于10,不显示价格区间
if (self::$total < 10) {
return $result;
}
if (self::checkSearch('price')) {
return array();
}
... ... @@ -1086,6 +1082,10 @@ class HelperSearch
public static function getSelected()
{
$result = array();
//无结果
if (self::$total == 0 && self::$options['controller'] == 'Search') {
return $result;
}
$data = array();
foreach (self::$selected as $key => $val) {
$data[] = $val;
... ... @@ -1386,6 +1386,10 @@ class HelperSearch
*/
public static function getOpts()
{
//无结果
if (self::$total == 0 && self::$options['controller'] == 'Search') {
return array();
}
//排序方式
$result['sortType'] = array( self::orderDefault(),self::orderTime(),self::orderPrice(),self::orderDiscount());
//特殊:新品、特价、限量
... ...
... ... @@ -49,29 +49,29 @@ class Mobile
public static function match($url, $host, $uri)
{
//guang.yohobuy.com
//guang.yohobuy.com/1.html
$list = array(
array(
'match' => '#^([guang\.]*)yohobuy\.com(\/*)$#',
),
array(
'match' => '#([guang\.]*)yohobuy.com/([0-9]+).html#',
'to' => 'guang.m.yohobuy.com/info/index?id='.substr($uri,1,(strpos($uri,'.')-1)) ,
),
);
foreach ($list as $value) {
if (preg_match($value['match'], $url) && !empty($value['to'])) {
return $value['to'];
} else if (preg_match($value['match'], $url)) {
$newHost = self::newHost($host);
return $newHost . $uri;
}
}
$continueList = array('www', 'list', 'search');
$hostSplit = explode('.', $host);
return 'm.yohobuy.com';
// //guang.yohobuy.com
// //guang.yohobuy.com/1.html
// $list = array(
// array(
// 'match' => '#^([guang\.]*)yohobuy\.com(\/*)$#',
// ),
// array(
// 'match' => '#([guang\.]*)yohobuy.com/([0-9]+).html#',
// 'to' => 'guang.m.yohobuy.com/info/index?id='.substr($uri,1,(strpos($uri,'.')-1)) ,
// ),
// );
// foreach ($list as $value) {
// if (preg_match($value['match'], $url) && !empty($value['to'])) {
// return $value['to'];
// } else if (preg_match($value['match'], $url)) {
// $newHost = self::newHost($host);
// return $newHost . $uri;
// }
// }
//
// $continueList = array('www', 'list', 'search');
// $hostSplit = explode('.', $host);
return 'm.yohobuy.com' . $uri;
}
/**
... ... @@ -91,18 +91,18 @@ class Mobile
public static function isMobile()
{
$userAgent = self::getUserAgent();
$mobile_agents = Array("240x320","acer","acoon","acs-","abacho","ahong","airness","alcatel","amoi","android","anywhereyougo.com","applewebkit/525","applewebkit/532","asus","audio","au-mic","avantogo","becker","benq","bilbo","bird","blackberry","blazer","bleu","cdm-","compal","coolpad","danger","dbtel","dopod","elaine","eric","etouch","fly ","fly_","fly-","go.web","goodaccess","gradiente","grundig","haier","hedy","hitachi","htc","huawei","hutchison","inno","ipad","ipaq","ipod","jbrowser","kddi","kgt","kwc","lenovo","lg ","lg2","lg3","lg4","lg5","lg7","lg8","lg9","lg-","lge-","lge9","longcos","maemo","mercator","meridian","micromax","midp","mini","mitsu","mmm","mmp","mobi","mot-","moto","nec-","netfront","newgen","nexian","nf-browser","nintendo","nitro","nokia","nook","novarra","obigo","palm","panasonic","pantech","philips","phone","pg-","playstation","pocket","pt-","qc-","qtek","rover","sagem","sama","samu","sanyo","samsung","sch-","scooter","sec-","sendo","sgh-","sharp","siemens","sie-","softbank","sony","spice","sprint","spv","symbian","tablet","talkabout","tcl-","teleca","telit","tianyu","tim-","toshiba","tsm","up.browser","utec","utstar","verykool","virgin","vk-","voda","voxtel","vx","wap","wellco","wig browser","wii","windows ce","wireless","xda","xde","zte");
$is_mobile = false;
if (stristr($userAgent, 'ipad')) {
return $is_mobile;
return false;
}
foreach ($mobile_agents as $device) {
$mobileAgents = array('iphone','android',"240x320","acer","acoon","acs-","abacho","ahong","airness","alcatel","amoi","anywhereyougo.com","applewebkit/525","applewebkit/532","asus","audio","au-mic","avantogo","becker","benq","bilbo","bird","blackberry","blazer","bleu","cdm-","compal","coolpad","danger","dbtel","dopod","elaine","eric","etouch","fly ","fly_","fly-","go.web","goodaccess","gradiente","grundig","haier","hedy","hitachi","htc","huawei","hutchison","inno","ipad","ipaq","ipod","jbrowser","kddi","kgt","kwc","lenovo","lg ","lg2","lg3","lg4","lg5","lg7","lg8","lg9","lg-","lge-","lge9","longcos","maemo","mercator","meridian","micromax","midp","mini","mitsu","mmm","mmp","mobi","mot-","moto","nec-","netfront","newgen","nexian","nf-browser","nintendo","nitro","nokia","nook","novarra","obigo","palm","panasonic","pantech","philips","phone","pg-","playstation","pocket","pt-","qc-","qtek","rover","sagem","sama","samu","sanyo","samsung","sch-","scooter","sec-","sendo","sgh-","sharp","siemens","sie-","softbank","sony","spice","sprint","spv","symbian","tablet","talkabout","tcl-","teleca","telit","tianyu","tim-","toshiba","tsm","up.browser","utec","utstar","verykool","virgin","vk-","voda","voxtel","vx","wap","wellco","wig browser","wii","windows ce","wireless","xda","xde","zte");
$isMobile = false;
foreach ($mobileAgents as $device) {
if (stristr($userAgent, $device)) {
$is_mobile = true;
$isMobile = true;
break;
}
}
return $is_mobile;
return $isMobile;
}
/**
... ... @@ -112,10 +112,9 @@ class Mobile
public static function isGoMobile()
{
if (empty($_COOKIE['m2w']) && self::isMobile()) {
$newUrl = self::getNewUrl();
Header("HTTP/1.1 301 Moved Permanently");
header('Location:http://'.$newUrl);
exit;
header("HTTP/1.1 301 Moved Permanently");
header('Location:http://'.self::getNewUrl());
exit();
}
return true;
}
... ...
{{> layout/page-footer}}
{{#if rlsEnv}}
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/lib.js"></script>
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/index.js"></script>
{{/if}}
{{#if preEnv}}
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/lib.js"></script>
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/index-debug.js"></script>
{{/if}}
{{#if testEnv}}
<script src="http://static.buy.test.yoho.cn/dist/yohobuy/{{version}}/lib.js"></script>
<script src="http://static.buy.test.yoho.cn/dist/yohobuy/{{version}}/index-debug.js"></script>
{{/if}}
{{#if devEnv}}
<script src="http://localhost:8001/static/js/sea.js?nowrap"></script>
<script>
seajs.config({
base: 'http://localhost:8001/'
});
</script>
{{/if}}
{{> layout/use}}
{{> layout/analysis}}
</body>
</html>
{{> layout/page-footer}}
{{#if rlsEnv}}
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/lib.js"></script>
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/index.js"></script>
{{/if}}
{{#if preEnv}}
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/lib.js"></script>
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/index-debug.js"></script>
{{/if}}
{{#if testEnv}}
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/lib.js"></script>
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/index-debug.js"></script>
{{/if}}
{{#if devEnv}}
<script src="http://localhost:8001/static/js/sea.js?nowrap"></script>
<script>
seajs.config({
base: 'http://localhost:8001/'
});
</script>
{{/if}}
{{> layout/use}}
{{> layout/analysis}}
</body>
</html>
... ...
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<meta name="renderer" content="webkit">
<meta name="keywords" content="{{keywords}}">
<meta name="description" content="{{description}}">
<title>{{title}}</title>
<link rel="dns-prefetch" href="//cdn.yoho.cn">
<link rel="dns-prefetch" href="//static.yohobuy.com">
<link rel="dns-prefetch" href="//img10.static.yhbimg.com">
<link rel="dns-prefetch" href="//img11.static.yhbimg.com">
<link rel="dns-prefetch" href="//img12.static.yhbimg.com">
<link rel="dns-prefetch" href="//img13.static.yhbimg.com">
{{#if rlsEnv}}
<link rel="stylesheet" href="http://cdn.yoho.cn/yohobuy/{{version}}/index.css">
{{/if}}
{{#if preEnv}}
<link rel="stylesheet" href="http://cdn.yoho.cn/yohobuy/{{version}}/index.css">
{{/if}}
{{#if testEnv}}
<link rel="stylesheet" href="http://static.buy.test.yoho.cn/dist/yohobuy/{{version}}/index.css">
{{/if}}
{{#if devEnv}}
<link rel="stylesheet" href="http://webstatic.dev.yohobuy.com/css/index.css">
{{/if}}
</head>
<body>
{{> layout/page-header}}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<meta name="renderer" content="webkit">
<meta name="keywords" content="{{keywords}}">
<meta name="description" content="{{description}}">
<title>{{title}}</title>
<link rel="dns-prefetch" href="//cdn.yoho.cn">
<link rel="dns-prefetch" href="//static.yohobuy.com">
<link rel="dns-prefetch" href="//img10.static.yhbimg.com">
<link rel="dns-prefetch" href="//img11.static.yhbimg.com">
<link rel="dns-prefetch" href="//img12.static.yhbimg.com">
<link rel="dns-prefetch" href="//img13.static.yhbimg.com">
{{#if rlsEnv}}
<link rel="stylesheet" href="http://cdn.yoho.cn/yohobuy/{{version}}/index.css">
{{/if}}
{{#if preEnv}}
<link rel="stylesheet" href="http://cdn.yoho.cn/yohobuy/{{version}}/index.css">
{{/if}}
{{#if testEnv}}
<link rel="stylesheet" href="http://cdn.yoho.cn/yohobuy/{{version}}/index.css">
{{/if}}
{{#if devEnv}}
<link rel="stylesheet" href="http://webstatic.dev.yohobuy.com/css/index.css">
{{/if}}
</head>
<body>
{{> layout/page-header}}
{{> layout/simple-header}}
\ No newline at end of file
... ...
<?php
use Action\WebAction;
use WebPlugin\Cache;
use Configs\WebCacheConfig;
use WebPlugin\AuthCode;
use Index\HomeModel;
class ToolsController extends WebAction
{
public function init()
{
$valid_passwords = array ('test' => '123456');
$valid_users = array_keys($valid_passwords);
$user = $pass = '';
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_USER']))
{
$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];
}
$validated = (in_array($user, $valid_users)) && ($pass == $valid_passwords[$user]);
if (!$validated) {
header('WWW-Authenticate: Basic realm="www.yohobuy.com"');
header('HTTP/1.0 401 Unauthorized');
die ("Not authorized");
}
}
/**
* 缓存html
*
*/
public function cacheAction()
{
//频道=>key
$channels = array(
'导航' => WebCacheConfig::KEY_WEB_HOME_NAVBAR_DATA,
'男生首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_BOYS_CHANNEL,
'女生首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_GIRLS_CHANNEL,
'kids首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_KIDS_CHANNEL,
'lifestyle首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_LIFESTYLE_CHANNEL,
);
$html = '';
foreach ($channels as $key => $val) {
$url = '/tools/cacheclear?key='.urlencode(AuthCode::encode($val, 'yohobuy'));
$html.= sprintf('<li><a href="%s" target="_blank">清除%s缓存</a></li>',$url, $key);
}
echo $html;
}
/**
* 清除缓存
*
* @return json
*/
public function cacheclearAction()
{
$key = $this->get('key');
if(!empty($key)) {
$key = AuthCode::decode($key, 'yohobuy');
if(!empty($key)) {
//导航清除
if($key == WebCacheConfig::KEY_WEB_HOME_NAVBAR_DATA) {
$list = array(HomeModel::COOKIE_NAME_BOYS, HomeModel::COOKIE_NAME_GIRLS, HomeModel::COOKIE_NAME_KIDS, HomeModel::COOKIE_NAME_LIFESTYLE);
foreach ($list as $val) {
Cache::delete($key.'_'.$val);
}
} else {
Cache::delete($key);
}
echo '清除成功';
}
}
}
public function logAction()
{
print_r($_SERVER);
}
}
<?php
use Action\WebAction;
use WebPlugin\Cache;
use Configs\WebCacheConfig;
use WebPlugin\AuthCode;
use Index\HomeModel;
use Api\Yohobuy;
use Api\Sign;
use LibModels\Web\Home\IndexData;
class ToolsController extends WebAction
{
public function init()
{
if(APPLICATION_ENV == 'production') {
$valid_passwords = array ('yoho' => '9646abcdef');
} else {
$valid_passwords = array ('test' => '123456');
}
$valid_users = array_keys($valid_passwords);
$user = $pass = '';
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_USER']))
{
$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];
}
$validated = (in_array($user, $valid_users)) && ($pass == $valid_passwords[$user]);
if (!$validated) {
header('WWW-Authenticate: Basic realm="www.yohobuy.com"');
header('HTTP/1.0 401 Unauthorized');
die ("Not authorized");
}
}
/**
* 工具首页
*/
public function indexAction()
{
$html = '<br/><h2>工具首页</h2><br/>';
$channels = array('JAVA API'=>'/tools/javaapi', '缓存页面' =>'/tools/cache');
foreach($channels as $name => $url) {
$html .= sprintf('<li style="font-size:18px;"><a href="%s" target="_blank">%s</a></li>',$url, $name);
}
echo $html;
}
/**
* java api测试
*
*/
public function javaapiAction()
{
$html = '<br/><h3>java api测试</h3><br/>';
$channels = array('获取资源位'=> $this->getResourceUrl(), '获取最新上架' =>'');
foreach($channels as $name => $url) {
$html .= sprintf('<li style="font-size:18px;"><a href="%s" target="_blank">%s</a></li>',$url, $name);
}
echo $html;
}
/**
* 获取资源位地址
*
* @return string
*/
private function getResourceUrl()
{
$client_type ='web';
$content_code = '0c911d3000f52e8ca7cffb74f5864c29';
$params = Yohobuy::param();
$params['content_code'] = $content_code;
$params['client_type'] = $client_type;
$params['private_key'] = Yohobuy::$privateKeyList[$client_type];
$params['client_secret'] = Sign::getSign($params);
return Yohobuy::httpBuildQuery(Yohobuy::SERVICE_URL.IndexData::URL_OPERATIONS_RESOURCE_GET, $params);
}
/**
* 缓存html
*/
public function cacheAction()
{
//频道=>key
$channels = array(
'导航' => WebCacheConfig::KEY_WEB_HOME_NAVBAR_DATA,
'男生首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_BOYS_CHANNEL,
'女生首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_GIRLS_CHANNEL,
'kids首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_KIDS_CHANNEL,
'lifestyle首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_LIFESTYLE_CHANNEL,
);
$html = '<br/><h3>缓存页面</h3><br/>';
foreach ($channels as $key => $val) {
$url = '/tools/cacheclear?key='.urlencode(AuthCode::encode($val, 'yohobuy'));
$html.= sprintf('<li><a href="%s" target="_blank">清除%s缓存</a></li>',$url, $key);
}
echo $html;
}
/**
* 清除缓存
*
* @return json
*/
public function cacheclearAction()
{
$key = $this->get('key');
if(!empty($key)) {
$key = AuthCode::decode($key, 'yohobuy');
if(!empty($key)) {
//导航清除
if($key == WebCacheConfig::KEY_WEB_HOME_NAVBAR_DATA) {
$list = array(HomeModel::COOKIE_NAME_BOYS, HomeModel::COOKIE_NAME_GIRLS, HomeModel::COOKIE_NAME_KIDS, HomeModel::COOKIE_NAME_LIFESTYLE);
foreach ($list as $val) {
Cache::delete($key.'_'.$val);
}
} else {
Cache::delete($key);
}
echo '清除成功';
}
}
}
public function logAction()
{
print_r($_SERVER);
}
}
?>
\ No newline at end of file
... ...
... ... @@ -9,10 +9,10 @@ use LibModels\Web\Home\IndexData;
use LibModels\Web\Product\SearchData;
use WebPlugin\DataProcess\Channel as ChannelProcess;
define('CODE_BOYS_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? '79372627eee75d73afe7f9bac91e5ce6' : 'c15bf0cbfbd4893fd70c869c991f6d3d');
define('CODE_GIRLS_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? '75215008957605c05e8cd375eac4f817' : 'a519ba44ef3a85cf3c05e405c6ba8e53');
define('CODE_KIDS_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? 'd71f4b27f2a7229fbb31a4bc490a6f36' : 'a7741b94e8bb9d56d0d36e00c05956f7');
define('CODE_LIFESTYLE_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? '8a341ca7eacc069ba80f02dec80eaf34' : '1b053fd044834f5c86d5eb15fb237af9');
// define('CODE_BOYS_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? '79372627eee75d73afe7f9bac91e5ce6' : 'c15bf0cbfbd4893fd70c869c991f6d3d');
// define('CODE_GIRLS_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? '75215008957605c05e8cd375eac4f817' : 'a519ba44ef3a85cf3c05e405c6ba8e53');
// define('CODE_KIDS_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? 'd71f4b27f2a7229fbb31a4bc490a6f36' : 'a7741b94e8bb9d56d0d36e00c05956f7');
// define('CODE_LIFESTYLE_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? '8a341ca7eacc069ba80f02dec80eaf34' : '1b053fd044834f5c86d5eb15fb237af9');
/**
... ... @@ -46,15 +46,15 @@ class HomeModel
//lifestyle:8a341ca7eacc069ba80f02dec80eaf34,1b053fd044834f5c86d5eb15fb237af9
// 男首首页
const CODE_BOYS_CHANNEL = '79372627eee75d73afe7f9bac91e5ce6';
const CODE_BOYS_CHANNEL = 'c15bf0cbfbd4893fd70c869c991f6d3d';
// 女首首页
const CODE_GIRLS_CHANNEL = '75215008957605c05e8cd375eac4f817';
const CODE_GIRLS_CHANNEL = 'a519ba44ef3a85cf3c05e405c6ba8e53';
// 潮童首页
const CODE_KIDS_CHANNEL = 'd71f4b27f2a7229fbb31a4bc490a6f36';
const CODE_KIDS_CHANNEL = 'a7741b94e8bb9d56d0d36e00c05956f7';
// 创意生活新
const CODE_LIFESTYLE_CHANNEL = '8a341ca7eacc069ba80f02dec80eaf34';
const CODE_LIFESTYLE_CHANNEL = '1b053fd044834f5c86d5eb15fb237af9';
// 创意生活
const CODE_LIFESTYLE_CHANNEL_1 = '380c38155fd8beee10913a3f5b462da6';
... ...
... ... @@ -137,20 +137,26 @@ class PassportModel
/*
* 重写递增计数 cache方法
* $key cache-key
* $key cache-key,递增存放变量
* $offset 递增偏移量
* $initValue 初始化值
* $expiry 缓存时间
*/
public static function increment($key, $offset = 1, $initValue = 0, $expire = 1800)
public static function increment($key, $timeKey, $offset = 1, $initValue = 0, $expire = 1800)
{
//初始化key
if (!Cache::get($key)) {
Cache::set($key, $initValue, $expire);
//有效期之外清除key
if (!Cache::get($timeKey) && Cache::get($key)) {
Cache::delete($key);
}
//初始化计时
if (!Cache::get($timeKey) && !Cache::get($key)) {
Cache::set($timeKey, TRUE, $expire);
Cache::set($key, $initValue);
}
//增加偏移量
$cacheValue = intval(Cache::get($key))+$offset;
Cache::set($key, $cacheValue, $expire);
//未过期则递增
$cacheValue = intval(Cache::get($key)) + $offset;
Cache::set($key, $cacheValue);
}
}
... ...
... ... @@ -113,7 +113,7 @@ class AutouserinfoController extends WebAction
}
//未注册 未绑定
if ($res['code'] == 200) {
$next = Helpers::url('/thirdlogin/index', array(
$next = Helpers::url('/thirdlogin/noregist', array(
'openId' => $openId,
'sourceType' => $sourceType,
'area' => $area,
... ... @@ -135,6 +135,9 @@ class AutouserinfoController extends WebAction
$this->echoJson($data);
}
/*
* 根据手机号获取用户相关信息
*/
public static function getUserInfo($area, $mobile)
{
$userInfo = UserData::getUserInfoByMobile($area, $mobile);
... ... @@ -162,16 +165,16 @@ class AutouserinfoController extends WebAction
break;
}
$phoneNum = trim($this->post('mobile'));
$areaCode = trim($this->post('area'));
$mobile = trim($this->post('mobile'));
$area = trim($this->post('area'));
//校验手机号格式
if (!is_numeric($phoneNum) || !is_numeric($areaCode)) {
if (!is_numeric($mobile) || !is_numeric($area)) {
$data['code'] = 400;
$data['message'] = '手机号码格式不正确';
break;
}
$data = BindData::sendBindMsg($areaCode, $phoneNum);
$data = BindData::sendBindMsg($area, $mobile);
if (!isset($data['code'])) {
break;
}
... ... @@ -194,17 +197,17 @@ class AutouserinfoController extends WebAction
break;
}
$phoneNum = trim($this->post('mobile'));
$areaCode = trim($this->post('area'));
$mobile = trim($this->post('mobile'));
$area= trim($this->post('area'));
$code = trim($this->post('code')); //短信验证码
//校验手机号格式
if (!is_numeric($phoneNum) || !is_numeric($areaCode)) {
if (!is_numeric($mobile) || !is_numeric($area)) {
$data['code'] = 400;
$data['message'] = '手机号码格式不正确';
break;
}
$data = BindData::checkBindCode($areaCode, $phoneNum, $code);
$data = BindData::checkBindCode($area, $mobile, $code);
if (!isset($data['code'])) {
break;
}
... ... @@ -227,8 +230,8 @@ class AutouserinfoController extends WebAction
break;
}
$phoneNum = trim($this->post('mobile'));
$areaCode = trim($this->post('area', '86'));
$mobile = trim($this->post('mobile'));
$area = trim($this->post('area', '86'));
$openId = trim($this->post('openId'));
$sourceType = trim($this->post('sourceType'));
$code = trim($this->post('code')); //短信验证码
... ... @@ -236,20 +239,20 @@ class AutouserinfoController extends WebAction
$password = empty($password) ? '' : $password;
//校验手机号格式
if (!is_numeric($phoneNum) || !is_numeric($areaCode)) {
if (!is_numeric($mobile) || !is_numeric($area)) {
$data['code'] = 400;
$data['message'] = '手机号码格式不正确';
break;
}
//校验手机验证码
$bindMsgFlag = BindData::checkBindCode($areaCode, $phoneNum, $code);
$bindMsgFlag = BindData::checkBindCode($area, $mobile, $code);
if (isset($bindMsgFlag['code']) && $bindMsgFlag['code'] != 200) {
$data['code'] = 400;
$data['message'] = '短信验证码不正确';
break;
}
//绑定手机号
$res = BindData::bindMobile($openId, $sourceType, $phoneNum, $areaCode, $password);
$res = BindData::bindMobile($openId, $sourceType, $mobile, $area, $password);
if (!isset($res['code'])) {
break;
}
... ...
... ... @@ -28,7 +28,7 @@ class LoginController extends WebAction
if (!strstr($refer, 'http')) {
$refer = SITE_MAIN . $refer;
}
if (!empty($refer)) {
$this->setCookie('refer', $refer);
}
... ... @@ -70,7 +70,7 @@ class LoginController extends WebAction
*/
public function authAction()
{
$data = array('code' => 400, 'message' => '您输入的密码及账户名不匹配,是否<a href="'.Helpers::url('/passport/back/index').'" target="_blank">忘记密码?</a>', 'data' => '');
$data = array('code' => 400, 'message' => '您输入的密码及账户名不匹配,是否<a href="' . Helpers::url('/passport/back/index') . '" target="_blank">忘记密码?</a>', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
... ... @@ -108,26 +108,43 @@ class LoginController extends WebAction
*/
$ip = Helpers::getClientIp();
$ipKey = md5('ip_signin_' . $ip);
$ipTimeKey = md5('ip_signin_time' . $ip);
$accountKey = md5('account_signin_' . $account);
PassportModel::increment($ipKey, 1, 0, 3600);
$accountTimeKey = md5('account_signin_time' . $account);
//cache初始化,非有效时间内清除次数,有效时间内叠加cache计数
if (!Cache::get($accountTimeKey) && Cache::get($accountKey)) {
Cache::delete($accountKey);
}
if (!Cache::get($accountTimeKey) && !Cache::get($accountKey)) {
Cache::set($accountTimeKey, true, 1800);
Cache::set($accountKey, 0);
}
if (!Cache::get($ipTimeKey) && Cache::get($ipKey)) {
Cache::delete($ipKey);
}
if (!Cache::get($ipTimeKey) && !Cache::get($ipKey)) {
Cache::set($ipTimeKey, true, 3600);
Cache::set($ipKey, 0);
}
$accountTimes = Cache::get($accountKey);
if ($accountTimes > 10) {
$ipTimes = Cache::get($ipKey);
if ($accountTimes >= 10) {
$data = array('code' => 400, 'message' => '您的账号已被暂时锁定,请稍后再试', 'data' => '');
break;
}
$ipTimes = Cache::get($ipKey);
if ($ipTimes > 100) {
if ($ipTimes >= 100) {
$data = array('code' => 400, 'message' => '您尝试的次数过多,账号已被暂时锁定,请稍后再试', 'data' => '');
break;
}
$data = LoginData::signin($area, $account, $password, $shoppingKey);
if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) {
PassportModel::increment($accountKey, 1, 0, 1800);
$data = array('code' => 400, 'message' => '您输入的密码及账户名不匹配,是否<a href="'.Helpers::url('/passport/back/index').'" target="_blank">忘记密码?</a>', 'data' => '');
Cache::set($accountKey, intval(Cache::get($accountKey)) + 1);
Cache::set($ipKey, intval(Cache::get($ipKey)) + 1);
$data = array('code' => 400, 'message' => '您输入的密码及账户名不匹配,是否<a href="' . Helpers::url('/passport/back/index') . '" target="_blank">忘记密码?</a>', 'data' => '');
break;
}
//登录成功
$refer = $this->getCookie('refer');
if (empty($refer) || strstr($refer, 'signin.html') || strstr($refer, 'passport/login/index')) {
$refer = SITE_MAIN;
... ...
... ... @@ -48,7 +48,8 @@ class RegisterController extends WebAction
$ip = Helpers::getClientIp();
$data = array('code' => 400, 'message' => '', 'data' => '');
$ipKey = md5('ip_checkmobile_' . $ip);
PassportModel::increment($ipKey, 1, 0, 3600);
$ipTimeKey = md5('ip_checkmobile_time_' . $ip);
PassportModel::increment($ipKey,$ipTimeKey,1, 0, 3600);
$ipTimes = Cache::get($ipKey);
do{
/* 判断是不是AJAX请求 */
... ... @@ -60,7 +61,7 @@ class RegisterController extends WebAction
$data['message'] = '手机号码格式不正确';
break;
}
if ($ipTimes >= 500) {
if ($ipTimes > 500) {
$data['message'] = '由于你IP受限无法注册';
break;
}
... ... @@ -130,7 +131,8 @@ class RegisterController extends WebAction
}
//发送代码
$sendCodeKey = md5('send_code_' . $area . '_' . $mobile);
PassportModel::increment($sendCodeKey, 1, 0, 3600);
$sendCodeTimeKey = md5('send_code_time_' . $area . '_' . $mobile);
PassportModel::increment($sendCodeKey,$sendCodeTimeKey, 1, 0, 3600);
$sendCodeTimes = Cache::get($sendCodeKey);
if ($sendCodeTimes > 50) {
$data['message'] = '发送验证码太多';
... ...
... ... @@ -3,6 +3,7 @@
use Action\WebAction;
use Passport\PassportModel;
use LibModels\Wap\Passport\RegData;
use WebPlugin\Helpers;
class ThirdloginController extends WebAction
{
... ... @@ -24,8 +25,8 @@ class ThirdloginController extends WebAction
'simpleHeader' => $simpleHeader,
'openId' => $openId,
'sourceType' => $sourceType,
'region' => RegData::getAreasData(),
'serviceUrl' => Helpers::url('/help', array('category_id' => 9))
'region' => RegData::getAreasData(),//区域
'serviceUrl' => Helpers::url('/help', array('category_id' => 9))//服务条款
);
$this->_view->display('index', $data);
... ...
... ... @@ -3,7 +3,7 @@
use Action\WebAction;
use LibModels\Web\Product\FavoriteData;
use Product\BrandsModel;
use product\HotrankModel;
use Product\HotrankModel;
class IndexController extends WebAction
{
... ...