Files
2021-10-09 21:59:14 -04:00

57 lines
1.7 KiB
PHP

<?php
class Smedia extends CI_Controller {
public function index() {
$this->serve_file('');
}
private function serve_file($filename) {
if ($filename=='' || !file_exists($filename)) {
$filename = 'assets/images/accessdenied.png';
}
// Any additional path checks should go here
// TODO: realpath check to /opt/wrenchboard
header('Content-type: ' . mime_content_type($filename));
readfile($filename);
}
public function DEFAULTS() {
if (!isset($_SESSION['username']) or $_SESSION['username'] == '') {
$this->serve_file('');
return;
}
//var_dump($_SERVER);
$filename = str_replace("/smedia/","/opt/wrenchboard/",$_SERVER["SCRIPT_URL"]);
//echo $filename;
$this->serve_file($filename);
}
public function LIVE() {
if (!isset($_SESSION['username']) or $_SESSION['username'] == '') {
$this->serve_file('');
return;
}
$filename = str_replace("/smedia/","/opt/wrenchboard/",$_SERVER["SCRIPT_URL"]);
$this->serve_file($filename);
}
public function media() {
if (!isset($_SESSION['username']) or $_SESSION['username'] == '') {
$this->serve_file('');
return;
}
$filename = str_replace("/smedia/","/opt/wrenchboard/",$_SERVER["SCRIPT_URL"]);
$this->serve_file($filename);
}
public function TEST() {
if (!isset($_SESSION['username']) or $_SESSION['username'] == '') {
$this->serve_file('');
return;
}
$filename = str_replace("/smedia/","/opt/wrenchboard/",$_SERVER["SCRIPT_URL"]);
$this->serve_file($filename);
}
}