0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; if (!$res) die("Include of main fails"); require_once __DIR__.'/../lib/bericht.lib.php'; if (!$user->hasRight('bericht', 'read')) accessforbidden(); $pageid = GETPOSTINT('pageid'); if (!$pageid) { http_response_code(400); exit; } $res = $db->query("SELECT source_type, source_path FROM ".$db->prefix()."bericht_page WHERE rowid = ".((int) $pageid)); if (!$res) { http_response_code(500); exit; } $row = $db->fetch_object($res); if (!$row) { http_response_code(404); exit; } $full = bericht_resolve_data_path($row->source_path); if (!$full || !file_exists($full)) { http_response_code(404); exit; } $mime = dol_mimetype($full); header('Content-Type: '.$mime); header('Content-Length: '.filesize($full)); header('Cache-Control: private, max-age=300'); readfile($full);