merms-media data

This commit is contained in:
CHIEFSOFT\ameye
2026-01-01 09:08:38 -05:00
parent d1d0f32faa
commit 5bfe1d54f6
6 changed files with 155 additions and 12 deletions
+12 -5
View File
@@ -4,6 +4,18 @@ UID=1000
SERVER_PATH=production
# UPLOAD PATHS
UPLOAD_FOLDER="/app/uploads/DEV"
MEDIA_SERVER="https://qa-media.mermsemr.com"
# DATABASE SERVER
MAIN_DATABASE_IP="10.20.30.60"
MAIN_DATABASE_USERNAME="merms_panel"
MAIN_DATABASE_PASSWORD="merms_panel"
MAIN_DATABASE="merms_panel"
MAIN_DATABASE_PORT="5432"
PATH_MACHINE_LOCAL='/home/chiefsoft/DevSites/MERMS/MermsProvision/ANSIBLE/parts/'
# '/home/chiefsoft/MermsProvision/ANSIBLE/parts/'
# REMOTE_COMPOSER_PATH='chiefsoft@10.0.0.32:/home/chiefsoft/MermsProvision/ANSIBLE/parts/'
@@ -32,11 +44,6 @@ HAPROXY_SERVER_USER="admin"
HAPROXY_SERVER_PASS="Hapr0xy001"
MAIN_DATABASE_IP="10.20.30.60"
MAIN_DATABASE_USERNAME="merms_panel"
MAIN_DATABASE_PASSWORD="merms_panel"
MAIN_DATABASE="merms_panel"
MAIN_DATABASE_PORT="5432"
PROVISION_MSQL_DATABASE_IP="172.16.4.96"
PROVISION_MSQL_DATABASE_USERNAME="root"
+12 -6
View File
@@ -5,6 +5,18 @@ CI_ENVIRONMENT=production
SERVER_PATH = production
# UPLOAD PATHS
UPLOAD_FOLDER="/app/uploads/LIVE"
MEDIA_SERVER="https://media.mermsemr.com"
# DATABASE SERVER
MAIN_DATABASE_IP="10.13.3.60"
MAIN_DATABASE_USERNAME="merms_panel"
MAIN_DATABASE_PASSWORD="merms_panel"
MAIN_DATABASE="merms_panel"
MAIN_DATABASE_PORT="5432"
PATH_MACHINE_LOCAL='/home/chiefsoft/DevSites/MERMS/MermsProvision/ANSIBLE/parts/'
# '/home/chiefsoft/MermsProvision/ANSIBLE/parts/'
# REMOTE_COMPOSER_PATH = 'chiefsoft@10.0.0.32:/home/chiefsoft/MermsProvision/ANSIBLE/parts/'
@@ -32,12 +44,6 @@ HAPROXY_SERVER_USER="admin"
HAPROXY_SERVER_PASS="Hapr0xy001"
MAIN_DATABASE_IP="10.13.3.60"
MAIN_DATABASE_USERNAME="merms_panel"
MAIN_DATABASE_PASSWORD="merms_panel"
MAIN_DATABASE="merms_panel"
MAIN_DATABASE_PORT="5432"
PROVISION_MSQL_DATABASE_IP="172.16.4.96"
PROVISION_MSQL_DATABASE_USERNAME="root"
PROVISION_MSQL_DATABASE_PASSWORD="may12002!"
+45
View File
@@ -24,7 +24,52 @@ class Database extends Config
*
* @var array<string, mixed>
*/
public array $default = [
'DSN' => '',
'hostname' => '10.20.30.60',
'username' => 'merms_panel',
'password' => 'merms_panel',
'database' => 'merms_panel',
'schema' => 'public',
'DBDriver' => 'Postgre',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug' => true,
'charset' => 'utf8',
'swapPre' => '',
'failover' => [],
'port' => 5432,
'dateFormat' => [
'date' => 'Y-m-d',
'datetime' => 'Y-m-d H:i:s',
'time' => 'H:i:s',
],
];
public array $production = [
'DSN' => '',
'hostname' => '10.13.3.60',
'username' => 'merms_panel',
'password' => 'merms_panel',
'database' => 'merms_panel',
'schema' => 'public',
'DBDriver' => 'Postgre',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug' => true,
'charset' => 'utf8',
'swapPre' => '',
'failover' => [],
'port' => 5432,
'dateFormat' => [
'date' => 'Y-m-d',
'datetime' => 'Y-m-d H:i:s',
'time' => 'H:i:s',
],
];
public array $default_old = [
'DSN' => '',
'hostname' => 'localhost',
'username' => '',
+1
View File
@@ -8,3 +8,4 @@ use CodeIgniter\Router\RouteCollection;
$routes->get('/', 'Home::index');
$routes->get('/media/test', 'Media::index');
$routes->get('/media/show/(:any)', 'Media::imageGate/$1');
$routes->get('/website/(:any)', 'Media::WebsiteGate/$1');
+3 -1
View File
@@ -43,6 +43,8 @@ abstract class BaseController extends Controller
*/
// protected $session;
protected $db;
/**
* @return void
*/
@@ -52,7 +54,7 @@ abstract class BaseController extends Controller
parent::initController($request, $response, $logger);
// Preload any models, libraries, etc, here.
$this->db = \Config\Database::connect();
// E.g.: $this->session = service('session');
}
}
+82
View File
@@ -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 = [