merms-media data
This commit is contained in:
@@ -80,6 +80,88 @@ class Media extends BaseController
|
||||
exit();
|
||||
}
|
||||
|
||||
//
|
||||
#[NoReturn] public function WebsiteGate(): void
|
||||
{
|
||||
$uriSegments = explode("/", parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
|
||||
$segLen = count($uriSegments);
|
||||
// var_dump($uriSegments);
|
||||
// 0 => string '' (length=0)
|
||||
// 1 => string 'website' (length=7)
|
||||
// 2 => string '4bdc1594-a0d4-4eba-9dff-9e62f5c28d69' (length=36)
|
||||
// 3 => string 'coronary-artery-disease.png' (length=27)
|
||||
|
||||
$filename = $uriSegments[$segLen - 1];
|
||||
$webFileUid = $uriSegments[$segLen - 2];
|
||||
$fileDetails = $this->getWebFileDetails($webFileUid);
|
||||
|
||||
// var_dump($fileDetails);
|
||||
//'id' => string '12' (length=2)
|
||||
//'uid' => string '4bdc1594-a0d4-4eba-9dff-9e62f5c28d69' (length=36)
|
||||
//'member_id' => string '20' (length=2)
|
||||
//'member_uid' => string '2f1f9c8a-d50b-4fac-9de3-081bbc07cc64' (length=36)
|
||||
//'file_group' => string 'WEBSITE' (length=7)
|
||||
//'filename' => string 'coronary-artery-disease.png' (length=27)
|
||||
//'save_filename' => string '1767224858-coronary-artery-disease.png' (length=38)
|
||||
//'file_type' => string 'png' (length=3)
|
||||
//'file_size' => string '0' (length=1)
|
||||
//'status' => string '1' (length=1)
|
||||
//'added' => string '2025-12-31 18:47:38.905934' (length=26)
|
||||
//'updated' => string '2025-12-31 18:47:38.905943' (length=26)
|
||||
|
||||
// exit;
|
||||
///var/www/html/uploads/uploads/DEV/WEBSITE/W0000000020/1767055095-practice-in-ai_1.jpg
|
||||
$target_file = "/var/www/html/uploads/uploads/DEV/WEBSITE/W0000000020/1767055095-practice-in-ai_1.jpg";
|
||||
//$target_file = "/var/www/html/SITEFILES/TEST/" . $filename;
|
||||
$file_extension = "jpg"; // strtolower(substr(strrchr($filename, "."), 1));
|
||||
$ctype = "image/jpeg";
|
||||
switch ($file_extension) {
|
||||
case "gif":
|
||||
$ctype = "image/gif";
|
||||
break;
|
||||
case "png":
|
||||
$ctype = "image/png";
|
||||
break;
|
||||
case "jpeg":
|
||||
case "jpg":
|
||||
$ctype = "image/jpeg";
|
||||
break;
|
||||
case "svg":
|
||||
$ctype = "image/svg+xml";
|
||||
break;
|
||||
case "mp4":
|
||||
$ctype = "application/octet-stream";
|
||||
break;
|
||||
// case "mp4": $ctype="video/mp4"; break;
|
||||
default:
|
||||
}
|
||||
|
||||
$selectedFile = $target_file;
|
||||
header('Content-type: ' . $ctype);
|
||||
readfile($selectedFile);
|
||||
exit();
|
||||
}
|
||||
|
||||
private function getWebFileDetails($webFileUid): array
|
||||
{
|
||||
try {
|
||||
$sqlP = "SELECT * FROM members_webfiles WHERE uid::text = '$webFileUid' ";
|
||||
$query = $this->db->query($sqlP);
|
||||
$row = $query->getResultArray();
|
||||
if (isset($row)) {
|
||||
return $row;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// Handle the specific exception
|
||||
//echo "Caught exception: " . $e->getMessage() . "\n";
|
||||
log_message('error', 'Error in getWebFileDetails :: :: ' . $e->getMessage());
|
||||
} finally {
|
||||
// Cleanup code, always runs
|
||||
log_message('info', "Consider CACHE IN getWebFileDetails - $webFileUid");
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
private function imageSets($selImg): string
|
||||
{
|
||||
$image_set = [
|
||||
|
||||
Reference in New Issue
Block a user