Authored by whb

web测试

@@ -480,7 +480,7 @@ class WebAction extends Controller_Abstract @@ -480,7 +480,7 @@ class WebAction extends Controller_Abstract
480 $header = array( 480 $header = array(
481 'navbars'=> \Index\HomeModel::getNavBars($channel), 481 'navbars'=> \Index\HomeModel::getNavBars($channel),
482 'gobytype'=> 'gobuy'.$channel, 482 'gobytype'=> 'gobuy'.$channel,
483 - 'searchcate'=>'searchcate'.$channel, 483 + // 'searchcate'=>'searchcate'.$channel,
484 'header'=> true, 484 'header'=> true,
485 'apiDomain'=> $apiDomain 485 'apiDomain'=> $apiDomain
486 ); 486 );
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';