예제 #1
0
function checkMySQL()
{
    global $sqlhost, $sqlusername, $sqlpassword;
    $conn = new mysqli($sqlhost, $sqlusername, $sqlpassword);
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    if ($query = $conn->prepare("SELECT v FROM sweepelite.globalvars WHERE k=?")) {
        $var = "mysqlInitialized";
        $query->bind_param("s", $var);
        $query->execute();
        $shouldInit = false;
        if ($query->num_rows === 0) {
            $shouldInit = true;
        }
        $query->close();
        if ($shouldInit) {
            initMySQL();
        }
    } else {
        error_log("Could not prepare MySQL check statement.");
        error_log("Trying to init anyways, since this seems to be related to not being initialized yet.");
        initMySQL();
    }
}
function doQuery($v_query)
{
    global $numqs;
    global $link;
    if ($link == null) {
        initMySQL();
    }
    $numqs++;
    $result = mysql_query($v_query, $link);
    if (!$result) {
        die('<script language="Javascript"> alert("Q' . $numqs . ': Invalid Query: ' . mysql_error($link) . '\\n\\nQuery:\\n' . $v_query . '")</script>');
    }
    return $result;
}
예제 #3
0
//ini_set('display_errors', '1');
if (!file_exists("config.php") || file_exists("setup.php")) {
    die("<html><head><meta http-equiv=\"refresh\" content=\"0;url=setup.php\"></head></html>");
}
/*
 Bug 1 Fix
*/
if (isset($_GET['sesid'])) {
    session_id($_GET['sesid']);
}
session_start();
require 'functions.php';
if (getConfigVar("maint_mode")) {
    die("<html><body>System in Maintenance Mode</body></html>");
}
initMySQL();
if (getConfigVar("db_error_logging")) {
    set_error_handler("db_error_logger");
}
$pageid = "home";
if (isset($_GET['pageid'])) {
    $pageid = $_GET['pageid'];
}
if ($pageid == "logout") {
    session_unset();
    $pageid = "login";
}
$navi = "";
$admin = "";
/*
Check to see if there is a user logged in. If so, check their "user_level."