日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ken\trade

發布時間:2024/3/12 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ken\trade 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
<?phpnamespace ken\trade;use Yii; use yii\base\BootstrapInterface; use yii\web\ForbiddenHttpException;/*** 交易模塊 - Ken Trade** 使用配置** ~~~* return [* 'bootstrap' => ['ktrade'],* 'modules' => [* 'ktrade' => [* 'class' => 'ken\trade\Module',* 'allowedIPs' => ['127.0.0.1', '192.168.*.*'],* ],* ],* ]* ~~~** 默認時此模塊僅允許在 localhost 上進行訪問,也可以通過配置 * [[allowedIPs]] 屬性來讓其它機器訪問.* * 訪問地址: `http://localhost/path/to/index.php?r=gii`** 如果啟用url 美化功能 [[\yii\web\UrlManager::enablePrettyUrl|pretty URLs]],* 則訪問地址為: `http://localhost/path/to/index.php/gii`** @author Xiaohan Xu <vb2005xu@qq.com>* @since 2.0*/ class Module extends \yii\base\Module implements BootstrapInterface {/*** @inheritdoc*/public $controllerNamespace = 'ken\trade\controllers';/*** @var array * * 默認只允許 localhost 訪問.* 也可以設置 外網機器訪問,例如 ['127.0.0.1', '192.168.*.*']*/public $allowedIPs = ['127.0.0.1', '::1'];public $allowedHosts = [];/*** @var string 交易日志的目錄*/public $logPath = '@runtime/ktrade';/*** @var array 對外訪問的api列表*/public $apis = [];/*** @inheritdoc*/public function init(){parent::init();$this->logPath = Yii::getAlias($this->logPath);}/*** @inheritdoc*/public function bootstrap($app){$app->getUrlManager()->addRules([$this->id => $this->id,$this->id . '/<controller:[\w\-]+>/<action:[\w\-]+>' => $this->id . '/<controller>/<action>',], false);}/*** @inheritdoc*/public function beforeAction($action){if (!parent::beforeAction($action)) {return false;}if (Yii::$app instanceof \yii\web\Application && !$this->checkAccess()) {throw new ForbiddenHttpException('You are not allowed to access this page.');}foreach (array_merge($this->coreApis(), $this->apis) as $id => $config) {$this->apis[$id] = Yii::createObject($config);}$this->resetGlobalSettings();return true;}/*** Resets potentially incompatible global settings done in app config.*/protected function resetGlobalSettings(){if (Yii::$app instanceof \yii\web\Application) {Yii::$app->assetManager->bundles = [];}}/*** @return boolean whether the module can be accessed by the current user*/protected function checkAccess(){$ip = Yii::$app->getRequest()->getUserIP();foreach ($this->allowedIPs as $filter) {if ($filter === '*' || $filter === $ip || (($pos = strpos($filter, '*')) !== false && !strncmp($ip, $filter, $pos))) {return true;}}foreach ($this->allowedHosts as $hostname) {$filter = gethostbyname($hostname);if ($filter === $ip) {return true;}}Yii::warning('拒絕訪問 kentrade. 請求的 IP 是 ' . $ip, __METHOD__);return false;}/*** 返回 交易模塊提供的對外api接口* @return array*** */protected function coreApis(){return ['pay' => ['class' => 'ken\trade\apis'],'pay' => ['class' => 'ken\trade\apis'],];} }

總結

以上是生活随笔為你收集整理的ken\trade的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。