Example #1
0
function CreatePipelineGraph($g)
{
    //return;
    MarkTime("CreatePipelineGraph({$g})");
    $dotfile = tempnam("/tmp", 'DOTDOT');
    $pngfile = tempnam("/tmp", 'DOTPNG');
    $d[] = "digraph G {";
    $sqlstring = "select * from pipelines where pipeline_group = '{$g}'";
    $result = MySQLiQuery($sqlstring, __FILE__, __LINE__);
    while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
        $pipelinename = $row['pipeline_name'];
        $deps = $row['pipeline_dependency'];
        $groupids = $row['pipeline_groupid'];
        if ($deps != '') {
            $sqlstringA = "select * from pipelines where pipeline_id in ({$deps})";
            $resultA = MySQLiQuery($sqlstringA, __FILE__, __LINE__);
            while ($rowA = mysqli_fetch_array($resultA, MYSQLI_ASSOC)) {
                $depname = $rowA['pipeline_name'];
                $d[] = " \"{$depname}\" -> \"{$pipelinename}\";";
            }
        }
        if ($groupids != '') {
            $sqlstringA = "select * from groups where group_id in ({$groupids})";
            $resultA = MySQLiQuery($sqlstringA, __FILE__, __LINE__);
            while ($rowA = mysqli_fetch_array($resultA, MYSQLI_ASSOC)) {
                $groupname = $rowA['group_name'];
                $d[] = " \"{$groupname}\" -> \"{$pipelinename}\";";
                $d[] = " \"{$groupname}\" [shape=box,style=filled,color=\"lightblue\"];";
            }
        }
    }
    $d[] = "}";
    $d = array_unique($d);
    $dot = implode("\n", $d);
    file_put_contents($dotfile, $dot);
    $systemstring = "dot -Tpng {$dotfile} -o {$pngfile}";
    exec($systemstring);
    //echo $dot;
    $imdata = base64_encode(file_get_contents($pngfile));
    return $imdata;
}
Example #2
0
function DisplayInstanceSummary($id)
{
    $urllist['Project List'] = "projects.php";
    NavigationBar("Projects for " . $_SESSION['instancename'], $urllist, 0, '', '', '', '');
    /* get all studies associated with this project */
    $sqlstring = "SELECT b.enrollment_id, c.study_id, c.study_modality, c.study_num, c.study_ageatscan, d.uid, d.subject_id, d.birthdate, e.altuid, a.project_name FROM projects a LEFT JOIN enrollment b on a.project_id = b.project_id LEFT JOIN studies c on b.enrollment_id = c.enrollment_id LEFT JOIN subjects d on d.subject_id = b.subject_id LEFT JOIN subject_altuid e on e.subject_id = d.subject_id WHERE a.instance_id = {$id} and d.isactive = 1 order by a.project_name, e.altuid";
    $result = MySQLQuery($sqlstring, __FILE__, __LINE__);
    //PrintSQL($sqlstring);
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $studyid = $row['study_id'];
        $studynum = $row['study_num'];
        $uid = $row['uid'];
        $subjectid = $row['subject_id'];
        $age = $row['study_ageatscan'];
        $dob = $row['birthdate'];
        $projectname = $row['project_name'];
        $modality = strtolower($row['study_modality']);
        $enrollmentid = $row['enrollment_id'];
        $sqlstringA = "select altuid from subject_altuid where subject_id = '{$subjectid}' order by isprimary desc";
        $resultA = MySQLQuery($sqlstringA, __FILE__, __LINE__);
        $rowA = mysql_fetch_array($resultA, MYSQL_ASSOC);
        $isprimary = $rowA['isprimary'];
        $altuid = $rowA['altuid'];
        if ($modality != "" && $studyid != "") {
            /* check for valid modality */
            $sqlstring2 = "show tables from " . $GLOBALS['cfg']['mysqldatabase'] . " like '" . strtolower($modality) . "_series'";
            $result2 = MySQLiQuery($sqlstring2, __FILE__, __LINE__);
            if (mysqli_num_rows($result2) < 1) {
                continue;
            }
            /* get the series */
            $sqlstringA = "select * from {$modality}" . "_series where study_id = '{$studyid}' and ishidden <> 1";
            //PrintSQL($sqlstringA);
            $resultA = MySQLQuery($sqlstringA, __FILE__, __LINE__);
            while ($rowA = mysql_fetch_array($resultA, MYSQL_ASSOC)) {
                $seriesaltdesc = $rowA['series_altdesc'];
                if ($seriesaltdesc != "") {
                    $seriesdescs[$uid][$modality][$seriesaltdesc]++;
                    $uniqueseries[$modality][$seriesaltdesc]++;
                    $seriesdescs[$uid]['age'] = $age;
                    $seriesdescs[$uid]['dob'] = $dob;
                    $seriesdescs[$uid]['altuid'] = $altuid;
                    $seriesdescs[$uid]['subjectid'] = $subjectid;
                    $seriesdescs[$uid]['project'] = $projectname;
                }
            }
            /* get the measures */
            $sqlstringA = "select c.instrument_name, b.measure_name, a.* from measures a left join measurenames b on a.measurename_id = b.measurename_id left join measureinstruments c on a.instrumentname_id = c.measureinstrument_id where a.enrollment_id = '{$enrollmentid}'";
            //PrintSQL($sqlstringA);
            $resultA = MySQLQuery($sqlstringA, __FILE__, __LINE__);
            while ($rowA = mysql_fetch_array($resultA, MYSQL_ASSOC)) {
                $measurename = "[" . $rowA['instrument_name'] . "] - " . $rowA['measure_name'];
                if ($rowA['measure_type'] == 's') {
                    $measurevalue = $rowA['measure_valuestring'];
                } else {
                    $measurevalue = $rowA['measure_valuenum'];
                }
                if ($seriesaltdesc != "") {
                    $seriesdescs[$uid]['measures'][$measurename] = $measurevalue;
                    $uniqueseries['measures'][$measurename]++;
                }
            }
        }
    }
    //PrintVariable($seriesdescs, 'seriesdesc');
    //PrintVariable($uniqueseries, 'uniqueseries');
    ?>
		<script>
			$(document).ready(function() 
				{ 
					$("#thetable").tablesorter(); 
				} 
			);		
		</script>
		<table id="thetable" class="tablesorter">
			<thead>
				<tr>
					<th></th>
					<th></th>
					<th></th>
					<th></th>
					<th></th>
					<?php 
    foreach ($uniqueseries as $modality => $series) {
        $count = count($series);
        echo "<th colspan='{$count}'>{$modality}</th>";
    }
    ?>
				</tr>
				<tr>
					<th>UID</th>
					<th>Subject ID</th>
					<th>Age</th>
					<th>DOB</th>
					<th>Project</th>
					<?php 
    foreach ($uniqueseries as $modality => $series) {
        foreach ($series as $ser => $count) {
            echo "<th>{$ser} ({$count})</th>";
        }
    }
    ?>
				</tr>
			</thead>
		<?php 
    /* sort the list by altuid */
    //function compareByName($a, $b) {
    //	return strcmp($a["altuid"], $b["altuid"]);
    //}
    //usort($seriesdescs, 'compareByName');
    foreach ($seriesdescs as $uid => $modalities) {
        $age = $seriesdescs[$uid]['age'];
        $dob = $seriesdescs[$uid]['dob'];
        $altuid = $seriesdescs[$uid]['altuid'];
        $subjectid = $seriesdescs[$uid]['subjectid'];
        $project = $seriesdescs[$uid]['project'];
        ?>
			<tr>
				<td><a href="subjects.php?id=<?php 
        echo $subjectid;
        ?>
"><?php 
        echo $uid;
        ?>
</a></td>
				<td><?php 
        echo $altuid;
        ?>
</td>
				<td><?php 
        echo $age;
        ?>
</td>
				<td><?php 
        echo $dob;
        ?>
</td>
				<td><?php 
        echo $project;
        ?>
</td>
				<?php 
        foreach ($uniqueseries as $modality => $series) {
            foreach ($series as $ser => $count) {
                $localcount = $seriesdescs[$uid][$modality][$ser];
                if ($localcount > 0) {
                    $bgcolor = "#CAFFC4";
                } else {
                    $bgcolor = "";
                    $localcount = "-";
                }
                #if ($localcount > 0) { $bgcolor = "green"; } else { $bgcolor = "";}
                ?>
							<td style="background-color: <?php 
                echo $bgcolor;
                ?>
"><?php 
                echo $localcount;
                ?>
</td>
						<?php 
            }
        }
        ?>
			</tr><?php 
    }
    ?>
		</table>

		<?php 
}
Example #3
0
	function DoMergeSubjects($selectedid, $name, $dob, $gender, $ethnicity1, $ethnicity2, $handedness, $education, $phone1, $email, $maritalstatus, $smokingstatus, $altuid, $guid, $cancontact) {

		?>
		<span class="tiny">
		<ol>
		<?
		
		/* get list of subjectids that were not selected and will therefor be deleted*/
		foreach ($name as $key => $value) {
			if ($key != $selectedid) {
				$extrasubjectids[] = $key;
			}
		}
		
		/* update the primary subject with the info */
		/* perform data checks */
		$name = mysql_real_escape_string($name[$selectedid]);
		$dob = mysql_real_escape_string($dob[$selectedid]);
		$gender = mysql_real_escape_string($gender[$selectedid]);
		$ethnicity1 = mysql_real_escape_string($ethnicity1[$selectedid]);
		$ethnicity2 = mysql_real_escape_string($ethnicity2[$selectedid]);
		$handedness = mysql_real_escape_string($handedness[$selectedid]);
		$education = mysql_real_escape_string($education[$selectedid]);
		$phone1 = mysql_real_escape_string($phone1[$selectedid]);
		$email = mysql_real_escape_string($email[$selectedid]);
		$maritalstatus = mysql_real_escape_string($maritalstatus[$selectedid]);
		$smokingstatus = mysql_real_escape_string($smokingstatus[$selectedid]);
		$cancontact = mysql_real_escape_string($cancontact[$selectedid]);
		$altuid = mysql_real_escape_string($altuid[$selectedid]);
		$guid = mysql_real_escape_string($guid[$selectedid]);
		$altuids = explode(',',$altuid);

		$sqlstring = "start transaction";
		echo "<li><b>Starting transaction [$sqlstring]</b>";
		$result = MySQLiQuery($sqlstring,__FILE__,__LINE__);
		
		/* move all of the studies from the other subjects to the primary subject */
		$sqlstring = "select uid from subjects where subject_id = $selectedid";
		echo "<li>Getting selected UID [$sqlstring]";
		$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$newuid = $row['uid'];
		
		echo "<li>Getting study lists<ol>";
		foreach ($extrasubjectids as $oldid) {
			/* get list of studies associated with the oldsubjectid */
			$sqlstring = "select b.study_id from enrollment a left join studies b on a.enrollment_id = b.enrollment_id where a.subject_id = $oldid and b.study_id is not null";
			echo "<li>Get study list for [$oldid] [$sqlstring]";
			$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
			echo "<ol>";
			while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
				$studyid = $row['study_id'];
				echo "<li>Running MoveStudyToSubject($studyid, $newuid)<br>";
				MoveStudyToSubject($studyid, $newuid);
			}
			echo "</ol>";
			
			/* delete the old subject after everything has been merged */
			$sqlstring = "update subjects set isactive = 0 where subject_id = $oldid";
			echo "<li>Deleting old subject [$oldid] [$sqlstring]";
			$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
		}
		echo "</ol>";
		
		/* update the subject */
		$sqlstring = "update subjects set name = '$name', birthdate = '$dob', gender = '$gender', ethnicity1 = '$ethnicity1', ethnicity2 = '$ethnicity2', handedness = '$handedness', education = '$education', phone1 = '$phone1', email = '$email', marital_status = '$maritalstatus', smoking_status = '$smokingstatus', guid = '$guid', cancontact = '$cancontact' where subject_id = $selectedid";
		echo "<li>Updating subject [$sqlstring]";
		$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
		
		/* delete entries for this subject from the altuid table ... */
		$sqlstring = "delete from subject_altuid where subject_id = $selectedid";
		echo "<li>Deleting alternate IDs [$sqlstring]";
		$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
		
		echo "<ol>";
		/* ... and insert the new rows into the altuids table */
		foreach ($altuids as $altuid) {
			$altuid = trim($altuid);
			if (strpos($altuid, '*') !== FALSE) {
				$altuid = str_replace('*','',$altuid);
				$sqlstring = "insert ignore into subject_altuid (subject_id, altuid, isprimary) values ($selectedid, '$altuid',1)";
			}
			else {
				$sqlstring = "insert ignore into subject_altuid (subject_id, altuid, isprimary) values ($selectedid, '$altuid',0)";
			}
			echo "<li>Inserting new alternate UIDs [$sqlstring]";
			$result = MySQLQuery($sqlstring, __FILE__, __LINE__);
		}
		
		/* ------ all done ------ */
		$sqlstring = "commit";
		//PrintSQL("$sqlstring");
		echo "<li><b>Commit the transaction</b>";
		$result = MySQLiQuery($sqlstring,__FILE__,__LINE__);
		
		?></ol></ol><div align="center"><span class="message"><span class="uid"><?php 
echo FormatUID($uid);
?>
</span> updated</span></div><br><br><?
	}
Example #4
0
function DisplayFiles($id, $analysisid, $fileviewtype)
{
    $sqlstring = "select * from analysis a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join subjects d on c.subject_id = d.subject_id left join pipelines e on e.pipeline_id = a.pipeline_id where a.analysis_id = {$analysisid}";
    //echo $sqlstring;
    $result = MySQLiQuery($sqlstring, __FILE__, __LINE__);
    $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
    $uid = $row['uid'];
    $studynum = $row['study_num'];
    $pipelinename = $row['pipeline_name'];
    $pipelineid = $row['pipeline_id'];
    $pipeline_level = $row['pipeline_level'];
    $pipelinedirectory = $row['pipeline_directory'];
    //$path = $GLOBALS['pipelinedatapath'] . "/$uid/$studynum/$pipelinename/";
    /* build the correct path */
    //if (($pipeline_level == 1) && ($pipelinedirectory == "")) {
    if ($pipeline_level == 1) {
        $path = $GLOBALS['cfg']['analysisdir'] . "/{$uid}/{$studynum}/{$pipelinename}";
        echo "(1) Path is [{$path}]<br>";
    } elseif ($pipeline_level == 0) {
        $path = $GLOBALS['cfg']['mountdir'] . "{$pipelinedirectory}/{$uid}/{$studynum}/{$pipelinename}/pipeline";
        echo "(2) Path is [{$path}]<br>";
    } else {
        $path = $GLOBALS['cfg']['groupanalysisdir'] . "/{$pipelinename}";
        echo "(3) Path is [{$path}]<br>";
    }
    $origfileslog = $path . "origfiles.log";
    $finfo = finfo_open(FILEINFO_MIME);
    if (!file_exists($origfileslog) || $fileviewtype == "filesystem") {
        $files = find_all_files($path);
        //print_r($files);
        ?>
			Showing files from <b><?php 
        echo $path;
        ?>
</b> (<?php 
        echo count($files);
        ?>
 files) <span class="tiny">Reading from filesystem</span>
			<br><br>
			<table cellspacing="0" cellpadding="2">
				<tr>
					<td style="font-weight: bold; border-bottom:2px solid #999999">File</td>
					<td style="font-weight: bold; border-bottom:2px solid #999999">Timestamp</td>
					<td style="font-weight: bold; border-bottom:2px solid #999999">Permissions</td>
					<td style="font-weight: bold; border-bottom:2px solid #999999">Size <span class="tiny">bytes</span></td>
				</tr>
			<?php 
        foreach ($files as $line) {
            //$file\t$mtime\t$perm\t$isdir\t$islink\t$size
            $timestamp2 = "N/A";
            $perm2 = 'N/A';
            $islink2 = '';
            $isdir2 = '';
            $size2 = 0;
            list($file, $timestamp1, $perm1, $isdir1, $islink1, $size1) = explode("\t", $line);
            if (is_link($file)) {
                $islink2 = 1;
            }
            if (is_dir($file)) {
                $isdir2 = 1;
            }
            if (file_exists($file)) {
                $timestamp2 = filemtime($file);
                $perm2 = substr(sprintf('%o', fileperms($file)), -4);
                $size2 = filesize($file);
                //if (substr(finfo_file($finfo, "/mount$file"), 0, 4) == 'text') {
                //	$istext = true;
                //}
                //else {
                //	$istext = false;
                //}
                $filetype = "";
                if (stristr(strtolower($file), '.nii') !== FALSE) {
                    $filetype = 'nifti';
                }
                if (stristr(strtolower($file), '.nii.gz') !== FALSE) {
                    $filetype = 'nifti';
                }
                if (stristr(strtolower($file), '.inflated') !== FALSE) {
                    $filetype = 'mesh';
                }
                if (stristr(strtolower($file), '.smoothwm') !== FALSE) {
                    $filetype = 'mesh';
                }
                if (stristr(strtolower($file), '.sphere') !== FALSE) {
                    $filetype = 'mesh';
                }
                if (stristr(strtolower($file), '.pial') !== FALSE) {
                    $filetype = 'mesh';
                }
                if (stristr(strtolower($file), '.fsm') !== FALSE) {
                    $filetype = 'mesh';
                }
                if (stristr(strtolower($file), '.orig') !== FALSE) {
                    $filetype = 'mesh';
                }
                if (stristr(strtolower($file), '.png') !== FALSE) {
                    $filetype = 'image';
                }
                if (stristr(strtolower($file), '.ppm') !== FALSE) {
                    $filetype = 'image';
                }
                if (stristr(strtolower($file), '.jpg') !== FALSE) {
                    $filetype = 'image';
                }
                if (stristr(strtolower($file), '.jpeg') !== FALSE) {
                    $filetype = 'image';
                }
                if (stristr(strtolower($file), '.gif') !== FALSE) {
                    $filetype = 'image';
                }
                if (stristr(strtolower($file), '.txt') !== FALSE) {
                    $filetype = 'text';
                }
                if (stristr(strtolower($file), '.log') !== FALSE) {
                    $filetype = 'text';
                }
                if (stristr(strtolower($file), '.sh') !== FALSE) {
                    $filetype = 'text';
                }
                if (stristr(strtolower($file), '.job') !== FALSE) {
                    $filetype = 'text';
                }
                if (stristr(strtolower($file), ".o") !== FALSE) {
                    $filetype = 'text';
                }
                if (stristr(strtolower($file), ".e") !== FALSE) {
                    $filetype = 'text';
                }
                if (stristr(strtolower($file), ".par") !== FALSE) {
                    $filetype = 'text';
                }
                if (stristr(strtolower($file), ".mat") !== FALSE) {
                    $filetype = 'text';
                }
                if ($istext) {
                    $filetype = "text";
                }
                //echo "[$file $filetype]";
            }
            $filecolor = "black";
            if ($islink2) {
                $filecolor = "red";
            } else {
                $filecolor = '';
            }
            if ($isdir1) {
                $filecolor = "darkblue";
                $fileweight = '';
            } else {
                $filecolor = '';
                $fileweight = '';
            }
            $clusterpath = str_replace('/mount', '', $path);
            $displayfile = str_replace($clusterpath, '', $file);
            $lastslash = strrpos($displayfile, '/');
            $displayfile = substr($displayfile, 0, $lastslash) . '<b>' . substr($displayfile, $lastslash) . '</b>';
            $displayperms = '';
            for ($i = 1; $i <= 3; $i++) {
                switch (substr($perm2, $i, 1)) {
                    case 0:
                        $displayperms .= '---';
                        break;
                    case 1:
                        $displayperms .= '--x';
                        break;
                    case 2:
                        $displayperms .= '-w-';
                        break;
                    case 3:
                        $displayperms .= '-wx';
                        break;
                    case 4:
                        $displayperms .= 'r--';
                        break;
                    case 5:
                        $displayperms .= 'r-x';
                        break;
                    case 6:
                        $displayperms .= 'rw-';
                        break;
                    case 7:
                        $displayperms .= 'rwx';
                        break;
                }
            }
            ?>
				<tr>
					<td style="font-size:10pt; border-bottom: solid 1px #DDDDDD; color:<?php 
            echo $filecolor;
            ?>
; font-weight: <?php 
            echo $fileweight;
            ?>
">
					<?php 
            switch ($filetype) {
                case 'text':
                    ?>
					<a href="viewfile.php?file=<?php 
                    echo "{$file}";
                    ?>
"><span style="color:<?php 
                    echo $filecolor;
                    ?>
; font-weight: <?php 
                    echo $fileweight;
                    ?>
"><?php 
                    echo $displayfile;
                    ?>
</span></a>
					<?php 
                    break;
                case 'image':
                    ?>
					<a href="viewimagefile.php?file=<?php 
                    echo "{$file}";
                    ?>
"><span style="color:<?php 
                    echo $filecolor;
                    ?>
; font-weight: <?php 
                    echo $fileweight;
                    ?>
"><?php 
                    echo $displayfile;
                    ?>
</span></a>
					<?php 
                    break;
                case 'nifti':
                case 'mesh':
                    ?>
					<a href="viewimage.php?type=<?php 
                    echo $filetype;
                    ?>
&filename=<?php 
                    echo "{$file}";
                    ?>
"><span style="color:<?php 
                    echo $filecolor;
                    ?>
; font-weight: <?php 
                    echo $fileweight;
                    ?>
"><?php 
                    echo $displayfile;
                    ?>
</span></a>
					<?php 
                    break;
                default:
                    ?>
					<?php 
                    echo $displayfile;
                    ?>
					<?php 
            }
            ?>
					</td>
					<td style="font-size:10pt; border-bottom: solid 1px #DDDDDD"><?php 
            echo date("M j, Y H:i:s", $timestamp2);
            ?>
</span></td>
					<td style="font-size:10pt; border-bottom: solid 1px #DDDDDD"><?php 
            echo $displayperms;
            ?>
</td>
					<td style="font-size:10pt; border-bottom: solid 1px #DDDDDD"><?php 
            echo number_format($size2);
            ?>
</td>
				</tr>
				<?php 
        }
    } else {
        $origfiles = file_get_contents($path . "origfiles.log");
        $files = explode("\n", trim($origfiles));
        ?>
			Showing files from <b><?php 
        echo $path;
        ?>
</b> (<?php 
        echo count($files);
        ?>
 files) <span class="tiny">Reading from origfiles.log</span> Read from <a href="pipelines.php?action=viewfiles&analysisid=<?php 
        echo $analysisid;
        ?>
&fileviewtype=filesystem">filesystem</a>
			<br><br>
			<table cellspacing="0" cellpadding="2">
				<tr>
					<td style="font-weight: bold; border-bottom:2px solid #999999">File</td>
					<td style="font-weight: bold; border-bottom:2px solid #999999">Timestamp</td>
					<td style="font-weight: bold; border-bottom:2px solid #999999">Permissions</td>
					<td style="font-weight: bold; border-bottom:2px solid #999999">Size <span class="tiny">bytes</span></td>
				</tr>
			<?php 
        foreach ($files as $line) {
            //$file\t$mtime\t$perm\t$isdir\t$islink\t$size
            $timestamp2 = "N/A";
            $perm2 = 'N/A';
            $islink2 = '';
            $isdir2 = '';
            $size2 = 0;
            list($file, $timestamp1, $perm1, $isdir1, $islink1, $size1) = explode("\t", $line);
            //if (is_link('/mount' . $file)) { $islink2 = 1; }
            //if (is_dir('/mount' . $file)) { $isdir2 = 1; }
            if (file_exists('/mount' . $file)) {
                #$timestamp2 = filemtime('/mount' . $file);
                #$perm2 = substr(sprintf('%o', fileperms('/mount' . $file)), -4);
                #$size2 = filesize('/mount' . $file);
                //if (substr(finfo_file($finfo, "/mount$file"), 0, 4) == 'text') {
                //	$istext = true;
                //}
                //else {
                //	$istext = false;
                //}
                $filetype = "";
                if (stristr(strtolower($file), '.nii') !== FALSE) {
                    $filetype = 'nifti';
                }
                if (stristr(strtolower($file), '.nii.gz') !== FALSE) {
                    $filetype = 'nifti';
                }
                if (stristr(strtolower($file), '.inflated') !== FALSE) {
                    $filetype = 'mesh';
                }
                if (stristr(strtolower($file), '.smoothwm') !== FALSE) {
                    $filetype = 'mesh';
                }
                if (stristr(strtolower($file), '.sphere') !== FALSE) {
                    $filetype = 'mesh';
                }
                if (stristr(strtolower($file), '.pial') !== FALSE) {
                    $filetype = 'mesh';
                }
                if (stristr(strtolower($file), '.fsm') !== FALSE) {
                    $filetype = 'mesh';
                }
                if (stristr(strtolower($file), '.orig') !== FALSE) {
                    $filetype = 'mesh';
                }
                if (stristr(strtolower($file), '.png') !== FALSE) {
                    $filetype = 'image';
                }
                if (stristr(strtolower($file), '.ppm') !== FALSE) {
                    $filetype = 'image';
                }
                if (stristr(strtolower($file), '.jpg') !== FALSE) {
                    $filetype = 'image';
                }
                if (stristr(strtolower($file), '.jpeg') !== FALSE) {
                    $filetype = 'image';
                }
                if (stristr(strtolower($file), '.gif') !== FALSE) {
                    $filetype = 'image';
                }
                if (stristr(strtolower($file), '.txt') !== FALSE) {
                    $filetype = 'text';
                }
                if (stristr(strtolower($file), '.log') !== FALSE) {
                    $filetype = 'text';
                }
                if (stristr(strtolower($file), '.sh') !== FALSE) {
                    $filetype = 'text';
                }
                if (stristr(strtolower($file), '.job') !== FALSE) {
                    $filetype = 'text';
                }
                if (stristr(strtolower($file), ".o") !== FALSE) {
                    $filetype = 'text';
                }
                if (stristr(strtolower($file), ".e") !== FALSE) {
                    $filetype = 'text';
                }
                if (stristr(strtolower($file), ".par") !== FALSE) {
                    $filetype = 'text';
                }
                if (stristr(strtolower($file), ".mat") !== FALSE) {
                    $filetype = 'text';
                }
                if ($istext) {
                    $filetype = "text";
                }
                if ($size1 < 1) {
                    $filetype = "";
                }
            }
            $filecolor = "black";
            if ($islink2) {
                $filecolor = "red";
            } else {
                $filecolor = '';
            }
            if ($isdir1) {
                $filecolor = "darkblue";
                $fileweight = '';
            } else {
                $filecolor = '';
                $fileweight = '';
            }
            $clusterpath = str_replace('/mount', '', $path);
            $displayfile = str_replace($clusterpath, '', $file);
            $lastslash = strrpos($displayfile, '/');
            $displayfile = substr($displayfile, 0, $lastslash) . '<b>' . substr($displayfile, $lastslash) . '</b>';
            $displayperms1 = '';
            for ($i = 1; $i <= 3; $i++) {
                switch (substr($perm1, $i, 1)) {
                    case 0:
                        $displayperms1 .= '---';
                        break;
                    case 1:
                        $displayperms1 .= '--x';
                        break;
                    case 2:
                        $displayperms1 .= '-w-';
                        break;
                    case 3:
                        $displayperms1 .= '-wx';
                        break;
                    case 4:
                        $displayperms1 .= 'r--';
                        break;
                    case 5:
                        $displayperms1 .= 'r-x';
                        break;
                    case 6:
                        $displayperms1 .= 'rw-';
                        break;
                    case 7:
                        $displayperms1 .= 'rwx';
                        break;
                }
            }
            ?>
				<tr>
					<td style="font-size:9pt; border-bottom: solid 1px #DDDDDD; color:<?php 
            echo $filecolor;
            ?>
; font-weight: <?php 
            echo $fileweight;
            ?>
">
					<?php 
            switch ($filetype) {
                case 'text':
                    ?>
					<a href="viewfile.php?file=<?php 
                    echo "/mount{$file}";
                    ?>
"><span style="color:<?php 
                    echo $filecolor;
                    ?>
; font-weight: <?php 
                    echo $fileweight;
                    ?>
"><?php 
                    echo $displayfile;
                    ?>
</span></a>
					<?php 
                    break;
                case 'image':
                    ?>
					<a href="viewimagefile.php?file=<?php 
                    echo "/mount{$file}";
                    ?>
"><span style="color:<?php 
                    echo $filecolor;
                    ?>
; font-weight: <?php 
                    echo $fileweight;
                    ?>
"><?php 
                    echo $displayfile;
                    ?>
</span></a>
					<?php 
                    break;
                case 'nifti':
                case 'mesh':
                    ?>
					<a href="viewimage.php?type=<?php 
                    echo $filetype;
                    ?>
&filename=<?php 
                    echo "/mount{$file}";
                    ?>
"><span style="color:<?php 
                    echo $filecolor;
                    ?>
; font-weight: <?php 
                    echo $fileweight;
                    ?>
"><?php 
                    echo $displayfile;
                    ?>
</span></a>
					<?php 
                    break;
                default:
                    ?>
					<?php 
                    echo $displayfile;
                    ?>
					<?php 
            }
            ?>
					</td>
					<td style="font-size:10pt; border-bottom: solid 1px #DDDDDD"><?php 
            echo date("M j, Y H:i:s", $timestamp1);
            //if ($timestamp1 != $timestamp2) { echo "&nbsp;<span class='smalldiff'>$timestamp2</span>"; }
            ?>
</span></td>
					<td style="font-size:10pt; border-bottom: solid 1px #DDDDDD"><?php 
            echo $displayperms1;
            //if ($perm1 != $perm2) { echo "&nbsp;<span class='smalldiff'>$perm2</span>"; }
            ?>
</td>
					<td style="font-size:10pt; border-bottom: solid 1px #DDDDDD"><?php 
            echo number_format($size1);
            //if ($size1 != $size2) { echo "&nbsp;<span class='smalldiff'>" . number_format($size2) . "</span>"; }
            ?>
</td>
				</tr>
				<?php 
        }
        ?>
			</table>
			<?php 
    }
}
Example #5
0
	function GetProjectList() {
		/* get list of projects the user has data-write access to */
		$sqlstring = "select * from projects a left join user_project b on a.project_id = b.project_id where b.write_data = 1 and b.user_id = (select user_id from users where username = '******'username'] . "') order by a.project_name";
		$result = MySQLiQuery($sqlstring,__FILE__,__LINE__);
		$i=0;
		while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
			$r[$i]['projectid'] = $row['project_id'];
			$r[$i]['name'] = $row['project_name'];
			$r[$i]['costcenter'] = $row['project_costcenter'];
			$i++;
		}
		return $r;
	}