initial: bootstrap from BukidBountyApp base

This commit is contained in:
Jonathan Sykes
2026-06-06 18:43:00 +08:00
commit eb4a5731fb
5674 changed files with 160857 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Helpers;
use App\Models\FileList;
use Hypervel\Http\Request;
use App\Http\Controllers\FilesMainController;
class ObjectToBase64Helper
{
public static function urlSafeBase64ToObject(string $urlSafeBase64, bool $compressed = true)
{
if (!is_string($urlSafeBase64)) {
return false;
}
$base64 = str_replace(['-', '_'], ['+', '/'], $urlSafeBase64);
$padding = strlen($base64) % 4;
if ($padding !== 0) {
$base64 .= str_repeat('=', 4 - $padding);
}
// Base64 decode
$binary = base64_decode($base64, true);
if ($binary === false) {
return null;
}
try {
if ($compressed) {
// Equivalent of pako.inflate()
$json = gzuncompress($binary);
if ($json === false) {
return null;
}
return json_decode($json, true);
}
return json_decode($binary, true);
} catch (\Throwable $e) {
return null;
}
}
}