ACC SHELL

Path : /srv/www/vhosts/marevva/crossroadsfoundation/
File Upload :
Current File : /srv/www/vhosts/marevva/crossroadsfoundation/article-file-download.php

<?php

	header("Content-type: text/plain; charset=UTF-8");
	header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
	header("Cache-Control: no-store, no-cache, must-revalidate");
	header("Cache-Control: post-check=0, pre-check=0", false);
	header("Pragma: no-cache");
	
	include( 'init-db-info.php' );
	include( 'init-db.php' );
	include( 'init-path.php' );
	include( 'functions.php' );
	
	$url_hash = '';
	if ( isset( $_GET['hash'] ) ) $url_hash = $_GET['hash'];
	
	if ( isset( $url_hash ) )
	{
		$downloadItem = $db->getItemWhere( 'downloadHistory', " WHERE `hash`='" . $url_hash . "' " );
		
		if ( isset( $downloadItem['ID'] ) )
		{
			$db->setItem( 'downloadHistory', $downloadItem['ID'], array( 'downloadedDateTime'=>'CURRENT_TIMESTAMP', 'status'=>($downloadItem['status']+1) ) );
		
			
			//redirect to file
					$redirectTo = $downloadItem['fileURL'];
					
					header('Content-Description: File Transfer');
					header('Content-Type: application/octet-stream');
					header('Content-Disposition: attachment; filename="'.$downloadItem['fileName'].'"');
					header('Content-Transfer-Encoding: binary');
					header('Connection: Keep-Alive');
					header('Expires: 0');
					header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
					header('Pragma: public');
					header('Content-Length: ' . filesize( $serverFullPath . $redirectTo ) );
					
					flush();

					readfile( $serverFullPath . $redirectTo );
					
					exit;

		}
		else
		{
			header("HTTP/1.0 301 Moved Permanently");
			header("Status: Moved Permanently");
					
			header("Location: http://".$_SERVER['HTTP_HOST']."/");
		}
	}
	else
	{
		header("HTTP/1.0 301 Moved Permanently");
        header("Status: Moved Permanently");
				
		header("Location: http://".$_SERVER['HTTP_HOST']."/");
	}

?>

ACC SHELL 2018