Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // ROUTES[2] IS = IMAGE_ID + UNIQID
- // EXAMPLE: 23
- $file_name = (int)$routes[2];
- $file = '/home/husliste/images/'.$file_name;
- $sql = "SELECT i.image_filetype as filetype, i.image_type as type, i.image_key "
- . "FROM images i "
- . "WHERE i.image_deleted IS NULL "
- . "AND i.image_id = :filename LIMIT 1";
- $results = $db_connect->prepare($sql);
- $results->bindParam(':filename', $file_name, PDO::PARAM_INT);
- $results->execute();
- $db_image = $results->fetchAll(PDO::FETCH_ASSOC);
- foreach($db_image as $output){
- if($output['type']){
- // CREATE HEADER
- switch($output['filetype']){
- case "gif": $ctype="image/gif"; break;
- case "png": $ctype="image/png"; break;
- case "jpeg":
- case "jpg": $ctype="image/jpeg";break;
- default:
- }
- header('Content-type: '.$ctype);
- // CREATE FILE PATH
- $file_path = $file.'.'.$output['filetype'];
- // =========================================== //
- // PLAN
- if($output['type'] === '1'){
- if(checkPlanAccess($output['image_key'])){
- if(file_exists($file_path)){
- echo file_get_contents($file_path);
- }else{$error_code = 4;}
- }else{$error_code = 4;}
- }
- // PROFILE PICTURE
- elseif($output['type'] === '2' && $check_session){
- if(file_exists($file_path)){
- $image = file_get_contents($file_path);
- echo $image;
- }else{$error_code = 4;}
- }
- // COMPANY LOGO
- elseif($output['type'] === '3' && $check_session){
- if(file_exists($file_path)){
- echo file_get_contents($file_path);
- }else{$error_code = 4;}
- }
- // CUSTOMER LOGO
- elseif($output['type'] === '4'){
- if(checkCustomerAccess($output['image_key'])){
- if(file_exists($file_path)){
- echo file_get_contents($file_path);
- }else{$error_code = 4;}
- }else{$error_code = 4;}
- }
- // CUSTOMER PROJECT IMAGES
- elseif($output['type'] === '5'){
- if(checkCustomerProjectAccess($output['image_key'])){
- if(file_exists($file_path)){
- echo file_get_contents($file_path);
- }else{$error_code = 4;}
- }else{$error_code = 4;}
- }
- // SUPPLIER LOGO
- elseif($output['type'] === '6'){
- if(checkSupplierAccess($output['image_key'])){
- if(file_exists($file_path)){
- echo file_get_contents($file_path);
- }else{$error_code = 4;}
- }else{$error_code = 4;}
- }else{
- $error_code = 4;
- }
- }else{
- $error_code = 4;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement