query($sql_q); $file_d = $file_q->fetch_assoc(); if ($file_q->num_rows > 0) { $file_loc_url = SWB.'repository/'.( $file_d['file_dir']?$file_d['file_dir'].'/':'' ).$file_d['file_name']; $file_loc = REPOBS.( $file_d['file_dir']?$file_d['file_dir'].'/':'' ).$file_d['file_name']; if (file_exists($file_loc)) { // check access limit if ($file_d['access_limit']) { if (utility::isMemberLogin()) { $allowed_mem_types = @unserialize($file_d['access_limit']); if (!in_array($_SESSION['m_member_type_id'], $allowed_mem_types)) { # Access to file restricted # Member logged in but doesnt have privilege to download header("location:index.php"); exit(); } } else { header("location:index.php"); exit(); } } if ($file_d['mime_type'] == 'application/pdf') { if ($sysconf['pdf']['viewer'] == 'pdfjs') { // header('Location: ./js/pdfjs/web/viewer.php?file=../../../repository/'.$file_d['file_dir'].'/'.$file_d['file_name']); require './js/pdfjs/web/viewer.php'; exit(); } } else if (preg_match('@(image)/.+@i', $file_d['mime_type'])) { header('Content-Disposition: inline; filename="'.basename($file_loc).'"'); header('Content-Type: '.$file_d['mime_type']); readfile($file_loc); exit(); } } exit(); } else { die('