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 @@ -49,7 +49,10 @@ class WebAction extends Controller_Abstract
49 */ 49 */
50 public function init() 50 public function init()
51 { 51 {
52 - Mobile::isGoMobile(); 52 + if (!$this->isAjax()) {
  53 + Mobile::isGoMobile();
  54 + }
  55 +
53 $this->_request = $this->getRequest(); 56 $this->_request = $this->getRequest();
54 57
55 // 设置环境变量 58 // 设置环境变量
@@ -20,7 +20,7 @@ class HelperSearch @@ -20,7 +20,7 @@ class HelperSearch
20 //总页数 20 //总页数
21 public static $pageTotal; 21 public static $pageTotal;
22 //总记录数 22 //总记录数
23 - public static $total; 23 + public static $total = 0;
24 //接口返回搜索条件 24 //接口返回搜索条件
25 public static $filter; 25 public static $filter;
26 //选中的条件 26 //选中的条件
@@ -142,10 +142,6 @@ class HelperSearch @@ -142,10 +142,6 @@ class HelperSearch
142 } 142 }
143 //选中条件 143 //选中条件
144 $result['filters']['checkedConditions'] = self::getSelected(); 144 $result['filters']['checkedConditions'] = self::getSelected();
145 - if (empty($result['goods'])) {  
146 - $result['filters'] = array();  
147 - $result['opts'] = array();  
148 - }  
149 $result['pathNav'] = isset($options['controller']) && $options['controller'] == 'Sale' ? array() : self::$listNav; 145 $result['pathNav'] = isset($options['controller']) && $options['controller'] == 'Sale' ? array() : self::$listNav;
150 return $result; 146 return $result;
151 } 147 }
@@ -680,10 +676,6 @@ class HelperSearch @@ -680,10 +676,6 @@ class HelperSearch
680 public static function price($filter) 676 public static function price($filter)
681 { 677 {
682 $result = array(); 678 $result = array();
683 - //商品记录小于10,不显示价格区间  
684 - if (self::$total < 10) {  
685 - return $result;  
686 - }  
687 $params = self::$params; 679 $params = self::$params;
688 $priceId = isset($params['price']) && !empty(self::$params['price']) ? self::$params['price'] : ''; 680 $priceId = isset($params['price']) && !empty(self::$params['price']) ? self::$params['price'] : '';
689 if (isset($params['price'])) { 681 if (isset($params['price'])) {
@@ -707,6 +699,10 @@ class HelperSearch @@ -707,6 +699,10 @@ class HelperSearch
707 'href' => self::buildUrl($params) 699 'href' => self::buildUrl($params)
708 ); 700 );
709 } 701 }
  702 + //商品记录小于10,不显示价格区间
  703 + if (self::$total < 10) {
  704 + return $result;
  705 + }
710 if (self::checkSearch('price')) { 706 if (self::checkSearch('price')) {
711 return array(); 707 return array();
712 } 708 }
@@ -1086,6 +1082,10 @@ class HelperSearch @@ -1086,6 +1082,10 @@ class HelperSearch
1086 public static function getSelected() 1082 public static function getSelected()
1087 { 1083 {
1088 $result = array(); 1084 $result = array();
  1085 + //无结果
  1086 + if (self::$total == 0 && self::$options['controller'] == 'Search') {
  1087 + return $result;
  1088 + }
1089 $data = array(); 1089 $data = array();
1090 foreach (self::$selected as $key => $val) { 1090 foreach (self::$selected as $key => $val) {
1091 $data[] = $val; 1091 $data[] = $val;
@@ -1386,6 +1386,10 @@ class HelperSearch @@ -1386,6 +1386,10 @@ class HelperSearch
1386 */ 1386 */
1387 public static function getOpts() 1387 public static function getOpts()
1388 { 1388 {
  1389 + //无结果
  1390 + if (self::$total == 0 && self::$options['controller'] == 'Search') {
  1391 + return array();
  1392 + }
1389 //排序方式 1393 //排序方式
1390 $result['sortType'] = array( self::orderDefault(),self::orderTime(),self::orderPrice(),self::orderDiscount()); 1394 $result['sortType'] = array( self::orderDefault(),self::orderTime(),self::orderPrice(),self::orderDiscount());
1391 //特殊:新品、特价、限量 1395 //特殊:新品、特价、限量
@@ -49,29 +49,29 @@ class Mobile @@ -49,29 +49,29 @@ class Mobile
49 49
50 public static function match($url, $host, $uri) 50 public static function match($url, $host, $uri)
51 { 51 {
52 - //guang.yohobuy.com  
53 - //guang.yohobuy.com/1.html  
54 - $list = array(  
55 - array(  
56 - 'match' => '#^([guang\.]*)yohobuy\.com(\/*)$#',  
57 - ),  
58 - array(  
59 - 'match' => '#([guang\.]*)yohobuy.com/([0-9]+).html#',  
60 - 'to' => 'guang.m.yohobuy.com/info/index?id='.substr($uri,1,(strpos($uri,'.')-1)) ,  
61 - ),  
62 - );  
63 - foreach ($list as $value) {  
64 - if (preg_match($value['match'], $url) && !empty($value['to'])) {  
65 - return $value['to'];  
66 - } else if (preg_match($value['match'], $url)) {  
67 - $newHost = self::newHost($host);  
68 - return $newHost . $uri;  
69 - }  
70 - }  
71 -  
72 - $continueList = array('www', 'list', 'search');  
73 - $hostSplit = explode('.', $host);  
74 - return 'm.yohobuy.com'; 52 +// //guang.yohobuy.com
  53 +// //guang.yohobuy.com/1.html
  54 +// $list = array(
  55 +// array(
  56 +// 'match' => '#^([guang\.]*)yohobuy\.com(\/*)$#',
  57 +// ),
  58 +// array(
  59 +// 'match' => '#([guang\.]*)yohobuy.com/([0-9]+).html#',
  60 +// 'to' => 'guang.m.yohobuy.com/info/index?id='.substr($uri,1,(strpos($uri,'.')-1)) ,
  61 +// ),
  62 +// );
  63 +// foreach ($list as $value) {
  64 +// if (preg_match($value['match'], $url) && !empty($value['to'])) {
  65 +// return $value['to'];
  66 +// } else if (preg_match($value['match'], $url)) {
  67 +// $newHost = self::newHost($host);
  68 +// return $newHost . $uri;
  69 +// }
  70 +// }
  71 +//
  72 +// $continueList = array('www', 'list', 'search');
  73 +// $hostSplit = explode('.', $host);
  74 + return 'm.yohobuy.com' . $uri;
75 } 75 }
76 76
77 /** 77 /**
@@ -91,18 +91,18 @@ class Mobile @@ -91,18 +91,18 @@ class Mobile
91 public static function isMobile() 91 public static function isMobile()
92 { 92 {
93 $userAgent = self::getUserAgent(); 93 $userAgent = self::getUserAgent();
94 - $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");  
95 - $is_mobile = false;  
96 if (stristr($userAgent, 'ipad')) { 94 if (stristr($userAgent, 'ipad')) {
97 - return $is_mobile; 95 + return false;
98 } 96 }
99 - foreach ($mobile_agents as $device) { 97 + $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");
  98 + $isMobile = false;
  99 + foreach ($mobileAgents as $device) {
100 if (stristr($userAgent, $device)) { 100 if (stristr($userAgent, $device)) {
101 - $is_mobile = true; 101 + $isMobile = true;
102 break; 102 break;
103 } 103 }
104 } 104 }
105 - return $is_mobile; 105 + return $isMobile;
106 } 106 }
107 107
108 /** 108 /**
@@ -112,10 +112,9 @@ class Mobile @@ -112,10 +112,9 @@ class Mobile
112 public static function isGoMobile() 112 public static function isGoMobile()
113 { 113 {
114 if (empty($_COOKIE['m2w']) && self::isMobile()) { 114 if (empty($_COOKIE['m2w']) && self::isMobile()) {
115 - $newUrl = self::getNewUrl();  
116 - Header("HTTP/1.1 301 Moved Permanently");  
117 - header('Location:http://'.$newUrl);  
118 - exit; 115 + header("HTTP/1.1 301 Moved Permanently");
  116 + header('Location:http://'.self::getNewUrl());
  117 + exit();
119 } 118 }
120 return true; 119 return true;
121 } 120 }
1 - {{> layout/page-footer}}  
2 - {{#if rlsEnv}}  
3 - <script src="http://cdn.yoho.cn/yohobuy/{{version}}/lib.js"></script>  
4 - <script src="http://cdn.yoho.cn/yohobuy/{{version}}/index.js"></script>  
5 - {{/if}}  
6 - {{#if preEnv}}  
7 - <script src="http://cdn.yoho.cn/yohobuy/{{version}}/lib.js"></script>  
8 - <script src="http://cdn.yoho.cn/yohobuy/{{version}}/index-debug.js"></script>  
9 - {{/if}}  
10 - {{#if testEnv}}  
11 - <script src="http://static.buy.test.yoho.cn/dist/yohobuy/{{version}}/lib.js"></script>  
12 - <script src="http://static.buy.test.yoho.cn/dist/yohobuy/{{version}}/index-debug.js"></script>  
13 - {{/if}}  
14 - {{#if devEnv}}  
15 - <script src="http://localhost:8001/static/js/sea.js?nowrap"></script>  
16 - <script>  
17 - seajs.config({  
18 - base: 'http://localhost:8001/'  
19 - });  
20 - </script>  
21 - {{/if}}  
22 - {{> layout/use}}  
23 - {{> layout/analysis}}  
24 - </body>  
25 -</html> 1 + {{> layout/page-footer}}
  2 + {{#if rlsEnv}}
  3 + <script src="http://cdn.yoho.cn/yohobuy/{{version}}/lib.js"></script>
  4 + <script src="http://cdn.yoho.cn/yohobuy/{{version}}/index.js"></script>
  5 + {{/if}}
  6 + {{#if preEnv}}
  7 + <script src="http://cdn.yoho.cn/yohobuy/{{version}}/lib.js"></script>
  8 + <script src="http://cdn.yoho.cn/yohobuy/{{version}}/index-debug.js"></script>
  9 + {{/if}}
  10 + {{#if testEnv}}
  11 + <script src="http://cdn.yoho.cn/yohobuy/{{version}}/lib.js"></script>
  12 + <script src="http://cdn.yoho.cn/yohobuy/{{version}}/index-debug.js"></script>
  13 + {{/if}}
  14 + {{#if devEnv}}
  15 + <script src="http://localhost:8001/static/js/sea.js?nowrap"></script>
  16 + <script>
  17 + seajs.config({
  18 + base: 'http://localhost:8001/'
  19 + });
  20 + </script>
  21 + {{/if}}
  22 + {{> layout/use}}
  23 + {{> layout/analysis}}
  24 + </body>
  25 +</html>
1 -<!DOCTYPE html>  
2 -<html>  
3 -<head>  
4 - <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />  
5 - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
6 - <meta http-equiv="Cache-Control" content="no-siteapp" />  
7 - <meta name="renderer" content="webkit">  
8 - <meta name="keywords" content="{{keywords}}">  
9 - <meta name="description" content="{{description}}">  
10 - <title>{{title}}</title>  
11 - <link rel="dns-prefetch" href="//cdn.yoho.cn">  
12 - <link rel="dns-prefetch" href="//static.yohobuy.com">  
13 - <link rel="dns-prefetch" href="//img10.static.yhbimg.com">  
14 - <link rel="dns-prefetch" href="//img11.static.yhbimg.com">  
15 - <link rel="dns-prefetch" href="//img12.static.yhbimg.com">  
16 - <link rel="dns-prefetch" href="//img13.static.yhbimg.com">  
17 -{{#if rlsEnv}}  
18 - <link rel="stylesheet" href="http://cdn.yoho.cn/yohobuy/{{version}}/index.css">  
19 -{{/if}}  
20 -{{#if preEnv}}  
21 - <link rel="stylesheet" href="http://cdn.yoho.cn/yohobuy/{{version}}/index.css">  
22 -{{/if}}  
23 -{{#if testEnv}}  
24 - <link rel="stylesheet" href="http://static.buy.test.yoho.cn/dist/yohobuy/{{version}}/index.css">  
25 -{{/if}}  
26 -{{#if devEnv}}  
27 - <link rel="stylesheet" href="http://webstatic.dev.yohobuy.com/css/index.css">  
28 -{{/if}}  
29 -</head>  
30 -<body>  
31 - {{> layout/page-header}} 1 +<!DOCTYPE html>
  2 +<html>
  3 +<head>
  4 + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  5 + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6 + <meta http-equiv="Cache-Control" content="no-siteapp" />
  7 + <meta name="renderer" content="webkit">
  8 + <meta name="keywords" content="{{keywords}}">
  9 + <meta name="description" content="{{description}}">
  10 + <title>{{title}}</title>
  11 + <link rel="dns-prefetch" href="//cdn.yoho.cn">
  12 + <link rel="dns-prefetch" href="//static.yohobuy.com">
  13 + <link rel="dns-prefetch" href="//img10.static.yhbimg.com">
  14 + <link rel="dns-prefetch" href="//img11.static.yhbimg.com">
  15 + <link rel="dns-prefetch" href="//img12.static.yhbimg.com">
  16 + <link rel="dns-prefetch" href="//img13.static.yhbimg.com">
  17 +{{#if rlsEnv}}
  18 + <link rel="stylesheet" href="http://cdn.yoho.cn/yohobuy/{{version}}/index.css">
  19 +{{/if}}
  20 +{{#if preEnv}}
  21 + <link rel="stylesheet" href="http://cdn.yoho.cn/yohobuy/{{version}}/index.css">
  22 +{{/if}}
  23 +{{#if testEnv}}
  24 + <link rel="stylesheet" href="http://cdn.yoho.cn/yohobuy/{{version}}/index.css">
  25 +{{/if}}
  26 +{{#if devEnv}}
  27 + <link rel="stylesheet" href="http://webstatic.dev.yohobuy.com/css/index.css">
  28 +{{/if}}
  29 +</head>
  30 +<body>
  31 + {{> layout/page-header}}
32 {{> layout/simple-header}} 32 {{> layout/simple-header}}
1 -<?php  
2 -use Action\WebAction;  
3 -use WebPlugin\Cache;  
4 -use Configs\WebCacheConfig;  
5 -use WebPlugin\AuthCode;  
6 -use Index\HomeModel;  
7 -class ToolsController extends WebAction  
8 -{  
9 - public function init()  
10 - {  
11 - $valid_passwords = array ('test' => '123456');  
12 - $valid_users = array_keys($valid_passwords);  
13 - $user = $pass = '';  
14 - if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_USER']))  
15 - {  
16 - $user = $_SERVER['PHP_AUTH_USER'];  
17 - $pass = $_SERVER['PHP_AUTH_PW'];  
18 - }  
19 - $validated = (in_array($user, $valid_users)) && ($pass == $valid_passwords[$user]);  
20 - if (!$validated) {  
21 - header('WWW-Authenticate: Basic realm="www.yohobuy.com"');  
22 - header('HTTP/1.0 401 Unauthorized');  
23 - die ("Not authorized");  
24 - }  
25 - }  
26 -  
27 - /**  
28 - * 缓存html  
29 - *  
30 - */  
31 - public function cacheAction()  
32 - {  
33 - //频道=>key  
34 - $channels = array(  
35 - '导航' => WebCacheConfig::KEY_WEB_HOME_NAVBAR_DATA,  
36 - '男生首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_BOYS_CHANNEL,  
37 - '女生首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_GIRLS_CHANNEL,  
38 - 'kids首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_KIDS_CHANNEL,  
39 - 'lifestyle首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_LIFESTYLE_CHANNEL,  
40 - );  
41 - $html = '';  
42 - foreach ($channels as $key => $val) {  
43 - $url = '/tools/cacheclear?key='.urlencode(AuthCode::encode($val, 'yohobuy'));  
44 - $html.= sprintf('<li><a href="%s" target="_blank">清除%s缓存</a></li>',$url, $key);  
45 - }  
46 - echo $html;  
47 - }  
48 -  
49 - /**  
50 - * 清除缓存  
51 - *  
52 - * @return json  
53 - */  
54 - public function cacheclearAction()  
55 - {  
56 - $key = $this->get('key');  
57 - if(!empty($key)) {  
58 - $key = AuthCode::decode($key, 'yohobuy');  
59 - if(!empty($key)) {  
60 - //导航清除  
61 - if($key == WebCacheConfig::KEY_WEB_HOME_NAVBAR_DATA) {  
62 - $list = array(HomeModel::COOKIE_NAME_BOYS, HomeModel::COOKIE_NAME_GIRLS, HomeModel::COOKIE_NAME_KIDS, HomeModel::COOKIE_NAME_LIFESTYLE);  
63 - foreach ($list as $val) {  
64 - Cache::delete($key.'_'.$val);  
65 - }  
66 - } else {  
67 - Cache::delete($key);  
68 - }  
69 - echo '清除成功';  
70 - }  
71 - }  
72 - }  
73 -  
74 - public function logAction()  
75 - {  
76 - print_r($_SERVER);  
77 - }  
78 -}  
79 - 1 +<?php
  2 +use Action\WebAction;
  3 +use WebPlugin\Cache;
  4 +use Configs\WebCacheConfig;
  5 +use WebPlugin\AuthCode;
  6 +use Index\HomeModel;
  7 +use Api\Yohobuy;
  8 +use Api\Sign;
  9 +use LibModels\Web\Home\IndexData;
  10 +class ToolsController extends WebAction
  11 +{
  12 + public function init()
  13 + {
  14 + if(APPLICATION_ENV == 'production') {
  15 + $valid_passwords = array ('yoho' => '9646abcdef');
  16 + } else {
  17 + $valid_passwords = array ('test' => '123456');
  18 + }
  19 +
  20 + $valid_users = array_keys($valid_passwords);
  21 + $user = $pass = '';
  22 + if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_USER']))
  23 + {
  24 + $user = $_SERVER['PHP_AUTH_USER'];
  25 + $pass = $_SERVER['PHP_AUTH_PW'];
  26 + }
  27 + $validated = (in_array($user, $valid_users)) && ($pass == $valid_passwords[$user]);
  28 + if (!$validated) {
  29 + header('WWW-Authenticate: Basic realm="www.yohobuy.com"');
  30 + header('HTTP/1.0 401 Unauthorized');
  31 + die ("Not authorized");
  32 + }
  33 + }
  34 +
  35 + /**
  36 + * 工具首页
  37 + */
  38 + public function indexAction()
  39 + {
  40 + $html = '<br/><h2>工具首页</h2><br/>';
  41 + $channels = array('JAVA API'=>'/tools/javaapi', '缓存页面' =>'/tools/cache');
  42 + foreach($channels as $name => $url) {
  43 + $html .= sprintf('<li style="font-size:18px;"><a href="%s" target="_blank">%s</a></li>',$url, $name);
  44 + }
  45 + echo $html;
  46 + }
  47 +
  48 + /**
  49 + * java api测试
  50 + *
  51 + */
  52 + public function javaapiAction()
  53 + {
  54 + $html = '<br/><h3>java api测试</h3><br/>';
  55 + $channels = array('获取资源位'=> $this->getResourceUrl(), '获取最新上架' =>'');
  56 + foreach($channels as $name => $url) {
  57 + $html .= sprintf('<li style="font-size:18px;"><a href="%s" target="_blank">%s</a></li>',$url, $name);
  58 + }
  59 + echo $html;
  60 + }
  61 +
  62 + /**
  63 + * 获取资源位地址
  64 + *
  65 + * @return string
  66 + */
  67 + private function getResourceUrl()
  68 + {
  69 + $client_type ='web';
  70 + $content_code = '0c911d3000f52e8ca7cffb74f5864c29';
  71 + $params = Yohobuy::param();
  72 + $params['content_code'] = $content_code;
  73 + $params['client_type'] = $client_type;
  74 + $params['private_key'] = Yohobuy::$privateKeyList[$client_type];
  75 + $params['client_secret'] = Sign::getSign($params);
  76 + return Yohobuy::httpBuildQuery(Yohobuy::SERVICE_URL.IndexData::URL_OPERATIONS_RESOURCE_GET, $params);
  77 + }
  78 +
  79 + /**
  80 + * 缓存html
  81 + */
  82 + public function cacheAction()
  83 + {
  84 + //频道=>key
  85 + $channels = array(
  86 + '导航' => WebCacheConfig::KEY_WEB_HOME_NAVBAR_DATA,
  87 + '男生首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_BOYS_CHANNEL,
  88 + '女生首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_GIRLS_CHANNEL,
  89 + 'kids首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_KIDS_CHANNEL,
  90 + 'lifestyle首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_LIFESTYLE_CHANNEL,
  91 + );
  92 + $html = '<br/><h3>缓存页面</h3><br/>';
  93 + foreach ($channels as $key => $val) {
  94 + $url = '/tools/cacheclear?key='.urlencode(AuthCode::encode($val, 'yohobuy'));
  95 + $html.= sprintf('<li><a href="%s" target="_blank">清除%s缓存</a></li>',$url, $key);
  96 + }
  97 + echo $html;
  98 + }
  99 +
  100 + /**
  101 + * 清除缓存
  102 + *
  103 + * @return json
  104 + */
  105 + public function cacheclearAction()
  106 + {
  107 + $key = $this->get('key');
  108 + if(!empty($key)) {
  109 + $key = AuthCode::decode($key, 'yohobuy');
  110 + if(!empty($key)) {
  111 + //导航清除
  112 + if($key == WebCacheConfig::KEY_WEB_HOME_NAVBAR_DATA) {
  113 + $list = array(HomeModel::COOKIE_NAME_BOYS, HomeModel::COOKIE_NAME_GIRLS, HomeModel::COOKIE_NAME_KIDS, HomeModel::COOKIE_NAME_LIFESTYLE);
  114 + foreach ($list as $val) {
  115 + Cache::delete($key.'_'.$val);
  116 + }
  117 + } else {
  118 + Cache::delete($key);
  119 + }
  120 + echo '清除成功';
  121 + }
  122 + }
  123 + }
  124 +
  125 + public function logAction()
  126 + {
  127 + print_r($_SERVER);
  128 + }
  129 +}
  130 +
80 ?> 131 ?>
@@ -9,10 +9,10 @@ use LibModels\Web\Home\IndexData; @@ -9,10 +9,10 @@ use LibModels\Web\Home\IndexData;
9 use LibModels\Web\Product\SearchData; 9 use LibModels\Web\Product\SearchData;
10 use WebPlugin\DataProcess\Channel as ChannelProcess; 10 use WebPlugin\DataProcess\Channel as ChannelProcess;
11 11
12 -define('CODE_BOYS_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? '79372627eee75d73afe7f9bac91e5ce6' : 'c15bf0cbfbd4893fd70c869c991f6d3d');  
13 -define('CODE_GIRLS_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? '75215008957605c05e8cd375eac4f817' : 'a519ba44ef3a85cf3c05e405c6ba8e53');  
14 -define('CODE_KIDS_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? 'd71f4b27f2a7229fbb31a4bc490a6f36' : 'a7741b94e8bb9d56d0d36e00c05956f7');  
15 -define('CODE_LIFESTYLE_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? '8a341ca7eacc069ba80f02dec80eaf34' : '1b053fd044834f5c86d5eb15fb237af9'); 12 +// define('CODE_BOYS_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? '79372627eee75d73afe7f9bac91e5ce6' : 'c15bf0cbfbd4893fd70c869c991f6d3d');
  13 +// define('CODE_GIRLS_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? '75215008957605c05e8cd375eac4f817' : 'a519ba44ef3a85cf3c05e405c6ba8e53');
  14 +// define('CODE_KIDS_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? 'd71f4b27f2a7229fbb31a4bc490a6f36' : 'a7741b94e8bb9d56d0d36e00c05956f7');
  15 +// define('CODE_LIFESTYLE_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? '8a341ca7eacc069ba80f02dec80eaf34' : '1b053fd044834f5c86d5eb15fb237af9');
16 16
17 17
18 /** 18 /**
@@ -46,15 +46,15 @@ class HomeModel @@ -46,15 +46,15 @@ class HomeModel
46 //lifestyle:8a341ca7eacc069ba80f02dec80eaf34,1b053fd044834f5c86d5eb15fb237af9 46 //lifestyle:8a341ca7eacc069ba80f02dec80eaf34,1b053fd044834f5c86d5eb15fb237af9
47 47
48 // 男首首页 48 // 男首首页
49 - const CODE_BOYS_CHANNEL = '79372627eee75d73afe7f9bac91e5ce6'; 49 + const CODE_BOYS_CHANNEL = 'c15bf0cbfbd4893fd70c869c991f6d3d';
50 // 女首首页 50 // 女首首页
51 - const CODE_GIRLS_CHANNEL = '75215008957605c05e8cd375eac4f817'; 51 + const CODE_GIRLS_CHANNEL = 'a519ba44ef3a85cf3c05e405c6ba8e53';
52 52
53 // 潮童首页 53 // 潮童首页
54 - const CODE_KIDS_CHANNEL = 'd71f4b27f2a7229fbb31a4bc490a6f36'; 54 + const CODE_KIDS_CHANNEL = 'a7741b94e8bb9d56d0d36e00c05956f7';
55 55
56 // 创意生活新 56 // 创意生活新
57 - const CODE_LIFESTYLE_CHANNEL = '8a341ca7eacc069ba80f02dec80eaf34'; 57 + const CODE_LIFESTYLE_CHANNEL = '1b053fd044834f5c86d5eb15fb237af9';
58 58
59 // 创意生活 59 // 创意生活
60 const CODE_LIFESTYLE_CHANNEL_1 = '380c38155fd8beee10913a3f5b462da6'; 60 const CODE_LIFESTYLE_CHANNEL_1 = '380c38155fd8beee10913a3f5b462da6';
@@ -137,20 +137,26 @@ class PassportModel @@ -137,20 +137,26 @@ class PassportModel
137 137
138 /* 138 /*
139 * 重写递增计数 cache方法 139 * 重写递增计数 cache方法
140 - * $key cache-key 140 + * $key cache-key,递增存放变量
141 * $offset 递增偏移量 141 * $offset 递增偏移量
142 * $initValue 初始化值 142 * $initValue 初始化值
143 * $expiry 缓存时间 143 * $expiry 缓存时间
144 */ 144 */
145 - public static function increment($key, $offset = 1, $initValue = 0, $expire = 1800) 145 +
  146 + public static function increment($key, $timeKey, $offset = 1, $initValue = 0, $expire = 1800)
146 { 147 {
147 - //初始化key  
148 - if (!Cache::get($key)) {  
149 - Cache::set($key, $initValue, $expire); 148 + //有效期之外清除key
  149 + if (!Cache::get($timeKey) && Cache::get($key)) {
  150 + Cache::delete($key);
  151 + }
  152 + //初始化计时
  153 + if (!Cache::get($timeKey) && !Cache::get($key)) {
  154 + Cache::set($timeKey, TRUE, $expire);
  155 + Cache::set($key, $initValue);
150 } 156 }
151 - //增加偏移量  
152 - $cacheValue = intval(Cache::get($key))+$offset;  
153 - Cache::set($key, $cacheValue, $expire); 157 + //未过期则递增
  158 + $cacheValue = intval(Cache::get($key)) + $offset;
  159 + Cache::set($key, $cacheValue);
154 } 160 }
155 161
156 } 162 }
@@ -113,7 +113,7 @@ class AutouserinfoController extends WebAction @@ -113,7 +113,7 @@ class AutouserinfoController extends WebAction
113 } 113 }
114 //未注册 未绑定 114 //未注册 未绑定
115 if ($res['code'] == 200) { 115 if ($res['code'] == 200) {
116 - $next = Helpers::url('/thirdlogin/index', array( 116 + $next = Helpers::url('/thirdlogin/noregist', array(
117 'openId' => $openId, 117 'openId' => $openId,
118 'sourceType' => $sourceType, 118 'sourceType' => $sourceType,
119 'area' => $area, 119 'area' => $area,
@@ -135,6 +135,9 @@ class AutouserinfoController extends WebAction @@ -135,6 +135,9 @@ class AutouserinfoController extends WebAction
135 $this->echoJson($data); 135 $this->echoJson($data);
136 } 136 }
137 137
  138 + /*
  139 + * 根据手机号获取用户相关信息
  140 + */
138 public static function getUserInfo($area, $mobile) 141 public static function getUserInfo($area, $mobile)
139 { 142 {
140 $userInfo = UserData::getUserInfoByMobile($area, $mobile); 143 $userInfo = UserData::getUserInfoByMobile($area, $mobile);
@@ -162,16 +165,16 @@ class AutouserinfoController extends WebAction @@ -162,16 +165,16 @@ class AutouserinfoController extends WebAction
162 break; 165 break;
163 } 166 }
164 167
165 - $phoneNum = trim($this->post('mobile'));  
166 - $areaCode = trim($this->post('area')); 168 + $mobile = trim($this->post('mobile'));
  169 + $area = trim($this->post('area'));
167 //校验手机号格式 170 //校验手机号格式
168 - if (!is_numeric($phoneNum) || !is_numeric($areaCode)) { 171 + if (!is_numeric($mobile) || !is_numeric($area)) {
169 $data['code'] = 400; 172 $data['code'] = 400;
170 $data['message'] = '手机号码格式不正确'; 173 $data['message'] = '手机号码格式不正确';
171 break; 174 break;
172 } 175 }
173 176
174 - $data = BindData::sendBindMsg($areaCode, $phoneNum); 177 + $data = BindData::sendBindMsg($area, $mobile);
175 if (!isset($data['code'])) { 178 if (!isset($data['code'])) {
176 break; 179 break;
177 } 180 }
@@ -194,17 +197,17 @@ class AutouserinfoController extends WebAction @@ -194,17 +197,17 @@ class AutouserinfoController extends WebAction
194 break; 197 break;
195 } 198 }
196 199
197 - $phoneNum = trim($this->post('mobile'));  
198 - $areaCode = trim($this->post('area')); 200 + $mobile = trim($this->post('mobile'));
  201 + $area= trim($this->post('area'));
199 $code = trim($this->post('code')); //短信验证码 202 $code = trim($this->post('code')); //短信验证码
200 //校验手机号格式 203 //校验手机号格式
201 - if (!is_numeric($phoneNum) || !is_numeric($areaCode)) { 204 + if (!is_numeric($mobile) || !is_numeric($area)) {
202 $data['code'] = 400; 205 $data['code'] = 400;
203 $data['message'] = '手机号码格式不正确'; 206 $data['message'] = '手机号码格式不正确';
204 break; 207 break;
205 } 208 }
206 209
207 - $data = BindData::checkBindCode($areaCode, $phoneNum, $code); 210 + $data = BindData::checkBindCode($area, $mobile, $code);
208 if (!isset($data['code'])) { 211 if (!isset($data['code'])) {
209 break; 212 break;
210 } 213 }
@@ -227,8 +230,8 @@ class AutouserinfoController extends WebAction @@ -227,8 +230,8 @@ class AutouserinfoController extends WebAction
227 break; 230 break;
228 } 231 }
229 232
230 - $phoneNum = trim($this->post('mobile'));  
231 - $areaCode = trim($this->post('area', '86')); 233 + $mobile = trim($this->post('mobile'));
  234 + $area = trim($this->post('area', '86'));
232 $openId = trim($this->post('openId')); 235 $openId = trim($this->post('openId'));
233 $sourceType = trim($this->post('sourceType')); 236 $sourceType = trim($this->post('sourceType'));
234 $code = trim($this->post('code')); //短信验证码 237 $code = trim($this->post('code')); //短信验证码
@@ -236,20 +239,20 @@ class AutouserinfoController extends WebAction @@ -236,20 +239,20 @@ class AutouserinfoController extends WebAction
236 $password = empty($password) ? '' : $password; 239 $password = empty($password) ? '' : $password;
237 240
238 //校验手机号格式 241 //校验手机号格式
239 - if (!is_numeric($phoneNum) || !is_numeric($areaCode)) { 242 + if (!is_numeric($mobile) || !is_numeric($area)) {
240 $data['code'] = 400; 243 $data['code'] = 400;
241 $data['message'] = '手机号码格式不正确'; 244 $data['message'] = '手机号码格式不正确';
242 break; 245 break;
243 } 246 }
244 //校验手机验证码 247 //校验手机验证码
245 - $bindMsgFlag = BindData::checkBindCode($areaCode, $phoneNum, $code); 248 + $bindMsgFlag = BindData::checkBindCode($area, $mobile, $code);
246 if (isset($bindMsgFlag['code']) && $bindMsgFlag['code'] != 200) { 249 if (isset($bindMsgFlag['code']) && $bindMsgFlag['code'] != 200) {
247 $data['code'] = 400; 250 $data['code'] = 400;
248 $data['message'] = '短信验证码不正确'; 251 $data['message'] = '短信验证码不正确';
249 break; 252 break;
250 } 253 }
251 //绑定手机号 254 //绑定手机号
252 - $res = BindData::bindMobile($openId, $sourceType, $phoneNum, $areaCode, $password); 255 + $res = BindData::bindMobile($openId, $sourceType, $mobile, $area, $password);
253 if (!isset($res['code'])) { 256 if (!isset($res['code'])) {
254 break; 257 break;
255 } 258 }
@@ -28,7 +28,7 @@ class LoginController extends WebAction @@ -28,7 +28,7 @@ class LoginController extends WebAction
28 if (!strstr($refer, 'http')) { 28 if (!strstr($refer, 'http')) {
29 $refer = SITE_MAIN . $refer; 29 $refer = SITE_MAIN . $refer;
30 } 30 }
31 - 31 +
32 if (!empty($refer)) { 32 if (!empty($refer)) {
33 $this->setCookie('refer', $refer); 33 $this->setCookie('refer', $refer);
34 } 34 }
@@ -70,7 +70,7 @@ class LoginController extends WebAction @@ -70,7 +70,7 @@ class LoginController extends WebAction
70 */ 70 */
71 public function authAction() 71 public function authAction()
72 { 72 {
73 - $data = array('code' => 400, 'message' => '您输入的密码及账户名不匹配,是否<a href="'.Helpers::url('/passport/back/index').'" target="_blank">忘记密码?</a>', 'data' => ''); 73 + $data = array('code' => 400, 'message' => '您输入的密码及账户名不匹配,是否<a href="' . Helpers::url('/passport/back/index') . '" target="_blank">忘记密码?</a>', 'data' => '');
74 do { 74 do {
75 /* 判断是不是AJAX请求 */ 75 /* 判断是不是AJAX请求 */
76 if (!$this->isAjax()) { 76 if (!$this->isAjax()) {
@@ -108,26 +108,43 @@ class LoginController extends WebAction @@ -108,26 +108,43 @@ class LoginController extends WebAction
108 */ 108 */
109 $ip = Helpers::getClientIp(); 109 $ip = Helpers::getClientIp();
110 $ipKey = md5('ip_signin_' . $ip); 110 $ipKey = md5('ip_signin_' . $ip);
  111 + $ipTimeKey = md5('ip_signin_time' . $ip);
111 $accountKey = md5('account_signin_' . $account); 112 $accountKey = md5('account_signin_' . $account);
112 - PassportModel::increment($ipKey, 1, 0, 3600); 113 + $accountTimeKey = md5('account_signin_time' . $account);
  114 + //cache初始化,非有效时间内清除次数,有效时间内叠加cache计数
  115 + if (!Cache::get($accountTimeKey) && Cache::get($accountKey)) {
  116 + Cache::delete($accountKey);
  117 + }
  118 + if (!Cache::get($accountTimeKey) && !Cache::get($accountKey)) {
  119 + Cache::set($accountTimeKey, true, 1800);
  120 + Cache::set($accountKey, 0);
  121 + }
  122 + if (!Cache::get($ipTimeKey) && Cache::get($ipKey)) {
  123 + Cache::delete($ipKey);
  124 + }
  125 + if (!Cache::get($ipTimeKey) && !Cache::get($ipKey)) {
  126 + Cache::set($ipTimeKey, true, 3600);
  127 + Cache::set($ipKey, 0);
  128 + }
113 $accountTimes = Cache::get($accountKey); 129 $accountTimes = Cache::get($accountKey);
114 - if ($accountTimes > 10) { 130 + $ipTimes = Cache::get($ipKey);
  131 + if ($accountTimes >= 10) {
115 $data = array('code' => 400, 'message' => '您的账号已被暂时锁定,请稍后再试', 'data' => ''); 132 $data = array('code' => 400, 'message' => '您的账号已被暂时锁定,请稍后再试', 'data' => '');
116 break; 133 break;
117 } 134 }
118 -  
119 - $ipTimes = Cache::get($ipKey);  
120 - if ($ipTimes > 100) { 135 + if ($ipTimes >= 100) {
121 $data = array('code' => 400, 'message' => '您尝试的次数过多,账号已被暂时锁定,请稍后再试', 'data' => ''); 136 $data = array('code' => 400, 'message' => '您尝试的次数过多,账号已被暂时锁定,请稍后再试', 'data' => '');
122 break; 137 break;
123 } 138 }
124 $data = LoginData::signin($area, $account, $password, $shoppingKey); 139 $data = LoginData::signin($area, $account, $password, $shoppingKey);
125 if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) { 140 if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) {
126 - PassportModel::increment($accountKey, 1, 0, 1800);  
127 - $data = array('code' => 400, 'message' => '您输入的密码及账户名不匹配,是否<a href="'.Helpers::url('/passport/back/index').'" target="_blank">忘记密码?</a>', 'data' => ''); 141 + Cache::set($accountKey, intval(Cache::get($accountKey)) + 1);
  142 + Cache::set($ipKey, intval(Cache::get($ipKey)) + 1);
  143 + $data = array('code' => 400, 'message' => '您输入的密码及账户名不匹配,是否<a href="' . Helpers::url('/passport/back/index') . '" target="_blank">忘记密码?</a>', 'data' => '');
128 break; 144 break;
129 } 145 }
130 146
  147 + //登录成功
131 $refer = $this->getCookie('refer'); 148 $refer = $this->getCookie('refer');
132 if (empty($refer) || strstr($refer, 'signin.html') || strstr($refer, 'passport/login/index')) { 149 if (empty($refer) || strstr($refer, 'signin.html') || strstr($refer, 'passport/login/index')) {
133 $refer = SITE_MAIN; 150 $refer = SITE_MAIN;
@@ -48,7 +48,8 @@ class RegisterController extends WebAction @@ -48,7 +48,8 @@ class RegisterController extends WebAction
48 $ip = Helpers::getClientIp(); 48 $ip = Helpers::getClientIp();
49 $data = array('code' => 400, 'message' => '', 'data' => ''); 49 $data = array('code' => 400, 'message' => '', 'data' => '');
50 $ipKey = md5('ip_checkmobile_' . $ip); 50 $ipKey = md5('ip_checkmobile_' . $ip);
51 - PassportModel::increment($ipKey, 1, 0, 3600); 51 + $ipTimeKey = md5('ip_checkmobile_time_' . $ip);
  52 + PassportModel::increment($ipKey,$ipTimeKey,1, 0, 3600);
52 $ipTimes = Cache::get($ipKey); 53 $ipTimes = Cache::get($ipKey);
53 do{ 54 do{
54 /* 判断是不是AJAX请求 */ 55 /* 判断是不是AJAX请求 */
@@ -60,7 +61,7 @@ class RegisterController extends WebAction @@ -60,7 +61,7 @@ class RegisterController extends WebAction
60 $data['message'] = '手机号码格式不正确'; 61 $data['message'] = '手机号码格式不正确';
61 break; 62 break;
62 } 63 }
63 - if ($ipTimes >= 500) { 64 + if ($ipTimes > 500) {
64 $data['message'] = '由于你IP受限无法注册'; 65 $data['message'] = '由于你IP受限无法注册';
65 break; 66 break;
66 } 67 }
@@ -130,7 +131,8 @@ class RegisterController extends WebAction @@ -130,7 +131,8 @@ class RegisterController extends WebAction
130 } 131 }
131 //发送代码 132 //发送代码
132 $sendCodeKey = md5('send_code_' . $area . '_' . $mobile); 133 $sendCodeKey = md5('send_code_' . $area . '_' . $mobile);
133 - PassportModel::increment($sendCodeKey, 1, 0, 3600); 134 + $sendCodeTimeKey = md5('send_code_time_' . $area . '_' . $mobile);
  135 + PassportModel::increment($sendCodeKey,$sendCodeTimeKey, 1, 0, 3600);
134 $sendCodeTimes = Cache::get($sendCodeKey); 136 $sendCodeTimes = Cache::get($sendCodeKey);
135 if ($sendCodeTimes > 50) { 137 if ($sendCodeTimes > 50) {
136 $data['message'] = '发送验证码太多'; 138 $data['message'] = '发送验证码太多';
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 use Action\WebAction; 3 use Action\WebAction;
4 use Passport\PassportModel; 4 use Passport\PassportModel;
5 use LibModels\Wap\Passport\RegData; 5 use LibModels\Wap\Passport\RegData;
  6 +use WebPlugin\Helpers;
6 7
7 class ThirdloginController extends WebAction 8 class ThirdloginController extends WebAction
8 { 9 {
@@ -24,8 +25,8 @@ class ThirdloginController extends WebAction @@ -24,8 +25,8 @@ class ThirdloginController extends WebAction
24 'simpleHeader' => $simpleHeader, 25 'simpleHeader' => $simpleHeader,
25 'openId' => $openId, 26 'openId' => $openId,
26 'sourceType' => $sourceType, 27 'sourceType' => $sourceType,
27 - 'region' => RegData::getAreasData(),  
28 - 'serviceUrl' => Helpers::url('/help', array('category_id' => 9)) 28 + 'region' => RegData::getAreasData(),//区域
  29 + 'serviceUrl' => Helpers::url('/help', array('category_id' => 9))//服务条款
29 ); 30 );
30 31
31 $this->_view->display('index', $data); 32 $this->_view->display('index', $data);
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 use Action\WebAction; 3 use Action\WebAction;
4 use LibModels\Web\Product\FavoriteData; 4 use LibModels\Web\Product\FavoriteData;
5 use Product\BrandsModel; 5 use Product\BrandsModel;
6 -use product\HotrankModel; 6 +use Product\HotrankModel;
7 7
8 class IndexController extends WebAction 8 class IndexController extends WebAction
9 { 9 {