diff --git a/app/Http/Admin/Controllers/Controller.php b/app/Http/Admin/Controllers/Controller.php index 2704f7b3..2c3bb1f1 100644 --- a/app/Http/Admin/Controllers/Controller.php +++ b/app/Http/Admin/Controllers/Controller.php @@ -21,6 +21,17 @@ class Controller extends \Phalcon\Mvc\Controller public function beforeExecuteRoute(Dispatcher $dispatcher) { + /** + * demo分支拒绝数据提交 + */ + if ($this->isNotSafeRequest()) { + $dispatcher->forward([ + 'controller' => 'public', + 'action' => 'forbidden', + ]); + return false; + } + if ($this->isNotSafeRequest()) { $this->checkHttpReferer(); $this->checkCsrfToken(); diff --git a/app/Http/Admin/Controllers/PublicController.php b/app/Http/Admin/Controllers/PublicController.php index 04b8d8f1..5e0a1ab4 100644 --- a/app/Http/Admin/Controllers/PublicController.php +++ b/app/Http/Admin/Controllers/PublicController.php @@ -17,6 +17,8 @@ class PublicController extends \Phalcon\Mvc\Controller */ public function authAction() { + $this->response->setStatusCode(401); + if ($this->request->isAjax()) { return $this->jsonError(['msg' => '会话已过期,请重新登录']); } @@ -29,6 +31,8 @@ class PublicController extends \Phalcon\Mvc\Controller */ public function forbiddenAction() { + $this->response->setStatusCode(403); + if ($this->request->isAjax()) { return $this->jsonError(['msg' => '无相关操作权限']); } diff --git a/app/Http/Admin/Controllers/SettingController.php b/app/Http/Admin/Controllers/SettingController.php index 670c6700..c06cf6d6 100644 --- a/app/Http/Admin/Controllers/SettingController.php +++ b/app/Http/Admin/Controllers/SettingController.php @@ -31,7 +31,7 @@ class SettingController extends Controller $site = $settingService->getSectionSettings($section); - $site->base_url = $site->base_url ?: kg_site_base_url(); + $site['base_url'] = $site['base_url'] ?: kg_site_base_url(); $this->view->setVar('site', $site); } @@ -117,12 +117,12 @@ class SettingController extends Controller */ public function liveAction() { - $section = 'live'; - $settingService = new SettingService(); if ($this->request->isPost()) { + $section = $this->request->getPost('section'); + $data = $this->request->getPost(); $settingService->updateLiveSettings($section, $data); @@ -131,9 +131,13 @@ class SettingController extends Controller } else { - $live = $settingService->getLiveSettings(); + $push = $settingService->getLiveSettings('live.push'); + $pull = $settingService->getLiveSettings('live.pull'); + $notify = $settingService->getLiveSettings('live.notify'); - $this->view->setVar('live', $live); + $this->view->setVar('push', $push); + $this->view->setVar('pull', $pull); + $this->view->setVar('notify', $notify); } } @@ -156,13 +160,8 @@ class SettingController extends Controller } else { - $alipay = $settingService->getSectionSettings('pay.alipay'); - - $alipay->notify_url = $alipay->notify_url ?: kg_full_url(['for' => 'desktop.alipay_notify']); - - $wxpay = $settingService->getSectionSettings('pay.wxpay'); - - $wxpay->notify_url = $wxpay->notify_url ?: kg_full_url(['for' => 'desktop.wxpay_notify']); + $alipay = $settingService->getAlipaySettings(); + $wxpay = $settingService->getWxpaySettings(); $this->view->setVar('alipay', $alipay); $this->view->setVar('wxpay', $wxpay); @@ -190,10 +189,7 @@ class SettingController extends Controller $smser = $settingService->getSectionSettings($section); - $template = json_decode($smser->template); - $this->view->setVar('smser', $smser); - $this->view->setVar('template', $template); } } diff --git a/app/Http/Admin/Services/Chapter.php b/app/Http/Admin/Services/Chapter.php index 32cfcbad..6071a2f4 100644 --- a/app/Http/Admin/Services/Chapter.php +++ b/app/Http/Admin/Services/Chapter.php @@ -118,7 +118,6 @@ class Chapter extends Service $logger = $this->getLogger(); $logger->error('Create Chapter Error ' . kg_json_encode([ - 'line' => $e->getLine(), 'code' => $e->getCode(), 'message' => $e->getMessage(), ])); diff --git a/app/Http/Admin/Services/Course.php b/app/Http/Admin/Services/Course.php index 31a3fb3b..503e96b2 100644 --- a/app/Http/Admin/Services/Course.php +++ b/app/Http/Admin/Services/Course.php @@ -113,7 +113,6 @@ class Course extends Service $logger = $this->getLogger(); $logger->error('Create Course Error ' . kg_json_encode([ - 'line' => $e->getLine(), 'code' => $e->getCode(), 'message' => $e->getMessage(), ])); diff --git a/app/Http/Admin/Services/Setting.php b/app/Http/Admin/Services/Setting.php index a3502f58..68b7709c 100644 --- a/app/Http/Admin/Services/Setting.php +++ b/app/Http/Admin/Services/Setting.php @@ -9,17 +9,64 @@ use App\Repos\Vip as VipRepo; class Setting extends Service { + public function getAlipaySettings() + { + $alipay = $this->getSectionSettings('pay.alipay'); + + $alipay['notify_url'] = $alipay['notify_url'] ?: kg_full_url(['for' => 'desktop.alipay_notify']); + + return $alipay; + } + + public function getWxpaySettings() + { + $wxpay = $this->getSectionSettings('pay.wxpay'); + + $wxpay['notify_url'] = $wxpay['notify_url'] ?: kg_full_url(['for' => 'desktop.wxpay_notify']); + + return $wxpay; + } + + public function getVipSettings() + { + $vipRepo = new VipRepo(); + + return $vipRepo->findAll(['deleted' => 0]); + } + + public function getLiveSettings($section) + { + $result = $this->getSectionSettings($section); + + if ($section == 'live.notify') { + $result['stream_begin_url'] = $result['stream_begin_url'] ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'streamBegin']); + $result['stream_end_url'] = $result['stream_end_url'] ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'streamEnd']); + $result['record_url'] = $result['record_url'] ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'record']); + $result['snapshot_url'] = $result['snapshot_url'] ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'snapshot']); + $result['porn_url'] = $result['porn_url'] ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'porn']); + } + + return $result; + } + public function getSectionSettings($section) { $settingsRepo = new SettingRepo(); $items = $settingsRepo->findBySection($section); - $result = new \stdClass(); + $result = []; + /** + * demo分支过滤敏感数据 + */ if ($items->count() > 0) { foreach ($items as $item) { - $result->{$item->item_key} = $item->item_value; + $pattern = '/(auth|key|secret|pwd|password)/'; + if (preg_match($pattern, $item->item_key)) { + $item->item_value = '***'; + } + $result[$item->item_key] = $item->item_value; } } @@ -81,7 +128,9 @@ class Setting extends Service public function updateSmserSettings($section, $settings) { $template = $settings['template']; + $keys = array_keys($template['id']); + $myTemplate = []; foreach ($keys as $key) { @@ -96,13 +145,6 @@ class Setting extends Service $this->updateSectionSettings($section, $settings); } - public function getVipSettings() - { - $vipRepo = new VipRepo(); - - return $vipRepo->findAll(['deleted' => 0]); - } - public function updateVipSettings($items) { $vipRepo = new VipRepo(); @@ -114,17 +156,4 @@ class Setting extends Service } } - public function getLiveSettings() - { - $live = $this->getSectionSettings('live'); - - $live->notify_stream_begin_url = $live->notify_stream_begin_url ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'streamBegin']); - $live->notify_stream_end_url = $live->notify_stream_end_url ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'streamEnd']); - $live->notify_record_url = $live->notify_record_url ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'record']); - $live->notify_snapshot_url = $live->notify_snapshot_url ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'snapshot']); - $live->notify_porn_url = $live->notify_porn_url ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'porn']); - - return $live; - } - } diff --git a/app/Http/Admin/Views/chapter/lessons.volt b/app/Http/Admin/Views/chapter/lessons.volt index 26246c29..8ec5ab29 100644 --- a/app/Http/Admin/Views/chapter/lessons.volt +++ b/app/Http/Admin/Views/chapter/lessons.volt @@ -21,11 +21,11 @@ - {% if course.model == '1' %} + {% if course.model == 1 %} {{ partial('chapter/lessons_vod') }} - {% elseif course.model == '2' %} + {% elseif course.model == 2 %} {{ partial('chapter/lessons_live') }} - {% elseif course.model == '3' %} + {% elseif course.model == 3 %} {{ partial('chapter/lessons_read') }} {% endif %} diff --git a/app/Http/Admin/Views/chapter/lessons_live.volt b/app/Http/Admin/Views/chapter/lessons_live.volt index 3c280789..649374af 100644 --- a/app/Http/Admin/Views/chapter/lessons_live.volt +++ b/app/Http/Admin/Views/chapter/lessons_live.volt @@ -7,9 +7,13 @@ {% endif %} {%- endmacro %} -{%- macro live_status_info(attrs) %} - {% if attrs['stream']['status'] != 'active' %} - 直播中 +{%- macro live_status_info(status) %} + {% if status == 'active' %} + 活跃 + {% elseif status == 'inactive' %} + 沉默 + {% elseif status == 'forbid' %} + 禁播 {% endif %} {%- endmacro %} @@ -21,13 +25,15 @@