UnknownSec Bypass
403
:
/
mnt
/
lmsestudio-instance-vol002
/
lms_edf90346387e
/
app
/
Providers
/ [
drwxr-xr-x
]
Menu
Upload
Mass depes
Mass delete
Terminal
Info server
About
name :
CustomRulesServiceProvider.php
<?php namespace EstudioLMS\Providers; use EstudioLMS\Helpers\Helpers; use File; use GuzzleHttp\Client; use Illuminate\Support\ServiceProvider; use Illuminate\Contracts\Validation\Factory; use Illuminate\Translation\Translator; use Illuminate\Http\Request; use Respect\Validation\Validator as v; use Symfony\Component\HttpFoundation\File\UploadedFile; class CustomRulesServiceProvider extends ServiceProvider { /** * Bootstrap the application services. * * @return void */ public function boot() { $this->app->call([$this, 'registerValidatorExtensions']); } /** * Register the application services. * * @return void */ public function register() { // } /** * @param Factory $validator * @param Translator $translator * @param Request $request */ public function registerValidatorExtensions(Factory $validator, Translator $translator, Request $request) { $validator->extendImplicit( 'strong_pwd', function ($attribute, $value, $parameters) use ($request) { if (empty($value)) { return true; } /*$regex = '/^.*(?=.{8,})((?=.*[!@#$%^&*()\-_=+{};:,<.>]){1})(?=.*\d)((?=.*[a-z]){1})((?=.*[A-Z]){1}).*$/'; return preg_match($regex, $value);*/ return true; }, $translator->get('messages.lblStrongPwd') ); $validator->extendImplicit( 'xpto', function ($attribute, $value, $parameters) use ($request) { if ($request['name'] == $value) { return false; } else { return true; } }, 'A subcategoria não pode ser igual a mesma categoria' ); $validator->extendImplicit( 'cpf_cnpj', function ($attribute, $value, $parameters) { $value = preg_replace('/[^0-9]/', '', $value); if (strlen($value) === 14) { return v::cnpj()->validate($value); } elseif (strlen($value) === 11) { return v::cpf()->validate($value); } else { return false; } }, $translator->get('messages.lblCpfCnpj') ); $validator->extendImplicit( 'min_money', function ($attribute, $value, $parameters) { $money = floatval(str_replace(',', '.', str_replace('.', '', $value))); if ($money < 1) { return false; } return true; }, 'O valor não pode ser menor que 1.00' ); $validator->extendImplicit( 'min_subscription', function ($attribute, $value, $parameters) { $money = floatval(str_replace(',', '.', str_replace('.', '', $value))); if ($money < 10) { return false; } return true; }, 'O valor não pode ser menor que 10.00' ); $validator->extendImplicit( 'maximum', function ($attribute, $value, $parameters) { $money = floatval(str_replace(',', '.', str_replace('.', '', $value))); if ($money > 100) { return false; } return true; }, 'O valor não pode ser maior que 100' ); $validator->extendImplicit('greater_than', function ($attribute, $value, $parameters) { $other = $parameters[0]; return isset($other) and intval($value) > intval($other); }, $translator->get('messages.greaterThan') ); if ($request->has('uploaded_video')) { $fileName = $request->get('uploaded_video'); } else { $fileName = ''; } $validator->extendImplicit('file_exists', function ($attribute, $value, $parameters) use ($request) { $file = $request->get('file_name'); $fileName = $file . '.mp4'; return File::exists(public_path() . '/temp/' . $fileName); }, $translator->get('messages.file_exists', ['fillName' => $fileName]) ); $validator->extendImplicit('online_videos', function ($attribute, $value, $parameters) use ($request) { if (empty($value)) { return true; } $videoInfo = Helpers::videoInfo($value); if (isset($videoInfo['duration'])) { return true; } return false; }, $translator->get('messages.online_videos') ); $validator->extendImplicit( 'recaptcha', function ($attribute, $value, $parameters) { $client = new Client(); $response = $client->post( 'https://www.google.com/recaptcha/api/siteverify', [ 'form_params' => [ 'secret' => config('app.GOOGLE_RECAPTCHA_SECRET'), 'response' => $value ] ] ); $body = json_decode((string)$response->getBody()); return $body->success; }, $translator->get('messages.recaptcha') ); $validator->extendImplicit( 'ads_file', function($attribute, $value, $parameters) { if(is_null($value)) { return true; } if (!($value instanceof UploadedFile) || !$value->isValid()) { return false; } return strtolower($value->getClientOriginalName()) == 'ads.txt'; }, $translator->get('messages.ads_file') ); //png,bmp,gif,webp,avif,jpeg,jpg,svg,svgz $validator->extendImplicit( 'custom_images', function($attribute, $value, $parameters) { if($value instanceof UploadedFile) { $mimeType = $value->getMimeType(); $originalExtension = $value->getClientOriginalExtension(); $allowedMimeTypes = [ 'image/png', 'image/bmp', 'image/gif', 'image/webp', 'image/avif', 'image/jpeg', 'image/svg+xml', ]; if ($originalExtension === 'svg' && $mimeType === 'text/plain') { $mimeType = 'image/svg+xml'; } if ($originalExtension === 'avif' && $mimeType === 'application/octet-stream') { $mimeType = 'image/avif'; } return in_array($mimeType, $allowedMimeTypes); } else { return true; } }, 'Formato arquivo de imagem inválido! São permitidos apenas png,bmp,gif,webp,avif,jpeg,jpg,svg e svgz.' ); //zip,rar,tar,pdf,ppt,pptx,pps,ppsx,doc,docx,xls,xlsx,png,bmp,gif,webp,avif,jpeg,jpg,jpe,svg,svgz $validator->extendImplicit( 'custom_files', function($attribute, $value, $parameters) { $mimeType = $value->getMimeType(); $originalExtension = $value->getClientOriginalExtension(); $allowedMimeTypes = [ 'image/jpeg', 'image/png', 'image/bmp', 'image/gif', 'image/webp', 'image/avif', 'image/svg+xml', 'application/zip', 'application/vnd.rar', 'application/x-tar', 'application/pdf', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-exce', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/x-gzip' ]; if ($originalExtension === 'svg' && $mimeType === 'text/plain') { $mimeType = 'image/svg+xml'; } if ($originalExtension === 'avif' && $mimeType === 'application/octet-stream') { $mimeType = 'image/avif'; } return in_array($mimeType, $allowedMimeTypes); }, 'Formato arquivo de imagem inválido! São permitidos apenas zip,rar,tar,pdf,ppt,pptx,pps,ppsx,doc,docx,xls,xlsx,png,bmp,gif,webp,avif,jpeg,jpg,jpe,svg e svgz.' ); //png,bmp,gif,webp,jpeg,jpg $validator->extendImplicit( 'few_images', function($attribute, $value, $parameters) { if($value instanceof UploadedFile) { $mimeType = $value->getMimeType(); $originalExtension = $value->getClientOriginalExtension(); $allowedMimeTypes = [ 'image/png', 'image/bmp', 'image/gif', 'image/webp', 'image/jpeg', ]; return in_array($mimeType, $allowedMimeTypes); } else { return true; } }, 'Formato arquivo de imagem inválido! São permitidos apenas png,bmp,gif,webp,jpeg e jpg.' ); } }
Copyright © 2026 - UnknownSec