MOON
Server: Apache/2.2.23 (Unix) mod_ssl/2.2.23 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 PHP/5.4.10
System: Linux vps.presagepowered.net 2.6.18-398.el5 #1 SMP Tue Sep 16 20:51:48 EDT 2014 i686
User: mckernan (512)
PHP: 5.4.10
Disabled: NONE
Upload Files
File: /home/mckernan/public_html/iJournal/includes/journal/viewstatement.php
<?php

// view previously-generated statement

    // init database name
	$database = DB_PREFIX;	
	
    // process request
	if ($sid != '')
	{
	    // sid check
		require "includes/session/sidck.php";
        
        // fetch database name / open db
		$dbn = '';
        if ( isset($_POST['db']) ) $dbn = $_POST['db'];
		if ( isset($_GET['db']) ) $dbn = $_GET['db'];
		
		if ($dbn == '') die();
		
		$database .= $dbn;
		
		require "includes/db.php";
        
        
        // get period
        $file = getvar($db, 'f', 'string');
		$file .= '.pdf';
        $saveas = $file;
                
        // build file info
    	$filepath = clientPath() . $dbn . '/statements/' . $file;
        
        if (is_file($filepath))
    	{
    	   	$filesize = filesize($filepath);
    		
    		$mimetype = $mime_types[$filetype];
    		
    		
    		// set headers
    		header("Pragma: public");
    		header("Expires: 0");
    		header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    		header("Cache-Control: public");
    		header("Content-Description: File Transfer");
    		header("Content-Type: application/pdf");
    		header("Content-Transfer-Encoding: binary");
            header("Content-Disposition: inline; filename=\"$file\"");
    		header("Content-Length: " . $filesize);
    		
    		// download
    		$dlfile = fopen($filepath, "rb");
    		
    		if ($dlfile) 
    		{
    			while ( !feof($dlfile) ) 
    			{
    		    	print(fread($dlfile, 1024*8));
    		    	flush();
    		    	
    		    	if (connection_status() != 0) 
    				{
    		      		@fclose($dlfile);
    		      		die();
    		    	}
    		  	}
    		  
    		  	@fclose($dlfile);
    		} 
    	}
     }
?>