ericek111

Frames

Jul 31st, 2014
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 15.24 KB | None | 0 0
  1. <html>
  2. <head>
  3.   <title>Frames Test</title>
  4.   <meta charset="utf8">
  5.   <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
  6.   <script src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
  7.   <script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
  8.   <script src="<?=PATH?>js/jquery.cookie.js"></script>
  9.   <script src="<?=PATH?>js/jclock.js"></script>
  10.   <script src="js/stupidtable.js?dev"></script>
  11.   <link rel="stylesheet" type="text/css" href="style.css">
  12.   <script type="text/javascript" src="<?=PATH?>js/noty/packaged/jquery.noty.packaged.min.js"></script>
  13.     <script>
  14.       $(document).ready(function() {
  15.             $(function($) {
  16.               $('#timeinmenu').jclock();
  17.             });
  18.         var tabCookieName = "lixko2_lasttab";
  19.         $("#tabs").tabs({
  20.         active : ($.cookie(tabCookieName) || 0),
  21.         activate : function( event, ui ) {
  22.           var newIndex = ui.newTab.parent().children().index(ui.newTab);
  23.           if(newIndex == "1") loadlog(true);
  24.           else if(newIndex == "3") loadinfo(false);
  25.           $.cookie(tabCookieName, newIndex, { expires: 14 });
  26.           }
  27.         });
  28.         $("#autoupdate").change(function() {startLoop(); loadlog(false); });
  29.         if($("#tabs").tabs('option', 'active') == "1") loadlog(true);
  30.         if($("#tabs").tabs('option', 'active') == "3") loadinfo(true);
  31.       function updatelog() {
  32.         setTimeout( updatelog(), 1500 );
  33.       }
  34.       $("#container").fadeIn(500);
  35.       });
  36.       $(function(){
  37.         var moveBlanks = function(a, b) {
  38.           if ( a < b ){
  39.            if (a == "") return 1;
  40.            else return -1;
  41.          }
  42.          if ( a > b ){
  43.             if (b == "") return -1;
  44.             else return 1;
  45.           }
  46.           return 0;
  47.         };
  48.         var moveBlanksDesc = function(a, b) {
  49.           if ( a < b ) return 1;
  50.          if ( a > b ) return -1;
  51.           return 0;
  52.         };
  53.         var table = $("table").stupidtable({
  54.         "moveBlanks": moveBlanks,
  55.         "moveBlanksDesc": moveBlanksDesc,
  56.       });
  57.  
  58.       table.on("beforetablesort", function (event, data) {
  59.         // data.column - the index of the column sorted after a click
  60.         // data.direction - the sorting direction (either asc or desc)
  61.         $("#msg").text("Sorting index " + data.column);
  62.         $.cookie("lixko2_stupidtablesorting", data.column, { expires: 14 });
  63.       });
  64.  
  65.       table.on("aftertablesort", function (event, data) {
  66.         var th = $(this).find("th");
  67.         th.find(".arrowr").remove();
  68.         th.find(".arrowl").remove();
  69.         $("#stupidtable th").find("span").removeClass("activesortspan");
  70.         var dir = $.fn.stupidtable.dir;
  71.  
  72.         var arrow = data.direction === dir.ASC ? "&uarr;" : "&darr;";
  73.         th.eq(data.column).append('<div class="arrowr">' + arrow +'</div>');
  74.         th.eq(data.column).prepend('<div class="arrowl">' + arrow +'</div>');
  75.         th.eq(data.column).find("span").addClass("activesortspan");
  76.       });
  77.  
  78.       $("#stupidtable th").click(function() {
  79.  
  80.         $("#stupidtable th").removeClass("activesort");
  81.         $(this).addClass("activesort");
  82.       });
  83.       /*$("table.stupidtable tr").slice(1).click(function(){
  84.         $(".awesome").removeClass("awesome");
  85.         $(this).addClass("awesome");
  86.       });*/
  87.  
  88.     });
  89.       function loadinfo(showalert) {
  90.         $.get( "<?=PATH?>scripts/info.php", function(data) {
  91.            $('#phpinfocontent').html(data);
  92.             if(showalert) {
  93.               $.noty.consumeAlert({layout: 'topCenter', type: 'success', dismissQueue: true, timeout: 2000});
  94.               alert("PHP info loaded!");
  95.             }
  96.         })
  97.         .fail(function(data) {
  98.           $.noty.consumeAlert({layout: 'topCenter', type: 'error', dismissQueue: true});
  99.           alert("Error whilst trying to load PHP info! [1]");
  100.         });
  101.       }
  102.        
  103.       function loadlog(showalert) {
  104.         $.get( "logger.php?action=showlog", function(data) {
  105.           if(data == "error") {
  106.             $.noty.consumeAlert({layout: 'topCenter', type: 'error', dismissQueue: true});
  107.             alert("Error whilst trying to load logfile! [1]");
  108.           } else {
  109.             if(showalert) {
  110.               $.noty.consumeAlert({layout: 'topCenter', type: 'success', dismissQueue: true, timeout: 2000});
  111.               alert("Logfile loaded!");
  112.             }
  113.             $('#logcontent').html(data).fadeIn(500);
  114.           }
  115.         })
  116.         .fail(function(data) {
  117.           $.noty.consumeAlert({layout: 'topCenter', type: 'error', dismissQueue: true});
  118.           alert("Error whilst trying to load logfile! [2]");
  119.         });
  120.       }
  121.  
  122.       function clearlog() {
  123.         $.get( "logger.php?action=clearlog", function(data) {
  124.           if(data == "cleared") {
  125.             $.noty.consumeAlert({layout: 'topCenter', type: 'success', dismissQueue: true});
  126.             alert("Logfile cleared!");
  127.             $('#logcontent').html(data);
  128.             loadlog(false);
  129.           } else {
  130.             $.noty.consumeAlert({layout: 'topCenter', type: 'error', dismissQueue: true, timeout: 3000});
  131.             alert("Error whilst trying to clear logfile! [1]" + data);
  132.           }
  133.         })
  134.         .fail(function(data) {
  135.           $.noty.consumeAlert({layout: 'topCenter', type: 'error', dismissQueue: true, timeout: 3000});
  136.           alert("Error whilst trying to clear logfile! [2]");
  137.         });
  138.       }
  139.  
  140.       function wakeup() {
  141.         var invocations = 0;
  142.         if (++invocations >= 200) {
  143.           $.noty.consumeAlert({layout: 'topCenter', type: 'warning', dismissQueue: true, timeout: 3000});
  144.           alert("Stopped loading!");
  145.           clearInterval(handle);
  146.         } else {
  147.           loadlog(false);
  148.         }
  149.       }
  150.  
  151.       function notif() {
  152.         $.noty.consumeAlert({layout: 'topRight', type: 'success', dismissQueue: true});
  153.         alert("This is the same but noty consumed with options");
  154.        }
  155.  
  156.       function testtofile(level) {
  157.         $.get( "logger.php?action=testwrite" + level, function(data) {
  158.           $.noty.consumeAlert({layout: 'top', type: 'success', dismissQueue: true, timeout: 1000});
  159.           alert("Test entry written!");
  160.           loadlog(false);  
  161.         });
  162.        }
  163.  
  164.       function leveltoint(lvlstr) {
  165.         var lvlint;
  166.           if(lvlstr.toLowerCase() == "d" || lvlstr.toLowerCase() == "debug") {
  167.             lvlint=0;
  168.           } else if(lvlstr.toLowerCase() == "i" || lvlstr.toLowerCase() == "info") {
  169.             lvlint = 1;
  170.           } else if(lvlstr.toLowerCase() == "w" || lvlstr.toLowerCase() == "warn") {
  171.             lvlint = 2;
  172.           } else if(lvlstr.toLowerCase() == "e" || lvlstr.toLowerCase() == "error") {
  173.             lvlint = 3;
  174.           } else if(lvlstr.toLowerCase() == "f" || lvlstr.toLowerCase() == "fatal") {
  175.             lvlint = 4;
  176.           } else {
  177.             lvlint = 5;
  178.           }
  179.           return lvlint;
  180.        }
  181.  
  182.       function inttolevel(lvlint) {
  183.         var lvlstr;
  184.         if(lvlint == 0) {
  185.           lvlstr = "debug";
  186.         } else if(lvlint == 1) {
  187.           lvlstr = "info";
  188.         } else if(lvlint == 2) {
  189.           lvlstr = "warn";
  190.         } else if(lvlint == 3) {
  191.           lvlstr = "error";
  192.         } else if(lvlint == 4) {
  193.           lvlstr = "fatal";
  194.         } else {
  195.           lvlstr = "";
  196.         }
  197.         return lvlstr;
  198.         }
  199.  
  200.                   /*$('#submitbut').change(function(){
  201.                  $.ajax({
  202.                        type: "GET",
  203.                        url: "send.php",
  204.                        data: "query="+document.form.textarea.value,
  205.                        success: function(msg){
  206.                         document.getElementById("Div_Where_you_want_the_response").innerHTML = msg                         }
  207.                      })
  208.             });*/
  209.  
  210.       function startLoop() {
  211.         if(!$("#autoupdate").is(":checked")) clearInterval(myInterval);  // stop
  212.         else myInterval = setInterval( "loadlog(false)", <?=LOGUPDATEFREQUENCY?> );  // run  
  213.       }
  214.     </script>
  215. </head>
  216. <body>
  217.   <div id="page">
  218.   <div id="al">
  219.   <div id="tabs">
  220.   <div id="menu">
  221.   <ul class="tablist">
  222.     <li><a href="#tabs-1" class="tab">Debug</a></li>
  223.     <li><a href="#tabs-2" class="tab">Log</a></li>
  224.     <li><a href="#tabs-3" class="tab">Users</a></li>
  225.     <li><a href="#tabs-4" class="tab">Info</a></li>
  226.     <li><a href="#tabs-5" class="tab">Graph</a></li>
  227.   </ul>
  228.   <div id="timeinmenu"></div>
  229.   </div>
  230.   <div id="container">
  231.     <div id="tabs-1">
  232.       <b>Path: </b><?=PATH?><br />
  233.       <b>Date: </b><?=date("Y-m-d H:m:s"); ?><br />
  234.       <b>Logfile: </b><?=LOGFILE?><br />
  235.       <b>Absolute path: </b> <?=ABSPATH?>
  236.     </div>
  237.     <div id="tabs-2">
  238.       <input type="submit" name="submitbut" id="submitbut" value="Clear log!" onclick=clearlog(); />
  239.       Auto-refresh:<input type="checkbox" name="autoupdate" id="autoupdate" />
  240.       <input type="submit" name="writedebug" id="writedebug" value="Write DEBUG!" onclick=testtofile("d"); />
  241.       <input type="submit" name="writeinfo" id="writeinfo" value="Write INFO!" onclick=testtofile("i"); />
  242.       <input type="submit" name="writewarn" id="writewarn" value="Write WARN!" onclick=testtofile("w"); />
  243.       <input type="submit" name="writeerror" id="writeerror" value="Write ERROR!" onclick=testtofile("e"); />
  244.       <input type="submit" name="writefatal" id="writefatal" value="Write FATAL!" onclick=testtofile("f"); />
  245.       <pre><div id="logcontent"></div></pre>
  246.       <br />
  247.     </div>
  248.     <div id="tabs-3">
  249.       <?php if(LOGLEVEL == "debug") {
  250.        $array = [ "firstname" => "Erik", "lastname" => "Bročko", "city" => "Trnava"];
  251.         $jsoned = json_encode($array);
  252.         echo($jsoned . "<br />");
  253.         $original = json_decode($jsoned, true);
  254.         echo("<b>First: </b>" . $original["firstname"] . " <b>Last: </b>" . $original["lastname"]);
  255.         if(isset($original["city"])) { echo(" <b>City:</b>". $original["city"]); } else {echo(" <b>City</b> is not set! <br />"); }    ?>
  256.         <!-- <b>User 1: <?php if(user_exists(1)){ echo("Exists!"); } ?></b><br /> -->
  257.         <br /><b>Userdata: <?=get_userdata(1)?></b><br />
  258.        <?php } ?>
  259.       <form>
  260.         Name:
  261.         <input type="submit" value="Register" name="registerbut" id="registerbut" />
  262.       </form>
  263.       <table class="gridtable">
  264.         <tr>
  265.           <th colspan="5" class="head">MySQL</th>
  266.           <th colspan="3" class="head">JSON userdata</th>
  267.         </tr>
  268.         <tr>
  269.           <th><b>#</b></th>
  270.           <th><b>Username</b></th>
  271.           <th><b>E-mail</b></th>
  272.           <th><b>Rank</b></th>
  273.           <th><b>Created</b></th>
  274.           <th><b>First name</b></th>
  275.           <th><b>Last name</b></th>
  276.           <th><b>City</b></th>
  277.         </tr>
  278.         <?php
  279.          sql_connect();
  280.          global $mysqli;
  281.          $sql = "SELECT * FROM `users`";
  282.          if(!$result = $mysqli->query($sql)){
  283.             logtofile("There was an error running the query! (" . $mysqli->errno . ") " . $mysqli->error, "f");
  284.             die('There was an error running the query [' . $mysqli->error . ']');
  285.           }
  286.           while($row = mysqli_fetch_array($result)) {
  287.             $userdata = json_decode($row["data"], true); ?>
  288.             <tr>
  289.               <td><?=$row['id']?></td>
  290.               <td><?=$row['username']?></td>
  291.               <td><?=$row['email']?></td>
  292.               <td><?=getrank(5)?></td>
  293.               <td><?=$row['created']?></td>
  294.               <td><?=$userdata['firstname']?></td>
  295.               <td><?=$userdata['lastname']?></td>
  296.               <td><?=$userdata['city']?></td>
  297.             </tr>    
  298.           <?php } ?>
  299.       </table>
  300.     </div>
  301.       <div id="tabs-4">
  302.       <center><input type='button' name='reloadinfo' id='reloadinfo' onclick='loadinfo(false)' value='Reload!'/></center><br />
  303.       <div id="phpinfocontent">
  304.           Loading PHP info...
  305.       </div>
  306.       </div>
  307.       <div id="tabs-5">
  308.         <p id="msg">&nbsp;</p>
  309.         <div id="stupidtable" style="border: none">
  310.           <table class="stupidtable">
  311.             <thead>
  312.               <tr>
  313.                 <th data-sort="int"><span>Date</span></th>
  314.                 <th data-sort="int"><span>Level</span></th>
  315.                 <th data-sort="string-ins"><span>Text</span></th>
  316.                 <th data-sort="int"><span>Data</span></th>
  317.               </tr>
  318.             </thead>
  319.             <tbody>
  320.               <?php
  321.                $handle = fopen(LOGFILE, "r");
  322.                if ($handle) {
  323.                  while (($line = fgets($handle)) !== false) {
  324.                    $date = substr($line, 0, 19);
  325.                    $rest = substr($line, 19);
  326.                    $level = substr($rest, 2);
  327.                    $act = "";
  328.                    $pos = 0;
  329.                    $lvlint = 0;
  330.                    while($act != "]" || $pos < 6) {
  331.                      $act = substr($level, $pos, 1);
  332.                      if($act != "]") {
  333.                        $lvlint = leveltoint($act);
  334.                        break;
  335.                      }
  336.                      $pos++;
  337.                    }
  338.                    if(substr($rest, 7, 1) == "]") $rest = substr($rest, 9);
  339.                    else $rest = substr($rest, 8);
  340.                    $data = "";
  341.                    $act = "";
  342.                    $pos = 0;
  343.                    if(substr($rest, -2, 1) == "]") {
  344.                      while($act != "[") {
  345.                        $act = substr($level, $pos, 1);
  346.                        if($act == "[") {
  347.                          break;
  348.                        }
  349.                        $data = $act . $data;
  350.                        $pos--;
  351.                      }
  352.                    }
  353.                    $data = substr($data, 0, -3);
  354.                    $rest = substr($rest, 0, $pos - 1);
  355.                    echo "
  356.                      <tr>
  357.                       <td data-sort-value=" . strtotime($date) . ">$date</td>
  358.                       <td data-sort-value=$lvlint><div class='level$lvlint'>" . inttolevel($lvlint) . "</div></td>
  359.                       <td>$rest</td>";
  360.                       if(trim($data) == "") echo("<td data-sort-value=0></td>");
  361.                       else echo("<td>$data</td>");
  362.                       echo "</tr>";
  363.                       //echo $date . "/" . $lvlint . "/" . $rest . "/" . $data . "<br />";
  364.                   }
  365.                 } else {
  366.                   echo('<script type="text/javascript"> $.noty.consumeAlert({layout: "topCenter", type: "error", dismissQueue: true});
  367.                   alert("Failed to load log file!"); </script>'); }
  368.                   fclose($handle);
  369.                 ?>
  370.             </tbody>
  371.   </table>
  372.   </div>
  373.   </div>
  374. </div>
  375. </div>
  376. </div>
  377.  
  378. <? if(TIMEMETER) { ?>
  379. <div id="timeplaceholder">
  380. <div id="time">
  381. <?=round(((microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]) * 1000),3)?> ms
  382. </div>
  383. </div>
  384. <? } ?>
  385. <script type="text/javascript">
  386. $( "#time" ).animate({
  387.   opacity: 1
  388. }, 1000, "linear", function() {
  389.   setTimeout(function(){
  390.   $( "#time" ).animate({
  391.   opacity: 0
  392. }, 500, "linear", function() {
  393. });
  394. }, 3000);
  395. });
  396.  
  397. </script>
  398. <?php logtofile("Page loaded! [" . round(((microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]) * 1000),3) . "]" , "d"); ?>
  399. </body>
  400. </html>
Advertisement
Add Comment
Please, Sign In to add comment