Location: PHPKode > scripts > SHDetect > joshf-SHDetect-f0c6c96/admin/index.php
<?php

//SHDetect, Copyright Josh Fradley (http://github.com/joshf/SHDetect)

$version = "2.1.2";
$codename = "Bear";

if (!file_exists("../config.php")) {
    header("Location: ../installer");
}

require_once("../config.php");

$uniquekey = UNIQUE_KEY;

if (isset($_GET["nojs"])) {
    die("<html><head><title>SHDetect: Error</title><link rel=\"stylesheet\" type=\"text/css\" href=\"../style.css\" /></head><body><p>Please enable JavaScript to use SHDetect. For instructions on how to do this, see <a href=\"http://www.activatejavascript.org\">here</a>.</p></body></html>");
}

session_start();
if (!isset($_SESSION["is_logged_in_" . $uniquekey . ""])) {
    header("Location: login.php");
    exit; 
}

?>
<html> 
<head>
<title>SHDetect: Admin Home</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="robots" content="noindex, nofollow">
<link rel="stylesheet" type="text/css" href="../style.css" />
<link rel="stylesheet" type="text/css" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/themes/<? echo JQUERY_THEME; ?>/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="//ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.3/css/jquery.dataTables_themeroller.css" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.3/jquery.dataTables.js"></script>
</head>
<body>
<!--[if IE]>
<p>Please use a browser than conforms to web standards and can actually renders webpages properly. I suggest Firefox or Chrome.</p>
<![endif]-->
<noscript><meta http-equiv="refresh" content="0; url=index.php?nojs=true"></noscript>
<script type="text/javascript">
$(document).ready(function() {
    /* jQuery UI buttons */
    $("#userfunctions").buttonset();
    $("#showexamplecallurl").button();
    /* End */
    /* DataTables */
    $("#data").dataTable({
        "bJQueryUI": true,
        "sPaginationType": "full_numbers"
    });
    /* End */
    /* Table selection */
    var is_selected = 0;
    $("#data tbody").delegate("tr", "click", function() {
        if (is_selected) {
            $("td:first", is_selected).parent().children().each(function() {
                $(this).removeClass("highlight-row");
            });
        }
        is_selected = this;
        $("td:first", this).parent().children().each(function() {
            $(this).addClass("highlight-row");
        });
    });
    /* End */
    /* Toggle Example Call URL */
    $("#showexamplecallurl").click(function() {
        $("#examplecallurl").toggle("fast");
    });
    /* End */
    /* Refresh */
    $("#dorefresh").click(function() {
        window.location.reload();
    });
    /* End */
    /* Settings */
    $("#dogotosettingspage").click(function() {
        window.location = "settings.php";
    });
    /* End */
    /* Logout */
    $("#showlogout").click(function() {
        logoutconfirm=confirm("<? echo ADMIN_USER; ?>, are you sure you wish to logout?")
        if (logoutconfirm==true) {
            window.location.replace("logout.php");
        } else {
            return false;
        }
    });
    /* End */
});
</script>
<?php

$con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$con) {
    die("<h1>SHDetect: Error</h1><p>Could not connect to database: " . mysql_error() . ". Check your database settings are correct.</p><hr /><p><a href=\"javascript:history.go(-1)\">&larr; Go Back</a></p></body></html>");
}

$does_db_exist = mysql_select_db(DB_NAME, $con);
if (!$does_db_exist) {
    die("<h1>SHDetect: Error</h1><p>Could not connect to database: " . mysql_error() . ". Check your database settings are correct.</p><hr /><p><a href=\"javascript:history.go(-1)\">&larr; Go Back</a></p></body></html>");
}

$getdata = mysql_query("SELECT * FROM Data");

echo "<h1>SHDetect: Data for " . APP_NAME . " " . APP_VERSION . " build " . APP_BUILD . "</h1>
<p><table id=\"data\">
<thead>
<tr>
<th>Version</th>
<th>" . ucfirst(FIELD_1) . "</th>
<th>" . ucfirst(FIELD_2) . "</th>
<th>Date First Seen</th>
<th>" . ucfirst(FIELD_3) . "</th>
<th>Count</th>
</tr></thead><tbody>";

while($row = mysql_fetch_assoc($getdata)) {
    echo "<tr>";
    echo "<td>" . $row["Version"] . "</td>";
    echo "<td>" . $row["Field1"] . "</td>";
    echo "<td>" . $row["Field2"] . "</td>";
    echo "<td>" . $row["Date"] . "</td>";
    echo "<td>" . $row["Field3"] . "</td>";
    echo "<td>" . $row["Count"] . "</td>";
    echo "</tr>";
}
echo "</tbody></table></p>";

//Update checking
$remoteversion = file_get_contents("https://raw.github.com/joshf/SHDetect/master/version.txt");
if ($version < $remoteversion) {
    echo "<p><div class=\"ui-state-highlight ui-corner-all\" style=\"padding: 0 .7em;\"><p><span class=\"ui-icon ui-icon-refresh\" style=\"float: left; margin-right: .3em;\"></span><b>Info:</b> An update to SHDetect is available! Version $remoteversion has been released (you have $version). To see what changes are included see the <a href=\"https://github.com/joshf/SHDetect/compare/$version...$remoteversion\" target=\"_blank\">changelog</a>. Click <a href=\"https://github.com/joshf/SHDetect/zipball/$remoteversion\" target=\"_blank\">here</a> to update.</p></div></p>";
}

echo "<p><button id=\"showexamplecallurl\">Toggle Example Call URL</button></p>";

mysql_close($con);

?>
<div id="examplecallurl" style="display: none;">
    <p>Example call URL for your SHDetect installation:</p><p><textarea rows="2" cols="100"><? echo "" . PATH_TO_SCRIPT . "/detect.php?version=\$VERSION&" . FIELD_1 . "=$" . strtoupper(FIELD_1) . "&" . FIELD_2 . "=$" . strtoupper(FIELD_2) . "&" . FIELD_3 . "=$" . strtoupper(FIELD_3) . ""; ?></textarea></p><p>Replace $ variables with actual values.</p>
<?
 
 $lang = array("af", "ach", "ak", "am", "ar", "az", "be", "bem", "bg", "bh", "bn", "br", "bs", "ca", "chr", "ckb", "
 co", "crs", "cs", "cy", "da", "en_GB", "xh", "yi", "yo", "zh-CN", "zh-TW", "zu");
 $dorand = array_rand($lang);
 $randomlang = $lang[$dorand];
 echo "<p><a href=\"" . PATH_TO_SCRIPT . "/detect.php?version=" . rand(1, 20) . "&" . FIELD_1 . "=" . rand(1, 10) . "&" . FIELD_2 . "=" . rand(1, 10) . "&" . FIELD_3 . "=$randomlang\" target=\"_blank\">Click to test SHDetect</a> (this will make a call to detect.php)</p>";

?>
</div>
<div id="userfunctions">
<p><button id="dorefresh">Refresh</button>
<button id="dogotosettingspage">Settings</button>
<button id="showlogout">Logout</button></p>
</div>
<small>SHDetect <? echo $version; ?> "<? echo $codename; ?>" Copyright <a href="http://github.com/joshf" target="_blank">Josh Fradley</a> <? echo date("Y"); ?></small>
</body>
</html>
Return current item: SHDetect