1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-22 03:32:47 +08:00

demo分支过滤敏感数据以及限制提交

This commit is contained in:
xiaochong0302 2020-09-04 17:33:16 +08:00
parent 4c8d02fcf2
commit aab8d7a8f2
16 changed files with 202 additions and 124 deletions

View File

@ -21,6 +21,17 @@ class Controller extends \Phalcon\Mvc\Controller
public function beforeExecuteRoute(Dispatcher $dispatcher) public function beforeExecuteRoute(Dispatcher $dispatcher)
{ {
/**
* demo分支拒绝数据提交
*/
if ($this->isNotSafeRequest()) {
$dispatcher->forward([
'controller' => 'public',
'action' => 'forbidden',
]);
return false;
}
if ($this->isNotSafeRequest()) { if ($this->isNotSafeRequest()) {
$this->checkHttpReferer(); $this->checkHttpReferer();
$this->checkCsrfToken(); $this->checkCsrfToken();

View File

@ -17,6 +17,8 @@ class PublicController extends \Phalcon\Mvc\Controller
*/ */
public function authAction() public function authAction()
{ {
$this->response->setStatusCode(401);
if ($this->request->isAjax()) { if ($this->request->isAjax()) {
return $this->jsonError(['msg' => '会话已过期,请重新登录']); return $this->jsonError(['msg' => '会话已过期,请重新登录']);
} }
@ -29,6 +31,8 @@ class PublicController extends \Phalcon\Mvc\Controller
*/ */
public function forbiddenAction() public function forbiddenAction()
{ {
$this->response->setStatusCode(403);
if ($this->request->isAjax()) { if ($this->request->isAjax()) {
return $this->jsonError(['msg' => '无相关操作权限']); return $this->jsonError(['msg' => '无相关操作权限']);
} }

View File

@ -31,7 +31,7 @@ class SettingController extends Controller
$site = $settingService->getSectionSettings($section); $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); $this->view->setVar('site', $site);
} }
@ -117,12 +117,12 @@ class SettingController extends Controller
*/ */
public function liveAction() public function liveAction()
{ {
$section = 'live';
$settingService = new SettingService(); $settingService = new SettingService();
if ($this->request->isPost()) { if ($this->request->isPost()) {
$section = $this->request->getPost('section');
$data = $this->request->getPost(); $data = $this->request->getPost();
$settingService->updateLiveSettings($section, $data); $settingService->updateLiveSettings($section, $data);
@ -131,9 +131,13 @@ class SettingController extends Controller
} else { } 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 { } else {
$alipay = $settingService->getSectionSettings('pay.alipay'); $alipay = $settingService->getAlipaySettings();
$wxpay = $settingService->getWxpaySettings();
$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']);
$this->view->setVar('alipay', $alipay); $this->view->setVar('alipay', $alipay);
$this->view->setVar('wxpay', $wxpay); $this->view->setVar('wxpay', $wxpay);
@ -190,10 +189,7 @@ class SettingController extends Controller
$smser = $settingService->getSectionSettings($section); $smser = $settingService->getSectionSettings($section);
$template = json_decode($smser->template);
$this->view->setVar('smser', $smser); $this->view->setVar('smser', $smser);
$this->view->setVar('template', $template);
} }
} }

View File

@ -118,7 +118,6 @@ class Chapter extends Service
$logger = $this->getLogger(); $logger = $this->getLogger();
$logger->error('Create Chapter Error ' . kg_json_encode([ $logger->error('Create Chapter Error ' . kg_json_encode([
'line' => $e->getLine(),
'code' => $e->getCode(), 'code' => $e->getCode(),
'message' => $e->getMessage(), 'message' => $e->getMessage(),
])); ]));

View File

@ -113,7 +113,6 @@ class Course extends Service
$logger = $this->getLogger(); $logger = $this->getLogger();
$logger->error('Create Course Error ' . kg_json_encode([ $logger->error('Create Course Error ' . kg_json_encode([
'line' => $e->getLine(),
'code' => $e->getCode(), 'code' => $e->getCode(),
'message' => $e->getMessage(), 'message' => $e->getMessage(),
])); ]));

View File

@ -9,17 +9,64 @@ use App\Repos\Vip as VipRepo;
class Setting extends Service 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) public function getSectionSettings($section)
{ {
$settingsRepo = new SettingRepo(); $settingsRepo = new SettingRepo();
$items = $settingsRepo->findBySection($section); $items = $settingsRepo->findBySection($section);
$result = new \stdClass(); $result = [];
/**
* demo分支过滤敏感数据
*/
if ($items->count() > 0) { if ($items->count() > 0) {
foreach ($items as $item) { 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) public function updateSmserSettings($section, $settings)
{ {
$template = $settings['template']; $template = $settings['template'];
$keys = array_keys($template['id']); $keys = array_keys($template['id']);
$myTemplate = []; $myTemplate = [];
foreach ($keys as $key) { foreach ($keys as $key) {
@ -96,13 +145,6 @@ class Setting extends Service
$this->updateSectionSettings($section, $settings); $this->updateSectionSettings($section, $settings);
} }
public function getVipSettings()
{
$vipRepo = new VipRepo();
return $vipRepo->findAll(['deleted' => 0]);
}
public function updateVipSettings($items) public function updateVipSettings($items)
{ {
$vipRepo = new VipRepo(); $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;
}
} }

View File

@ -21,11 +21,11 @@
</div> </div>
</div> </div>
{% if course.model == '1' %} {% if course.model == 1 %}
{{ partial('chapter/lessons_vod') }} {{ partial('chapter/lessons_vod') }}
{% elseif course.model == '2' %} {% elseif course.model == 2 %}
{{ partial('chapter/lessons_live') }} {{ partial('chapter/lessons_live') }}
{% elseif course.model == '3' %} {% elseif course.model == 3 %}
{{ partial('chapter/lessons_read') }} {{ partial('chapter/lessons_read') }}
{% endif %} {% endif %}

View File

@ -7,9 +7,13 @@
{% endif %} {% endif %}
{%- endmacro %} {%- endmacro %}
{%- macro live_status_info(attrs) %} {%- macro live_status_info(status) %}
{% if attrs['stream']['status'] != 'active' %} {% if status == 'active' %}
<span class="layui-badge layui-bg-blue">直播中</span> <span class="layui-badge layui-bg-blue">活跃</span>
{% elseif status == 'inactive' %}
<span class="layui-badge layui-bg-gray">沉默</span>
{% elseif status == 'forbid' %}
<span class="layui-badge layui-bg-red">禁播</span>
{% endif %} {% endif %}
{%- endmacro %} {%- endmacro %}
@ -21,13 +25,15 @@
<col> <col>
<col> <col>
<col> <col>
<col>
<col width="12%"> <col width="12%">
</colgroup> </colgroup>
<thead> <thead>
<tr> <tr>
<th>编号</th> <th>编号</th>
<th>名称</th> <th>名称</th>
<th>时间</th> <th>直播时间</th>
<th>推流状态</th>
<th>排序</th> <th>排序</th>
<th>免费</th> <th>免费</th>
<th>发布</th> <th>发布</th>
@ -46,9 +52,9 @@
<td> <td>
<span><a href="{{ edit_url }}">{{ item.title }}</a></span> <span><a href="{{ edit_url }}">{{ item.title }}</a></span>
<span class="layui-badge layui-bg-green">课</span> <span class="layui-badge layui-bg-green">课</span>
{{ live_status_info(item.attrs) }}
</td> </td>
<td>{{ live_time_info(item.attrs) }}</td> <td>{{ live_time_info(item.attrs) }}</td>
<td>{{ live_status_info(item.attrs['stream']['status']) }}</td>
<td><input class="layui-input kg-priority" type="text" name="priority" title="数值越小排序越靠前" value="{{ item.priority }}" data-url="{{ update_url }}"></td> <td><input class="layui-input kg-priority" type="text" name="priority" title="数值越小排序越靠前" value="{{ item.priority }}" data-url="{{ update_url }}"></td>
<td><input type="checkbox" name="free" value="1" lay-skin="switch" lay-text="是|否" lay-filter="free" data-url="{{ update_url }}" {% if item.free == 1 %}checked{% endif %}></td> <td><input type="checkbox" name="free" value="1" lay-skin="switch" lay-text="是|否" lay-filter="free" data-url="{{ update_url }}" {% if item.free == 1 %}checked{% endif %}></td>
<td><input type="checkbox" name="published" value="1" lay-skin="switch" lay-text="是|否" lay-filter="published" data-url="{{ update_url }}" {% if item.published == 1 %}checked{% endif %}></td> <td><input type="checkbox" name="published" value="1" lay-skin="switch" lay-text="是|否" lay-filter="published" data-url="{{ update_url }}" {% if item.published == 1 %}checked{% endif %}></td>

View File

@ -27,8 +27,8 @@
<tr> <tr>
<th>编号</th> <th>编号</th>
<th>名称</th> <th>名称</th>
<th>视频状态</th> <th>状态</th>
<th>视频时长</th> <th>时长</th>
<th>排序</th> <th>排序</th>
<th>免费</th> <th>免费</th>
<th>发布</th> <th>发布</th>
@ -37,7 +37,7 @@
</thead> </thead>
<tbody> <tbody>
{% for item in lessons %} {% for item in lessons %}
{% set show_url = url({'for':'desktop.chapter.show','id':item.id}) %} {% set preview_url = url({'for':'desktop.chapter.show','id':item.id}) %}
{% set edit_url = url({'for':'admin.chapter.edit','id':item.id}) %} {% set edit_url = url({'for':'admin.chapter.edit','id':item.id}) %}
{% set update_url = url({'for':'admin.chapter.update','id':item.id}) %} {% set update_url = url({'for':'admin.chapter.update','id':item.id}) %}
{% set delete_url = url({'for':'admin.chapter.delete','id':item.id}) %} {% set delete_url = url({'for':'admin.chapter.delete','id':item.id}) %}

View File

@ -2,37 +2,37 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">回调密钥</label> <label class="layui-form-label">回调密钥</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="notify_auth_key" value="{{ live.notify_auth_key }}"> <input class="layui-input" type="text" name="auth_key" value="{{ notify.auth_key }}">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">推流回调</label> <label class="layui-form-label">推流回调</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="notify_stream_begin_url" value="{{ live.notify_stream_begin_url }}" layui-verify="required"> <input class="layui-input" type="text" name="stream_begin_url" value="{{ notify.stream_begin_url }}" layui-verify="required">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">断流回调</label> <label class="layui-form-label">断流回调</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="notify_stream_end_url" value="{{ live.notify_stream_end_url }}" layui-verify="required"> <input class="layui-input" type="text" name="stream_end_url" value="{{ notify.stream_end_url }}" layui-verify="required">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">录制回调</label> <label class="layui-form-label">录制回调</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="notify_record_url" value="{{ live.notify_record_url }}" layui-verify="required"> <input class="layui-input" type="text" name="record_url" value="{{ notify.record_url }}" layui-verify="required">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">截图回调</label> <label class="layui-form-label">截图回调</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="notify_snapshot_url" value="{{ live.notify_snapshot_url }}" layui-verify="required"> <input class="layui-input" type="text" name="snapshot_url" value="{{ notify.snapshot_url }}" layui-verify="required">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">鉴黄回调</label> <label class="layui-form-label">鉴黄回调</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="notify_porn_url" value="{{ live.notify_porn_url }}" layui-verify="required"> <input class="layui-input" type="text" name="porn_url" value="{{ notify.porn_url }}" layui-verify="required">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
@ -40,6 +40,7 @@
<div class="layui-input-block"> <div class="layui-input-block">
<button class="layui-btn" lay-submit="true" lay-filter="go">提交</button> <button class="layui-btn" lay-submit="true" lay-filter="go">提交</button>
<button type="button" class="kg-back layui-btn layui-btn-primary">返回</button> <button type="button" class="kg-back layui-btn layui-btn-primary">返回</button>
<input type="hidden" name="section" value="notify">
</div> </div>
</div> </div>
</form> </form>

View File

@ -1,5 +1,5 @@
{% set pull_auth_display = live.pull_auth_enabled == 0 ? 'style="display:none;"' : '' %} {% set auth_display = pull.auth_enabled == 0 ? 'style="display:none;"' : '' %}
{% set ppt_display = live.pull_trans_enabled == 0 ? 'style="display:none;"' : '' %} {% set ppt_display = pull.trans_enabled == 0 ? 'style="display:none;"' : '' %}
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.live'}) }}"> <form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.live'}) }}">
<fieldset class="layui-elem-field layui-field-title"> <fieldset class="layui-elem-field layui-field-title">
@ -8,14 +8,14 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">拉流协议</label> <label class="layui-form-label">拉流协议</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input type="radio" name="pull_protocol" value="http" title="HTTP" {% if live.pull_protocol == "http" %}checked{% endif %}> <input type="radio" name="protocol" value="http" title="HTTP" {% if pull.protocol == "http" %}checked{% endif %}>
<input type="radio" name="pull_protocol" value="https" title="HTTPS" {% if live.pull_protocol == "https" %}checked{% endif %}> <input type="radio" name="protocol" value="https" title="HTTPS" {% if pull.protocol == "https" %}checked{% endif %}>
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">拉流域名</label> <label class="layui-form-label">拉流域名</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="pull_domain" value="{{ live.pull_domain }}" layui-verify="required"> <input class="layui-input" type="text" name="domain" value="{{ pull.domain }}" layui-verify="required">
</div> </div>
</div> </div>
<fieldset class="layui-elem-field layui-field-title"> <fieldset class="layui-elem-field layui-field-title">
@ -24,21 +24,21 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">开启鉴权</label> <label class="layui-form-label">开启鉴权</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input type="radio" name="pull_auth_enabled" value="1" title="是" lay-filter="pull_auth_enabled" {% if live.pull_auth_enabled == 1 %}checked{% endif %}> <input type="radio" name="auth_enabled" value="1" title="是" lay-filter="pull_auth_enabled" {% if pull.auth_enabled == 1 %}checked{% endif %}>
<input type="radio" name="pull_auth_enabled" value="0" title="否" lay-filter="pull_auth_enabled" {% if live.pull_auth_enabled == 0 %}checked{% endif %}> <input type="radio" name="auth_enabled" value="0" title="否" lay-filter="pull_auth_enabled" {% if pull.auth_enabled == 0 %}checked{% endif %}>
</div> </div>
</div> </div>
<div id="pull-auth-block" {{ pull_auth_display }}> <div id="pull-auth-block" {{ auth_display }}>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">鉴权密钥</label> <label class="layui-form-label">鉴权密钥</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="pull_auth_key" value="{{ live.pull_auth_key }}"> <input class="layui-input" type="text" name="auth_key" value="{{ pull.auth_key }}">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">有效时间(秒)</label> <label class="layui-form-label">有效时间(秒)</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="pull_auth_delta" value="{{ live.pull_auth_delta }}"> <input class="layui-input" type="text" name="auth_delta" value="{{ pull.auth_delta }}">
</div> </div>
</div> </div>
</div> </div>
@ -48,8 +48,8 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">开启转码</label> <label class="layui-form-label">开启转码</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input type="radio" name="pull_trans_enabled" value="1" title="是" lay-filter="pull_trans_enabled" {% if live.pull_trans_enabled == 1 %}checked{% endif %}> <input type="radio" name="trans_enabled" value="1" title="是" lay-filter="pull_trans_enabled" {% if pull.trans_enabled == 1 %}checked{% endif %}>
<input type="radio" name="pull_trans_enabled" value="0" title="否" lay-filter="pull_trans_enabled" {% if live.pull_trans_enabled == 0 %}checked{% endif %}> <input type="radio" name="trans_enabled" value="0" title="否" lay-filter="pull_trans_enabled" {% if pull.trans_enabled == 0 %}checked{% endif %}>
</div> </div>
</div> </div>
<div id="ptt-block" {{ ppt_display }}> <div id="ptt-block" {{ ppt_display }}>
@ -96,6 +96,7 @@
<div class="layui-input-block"> <div class="layui-input-block">
<button class="layui-btn" lay-submit="true" lay-filter="go">提交</button> <button class="layui-btn" lay-submit="true" lay-filter="go">提交</button>
<button type="button" class="kg-back layui-btn layui-btn-primary">返回</button> <button type="button" class="kg-back layui-btn layui-btn-primary">返回</button>
<input type="hidden" name="section" value="pull">
</div> </div>
</div> </div>
</form> </form>

View File

@ -1,4 +1,4 @@
{% set push_auth_display = live.push_auth_enabled == 0 ? 'style="display:none;"' : '' %} {% set auth_display = push.auth_enabled == 0 ? 'style="display:none;"' : '' %}
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.live'}) }}"> <form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.live'}) }}">
<fieldset class="layui-elem-field layui-field-title"> <fieldset class="layui-elem-field layui-field-title">
@ -7,7 +7,7 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">推流域名</label> <label class="layui-form-label">推流域名</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="push_domain" value="{{ live.push_domain }}" layui-verify="required"> <input class="layui-input" type="text" name="domain" value="{{ push.domain }}" layui-verify="required">
</div> </div>
</div> </div>
<fieldset class="layui-elem-field layui-field-title"> <fieldset class="layui-elem-field layui-field-title">
@ -16,21 +16,21 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">开启鉴权</label> <label class="layui-form-label">开启鉴权</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input type="radio" name="push_auth_enabled" value="1" title="是" lay-filter="push_auth_enabled" {% if live.push_auth_enabled == 1 %}checked{% endif %}> <input type="radio" name="auth_enabled" value="1" title="是" lay-filter="auth_enabled" {% if push.auth_enabled == 1 %}checked{% endif %}>
<input type="radio" name="push_auth_enabled" value="0" title="否" lay-filter="push_auth_enabled" {% if live.push_auth_enabled == 0 %}checked{% endif %}> <input type="radio" name="auth_enabled" value="0" title="否" lay-filter="auth_enabled" {% if push.auth_enabled == 0 %}checked{% endif %}>
</div> </div>
</div> </div>
<div id="push-auth-block" {{ push_auth_display }}> <div id="push-auth-block" {{ auth_display }}>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">鉴权密钥</label> <label class="layui-form-label">鉴权密钥</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="push_auth_key" value="{{ live.push_auth_key }}"> <input class="layui-input" type="text" name="auth_key" value="{{ push.auth_key }}">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">有效时间(秒)</label> <label class="layui-form-label">有效时间(秒)</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="push_auth_delta" value="{{ live.push_auth_delta }}"> <input class="layui-input" type="text" name="auth_delta" value="{{ push.auth_delta }}">
</div> </div>
</div> </div>
</div> </div>
@ -39,6 +39,7 @@
<div class="layui-input-block"> <div class="layui-input-block">
<button class="layui-btn" lay-submit="true" lay-filter="go">提交</button> <button class="layui-btn" lay-submit="true" lay-filter="go">提交</button>
<button type="button" class="kg-back layui-btn layui-btn-primary">返回</button> <button type="button" class="kg-back layui-btn layui-btn-primary">返回</button>
<input type="hidden" name="section" value="push">
</div> </div>
</div> </div>
</form> </form>

View File

@ -2,6 +2,8 @@
{% block content %} {% block content %}
{% set template = smser.template|json_decode %}
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.smser'}) }}"> <form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.smser'}) }}">
<fieldset class="layui-elem-field layui-field-title"> <fieldset class="layui-elem-field layui-field-title">
<legend>基础配置</legend> <legend>基础配置</legend>

View File

@ -34,7 +34,9 @@ class Live extends Service
public function __construct() public function __construct()
{ {
$this->settings = $this->getSectionSettings('live'); $this->settings['push'] = $this->getSectionSettings('live.push');
$this->settings['pull'] = $this->getSectionSettings('live.pull');
$this->settings['notify'] = $this->getSectionSettings('live.notify');
$this->logger = $this->getLogger('live'); $this->logger = $this->getLogger('live');
@ -55,7 +57,7 @@ class Live extends Service
$request = new DescribeLiveStreamStateRequest(); $request = new DescribeLiveStreamStateRequest();
$params = json_encode([ $params = json_encode([
'DomainName' => $this->settings['push_domain'], 'DomainName' => $this->settings['push']['domain'],
'AppName' => $appName ?: 'live', 'AppName' => $appName ?: 'live',
'StreamName' => $streamName, 'StreamName' => $streamName,
]); ]);
@ -73,7 +75,6 @@ class Live extends Service
} catch (TencentCloudSDKException $e) { } catch (TencentCloudSDKException $e) {
$this->logger->error('Describe Live Stream State Exception ' . kg_json_encode([ $this->logger->error('Describe Live Stream State Exception ' . kg_json_encode([
'line' => $e->getLine(),
'code' => $e->getErrorCode(), 'code' => $e->getErrorCode(),
'message' => $e->getMessage(), 'message' => $e->getMessage(),
'requestId' => $e->getRequestId(), 'requestId' => $e->getRequestId(),
@ -100,7 +101,7 @@ class Live extends Service
$request = new ForbidLiveStreamRequest(); $request = new ForbidLiveStreamRequest();
$params = json_encode([ $params = json_encode([
'DomainName' => $this->settings['push_domain'], 'DomainName' => $this->settings['push']['domain'],
'AppName' => $appName ?: 'live', 'AppName' => $appName ?: 'live',
'StreamName' => $streamName, 'StreamName' => $streamName,
'Reason' => $reason, 'Reason' => $reason,
@ -119,7 +120,6 @@ class Live extends Service
} catch (TencentCloudSDKException $e) { } catch (TencentCloudSDKException $e) {
$this->logger->error('Forbid Live Stream Exception ' . kg_json_encode([ $this->logger->error('Forbid Live Stream Exception ' . kg_json_encode([
'line' => $e->getLine(),
'code' => $e->getErrorCode(), 'code' => $e->getErrorCode(),
'message' => $e->getMessage(), 'message' => $e->getMessage(),
'requestId' => $e->getRequestId(), 'requestId' => $e->getRequestId(),
@ -145,7 +145,7 @@ class Live extends Service
$request = new ResumeLiveStreamRequest(); $request = new ResumeLiveStreamRequest();
$params = json_encode([ $params = json_encode([
'DomainName' => $this->settings['push_domain'], 'DomainName' => $this->settings['push']['domain'],
'AppName' => $appName ?: 'live', 'AppName' => $appName ?: 'live',
'StreamName' => $streamName, 'StreamName' => $streamName,
]); ]);
@ -163,7 +163,6 @@ class Live extends Service
} catch (TencentCloudSDKException $e) { } catch (TencentCloudSDKException $e) {
$this->logger->error('Resume Live Stream Exception ' . kg_json_encode([ $this->logger->error('Resume Live Stream Exception ' . kg_json_encode([
'line' => $e->getLine(),
'code' => $e->getErrorCode(), 'code' => $e->getErrorCode(),
'message' => $e->getMessage(), 'message' => $e->getMessage(),
'requestId' => $e->getRequestId(), 'requestId' => $e->getRequestId(),
@ -186,10 +185,10 @@ class Live extends Service
{ {
$appName = $appName ?: 'live'; $appName = $appName ?: 'live';
$authEnabled = $this->settings['push_auth_enabled']; $authEnabled = $this->settings['push']['auth_enabled'];
$authKey = $this->settings['push_auth_key']; $authKey = $this->settings['push']['auth_key'];
$expireTime = $this->settings['push_auth_delta'] + time(); $expireTime = $this->settings['push']['auth_delta'] + time();
$domain = $this->settings['push_domain']; $domain = $this->settings['push']['domain'];
$authParams = $this->getAuthParams($streamName, $authKey, $expireTime); $authParams = $this->getAuthParams($streamName, $authKey, $expireTime);
@ -210,12 +209,12 @@ class Live extends Service
{ {
$appName = $appName ?: 'live'; $appName = $appName ?: 'live';
$protocol = $this->settings['pull_protocol']; $protocol = $this->settings['pull']['protocol'];
$domain = $this->settings['pull_domain']; $domain = $this->settings['pull']['domain'];
$authEnabled = $this->settings['pull_auth_enabled']; $authEnabled = $this->settings['pull']['auth_enabled'];
$transEnabled = $this->settings['pull_trans_enabled']; $transEnabled = $this->settings['pull']['trans_enabled'];
$authKey = $this->settings['pull_auth_key']; $authKey = $this->settings['pull']['auth_key'];
$expireTime = $this->settings['pull_auth_delta'] + time(); $expireTime = $this->settings['pull']['auth_delta'] + time();
$formats = ['rtmp', 'flv', 'm3u8']; $formats = ['rtmp', 'flv', 'm3u8'];

View File

@ -136,11 +136,11 @@ class LiveNotify extends Service
$redis = $cache->getRedis(); $redis = $cache->getRedis();
$keyName = $this->getNotifyKeyName(); $key = $this->getNotifyKey();
$redis->sAdd($keyName, $chapter->id); $redis->sAdd($key, $chapter->id);
$redis->expire($keyName, 86400); $redis->expire($key, 86400);
} }
protected function getChapter($streamId) protected function getChapter($streamId)
@ -176,9 +176,9 @@ class LiveNotify extends Service
return false; return false;
} }
$live = $this->getSectionSettings('live'); $live = $this->getSectionSettings('live.notify');
$mySign = md5($live['notify_auth_key'] . $time); $mySign = md5($live['auth_key'] . $time);
return $sign == $mySign; return $sign == $mySign;
} }

View File

@ -76,53 +76,83 @@ final class InsertSettingData extends AbstractMigration
'item_value' => '0', 'item_value' => '0',
], ],
[ [
'section' => 'live', 'section' => 'live.push',
'item_key' => 'push_domain', 'item_key' => 'domain',
'item_value' => 'push.abc.com', 'item_value' => '',
], ],
[ [
'section' => 'live', 'section' => 'live.push',
'item_key' => 'pull_trans_enabled',
'item_value' => '1',
],
[
'section' => 'live',
'item_key' => 'pull_auth_enabled',
'item_value' => '1',
],
[
'section' => 'live',
'item_key' => 'push_auth_enabled', 'item_key' => 'push_auth_enabled',
'item_value' => '1', 'item_value' => '1',
], ],
[ [
'section' => 'live', 'section' => 'live.push',
'item_key' => 'pull_protocol', 'item_key' => 'push_auth_key',
'item_value' => 'http', 'item_value' => '',
], ],
[ [
'section' => 'live', 'section' => 'live.push',
'item_key' => 'push_auth_delta', 'item_key' => 'push_auth_delta',
'item_value' => '18000', 'item_value' => '18000',
], ],
[ [
'section' => 'live', 'section' => 'live.pull',
'item_key' => 'pull_auth_delta', 'item_key' => 'pull_protocol',
'item_value' => '18000', 'item_value' => 'http',
], ],
[ [
'section' => 'live', 'section' => 'live.pull',
'item_key' => 'pull_domain',
'item_value' => '',
],
[
'section' => 'live.pull',
'item_key' => 'pull_trans_enabled',
'item_value' => '0',
],
[
'section' => 'live.pull',
'item_key' => 'pull_auth_enabled',
'item_value' => '1',
],
[
'section' => 'live.pull',
'item_key' => 'pull_auth_key', 'item_key' => 'pull_auth_key',
'item_value' => '', 'item_value' => '',
], ],
[ [
'section' => 'live', 'section' => 'live.pull',
'item_key' => 'pull_domain', 'item_key' => 'pull_auth_delta',
'item_value' => 'play.abc.com', 'item_value' => '18000',
], ],
[ [
'section' => 'live', 'section' => 'live.notify',
'item_key' => 'push_auth_key', 'item_key' => 'pull_auth_key',
'item_value' => '',
],
[
'section' => 'live.notify',
'item_key' => 'stream_begin_url',
'item_value' => '',
],
[
'section' => 'live.notify',
'item_key' => 'stream_end_url',
'item_value' => '',
],
[
'section' => 'live.notify',
'item_key' => 'record_url',
'item_value' => '',
],
[
'section' => 'live.notify',
'item_key' => 'snapshot_url',
'item_value' => '',
],
[
'section' => 'live.notify',
'item_key' => 'porn_url',
'item_value' => '', 'item_value' => '',
], ],
[ [