From cdfc5e88d7cf431cf0e07d8b917acef2d4692b1d Mon Sep 17 00:00:00 2001 From: "sas.fajri" Date: Sun, 24 May 2026 10:06:07 +0700 Subject: [PATCH] Fix consent media root --- .../controllers/tools/Inform_consent.php | 33 ++++++++++++++++-- .../controllers/tools/Inform_consent_cpmi.php | 34 +++++++++++++++++-- 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/application/controllers/tools/Inform_consent.php b/application/controllers/tools/Inform_consent.php index b1d27ba6..0fcfa4bd 100644 --- a/application/controllers/tools/Inform_consent.php +++ b/application/controllers/tools/Inform_consent.php @@ -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; + } } diff --git a/application/controllers/tools/Inform_consent_cpmi.php b/application/controllers/tools/Inform_consent_cpmi.php index 15a4dfd1..147235de 100644 --- a/application/controllers/tools/Inform_consent_cpmi.php +++ b/application/controllers/tools/Inform_consent_cpmi.php @@ -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; + } }