Exemple #1
0
	function SearchDefault(&$result, $s, $colors, $colors2) {
		error_reporting(-1);
		ini_set('display_errors', '1');
	
		/* escape all the variables and put them back into meaningful variable names */
		foreach ($s as $key => $value) {
			if (is_scalar($value)) { $$key = mysql_real_escape_string($s[$key]); }
			else { $$key = $s[$key]; }
		}
	
		/* ---------------- regular search --------------- */
		$s_studymodality = strtolower($s_studymodality);
		$sqlstring3 = "select data_id, rating_value from ratings where rating_type = 'series' and data_modality = '$s_studymodality'";
		$result3 = MySQLQuery($sqlstring3,__FILE__,__LINE__);
		while ($row3 = mysql_fetch_array($result3, MYSQL_ASSOC)) {
			//$ratingseriesids[] = $row3['data_id'];
			$ratingseriesid = $row3['data_id'];
			$ratings[$ratingseriesid][] = $row3['rating_value'];
		}
		?>
		<br><br>
		<form name="subjectlist" method="post" action="search.php">
		<input type="hidden" name="modality" value="<?php 
echo $s_studymodality;
?>
">
		<input type="hidden" name="action" value="submit">
		<?
		
		if (strtolower($s_studymodality) == "mr") {
			/* get the movement & SNR stats by sequence name */
			$sqlstring2 = "SELECT b.series_sequencename, max(a.move_maxx) 'maxx', min(a.move_minx) 'minx', max(a.move_maxy) 'maxy', min(a.move_miny) 'miny', max(a.move_maxz) 'maxz', min(a.move_minz) 'minz', avg(a.pv_snr) 'avgpvsnr', avg(a.io_snr) 'avgiosnr', std(a.pv_snr) 'stdpvsnr', std(a.io_snr) 'stdiosnr', min(a.pv_snr) 'minpvsnr', min(a.io_snr) 'miniosnr', max(a.pv_snr) 'maxpvsnr', max(a.io_snr) 'maxiosnr', min(a.motion_rsq) 'minmotion', max(a.motion_rsq) 'maxmotion', avg(a.motion_rsq) 'avgmotion', std(a.motion_rsq) 'stdmotion' FROM mr_qa a left join mr_series b on a.mrseries_id = b.mrseries_id where a.io_snr > 0 group by b.series_sequencename";
			//echo "$sqlstring2<br>";
			$result2 = MySQLQuery($sqlstring2,__FILE__,__LINE__);
			while ($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)) {
				$sequence = $row2['series_sequencename'];
				$pstats[$sequence]['avgpvsnr'] = $row2['avgpvsnr'];
				$pstats[$sequence]['stdpvsnr'] = $row2['stdpvsnr'];
				$pstats[$sequence]['minpvsnr'] = $row2['minpvsnr'];
				$pstats[$sequence]['maxpvsnr'] = $row2['maxpvsnr'];
				$pstats[$sequence]['avgiosnr'] = $row2['avgiosnr'];
				$pstats[$sequence]['stdiosnr'] = $row2['stdiosnr'];
				$pstats[$sequence]['miniosnr'] = $row2['miniosnr'];
				$pstats[$sequence]['maxiosnr'] = $row2['maxiosnr'];
				$pstats[$sequence]['avgmotion'] = $row2['avgmotion'];
				$pstats[$sequence]['stdmotion'] = $row2['stdmotion'];
				$pstats[$sequence]['minmotion'] = $row2['minmotion'];
				$pstats[$sequence]['maxmotion'] = $row2['maxmotion'];
	
				if ($row2['stdiosnr'] != 0) {
					$pstats[$sequence]['maxstdiosnr'] = ($row2['avgiosnr'] - $row2['miniosnr'])/$row2['stdiosnr'];
				} else { $pstats[$sequence]['maxstdiosnr'] = 0; }
				if ($row2['stdpvsnr'] != 0) {
					$pstats[$sequence]['maxstdpvsnr'] = ($row2['avgpvsnr'] - $row2['minpvsnr'])/$row2['stdpvsnr'];
				} else { $pstats[$sequence]['maxstdpvsnr'] = 0; }
				if ($row2['stdmotion'] != 0) {
					$pstats[$sequence]['maxstdmotion'] = ($row2['avgmotion'] - $row2['minmotion'])/$row2['stdmotion'];
				} else { $pstats[$sequence]['maxstdmotion'] = 0; }
			}
			
			//print_r($pstats);
		}
		?>
		<? if ($s_resultorder == "table") { ?>
		<table width="100%" class="searchresultssheet">
		<? } else { ?>
		<table width="100%" class="searchresults">
		<? } ?>
			<script type="text/javascript">
			$(document).ready(function() {
				$("#seriesall").click(function() {
					var checked_status = this.checked;
					$(".allseries").find("input[type='checkbox']").each(function() {
						this.checked = checked_status;
					});
				});
			});
			</script>
		<?
		$projectids = array();
		$projectnames = array();

		/* get the users id */
		$sqlstringC = "select user_id from users where username = '******'username'] ."'";
		$resultC = MySQLQuery($sqlstringC,__FILE__,__LINE__);
		$rowC = mysql_fetch_array($resultC, MYSQL_ASSOC);
		$userid = $rowC['user_id'];
				
		/* check to see which projects this user has access to view */
		$sqlstringC = "select a.project_id 'projectid', b.project_name 'projectname' from user_project a left join projects b on a.project_id = b.project_id where a.user_id = $userid and (a.view_data = 1 or a.view_phi = 1)";
		//print "$sqlstringC<br>";
		$resultC = MySQLQuery($sqlstringC,__FILE__,__LINE__);
		while ($rowC = mysql_fetch_array($resultC, MYSQL_ASSOC)) {
			$projectids[] = $rowC['projectid'];
		}
		
		/* tell the user if there are results for projects they don't have access to */
		while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
			$projectid = $row['project_id'];
			$projectname = $row['project_name'];
			$studyid = $row['study_id'];
			$subjectid = $row['subject_id'];
			$uid = $row['uid'];

			if (!in_array($projectid, $projectids)) {
				//echo "$projectid is not in projectids<br>";
				if (!in_array($projectname, $projectnames)) {
					//echo "$projectname is not in projectnames<br>";
					$projectnames[] = $projectname;
				}
			}
			
			/* BUT: while we're in this loop, count the # of unique studies ... */
			if ((!isset($studies)) || (!in_array($studyid, $studies))) {
				$studies[] = $studyid;
			}
			/* ... and # of unique subjects */
			if ((!isset($subjects)) || (!in_array($subjectid, $subjects))) {
				$subjects[] = $subjectid;
			}
			/* also a unique list of UIDs */
			if ((!isset($uids)) || (!in_array($uid, $uids))) {
				$uids[] = $uid;
			}
		}
		
		/* get the measures, if requested */
		$measurenames = null;
		if ($s_measurelist != "") {
			$searchcriteria = ParseMeasureResultList($s_measurelist, "d.measure_name");
			
			if ($s_measurelist == "*") {
				$sqlstringD = "select a.subject_id, b.enrollment_id, c.*, d.measure_name from measures c join measurenames d on c.measurename_id = d.measurename_id left join enrollment b on c.enrollment_id = b.enrollment_id join subjects a on a.subject_id = b.subject_id where a.subject_id in (" . implode2(",", $subjects) . ")";
			}
			else {
				$sqlstringD = "select a.subject_id, b.enrollment_id, c.*, d.measure_name from measures c join measurenames d on c.measurename_id = d.measurename_id left join enrollment b on c.enrollment_id = b.enrollment_id join subjects a on a.subject_id = b.subject_id where a.subject_id in (" . implode2(",", $subjects) . ") and d.measure_name in (" . MakeSQLList($s_measurelist) . ")";
			}
			
			//PrintSQL($sqlstringD);
			$resultD = MySQLQuery($sqlstringD,__FILE__,__LINE__);
			//echo "<pre>";
			//print_r($sqlstringD);
			//echo "</pre>";
			//PrintSQLTable($resultD);
			//$i=0;
			while ($rowD = mysql_fetch_array($resultD, MYSQL_ASSOC)) {
				if ($rowD['measure_type'] == 's') {
					$measuredata[$rowD['subject_id']][$rowD['measure_name']]['value'] = $rowD['measure_valuestring'];
				}
				else {
					$measuredata[$rowD['subject_id']][$rowD['measure_name']]['value'] = $rowD['measure_valuenum'];
				}
				$measuredata[$rowD['subject_id']][$rowD['measure_name']]['notes'] = $rowD['measure_notes'];
				$measurenames[] = $rowD['measure_name'];
				//$i++;
			}
			$measurenames = array_unique($measurenames);
			natcasesort($measurenames);
			//echo "<pre>";
			//print_r($measurenames);
			//print_r($measuredata);
			//echo "</pre>";
		}
		
		/* if there was a list of UIDs or alternate UIDs, determine which were not found */
		if ($s['s_subjectuid'] != "") {
			$uidsearchlist = preg_split('/[\^,;\-\'\s\t\n\f\r]+/', $s['s_subjectuid']);
			$missinguids = array_diff($uidsearchlist,$uids);
		}
		if ($s['s_subjectaltuid'] != "") {
			$altuidsearchlist = preg_split('/[\^,;\-\'\s\t\n\f\r]+/', $s['s_subjectaltuid']);

			/* get list of UIDs from the list of alternate UIDs */
			$sqlstringX = "select altuid from subject_altuid a left join subjects b on a.subject_id = b.subject_id where a.altuid in (" . MakeSQLList($s['s_subjectaltuid']) . ")";
			$resultX = MySQLQuery($sqlstringX,__FILE__,__LINE__);
			while ($rowX = mysql_fetch_array($resultX, MYSQL_ASSOC)) {
				$altuids[] = $rowX['altuid'];
			}
			$missingaltuids = array_diff($altuidsearchlist,$altuids);
		}
		if ($s['s_subjectgroupid'] != "") {
			$subjectids = explode(',', GetIDListFromGroup($s['s_subjectgroupid']));
			$missingsubjects = array_diff($subjectids,$subjects);
			if (count($missingstudies) > 0) {
				$sqlstringY = "select uid from subjects where subject_id in (" . implode(',',$missingsubjects) . ")";
				$resultY = MySQLQuery($sqlstringY,__FILE__,__LINE__);
				while ($rowY = mysql_fetch_array($resultY, MYSQL_ASSOC)) {
					$missinguids[] = $rowY['uid'];
				}
			}
		}
		if ($s['s_studygroupid'] != "") {
			$studyids = explode(',', GetIDListFromGroup($s['s_studygroupid']));
			$missingstudies = array_diff($studyids,$studies);
			//PrintVariable($studies,'studies');
			if (count($missingstudies) > 0) {
				$sqlstringY = "select a.study_num, c.uid from studies a left join enrollment b on a.enrollment_id = b.enrollment_id left join subjects c on c.subject_id = b.subject_id where study_id in (" . implode(',',$missingstudies) . ")";
				$resultY = MySQLQuery($sqlstringY,__FILE__,__LINE__);
				while ($rowY = mysql_fetch_array($resultY, MYSQL_ASSOC)) {
					$missingstudynums[] = $rowY['uid'] . $rowY['study_num'];
				}
			}
		}
		?>
		Found <b><?php 
echo count($subjects);
?>
 subjects</b> in <b><?php 
echo count($studies);
?>
 studies</b> with <b><?php 
echo mysql_num_rows($result);
?>
 series</b> matching your query<!-- &nbsp; &nbsp; <span class="sublabel">Query took <?php 
echo number_format($querytime, 4);
?>
 sec to execute</span>-->
		<?
			if (count($missinguids) > 0) {
			?>
				<details>
				<summary style="font-size:9pt; background-color: orangered; color: white;"><?php 
echo count($missinguids);
?>
 UIDs not found</summary>
				<span style="font-size:9pt"><?php 
echo implode('<br>', $missinguids);
?>
</span>
				</details>
			<?
			}
			elseif ($uidsearchlist != '') {
			?>
				<br><span style="font-size:8pt">All UIDs found</span>
			<?
			}
			
			if (count($missingaltuids) > 0) {
			?>
				<details>
				<summary style="font-size:9pt; background-color: orangered; color: white;"><?php 
echo count($missingaltuids);
?>
 alternate UIDs not found</summary>
				<span style="font-size:9pt"><?php 
echo implode('<br>', $missingaltuids);
?>
</span>
				</details>
			<?
			}
			elseif ($altuidsearchlist != '') {
			?>
				<br><span style="font-size:8pt">All alternate UIDs found</span>
			<?
			}
			
			if (count($missingstudynums) > 0) {
			?>
				<details>
				<summary style="font-size:9pt; background-color: orangered; color: white;"><?php 
echo count($missingstudynums);
?>
 Studies not found</summary>
				<span style="font-size:9pt"><?php 
echo implode('<br>', $missingstudynums);
?>
</span>
				</details>
			<?
			}
			elseif ($uidsearchlist != '') {
			?>
				<br><span style="font-size:8pt">All UIDs found</span>
			<?
			}
		?>
		<br><br>
		<?
		if (count($projectnames) > 0) {
		?>
			<div style="border: 2px solid darkred; background-color: #FFEEEE; text-align: left; padding:5px; border-radius: 5px">
			<b>Your search results contain subjects enrolled in the following projects to which you do not have view access</b>
			<br>Contact your PI or project administrator for access
			<ul>
			<?
			natcasesort($projectnames);
			foreach ($projectnames as $projectname) {
				echo "<li>$projectname</li>\n";
			}
			?>
			</ul>
			</div>
			<?
		}
		
		/* ----- loop through the results and display them ----- */
		mysql_data_seek($result,0); /* rewind the record pointer */
		$laststudy_id = "";
		$headeradded = 0;
		while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
			//echo "<pre>";
			//print_r($row);
			//echo "</pre>";
			
			$project_id = $row['project_id'];
			/* if the user doesn't have view access to this project, skip to the next record */
			if (($projectids == null) || (!in_array($project_id, $projectids))) {
				continue;
			}
			$enrollment_id = $row['enrollment_id'];
			$subject_id = $row['subject_id'];
			$project_name = $row['project_name'];
			$project_costcenter = $row['project_costcenter'];
			$name = $row['name'];
			$birthdate = $row['birthdate'];
			$gender = $row['gender'];
			$uid = $row['uid'];
			$subject_id = $row['subject_id'];
			$study_id = $row['study_id'];
			$study_num = $row['study_num'];
			$study_desc = $row['study_desc'];
			$study_type = $row['study_type'];
			$study_height = $row['study_height'];
			$study_weight = $row['study_weight'];
			$study_alternateid = $row['study_alternateid'];
			$study_modality = strtolower($row['study_modality']);
			$study_datetime = $row['study_datetime'];
			$study_ageatscan = $row['study_ageatscan'];
			$study_type = $row['study_type'];
			$study_operator = $row['study_operator'];
			$study_performingphysician = $row['study_performingphysician'];
			$study_site = $row['study_site'];
			$study_institution = $row['study_institution'];
			$enrollsubgroup = $row['enroll_subgroup'];

			/* get list of alternate subject UIDs */
			$altuids = GetAlternateUIDs($subject_id);
			if (count($altuids) > 0) {
				$altuidlist = implode2(",",$altuids);
			}
			else {
				$altuidlist = "";
			}
			
			/* calculate the BMI */
			if (($study_height == 0) || ($study_weight == 0)) {
				$study_bmi = 0;
			}
			else {
				$study_bmi = $study_weight / ( $study_height * $study_height);
			}

			$newstudyid = $uid . $study_num;

			/* calculate age at scan */
			if (($study_ageatscan == '') || ($study_ageatscan == 0)) {
				list($year, $month, $day) = explode("-", $birthdate);
				$d1 = mktime(0,0,0,$month,$day,$year);
				list($year, $month, $day, $extra) = explode("-", $study_datetime);
				$d2 = mktime(0,0,0,$month,$day,$year);
				$ageatscan = floor(($d2-$d1)/31536000);
			}
			else {
				$ageatscan = $study_ageatscan;
			}

			/* fix some fields */
			list($lname, $fname) = explode("^",$name);
			$name = strtoupper(substr($fname,0,1)) . strtoupper(substr($lname,0,1));
			$study_desc = str_replace("^"," ",$study_desc);
			if (($s_resultorder == "study") || ($s_resultorder == "export")) {
				$study_datetime = date("M j, Y g:ia",strtotime($study_datetime));
			}
			else {
				$study_datetime = date("Y-m-d H:i",strtotime($study_datetime));
			}

			/* gather series specific info based on modality */
			if ($study_modality == "mr") {
				$series_id = $row['mrseries_id'];
				$series_datetime = $row['series_datetime'];
				$series_desc = $row['series_desc'];
				$series_altdesc = $row['series_altdesc'];
				$sequence = $row['series_sequencename'];
				$series_num = $row['series_num'];
				$series_tr = $row['series_tr'];
				$series_spacingx = $row['series_spacingx'];
				$series_spacingy = $row['series_spacingy'];
				$series_spacingz = $row['series_spacingz'];
				$series_fieldstrength = $row['series_fieldstrength'];
				$series_notes = $row['series_notes'];
				$img_rows = $row['img_rows'];
				$img_cols = $row['img_cols'];
				$img_slices = $row['img_slices'];
				$bold_reps = $row['bold_reps'];
				$numfiles = $row['numfiles'];
				$series_size = $row['series_size'];
				$numfiles_beh = $row['numfiles_beh'];
				$beh_size = $row['beh_size'];
				$series_status = $row['series_status'];
				$is_derived = $row['is_derived'];
				$move_minx = $row['move_minx'];
				$move_miny = $row['move_miny'];
				$move_minz = $row['move_minz'];
				$move_maxx = $row['move_maxx'];
				$move_maxy = $row['move_maxy'];
				$move_maxz = $row['move_maxz'];
				$rot_maxp = $row['rot_maxp'];
				$rot_maxr = $row['rot_maxr'];
				$rot_maxy = $row['rot_maxy'];
				$rot_minp = $row['rot_minp'];
				$rot_minr = $row['rot_minr'];
				$rot_miny = $row['rot_miny'];
				$iosnr = $row['io_snr'];
				$pvsnr = $row['pv_snr'];
				$motion_rsq = $row['motion_rsq'];
				
				$thumbpath = $GLOBALS['cfg']['archivedir'] . "/$uid/$study_num/$series_num/thumb.png";
				$gifthumbpath = $GLOBALS['cfg']['archivedir'] . "/$uid/$study_num/$series_num/thumb.gif";
				$realignpath = $GLOBALS['cfg']['archivedir'] . "/$uid/$study_num/$series_num/MotionCorrection.txt";
				
				$series_datetime = date("g:ia",strtotime($series_datetime));
				$series_size = HumanReadableFilesize($series_size);
				$beh_size = HumanReadableFilesize($beh_size);
				
				if (($sequence == "epfid2d1_64") && ($numfiles_beh < 1)) { $behcolor = "red"; } else { $behcolor = ""; }
				/* format the colors for realignment and SNR */
				$rangex = abs($move_minx) + abs($move_maxx);
				$rangey = abs($move_miny) + abs($move_maxy);
				$rangez = abs($move_minz) + abs($move_maxz);
				$rangePitch = abs($rot_minp) + abs($rot_maxp);
				$rangeRoll = abs($rot_minr) + abs($rot_maxr);
				$rangeYaw = abs($rot_miny) + abs($rot_maxy);
				
				/* calculate color based on voxel size... red (100) means more than 1 voxel displacement in that direction */
				if ($series_spacingx > 0) { $xindex = round(($rangex/$series_spacingx)*100); if ($xindex > 100) { $xindex = 100; } }
				if ($series_spacingy > 0) { $yindex = round(($rangey/$series_spacingy)*100); if ($yindex > 100) { $yindex = 100; } }
				if ($series_spacingz > 0) { $zindex = round(($rangez/$series_spacingz)*100); if ($zindex > 100) { $zindex = 100; } }

				/* get standard deviations from the mean for SNR */
				if ($pstats[$sequence]['stdiosnr'] != 0) {
					if ($iosnr > $pstats[$sequence]['avgiosnr']) {
						$stdsiosnr = 0;
					}
					else {
						$stdsiosnr = (($iosnr - $pstats[$sequence]['avgiosnr'])/$pstats[$sequence]['stdiosnr']);
					}
				}
				if ($pstats[$sequence]['stdpvsnr'] != 0) {
					if ($pvsnr > $pstats[$sequence]['avgpvsnr']) {
						$stdspvsnr = 0;
					}
					else {
						$stdspvsnr = (($pvsnr - $pstats[$sequence]['avgpvsnr'])/$pstats[$sequence]['stdpvsnr']);
					}
				}
				if ($pstats[$sequence]['stdmotion'] != 0) {
					if ($motion_rsq > $pstats[$sequence]['avgmotion']) {
						$stdsmotion = 0;
					}
					else {
						$stdsmotion = (($motion_rsq - $pstats[$sequence]['avgmotion'])/$pstats[$sequence]['stdmotion']);
					}
				}
				
				if ($pstats[$sequence]['maxstdpvsnr'] == 0) { $pvindex = 100; }
				else { $pvindex = round(($stdspvsnr/$pstats[$sequence]['maxstdpvsnr'])*100); }
				$pvindex = 100 + $pvindex;
				if ($pvindex > 100) { $pvindex = 100; }
				
				if ($pstats[$sequence]['maxstdiosnr'] == 0) { $ioindex = 100; }
				else { $ioindex = round(($stdsiosnr/$pstats[$sequence]['maxstdiosnr'])*100); }
				$ioindex = 100 + $ioindex;
				if ($ioindex > 100) { $ioindex = 100; }
				
				if ($pstats[$sequence]['maxstdmotion'] == 0) { $motionindex = 100; }
				else { $motionindex = round(($stdsmotion/$pstats[$sequence]['maxstdmotion'])*100); }
				$motionindex = 100 + $motionindex;
				if ($motionindex > 100) { $motionindex = 100; }
				
				$maxpvsnrcolor = $colors[100-$pvindex];
				$maxiosnrcolor = $colors[100-$ioindex];
				$maxmotioncolor = $colors[100-$motionindex];
				if ($pvsnr <= 0.0001) { $pvsnr = "-"; $maxpvsnrcolor = "#FFFFFF"; }
				else { $pvsnr = number_format($pvsnr,2); }
				if ($iosnr <= 0.0001) { $iosnr = "-"; $maxiosnrcolor = "#FFFFFF"; }
				else { $iosnr = number_format($iosnr,2); }
				if ($motion_rsq <= 0.0001) { $motion_rsq = "-"; $maxmotioncolor = ""; }
				else { $motion_rsq = number_format($motion_rsq,5); }
				
				/* setup movement colors */
				$maxxcolor = $colors[$xindex];
				$maxycolor = $colors[$yindex];
				$maxzcolor = $colors[$zindex];
				if ($rangex <= 0.0001) { $rangex = "-"; $maxxcolor = "#FFFFFF"; }
				else { $rangex = number_format($rangex,2); }
				if ($rangey <= 0.0001) { $rangey = "-"; $maxycolor = "#FFFFFF"; }
				else { $rangey = number_format($rangey,2); }
				if ($rangez <= 0.0001) { $rangez = "-"; $maxzcolor = "#FFFFFF"; }
				else { $rangez = number_format($rangez,2); }
				
				/* check if this is real data, or unusable data based on the ratings, and get rating counts */
				$isbadseries = false;
				$istestseries = false;
				$ratingcount2 = '';
				$hasratings = false;
				$rowcolor = '';
				if (isset($ratings)) {
					foreach ($ratings as $key => $ratingarray) {
						if ($key == $series_id) {
							$hasratings = true;
							if (in_array(5,$ratingarray)) {
								$isbadseries = true;
								//echo "IsBadSeries is true";
							}
							if (in_array(6,$ratingarray)) {
								$istestseries = true;
							}
							$ratingcount2 = count($ratingarray);
							break;
						}
					}
				}
				if ($isbadseries) { $rowcolor = "red"; }
				if ($istestseries) { $rowcolor = "#AAAAAA"; }
			}
			else {
				$series_id = $row[$study_modality . 'series_id'];
				$series_num = $row['series_num'];
				$series_datetime = $row['series_datetime'];
				$series_protocol = $row['series_protocol'];
				$series_numfiles = $row['series_numfiles'];
				$series_size = $row['series_size'];
				$series_notes = $row['series_notes'];
				
				$series_datetime = date("g:ia",strtotime($series_datetime));
				if ($series_numfiles < 1) { $series_numfiles = "-"; }
				if ($series_size > 1) { $series_size = HumanReadableFilesize($series_size); } else { $series_size = "-"; }
			}
			
			/* display study header if study */
			if ($study_id != $laststudy_id) {
				if (($s_resultorder == "study") || ($s_resultorder == "export")) {
					/* display study header */
					?>
					<script type="text/javascript">
					$(document).ready(function() {
						$("#study<?php 
echo $study_id;
?>
").click(function() {
							var checked_status = this.checked;
							$(".tr<?php 
echo $study_id;
?>
").find("input[type='checkbox']").each(function() {
								this.checked = checked_status;
							});
						});
					});
					</script>
					<tr>
						<td colspan="19">
							<br>
							<table width="100%" class="searchresultstudy">
								<tr>
									<td class="header1"><?php 
echo $name;
?>
</td>
									<td class="header1"><a href="subjects.php?id=<?php 
echo $subject_id;
?>
" class="header1"><?php 
echo $uid;
?>
</a></td>
									<td class="header3"><?php 
echo $altuidlist;
?>
</td>
									<td class="header2"><a href="studies.php?id=<?php 
echo $study_id;
?>
">Study <?php 
echo $study_num;
?>
</a> <?php 
echo $study_type;
?>
</td>
									<td class="header2"><?php 
echo $project_name;
?>
 (<?php 
echo $project_costcenter;
?>
)</td>
									<td class="header2"><?php 
echo $study_datetime;
?>
</td>
									<td class="header3"><?php 
echo $enrollsubgroup;
?>
</td>
									<td class="header3"><?php 
echo number_format($ageatscan, 1);
?>
Y</td>
									<td class="header3"><?php 
echo $gender;
?>
</td>
									<td class="header3"><?php 
echo $study_alternateid;
?>
</td>
									<td class="header3"><?php 
echo $study_type;
?>
</td>
									<td class="header3"><?php 
echo $study_site;
?>
</td>
								</tr>
							</table>
						</td>
					</tr>
					<?
				}
				/* display the series header only once */
				if ($study_modality == "mr") {
					if (($laststudy_id == "") && ($s_resultorder != "study") && ($s_resultorder != "export") && ($s_resultorder != "csv")) {
						DisplayMRSeriesHeader($s_resultorder, $measurenames);
					}
					if (($s_resultorder == "study") || ($s_resultorder == "export")) {
						DisplayMRStudyHeader($study_id, true, $measurenames);
					}
					if ($s_resultorder == "csv") {
						if (!$headeradded) {
							$header = DisplayMRStudyHeader($study_id, false, $measurenames);
							$csv .= "$header";
							if (count($measurenames) > 0) {
								foreach ($measurenames as $measurename) {
									$csv .= ",$measurename";
								}
							}
							$csv .= "\n";
						}
						$headeradded = 1;
					}
				}
				else {
					if (($laststudy_id == "") && ($s_resultorder != "study") && ($s_resultorder != "export")) {
						DisplayGenericSeriesHeader($s_resultorder);
					}
					if (($s_resultorder == "study") || ($s_resultorder == "export")) {
						DisplayGenericStudyHeader($study_id);
					}
				}
			}
			/* set the css class for the rows */
			if (($s_resultorder == "series") || ($s_resultorder == "table") || ($s_resultorder == "operations")) {
				$rowstyle = "seriesrowsmall";
			}
			else {
				$rowstyle = "seriesrow";
			}
			/* and then display the series... */
			if ($study_modality == "mr") {
				if ($s_resultorder == "csv") {
					if ($s_usealtseriesdesc) {
						$csv .= "$series_num, $series_altdesc, $uid, $gender, $ageatscan, " . implode2(' ',$altuids) . ", $newstudyid, $study_alternateid, $study_type, $study_num, $study_datetime, $study_type, $project_name($project_costcenter), $study_height, $study_weight, $study_bmi, $series_datetime, $move_minx, $move_miny, $move_minz, $move_maxx, $move_maxy, $move_maxz, $rangex, $rangey, $rangez, $rangePitch, $rangeRoll, $rangeYaw, $pvsnr, $iosnr, $img_cols, $img_rows, $numfiles, $series_size, $sequence, $series_tr, $numfiles_beh, $beh_size";
					}
					else {
						$csv .= "$series_num, $series_desc, $uid, $gender, $ageatscan, " . implode2(' ',$altuids) . ", $newstudyid, $study_alternateid, $study_type, $study_num, $study_datetime, $study_type, $project_name($project_costcenter), $study_height, $study_weight, $study_bmi, $series_datetime, $move_minx, $move_miny, $move_minz, $move_maxx, $move_maxy, $move_maxz, $rangex, $rangey, $rangez, $rangePitch, $rangeRoll, $rangeYaw, $pvsnr, $iosnr, $img_cols, $img_rows, $numfiles, $series_size, $sequence, $series_tr, $numfiles_beh, $beh_size";
					}
					if (count($measurenames) > 0) {
						foreach ($measurenames as $measure) {
							$csv .= "," . $measuredata[$subject_id][$measure]['value'];
						}
					}
					$csv .= "\n";
				}
				else {
				?>
					<tr class="tr<?php 
echo $study_id;
?>
 allseries" style="color: <?php 
echo $rowcolor;
?>
; white-space: nowrap">
						<? if ($s_resultorder != "table") { ?>
							<td class="<?php 
echo $rowstyle;
?>
"><input type="checkbox" name="seriesid[]" value="<?php 
echo $series_id;
?>
"></td>
						<? } ?>
						<td class="<?php 
echo $rowstyle;
?>
"><b><?php 
echo $series_num;
?>
</b></td>
						<td class="<?php 
echo $rowstyle;
?>
">
							<!--<a href="protocols.php?action=viewprotocol&protocol=<?php 
echo $series_desc;
?>
" rel="protocols.php?action=viewprotocol&protocol=<?php 
echo $series_desc;
?>
" class="wide cluetip-default" title="Protocol Info">-->
							<span><? if ($s_usealtseriesdesc) { echo $series_altdesc; } else { echo $series_desc; } ?></span></a>
							&nbsp;<a href="preview.php?image=<?php 
echo $thumbpath;
?>
" class="preview"><img src="images/preview.gif" border="0"></a>
							&nbsp;<a href="preview.php?image=<?php 
echo $gifthumbpath;
?>
" class="preview"><img src="images/movie.png" border="0"></a>
						</td>
						<? if (($s_resultorder == "series") || ($s_resultorder == "table") || ($s_resultorder == "operations")) { ?>
							<td class="<?php 
echo $rowstyle;
?>
"><a href="subjects.php?id=<?php 
echo $subject_id;
?>
"><tt><?php 
echo $uid;
?>
</tt></a></td>
							<td class="<?php 
echo $rowstyle;
?>
"><?php 
echo $gender;
?>
</td>
							<td class="<?php 
echo $rowstyle;
?>
"><?php 
echo number_format($ageatscan, 1);
?>
Y</td>
							<td class="<?php 
echo $rowstyle;
?>
"><a href="subjects.php?id=<?php 
echo $subject_id;
?>
"><tt><? if (count($altuids) > 0) { echo implode2(', ',$altuids); } ?></tt></a></td>
							<td class="<?php 
echo $rowstyle;
?>
"><a href="studies.php?id=<?php 
echo $study_id;
?>
"><?php 
echo $newstudyid;
?>
</a></td>
							<td class="<?php 
echo $rowstyle;
?>
"><a href="studies.php?id=<?php 
echo $study_id;
?>
"><?php 
echo $study_alternateid;
?>
</a></td>
							<td class="<?php 
echo $rowstyle;
?>
"><a href="studies.php?id=<?php 
echo $study_id;
?>
"><?php 
echo $study_type;
?>
</a></td>
							<td class="<?php 
echo $rowstyle;
?>
"><a href="studies.php?id=<?php 
echo $study_id;
?>
"><?php 
echo $study_num;
?>
</a></td>
							<td class="<?php 
echo $rowstyle;
?>
"><?php 
echo $study_datetime;
?>
</td>
							<td class="<?php 
echo $rowstyle;
?>
"><?php 
echo $series_datetime;
?>
</td>
						<? } else { ?>
							<td class="<?php 
echo $rowstyle;
?>
"><?php 
echo $series_datetime;
?>
</td>
						<? } ?>
						<td class="<?php 
echo $rowstyle;
?>
" align="right" style="background-color: <?php 
echo $maxxcolor;
?>
;"><?php 
echo $rangex;
?>
</td>
						<td class="<?php 
echo $rowstyle;
?>
" align="right" style="background-color: <?php 
echo $maxycolor;
?>
;"><?php 
echo $rangey;
?>
</td>
						<td class="<?php 
echo $rowstyle;
?>
" align="right" style="background-color: <?php 
echo $maxzcolor;
?>
;"><?php 
echo $rangez;
?>
</td>
						<? if ($s_resultorder != "table") { ?>
						<td class="<?php 
echo $rowstyle;
?>
" style="padding: 0px 5px;">
							<a href="JavaScript:newPopup('mrseriesqa.php?id=<?php 
echo $series_id;
?>
');"><img src="images/chart.gif" border="0" title="View QA results, including movement correction"></a>
						</td>
						<td class="<?php 
echo $rowstyle;
?>
" style="padding: 0px 5px;">
							<span style="font-size:7pt"><?php 
echo $ratingcount2;
?>
</span>
							<a href="JavaScript:newPopup('ratings.php?id=<?php 
echo $series_id;
?>
&type=series&modality=mr');">
							<? if ($hasratings) { $image = "rating2.png"; } else { $image = "rating.png"; } ?>
							<img src="images/<?php 
echo $image;
?>
" border="0" title="View ratings">
							</a>
						</td>
						<td class="<?php 
echo $rowstyle;
?>
">
							<? if (trim($series_notes) != "") { ?>
							<span title="<?php 
echo $series_notes;
?>
" style="font-size:12pt">&#9998;</span>
							<? } ?>
						</td>
						<? } ?>
						<td class="<?php 
echo $rowstyle;
?>
" align="right" style="background-color: <?php 
echo $maxpvsnrcolor;
?>
;">
							<a href="stddevchart.php?h=40&w=450&min=<?php 
echo $pstats[$sequence]['minpvsnr'];
?>
&max=<?php 
echo $pstats[$sequence]['maxpvsnr'];
?>
&mean=<?php 
echo $pstats[$sequence]['avgpvsnr'];
?>
&std=<?php 
echo $pstats[$sequence]['stdpvsnr'];
?>
&i=<?php 
echo $pvsnr;
?>
&b=yes" class="preview" style="color: black; text-decoration: none"><?php 
echo $pvsnr;
?>
</a> 
						</td>
						<td class="<?php 
echo $rowstyle;
?>
" align="right" style="background-color: <?php 
echo $maxiosnrcolor;
?>
;">
							<a href="stddevchart.php?h=40&w=450&min=<?php 
echo $pstats[$sequence]['miniosnr'];
?>
&max=<?php 
echo $pstats[$sequence]['maxiosnr'];
?>
&mean=<?php 
echo $pstats[$sequence]['avgiosnr'];
?>
&std=<?php 
echo $pstats[$sequence]['stdiosnr'];
?>
&i=<?php 
echo $iosnr;
?>
&b=yes" class="preview" style="color: black; text-decoration: none"><?php 
echo $iosnr;
?>
</a>
						</td>
						<td class="<?php 
echo $rowstyle;
?>
" align="right" style="background-color: <?php 
echo $maxmotioncolor;
?>
; font-size:8pt">
							<a href="stddevchart.php?h=40&w=450&min=<?php 
echo $pstats[$sequence]['minmotion'];
?>
&max=<?php 
echo $pstats[$sequence]['maxmotion'];
?>
&mean=<?php 
echo $pstats[$sequence]['avgmotion'];
?>
&std=<?php 
echo $pstats[$sequence]['stdmotion'];
?>
&i=<?php 
echo $motion_rsq;
?>
&b=yes" class="preview" style="color: black; text-decoration: none"><?php 
echo $motion_rsq;
?>
</a>
						</td>
						<td class="<?php 
echo $rowstyle;
?>
"><?php 
echo $img_cols;
?>
&times;<?php 
echo $img_rows;
?>
</td>
						<td class="<?php 
echo $rowstyle;
?>
">
							<?php 
echo $numfiles;
?>
							<?
								if ($s_audit) {
									$files = glob($GLOBALS['cfg']['archivedir'] . "/$uid/$study_num/$series_num/dicom/*.dcm");
									//print_r($files);
									if (count($files) != $numfiles) { ?><span style="color: white; background-color: red; padding: 1px 5px; font-weight: bold"><?php 
echo count($files);
?>
</span> <? }
								}
							?>
						</td>
						<td class="<?php 
echo $rowstyle;
?>
"><?php 
echo $series_size;
?>
</td>
						<td class="<?php 
echo $rowstyle;
?>
"><?php 
echo $sequence;
?>
</td>
						<td class="<?php 
echo $rowstyle;
?>
"><?php 
echo $series_tr;
?>
</td>
						<? if ($s_resultorder != "table") { ?>
						<td class="<?php 
echo $rowstyle;
?>
" bgcolor="<?php 
echo $behcolor;
?>
"><?php 
echo $numfiles_beh;
?>
 <span class="tiny">(<?php 
echo $beh_size;
?>
)</span></td>
						<? }
							if (count($measurenames) > 0) {
								foreach ($measurenames as $measure) {
								?>
								<td class="<?php 
echo $rowstyle;
?>
"><?php 
echo $measuredata[$subject_id][$measure]['value'];
?>
</td>
								<?
								}
							}
						?>
					</tr>
					<?
				}
			}
			else {
				?>
				<tr class="tr<?php 
echo $study_id;
?>
 allseries">
					<? if ($s_resultorder != "table") { ?>
						<td class="<?php 
echo $rowstyle;
?>
"><input type="checkbox" name="seriesid[]" value="<?php 
echo $series_id;
?>
"></td>
					<? } ?>
					<td class="<?php 
echo $rowstyle;
?>
"><b><?php 
echo $series_num;
?>
</b></td>
					<td class="<?php 
echo $rowstyle;
?>
"><?php 
echo $series_protocol;
?>
</td>
					<? if (($s_resultorder == "series") || ($s_resultorder == "table") || ($s_resultorder == "operations")) { ?>
						<td class="<?php 
echo $rowstyle;
?>
"><tt><?php 
echo $uid;
?>
</tt></td>
						<td class="<?php 
echo $rowstyle;
?>
"><a href="subjects.php?id=<?php 
echo $subject_id;
?>
"><tt><?php 
echo implode2(', ', $altuids);
?>
</tt></a></td>
						<td class="<?php 
echo $rowstyle;
?>
"><a href="studies.php?id=<?php 
echo $study_id;
?>
"><?php 
echo $study_num;
?>
</a></td>
						<td class="<?php 
echo $rowstyle;
?>
"><?php 
echo $study_datetime;
?>
</td>
						<td class="<?php 
echo $rowstyle;
?>
"><?php 
echo $series_datetime;
?>
</td>
					<? } else { ?>
						<td class="<?php 
echo $rowstyle;
?>
"><?php 
echo $series_datetime;
?>
</td>
					<? } ?>
					<td class="<?php 
echo $rowstyle;
?>
"><?php 
echo $series_numfiles;
?>
</td>
					<td class="<?php 
echo $rowstyle;
?>
"><?php 
echo $series_size;
?>
</td>
					<td class="<?php 
echo $rowstyle;
?>
"><?php 
echo $series_notes;
?>
</td>
				</tr>
				<?
			}

			$laststudy_id = $study_id;
		}

		/* ---------- generate csv file ---------- */
		if ($s_resultorder == "csv") {
			$filename = "query" . GenerateRandomString(10) . ".csv";
			file_put_contents("/tmp/" . $filename, $csv);
			?>
			<div width="50%" align="center" style="background-color: #FAF8CC; padding: 5px;">
			Download .csv file <a href="download.php?type=file&filename=<?php 
echo "/tmp/{$filename}";
?>
"><img src="images/download16.png"></a>
			</div>
			<?
		}
		?>
		</table>
		
		<?
			/* ---------- display download/group box ---------- */
			if (($s_resultorder == "study") || ($s_resultorder == "series") || ($s_resultorder == "export")) {
				DisplayDownloadBox($s_studymodality, $s_resultorder);
			}
			elseif ($s_resultorder == "operations") {
				DisplayFileIOBox();
			}
		?>
		<br><br><br>
		<?
	}
Exemple #2
0
	function DisplayStats() {
	
		$urllist['Statistics'] = "stats.php";
		NavigationBar("Stats", $urllist);

		$currentyear = date("Y");
		
		$sqlstring = "select count(*) count from subjects where isactive = 1";
		$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$numsubjects = number_format($row['count']);
		$numtotalsubjects = $row['count'];

		$sqlstring = "select count(*) count from studies";
		$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$numstudies = $row['count'];

		$totalseries = 0;
		$totalsize = 0;
		$sqlstring = "show tables from " . $GLOBALS['cfg']['mysqldatabase'] . " like '%_series'";
		$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
		while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
			//print_r($row);
			$tablename = $row['Tables_in_' . $GLOBALS['cfg']['mysqldatabase'] . ' (%_series)'];
			//echo $tablename;
			$parts = explode("_", $tablename);
			$modality = $parts[0];
			
			$sqlstring2 = "select count(*) 'count', sum(series_size) 'size' from $modality" . "_series";
			$result2 = mysql_query($sqlstring2) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring2</i><br>");
			$row2 = mysql_fetch_array($result2, MYSQL_ASSOC);
			$totalseries += $row2['count'];
			$totalsize += $row2['size'];
			$seriescounts[$modality] = number_format($row2['count']);
			$seriessize[$modality] = HumanReadableFilesize($row2['size']);
		}
		
		/* total series qa time */
		$sqlstring = "select sum(cputime) totalcpu from mr_qa";
		$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$diff = $row['totalcpu'];
		$totalseriesqacpu = FormatCountdown($diff);

		/* total study qa time */
		$sqlstring = "select sum(cputime) totalcpu from mr_studyqa";
		$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$diff = $row['totalcpu'];
		$totalstudyqacpu = FormatCountdown($diff);
		
		/* total request processing time */
		$sqlstring = "select sum(req_cputime) totalrequestcpu from data_requests";
		$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$diff = $row['totalrequestcpu'];
		$totalrequestcpu = FormatCountdown($diff);
		
		/* mean request time */
		$sqlstring = "SELECT avg(time_to_sec(timediff(req_completedate, req_date))) avgtime FROM `data_requests` where req_completedate > '000-00-00 00:00:00'";
		$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$diff = $row['avgtime'];
		$avgrequesttime = FormatCountdown($diff);

		/* median request time */
		$sqlstring = "SELECT * FROM `data_requests` where req_completedate > '0000-00-00 00:00:00'";
		$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
		$numrows = mysql_num_rows($result);
		$med = round($numrows/2);
		
		$sqlstring = "SELECT time_to_sec(timediff(req_completedate, req_date)) avgtime FROM `data_requests` where req_completedate > '0000-00-00 00:00:00' order by avgtime limit $med,1";
		$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$diff = $row['avgtime'];
		$medianrequesttime = FormatCountdown($diff);
		
		$uptime = shell_exec('uptime');
		
		/* subject demographics */
		$sqlstring = "select (select count(*) from subjects where gender = 'F') 'numfemales', (select count(*) from subjects where gender = 'M') 'nummales', (select count(*) from subjects where gender = 'O') 'numother', (select count(*) from subjects where gender = 'U') 'numunknown', (select count(*) from subjects where gender not in ('F','M','O','U')) 'numnotspec'";
		$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$numfemales = $row['numfemales'];
		$nummales = $row['nummales'];
		$numother = $row['numother'];
		$numunknown = $row['numunknown'];
		$numnotspec = $row['numnotspec'];
		
		?>
		
		<table width="100%">
			<tr>
				<td valign="top" width="50%">
					<table class="bluerounded" width="100%">
						<tr>
							<td class="title">Series Info</td>
						</tr>
						<tr>
							<td class="body">
								<span style="font-size:10pt;">
								<b>Available Data:</b><br>
								<?php 
echo $numsubjects;
?>
 subjects<br>
								<?php 
echo number_format($numstudies);
?>
 studies<br>
								<br>
								<table class="smalldisplaytable">
									<tr>
										<th><b>Series</b></th>
										<th align="right"><b>Count</b></th>
										<th align="right"><b>Size</b></th>
									</tr>
								<?
									foreach ($seriescounts as $modality => $count) {
										?>
										<tr>
											<td><?php 
echo strtoupper($modality);
?>
</td>
											<td align="right"><?php 
echo $count;
?>
</td>
											<td align="right"><?php 
echo $seriessize[$modality];
?>
</td>
										</tr>
										<?
									}
								?>
									<tr style="color: #5882FA; font-weight: bold">
										<td>Total</td>
										<td align="right"><?php 
echo number_format($totalseries);
?>
</td>
										<td align="right"><?php 
echo HumanReadableFilesize($totalsize);
?>
</td>
									</tr>
								</table>
								</span>
							</td>
						</tr>
					</table>
					
					<br>
					
					<table class="bluerounded" width="100%">
						<tr>
							<td class="title">System Info</td>
						</tr>
						<tr>
							<td class="body">
								<span class="header">Uptime</span><br>
								<?php 
echo $uptime;
?>
								<br><bR>
								<span class="header">Data Requests</span><br>
								<b>CPU time:</b> <?php 
echo $totalrequestcpu;
?>
<br>
								<b>Mean request time:</b> <?php 
echo $avgrequesttime;
?>
<br>
								<b>Median request time:</b> <?php 
echo $medianrequesttime;
?>
<br>
							</td>
						</tr>
					</table>
					
					<br>
					
					<table class="bluerounded" width="100%">
						<tr>
							<td class="title">Subject Demographics</td>
						</tr>
						<tr>
							<td class="body">
								<table class="reviewtable">
									<tr>
										<td class="label"># females</td>
										<td class="value"><?php 
echo $numfemales;
?>
 (<?php 
echo number_format($numfemales / $numtotalsubjects * 100, 1);
?>
%)</td>
									</tr>
									<tr>
										<td class="label"># males</td>
										<td class="value"><?php 
echo $nummales;
?>
 (<?php 
echo number_format($nummales / $numtotalsubjects * 100, 1);
?>
%)</td>
									</tr>
									<tr>
										<td class="label"># other</td>
										<td class="value"><?php 
echo $numother;
?>
 (<?php 
echo number_format($numother / $numtotalsubjects * 100, 1);
?>
%)</td>
									</tr>
									<tr>
										<td class="label"># unknown</td>
										<td class="value"><?php 
echo $numunknown;
?>
 (<?php 
echo number_format($numunknown / $numtotalsubjects * 100, 1);
?>
%)</td>
									</tr>
									<tr>
										<td class="label"># not specified</td>
										<td class="value"><?php 
echo $numnotspec;
?>
 (<?php 
echo number_format($numnotspec / $numtotalsubjects * 100, 1);
?>
%)</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>					
				</td>
				<td valign="top" width="50%">
					<table class="bluerounded" width="100%">
						<tr>
							<td class="title">MR</td>
						</tr>
						<tr>
							<td class="body">
								<span class="header">CPU time</span><br>
								<b>Total series QA CPU time:</b> <?php 
echo $totalseriesqacpu;
?>
<br>
								<b>Total study QA CPU time:</b> <?php 
echo $totalstudyqacpu;
?>
<br>
							</td>
						</tr>
						<tr>
							<td class="body">
								<table cellspacing="0" cellpadding="2" style="font-size:10pt">
									<tr>
										<td colspan="24" align="center"><span class="header">Total # MR studies starting at time...</span></td>
									</tr>
									<tr>
										<td colspan="12" align="center" style="border-bottom: 1px solid gray; border-right: 1pt solid gray">AM</td>
										<td colspan="12" align="center" style="border-bottom: 1px solid gray">PM</td>
									</tr>
									<tr style="font-size:10pt">
										<?
											for ($hour=0;$hour<24;$hour++) {
												if ($hour == 0){
													?><td align="center" style="border-left: solid 1px #CCCCCC; border-right: solid 1px #CCCCCC;">12</td><?
												}
												else {
													if ($hour < 12) {
														?><td align="center" style="border-right: solid 1px #CCCCCC;"><?php 
echo $hour;
?>
</td><?
													}
													else {
														$hr = $hour;
														if ($hour != 12) {
															$hr = $hr - 12;
														}
														?><td align="center" style="border-right: solid 1px #CCCCCC;"><?php 
echo $hr;
?>
</td><?
													}
												}
											}
										?>
									</tr>
									<tr>
								<?
									for ($hour=0;$hour<24;$hour++) {
										$sqlstring = "select count(*) count from studies where hour(study_datetime) = $hour and study_modality = 'MR'";
										#echo "$sqlstring<br>";
										$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
										$row = mysql_fetch_array($result, MYSQL_ASSOC);
										$count = $row['count'];
										$percent = round(($count/$numstudies)*100);
										$counts[$hour] = $count;
										//echo "[$count] [$numstudies] [$percent]";
										#echo "<td align=right>$percent%&nbsp;</td>";
										?>
										<td valign="bottom" align="center" style="border-right: solid 1px #CCCCCC;">
											<table height="<? echo $percent*2; ?>px" cellpadding=0 cellspacing=0 width="15px">
												<tr>
													<td bgcolor="red" style="font-size: 0px">&nbsp;</td>
												</tr>
											</table>
										</td>
										<?
									}
									?> </tr><tr style="font-size:8pt"> <?
									for ($hour=0;$hour<24;$hour++) {
										echo "<td align=center>$counts[$hour]</td>";
									}
								?>
									</tr>
								</table>
								<br><br>
								<table cellspacing="0" cellpadding="2" style="font-size:10pt">
									<tr>
										<td colspan="13" align="center" style="border-bottom: 1pt solid darkgray"><span class="header">Scan History (# sessions per month)</span></td>
									</tr>
									<tr>
										<td>Year</td>
										<td>Jan</td>
										<td>Feb</td>
										<td>Mar</td>
										<td>Apr</td>
										<td>May</td>
										<td>Jun</td>
										<td>Jul</td>
										<td>Aug</td>
										<td>Sep</td>
										<td>Oct</td>
										<td>Nov</td>
										<td>Dec</td>
									</tr>
								<?
									$sqlstring = "select year(min(study_datetime)) firstyear from studies where study_datetime > '0000-00-00 00:00:01' and study_modality = 'MR'";
									$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
									$row = mysql_fetch_array($result, MYSQL_ASSOC);
									$firstyear = $row['firstyear'];
									
									$numyears = $currentyear - $firstyear;
									
									for ($year=$firstyear;$year<=$currentyear;$year++) {
										?>
										<tr>
											<td>
												<a href="reports.php?action=yearstudy&year=<?php 
echo $year;
?>
&modality=MR"><b><?php 
echo $year;
?>
</b></a>
											</td>
										<?
										for ($month=1;$month<=12;$month++) {
											$sqlstring = "select count(*) count from studies where year(study_datetime) = $year and month(study_datetime) = $month and study_modality = 'MR'";
											#echo "$sqlstring<br>";
											$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
											$row = mysql_fetch_array($result, MYSQL_ASSOC);
											$count = $row['count'];
											echo "<td align=right>$count &nbsp;</td>";
										}
										?>
										</tr>
										<?
									}
								?>
								</table>
								
							</td>
						</tr>
						<tr>
							<td class="body">
							<?
								$sqlstring = "SELECT (move_maxx-move_minx + move_maxy-move_miny + move_maxz-move_minz) 'totalmovement', datediff(c.study_datetime, e.birthdate) 'ageatscan', e.gender FROM mr_qa a left join mr_series b on a.mrseries_id = b.mrseries_id left join studies c on b.study_id = c.study_id left join enrollment d on c.enrollment_id = d.enrollment_id left join subjects e on d.subject_id = e.subject_id";
								$result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>$sqlstring</i><br>");
								$i=0;
								while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
									if (($row['totalmovement'] > 0) && ($row['totalmovement'] < 50)) {
										//print_r($row);
										$y[] = number_format($row['totalmovement'],2);
										$x[] = number_format($row['ageatscan']/365.25,2);
										if ($row['gender'] == 'F')
											$c[] = 'FF0000'; //$c[] = 'FFC0CB';
										elseif ($row['gender'] == 'M')
											$c[] = '0000FF'; //$c[] = '4169E1';
										else
											$c[] = '888888';
										$i++;
									}
									//if ($i>100) break;
								}
								//print_r($x);
								$chd = implode(",",$x) . "|" . implode(",",$y);
								$chco = implode("|",$c);
								
								$x = implode(",",$x);
								$y = implode(",",$y);
								$c = implode(",",$c);
								
								$chartfilename = DrawScatterPlot(600,400,$x,$y,$c);
							?>
							<b>Age vs movement</b><br>
							<img src="data:image/png;base64,<?php 
echo base64_encode(file_get_contents($chartfilename));
?>
">
							<?
								/* image data should've been sent to the browser, so delete the temp image */
								unlink($chartfilename);
							?>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		<?
	}
Exemple #3
0
function DisplayDownloadList()
{
    $urllist['Public Downloads'] = "publicdownloads.php";
    NavigationBar("Export", $urllist);
    ?>

	<table class="graydisplaytable">
		<thead>
			<tr>
				<th>Description</th>
				<th>Status</th>
				<th>Created</th>
				<th>Expires</th>
				<th>Release notes</th>
				<th>Zip size<br><span class="tiny">bytes</span></th>
				<th>Unzipped size<br><span class="tiny">bytes</span></th>
				<th>Creator</th>
				<th>Password</th>
				<th>Download link<br><span class="tiny">Copy link to use</span></th>
			</tr>
		</thead>
		<tbody>
			<?php 
    $sqlstring = "select * from public_downloads where pd_createdby = '" . $_SESSION['username'] . "' or pd_shareinternal = 1 order by pd_createdate desc";
    //PrintSQL($sqlstring);
    $result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>{$sqlstring}</i><br>");
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $id = $row['pd_id'];
        $createdate = $row['pd_createdate'];
        $expiredate = $row['pd_expiredate'];
        $expiredays = $row['pd_expiredays'];
        $createdby = $row['pd_createdby'];
        $zipsize = $row['pd_zippedsize'];
        $unzipsize = $row['pd_unzippedsize'];
        $filename = $row['pd_filename'];
        $desc = $row['pd_desc'];
        $notes = $row['pd_notes'];
        $filecontents = $row['pd_filecontents'];
        $shareinternal = $row['pd_shareinternal'];
        $registerrequired = $row['pd_registerrequired'];
        $password = strtoupper($row['pd_password']);
        $status = $row['pd_status'];
        $key = strtoupper($row['pd_key']);
        ?>
			<tr>
				<td><?php 
        echo $desc;
        ?>
</td>
				<td><?php 
        echo $status;
        ?>
</td>
				<td style="font-size:9pt"><?php 
        echo $createdate;
        ?>
</td>
				<td style="font-size:9pt"><?php 
        echo $expiredate;
        ?>
</td>
				<td><img src="images/preview.gif" title="<?php 
        echo $notes;
        ?>
"></td>
				<td style="font-size:9pt" align="right"><?php 
        echo HumanReadableFilesize($zipsize);
        ?>
</td>
				<td style="font-size:9pt" align="right"><?php 
        echo HumanReadableFilesize($unzipsize);
        ?>
</td>
				<td><?php 
        echo $createdby;
        ?>
</td>
				<td style="font-size:8pt"><?php 
        echo $password;
        ?>
</td>
				<td><input type="text" value="<?php 
        echo $GLOBALS['cfg']['siteurl'] . "/pd.php?k={$key}";
        ?>
"></td>
			</tr>
			<?php 
    }
    ?>
		</tbody>
	</table>
	<?php 
}
Exemple #4
0
function DisplayCommonList()
{
    $urllist['Common objects'] = "common.php";
    NavigationBar("Common objects", $urllist);
    ?>
		<SCRIPT LANGUAGE="Javascript">
		<!---
			function decision(message, url){
				if(confirm(message)) location.href = url;
			}
		// --->
		</SCRIPT>
		
		<table class="smalldisplaytable">
			<thead>
				<tr>
					<th>Group</th>
					<th>Name</th>
					<th>Description</th>
					<th>Type</th>
					<th>Value</th>
					<th>Size</th>
					<th>Upload <?php 
    echo strtoupper($modality);
    ?>
 file<br><span class="tiny">Click button or Drag & Drop</span></th>
					<th>Delete</th>
				</tr>
			</thead>
			<tbody>
				<form action="common.php" method="post" enctype="multipart/form-data">
				<input type="hidden" name="action" value="addobject">
				<input type="hidden" name="modality" value="<?php 
    echo strtoupper($modality);
    ?>
">
				<input type="hidden" name="id" value="<?php 
    echo $id;
    ?>
">
				<tr>
					<td><input type="text" name="common_group" size="15"></td>
					<td><input type="text" name="common_name"></td>
					<td><input type="text" name="common_desc"></td>
					<td>
						<select name="common_type">
							<option value="file">File</option>
							<option value="text">Text</option>
							<option value="number">Number</option>
						</select>
					</td>
					<td><input type="text" name="common_value"></td>
					<td></td>
					<td>
						<input type="file" name="file">
					</td>
					<td><input type="submit" value="Create"></td>
				</tr>
				</form>
				<?php 
    $sqlstring = "select * from common order by common_group, common_name";
    $result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><b>{$sqlstring}</b><br>");
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $common_id = $row['common_id'];
        $type = $row['common_type'];
        $group = $row['common_group'];
        $name = $row['common_name'];
        $desc = $row['common_desc'];
        $number = $row['common_number'];
        $text = $row['common_text'];
        $file = $row['common_file'];
        $size = $row['common_size'];
        switch ($type) {
            case 'number':
                $value = $number;
                break;
            case 'file':
                $value = $file;
                break;
            case 'text':
                $value = $text;
                break;
        }
        ?>
						<script type="text/javascript">
							$(document).ready(function(){
								$(".edit_inline<?php 
        echo $common_id;
        ?>
").editInPlace({
									url: "common_inlineupdate.php",
									params: "action=editinplace&id=<?php 
        echo $series_id;
        ?>
",
									default_text: "<i style='color:#AAAAAA'>Edit here...</i>",
									bg_over: "white",
									bg_out: "lightyellow",
								});
							});
						</script>
						<tr>
							<td><?php 
        echo $group;
        ?>
</td>
							<td><?php 
        echo $name;
        ?>
</td>
							<td><?php 
        echo $desc;
        ?>
</td>
							<td><?php 
        echo $type;
        ?>
</td>
							<td><?php 
        echo $value;
        ?>
</td>
							<td><?php 
        echo HumanReadableFilesize($size);
        ?>
</td>
							<td nowrap><?php 
        echo $series_size;
        ?>
 <a href="download.php?modality=<?php 
        echo $modality;
        ?>
&seriesid=<?php 
        echo $series_id;
        ?>
" border="0"><img src="images/download16.png" title="Download <?php 
        echo $modality;
        ?>
 data"></a></td>
							<td align="right">
								<a href="javascript:decision('Are you sure you want to delete this object?', 'common.php?action=deleteobject&id=<?php 
        echo $common_id;
        ?>
')" style="color: red">X</a>
							</td>
						</tr>
					<?php 
    }
    ?>
			</tbody>
		</table>
		<?php 
}
 function freeSpace()
 {
     echo HumanReadableFilesize(disk_free_space("/"));
 }
Exemple #6
0
	function DisplayStats() {
	
		$urllist['Statistics'] = "stats.php";
		NavigationBar("Stats", $urllist);

		$currentyear = date("Y");
		
		$sqlstring = "select count(*) count from subjects where isactive = 1";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$numsubjects = number_format($row['count']);
		$numtotalsubjects = $row['count'];

		$sqlstring = "select count(*) count from studies";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$numstudies = $row['count'];

		$totalseries = 0;
		$totalsize = 0;
		$sqlstring = "show tables from " . $GLOBALS['cfg']['mysqldatabase'] . " like '%\_series'";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
			//print_r($row);
			$tablename = $row['Tables_in_' . $GLOBALS['cfg']['mysqldatabase'] . ' (%\_series)'];
			//echo $tablename;
			$parts = explode("_", $tablename);
			$modality = $parts[0];
			
			$sqlstring2 = "select count(*) 'count', sum(series_size) 'size' from $modality" . "_series";
			$result2 = MySQLQuery($sqlstring2,__LINE__,__FILE__);
			$row2 = mysql_fetch_array($result2, MYSQL_ASSOC);
			$totalseries += $row2['count'];
			$totalsize += $row2['size'];
			$seriescounts[$modality] = number_format($row2['count']);
			$seriessize[$modality] = HumanReadableFilesize($row2['size']);

			$sqlstring2 = "select sum(b.series_size) 'totalbytes' from data_requests a left join $modality" . "_series b on a.req_seriesid = b.$modality" . "series_id";
			//PrintSQL($sqlstring);
			$result2 = MySQLQuery($sqlstring2,__LINE__,__FILE__);
			$row2 = mysql_fetch_array($result2, MYSQL_ASSOC);
			$seriesreqsize[$modality] = HumanReadableFilesize($row2['totalbytes']);
			$totalreqbytes += $row2['totalbytes'];
		}
		//print_r($seriescounts);
		
		/* total series qa time */
		$sqlstring = "select sum(cputime) totalcpu from mr_qa";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$diff = $row['totalcpu'];
		$totalseriesqacpu = FormatCountdown($diff);

		/* total study qa time */
		$sqlstring = "select sum(cputime) totalcpu from mr_studyqa";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$diff = $row['totalcpu'];
		$totalstudyqacpu = FormatCountdown($diff);
		
		/* total request processing time */
		$sqlstring = "select sum(req_cputime) totalrequestcpu from data_requests";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$diff = $row['totalrequestcpu'];
		$totalrequestcpu = FormatCountdown($diff);
		
		/* mean request time */
		$sqlstring = "SELECT avg(time_to_sec(timediff(req_completedate, req_date))) avgtime FROM `data_requests` where req_completedate > '000-00-00 00:00:00'";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$diff = $row['avgtime'];
		$avgrequesttime = FormatCountdown($diff);

		/* median request time */
		$sqlstring = "SELECT * FROM `data_requests` where req_completedate > '0000-00-00 00:00:00'";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		$numrows = mysql_num_rows($result);
		$med = round($numrows/2);
		
		$sqlstring = "SELECT time_to_sec(timediff(req_completedate, req_date)) avgtime FROM `data_requests` where req_completedate > '0000-00-00 00:00:00' order by avgtime limit $med,1";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$diff = $row['avgtime'];
		$medianrequesttime = FormatCountdown($diff);
		
		$uptime = shell_exec('uptime');
		
		/* subject demographics */
		$sqlstring = "select (select count(*) from subjects where gender = 'F') 'numfemales', (select count(*) from subjects where gender = 'M') 'nummales', (select count(*) from subjects where gender = 'O') 'numother', (select count(*) from subjects where gender = 'U') 'numunknown', (select count(*) from subjects where gender not in ('F','M','O','U')) 'numnotspec'";
		$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$numfemales = $row['numfemales'];
		$nummales = $row['nummales'];
		$numother = $row['numother'];
		$numunknown = $row['numunknown'];
		$numnotspec = $row['numnotspec'];
		
		?>
		
		<table width="100%">
			<tr>
				<td valign="top" width="50%">
					<table class="bluerounded" width="100%">
						<tr>
							<td class="title">Series Info</td>
						</tr>
						<tr>
							<td class="body">
								<span style="font-size:10pt;">
								<b>Available Data:</b><br>
								<?php 
echo $numsubjects;
?>
 subjects<br>
								<?php 
echo number_format($numstudies);
?>
 studies<br>
								<br>
								<table class="smalldisplaytable">
									<tr>
										<th><b>Series</b></th>
										<th align="right"><b>Count</b></th>
										<th align="right"><b>Size</b></th>
										<th align="right"><b>Request Data</b></th>
									</tr>
								<?
									foreach ($seriescounts as $modality => $count) {
										?>
										<tr>
											<td><?php 
echo strtoupper($modality);
?>
</td>
											<td align="right"><?php 
echo $count;
?>
</td>
											<td align="right"><?php 
echo $seriessize[$modality];
?>
</td>
											<td align="right"><?php 
echo $seriesreqsize[$modality];
?>
</td>
										</tr>
										<?
									}
								?>
									<tr style="color: #5882FA; font-weight: bold">
										<td>Total</td>
										<td align="right"><?php 
echo number_format($totalseries);
?>
</td>
										<td align="right"><?php 
echo HumanReadableFilesize($totalsize);
?>
</td>
										<td align="right"><?php 
echo HumanReadableFilesize($totalreqbytes);
?>
</td>
									</tr>
								</table>
								</span>
							</td>
						</tr>
					</table>
					
					<br>
					
					<table class="bluerounded" width="100%">
						<tr>
							<td class="title">System Info</td>
						</tr>
						<tr>
							<td class="body">
								<span class="header">Uptime</span><br>
								<?php 
echo $uptime;
?>
								<br><bR>
								<span class="header">Data Requests</span><br>
								<b>CPU time:</b> <?php 
echo $totalrequestcpu;
?>
<br>
								<b>Mean request time:</b> <?php 
echo $avgrequesttime;
?>
<br>
								<b>Median request time:</b> <?php 
echo $medianrequesttime;
?>
<br>
							</td>
						</tr>
					</table>
					
					<br>
					
					<table class="bluerounded" width="100%">
						<tr>
							<td class="title">Subject Demographics</td>
						</tr>
						<tr>
							<td class="body">
								<table class="reviewtable">
									<tr>
										<td class="label"># females</td>
										<td class="value"><?php 
echo $numfemales;
?>
 (<?php 
echo number_format($numfemales / $numtotalsubjects * 100, 1);
?>
%)</td>
									</tr>
									<tr>
										<td class="label"># males</td>
										<td class="value"><?php 
echo $nummales;
?>
 (<?php 
echo number_format($nummales / $numtotalsubjects * 100, 1);
?>
%)</td>
									</tr>
									<tr>
										<td class="label"># other</td>
										<td class="value"><?php 
echo $numother;
?>
 (<?php 
echo number_format($numother / $numtotalsubjects * 100, 1);
?>
%)</td>
									</tr>
									<tr>
										<td class="label"># unknown</td>
										<td class="value"><?php 
echo $numunknown;
?>
 (<?php 
echo number_format($numunknown / $numtotalsubjects * 100, 1);
?>
%)</td>
									</tr>
									<tr>
										<td class="label"># not specified</td>
										<td class="value"><?php 
echo $numnotspec;
?>
 (<?php 
echo number_format($numnotspec / $numtotalsubjects * 100, 1);
?>
%)</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>					
				</td>
				<td valign="top" width="50%">
					<table class="bluerounded" width="100%">
						<tr>
							<td class="title">MR</td>
						</tr>
						<tr>
							<td class="body">
								<span class="header">CPU time</span><br>
								<b>Total series QA CPU time:</b> <?php 
echo $totalseriesqacpu;
?>
<br>
								<b>Total study QA CPU time:</b> <?php 
echo $totalstudyqacpu;
?>
<br>
							</td>
						</tr>
						<tr>
							<td class="body">
								<table cellspacing="0" cellpadding="2" style="font-size:10pt">
									<tr>
										<td colspan="24" align="center"><span class="header">Total # MR studies starting at time...</span></td>
									</tr>
									<tr>
										<td colspan="12" align="center" style="border-bottom: 1px solid gray; border-right: 1pt solid gray">AM</td>
										<td colspan="12" align="center" style="border-bottom: 1px solid gray">PM</td>
									</tr>
									<tr style="font-size:10pt">
										<?
											for ($hour=0;$hour<24;$hour++) {
												if ($hour == 0){
													?><td align="center" style="border-left: solid 1px #CCCCCC; border-right: solid 1px #CCCCCC;">12</td><?
												}
												else {
													if ($hour < 12) {
														?><td align="center" style="border-right: solid 1px #CCCCCC;"><?php 
echo $hour;
?>
</td><?
													}
													else {
														$hr = $hour;
														if ($hour != 12) {
															$hr = $hr - 12;
														}
														?><td align="center" style="border-right: solid 1px #CCCCCC;"><?php 
echo $hr;
?>
</td><?
													}
												}
											}
										?>
									</tr>
									<tr>
								<?
									for ($hour=0;$hour<24;$hour++) {
										$sqlstring = "select count(*) count from studies where hour(study_datetime) = $hour and study_modality = 'MR'";
										#echo "$sqlstring<br>";
										$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
										$row = mysql_fetch_array($result, MYSQL_ASSOC);
										$count = $row['count'];
										$percent = round(($count/$numstudies)*100);
										$counts[$hour] = $count;
										//echo "[$count] [$numstudies] [$percent]";
										#echo "<td align=right>$percent%&nbsp;</td>";
										?>
										<td valign="bottom" align="center" style="border-right: solid 1px #CCCCCC;">
											<table height="<? echo $percent*2; ?>px" cellpadding=0 cellspacing=0 width="15px">
												<tr>
													<td bgcolor="red" style="font-size: 0px">&nbsp;</td>
												</tr>
											</table>
										</td>
										<?
									}
									?> </tr><tr style="font-size:8pt"> <?
									for ($hour=0;$hour<24;$hour++) {
										echo "<td align=center>$counts[$hour]</td>";
									}
								?>
									</tr>
								</table>
								<br><br>
								<table cellspacing="0" cellpadding="2" style="font-size:10pt">
									<tr>
										<td colspan="13" align="center" style="border-bottom: 1pt solid darkgray"><span class="header">Scan History (# sessions per month)</span></td>
									</tr>
									<tr>
										<td>Year</td>
										<td>Jan</td>
										<td>Feb</td>
										<td>Mar</td>
										<td>Apr</td>
										<td>May</td>
										<td>Jun</td>
										<td>Jul</td>
										<td>Aug</td>
										<td>Sep</td>
										<td>Oct</td>
										<td>Nov</td>
										<td>Dec</td>
									</tr>
								<?
								
									$sqlstring = "select year(min(study_datetime)) firstyear from studies where study_datetime > '0000-00-00 00:00:01' and study_modality = 'MR'";
									$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
									$row = mysql_fetch_array($result, MYSQL_ASSOC);
									$firstyear = $row['firstyear'];
									
									$numyears = $currentyear - $firstyear;
									
									for ($year=$firstyear;$year<=$currentyear;$year++) {
										?>
										<tr>
											<td>
												<a href="reports.php?action=yearstudy&year=<?php 
echo $year;
?>
&modality=MR"><b><?php 
echo $year;
?>
</b></a>
											</td>
										<?
										for ($month=1;$month<=12;$month++) {
											$sqlstring = "select count(*) count from studies where year(study_datetime) = $year and month(study_datetime) = $month and study_modality = 'MR'";
											#echo "$sqlstring<br>";
											$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
											$row = mysql_fetch_array($result, MYSQL_ASSOC);
											$count = $row['count'];
											echo "<td align=right>$count &nbsp;</td>";
										}
										?>
										</tr>
										<?
									}
								?>
								</table>
								
							</td>
						</tr>
						<tr>
							<td class="body">
							<?
								$sqlstring = "SELECT (move_maxx-move_minx + move_maxy-move_miny + move_maxz-move_minz) 'totalmovement', datediff(c.study_datetime, e.birthdate) 'ageatscan', e.gender FROM mr_qa a left join mr_series b on a.mrseries_id = b.mrseries_id left join studies c on b.study_id = c.study_id left join enrollment d on c.enrollment_id = d.enrollment_id left join subjects e on d.subject_id = e.subject_id where datediff(c.study_datetime, e.birthdate) < 45656 and e.gender in ('M','F')";
								$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
								$i=0;
								while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
									if (($row['totalmovement'] > 0) && ($row['totalmovement'] < 50)) {
										//print_r($row);
										$y[] = number_format($row['totalmovement'],2);
										$x[] = number_format($row['ageatscan']/365.25,2);
										if ($row['gender'] == 'F')
											$c[] = 'FF0000'; //$c[] = 'FFC0CB';
										elseif ($row['gender'] == 'M')
											$c[] = '0000FF'; //$c[] = '4169E1';
										else
											$c[] = '888888';
										$i++;
									}
									//if ($i>100) break;
								}
								//print_r($x);
								$chd = implode(",",$x) . "|" . implode(",",$y);
								$chco = implode("|",$c);
								
								$x = implode(",",$x);
								$y = implode(",",$y);
								$c = implode(",",$c);
								
								$chartfilename = DrawScatterPlot(600,300,$x,$y,$c);
							?>
							<b>Age vs movement</b><br>
							<img src="data:image/png;base64,<?php 
echo base64_encode(file_get_contents($chartfilename));
?>
">
							<?
								/* image data should've been sent to the browser, so delete the temp image */
								unlink($chartfilename);
							?>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<table class="bluerounded" width="100%">
						<tr>
							<td class="title">Cumulative Data Storage by Site</td>
						</tr>
						<tr>
							<td class="body">
								<?
									unset($sites);
									/* get the list of possible study sites (equipments) */
									//$sqlstring = "select distinct(study_site) 'site' from studies";
									$sqlstring = "select distinct(study_site) 'site' from studies where study_site in ('hhntMRC20107','AWP45351','WHSKYRA-01')";
									$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
									while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
										$sites[] = $row['site'];
									}
									
									natcasesort($sites);
									//PrintVariable($sites,'sites');
									
								?>
								<script>
									$(function() {
											var data2 = [
									<?
										foreach ($sites as $site) {
											unset($jsonstrings);
											$cumtotal = 0;
											?>
												{
												label: "<?php 
echo $site;
?>
",
												data: [<?
											$sqlstring = "SELECT unix_timestamp(DATE(a.study_datetime)) Date, a.study_site, COUNT(DISTINCT a.study_datetime) totalCount, sum(b.series_size) 'totalsize' FROM studies a left join mr_series b on a.study_id = b.study_id where a.study_site = '$site' GROUP BY DATE(a.study_datetime) order by Date";
											$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
											while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
											//$row = mysql_fetch_array($result, MYSQL_ASSOC);
												$date = $row['Date']*1000;
												if ($date > 0) {
													$totalsize = $row['totalsize']/1000/1000/1000;
													$totalcount = $row['totalCount'];
													$cumtotal += $totalsize;
													//$studysites[$site][$date]['size'] = $totalsize;
													//$studysites[$site][$date]['count'] = $totalcount;
													
													//$jsonstrings[] .= "['$date', $totalsize]";
													$jsonstrings[] .= "['$date', " . number_format($cumtotal,1,'.','') . "]";
												}
											}
											?><?php 
echo implode2(',', $jsonstrings);
?>
]
												},
											<?
											
										}
										//PrintVariable($studysites,'StudySites');
									?>
										];
									
										var options2 = {
											series: {
												lines: {
													show: true,
													fill: true
												},
												points: {
													show: false
												}
											},
											legend: {
												noColumns: 6
											},
											xaxis: {
												mode: "time",
												timeformat: "%Y-%m-%d"
											},
											yaxis: {
												min: 0,
												tickDecimals: 1
											},
											selection: {
												mode: "x"
											}
										};

										var placeholder2 = $("#placeholder2");

										var plot2 = $.plot(placeholder2, data2, options2);
									});
								</script>
								
								<div class='flot-y-axis'>
									<div class='flot-tick-label'>GB</div>
								</div>
								<div id="placeholder2" style="width:1100px;height:600px;"></div>
							</td>
						</tr>
					</table>
					<br><Br>
					<table class="bluerounded" width="100%">
						<tr>
							<td class="title">Data Storage by Day by Site</td>
						</tr>
						<tr>
							<td class="body">
								<?
									unset($sites);
									/* get the list of possible study sites (equipments) */
									$sqlstring = "select distinct(study_site) 'site' from studies where study_site in ('hhntMRC20107','AWP45351','WHSKYRA-01')";
									$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
									while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
										$sites[] = $row['site'];
									}
									
									natcasesort($sites);
									//PrintVariable($sites,'sites');
									
								?>
								<script>
									$(function() {
											var data = [
									<?
										foreach ($sites as $site) {
											unset($jsonstrings);
											?>
												{
												label: "<?php 
echo $site;
?>
",
												data: [<?
											$sqlstring = "SELECT unix_timestamp(DATE(a.study_datetime)) Date, a.study_site, COUNT(DISTINCT a.study_datetime) totalCount, sum(b.series_size) 'totalsize' FROM studies a left join mr_series b on a.study_id = b.study_id where a.study_site = '$site' GROUP BY DATE(a.study_datetime) order by Date";
											$result = MySQLQuery($sqlstring,__LINE__,__FILE__);
											while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
											//$row = mysql_fetch_array($result, MYSQL_ASSOC);
												$date = $row['Date']*1000;
												if ($date > 0) {
													$totalsize = $row['totalsize']/1000/1000/1000;
													$totalcount = $row['totalCount'];
													//$cumtotal += $totalsize;
													//$studysites[$site][$date]['size'] = $totalsize;
													//$studysites[$site][$date]['count'] = $totalcount;
													
													$jsonstrings[] .= "['$date', " . number_format($totalsize,1,'.','') . "]";
													//$jsonstrings[] .= "['$date', $cumtotal]";
												}
											}
											?><?php 
echo implode2(',', $jsonstrings);
?>
]
												},
											<?
											
										}
										//PrintVariable($studysites,'StudySites');
									?>
										];
									
										var options = {
											series: {
												lines: {
													show: true,
													fill: true
												},
												points: {
													show: false
												}
											},
											legend: {
												noColumns: 6
											},
											xaxis: {
												mode: "time",
												timeformat: "%Y-%m-%d"
											},
											yaxis: {
												min: 0,
												tickDecimals: 1
											},
											selection: {
												mode: "x"
											}
										};

										var placeholder = $("#placeholder");

										var plot = $.plot(placeholder, data, options);									
									});
								</script>
								
								<div class='flot-y-axis'>
									<div class='flot-tick-label'>GB</div>
								</div>
								<div id="placeholder" style="width:1100px;height:600px;"></div>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		<?
	}
Exemple #7
0
	function DisplayGenericSeries($id, $modality) {
		?>
		<SCRIPT LANGUAGE="Javascript">
		<!---
			function decision(message, url){
				if(confirm(message)) location.href = url;
			}
		// --->
		</SCRIPT>
		
		<table class="smalldisplaytable">
			<thead>
				<tr>
					<th>Series #</th>
					<th>Protocol</th>
					<th>Date</th>
					<th>Notes</th>
					<th># files</th>
					<th>Size</th>
					<th>Upload <?php 
echo strtoupper($modality);
?>
 file(s)<br><span class="tiny">Click button or Drag & Drop</span></th>
					<th>Download</th>
					<th>Delete</th>
				</tr>
			</thead>
			<tbody>
				<?
					$max_seriesnum = 0;
					$sqlstring = "select * from `" . strtolower($modality) . "_series` where study_id = $id order by series_num";
					$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
					while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
						$series_id = $row[strtolower($modality) . "series_id"];
						$series_num = $row['series_num'];
						if ($series_num > $max_seriesnum) { $max_seriesnum = $series_num; }
						//$series_datetime = date('M j, Y g:ia',strtotime($row['series_datetime']));
						$series_datetime = $row['series_datetime'];
						$protocol = $row['series_protocol'];
						$notes = $row['series_notes'];
						$numfiles = $row['series_numfiles'];
						$series_size = $row['series_size'];
						$lastupdate = $row['lastupdate'];

						if ($numfiles < 1) { $numfiles = "-"; }
						if ($series_size > 1) { $series_size = HumanReadableFilesize($series_size); } else { $series_size = "-"; }
						?>
						<script type="text/javascript">
							$(document).ready(function(){
								$(".edit_inline<? echo $series_id; ?>").editInPlace({
									url: "series_inlineupdate.php",
									params: "action=editinplace&modality=<?php 
echo $modality;
?>
&id=<? echo $series_id; ?>",
									default_text: "<i style='color:#AAAAAA'>Add notes...</i>",
									bg_over: "white",
									bg_out: "lightyellow",
								});
							});
						</script>
						<tr>
							<td><a href="studies.php?action=editseries&seriesid=<?php 
echo $series_id;
?>
&modality=<?php 
echo strtolower($modality);
?>
"><?php 
echo $series_num;
?>
</a></td>
							<td><span id="series_protocol" class="edit_inline<? echo $series_id; ?>" style="background-color: lightyellow; padding: 1px 3px; font-size: 8pt;"><? echo $protocol; ?></span></td>
							<td><span id="series_datetime" class="edit_inline<? echo $series_id; ?>" style="background-color: lightyellow; padding: 1px 3px; font-size: 8pt;"><? echo $series_datetime; ?></span></td>
							<td><span id="series_notes" class="edit_inline<? echo $series_id; ?>" style="background-color: lightyellow; padding: 1px 3px; font-size: 8pt;"><? echo $notes; ?></span></td>
							<td><a href="managefiles.php?seriesid=<?php 
echo $series_id;
?>
&modality=<?php 
echo $modality;
?>
&datatype=<?php 
echo $modality;
?>
"><?php 
echo $numfiles;
?>
</a></td>
							<td><?php 
echo $series_size;
?>
</td>
							<td>
							<!--<form action="studies.php" method="post" enctype="multipart/form-data">
							<input type="hidden" name="action" value="upload">
							<input type="hidden" name="modality" value="<?php 
echo $modality;
?>
">
							<input type="hidden" name="studyid" value="<?php 
echo $id;
?>
">
							<input type="hidden" name="seriesid" value="<?php 
echo $series_id;
?>
">
							<input type="file" name="files[]" multiple><input type="submit" value="Upload">-->
							<span id="uploader<?php 
echo $series_id;
?>
"></span>
							</form>
							</td>
							<td nowrap><?php 
echo $series_size;
?>
 <a href="download.php?modality=<?php 
echo $modality;
?>
&seriesid=<?php 
echo $series_id;
?>
" border="0"><img src="images/download16.png" title="Download <?php 
echo $modality;
?>
 data"></a></td>
							<td align="right">
								<a href="javascript:decision('Are you sure you want to delete this series?', 'studies.php?action=deleteseries&modality=<?php 
echo $modality;
?>
&id=<?php 
echo $id;
?>
&seriesid=<?php 
echo $series_id;
?>
')" style="color: red">X</a>
							</td>
						</tr>
					<?
					}
					?>
					<!-- uploader script for this series -->
					<script>
						function createUploaders(){
							/* window.onload can only be called once, so make 1 function to create all uploaders */
					<?
					mysql_data_seek($result,0); /* reset the sql result, so we can loop through it again */
					while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
						$series_id = $row[strtolower($modality) . "series_id"];
						?>
								var uploader<?php 
echo $series_id;
?>
 = new qq.FileUploader({
									element: document.getElementById('uploader<?php 
echo $series_id;
?>
'),
									action: 'upload.php',
									params: {modality: '<?php 
echo strtoupper($modality);
?>
', studyid: '<?php 
echo $id;
?>
', seriesid: <?php 
echo $series_id;
?>
},
									debug: true
								});
					<?
					}
					?>
						}
						// in your app create uploader as soon as the DOM is ready
						// don't wait for the window to load  
						window.onload = createUploaders;
					</script>
				<form action="studies.php" method="post">
				<input type="hidden" name="action" value="addseries">
				<input type="hidden" name="modality" value="<?php 
echo strtoupper($modality);
?>
">
				<input type="hidden" name="id" value="<?php 
echo $id;
?>
">
				<tr>
					<td><input type="text" name="series_num" size="3" maxlength="10" value="<?php 
echo $max_seriesnum + 1;
?>
"></td>
					<td>
						<select name="protocol">
						<?
							$sqlstring = "select * from modality_protocol where modality = '$modality'";
							$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
							while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
								$protocol = $row['protocol'];
								?>
								<option value="<?php 
echo $protocol;
?>
"><?php 
echo $protocol;
?>
</option>
								<?
							}
						?>
						</select>
					</td>
					<td><input type="text" name="series_datetime" value="<?php 
echo date('Y-m-d h:i:s a');
?>
"></td>
					<td><input type="text" name="notes"></td>
					<td></td>
					<td></td>
					<td><input type="submit" value="Create"></td>
					<td></td>
				</tr>
				</form>
			</tbody>
		</table>
		<?
	}
Exemple #8
0
function DisplayDownloadList()
{
    ?>

	<p style="background-color: #FFFFDF; border: 1px solid yellow; padding: 8px"><b>Notes</b><br>Some downloads may require registration. Click Download link to view release notes and contents of the download file. All downloads were created from data stored on this server. More detailed search criteria and QC information is available by logging in to the server and going to the Search page.</p>
	
	<div align="center">
	<table class="graydisplaytable" width="90%">
		<thead>
			<tr>
				<th>Description</th>
				<th>Created</th>
				<th>Expire date</th>
				<th>Release notes</th>
				<th>Zip size</th>
				<th>Unzipped size</th>
				<th># downloaded</th>
				<th>&nbsp;<span style="color: red; font-size:16pt">*</span> <span class="tiny">registration required</span></th>
			</tr>
		</thead>
		<tbody>
			<?php 
    $sqlstring = "select * from public_downloads where pd_status = 'complete' and pd_ispublic = 1 order by pd_desc asc";
    //PrintSQL($sqlstring);
    $result = mysql_query($sqlstring) or die("Query failed: " . mysql_error() . "<br><i>{$sqlstring}</i><br>");
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $id = $row['pd_id'];
        $createdate = $row['pd_createdate'];
        $expiredate = $row['pd_expiredate'];
        $expiredays = $row['pd_expiredays'];
        $createdby = $row['pd_createdby'];
        $zipsize = $row['pd_zippedsize'];
        $unzipsize = $row['pd_unzippedsize'];
        $filename = $row['pd_filename'];
        $desc = $row['pd_desc'];
        $notes = $row['pd_notes'];
        $filecontents = $row['pd_filecontents'];
        $shareinternal = $row['pd_shareinternal'];
        $registerrequired = $row['pd_registerrequired'];
        $status = $row['pd_status'];
        $key = strtoupper($row['pd_key']);
        $numdownload = $row['pd_numdownloads'];
        if ($createdate == $expiredate) {
            $expiredate = "None";
        }
        ?>
			<tr>
				<td><?php 
        echo $desc;
        ?>
</td>
				<td style="font-size:9pt"><?php 
        echo $createdate;
        ?>
</td>
				<td style="font-size:9pt"><?php 
        echo $expiredate;
        ?>
</td>
				<td><img src="images/preview.gif" title="<?php 
        echo $notes;
        ?>
"></td>
				<td style="font-size:9pt" align="right"><?php 
        echo HumanReadableFilesize($zipsize);
        ?>
</td>
				<td style="font-size:9pt" align="right"><?php 
        echo HumanReadableFilesize($unzipsize);
        ?>
</td>
				<td style="font-size:9pt" align="right"><?php 
        echo $numdownload;
        ?>
</td>
				<td>&nbsp;<a href="<?php 
        echo $GLOBALS['cfg']['siteurl'] . "/pd.php?k={$key}";
        ?>
">Download</a>&nbsp; <?php 
        if ($registerrequired) {
            ?>
<span style="color: red; font-size:16pt">*</span><?php 
        }
        ?>
</td>
			</tr>
			<?php 
    }
    ?>
		</tbody>
	</table>
	</div>
	<?php 
}
Exemple #9
0
	function DisplayDownload($k, $p) {
		$k = mysql_real_escape_string($k);

		if (trim($k) == "") {
			DisplayInvalidLink();
			return 0;
		}
		
		/* check if the key exists in the users_pending table */
		$sqlstring = "select * from public_downloads where pd_key = '$k'";
		//echo "$sqlstring<br>";
		$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
		if (mysql_num_rows($result) > 0) {
			$row = mysql_fetch_array($result, MYSQL_ASSOC);
			$id = $row['pd_id'];
			$createdate = $row['pd_createdate'];
			$expiredate = $row['pd_expiredate'];
			$zipsize = $row['pd_zippedsize'];
			$unzipsize = $row['pd_unzippedsize'];
			$desc = $row['pd_desc'];
			$filename = $row['pd_filename'];
			$releasenotes = $row['pd_notes'];
			$filecontents = $row['pd_filecontents'];
			$numdownloads = $row['pd_numdownloads'];
			$registerrequired = $row['pd_registerrequired'];
		}
		else {
			DisplayInvalidLink();
			return 0;
		}
		
		/* create the download link on the filesystem */
		$newlink = sha1(time());
		$systemstring = "ln -s " . $GLOBALS['cfg']['webdir'] . "/$filename " . $GLOBALS['cfg']['webdir'] . "/$newlink.zip";
		`$systemstring`;

		?>
		<b><?php 
echo $desc;
?>
</b><br>
		<span class="tiny"><b>Created</b> <?php 
echo $createdate;
?>
<br>
		<b>Total size</b> <?php 
echo HumanReadableFilesize($unzipsize);
?>
<br>
		<b>Downloads</b> <?php 
echo number_format($numdownloads, 0);
?>
		</span>
		<br><br>
		<? if ($createdate != $expiredate) { ?>
		Download valid through <b><?php 
echo $expiredate;
?>
</b>
		<br><br>
		<? } ?>
		Release notes:
		<details>
		<summary style="font-size:9pt">View</summary>
		<div style="border: solid 1px gray; background-color: #eee; margin:10px; padding:8px">
<tt><?php 
echo $releasenotes;
?>
</tt>
		</div>
		</details>
		<br>
		Download contents:
		<details>
		<summary style="font-size:9pt">View</summary>
		<pre style="border: solid 1px gray; background-color: #eee; margin:10px; padding:8px">
<?php 
echo $filecontents;
?>
		</pre>
		</details>
		<br>
		<br>
		<br>
		<?
		if (($registerrequired) && ($_SESSION['validlogin'] != true)) {
			?>
			The creator of this download has requested that you register with NiDB before downloading. Click this <a href="signup.php">link</a> to register. Then you can proceed to the download page.
			<?
		}
		else {
			?>
			<div align="center"><a href="download/<?php 
echo "{$newlink}.zip";
?>
" style="border: 2px orange solid; background-color: #fccd8f; padding: 15px 30px 25px 30px; border-radius:10px; color: #CA5900; font-weight: bold">Download</a><br><span style="font-size: 8pt"><?php 
echo HumanReadableFilesize($zipsize);
?>
</span></div>
			<?
			/* increment the numdownload for this download... i know, its not really accurate, but it'll be a ballpark figure. Chances are if they're coming to this page, they're only here to click this download link */
			$sqlstring = "update public_downloads set pd_numdownloads = pd_numdownloads + 1 where pd_id = $id";
			$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
		}
		return 1;
	}
Exemple #10
0
<span id="onmouseover">
<a style="font-family: Optima, Segoe, Segoe UI, Candara, Calibri, Arial, sans-serif;color: "<?php 
                        echo $color;
                        ?>
;" href='<?php 
                        echo $self;
                        ?>
?view=<?php 
                        echo $dir . $file;
                        ?>
'><?php 
                        echo $file;
                        ?>
</a>
<font color="#b0b000"><?php 
                        echo HumanReadableFilesize(filesize($dir . $file));
                        ?>
</font>
<font color="yellow"><?php 
                        echo getFilePermissions($dir . $file);
                        ?>
</font> <font color="#fff">> </font><?php 
                        echo getperms($dir . $file);
                        ?>
<a id="za" style="margin-right:30px" href="<?php 
                        echo $self;
                        ?>
?delete=<?php 
                        echo $dir . $file;
                        ?>
&action=mumpet">Delete</a>
Exemple #11
0
function scan_file($path)
{
    global $ext, $patterns, $count, $total_results, $FileNames;
    $dateformat = "d F Y - H:i:s ";
    if (in_array(pathinfo($path, PATHINFO_EXTENSION), $ext) && filesize($path) && !stripos($path, 'malware-scanner.php')) {
        if ($malic_file_descr = array_search(pathinfo($path, PATHINFO_BASENAME), $FileNames)) {
            echo '<tr>
                    <td>' . basename($path) . '</td>
                    <td>Suspicious FileName</td>
                    <td> - </td>
                    <td>' . substr(sprintf('%o', fileperms($path)), -4) . '</td>
                    <td><a href="#details-' . pathinfo($path, PATHINFO_FILENAME) . '" class="mb-xs mt-xs mr-xs modal-with-zoom-anim btn btn-success"><i class="fa fa-file-text"></i> Details</a></td>
                    <div id="details-' . pathinfo($path, PATHINFO_FILENAME) . '" class="zoom-anim-dialog modal-block modal-header-color modal-block-danger mfp-hide">
										<section class="panel">
											<header class="panel-heading">
												<h2 class="panel-title">Details</h2>
											</header>
											<div class="panel-body">
                                            
														<label class="col-sm-3 control-label"><i class="fa fa-file-text"></i> File Name: </label>
														<div class="col-sm-9">
															<input type="text" name="name" class="form-control" value="' . basename($path) . '" readonly /><br />
														</div>
                                                        
                                                        <label class="col-sm-3 control-label"><i class="fa fa-flag"></i> Path:</label>
														<div class="col-sm-9">
															<input type="text" class="form-control" value="' . $path . '" readonly /><br />
														</div>
                                                        
                                                        <label class="col-sm-3 control-label"><i class="fa fa-lock"></i> Permission: </label>
														<div class="col-sm-9">
															<input type="text" class="form-control" value="' . substr(sprintf('%o', fileperms($path)), -4) . '" readonly /><br />
														</div>
                                                        
                                                        <label class="col-sm-3 control-label"><i class="fa fa-key"></i> Last Accessed: </label>
														<div class="col-sm-9">
															<input type="text" class="form-control" value="' . date($dateformat, fileatime($path)) . '" readonly /><br />
														</div>
                                                        
                                                        <label class="col-sm-3 control-label"><i class="fa fa-pencil-square-o"></i> Last Modified: </label>
														<div class="col-sm-9">
															<input type="text" class="form-control" value="' . date($dateformat, filemtime($path)) . '" readonly /><br />
														</div>
                                                        
                                                        <label class="col-sm-3 control-label"><i class="fa fa-folder"></i> File Size: </label>
														<div class="col-sm-9">
															<input type="text" class="form-control" value="' . HumanReadableFilesize($path) . '" readonly /><br />
														</div>
                                                        
                                                        <label class="col-sm-3 control-label"><i class="fa fa-cog"></i> MD5 Hash: </label>
														<div class="col-sm-9">
															<input type="text" class="form-control" value="' . md5_file($path) . '" readonly /><br />
														</div>
											</div>
											<footer class="panel-footer">
												<div class="row">
													<div class="row">
													<div class="col-md-8 text-left">
													</div>
                                                    <div class="col-md-4 text-right">
														<button class="btn btn-default modal-dismiss">Close</button> &nbsp;&nbsp;
													</div>
												</div>
												</div>
											</footer>
										</section>
				         </div>
                    </tr>
                    ';
        }
        if (!($content = file_get_contents($path))) {
            $error = 'Could not check ' . $path;
        } else {
            foreach ($patterns as $pattern) {
                if (is_array($pattern)) {
                    preg_match_all('#' . $pattern[0] . '#isS', $content, $found, PREG_OFFSET_CAPTURE);
                } else {
                    preg_match_all('#' . $pattern . '#isS', $content, $found, PREG_OFFSET_CAPTURE);
                }
                $all_results = $found[0];
                $results_count = count($all_results);
                $total_results += $results_count;
                if (!empty($all_results)) {
                    $count++;
                    if (is_array($pattern)) {
                        echo '<tr>
                         <td>' . basename($path) . '</td>
                         <td><font color="red"><i>' . $pattern[1] . '</i></font></td>
                         <td>' . $results_count . '</td>
                         <td>' . substr(sprintf('%o', fileperms($path)), -4) . '</td>
                         <td><a href="#details-' . $count . '" class="mb-xs mt-xs mr-xs modal-with-zoom-anim btn btn-success"><i class="fa fa-file-text"></i> Details</a></td>
                        
                        <div id="details-' . $count . '" class="zoom-anim-dialog modal-block modal-header-color modal-block-danger mfp-hide">
										<section class="panel">
											<header class="panel-heading">
												<h2 class="panel-title">Details</h2>
											</header>
											<div class="panel-body">
                                            
														<label class="col-sm-3 control-label"><i class="fa fa-file-text"></i> File Name: </label>
														<div class="col-sm-9">
															<input type="text" name="name" class="form-control" value="' . basename($path) . '" readonly /><br />
														</div>
                                                        
                                                        <label class="col-sm-3 control-label"><i class="fa fa-flag"></i> Path:</label>
														<div class="col-sm-9">
															<input type="text" class="form-control" value="' . $path . '" readonly /><br />
														</div>
                                                        
                                                        <label class="col-sm-3 control-label"><i class="fa fa-lock"></i> Permission: </label>
														<div class="col-sm-9">
															<input type="text" class="form-control" value="' . substr(sprintf('%o', fileperms($path)), -4) . '" readonly />
                                                            ';
                        $permissions = substr(sprintf('%o', fileperms($path)), -4);
                        if (intval($permissions) == 777) {
                            $permissions = '<font color="orange">(Please note: The file have full access permissions)</font><br /><br />';
                        } else {
                            echo '<br />';
                        }
                        echo '
														</div>
                                                        
                                                        <label class="col-sm-3 control-label"><i class="fa fa-key"></i> Last Accessed: </label>
														<div class="col-sm-9">
															<input type="text" class="form-control" value="' . date($dateformat, fileatime($path)) . '" readonly /><br />
														</div>
                                                        
                                                        <label class="col-sm-3 control-label"><i class="fa fa-pencil-square-o"></i> Last Modified: </label>
														<div class="col-sm-9">
															<input type="text" class="form-control" value="' . date($dateformat, filemtime($path)) . '" readonly /><br />
														</div>
                                                        
                                                        <label class="col-sm-3 control-label"><i class="fa fa-folder"></i> File Size: </label>
														<div class="col-sm-9">
															<input type="text" class="form-control" value="' . HumanReadableFilesize($path) . '" readonly /><br />
														</div>
                                                        
                                                        <label class="col-sm-3 control-label"><i class="fa fa-cog"></i> MD5 Hash: </label>
														<div class="col-sm-9">
															<input type="text" class="form-control" value="' . md5_file($path) . '" readonly /><br />
														</div>
														
														<label class="col-sm-3 control-label"><i class="fa fa-folder"></i> Threat Description: </label>
														<div class="col-sm-9">
															<textarea type="text" class="form-control" rows="7" readonly />' . $pattern[2] . '</textarea><br />
														</div>
														
														';
                        foreach ($all_results as $match) {
                            echo '<span class="offset">Line #: ', calculate_line_number($match[1], $content), '</span>', "<pre>... " . htmlentities(substr($content, $match[1], 200), ENT_QUOTES) . " ...</pre>\n";
                        }
                        echo '
											</div>
											<footer class="panel-footer">
												<div class="row">
													<div class="row">
													<div class="col-md-8 text-left">
													</div>
                                                    <div class="col-md-4 text-right">
														<button class="btn btn-default modal-dismiss">Close</button> &nbsp;&nbsp;
													</div>
												</div>
												</div>
											</footer>
										</section>
				         </div>
                        ';
                    }
                    echo '
                    </tr>
                    ';
                }
            }
            unset($content);
        }
    }
}