<?php
 
/*
 
 * ***************************************************************************************************
 
 *
 
 * File name: index.php
 
 *
 
 * Copyright © 2015 Alessandro Quintiliani
 
 *
 
 * This file is part of LogDeltaTime.
 
 *
 
 * LogDeltaTime is free software: you can redistribute it and/or modify
 
 * it under the terms of the GNU General Public License as published by
 
 * the Free Software Foundation, either version 3 of the License, or
 
 * (at your option) any later version.
 
 * 
 
 * LogDeltaTime is distributed in the hope that it will be useful,
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
 * GNU General Public License for more details.
 
 * 
 
 * You should have received a copy of the GNU General Public License
 
 * along with LogDeltaTime.  If not, see <http://www.gnu.org/licenses/>.
 
 *
 
 * ***************************************************************************************************
 
 */
 
 
$scriptPHPtoDebug = ""; # this variable is set with the value of the button RUN EXAMPLEx.PHP sent via POST when clicked, and its value is
 
                                   # the name of the example PHP script associated
 
 
$LOGDIR="";                 # this variable is set at the end of the exampleX.php execution, with the value of the local variable $LOGDIR defined in exampleX.php, and it's
 
                                   # part of an URL to the log file generated by exampleX.php whose link appears below the buttons RUN EXAMPLEx.PHP 
 
 
$LOGFILE="";                # this variable is set at the end of the exampleX.php execution, with the value of the local variable $LOGFILE defined in exampleX.php, and it's
 
                                   # part of an URL to the log file generated by exampleX.php whose link appears below the buttons RUN EXAMPLEx.PHP 
 
 
$arr_button_names = array('btn_example1', 
 
                                      'btn_example2', 
 
                                      'btn_example3', 
 
                                      'btn_example4'
 
                                    );
 
 
if ( isset($_POST) ) {
 
  
 
  foreach($_POST as $kpost=>$vpost) {
 
    if (in_array($kpost, $arr_button_names)) {
 
       $scriptPHPtoDebug = $vpost;
 
       break;     
 
    }  
 
  }  
 
  
 
  if ($scriptPHPtoDebug) {
 
       include($scriptPHPtoDebug);
 
  }      
 
}
 
 
?>
 
<!DOCTYPE HTML>
 
<html>
 
<head>
 
<title>LOGDELTATIME - LOG DEBUGGING EXAMPLES</title>
 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 
<script type="text/javascript">
 
   function showHelp(id_button) {      
 
     var array_titles = [
 
                              "This PHP script generates logexample1.txt with the \nlog " +
 
                              "statements written in the first format (delta time between consecutive log statements)." + 
 
                              "\nOnly the essential methods wlog(..), end() are invoked in this script",
 
                              
 
                              "This PHP script generates logexample2.txt with the \nlog " +
 
                              "statements written in the second format (NO delta time between consecutive log statements)." +
 
                              "\nThe methods invoked in this script are setDeltaLog(false), wlog(..), end()",
 
 
                              "This PHP script generates logexample3.txt with only those log " +
 
                              "\nstatements whose difference between two consecutive debug messages is at least 2 seconds." +
 
                              "\nThe methods invoked in this script are setDeltaMin(..), wlog(..), end()",
 
 
                              "This PHP script generates logexample4.txt with two groups of log " +
 
                              "\nstatements where each of them  has the value of a loop control variable prepended at." +
 
                              "\nThe methods invoked in this script are setCtrlVar(..), wlog(..), end()"
 
                            ];
 
     
 
       var index_btn = id_button.charAt(id_button.length-1) - 1;
 
       var be = document.getElementById(id_button);         
 
        var a = be.setAttribute("title",array_titles[index_btn]);
 
        be.appendChild(a);
 
    }
 
</script> 
 
</head>
 
<body>
 
<h1 style="font-size:200%; text-align: center;">EXAMPLES OF DEBUGGING PHP FILES</h1>
 
 
 
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" target="_self">
 
  <div>    
 
    <table style="margin-left: auto; margin-right: auto; text-align: center;">
 
        <tr>
 
            <td COLSPAN="4"> </td>
 
        </tr>
 
        <tr>
 
            <td> <button id="btn_example1" name="btn_example1" value="example1.php" type="submit" onmouseover="javascript:showHelp('btn_example1');">RUN EXAMPLE1.PHP</button> </td>
 
            <td> <button id="btn_example2" name="btn_example2" value="example2.php" type="submit" onmouseover="javascript:showHelp('btn_example2');">RUN EXAMPLE2.PHP</button> </td>
 
            <td> <button id="btn_example3" name="btn_example3" value="example3.php" type="submit" onmouseover="javascript:showHelp('btn_example3');">RUN EXAMPLE3.PHP</button> </td>
 
            <td> <button id="btn_example4" name="btn_example4" value="example4.php" type="submit" onmouseover="javascript:showHelp('btn_example4');">RUN EXAMPLE4.PHP</button> </td>
 
        </tr>
 
    </table>
 
  </div>    
 
</form>
 
 
 
<div style="text-align:center"> 
 
<?php
 
if ($scriptPHPtoDebug) { 
 
  echo "<br>Script " . $scriptPHPtoDebug . " executed. See the log file <a href=\"" . $LOGDIR."/".$LOGFILE . "\" target=framename style=\"text-decoration:none;\">" . $LOGFILE . "</a>";
 
}
 
?>
 
</div>
 
</body>
 
</html>
 
 |