<!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/vendor/prototype/prototype.js" type="text/javascript"></script>
        <style>
            * {
                font-family: Open Sans, sans-serif;
            }
            body {
                background-color: #F5F5F5;
                margin: 0;
                padding: 20px;
                overflow: hidden;
            }
            h1 {
                font-size: 30px;
                font-weight: normal;
                color: #555;
                height: 20px;
                text-align: center;
                margin: 10px auto;
            }

            div.mainContainer{
                position: relative;
                display: block;
                border-radius: 4px;
                margin: 36px auto;
                width: 660px;
                height: 80%;
                padding: 7px 11px;
                color: #535353;
            }

            p.status{
                margin-top: 0;
                font-size: 15px;
                line-height: 20px;
                text-align: justify;
                height: 60px;
                padding: 0 5px;
            }
            p.status a{
                display: inline-block;
                background-color: #555555;
                color: white;
                text-transform: uppercase;
                padding: 5px 10px;
                text-decoration: none;
                border-radius: 3px;
                margin: 9px 1px;
            }
            p.status strong{
                font-weight: normal;
                font-style: italic;
            }

            div.testList{
                font-size: 15px;
                margin: 0 auto;
                overflow-y: scroll;
                background-color: #ffffff;
                border-radius: 3px;
                box-shadow: 0 0 8px rgba(0,0,0,0.25);
            }

            div.testLine {
                text-align: left;
                padding: 15px 15px 9px;
                border-bottom: 1px solid #E7E7E7;
            }
            div.testClear{
                clear:both;
                height: 8px;
            }
            div.testName{
                float: left;
                width: 80%;
                cursor: pointer;
                font-size: 20px;
                color: #555;
            }
            div.testName span{
                display: none;
            }
            div.testStatus{
                float: right;
                width: 20%;
                text-transform: uppercase;
                text-align: right;
                color: #090;
                margin-top: 3px;
            }
            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: 20px 0 5px;
            }
            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='?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='?ignore_tests=true'>click here to continue to Pydio</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='?ignore_tests=true'>Click there to continue to Pydio</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() - 120 ;
                    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>