Fix consent media root

This commit is contained in:
sas.fajri
2026-05-24 10:06:07 +07:00
parent f0c0bfc4f3
commit cdfc5e88d7
2 changed files with 63 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ class Inform_consent extends MY_Controller
{
private $pageContentBottom = 272.0;
private $footerY = 286.0;
private $mediaRoot = null;
public function __construct()
{
@@ -682,11 +683,15 @@ class Inform_consent extends MY_Controller
if (strpos($url, '/') === 0) {
if (strpos($url, '/one-media/') === 0) {
$absMedia = '/home/one/project' . $url;
$absMedia = rtrim($this->get_media_root(), '/') . $url;
if (is_file($absMedia)) {
return $absMedia;
}
$httpUrl = 'http://devone.aplikasi.web.id' . $url;
$httpHost = isset($_SERVER['HTTP_HOST']) ? trim((string)$_SERVER['HTTP_HOST']) : '';
if ($httpHost === '') {
$httpHost = '10.9.20.31';
}
$httpUrl = 'http://' . $httpHost . $url;
return $this->resolve_signature_path($httpUrl);
}
@@ -703,4 +708,28 @@ class Inform_consent extends MY_Controller
return is_file($url) ? $url : null;
}
private function get_media_root()
{
if ($this->mediaRoot !== null) {
return $this->mediaRoot;
}
$defaultRoot = '/home/one/project/one/';
$sql = "SELECT S_SystemsMediaUrl
FROM conf_systems
WHERE S_SystemsID > 0
LIMIT 1";
$qry = $this->db_onedev->query($sql);
if ($qry && $qry->row()) {
$root = trim((string)$qry->row()->S_SystemsMediaUrl);
if ($root !== '') {
$this->mediaRoot = rtrim($root, '/') . '/';
return $this->mediaRoot;
}
}
$this->mediaRoot = $defaultRoot;
return $this->mediaRoot;
}
}

View File

@@ -2,6 +2,8 @@
class Inform_consent_cpmi extends MY_Controller
{
private $mediaRoot = null;
public function __construct()
{
parent::__construct();
@@ -341,11 +343,15 @@ class Inform_consent_cpmi extends MY_Controller
}
if (strpos($url, '/one-media/') === 0) {
$absMedia = '/home/one/project' . $url;
$absMedia = rtrim($this->get_media_root(), '/') . $url;
if (is_file($absMedia)) {
return $absMedia;
}
return $this->resolve_signature_path('http://devone.aplikasi.web.id' . $url);
$httpHost = isset($_SERVER['HTTP_HOST']) ? trim((string)$_SERVER['HTTP_HOST']) : '';
if ($httpHost === '') {
$httpHost = '10.9.20.31';
}
return $this->resolve_signature_path('http://' . $httpHost . $url);
}
if (strpos($url, '/') === 0) {
@@ -362,4 +368,28 @@ class Inform_consent_cpmi extends MY_Controller
return is_file($url) ? $url : null;
}
private function get_media_root()
{
if ($this->mediaRoot !== null) {
return $this->mediaRoot;
}
$defaultRoot = '/home/one/project/one/';
$sql = "SELECT S_SystemsMediaUrl
FROM conf_systems
WHERE S_SystemsID > 0
LIMIT 1";
$qry = $this->db_onedev->query($sql);
if ($qry && $qry->row()) {
$root = trim((string)$qry->row()->S_SystemsMediaUrl);
if ($root !== '') {
$this->mediaRoot = rtrim($root, '/') . '/';
return $this->mediaRoot;
}
}
$this->mediaRoot = $defaultRoot;
return $this->mediaRoot;
}
}