UnknownSec Bypass
403
:
/
mnt
/
lmsestudio-instance-vol002
/
lms_d6ed84231c36
/
app
/
Helpers
/ [
drwxr-xr-x
]
Menu
Upload
Mass depes
Mass delete
Terminal
Info server
About
name :
Helpers.php
<?php namespace EstudioLMS\Helpers; use DateInterval; /** * Class Helpers * @package EstudioLMS\Helpers */ class Helpers { /** * @param $data * @return string */ public static function logDataChanged($data) { $changes = []; $log = ''; foreach ($data->getDirty() as $key => $value) { $original = $data->getOriginal($key); $changes[$key] = [ 'old' => $original, 'new' => $value, ]; } if (isset($changes)) { if (count($changes) > 0) { $log = ''; foreach ($changes as $key => $change) { $log .= $key . ' Changed from: ' . $change['old'] . ' to: ' . $change['new'] . PHP_EOL; } } } return $log; } /** * @param $string * @return mixed */ public static function keepNumericOnly($string) { return preg_replace("/[^0-9,.]/", "", $string); } /** * @param $url * @return mixed */ public static function videoInfo($url) { if (strpos($url, 'youtube.com')) { $url = parse_url($url); if (!isset($url['query'])) { return []; } parse_str($url['query'], $output); $videoId = $output['v']; return self::youtubeVideoInfo($videoId); } elseif (strpos($url, 'youtu.be')) { $videoId = explode('youtu.be/', $url); $videoId = $videoId[1]; return self::youtubeVideoInfo($videoId); } elseif (strpos($url, 'vimeo.com')) { $videoId = explode('vimeo.com/', $url); $videoId = $videoId[1]; return self::vimeoVideoInfo($videoId); } else { return []; } } private static function youtubeVideoInfo($videoId) { try { $api_key = 'AIzaSyDSg74gqy2oAvM3HNEogHlJFGcmqWbXGA4'; $vinfo['video_type'] = 'youtube'; $vinfo['video_id'] = $videoId; $xml = file_get_contents( "https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id=$videoId&key=$api_key" ); $result = json_decode($xml, true); if (empty($result['items'][0]['contentDetails'])) { return null; } $vinfo = $result['items'][0]['contentDetails']; $interval = new DateInterval($vinfo['duration']); $vinfo['duration'] = $interval->h * 3600 + $interval->i * 60 + $interval->s; $thumbnail_base = 'https://i.ytimg.com/vi/'; $vinfo['thumbnail']['default'] = $thumbnail_base . $videoId . '/default.jpg'; $vinfo['thumbnail']['mqDefault'] = $thumbnail_base . $videoId . '/mqdefault.jpg'; $vinfo['thumbnail']['hqDefault'] = $thumbnail_base . $videoId . '/hqdefault.jpg'; $vinfo['thumbnail']['sdDefault'] = $thumbnail_base . $videoId . '/sddefault.jpg'; $vinfo['thumbnail']['maxresDefault'] = $thumbnail_base . $videoId . '/maxresdefault.jpg'; } catch (\Exception $e) { $vinfo = []; } return $vinfo; } private static function vimeoVideoInfo($videoId) { $vinfo = []; try { $xml = @file_get_contents("http://vimeo.com/api/oembed.json?url=https://vimeo.com/$videoId"); $xml = json_decode($xml, true); $vinfo['video_type'] = $xml['provider_name']; $vinfo['video_id'] = $xml['video_id']; $vinfo['title'] = $xml['title']; $vinfo['url'] = isset($xml['uri']) ? $xml['uri'] : ''; $vinfo['author_name'] = isset($xml['author_name']) ? $xml['author_name'] : ''; $vinfo['author_url'] = isset($xml['author_url']) ? $xml['author_url'] : ''; $vinfo['duration'] = $xml['duration']; } catch (\Exception $e) { $vinfo = []; } return $vinfo; } public static function formatValue($value) { $value = floor($value * 100) / 100; return number_format($value, 2, ",", "."); } public static function obfuscateEmail($email) { $em = explode("@", $email); $name = implode(array_slice($em, 0, count($em) - 1), '@'); $len = floor(strlen($name) / 2); return substr($name, 0, $len) . str_repeat('*', $len) . "@" . end($em); } public static function randomPassword($length) { $chars = "@#_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; return substr(str_shuffle($chars), 0, $length); } public static function UFlist() { $ufArr = [ 'AC' => 'AC', 'AL' => 'AL', 'AM' => 'AM', 'AP' => 'AP', 'BA' => 'BA', 'CE' => 'CE', 'DF' => 'DF', 'ES' => 'ES', 'GO' => 'GO', 'MA' => 'MA', 'MG' => 'MG', 'MS' => 'MS', 'MT' => 'MT', 'PA' => 'PA', 'PB' => 'PB', 'PE' => 'PE', 'PI' => 'PI', 'PR' => 'PR', 'RJ' => 'RJ', 'RN' => 'RN', 'RO' => 'RO', 'RR' => 'RR', 'RS' => 'RS', 'SC' => 'SC', 'SE' => 'SE', 'SP' => 'SP', 'TO' => 'TO' ]; return $ufArr; } public static function convertToHoursMins($time, $format = '%02d:%02d') { if ($time < 1) { return; } $hours = floor($time / 60); $minutes = ($time % 60); return sprintf($format, $hours, $minutes); } public static function userTypes($withSuper = false) { if ($withSuper) { $userTypes = [ 1 => 'admin', 2 => 'professor', 3 => 'aluno', 5 => 'Super Admin' ]; } else { $userTypes = [ 1 => 'admin', 2 => 'professor', 3 => 'aluno', 5 => 'Super Admin' ]; } return $userTypes; } public static function newGuid() { $s = strtoupper(md5(uniqid(rand(), true))); $guidText = substr($s, 0, 8) . '-' . substr($s, 8, 4) . '-' . substr($s, 12, 4) . '-' . substr($s, 16, 4) . '-' . substr($s, 20); return $guidText; } public static function uniqueFileName($prepend = '') { if (empty($prepend)) { return uniqid(); } return uniqid($prepend); } public static function getLocalVideoDuration($videoFile) { $file = $videoFile; $result = shell_exec('ffmpeg -i ' . escapeshellcmd($file) . ' 2>&1'); preg_match('/(?<=Duration: )(\d{2}:\d{2}:\d{2})\.\d{2}/', $result, $match); $time = $match[0]; if (count($match) > 1) { $time = $match[1]; } $parsed = date_parse($time); $seconds = $parsed['hour'] * 3600 + $parsed['minute'] * 60 + $parsed['second']; return $seconds; } public static function findLongestStringFromArray($array = []) { if (!empty($array)) { $lengths = array_map('strlen', $array); $maxLength = max($lengths); $key = array_search($maxLength, $lengths); return ['length' => $maxLength, 'key' => $key, 'string' => $array[$key]]; } } }
Copyright © 2026 - UnknownSec