diff --git a/README.md b/README.md index 58b0251f..1a478c4f 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,12 @@ 都有些什么功能?我也不想写一大堆,自己体验吧! +帐号:100015@163.com / 123456 (前后台通用) + PS:**系统后台已禁止提交并隐藏私人配置** - [前台演示](https://ctc.koogua.com) - [后台演示](https://ctc.koogua.com/admin) -- [系统截图](https://gitee.com/koogua/course-tencent-cloud/wikis/系统截图) - -体验帐号: 100015@163.com / 123456 #### 项目组件 @@ -33,7 +32,7 @@ PS:**系统后台已禁止提交并隐藏私人配置** #### 安装指南 - [运行环境搭建](https://gitee.com/koogua/course-tencent-cloud-docker) -- [腾讯服务配置](https://gitee.com/koogua/course-tencent-cloud-docker/wikis/腾讯服务配置) +- [系统服务配置](https://gitee.com/koogua/course-tencent-cloud/wikis/服务配置) #### 会推出商业服务吗? diff --git a/app/Builders/ConsultList.php b/app/Builders/ConsultList.php index c74407bd..2223f559 100644 --- a/app/Builders/ConsultList.php +++ b/app/Builders/ConsultList.php @@ -73,7 +73,7 @@ class ConsultList extends Builder $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $result = []; diff --git a/app/Builders/CourseFavoriteList.php b/app/Builders/CourseFavoriteList.php index 9d196641..a516a3a4 100644 --- a/app/Builders/CourseFavoriteList.php +++ b/app/Builders/CourseFavoriteList.php @@ -45,7 +45,7 @@ class CourseFavoriteList extends Builder $courses = $courseRepo->findByIds($ids, $columns); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $result = []; @@ -69,7 +69,7 @@ class CourseFavoriteList extends Builder $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $result = []; diff --git a/app/Builders/CourseList.php b/app/Builders/CourseList.php index 17659789..667de997 100644 --- a/app/Builders/CourseList.php +++ b/app/Builders/CourseList.php @@ -61,7 +61,7 @@ class CourseList extends Builder $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $result = []; diff --git a/app/Builders/CourseTopicList.php b/app/Builders/CourseTopicList.php index 8ae453d8..0d7ebd46 100644 --- a/app/Builders/CourseTopicList.php +++ b/app/Builders/CourseTopicList.php @@ -45,7 +45,7 @@ class CourseTopicList extends Builder $courses = $courseRepo->findByIds($ids, $columns); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $result = []; diff --git a/app/Builders/CourseUserList.php b/app/Builders/CourseUserList.php index 153dd22c..b1579725 100644 --- a/app/Builders/CourseUserList.php +++ b/app/Builders/CourseUserList.php @@ -45,7 +45,7 @@ class CourseUserList extends Builder $courses = $courseRepo->findByIds($ids, $columns); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $result = []; @@ -66,7 +66,7 @@ class CourseUserList extends Builder $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $result = []; diff --git a/app/Builders/DanmuList.php b/app/Builders/DanmuList.php index 0886ed9c..59fa36cb 100644 --- a/app/Builders/DanmuList.php +++ b/app/Builders/DanmuList.php @@ -84,7 +84,7 @@ class DanmuList extends Builder $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $result = []; diff --git a/app/Builders/ImFriendUserList.php b/app/Builders/ImFriendUserList.php index f8a39826..50d69ce7 100644 --- a/app/Builders/ImFriendUserList.php +++ b/app/Builders/ImFriendUserList.php @@ -31,7 +31,7 @@ class ImFriendUserList extends Builder $users = $userRepo->findByIds($ids, $columns); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $result = []; diff --git a/app/Builders/ImGroupList.php b/app/Builders/ImGroupList.php index 7f779425..39316477 100644 --- a/app/Builders/ImGroupList.php +++ b/app/Builders/ImGroupList.php @@ -55,7 +55,7 @@ class ImGroupList extends Builder $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $result = []; diff --git a/app/Builders/ImGroupUserList.php b/app/Builders/ImGroupUserList.php index 4947f967..dafe443f 100644 --- a/app/Builders/ImGroupUserList.php +++ b/app/Builders/ImGroupUserList.php @@ -40,7 +40,7 @@ class ImGroupUserList extends Builder $users = $userRepo->findByIds($ids, $columns); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $result = []; @@ -64,7 +64,7 @@ class ImGroupUserList extends Builder $users = $this->getGroupOwners($groups->toArray()); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $result = []; diff --git a/app/Builders/ImMessageList.php b/app/Builders/ImMessageList.php index 486feb25..0c394cc6 100644 --- a/app/Builders/ImMessageList.php +++ b/app/Builders/ImMessageList.php @@ -26,7 +26,7 @@ class ImMessageList extends Builder $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $result = []; diff --git a/app/Builders/OrderList.php b/app/Builders/OrderList.php index 18caf72b..5a5a2ff6 100644 --- a/app/Builders/OrderList.php +++ b/app/Builders/OrderList.php @@ -12,7 +12,7 @@ class OrderList extends Builder public function __construct() { - $this->imgBaseUrl = kg_ci_base_url(); + $this->imgBaseUrl = kg_ss_url(); } /** diff --git a/app/Builders/ReviewList.php b/app/Builders/ReviewList.php index a78a1f65..e16f430b 100644 --- a/app/Builders/ReviewList.php +++ b/app/Builders/ReviewList.php @@ -55,7 +55,7 @@ class ReviewList extends Builder $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $result = []; diff --git a/app/Builders/UserList.php b/app/Builders/UserList.php index b033ec1b..4731773e 100644 --- a/app/Builders/UserList.php +++ b/app/Builders/UserList.php @@ -10,7 +10,7 @@ class UserList extends Builder public function handleUsers(array $users) { - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); foreach ($users as $key => $user) { $users[$key]['avatar'] = $baseUrl . $user['avatar']; diff --git a/app/Console/Tasks/CleanSessionTask.php b/app/Console/Tasks/CleanSessionTask.php index a7140a1b..2be57e51 100644 --- a/app/Console/Tasks/CleanSessionTask.php +++ b/app/Console/Tasks/CleanSessionTask.php @@ -4,39 +4,32 @@ namespace App\Console\Tasks; use App\Library\Cache\Backend\Redis as RedisCache; use Phalcon\Cli\Task; +use Phalcon\Config; class CleanSessionTask extends Task { - /** - * @var RedisCache - */ - protected $cache; - - /** - * @var \Redis - */ - protected $redis; - public function mainAction() { - $this->cache = $this->getDI()->get('cache'); + $config = $this->getConfig(); - $this->redis = $this->cache->getRedis(); + $cache = $this->getCache(); + + $redis = $cache->getRedis(); + + $redis->select($config->path('session.db')); $keys = $this->querySessionKeys(10000); if (count($keys) == 0) return; - $config = $this->getDI()->get('config'); - - $lifetime = $config->session->lifetime; + $lifetime = $config->path('session.lifetime'); foreach ($keys as $key) { - $ttl = $this->redis->ttl($key); - $content = $this->redis->get($key); + $ttl = $redis->ttl($key); + $content = $redis->get($key); if (empty($content) && $ttl < $lifetime * 0.5) { - $this->redis->del($key); + $redis->del($key); } } } @@ -49,7 +42,29 @@ class CleanSessionTask extends Task */ protected function querySessionKeys($limit) { - return $this->cache->queryKeys('_PHCR', $limit); + $cache = $this->getCache(); + + return $cache->queryKeys('_PHCR', $limit); + } + + protected function getConfig() + { + /** + * @var Config $config + */ + $config = $this->getDI()->get('config'); + + return $config; + } + + protected function getCache() + { + /** + * @var RedisCache $cache + */ + $cache = $this->getDI()->get('cache'); + + return $cache; } } diff --git a/app/Http/Admin/Controllers/ChapterController.php b/app/Http/Admin/Controllers/ChapterController.php index 755c9ba1..bbef2879 100644 --- a/app/Http/Admin/Controllers/ChapterController.php +++ b/app/Http/Admin/Controllers/ChapterController.php @@ -5,7 +5,6 @@ namespace App\Http\Admin\Controllers; use App\Http\Admin\Services\Chapter as ChapterService; use App\Http\Admin\Services\ChapterContent as ChapterContentService; use App\Http\Admin\Services\Course as CourseService; -use App\Http\Admin\Services\Setting as SettingService; use App\Models\Course as CourseModel; /** @@ -86,13 +85,10 @@ class ChapterController extends Controller $contentService = new ChapterContentService(); $chapterService = new ChapterService(); $courseService = new CourseService(); - $settingService = new SettingService(); $chapter = $chapterService->getChapter($id); $course = $courseService->getCourse($chapter->course_id); - $storage = $settingService->getSectionSettings('storage'); - $this->view->setVar('storage', $storage); $this->view->setVar('chapter', $chapter); $this->view->setVar('course', $course); diff --git a/app/Http/Admin/Controllers/SettingController.php b/app/Http/Admin/Controllers/SettingController.php index c06cf6d6..1531065b 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['url'] = $site['url'] ?: kg_site_url(); $this->view->setVar('site', $site); } @@ -67,7 +67,7 @@ class SettingController extends Controller */ public function storageAction() { - $section = 'storage'; + $section = 'cos'; $settingService = new SettingService(); @@ -81,9 +81,9 @@ class SettingController extends Controller } else { - $storage = $settingService->getSectionSettings($section); + $cos = $settingService->getSectionSettings($section); - $this->view->setVar('storage', $storage); + $this->view->setVar('cos', $cos); } } diff --git a/app/Http/Admin/Controllers/UploadController.php b/app/Http/Admin/Controllers/UploadController.php index f7ab899f..eb251179 100644 --- a/app/Http/Admin/Controllers/UploadController.php +++ b/app/Http/Admin/Controllers/UploadController.php @@ -22,7 +22,7 @@ class UploadController extends Controller if ($file) { return $this->jsonSuccess([ 'data' => [ - 'src' => $service->getCiImageUrl($file->path), + 'src' => $service->getImageUrl($file->path), 'title' => $file->name, ] ]); @@ -43,7 +43,7 @@ class UploadController extends Controller if ($file) { return $this->jsonSuccess([ 'data' => [ - 'src' => $service->getCiImageUrl($file->path), + 'src' => $service->getImageUrl($file->path), 'title' => $file->name, ] ]); @@ -64,7 +64,7 @@ class UploadController extends Controller if ($file) { return $this->jsonSuccess([ 'data' => [ - 'src' => $service->getCiImageUrl($file->path), + 'src' => $service->getImageUrl($file->path), 'title' => $file->name, ] ]); diff --git a/app/Http/Admin/Services/Setting.php b/app/Http/Admin/Services/Setting.php index 90e27a9c..a3f4104b 100644 --- a/app/Http/Admin/Services/Setting.php +++ b/app/Http/Admin/Services/Setting.php @@ -87,12 +87,8 @@ class Setting extends Service { $protocol = ['http://', 'https://']; - if (isset($settings['bucket_domain'])) { - $settings['bucket_domain'] = str_replace($protocol, '', $settings['bucket_domain']); - } - - if (isset($settings['ci_domain'])) { - $settings['ci_domain'] = str_replace($protocol, '', $settings['ci_domain']); + if (isset($settings['domain'])) { + $settings['domain'] = str_replace($protocol, '', $settings['domain']); } $this->updateSectionSettings($section, $settings); @@ -107,12 +103,10 @@ class Setting extends Service { $protocol = ['http://', 'https://']; - if (isset($settings['push_domain'])) { - $settings['push_domain'] = str_replace($protocol, '', $settings['push_domain']); - } - - if (isset($settings['pull_domain'])) { - $settings['pull_domain'] = str_replace($protocol, '', $settings['pull_domain']); + if (in_array($section, ['live.push', 'live.pull'])) { + if (isset($settings['domain'])) { + $settings['domain'] = str_replace($protocol, '', $settings['domain']); + } } $this->updateSectionSettings($section, $settings); diff --git a/app/Http/Admin/Views/chapter/edit_lesson.volt b/app/Http/Admin/Views/chapter/edit_lesson.volt index 9b30eba6..802c973e 100644 --- a/app/Http/Admin/Views/chapter/edit_lesson.volt +++ b/app/Http/Admin/Views/chapter/edit_lesson.volt @@ -26,11 +26,11 @@ {{ partial('chapter/edit_lesson_basic') }}
- {% if course.model == '1' %} + {% if course.model == 1 %} {{ partial('chapter/edit_lesson_vod') }} - {% elseif course.model == '2' %} + {% elseif course.model == 2 %} {{ partial('chapter/edit_lesson_live') }} - {% elseif course.model == '3' %} + {% elseif course.model == 3 %} {{ partial('chapter/edit_lesson_read') }} {% endif %}
diff --git a/app/Http/Admin/Views/setting/site.volt b/app/Http/Admin/Views/setting/site.volt index 14aa3ab6..bed80a89 100644 --- a/app/Http/Admin/Views/setting/site.volt +++ b/app/Http/Admin/Views/setting/site.volt @@ -32,7 +32,7 @@
- +
diff --git a/app/Http/Admin/Views/setting/storage.volt b/app/Http/Admin/Views/setting/storage.volt index 650b68d9..ced0f8ca 100644 --- a/app/Http/Admin/Views/setting/storage.volt +++ b/app/Http/Admin/Views/setting/storage.volt @@ -9,26 +9,26 @@
- +
- +
- - + +
- +
diff --git a/app/Http/Desktop/Controllers/MyController.php b/app/Http/Desktop/Controllers/MyController.php index e9581bb5..8334d646 100644 --- a/app/Http/Desktop/Controllers/MyController.php +++ b/app/Http/Desktop/Controllers/MyController.php @@ -151,14 +151,14 @@ class MyController extends Controller */ public function groupsAction() { - $type = $this->request->getQuery('type', 'trim', 'joined'); + $scope = $this->request->getQuery('scope', 'trim', 'joined'); $service = new MyGroupListService(); - $pager = $service->handle($type); + $pager = $service->handle($scope); $this->view->pick('my/groups'); - $this->view->setVar('type', $type); + $this->view->setVar('scope', $scope); $this->view->setVar('pager', $pager); } diff --git a/app/Http/Desktop/Controllers/PublicController.php b/app/Http/Desktop/Controllers/PublicController.php index b25eefac..b838cc5b 100644 --- a/app/Http/Desktop/Controllers/PublicController.php +++ b/app/Http/Desktop/Controllers/PublicController.php @@ -32,7 +32,7 @@ class PublicController extends \Phalcon\Mvc\Controller $service = new StorageService(); - $location = $service->getCiImageUrl($file->path); + $location = $service->getImageUrl($file->path); $this->response->redirect($location); diff --git a/app/Http/Desktop/Controllers/UploadController.php b/app/Http/Desktop/Controllers/UploadController.php index 062ceb20..d1d3453f 100644 --- a/app/Http/Desktop/Controllers/UploadController.php +++ b/app/Http/Desktop/Controllers/UploadController.php @@ -18,12 +18,15 @@ class UploadController extends Controller { $service = new StorageService(); - $key = $service->uploadAvatarImage(); + $file = $service->uploadAvatarImage(); - $url = $service->getCiImageUrl($key); - - if ($url) { - return $this->jsonSuccess(['data' => ['src' => $url, 'title' => '']]); + if ($file) { + return $this->jsonSuccess([ + 'data' => [ + 'src' => $service->getImageUrl($file->path), + 'title' => $file->name, + ] + ]); } else { return $this->jsonError(['msg' => '上传文件失败']); } diff --git a/app/Http/Desktop/Services/Im.php b/app/Http/Desktop/Services/Im.php index 240a16d7..251e0e2e 100644 --- a/app/Http/Desktop/Services/Im.php +++ b/app/Http/Desktop/Services/Im.php @@ -59,7 +59,7 @@ class Im extends Service return []; } - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $result = []; @@ -252,7 +252,7 @@ class Im extends Service $users = $userRepo->findByIds($ids); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $mapping = []; @@ -303,7 +303,7 @@ class Im extends Service $groups = $groupRepo->findByIds($ids); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $mapping = []; diff --git a/app/Http/Desktop/Services/ImGroup.php b/app/Http/Desktop/Services/ImGroup.php index 57e2dfdf..ac3d9c4c 100644 --- a/app/Http/Desktop/Services/ImGroup.php +++ b/app/Http/Desktop/Services/ImGroup.php @@ -188,7 +188,7 @@ class ImGroup extends Service $users = $builder->getUsers($groups); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $items = []; diff --git a/app/Http/Desktop/Views/im/group/manage/edit.volt b/app/Http/Desktop/Views/im/group/manage/edit.volt index dca5c02f..92ab7093 100644 --- a/app/Http/Desktop/Views/im/group/manage/edit.volt +++ b/app/Http/Desktop/Views/im/group/manage/edit.volt @@ -2,8 +2,8 @@ {% block content %} - {% set update_url = url({'for':'desktop.group.update','id':group.id}) %} - {% set name_readonly = group.type == 'course' ? 'readonly="readonly"' : '' %} + {% set update_url = url({'for':'desktop.igm.update','id':group.id}) %} + {% set name_readonly = group.type == 1 ? 'readonly="readonly"' : '' %}
diff --git a/app/Http/Desktop/Views/im/group/pager.volt b/app/Http/Desktop/Views/im/group/pager.volt index f2c147bc..de0ffd57 100644 --- a/app/Http/Desktop/Views/im/group/pager.volt +++ b/app/Http/Desktop/Views/im/group/pager.volt @@ -11,7 +11,7 @@ {{ type_info(item.type) }}
diff --git a/app/Http/Desktop/Views/im/index_groups.volt b/app/Http/Desktop/Views/im/index_groups.volt index f05bb731..ee9f34b8 100644 --- a/app/Http/Desktop/Views/im/index_groups.volt +++ b/app/Http/Desktop/Views/im/index_groups.volt @@ -8,7 +8,7 @@ {{ type_info(group.type) }}
diff --git a/app/Http/Desktop/Views/im/index_users.volt b/app/Http/Desktop/Views/im/index_users.volt index 7515629b..ebf8c60e 100644 --- a/app/Http/Desktop/Views/im/index_users.volt +++ b/app/Http/Desktop/Views/im/index_users.volt @@ -9,7 +9,7 @@ {{ vip_info(user.vip) }}
diff --git a/app/Http/Desktop/Views/my/groups.volt b/app/Http/Desktop/Views/my/groups.volt index f5e3a6f4..7520087a 100644 --- a/app/Http/Desktop/Views/my/groups.volt +++ b/app/Http/Desktop/Views/my/groups.volt @@ -4,10 +4,10 @@ {{ partial('macros/group') }} - {% set joined_url = url({'for':'desktop.my.groups'},{'type':'joined'}) %} - {% set owned_url = url({'for':'desktop.my.groups'},{'type':'owned'}) %} - {% set joined_class = type == 'joined' ? 'layui-btn layui-btn-xs' : 'none' %} - {% set owned_class = type == 'owned' ? 'layui-btn layui-btn-xs' : 'none' %} + {% set joined_url = url({'for':'desktop.my.groups'},{'scope':'joined'}) %} + {% set owned_url = url({'for':'desktop.my.groups'},{'scope':'owned'}) %} + {% set joined_class = scope == 'joined' ? 'layui-btn layui-btn-xs' : 'none' %} + {% set owned_class = scope == 'owned' ? 'layui-btn layui-btn-xs' : 'none' %}
{{ partial('my/menu') }}
@@ -18,7 +18,7 @@ 管理的
- {% if type == 'owned' %} + {% if scope == 'owned' %} {{ partial('my/groups_owned') }} {% else %} {{ partial('my/groups_joined') }} diff --git a/app/Http/Desktop/Views/teacher/pager.volt b/app/Http/Desktop/Views/teacher/pager.volt index 5c145780..63dfb7ae 100644 --- a/app/Http/Desktop/Views/teacher/pager.volt +++ b/app/Http/Desktop/Views/teacher/pager.volt @@ -2,14 +2,14 @@
{% for item in pager.items %} - {% set item.title = item.title ? item.title : '暂露头角' %} + {% set item.title = item.title ? item.title : '小小教书匠' %} {% set item.about = item.about ? item.about : '这个人很懒,什么都没留下' %} {% set user_url = url({'for':'desktop.teacher.show','id':item.id}) %}
diff --git a/app/Http/Desktop/Views/vip/users.volt b/app/Http/Desktop/Views/vip/users.volt index 966fee38..0be0e6a1 100644 --- a/app/Http/Desktop/Views/vip/users.volt +++ b/app/Http/Desktop/Views/vip/users.volt @@ -12,7 +12,7 @@ {{ vip_info(item.vip) }}
diff --git a/app/Library/Helper.php b/app/Library/Helper.php index 0ee934f5..5dd4b3b1 100644 --- a/app/Library/Helper.php +++ b/app/Library/Helper.php @@ -121,7 +121,7 @@ function kg_ip2region($ip, $dbFile = null) * * @return string */ -function kg_site_base_url() +function kg_site_url() { $scheme = filter_input(INPUT_SERVER, 'REQUEST_SCHEME'); $host = filter_input(INPUT_SERVER, 'HTTP_HOST'); @@ -168,25 +168,25 @@ function kg_default_cover_path() } /** - * 获取数据万象基准URL + * 获取存储基准URL * * @return string */ -function kg_ci_base_url() +function kg_ss_url() { $storage = new StorageService(); - return $storage->getCiBaseUrl(); + return $storage->getBaseUrl(); } /** - * 获取数据万象URL + * 获取存储图片URL * * @param string $path * @param string $style * @return string */ -function kg_ci_img_url($path, $style = null) +function kg_ss_img_url($path, $style = null) { if (!$path) return ''; @@ -196,35 +196,35 @@ function kg_ci_img_url($path, $style = null) $storage = new StorageService(); - return $storage->getCiImageUrl($path, $style); + return $storage->getImageUrl($path, $style); } /** - * 获取头像数据万象URL + * 获取头像URL * * @param string $path * @param string $style * @return string */ -function kg_ci_avatar_img_url($path, $style = null) +function kg_ss_avatar_url($path, $style = null) { $path = $path ?: kg_default_avatar_path(); - return kg_ci_img_url($path, $style); + return kg_ss_img_url($path, $style); } /** - * 获取封面数据万象URL + * 获取封面URL * * @param string $path * @param string $style * @return string */ -function kg_ci_cover_img_url($path, $style = null) +function kg_ss_cover_url($path, $style = null) { $path = $path ?: kg_default_cover_path(); - return kg_ci_img_url($path, $style); + return kg_ss_img_url($path, $style); } /** @@ -432,7 +432,7 @@ function kg_full_url($uri, $args = null) */ $url = Di::getDefault()->getShared('url'); - $baseUrl = kg_site_base_url(); + $baseUrl = kg_site_url(); return $baseUrl . $url->get($uri, $args); } \ No newline at end of file diff --git a/app/Models/Carousel.php b/app/Models/Carousel.php index 1b8c883b..91195f96 100644 --- a/app/Models/Carousel.php +++ b/app/Models/Carousel.php @@ -158,7 +158,7 @@ class Carousel extends Model public function afterFetch() { if (!Text::startsWith($this->cover, 'http')) { - $this->cover = kg_ci_cover_img_url($this->cover); + $this->cover = kg_ss_cover_url($this->cover); } if (is_string($this->style) && !empty($this->style)) { diff --git a/app/Models/Course.php b/app/Models/Course.php index 3c190525..360fd328 100644 --- a/app/Models/Course.php +++ b/app/Models/Course.php @@ -338,7 +338,7 @@ class Course extends Model $this->score = (float)$this->score; if (!Text::startsWith($this->cover, 'http')) { - $this->cover = kg_ci_cover_img_url($this->cover); + $this->cover = kg_ss_cover_url($this->cover); } if (is_string($this->attrs) && !empty($this->attrs)) { diff --git a/app/Models/ImGroup.php b/app/Models/ImGroup.php index 88b07f28..946df252 100644 --- a/app/Models/ImGroup.php +++ b/app/Models/ImGroup.php @@ -156,7 +156,7 @@ class ImGroup extends Model public function afterFetch() { if (!Text::startsWith($this->avatar, 'http')) { - $this->avatar = kg_ci_avatar_img_url($this->avatar); + $this->avatar = kg_ss_avatar_url($this->avatar); } } diff --git a/app/Models/ImUser.php b/app/Models/ImUser.php index 4b358218..9b4ed69f 100644 --- a/app/Models/ImUser.php +++ b/app/Models/ImUser.php @@ -133,7 +133,7 @@ class ImUser extends Model public function afterFetch() { if (!Text::startsWith($this->avatar, 'http')) { - $this->avatar = kg_ci_avatar_img_url($this->avatar); + $this->avatar = kg_ss_avatar_url($this->avatar); } } diff --git a/app/Models/User.php b/app/Models/User.php index a96ab300..4553cf2c 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -221,7 +221,7 @@ class User extends Model public function afterFetch() { if (!Text::startsWith($this->avatar, 'http')) { - $this->avatar = kg_ci_avatar_img_url($this->avatar); + $this->avatar = kg_ss_avatar_url($this->avatar); } } diff --git a/app/Providers/Volt.php b/app/Providers/Volt.php index ac767758..835c7af8 100644 --- a/app/Providers/Volt.php +++ b/app/Providers/Volt.php @@ -46,8 +46,8 @@ class Volt extends Provider return 'kg_js_include(' . $resolvedArgs . ')'; }); - $compiler->addFunction('ci_img_url', function ($resolvedArgs) { - return 'kg_ci_img_url(' . $resolvedArgs . ')'; + $compiler->addFunction('ss_img_url', function ($resolvedArgs) { + return 'kg_ss_img_url(' . $resolvedArgs . ')'; }); $compiler->addFunction('substr', function ($resolvedArgs) { diff --git a/app/Services/Frontend/Course/CourseList.php b/app/Services/Frontend/Course/CourseList.php index 2e681fb9..35e3b60a 100644 --- a/app/Services/Frontend/Course/CourseList.php +++ b/app/Services/Frontend/Course/CourseList.php @@ -57,7 +57,7 @@ class CourseList extends FrontendService $items = []; - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); foreach ($courses as $course) { diff --git a/app/Services/Frontend/My/GroupList.php b/app/Services/Frontend/My/GroupList.php index 407da39a..e399cad2 100644 --- a/app/Services/Frontend/My/GroupList.php +++ b/app/Services/Frontend/My/GroupList.php @@ -11,13 +11,13 @@ use App\Services\Frontend\User\GroupList as UserGroupListService; class GroupList extends FrontendService { - public function handle($type) + public function handle($scope) { $result = []; - if ($type == 'joined') { + if ($scope == 'joined') { $result = $this->handleJoinedGroups(); - } elseif ($type == 'owned') { + } elseif ($scope == 'owned') { $result = $this->handleOwnedGroups(); } @@ -62,7 +62,7 @@ class GroupList extends FrontendService $users = $builder->getUsers($groups); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $items = []; diff --git a/app/Services/Frontend/My/ProfileInfo.php b/app/Services/Frontend/My/ProfileInfo.php index 1486f3bd..7bf92074 100644 --- a/app/Services/Frontend/My/ProfileInfo.php +++ b/app/Services/Frontend/My/ProfileInfo.php @@ -17,7 +17,7 @@ class ProfileInfo extends FrontendService protected function handleUser(UserModel $user) { - $user->avatar = kg_ci_img_url($user->avatar); + $user->avatar = kg_ss_avatar_url($user->avatar); $user->area = $this->handleArea($user->area); diff --git a/app/Services/Frontend/Order/OrderInfo.php b/app/Services/Frontend/Order/OrderInfo.php index d0d30221..cad86657 100644 --- a/app/Services/Frontend/Order/OrderInfo.php +++ b/app/Services/Frontend/Order/OrderInfo.php @@ -91,14 +91,14 @@ class OrderInfo extends FrontendService protected function handleCourseInfo($itemInfo) { - $itemInfo['course']['cover'] = kg_ci_img_url($itemInfo['course']['cover']); + $itemInfo['course']['cover'] = kg_ss_cover_url($itemInfo['course']['cover']); return $itemInfo; } protected function handlePackageInfo($itemInfo) { - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); foreach ($itemInfo['courses'] as &$course) { $course['cover'] = $baseUrl . $course['cover']; diff --git a/app/Services/Frontend/Teacher/TeacherList.php b/app/Services/Frontend/Teacher/TeacherList.php index b300a1a8..79db1330 100644 --- a/app/Services/Frontend/Teacher/TeacherList.php +++ b/app/Services/Frontend/Teacher/TeacherList.php @@ -40,7 +40,7 @@ class TeacherList extends FrontendService $items = []; - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); foreach ($users as $user) { diff --git a/app/Services/Frontend/Teaching/CourseList.php b/app/Services/Frontend/Teaching/CourseList.php index d8c93650..ae2be19c 100644 --- a/app/Services/Frontend/Teaching/CourseList.php +++ b/app/Services/Frontend/Teaching/CourseList.php @@ -33,7 +33,7 @@ class CourseList extends FrontendService $items = []; - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); foreach ($pager->items->toArray() as $course) { diff --git a/app/Services/Frontend/Vip/CourseList.php b/app/Services/Frontend/Vip/CourseList.php index 0a9b6d1b..97258237 100644 --- a/app/Services/Frontend/Vip/CourseList.php +++ b/app/Services/Frontend/Vip/CourseList.php @@ -37,7 +37,7 @@ class CourseList extends FrontendService $courses = $pager->items->toArray(); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $items = []; diff --git a/app/Services/Frontend/Vip/UserList.php b/app/Services/Frontend/Vip/UserList.php index d282760a..145c9590 100644 --- a/app/Services/Frontend/Vip/UserList.php +++ b/app/Services/Frontend/Vip/UserList.php @@ -37,7 +37,7 @@ class UserList extends FrontendService $users = $pager->items->toArray(); - $baseUrl = kg_ci_base_url(); + $baseUrl = kg_ss_url(); $items = []; diff --git a/app/Services/Pay/WxpayGateway.php b/app/Services/Pay/WxpayGateway.php index 3ecfa1c4..8e06c588 100644 --- a/app/Services/Pay/WxpayGateway.php +++ b/app/Services/Pay/WxpayGateway.php @@ -45,6 +45,8 @@ class WxpayGateway extends Service 'mch_id' => $this->settings['mch_id'], 'key' => $this->settings['key'], 'notify_url' => $this->settings['notify_url'], + 'cert_client' => '', + 'cert_key' => '', 'log' => [ 'file' => log_path('wxpay.log'), 'level' => $level, diff --git a/app/Services/Refund.php b/app/Services/Refund.php index d29614fa..8e544a15 100644 --- a/app/Services/Refund.php +++ b/app/Services/Refund.php @@ -32,7 +32,7 @@ class Refund extends Service */ $itemInfo = $order->item_info; - $itemInfo['course']['cover'] = kg_ci_cover_img_url($itemInfo['course']['cover']); + $itemInfo['course']['cover'] = kg_ss_cover_url($itemInfo['course']['cover']); $refundPercent = 0.00; $refundAmount = 0.00; @@ -72,7 +72,7 @@ class Refund extends Service */ foreach ($itemInfo['courses'] as &$course) { - $course['cover'] = kg_ci_cover_img_url($course['cover']); + $course['cover'] = kg_ss_cover_url($course['cover']); $refundPercent = 0.00; $refundAmount = 0.00; diff --git a/app/Services/Storage.php b/app/Services/Storage.php index 10261364..57f12200 100644 --- a/app/Services/Storage.php +++ b/app/Services/Storage.php @@ -25,7 +25,7 @@ class Storage extends Service public function __construct() { - $this->settings = $this->getSectionSettings('storage'); + $this->settings = $this->getSectionSettings('cos'); $this->logger = $this->getLogger('storage'); @@ -41,7 +41,7 @@ class Storage extends Service */ public function putString($key, $body) { - $bucket = $this->settings['bucket_name']; + $bucket = $this->settings['bucket']; try { @@ -52,7 +52,6 @@ class Storage extends Service } catch (\Exception $e) { $this->logger->error('Put String Exception ' . kg_json_encode([ - 'line' => $e->getLine(), 'code' => $e->getCode(), 'message' => $e->getMessage(), ])); @@ -72,7 +71,7 @@ class Storage extends Service */ public function putFile($key, $filename) { - $bucket = $this->settings['bucket_name']; + $bucket = $this->settings['bucket']; try { @@ -85,7 +84,6 @@ class Storage extends Service } catch (\Exception $e) { $this->logger->error('Put File Exception ' . kg_json_encode([ - 'line' => $e->getLine(), 'code' => $e->getCode(), 'message' => $e->getMessage(), ])); @@ -104,7 +102,7 @@ class Storage extends Service */ public function deleteObject($key) { - $bucket = $this->settings['bucket_name']; + $bucket = $this->settings['bucket']; try { @@ -118,7 +116,6 @@ class Storage extends Service } catch (\Exception $e) { $this->logger->error('Delete Object Exception ' . kg_json_encode([ - 'line' => $e->getLine(), 'code' => $e->getCode(), 'message' => $e->getMessage(), ])); @@ -130,52 +127,39 @@ class Storage extends Service } /** - * 获取存储桶文件URL + * 获取文件URL * * @param string $key * @return string */ - public function getBucketFileUrl($key) + public function getFileUrl($key) { - return $this->getBucketBaseUrl() . $key; + return $this->getBaseUrl() . $key; } /** - * 获取数据万象图片URL + * 获取图片URL * * @param string $key * @param string $style * @return string */ - public function getCiImageUrl($key, $style = null) + public function getImageUrl($key, $style = null) { $style = $style ?: ''; - return $this->getCiBaseUrl() . $key . $style; + return $this->getBaseUrl() . $key . $style; } /** - * 获取存储桶根URL + * 获取基准URL * * @return string */ - public function getBucketBaseUrl() + public function getBaseUrl() { - $protocol = $this->settings['bucket_protocol']; - $domain = $this->settings['bucket_domain']; - - return sprintf('%s://%s', $protocol, trim($domain, '/')); - } - - /** - * 获取数据万象根URL - * - * @return string - */ - public function getCiBaseUrl() - { - $protocol = $this->settings['ci_protocol']; - $domain = $this->settings['ci_domain']; + $protocol = $this->settings['protocol']; + $domain = $this->settings['domain']; return sprintf('%s://%s', $protocol, trim($domain, '/')); } @@ -217,8 +201,8 @@ class Storage extends Service $secret = $this->getSectionSettings('secret'); return new CosClient([ - 'region' => $this->settings['bucket_region'], - 'schema' => $this->settings['bucket_protocol'], + 'region' => $this->settings['region'], + 'schema' => $this->settings['protocol'], 'credentials' => [ 'secretId' => $secret['secret_id'], 'secretKey' => $secret['secret_key'], diff --git a/db/migrations/20200827112717_insert_setting_data.php b/db/migrations/20200827112717_insert_setting_data.php index 2f677fca..485c54e9 100644 --- a/db/migrations/20200827112717_insert_setting_data.php +++ b/db/migrations/20200827112717_insert_setting_data.php @@ -10,6 +10,11 @@ final class InsertSettingData extends AbstractMigration public function up() { $rows = [ + [ + 'section' => 'captcha', + 'item_key' => 'enabled', + 'item_value' => '0', + ], [ 'section' => 'captcha', 'item_key' => 'app_id', @@ -21,7 +26,7 @@ final class InsertSettingData extends AbstractMigration 'item_value' => '', ], [ - 'section' => 'captcha', + 'section' => 'im.cs', 'item_key' => 'enabled', 'item_value' => '0', ], @@ -32,8 +37,8 @@ final class InsertSettingData extends AbstractMigration ], [ 'section' => 'im.cs', - 'item_key' => 'enabled', - 'item_value' => '0', + 'item_key' => 'user2_id', + 'item_value' => '', ], [ 'section' => 'im.cs', @@ -41,20 +46,15 @@ final class InsertSettingData extends AbstractMigration 'item_value' => '', ], [ - 'section' => 'im.cs', - 'item_key' => 'user2_id', - 'item_value' => '', + 'section' => 'im.main', + 'item_key' => 'title', + 'item_value' => '菜鸟驿站', ], [ 'section' => 'im.main', 'item_key' => 'msg_max_length', 'item_value' => '1000', ], - [ - 'section' => 'im.main', - 'item_key' => 'title', - 'item_value' => '菜鸟驿站', - ], [ 'section' => 'im.main', 'item_key' => 'upload_img_enabled', @@ -170,6 +170,11 @@ final class InsertSettingData extends AbstractMigration 'item_key' => 'smtp_encryption', 'item_value' => 'ssl', ], + [ + 'section' => 'mailer', + 'item_key' => 'smtp_authentication', + 'item_value' => '1', + ], [ 'section' => 'mailer', 'item_key' => 'smtp_username', @@ -191,10 +196,15 @@ final class InsertSettingData extends AbstractMigration 'item_value' => 'ABC有限公司', ], [ - 'section' => 'mailer', - 'item_key' => 'smtp_authentication', + 'section' => 'pay.alipay', + 'item_key' => 'enabled', 'item_value' => '1', ], + [ + 'section' => 'pay.alipay', + 'item_key' => 'app_id', + 'item_value' => '', + ], [ 'section' => 'pay.alipay', 'item_key' => 'public_key', @@ -207,34 +217,19 @@ final class InsertSettingData extends AbstractMigration ], [ 'section' => 'pay.alipay', + 'item_key' => 'return_url', + 'item_value' => '', + ], + [ + 'section' => 'pay.alipay', + 'item_key' => 'notify_url', + 'item_value' => '', + ], + [ + 'section' => 'pay.wxpay', 'item_key' => 'enabled', 'item_value' => '1', ], - [ - 'section' => 'pay.alipay', - 'item_key' => 'return_url', - 'item_value' => '', - ], - [ - 'section' => 'pay.alipay', - 'item_key' => 'notify_url', - 'item_value' => '', - ], - [ - 'section' => 'pay.alipay', - 'item_key' => 'app_id', - 'item_value' => '', - ], - [ - 'section' => 'pay.wxpay', - 'item_key' => 'notify_url', - 'item_value' => '', - ], - [ - 'section' => 'pay.wxpay', - 'item_key' => 'return_url', - 'item_value' => '', - ], [ 'section' => 'pay.wxpay', 'item_key' => 'app_id', @@ -252,8 +247,13 @@ final class InsertSettingData extends AbstractMigration ], [ 'section' => 'pay.wxpay', - 'item_key' => 'enabled', - 'item_value' => '1', + 'item_key' => 'notify_url', + 'item_value' => '', + ], + [ + 'section' => 'pay.wxpay', + 'item_key' => 'return_url', + 'item_value' => '', ], [ 'section' => 'secret', @@ -270,6 +270,11 @@ final class InsertSettingData extends AbstractMigration 'item_key' => 'app_id', 'item_value' => '', ], + [ + 'section' => 'site', + 'item_key' => 'title', + 'item_value' => '酷瓜云课堂', + ], [ 'section' => 'site', 'item_key' => 'keywords', @@ -277,9 +282,29 @@ final class InsertSettingData extends AbstractMigration ], [ 'section' => 'site', - 'item_key' => 'analytics', + 'item_key' => 'description', + 'item_value' => '酷瓜云课堂,依托腾讯云基础服务,使用C扩展框架PHALCON开发', + ], + [ + 'section' => 'site', + 'item_key' => 'url', 'item_value' => '', ], + [ + 'section' => 'site', + 'item_key' => 'enabled', + 'item_value' => '1', + ], + [ + 'section' => 'site', + 'item_key' => 'closed_tips', + 'item_value' => '站点维护中,请稍后再访问。', + ], + [ + 'section' => 'site', + 'item_key' => 'copyright', + 'item_value' => '2016-2020 深圳市酷瓜软件有限公司', + ], [ 'section' => 'site', 'item_key' => 'icp_sn', @@ -302,34 +327,9 @@ final class InsertSettingData extends AbstractMigration ], [ 'section' => 'site', - 'item_key' => 'copyright', - 'item_value' => '2016-2020 深圳市酷瓜软件有限公司', - ], - [ - 'section' => 'site', - 'item_key' => 'base_url', + 'item_key' => 'analytics', 'item_value' => '', ], - [ - 'section' => 'site', - 'item_key' => 'enabled', - 'item_value' => '1', - ], - [ - 'section' => 'site', - 'item_key' => 'closed_tips', - 'item_value' => '站点维护中,请稍后再访问。', - ], - [ - 'section' => 'site', - 'item_key' => 'description', - 'item_value' => '酷瓜云课堂,依托腾讯云基础服务,使用C扩展框架PHALCON开发', - ], - [ - 'section' => 'site', - 'item_key' => 'title', - 'item_value' => '酷瓜云课堂', - ], [ 'section' => 'smser', 'item_key' => 'app_id', @@ -337,8 +337,8 @@ final class InsertSettingData extends AbstractMigration ], [ 'section' => 'smser', - 'item_key' => 'template', - 'item_value' => '{"verify":{"id":"561282","content":"验证码:{1},{2} 分钟内有效,如非本人操作请忽略。"},"order":{"id":"561954","content":"下单成功,商品名称:{1},订单序号:{2},订单金额:¥{3}"},"refund":{"id":"561286","content":"退款成功,商品名称:{1},订单序号:{2},退款金额:¥{3}"},"live":{"id":"561288","content":"直播预告,课程名称:{1},章节名称:{2},开播时间:{3}"}}', + 'item_key' => 'app_key', + 'item_value' => '', ], [ 'section' => 'smser', @@ -347,64 +347,29 @@ final class InsertSettingData extends AbstractMigration ], [ 'section' => 'smser', - 'item_key' => 'app_key', + 'item_key' => 'template', + 'item_value' => '{"verify":{"id":"561282","content":"验证码:{1},{2} 分钟内有效,如非本人操作请忽略。"},"order":{"id":"561954","content":"下单成功,商品名称:{1},订单序号:{2},订单金额:¥{3}"},"refund":{"id":"561286","content":"退款成功,商品名称:{1},订单序号:{2},退款金额:¥{3}"},"live":{"id":"561288","content":"直播预告,课程名称:{1},章节名称:{2},开播时间:{3}"}}', + ], + [ + 'section' => 'cos', + 'item_key' => 'bucket', 'item_value' => '', ], [ - 'section' => 'storage', - 'item_key' => 'ci_protocol', + 'section' => 'cos', + 'item_key' => 'region', + 'item_value' => '', + ], + [ + 'section' => 'cos', + 'item_key' => 'protocol', 'item_value' => 'https', ], [ - 'section' => 'storage', - 'item_key' => 'bucket_name', + 'section' => 'cos', + 'item_key' => 'domain', 'item_value' => '', ], - [ - 'section' => 'storage', - 'item_key' => 'ci_domain', - 'item_value' => '', - ], - [ - 'section' => 'storage', - 'item_key' => 'bucket_region', - 'item_value' => '', - ], - [ - 'section' => 'storage', - 'item_key' => 'bucket_protocol', - 'item_value' => 'https', - ], - [ - 'section' => 'storage', - 'item_key' => 'bucket_domain', - 'item_value' => '', - ], - [ - 'section' => 'vod', - 'item_key' => 'dist_protocol', - 'item_value' => 'https', - ], - [ - 'section' => 'vod', - 'item_key' => 'watermark_enabled', - 'item_value' => '1', - ], - [ - 'section' => 'vod', - 'item_key' => 'watermark_template', - 'item_value' => '462027', - ], - [ - 'section' => 'vod', - 'item_key' => 'audio_format', - 'item_value' => 'mp3', - ], - [ - 'section' => 'vod', - 'item_key' => 'video_format', - 'item_value' => 'hls', - ], [ 'section' => 'vod', 'item_key' => 'storage_type', @@ -417,14 +382,39 @@ final class InsertSettingData extends AbstractMigration ], [ 'section' => 'vod', - 'item_key' => 'key_anti_ip_limit', - 'item_value' => '', + 'item_key' => 'audio_format', + 'item_value' => 'mp3', + ], + [ + 'section' => 'vod', + 'item_key' => 'video_format', + 'item_value' => 'hls', + ], + [ + 'section' => 'vod', + 'item_key' => 'watermark_enabled', + 'item_value' => '1', + ], + [ + 'section' => 'vod', + 'item_key' => 'watermark_template', + 'item_value' => '462027', + ], + [ + 'section' => 'vod', + 'item_key' => 'dist_protocol', + 'item_value' => 'https', ], [ 'section' => 'vod', 'item_key' => 'dist_domain', 'item_value' => '', ], + [ + 'section' => 'vod', + 'item_key' => 'key_anti_enabled', + 'item_value' => '1', + ], [ 'section' => 'vod', 'item_key' => 'key_anti_key', @@ -437,8 +427,8 @@ final class InsertSettingData extends AbstractMigration ], [ 'section' => 'vod', - 'item_key' => 'key_anti_enabled', - 'item_value' => '1', + 'item_key' => 'key_anti_ip_limit', + 'item_value' => '', ], ];