Location: PHPKode > projects > Ptk-forensics > ptk/lib/report_pdf.php
<?php
/*
PTK  - DFLabs
Copyright (C) 2008 - DFLabs srl - All rights reserved
hide@address.com
*/
include("check_session.php");
include("check_session_image.php");
include ('class.ezpdf.php');
include ('lib_std.php');
include("lib_commands.php");
include ("loggerClass.php");
session_start();

if (isset($_SESSION['rep_token']) && strcmp($_SESSION['rep_token'],$_POST['token'])==0){
	new Log($_SESSION['ip'], $_SESSION['user'], 'New report created');
	$case = case_info($_SESSION['case_id']);
	$user = $_SESSION['user'];
	$image = image_list($_SESSION['case_id']);

	$pdf =& new Cezpdf();
	$pdf -> addInfo(array('Title'=>'PTK Report','Author'=>'PTK - DFLabs'));
	$pdf -> ezSetMargins(50,80,50,50);
	$pdf -> selectFont('../fonts/Helvetica.afm');
	$pdf->ezStartPageNumbers(550,30,10,'','',1);
	$pdf -> addJpegFromFile('../img/ptk_logo.jpg',360,740,180);
	
	$pdf -> ezSetDy(-100);

	$img = $pdf->openObject();
	$pdf->saveState();
	$pdf->setStrokeColor(0,0,0,1);
	$pdf->line(45,50,560,50);
	$pdf->addText(50,30,8, "PTK Report - Case ".stripslashes($case['name']));
	$pdf->restoreState();
	$pdf->closeObject();
	$pdf -> addObject($img,'all');

	$pdf -> addText(50,750,20,"<b>Case Report</b>");

	$pdf -> addText(50,700,12,"<b>Case: </b>".stripslashes($case['name']));
	$pdf -> addText(50,680,12,"<b>Investigator: </b>$user");


	//*****CASE INFORMATIONS
	$pdf -> ezSetDy(-40);
	$pdf -> ezText("<b>Case informations</b>",12);
	$pdf -> ezSetDy(-5);
	if($case['is_locked']==0) $locked="no"; else $locked="yes";
	$data = array(
		array('field'=>'<b>Name</b>','value'=>stripslashes($case['name'])),
		array('field'=>'<b>Description</b>','value'=>$case['description']),
		array('field'=>'<b>Creation time</b>','value'=>$case['creation_time']),
		array('field'=>'<b>Closing time</b>','value'=>$case['closing_time']),
		array('field'=>'<b>Locked</b>','value'=>$locked)
	);
	$pdf->ezTable($data,array('field'=>'<b>Field</b>','value'=>'<b>Value</b>'),''
		,array('showHeadings'=>0,'maxWidth'=>510,'xPos'=>'left','xOrientation'=>'right','cols'=>array('field'=>array('width'=>100),'value'=>array('width'=>410))));
	

	//*****EVIDENCES' INFORMATIONS
	for($i=0;$i<sizeof($image);$i++){
		if(isset($_POST[$image[$i]['name']])){
			$pdf->ezNewPage();
			$pdf -> ezText("<b>Evidence: ".$image[$i]['name']."</b>",12);	
	
		switch ($image[$i]['acquisition_type']){
				case '-1': $acquisition_type=''; break;
				case '0': $acquisition_type='DD'; break;
				case '1': $acquisition_type='100%'; break;
				case '2': $acquisition_type='AFF'; break;
				case '3': $acquisition_type='ENCASE'; break;
				case '4': $acquisition_type='SAFEBACK'; break;
				case '5': $acquisition_type='IMAGEMASTER DD'; break;
				case '6': $acquisition_type='OTHER'; break;
			}	
			$location = array(); $location = explode(";", $image['acquisition_location']);
			$state = $location[0];
			$city = $location[1];
			$address = $location[2];
			$zip = $location[3];	
			
			$partition = partition_info($image[$i]['id']);	
			$part_id = '';
		for($x=0; $x<sizeof($partition);$x++){
				$part_id .= $partition[$x]['id'].",";
			}
			$part_id = preg_replace("/,$/", "", $part_id);
			$bm = get_bookmarks($_SESSION['case_id'], $_SESSION['user'], $part_id, "");			
	
			$pdf -> ezSetDy(-10);
			$data = array(
				array('field'=>'<b>Name</b>','value'=>$image[$i]['name']),
				array('field'=>'<b>Description</b>','value'=>$image[$i]['description']),
				array('field'=>'<b>Size</b>','value'=>$image[$i]['image_size']),
				array('field'=>'<b>Timezone</b>','value'=>$image[$i]['timezone']),
				array('field'=>'<b>MD5</b>','value'=>$image[$i]['image_md5']),
				array('field'=>'<b>Last MD5 check</b>','value'=>$image[$i]['image_md5_check']),
				array('field'=>'<b>SHA1</b>','value'=>$image[$i]['image_sha1']),
				array('field'=>'<b>Last SHA1 check</b>','value'=>$image[$i]['image_sha1_check']),
				array('field'=>'<b>Acquisition type</b>','value'=>$acquisition_type),
				array('field'=>'<b>Acquisition time</b>','value'=>$image[$i]['acquisition_time']),
				array('field'=>'<b>Acquisition operator</b>','value'=>$image[$i]['acquisition_operator']),
				array('field'=>'<b>State</b>','value'=>$state),
				array('field'=>'<b>City</b>','value'=>$city),
				array('field'=>'<b>Address</b>','value'=>$address),
				array('field'=>'<b>Zip code</b>','value'=>$zip)
			);
			$pdf->ezTable($data,array('field'=>'<b>Field</b>','value'=>'<b>Value</b>'),''
				,array('showHeadings'=>0,'maxWidth'=>510,'xPos'=>'left','xOrientation'=>'right','cols'=>array('field'=>array('width'=>100),'value'=>array('width'=>410))));	
				
			$pdf -> ezSetDy(-20);	
			if(sizeof($bm)!=0)
				$pdf -> ezText("<b>Bookmarks</b>",12);	
			$pdf -> ezSetDy(-10);	
			for($j=0;$j<sizeof($bm);$j++){
				$path = get_image_path_from_partition($bm[$j]['id_partition']);
				$offset = get_partition_offset_from_id($bm[$j]['id_partition']);						
				$type = get_file_type($path, $offset, $bm[$j]['reference']);
				if((preg_match("/(image data)|(PC bitmap data)/", $type)) and (isset($_POST['thumbnails']))){
					$nm = preg_replace("/\s\|\s.+$/", "", $bm[$j]['title']);
					$n = preg_replace("/\s\(deleted\)/", "", $nm);	
					$name = preg_replace("/\s/", "_", $n);				
					$picture = get_file_content_image_report($offset, $bm[$j]['reference'], $name, $path);	
					$data1 = array(
						array('field'=>'<b>Title</b>','value'=>$bm[$j]['title']),
						array('field'=>'<b>Description</b>','value'=>$bm[$j]['description']),
						array('field'=>'<b>Tags</b>','value'=>$bm[$j]['tags']),
						array('field'=>'<b>Bookmark type</b>','value'=>get_bookmark_type($bm[$j]['type'])),
						array('field'=>'<b>Investigator</b>','value'=>$bm[$j]['user']),
						array('field'=>'<b>Filetype</b>','value'=>$type),
						array('field'=>"<b>Thumbnail</b>",'value'=>"\n<C:showimage:$picture 100>")
					);
				}else{
					$data1 = array(
						array('field'=>'<b>Title</b>','value'=>$bm[$j]['title']),
						array('field'=>'<b>Description</b>','value'=>$bm[$j]['description']),
						array('field'=>'<b>Tags</b>','value'=>$bm[$j]['tags']),
						array('field'=>'<b>Bookmark type</b>','value'=>get_bookmark_type($bm[$j]['type'])),
						array('field'=>'<b>Investigator</b>','value'=>$bm[$j]['user']),
						array('field'=>'<b>Filetype</b>','value'=>$type)			
					);
				}
				$pdf->ezTable($data1,array('field'=>'<b>Field</b>','value'=>'<b>Value</b>'),''
					,array('showHeadings'=>0,'maxWidth'=>510,'shaded'=>0,'xPos'=>'left','xOrientation'=>'right','cols'=>array('field'=>array('width'=>100),'value'=>array('width'=>410))));	
			}
		}
	}

	$pdfcode = $pdf->ezOutput();
	
	if ($handle = opendir('../temp')) {
		while (false !== ($fl = readdir($handle))) {
			if($fl!="." && $fl !=".."){
				unlink("../temp/$fl");
			}
		}
		closedir($handle);
	}

	$timestamp = date('Ymd_H.i.s');
	$report_name = $timestamp."_".stripslashes($case['name']).".pdf";
	$fp=fopen("../report/$report_name",'wb');
	fwrite($fp,$pdfcode);
	fclose($fp);
	$_SESSION['last_report']=$report_name;
	header("location:analysis_report.php");
}else{
        new AuditLog('Unauthorized access to report_pdf ');
        header("location: goto_home.php");
}
?>
Return current item: Ptk-forensics