Ejemplo n.º 1
0
function braincatalogue($args)
{
    global $connection;
    if (count($args) == 0 || $args[1] == "index.html" || $args[1] == "index.htm") {
        $html = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/templates/home.html");
        $specimen = returnimages($_SERVER['DOCUMENT_ROOT'] . "/data");
        $tmp = str_replace("<!--SPECIMENS-->", $specimen, $html);
        $html = $tmp;
        header('HTTP/1.1 200 OK');
        header("Status: 200 OK");
        print $html;
    } else {
        if ($args[1] == "blog") {
            $html = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/templates/blog.html");
            $blog = file_get_contents("http://braincatalogue.org/php/blog.php");
            $tmp = str_replace("<!--Core-->", $blog, $html);
            $html = $tmp;
            header('HTTP/1.1 200 OK');
            header("Status: 200 OK");
            print $html;
        } else {
            if ($args[1] == "user") {
                user_update($args[2]);
            } else {
                if ($args[1] == "atlasMaker") {
                    $specimen = $args[2];
                    if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/" . $specimen)) {
                        $html = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/templates/atlasMaker.html");
                        $tmp = str_replace("<!--SPECIMEN-->", $specimen, $html);
                        $html = $tmp;
                        header('HTTP/1.1 200 OK');
                        header("Status: 200 OK");
                        print $html;
                    }
                } else {
                    /*
                    	This bit of code permits to have MRI directories that
                    	do not appear in the front page.
                    	It works by looking from the end of the url if the
                    	directory exists. If it doesn't, it may be because
                    	the user is asking for a segmentation atlas. In that
                    	case, the code tries eliminating the last part.
                    */
                    $found = false;
                    for ($i = count($args); $i > 0; $i--) {
                        $specimen = join("/", array_slice($args, 0, $i));
                        if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/" . $specimen)) {
                            $found = true;
                            break;
                        }
                    }
                    if ($found) {
                        //var_dump($args);
                        //echo "[".$specimen."] ".$found;
                        if ($i < count($args)) {
                            /*
                            	Query for atlas
                            */
                            $atlas = $args[count($args)];
                            if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/" . $specimen . "/" . $atlas . ".nii.gz")) {
                                header('HTTP/1.1 200 OK');
                                header("Status: 200 OK");
                                $html = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/templates/atlasMaker.html");
                                $tmp = str_replace("<!--SPECIMEN-->", $specimen, $html);
                                $html = $tmp;
                                $tmp = str_replace("<!--ATLAS-->", $atlas, $html);
                                $html = $tmp;
                                print $html;
                            } else {
                                /*
                                header('HTTP/1.1 404 Not Found');
                                echo "We don't have an atlas <i>".$atlas."</i> for specimen <i>".$specimen."</i>, yet...";
                                */
                                header('HTTP/1.1 200 OK');
                                header("Status: 200 OK");
                                $html = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/templates/atlasMaker.html");
                                $tmp = str_replace("<!--SPECIMEN-->", $specimen, $html);
                                $html = $tmp;
                                $tmp = str_replace("<!--ATLAS-->", $atlas, $html);
                                $html = $tmp;
                                print $html;
                            }
                        } else {
                            /*
                            	Query for specimen info
                            */
                            header('HTTP/1.1 200 OK');
                            header("Status: 200 OK");
                            $html = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/templates/specimen.html");
                            // Configure specimen
                            //--------------------
                            $tmp = str_replace("<!--SPECIMEN-->", $specimen, $html);
                            $html = $tmp;
                            // Configure atlases
                            //------------------
                            $info = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/" . $specimen . "/info.txt"));
                            $tmp = str_replace("<!--INFO-->", mysqli_real_escape_string($connection, json_encode($info)), $html);
                            $html = $tmp;
                            print $html;
                        }
                    } else {
                        header('HTTP/1.1 404 Not Found');
                        echo "We don't have data for {$specimen}, yet...";
                    }
                }
            }
        }
    }
}
Ejemplo n.º 2
0
//PHP SCRIPT: getimages.php
Header("content-type: application/x-javascript");
//This function gets the file names of all images in the current directory
//and ouputs them as a JavaScript array
function returnimages()
{
    $dirname = "../../files/" . $_GET['id'] . "/img";
    $pattern = "(\\.jpg\$)|(\\.png\$)|(\\.jpeg\$)|(\\.gif\$)";
    //valid image extensions
    $files = array();
    $curimage = 0;
    if ($handle = opendir($dirname)) {
        while (false !== ($file = readdir($handle))) {
            if (eregi($pattern, $file)) {
                //if this file is a valid image
                //Output it as a JavaScript array element
                echo 'galleryarray[1][' . $curimage . ']="files/' . $_GET['id'] . '/img/large_thumb/large_thumb_' . $file . '";';
                echo 'galleryarray[2][' . $curimage . ']="files/' . $_GET['id'] . '/img/thumb/thumb_' . $file . '";';
                $curimage++;
            }
        }
        closedir($handle);
    }
    return $files;
}
echo 'var galleryarray=new Array();galleryarray[1]=new Array();galleryarray[2]=new Array();';
//Define array in JavaScript
returnimages();
?>
 
Ejemplo n.º 3
0
                echo 'galleryarray[' . $curimage . ']=["' . $file . '"];' . "\n";
                $curimage++;
            }
        }
        closedir($handle);
    }
    return $files;
}
?>
<html>
<head>

<script type="text/javascript">
var galleryarray=new Array();
<?php 
echo implode("\n", returnimages($IMGPATH));
?>
var curimg=0;
function rotateimages () {
	document.getElementById("slideshow").setAttribute ("src", "<?php 
echo $IMGPATH;
?>
"+galleryarray[curimg])
	curimg = (curimg < galleryarray.length-1) ? curimg+1 : 0
}
window.onload = function() {
	setInterval("rotateimages()", 2500)
}
</script>

</head>