漏洞修复

master
lion 7 hours ago
parent e35706047b
commit 243b92c834

@ -8,6 +8,7 @@ use App\Models\User;
use App\Repositories\MeetRepository;
use App\Repositories\YuanheRepository;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
class PushCourses extends Command
@ -58,10 +59,21 @@ class PushCourses extends Command
foreach ($courses as $course) {
// 所有报名审核成功的用户id
$userIds = $course->courseSigns()->where('status', 1)->pluck('user_id');
$users = User::whereIn('id', $userIds)->whereHas('company', function ($query) {
$query->whereNotNull('credit_code');
})->groupBy('company_id')->get();
$users = User::whereIn('id', $userIds)->has('company')->with('company')->groupBy('company_id')->get();
foreach ($users as $user) {
$company = $user->company;
if (trim((string) $company->credit_code) === '') {
$reason = '统一社会信用代码为空';
$this->warn("推送跳过:{$course->name}-{$company->company_name}-{$reason}");
Log::warning('元禾课程推送跳过', [
'course_id' => $course->id,
'course_name' => $course->name,
'company_id' => $company->id,
'company_name' => $company->company_name,
'reason' => $reason,
]);
continue;
}
$result = $YuanheRepository->pushCourses($course, $user, $out);
if ($result) {
$user->is_push = 1;

@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin;
use App\Helpers\ResponseCode;
use App\Models\Upload;
use Illuminate\Http\Request;
use Illuminate\Http\UploadedFile;
class UploadController extends CommonController
{
@ -26,13 +27,19 @@ class UploadController extends CommonController
public function uploadFile(Request $request)
{
$file = $request->file('file');
if (!$file instanceof UploadedFile || !$file->isValid()) {
return $this->fail([ResponseCode::ERROR_BUSINESS, '请选择有效文件']);
}
//获取文件大小,单位B
$fileSize = floor($file->getSize());
if ($fileSize >= 50 * 1024 *1024) {
return $this->fail([ResponseCode::ERROR_BUSINESS, '文件必须小于10M']);
}
//过滤文件后缀
$ext = $file->getClientOriginalExtension();
$ext = strtolower($file->getClientOriginalExtension());
if ($ext === 'pdf' && $file->getMimeType() !== 'application/pdf') {
return $this->fail([ResponseCode::ERROR_BUSINESS, '文件内容不是 PDF']);
}
if (in_array($ext, ['zip','rar','ppt','pptx','xls','xlsx','doc','docx','png','gif','jpg','jpeg','pdf','mp4'])) {
// 保存目录
$dir = 'files';

@ -41,6 +41,9 @@ class UploadController extends CommonController
if (!is_string($originalName) || trim($originalName) === '') $originalName = $file->getClientOriginalName();
//过滤文件后缀
$ext = strtolower($file->getClientOriginalExtension());
if ($ext === 'pdf' && $file->getMimeType() !== 'application/pdf') {
return $this->fail([ResponseCode::ERROR_BUSINESS, '文件内容不是 PDF']);
}
if ($request->filled('survey_question_id')) {
$question = \App\Models\CourseContentEvaluationAsk::find($request->input('survey_question_id'));
if (!$question || $question->edit_input !== 'file') return $this->fail([ResponseCode::ERROR_BUSINESS, '上传题目不存在']);

@ -186,11 +186,14 @@ class YuanheRepository
return false;
}
$params = [
'classTeacher' => $course->teacher->name??'',
'classTeacher' => $course->teacher_detail->pluck('name')
->map(fn ($name) => trim((string) $name))
->filter(fn ($name) => $name !== '')
->implode('、'),
'courseName' => $course->name,
'description' => $user->company->businessScope??'',
'enterpriseName' => $user->company->company_name,
'creditCode' => $user->company->credit_code,
'creditCode' => trim((string) $user->company->credit_code),
'groupId' => '1030004',
'openTime' => $course->start_date
];

@ -0,0 +1,13 @@
# Load in the wx.sstbc.com server block before other matching regex locations.
location = /storage/files/17939373196aed4fa7e9f94.pdf {
return 404;
}
location ~* ^/storage/files/[^/]+\.pdf$ {
try_files $uri =404;
types {}
default_type application/octet-stream;
add_header Content-Disposition "attachment" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Content-Security-Policy "sandbox" always;
}
Loading…
Cancel
Save