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 @@
- +
{% if captcha.enabled == 1 %}
diff --git a/app/Http/Admin/Views/templates/main.volt b/app/Http/Admin/Views/templates/main.volt index a4a8a8ea23d78943938e25e27a28cacf0d4579f1..70658df73f3408e886fef58b2dec672d48aae9cf 100644 --- a/app/Http/Admin/Views/templates/main.volt +++ b/app/Http/Admin/Views/templates/main.volt @@ -24,5 +24,13 @@ {% block include_js %}{% endblock %} {% block inline_js %}{% endblock %} +{% set site = setting('site') %} + +{% if site['analytics_enabled'] == 1 %} +
+ {{ site['analytics_script'] }} +
+{% endif %} + \ No newline at end of file diff --git a/app/Http/Home/Views/account/login_by_password.volt b/app/Http/Home/Views/account/login_by_password.volt index 2de28228a0aa007610c64a108f1f0b0172fab7ff..000303e3f79635138fe36ad603538f2756e38313 100644 --- a/app/Http/Home/Views/account/login_by_password.volt +++ b/app/Http/Home/Views/account/login_by_password.volt @@ -4,11 +4,11 @@
- +
- +
{% if captcha.enabled == 1 %}
diff --git a/app/Http/Home/Views/order/pay.volt b/app/Http/Home/Views/order/pay.volt index a150e38bffe881a233cc3b9f403cbe34884372ae..a38fd718460ae84f97104f6b1100067812f37750 100644 --- a/app/Http/Home/Views/order/pay.volt +++ b/app/Http/Home/Views/order/pay.volt @@ -51,4 +51,15 @@ {{ js_include('home/js/order.pay.js') }} +{% endblock %} + +{% block inline_js %} + + + {% endblock %} \ No newline at end of file diff --git a/app/Services/Auth/Api.php b/app/Services/Auth/Api.php index 71084950add492569770d2a4c6a877b67ebb8238..bd1534a586c7df7c97531e86f58679407c26cb95 100644 --- a/app/Services/Auth/Api.php +++ b/app/Services/Auth/Api.php @@ -26,7 +26,10 @@ class Api extends AuthService $clientType = $this->getClientType(); - $this->logoutClients($user->id, $clientType); + /** + * demo版本不限制多人登录 + */ + // $this->logoutClients($user->id, $clientType); $this->createUserToken($user->id, $token, $lifetime); diff --git a/app/Services/Auth/Home.php b/app/Services/Auth/Home.php index 9db3e691912af2557943106b222b6f3c1e925baf..455c94a336883f427d63651f63dfdd98693eaf3a 100644 --- a/app/Services/Auth/Home.php +++ b/app/Services/Auth/Home.php @@ -24,7 +24,10 @@ class Home extends AuthService $lifetime = $this->getSessionLifetime(); - $this->logoutClients($user->id); + /** + * demo版本不限制多人登录 + */ + // $this->logoutClients($user->id); $this->createUserSession($user->id, $sessionId, $lifetime); diff --git a/app/Services/ChapterVod.php b/app/Services/ChapterVod.php index 6b2e174e8fa9282ba2958920c678000f0919a533..347b96f618c4712cbd12c6f52b4965f11924f5fa 100644 --- a/app/Services/ChapterVod.php +++ b/app/Services/ChapterVod.php @@ -84,9 +84,12 @@ class ChapterVod extends Service $vodTemplates = $this->getVodTemplates(); + /** + * 腾讯云播放器只支持[od|hd|sd],遇到fd替换为od + */ foreach ($vodTemplates as $key => $template) { if ($height >= $template['height']) { - return $key; + return $key == 'fd' ? $default : $key; } } diff --git a/scheduler.php b/scheduler.php index 70217971c2c8a26a705a88b51fa0bbb80f8b0e86..a45497867d2457c1f4195518be7dbca66c627df1 100644 --- a/scheduler.php +++ b/scheduler.php @@ -72,6 +72,9 @@ $scheduler->php($script, $bin, ['--task' => 'sync_article_score', '--action' => $scheduler->php($script, $bin, ['--task' => 'sync_question_score', '--action' => 'main']) ->hourly(37); +$scheduler->php($script, $bin, ['--task' => 'reset_demo_account', '--action' => 'main']) + ->hourly(59); + $scheduler->php($script, $bin, ['--task' => 'clean_log', '--action' => 'main']) ->daily(3, 3); @@ -87,15 +90,15 @@ $scheduler->php($script, $bin, ['--task' => 'sync_app_info', '--action' => 'main $scheduler->php($script, $bin, ['--task' => 'sync_tag_stat', '--action' => 'main']) ->daily(3, 17); -$scheduler->php($script, $bin, ['--task' => 'sync_course_stat', '--action' => 'main']) - ->daily(3, 19); - $scheduler->php($script, $bin, ['--task' => 'close_question', '--action' => 'main']) ->daily(3, 23); $scheduler->php($script, $bin, ['--task' => 'sitemap', '--action' => 'main']) ->daily(4, 3); +$scheduler->php($script, $bin, ['--task' => 'renew_demo_live_course', '--action' => 'main']) + ->daily(4, 7); + $scheduler->php($script, $bin, ['--task' => 'teacher_live_notice', '--action' => 'provide']) ->daily(4, 7);