Decoded Output
Download<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshopppppadmin\modules\Fecadminlock\cache;
use fec\helpers\CUrl;
use fec\helpers\CRequest;
use fecshopppppadmin\interfacesase\AppadminbaseBlockInterface;
use fecshopppppadmin\modules\AppadminbaseBlock;
use Yii;
/**
* block cmsrticle.
* @author Terry Zhao <[email protected]>
* @since 1.0
*/
class Index extends AppadminbaseBlock implements AppadminbaseBlockInterface
{
// rediscommonredis
public $appRedisCache;
//
public $errors;
// commonrediskey
public $commonConfigKey = 'commonConfig';
public function init()
{
$this->_currentUrl = CUrl::getUrl("fecadmin/cache/index");
$this->_currentParamUrl = CUrl::getCurrentUrl();
}
public function getLastData(){
#
#
$pagerForm = $this->getPagerForm();
#
$searchBar = $this->getSearchBar();
#
$editBar = $this->getEditBar();
#
$thead = $this->getTableThead();
#
$tbody = $this->getTableTbody();
#
$toolBar = $this->getToolBar($this->_param['numCount'],$this->_param['pageNum'],$this->_param['numPerPage']);
return [
'pagerForm' => $pagerForm,
'searchBar' => $searchBar,
'editBar' => $editBar,
'thead' => $thead,
'tbody' => $tbody,
'toolBar' => $toolBar,
];
}
public function getTableFieldArr(){
return [];
}
#
public function getSearchArr(){
return [];
}
public function getEditBar(){
if(!strstr($this->_currentParamUrl,"?")){
$csvUrl = $this->_currentParamUrl."?type=export";
}else{
$csvUrl = $this->_currentParamUrl."&type=export";
}
return '<ul class="toolBar">
<li><a csrfName="' .CRequest::getCsrfName(). '" csrfVal="' .CRequest::getCsrfValue(). '" title="'.Yii::$service->page->translate->__('Are you sure you want to refresh the cache?').'" target="selectedTodo" rel="ids" postType="string" href="'.$this->_currentUrl.'?method=reflush" class="edit"><span>' . Yii::$service->page->translate->__('Refresh Cache') . '</span></a></li>
<li class="line">line</li>
</ul>';
}
public function getTableThead(){
return '
<thead>
<tr>
<th width="22"><input type="checkbox" group="ids" class="checkboxCtrl"></th>
<th width="40">' . Yii::$service->page->translate->__('Cache Name') . '</th>
<th width="110">' . Yii::$service->page->translate->__('Cache Description') . '</th>
</tr>
</thead>';
}
public function getTableTbody(){
$str = '';
$reflushRedisCache = \Yii::$app->controller->module->params['cacheConfigFile'];
if (is_array($reflushRedisCache)) {
foreach ($reflushRedisCache as $appName => $c) {
if ($appName != $this->commonConfigKey) {
$str .= '<tr target="sid_user" rel="'.$appName.'">
<td><input name="ids" value="'.$appName.'" type="checkbox"></td>
<td>'.$appName.'</td>
<td> '. Yii::$service->page->translate->__('Refresh all caches') .''.$appName.'</td>
</tr>
';
}
}
}
return $str;
}
/**
* redis
* redisredis
* commonredisredisredis componentredis
*/
public function getRedisCacheConfig(){
$arr = \Yii::$app->controller->module->params['cacheConfigFile'];
if (is_array($arr)) {
// commonredis
if (!isset($arr[$this->commonConfigKey]) || !$arr[$this->commonConfigKey]) {
$this->errors = 'module config: cacheConfigFile[commonConfig] can not empty';
return false;
}
$file = Yii::getAlias($arr[$this->commonConfigKey]);
$config = require($file);
if (!isset($config['components']['cache']['class']) || !$config['components']['cache']['class'] || $config['components']['cache']['class'] != 'yii
edis\Cache') {
$this->errors = 'can not find $config[\'components\'][\'cache\'][\'redis\'] in '.$file;
return false;
}
$baseConfig = isset($config['components']['redis']) ? $config['components']['redis'] : [];
// redis
foreach ($arr as $app => $appFile) {
if ($app != $this->commonConfigKey) {
$file = Yii::getAlias($appFile);
$config = require($file);
$appRedisConfig = isset($config['components']['redis']) ? $config['components']['redis'] : [];
if (!empty($appRedisConfig)) {
$this->appRedisCache[$app] = \yii\helpers\ArrayHelper::merge($baseConfig, $appRedisConfig);
} else {
$this->appRedisCache[$app] = $baseConfig;
}
}
}
$baseCacheConfig = isset($config['components']['cache']['redis']) ? $config['components']['cache']['redis'] : [];
foreach ($this->appRedisCache as $app => $config) {
$this->appRedisCache[$app] = \yii\helpers\ArrayHelper::merge($config, $baseCacheConfig);
}
// redis
foreach ($arr as $app => $appFile) {
if ($app != $this->commonConfigKey) {
$file = Yii::getAlias($appFile);
$config = require($file);
$appRedisConfig = isset($config['components']['cache']['redis']) ? $config['components']['cache']['redis'] : [];
if (!empty($appRedisConfig)) {
$this->appRedisCache[$app] = \yii\helpers\ArrayHelper::merge($this->appRedisCache[$app], $appRedisConfig);
}
}
}
}
return true;
}
// cache
public function isFileCache()
{
$arr = \Yii::$app->controller->module->params['cacheConfigFile'];
if (is_array($arr)) {
// commonredis
if (!isset($arr[$this->commonConfigKey]) || !$arr[$this->commonConfigKey]) {
$this->errors = 'module config: cacheFileConfigFile[commonConfig] can not empty';
return false;
}
$file = Yii::getAlias($arr[$this->commonConfigKey]);
$config = require($file);
if (!isset($config['components']['cache']['class']) || !$config['components']['cache']['class'] || $config['components']['cache']['class'] != 'yii\caching\FileCache') {
$this->errors = 'can not find $config[\'components\'][\'cache\'][\'fileCache\'] in '.$file;
return false;
}
return true;
}
return false;
}
//
public function flushFileCache()
{
$cachePath = Yii::$app->cache->cachePath;
$cacheAppNameStr = Yii::$app->request->post('ids');
$cacheAppNameArr = explode(",",$cacheAppNameStr);
$successReflushAppNameArr = [];
if (is_array($cacheAppNameArr)) {
foreach ($cacheAppNameArr as $cacheAppName) {
$cacheAppName = strtolower($cacheAppName);
$appCachePath = str_replace('appadmin', $cacheAppName, $cachePath);
//echo $cachePath;
Yii::$app->cache->cachePath = $appCachePath;
Yii::$app->cache->flush();
$successReflushAppNameArr[] = $cacheAppName;
}
}
echo json_encode([
"statusCode" => "200",
"message" => Yii::$service->page->translate->__('Reflush cache success, AppName') . ":" . implode(',', $successReflushAppNameArr),
]);
}
/**
*
*/
public function reflush(){
//
if ($this->isFileCache()) {
$this->flushFileCache();
exit;
}
// flush redis cache
$this->flushRedisCache();
exit;
}
// redis
public function flushRedisCache()
{
// redis cache
if (!$this->getRedisCacheConfig()) {
echo json_encode([
"statusCode" => "300",
"message" => $this->errors,
]);
return ;
}
$successReflushAppNameArr = [];
$cacheAppNameStr = Yii::$app->request->post('ids');
$cacheAppNameArr = explode(",",$cacheAppNameStr);
if (is_array($cacheAppNameArr)) {
foreach ($cacheAppNameArr as $cacheAppName) {
$cacheAppName = trim($cacheAppName);
if (isset($this->appRedisCache[$cacheAppName]) && $this->appRedisCache[$cacheAppName]) {
$redisComponent = Yii::createObject($this->appRedisCache[$cacheAppName]);
$redisComponent->executeCommand('FLUSHDB');
$successReflushAppNameArr[] = $cacheAppName;
}
}
}
#
// ecadmin\helpers\CConfig::flushCacheConfig();
echo json_encode([
"statusCode" => "200",
"message" => Yii::$service->page->translate->__('Reflush cache success, AppName') . ":" . implode(',', $successReflushAppNameArr),
]);
}
}
?>
Did this file decode correctly?
How would you describe this file?
Thank you for your feedback! This will help us detect malicious PHP files more accurately in the future.
Function Calls
None
Variables
None
Stats
| MD5 | 45d7e4861d1cec5c |
|---|---|
| Eval Count | 0 |
| Decode Time | 123 ms |
Original Code
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\app\appadmin\modules\Fecadmin\block\cache;
use fec\helpers\CUrl;
use fec\helpers\CRequest;
use fecshop\app\appadmin\interfaces\base\AppadminbaseBlockInterface;
use fecshop\app\appadmin\modules\AppadminbaseBlock;
use Yii;
/**
* block cms\article.
* @author Terry Zhao <[email protected]>
* @since 1.0
*/
class Index extends AppadminbaseBlock implements AppadminbaseBlockInterface
{
// rediscommonredis
public $appRedisCache;
//
public $errors;
// commonrediskey
public $commonConfigKey = 'commonConfig';
public function init()
{
$this->_currentUrl = CUrl::getUrl("fecadmin/cache/index");
$this->_currentParamUrl = CUrl::getCurrentUrl();
}
public function getLastData(){
#
#
$pagerForm = $this->getPagerForm();
#
$searchBar = $this->getSearchBar();
#
$editBar = $this->getEditBar();
#
$thead = $this->getTableThead();
#
$tbody = $this->getTableTbody();
#
$toolBar = $this->getToolBar($this->_param['numCount'],$this->_param['pageNum'],$this->_param['numPerPage']);
return [
'pagerForm' => $pagerForm,
'searchBar' => $searchBar,
'editBar' => $editBar,
'thead' => $thead,
'tbody' => $tbody,
'toolBar' => $toolBar,
];
}
public function getTableFieldArr(){
return [];
}
#
public function getSearchArr(){
return [];
}
public function getEditBar(){
if(!strstr($this->_currentParamUrl,"?")){
$csvUrl = $this->_currentParamUrl."?type=export";
}else{
$csvUrl = $this->_currentParamUrl."&type=export";
}
return '<ul class="toolBar">
<li><a csrfName="' .CRequest::getCsrfName(). '" csrfVal="' .CRequest::getCsrfValue(). '" title="'.Yii::$service->page->translate->__('Are you sure you want to refresh the cache?').'" target="selectedTodo" rel="ids" postType="string" href="'.$this->_currentUrl.'?method=reflush" class="edit"><span>' . Yii::$service->page->translate->__('Refresh Cache') . '</span></a></li>
<li class="line">line</li>
</ul>';
}
public function getTableThead(){
return '
<thead>
<tr>
<th width="22"><input type="checkbox" group="ids" class="checkboxCtrl"></th>
<th width="40">' . Yii::$service->page->translate->__('Cache Name') . '</th>
<th width="110">' . Yii::$service->page->translate->__('Cache Description') . '</th>
</tr>
</thead>';
}
public function getTableTbody(){
$str = '';
$reflushRedisCache = \Yii::$app->controller->module->params['cacheConfigFile'];
if (is_array($reflushRedisCache)) {
foreach ($reflushRedisCache as $appName => $c) {
if ($appName != $this->commonConfigKey) {
$str .= '<tr target="sid_user" rel="'.$appName.'">
<td><input name="ids" value="'.$appName.'" type="checkbox"></td>
<td>'.$appName.'</td>
<td> '. Yii::$service->page->translate->__('Refresh all caches') .''.$appName.'</td>
</tr>
';
}
}
}
return $str;
}
/**
* redis
* redisredis
* commonredisredisredis componentredis
*/
public function getRedisCacheConfig(){
$arr = \Yii::$app->controller->module->params['cacheConfigFile'];
if (is_array($arr)) {
// commonredis
if (!isset($arr[$this->commonConfigKey]) || !$arr[$this->commonConfigKey]) {
$this->errors = 'module config: cacheConfigFile[commonConfig] can not empty';
return false;
}
$file = Yii::getAlias($arr[$this->commonConfigKey]);
$config = require($file);
if (!isset($config['components']['cache']['class']) || !$config['components']['cache']['class'] || $config['components']['cache']['class'] != 'yii\redis\Cache') {
$this->errors = 'can not find $config[\'components\'][\'cache\'][\'redis\'] in '.$file;
return false;
}
$baseConfig = isset($config['components']['redis']) ? $config['components']['redis'] : [];
// redis
foreach ($arr as $app => $appFile) {
if ($app != $this->commonConfigKey) {
$file = Yii::getAlias($appFile);
$config = require($file);
$appRedisConfig = isset($config['components']['redis']) ? $config['components']['redis'] : [];
if (!empty($appRedisConfig)) {
$this->appRedisCache[$app] = \yii\helpers\ArrayHelper::merge($baseConfig, $appRedisConfig);
} else {
$this->appRedisCache[$app] = $baseConfig;
}
}
}
$baseCacheConfig = isset($config['components']['cache']['redis']) ? $config['components']['cache']['redis'] : [];
foreach ($this->appRedisCache as $app => $config) {
$this->appRedisCache[$app] = \yii\helpers\ArrayHelper::merge($config, $baseCacheConfig);
}
// redis
foreach ($arr as $app => $appFile) {
if ($app != $this->commonConfigKey) {
$file = Yii::getAlias($appFile);
$config = require($file);
$appRedisConfig = isset($config['components']['cache']['redis']) ? $config['components']['cache']['redis'] : [];
if (!empty($appRedisConfig)) {
$this->appRedisCache[$app] = \yii\helpers\ArrayHelper::merge($this->appRedisCache[$app], $appRedisConfig);
}
}
}
}
return true;
}
// cache
public function isFileCache()
{
$arr = \Yii::$app->controller->module->params['cacheConfigFile'];
if (is_array($arr)) {
// commonredis
if (!isset($arr[$this->commonConfigKey]) || !$arr[$this->commonConfigKey]) {
$this->errors = 'module config: cacheFileConfigFile[commonConfig] can not empty';
return false;
}
$file = Yii::getAlias($arr[$this->commonConfigKey]);
$config = require($file);
if (!isset($config['components']['cache']['class']) || !$config['components']['cache']['class'] || $config['components']['cache']['class'] != 'yii\caching\FileCache') {
$this->errors = 'can not find $config[\'components\'][\'cache\'][\'fileCache\'] in '.$file;
return false;
}
return true;
}
return false;
}
//
public function flushFileCache()
{
$cachePath = Yii::$app->cache->cachePath;
$cacheAppNameStr = Yii::$app->request->post('ids');
$cacheAppNameArr = explode(",",$cacheAppNameStr);
$successReflushAppNameArr = [];
if (is_array($cacheAppNameArr)) {
foreach ($cacheAppNameArr as $cacheAppName) {
$cacheAppName = strtolower($cacheAppName);
$appCachePath = str_replace('appadmin', $cacheAppName, $cachePath);
//echo $cachePath;
Yii::$app->cache->cachePath = $appCachePath;
Yii::$app->cache->flush();
$successReflushAppNameArr[] = $cacheAppName;
}
}
echo json_encode([
"statusCode" => "200",
"message" => Yii::$service->page->translate->__('Reflush cache success, AppName') . ":" . implode(',', $successReflushAppNameArr),
]);
}
/**
*
*/
public function reflush(){
//
if ($this->isFileCache()) {
$this->flushFileCache();
exit;
}
// flush redis cache
$this->flushRedisCache();
exit;
}
// redis
public function flushRedisCache()
{
// redis cache
if (!$this->getRedisCacheConfig()) {
echo json_encode([
"statusCode" => "300",
"message" => $this->errors,
]);
return ;
}
$successReflushAppNameArr = [];
$cacheAppNameStr = Yii::$app->request->post('ids');
$cacheAppNameArr = explode(",",$cacheAppNameStr);
if (is_array($cacheAppNameArr)) {
foreach ($cacheAppNameArr as $cacheAppName) {
$cacheAppName = trim($cacheAppName);
if (isset($this->appRedisCache[$cacheAppName]) && $this->appRedisCache[$cacheAppName]) {
$redisComponent = Yii::createObject($this->appRedisCache[$cacheAppName]);
$redisComponent->executeCommand('FLUSHDB');
$successReflushAppNameArr[] = $cacheAppName;
}
}
}
#
// \fecadmin\helpers\CConfig::flushCacheConfig();
echo json_encode([
"statusCode" => "200",
"message" => Yii::$service->page->translate->__('Reflush cache success, AppName') . ":" . implode(',', $successReflushAppNameArr),
]);
}
}