<%@language = "javascript" %>
<% /*
    LET OP: Dit bestand kan moeilijk te beantwoorden vragen opwerpen
            en is dan ook een 'undocumented' feature.

    $Revision$
    $Id$

    File:           appl/fac/fac_verify_bestpractises.asp
    Description:    Verify Facilitor best practises
    Parameters:
    Context:        Manual call to check best practises
    Note:           FACTAB authorization is required
                    tenzij we in de ontwikkelomgeving zitten

                    Ook te benaderen als api2 via http://logc.facws001.sg.nl/trunk/api2/bestpractices.table?failonly=1
*/
%>
<!--#include file="../Shared/common.inc"-->
<!--#include file="../api2/model_bestpractices.inc "-->

<%
    if (typeof ANONYMOUS_Allowed == "undefined" || !ANONYMOUS_Allowed)
    {
        var autfunction = "WEB_FACTAB";
        var authparams = user.checkAutorisation(autfunction);
    }
%>
<!DOCTYPE html>
<head>
     <meta http-equiv="Content-Type" content="text/html;charset=windows-1252">
     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
     <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<style>
    th, td {
      font-family: Verdana;
      font-size: 10pt;
      color: #000000;
      padding: 2px;
      background-color: #D6D8E8;
    }
    label { width: 50px; display: inline; }
    th { text-align: left }
    table.inside td
        {
            padding: 0px 0px 0px 5px;
            font-size: smaller;
        }
</style>
<title>Facilitor installation verifier</title>
<script>
    function reload()
    {
        var hrefBase = window.location.href;
        window.location.href = hrefBase;
    }
</script>
</head>
<%
resultcodes = { ok: "No problem",
                fatal: "No further checks possible, fix and recheck",
                error: "Error, fix and recheck",
                warning: "Warning: Could be more secure",
                inform: "Information only"
              }

function checker (description, fnCheck)
{
    if (typeof cnt_id == "undefined") cnt_id = 1;
    cnt_id ++;

    Response.Write("\n<tr><td>");
    Response.Write(description);
    var res = fnCheck();

    Response.Write("<div id='div"+cnt_id+"' style='padding-left: 20px'><em>"+safe.html("message" in res?res.message:'')+"</em></div>");
    Response.Write("</td>");
    Response.Write("\n<td>"+ safe.html("val" in res?res.val:'')+"</td>");
    Response.Write("\n<td>"+ safe.html("info" in res?res.info:'')+"</td>");
    var idtxt = res.id?" id="+res.id:"";
    switch (res.result)
    {
        case resultcodes.ok:
            Response.Write("<td style='color:green'"+idtxt+">Ok</td>");
            break;
        case resultcodes.warning:
            Response.Write("<td style='color:yellow'"+idtxt+">Warning</td>");
            break;
        case resultcodes.error:
            Response.Write("<td style='background-color:red'"+idtxt+">Error</td>");
            break;
        case resultcodes.fatal:
            Response.Write("<td style='background-color:red'"+idtxt+">Error</td></tr></table>");
            Response.Write("<h1 style='background-color:red'>Verify aborted</h1>");
            Response.End;
            break;
        case resultcodes.inform:
            Response.Write("<td style='color:green'"+idtxt+">Inform</td>");
            break;
        default:
            Response.Write("<td style='color:red'"+idtxt+">Unknown</td>");
            break;
    }
    Response.Write("</tr>");
}

%><table>
<thead><tr><th align='left'><table><tr><td><b>Verify.asp $Revision$<br>
               Checking <%= toDateTimeString(new Date()) %></b><br>
               Software folder: <%= Server.HTMLEncode(Server.MapPath("../..")) %><br>
               <% if (this.FCLTVersion ) Response.Write("Software version " + this.FCLTVersion + "<br>") %>
               </td>
               <td valign='top'>
                <form method='post' target='_new'>
                    <input type='button' onclick='this.value="Please wait...";reload()' value='Refresh'>
                </form>
               </td></tr></table>
           </th>
           <th align='left'>Value</th>
           <th align='left'>Best</th>
           <th align='left'>Result</th>
       </tr>
</thead>
<%

var bp = new model_bestpractices().REST_GET({ filter: {}});

for (var s = 0; s < bp.length; s++)
{
    var set = bp[s];
    checker(set.settingname, function ()
        {
            if (!set.result)
            {
                return { result: resultcodes.ok,
                         val: set.value
                       };
            }
            return { result: resultcodes.warning,
                        val: set.value,
                        info: set.remark||set.best,
                        message: set.result }
        });
}


ASPPAGE_END(); %> 
