Your IP : 216.73.216.79


Current Path : /var/www/html/ebilikparlimen1/ebilik/ks_builtin/
Upload File :
Current File : /var/www/html/ebilikparlimen1/ebilik/ks_builtin/file_dispatcher.php

<?php

/**
 * This file retrieves file attachments.
 * @param $_GET['id'] //attachment ID
 * @param $_GET['key'] //ecrypted key. Look at KS_Attachment:generateKey()
 */

include_once '../library.php';

$isAuth = CUSTOM_User::checkAuthentication ();

if (! $isAuth) {
	header ( "Location: " . KSCONFIG_URL . "ks_user/login.php?msg=notlogin" );
}

$id = ( int ) $_GET ['id'];
$key = KS_Filter::inputSanitize ( $_GET ['key'] );

$objAttachment = new KS_Attachment ();
$objAttachment->setId ( $id );
if (! $objAttachment->exists ()) {
	echo "No files found with id '$id'";
	exit ();
}
$objAttachment->select ();

//check if key is valid
if ($key != $objAttachment->generateKey ()) {
	echo "Key no match!";
	exit ();
}

//the actual file in server
$filename = KSCONFIG_CACHE_UPLOAD_PATH . $id . '_' . $objAttachment->getFilename ();

$now = gmdate ( 'D, d M Y H:i:s' ) . ' GMT';
header ( 'Content-Type: ' . $objAttachment->getFilemimetype () );
header ( 'Expires: ' . $now );
header ( 'Content-Disposition: inline; filename="' . $objAttachment->getFilename () . '"' );
header ( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
header ( 'Pragma: public' );
echo file_get_contents ( $filename );
exit ();