diff --git a/SITEFILES/TEST/about-choose-sec-image1.png b/SITEFILES/TEST/about-choose-sec-image1.png new file mode 100644 index 0000000..110b618 Binary files /dev/null and b/SITEFILES/TEST/about-choose-sec-image1.png differ diff --git a/SITEFILES/TEST/about-choose-sec-image2.png b/SITEFILES/TEST/about-choose-sec-image2.png new file mode 100644 index 0000000..88ad009 Binary files /dev/null and b/SITEFILES/TEST/about-choose-sec-image2.png differ diff --git a/SITEFILES/TEST/about-choose-sec-image3.png b/SITEFILES/TEST/about-choose-sec-image3.png new file mode 100644 index 0000000..7b374d1 Binary files /dev/null and b/SITEFILES/TEST/about-choose-sec-image3.png differ diff --git a/SITEFILES/TEST/about-page-sec1-image1.png b/SITEFILES/TEST/about-page-sec1-image1.png new file mode 100644 index 0000000..41817b6 Binary files /dev/null and b/SITEFILES/TEST/about-page-sec1-image1.png differ diff --git a/SITEFILES/TEST/about-page-sec1-image2.png b/SITEFILES/TEST/about-page-sec1-image2.png new file mode 100644 index 0000000..b1d72bf Binary files /dev/null and b/SITEFILES/TEST/about-page-sec1-image2.png differ diff --git a/SITEFILES/TEST/about10-image.png b/SITEFILES/TEST/about10-image.png new file mode 100644 index 0000000..f5af002 Binary files /dev/null and b/SITEFILES/TEST/about10-image.png differ diff --git a/SITEFILES/TEST/about2-image1.png b/SITEFILES/TEST/about2-image1.png new file mode 100644 index 0000000..eb4a8f9 Binary files /dev/null and b/SITEFILES/TEST/about2-image1.png differ diff --git a/SITEFILES/TEST/about2-image2.png b/SITEFILES/TEST/about2-image2.png new file mode 100644 index 0000000..5c42459 Binary files /dev/null and b/SITEFILES/TEST/about2-image2.png differ diff --git a/SITEFILES/TEST/about3-image1.png b/SITEFILES/TEST/about3-image1.png new file mode 100644 index 0000000..f9577a7 Binary files /dev/null and b/SITEFILES/TEST/about3-image1.png differ diff --git a/SITEFILES/TEST/about3-image2.png b/SITEFILES/TEST/about3-image2.png new file mode 100644 index 0000000..4553f09 Binary files /dev/null and b/SITEFILES/TEST/about3-image2.png differ diff --git a/SITEFILES/TEST/about4-image1.png b/SITEFILES/TEST/about4-image1.png new file mode 100644 index 0000000..004e7fd Binary files /dev/null and b/SITEFILES/TEST/about4-image1.png differ diff --git a/SITEFILES/TEST/about4-image3.png b/SITEFILES/TEST/about4-image3.png new file mode 100644 index 0000000..05c2684 Binary files /dev/null and b/SITEFILES/TEST/about4-image3.png differ diff --git a/SITEFILES/TEST/about5-image1.png b/SITEFILES/TEST/about5-image1.png new file mode 100644 index 0000000..238c4c3 Binary files /dev/null and b/SITEFILES/TEST/about5-image1.png differ diff --git a/SITEFILES/TEST/about5-image2.png b/SITEFILES/TEST/about5-image2.png new file mode 100644 index 0000000..197b3fc Binary files /dev/null and b/SITEFILES/TEST/about5-image2.png differ diff --git a/SITEFILES/TEST/about5-image3.png b/SITEFILES/TEST/about5-image3.png new file mode 100644 index 0000000..7beae89 Binary files /dev/null and b/SITEFILES/TEST/about5-image3.png differ diff --git a/SITEFILES/TEST/about6-image1.png b/SITEFILES/TEST/about6-image1.png new file mode 100644 index 0000000..db60536 Binary files /dev/null and b/SITEFILES/TEST/about6-image1.png differ diff --git a/SITEFILES/TEST/about6-image2.png b/SITEFILES/TEST/about6-image2.png new file mode 100644 index 0000000..c99b24f Binary files /dev/null and b/SITEFILES/TEST/about6-image2.png differ diff --git a/SITEFILES/TEST/about7-image.png b/SITEFILES/TEST/about7-image.png new file mode 100644 index 0000000..7c14e76 Binary files /dev/null and b/SITEFILES/TEST/about7-image.png differ diff --git a/SITEFILES/TEST/about8-image.png b/SITEFILES/TEST/about8-image.png new file mode 100644 index 0000000..f7e72d3 Binary files /dev/null and b/SITEFILES/TEST/about8-image.png differ diff --git a/app/Config/Routes.php b/app/Config/Routes.php index ec9da98..9ddab6c 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -6,4 +6,5 @@ use CodeIgniter\Router\RouteCollection; * @var RouteCollection $routes */ $routes->get('/', 'Home::index'); -$routes->get('/media/test', 'Media::index'); +$routes->get('/media/test', 'Media::index'); +$routes->get('/media/show/(:any)', 'Media::imageGate/$1'); diff --git a/app/Controllers/Media.php b/app/Controllers/Media.php index 890b986..c25eb8e 100644 --- a/app/Controllers/Media.php +++ b/app/Controllers/Media.php @@ -10,43 +10,118 @@ class Media extends BaseController $target_file = "/var/www/html/SITEFILES/TEST/test.jpg"; $filename = $target_file; - $file_extension = strtolower(substr(strrchr($filename,"."),1)); - $ctype="image/jpeg"; - switch( $file_extension ) { - case "gif": $ctype="image/gif"; break; - case "png": $ctype="image/png"; break; + $file_extension = 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 "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; + $selectedFile = $target_file; header('Content-type: ' . $ctype); readfile($selectedFile); exit(); -/* - if (file_exists($selectedFile)) { - log_message('critical', "FILE ************************** --->0002"); - header('Content-Description: File Transfer'); - header('Content-Type: application/octet-stream'); - header('Content-Disposition: attachment; filename="'.basename($selectedFile).'"'); - header('Expires: 0'); - header('Cache-Control: must-revalidate'); - header('Pragma: public'); - header('Content-Length: ' . filesize($selectedFile)); - readfile($selectedFile); - exit; - } -*/ + /* + if (file_exists($selectedFile)) { + log_message('critical', "FILE ************************** --->0002"); + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename="'.basename($selectedFile).'"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + header('Content-Length: ' . filesize($selectedFile)); + readfile($selectedFile); + exit; + } + */ - // echo $target_file; + // echo $target_file; - // return $target_file; + // return $target_file; } + + public function imageGate() + { + $uriSegments = explode("/", parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)); + $segLen = count($uriSegments); + //var_dump($uriSegments); + + $filename = $this->imageSets($uriSegments[ $segLen -1 ]); + $target_file = "/var/www/html/SITEFILES/TEST/".$filename; + $file_extension = 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 imageSets($selImg) + { + $image_set = [ + "test" => "test.jpg", + "about8-image" => "about8-image.png", + "about7-image" => "about7-image.png", + "about6-image1" => "about6-image1.png", + "about6-image2" => "about6-image2.png", + "about5-image3" => "about5-image3.png", + "about5-image2" => "about5-image2.png", + "about4-image3" => "about4-image3.png", + "about5-image1" => "about5-image1.png", + "about3-image1" => "about3-image1.png", + "about3-image2" => "about3-image2.png", + "about4-image1" => "about4-image1.png", + "about10-image" => "about10-image.png", + "about2-image1" => "about2-image1.png", + "about2-image2" => "about2-image2.png", + "about-page-sec1-image1" => "about-page-sec1-image1.png", + "about-page-sec1-image2" => "about-page-sec1-image2.png", + "about-choose-sec-image2" => "about-choose-sec-image2.png", + "about-choose-sec-image3" => "about-choose-sec-image3.png", + "about-choose-sec-image1" => "about-choose-sec-image1.png", + ]; + return $image_set[$selImg]; + } + }