...
|
...
|
@@ -4,11 +4,19 @@ 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']))
|
...
|
...
|
@@ -25,9 +33,52 @@ class ToolsController extends WebAction |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 缓存html
|
|
|
* 工具首页
|
|
|
*/
|
|
|
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
|
...
|
...
|
@@ -38,7 +89,7 @@ class ToolsController extends WebAction |
|
|
'kids首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_KIDS_CHANNEL,
|
|
|
'lifestyle首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_LIFESTYLE_CHANNEL,
|
|
|
);
|
|
|
$html = '';
|
|
|
$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);
|
...
|
...
|
|