diff --git a/app/Console/Tasks/RenewDemoLiveCourseTask.php b/app/Console/Tasks/RenewDemoLiveCourseTask.php new file mode 100644 index 0000000000000000000000000000000000000000..e5bb204e2770cac09706f1e97c9faee976d80da6 --- /dev/null +++ b/app/Console/Tasks/RenewDemoLiveCourseTask.php @@ -0,0 +1,81 @@ +findLiveCourses(); + + if ($courses->count() == 0) return; + + foreach ($courses as $course) { + + $lessons = $courseRepo->findLessons($course->id); + + foreach ($lessons as $lesson) { + $this->handleLesson($lesson); + } + + $statService = new CourseStatService(); + + $statService->updateLiveAttrs($course->id); + + $cache = new CourseChapterListCache(); + + $cache->rebuild($course->id); + } + } + + protected function handleLesson(ChapterModel $chapter) + { + $chapterRepo = new ChapterRepo(); + + $live = $chapterRepo->findChapterLive($chapter->id); + + if ($live->start_time > time()) return; + + $startTime = strtotime('+1 month', $live->start_time); + $endTime = strtotime('+1 month', $live->end_time); + + $live->start_time = $startTime; + $live->end_time = $endTime; + + $live->update(); + + $attrs = $chapter->attrs; + + $attrs['start_time'] = $startTime; + $attrs['end_time'] = $endTime; + + $chapter->attrs = $attrs; + + $chapter->update(); + } + + protected function findLiveCourses($limit = 8) + { + return CourseModel::query() + ->where('model = :model:', ['model' => CourseModel::MODEL_LIVE]) + ->orderBy('id DESC') + ->limit($limit) + ->execute(); + } + +} diff --git a/app/Console/Tasks/ResetDemoAccountTask.php b/app/Console/Tasks/ResetDemoAccountTask.php new file mode 100644 index 0000000000000000000000000000000000000000..c62615c601eeb6bc7c8a00ae063865a08313a7bc --- /dev/null +++ b/app/Console/Tasks/ResetDemoAccountTask.php @@ -0,0 +1,74 @@ +reset_account_100015(); + $this->reset_account_100065(); + } + + protected function reset_account_100015() + { + $accountRepo = new AccountRepo(); + + $account = $accountRepo->findById(100015); + + $salt = PasswordUtil::salt(); + $hash = PasswordUtil::hash('123456', $salt); + + $account->phone = '13507083515'; + $account->email = '100015@163.com'; + $account->salt = $salt; + $account->password = $hash; + + $account->update(); + + $userRepo = new UserRepo(); + + $user = $userRepo->findById(100015); + + $user->name = '酷瓜云课堂'; + $user->title = '首席音效师'; + $user->about = '酷瓜云课堂(腾讯云版),依托腾讯云基础服务架构,采用C扩展PHP框架Phalcon开发,致力开源网课系统,开源网校系统,开源在线教育系统。'; + $user->avatar = '/img/avatar/20210214084718217596.jpeg'; + + $user->update(); + } + + protected function reset_account_100065() + { + $accountRepo = new AccountRepo(); + + $account = $accountRepo->findById(100065); + + $salt = PasswordUtil::salt(); + $hash = PasswordUtil::hash('123456', $salt); + + $account->phone = '13607083515'; + $account->email = '100065@163.com'; + $account->salt = $salt; + $account->password = $hash; + + $account->update(); + + $userRepo = new UserRepo(); + + $user = $userRepo->findById(100065); + + $user->name = '酷瓜云小二'; + $user->title = '首席茶艺师'; + $user->about = '酷瓜云课堂,100%开源在线教育解决方案'; + $user->avatar = '/img/avatar/default.png'; + + $user->update(); + } + +} diff --git a/app/Http/Admin/Controllers/Controller.php b/app/Http/Admin/Controllers/Controller.php index dc93c72cf8ad57771125bc70fec614a26e2d7a0e..86247973302d31eeebae3fe86b6391caa1f0c106 100644 --- a/app/Http/Admin/Controllers/Controller.php +++ b/app/Http/Admin/Controllers/Controller.php @@ -50,6 +50,17 @@ class Controller extends \Phalcon\Mvc\Controller $this->authUser = $this->getAuthUser(); + /** + * demo分支拒绝数据提交,100001帐号除外 + */ + if ($this->isNotSafeRequest() && $this->authUser->id != 100001) { + $dispatcher->forward([ + 'controller' => 'public', + 'action' => 'forbidden', + ]); + return false; + } + /** * root用户忽略权限检查 */ diff --git a/app/Http/Admin/Services/Setting.php b/app/Http/Admin/Services/Setting.php index d15207dcae23044260e900337edb37e98e90af9a..607847a77341ad905683cb631252d5c98d0730a0 100644 --- a/app/Http/Admin/Services/Setting.php +++ b/app/Http/Admin/Services/Setting.php @@ -127,8 +127,19 @@ class Setting extends Service $result = []; + /** + * demo分支过滤敏感数据,100001帐号除外 + */ if ($items->count() > 0) { + $pattern = '/(id|auth|key|secret|token|password|pwd|mobile|phone|mail|email)$/'; + $controllerName = $this->dispatcher->getControllerName(); foreach ($items as $item) { + $case1 = preg_match($pattern, $item->item_key); + $case2 = $controllerName == 'setting'; + $case3 = $this->getLoginUser()->id != 100001; + if ($case1 && $case2 && $case3) { + $item->item_value = '******'; + } $result[$item->item_key] = $item->item_value; } } diff --git a/app/Http/Admin/Views/public/login.volt b/app/Http/Admin/Views/public/login.volt index b4c31fec21402c8eb3aa20a9cb0de2ecd612bcaa..72f0f2e3cf97fce33c51b8bdf9f897977d217d48 100644 --- a/app/Http/Admin/Views/public/login.volt +++ b/app/Http/Admin/Views/public/login.volt @@ -16,7 +16,7 @@