Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Frames Test</title>
- <meta charset="utf8">
- <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
- <script src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
- <script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
- <script src="<?=PATH?>js/jquery.cookie.js"></script>
- <script src="<?=PATH?>js/jclock.js"></script>
- <script src="js/stupidtable.js?dev"></script>
- <link rel="stylesheet" type="text/css" href="style.css">
- <script type="text/javascript" src="<?=PATH?>js/noty/packaged/jquery.noty.packaged.min.js"></script>
- <script>
- $(document).ready(function() {
- $(function($) {
- $('#timeinmenu').jclock();
- });
- var tabCookieName = "lixko2_lasttab";
- $("#tabs").tabs({
- active : ($.cookie(tabCookieName) || 0),
- activate : function( event, ui ) {
- var newIndex = ui.newTab.parent().children().index(ui.newTab);
- if(newIndex == "1") loadlog(true);
- else if(newIndex == "3") loadinfo(false);
- $.cookie(tabCookieName, newIndex, { expires: 14 });
- }
- });
- $("#autoupdate").change(function() {startLoop(); loadlog(false); });
- if($("#tabs").tabs('option', 'active') == "1") loadlog(true);
- if($("#tabs").tabs('option', 'active') == "3") loadinfo(true);
- function updatelog() {
- setTimeout( updatelog(), 1500 );
- }
- $("#container").fadeIn(500);
- });
- $(function(){
- var moveBlanks = function(a, b) {
- if ( a < b ){
- if (a == "") return 1;
- else return -1;
- }
- if ( a > b ){
- if (b == "") return -1;
- else return 1;
- }
- return 0;
- };
- var moveBlanksDesc = function(a, b) {
- if ( a < b ) return 1;
- if ( a > b ) return -1;
- return 0;
- };
- var table = $("table").stupidtable({
- "moveBlanks": moveBlanks,
- "moveBlanksDesc": moveBlanksDesc,
- });
- table.on("beforetablesort", function (event, data) {
- // data.column - the index of the column sorted after a click
- // data.direction - the sorting direction (either asc or desc)
- $("#msg").text("Sorting index " + data.column);
- $.cookie("lixko2_stupidtablesorting", data.column, { expires: 14 });
- });
- table.on("aftertablesort", function (event, data) {
- var th = $(this).find("th");
- th.find(".arrowr").remove();
- th.find(".arrowl").remove();
- $("#stupidtable th").find("span").removeClass("activesortspan");
- var dir = $.fn.stupidtable.dir;
- var arrow = data.direction === dir.ASC ? "↑" : "↓";
- th.eq(data.column).append('<div class="arrowr">' + arrow +'</div>');
- th.eq(data.column).prepend('<div class="arrowl">' + arrow +'</div>');
- th.eq(data.column).find("span").addClass("activesortspan");
- });
- $("#stupidtable th").click(function() {
- $("#stupidtable th").removeClass("activesort");
- $(this).addClass("activesort");
- });
- /*$("table.stupidtable tr").slice(1).click(function(){
- $(".awesome").removeClass("awesome");
- $(this).addClass("awesome");
- });*/
- });
- function loadinfo(showalert) {
- $.get( "<?=PATH?>scripts/info.php", function(data) {
- $('#phpinfocontent').html(data);
- if(showalert) {
- $.noty.consumeAlert({layout: 'topCenter', type: 'success', dismissQueue: true, timeout: 2000});
- alert("PHP info loaded!");
- }
- })
- .fail(function(data) {
- $.noty.consumeAlert({layout: 'topCenter', type: 'error', dismissQueue: true});
- alert("Error whilst trying to load PHP info! [1]");
- });
- }
- function loadlog(showalert) {
- $.get( "logger.php?action=showlog", function(data) {
- if(data == "error") {
- $.noty.consumeAlert({layout: 'topCenter', type: 'error', dismissQueue: true});
- alert("Error whilst trying to load logfile! [1]");
- } else {
- if(showalert) {
- $.noty.consumeAlert({layout: 'topCenter', type: 'success', dismissQueue: true, timeout: 2000});
- alert("Logfile loaded!");
- }
- $('#logcontent').html(data).fadeIn(500);
- }
- })
- .fail(function(data) {
- $.noty.consumeAlert({layout: 'topCenter', type: 'error', dismissQueue: true});
- alert("Error whilst trying to load logfile! [2]");
- });
- }
- function clearlog() {
- $.get( "logger.php?action=clearlog", function(data) {
- if(data == "cleared") {
- $.noty.consumeAlert({layout: 'topCenter', type: 'success', dismissQueue: true});
- alert("Logfile cleared!");
- $('#logcontent').html(data);
- loadlog(false);
- } else {
- $.noty.consumeAlert({layout: 'topCenter', type: 'error', dismissQueue: true, timeout: 3000});
- alert("Error whilst trying to clear logfile! [1]" + data);
- }
- })
- .fail(function(data) {
- $.noty.consumeAlert({layout: 'topCenter', type: 'error', dismissQueue: true, timeout: 3000});
- alert("Error whilst trying to clear logfile! [2]");
- });
- }
- function wakeup() {
- var invocations = 0;
- if (++invocations >= 200) {
- $.noty.consumeAlert({layout: 'topCenter', type: 'warning', dismissQueue: true, timeout: 3000});
- alert("Stopped loading!");
- clearInterval(handle);
- } else {
- loadlog(false);
- }
- }
- function notif() {
- $.noty.consumeAlert({layout: 'topRight', type: 'success', dismissQueue: true});
- alert("This is the same but noty consumed with options");
- }
- function testtofile(level) {
- $.get( "logger.php?action=testwrite" + level, function(data) {
- $.noty.consumeAlert({layout: 'top', type: 'success', dismissQueue: true, timeout: 1000});
- alert("Test entry written!");
- loadlog(false);
- });
- }
- function leveltoint(lvlstr) {
- var lvlint;
- if(lvlstr.toLowerCase() == "d" || lvlstr.toLowerCase() == "debug") {
- lvlint=0;
- } else if(lvlstr.toLowerCase() == "i" || lvlstr.toLowerCase() == "info") {
- lvlint = 1;
- } else if(lvlstr.toLowerCase() == "w" || lvlstr.toLowerCase() == "warn") {
- lvlint = 2;
- } else if(lvlstr.toLowerCase() == "e" || lvlstr.toLowerCase() == "error") {
- lvlint = 3;
- } else if(lvlstr.toLowerCase() == "f" || lvlstr.toLowerCase() == "fatal") {
- lvlint = 4;
- } else {
- lvlint = 5;
- }
- return lvlint;
- }
- function inttolevel(lvlint) {
- var lvlstr;
- if(lvlint == 0) {
- lvlstr = "debug";
- } else if(lvlint == 1) {
- lvlstr = "info";
- } else if(lvlint == 2) {
- lvlstr = "warn";
- } else if(lvlint == 3) {
- lvlstr = "error";
- } else if(lvlint == 4) {
- lvlstr = "fatal";
- } else {
- lvlstr = "";
- }
- return lvlstr;
- }
- /*$('#submitbut').change(function(){
- $.ajax({
- type: "GET",
- url: "send.php",
- data: "query="+document.form.textarea.value,
- success: function(msg){
- document.getElementById("Div_Where_you_want_the_response").innerHTML = msg }
- })
- });*/
- function startLoop() {
- if(!$("#autoupdate").is(":checked")) clearInterval(myInterval); // stop
- else myInterval = setInterval( "loadlog(false)", <?=LOGUPDATEFREQUENCY?> ); // run
- }
- </script>
- </head>
- <body>
- <div id="page">
- <div id="al">
- <div id="tabs">
- <div id="menu">
- <ul class="tablist">
- <li><a href="#tabs-1" class="tab">Debug</a></li>
- <li><a href="#tabs-2" class="tab">Log</a></li>
- <li><a href="#tabs-3" class="tab">Users</a></li>
- <li><a href="#tabs-4" class="tab">Info</a></li>
- <li><a href="#tabs-5" class="tab">Graph</a></li>
- </ul>
- <div id="timeinmenu"></div>
- </div>
- <div id="container">
- <div id="tabs-1">
- <b>Path: </b><?=PATH?><br />
- <b>Date: </b><?=date("Y-m-d H:m:s"); ?><br />
- <b>Logfile: </b><?=LOGFILE?><br />
- <b>Absolute path: </b> <?=ABSPATH?>
- </div>
- <div id="tabs-2">
- <input type="submit" name="submitbut" id="submitbut" value="Clear log!" onclick=clearlog(); />
- Auto-refresh:<input type="checkbox" name="autoupdate" id="autoupdate" />
- <input type="submit" name="writedebug" id="writedebug" value="Write DEBUG!" onclick=testtofile("d"); />
- <input type="submit" name="writeinfo" id="writeinfo" value="Write INFO!" onclick=testtofile("i"); />
- <input type="submit" name="writewarn" id="writewarn" value="Write WARN!" onclick=testtofile("w"); />
- <input type="submit" name="writeerror" id="writeerror" value="Write ERROR!" onclick=testtofile("e"); />
- <input type="submit" name="writefatal" id="writefatal" value="Write FATAL!" onclick=testtofile("f"); />
- <pre><div id="logcontent"></div></pre>
- <br />
- </div>
- <div id="tabs-3">
- <?php if(LOGLEVEL == "debug") {
- $array = [ "firstname" => "Erik", "lastname" => "Bročko", "city" => "Trnava"];
- $jsoned = json_encode($array);
- echo($jsoned . "<br />");
- $original = json_decode($jsoned, true);
- echo("<b>First: </b>" . $original["firstname"] . " <b>Last: </b>" . $original["lastname"]);
- if(isset($original["city"])) { echo(" <b>City:</b>". $original["city"]); } else {echo(" <b>City</b> is not set! <br />"); } ?>
- <!-- <b>User 1: <?php if(user_exists(1)){ echo("Exists!"); } ?></b><br /> -->
- <br /><b>Userdata: <?=get_userdata(1)?></b><br />
- <?php } ?>
- <form>
- Name:
- <input type="submit" value="Register" name="registerbut" id="registerbut" />
- </form>
- <table class="gridtable">
- <tr>
- <th colspan="5" class="head">MySQL</th>
- <th colspan="3" class="head">JSON userdata</th>
- </tr>
- <tr>
- <th><b>#</b></th>
- <th><b>Username</b></th>
- <th><b>E-mail</b></th>
- <th><b>Rank</b></th>
- <th><b>Created</b></th>
- <th><b>First name</b></th>
- <th><b>Last name</b></th>
- <th><b>City</b></th>
- </tr>
- <?php
- sql_connect();
- global $mysqli;
- $sql = "SELECT * FROM `users`";
- if(!$result = $mysqli->query($sql)){
- logtofile("There was an error running the query! (" . $mysqli->errno . ") " . $mysqli->error, "f");
- die('There was an error running the query [' . $mysqli->error . ']');
- }
- while($row = mysqli_fetch_array($result)) {
- $userdata = json_decode($row["data"], true); ?>
- <tr>
- <td><?=$row['id']?></td>
- <td><?=$row['username']?></td>
- <td><?=$row['email']?></td>
- <td><?=getrank(5)?></td>
- <td><?=$row['created']?></td>
- <td><?=$userdata['firstname']?></td>
- <td><?=$userdata['lastname']?></td>
- <td><?=$userdata['city']?></td>
- </tr>
- <?php } ?>
- </table>
- </div>
- <div id="tabs-4">
- <center><input type='button' name='reloadinfo' id='reloadinfo' onclick='loadinfo(false)' value='Reload!'/></center><br />
- <div id="phpinfocontent">
- Loading PHP info...
- </div>
- </div>
- <div id="tabs-5">
- <p id="msg"> </p>
- <div id="stupidtable" style="border: none">
- <table class="stupidtable">
- <thead>
- <tr>
- <th data-sort="int"><span>Date</span></th>
- <th data-sort="int"><span>Level</span></th>
- <th data-sort="string-ins"><span>Text</span></th>
- <th data-sort="int"><span>Data</span></th>
- </tr>
- </thead>
- <tbody>
- <?php
- $handle = fopen(LOGFILE, "r");
- if ($handle) {
- while (($line = fgets($handle)) !== false) {
- $date = substr($line, 0, 19);
- $rest = substr($line, 19);
- $level = substr($rest, 2);
- $act = "";
- $pos = 0;
- $lvlint = 0;
- while($act != "]" || $pos < 6) {
- $act = substr($level, $pos, 1);
- if($act != "]") {
- $lvlint = leveltoint($act);
- break;
- }
- $pos++;
- }
- if(substr($rest, 7, 1) == "]") $rest = substr($rest, 9);
- else $rest = substr($rest, 8);
- $data = "";
- $act = "";
- $pos = 0;
- if(substr($rest, -2, 1) == "]") {
- while($act != "[") {
- $act = substr($level, $pos, 1);
- if($act == "[") {
- break;
- }
- $data = $act . $data;
- $pos--;
- }
- }
- $data = substr($data, 0, -3);
- $rest = substr($rest, 0, $pos - 1);
- echo "
- <tr>
- <td data-sort-value=" . strtotime($date) . ">$date</td>
- <td data-sort-value=$lvlint><div class='level$lvlint'>" . inttolevel($lvlint) . "</div></td>
- <td>$rest</td>";
- if(trim($data) == "") echo("<td data-sort-value=0></td>");
- else echo("<td>$data</td>");
- echo "</tr>";
- //echo $date . "/" . $lvlint . "/" . $rest . "/" . $data . "<br />";
- }
- } else {
- echo('<script type="text/javascript"> $.noty.consumeAlert({layout: "topCenter", type: "error", dismissQueue: true});
- alert("Failed to load log file!"); </script>'); }
- fclose($handle);
- ?>
- </tbody>
- </table>
- </div>
- </div>
- </div>
- </div>
- </div>
- <? if(TIMEMETER) { ?>
- <div id="timeplaceholder">
- <div id="time">
- <?=round(((microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]) * 1000),3)?> ms
- </div>
- </div>
- <? } ?>
- <script type="text/javascript">
- $( "#time" ).animate({
- opacity: 1
- }, 1000, "linear", function() {
- setTimeout(function(){
- $( "#time" ).animate({
- opacity: 0
- }, 500, "linear", function() {
- });
- }, 3000);
- });
- </script>
- <?php logtofile("Page loaded! [" . round(((microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]) * 1000),3) . "]" , "d"); ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment