<?php
/****************************
 * File : pdfviewer.php
 * Author : Cygnusa
 * @2018
****************************/

//SECURITY 
if ( ! defined('APPLICATION_PATH')) exit('No direct script access allowed');
//FUNCTION LISTS

class pdfviewer
{
	//CONSTRUCT 
	function __construct($parent)
	{
		//GET PAGE MESSAGE
		$this->pdfviewerFunc($parent);		 
		$parent->response(array('response'=>'failed', 'message' => 'PAGE NOT FOUND'), 404);
	}

	/* /////////////////////////////// TRAINING //////////////////////////////////////// */
	private function pdfviewerFunc($parent)
    {
		globalfunc::checkMethodType($parent,array('GET'));		
		globalfunc::checkParamCount($parent,1);
		//globalfunc::checkAuthrozation($parent,array('type'=>'user'));
        
        $decode_url= base64_decode(escape_str($parent->params[0]));
        //CONNECT S3
		$s3=awsfileserver::connectS3(); 
        $obj = new stdClass();
        $obj->key_name=$decode_url;					
        $s3_sign_url=awsfileserver::getS3Url($s3,S3_BUCKET,$obj);  
        
        header("Content-type:application/pdf");
        header("Access-Control-Allow-Origin: *");        
        @readfile($s3_sign_url);        
        exit;
 
    }
    /* //////////////////////////////////////////////////////////////////////////////////////////// */
 

}

?>