<!DOCTYPE html>
<html>
	<head>
		<title>Pydio</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="icon" type="image/x-png" href="AJXP_THEME_FOLDER/images/html-folder.png">
		<script src="plugins/gui.ajax/res/js/lib/prototype/prototype.js" type="text/javascript"></script>
        <style>
            body {
                background-color:#fff;
                margin:0;
                padding:20;
                font-family: Helvetica, Verdana, Arial;
                overflow: hidden;
                background-image: url('plugins/gui.ajax/res/themes/vision/images/grid_t.png');
            }
            h1 {
                font-size: 33px;
                color: #BBB;
                height: 20px;
                text-align: center;
                margin: 20px auto;
            }

            div.mainContainer{
                position: relative;
                display: block;
                -webkit-border-radius: 10px;
                -moz-border-radius: 10px;
                border-radius: 10px;
                background-color: #EEF3F7;
                -webkit-box-shadow: 1px 1px 64px rgba(0,0,0,0.25);
                -moz-box-shadow: 1px 1px 64px rgba(0,0,0,0.25);
                box-shadow: 1px 1px 64px rgba(0,0,0,0.25);
                margin: 40px auto;
                width: 500px;
                height: 80%;
                padding: 18px;
            }

            p.status{
                margin-top: 0;
                font-size: 15px;
                line-height: 20px;
                text-align: justify;
                height: 60px;
            }
            p.status a{
                font-weight: bold;
                color: #666;
            }
            p.status strong{
                font-weight: normal;
                font-style: italic;
            }

            div.testList{
                font-family: Helvetica, Verdana, Arial;
                font-size: 15px;
                margin: 0 auto;
                height: 331px;
                overflow-y: scroll;
                border: 1px solid #DDD;
                -moz-box-shadow: inset 1px 1px 9px #ddd;
                -webkit-box-shadow: inset 1px 1px 9px #ddd;
                box-shadow: inset 1px 1px 9px #ddd;
                background-color: #ffffff;
            }

            div.testLine {
                text-align: left;
                padding: 10px;
                padding-bottom: 0px;
            }
            div.testClear{
                clear:both;
                border-bottom: 1px solid #dddddd;
                height: 8px;
            }
            div.testName{
                float:left;
                width:80%;
                cursor: pointer;
            }
            div.testName span{
            }
            div.testStatus{
                float:right;
                width:20%;
                text-transform: uppercase;
                text-align: right;
                font-weight: bold;
                color: #090;
            }
            div.testLine.error .testStatus{
                color : #933;
            }
            div.testLine.warning .testStatus{
                color: #f90;
            }
            div.testDescription{
                display:none;
                font-size: 0.8em;
                color: #999;
                clear: both;
                padding: 5px 0;
                padding-left: 8px;
            }
            div.testDescription.visible
            {
                display: block;
            }
            p.suggestion{
                font-size:0.9em;
                margin:5px 0 0;
            }

        </style>

	</head>
	<body bgcolor="#FFFFFF" text="#000000" marginheight="0" marginwidth="0" leftmargin="0" topmargin="0"  style="">

        <h1>Pydio Diagnostic Tool</h1>

        <div class="mainContainer">
            <?php
                if ($showSkipLink) {
                    if (count($ALL_ROWS["warning"]) && !count($ALL_ROWS["error"])) {
                        echo "<p class='status statusWarning'><strong>Status</strong> : You have some warnings, but no fatal error detected, Pydio should run ok. <br/>Please review the warnings, and <a href='index.php?ignore_tests=true'>click here to continue to Pydio</a>.</p>";
                    } else if(count($ALL_ROWS["error"])) {
                        echo "<p class='status statusError'><strong>Status</strong> : <b>You have some errors</b> that may prevent Pydio from running. Please review the error lines to check what action you should do. If you want to skip this step, simply <a href='index.php?ignore_tests=true'>click here to continue to Ajaxplorer</a>.</p>";
                    }else{
                        echo "<p class='status'><strong>Status</strong> : <b>No specific errors</b> were detected, your Pydio installation should run smoothly! <br/><a href='index.php?ignore_tests=true'>Click there to continue to Ajaxplorer</a></p>";
                    }
                }
            ?>

            <div class="testList">
            <?php

                foreach ($ALL_ROWS as $testsType => $allTests){

                    foreach($allTests as $testKey => $testInfo){

                        $status = ($testsType == "passed"?"ok":$testsType);
                        echo "<div class='testLine $testsType'>
                            <div class='testName'><span>".($testsType != "passed"?"-":"+")."</span> $testKey</div>
                            <div class='testStatus'>$status</div>
                            <div class='testDescription ".($testsType != "passed"?" visible":"")."'>$testInfo</div>
                            <div class='testClear'></div>
                        </div>";

                    }

                }

            ?>
            </div>

            <script type="text/javascript">
                var testRewrite = new Ajax.Request('data/cache/index.html', {
                    method : 'get',
                    onComplete : function(response){
                        if(200 == response.status){
                            var html = '<div class="testLine error">\
                                <div class="testName"><span>-</span>Security Breach</div>\
                                <div class="testStatus">error</div>\
                                <div class="testDescription  visible">It seems that your <b>data/</b> folder is not correctly protected, and that subfolders (like the data/cache/ folder) are web-accessible. If you are using <b>Apache</b>, make sure the AllowOverride All option is active for your current directory. If you are running <b>Windows IIS</b>, you must manually add a RequestFiltering/HiddenSegments configuration to prevent web access to these folders. If you have defined a different AJXP_DATA_PATH pointing outside the webfolder, you can ignore this warning.</div>\
                                <div class="testClear"></div>\
                            </div>';
                            $$('div.testList')[0].insert({top:html});
                        }
                    }
                });

                $$('div.testName').invoke("observe", "click", function(event){
                    var target = event.target;
                    if(target.tagName.toLowerCase() == "span") target = target.up("div.testName");
                    target.next("div.testDescription").toggleClassName("visible");
                    if(target.next("div.testDescription").hasClassName("visible")){
                        target.down("span").update("-");
                    }else{
                        target.down("span").update("+");
                    }
                });
                var resize = function(){
                    var h1 = document.viewport.getHeight() - 160 ;
                    var h = h1 - 80;
                    $$("div.mainContainer")[0].setStyle({height:h1+'px'});
                    $$("div.testList")[0].setStyle({height:h + 'px'});
                };
                Event.observe(window, "resize", resize);
                resize();
            </script>
        </div>

        <!-- <h1 style="text-align: right">Continue to Pydio &gt;&gt; </h1>-->
    </body>
</html>