1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-07-19 06:36:14 +08:00
koogua 1d2f1dd266 1.更改模块继承基类
2.升级layui到2.6.8
3.升级腾讯云播放器
4.点播增加外链支持
2021-06-12 12:34:40 +08:00

54 lines
1.3 KiB
PHP

<?php
namespace App\Validators;
use App\Exceptions\BadRequest as BadRequestException;
use App\Library\Validators\Common as CommonValidator;
class ChapterVod extends Validator
{
public function checkFileId($fileId)
{
$value = $this->filter->sanitize($fileId, ['trim', 'string']);
if (!CommonValidator::intNumber($value)) {
throw new BadRequestException('chapter_vod.invalid_file_id');
}
return $value;
}
public function checkDuration($duration)
{
$value = $value = $this->filter->sanitize($duration, ['trim', 'int']);
if ($value < 10 || $value > 10 * 3600) {
throw new BadRequestException('chapter_vod.invalid_duration');
}
return $value;
}
public function checkFileUrl($url)
{
$value = $this->filter->sanitize($url, ['trim', 'string']);
if (!CommonValidator::url($value)) {
throw new BadRequestException('chapter_vod.invalid_file_url');
}
$ext = strtolower(pathinfo($url, PATHINFO_EXTENSION));
/**
* 点播只支持mp4,m3u8格式
*/
if (!in_array($ext, ['mp4', 'm3u8'])) {
throw new BadRequestException('chapter_vod.invalid_file_ext');
}
return $value;
}
}