function initi($web_server_base_path, $tracker_module_base_path, $debug = false) { // host/pw/dbase/etc variables in credentials.inc $cfile = "{$web_server_base_path}/config/credentials.inc"; if ($debug) { echo "<!-- into init() seeking [{$web_server_base_path}]/config/credentials.inc -->\n"; echo "<!-- and [{$tracker_module_base_path}]/config/tracker.sql -->\n"; echo "<!-- vs [{$cfile}] -->\n"; } $shandle = "error"; if (file_exists($cfile)) { include_once $cfile; if (isset($user) && isset($pass) && isset($host) && isset($dbase)) { if ($debug) { echo "<!-- db connect to {$user}@{$host} with {$pass} -->\n"; } $shandle = mysqli_connect($host, $user, $pass, $dbase); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit; } // system and tracker databases should always be checked. //ichecktables($shandle,"system","$web_server_base_path/baselib/system.sql",$debug); ichecktables($shandle, "tracker", "{$tracker_module_base_path}/baselib/tracker.sql", $debug); } } if ($debug == "true") { echo "<!-- shandle:"; print_r($shandle); echo "-->\n"; } return $shandle; }
function check_tables($shandle, $docroot, $debug = false) { // check all tables // get a list of all sql files in this directory and process them $tables = array(); $cmd = "ls -1 {$docroot}/sql/*.sql"; if ($debug) { echo "<!-- executing [{$cmd}] -->\n"; } $sqlist = `{$cmd}`; $tables = explode("\n", $sqlist); foreach ($tables as $this_table) { if ($this_table != "\n" and $this_table != "") { if ($debug) { echo "<!-- Processing [{$this_table}] -->\n"; } $tablename = str_replace($docroot, "", $this_table); $tablename = str_replace("/sql/", "", $tablename); $tablename = str_replace(".sql", "", $tablename); ichecktables($shandle, $tablename, $this_table, $debug); } } }
// version 1.0 // September 14, 2015 // successful login needs to set $_SESSION["logstate"] = "authenticated"; if (session_id() == "") { session_start(); } $baseref = $_SESSION["baseref"]; $docroot = $_SESSION["docroot"]; $shandle = $_SESSION["shandle"]; $goplace = isset($goplace) ? $goplace : "login"; $pathspec = isset($pathspec) ? $pathspec : "pages/login"; $logmod = isset($logmod) ? $logmod : "{$pathspec}"; $exitplace = isset($exitplace) ? $exitplace : "staff"; $weblog = "{$baseref}/{$pathspec}"; echo "<!-- 2 [{$goplace}][{$pathspec}][{$logmod}][{$weblog}] -->\n"; ichecktables($shandle, "accounts", "{$logmod}/config/accounts.sql"); setstyle("/{$pathspec}/", true); // get post variables $username = getvardata("username", "", 00); $password = getvardata("password", "", 99); $shortcut = getvardata("shortcut", "splash.php", 99); $debug = getvardata("debug", false, 99); //echo "<!-- in login with [$shortcut] -->\n"; // ok if we have username & password, let's see if we can find a match $showpage = "false"; $errstate = ""; if (strlen($username) > 0 && strlen($password) > 0) { $sql = "select password from accounts where username=\"{$username}\" limit 1"; if ($debug) { echo "<!-- sql[{$sql}] -->\n"; }
session_start(); } $start = time(); $webname = $_SERVER["SERVER_NAME"]; $scriptname = $_SERVER["PHP_SELF"]; $docroot = $_SERVER["DOCUMENT_ROOT"]; $browser = $_SERVER["HTTP_USER_AGENT"]; $protocol = isset($_SERVER["HTTPS"]) ? "https://" : "http://"; $baseref = "{$protocol}{$webname}"; $modbase = "{$docroot}/tracker"; include_once "{$docroot}/baselib/baselib.php"; include_once "{$docroot}/baselib/iconfig.php"; include_once "objects.php"; // contact database and make sure we have the table setup $shandle = initi("{$docroot}", $modbase); ichecktables($shandle, "activecss", "{$baseref}/css/activecss/activecss.sql"); // proto for trackhit is: //trackhit($shandle,$webname,$scriptname,"theme","$theme"); $btype = !isset($_SESSION["btype"]) ? browsertype($browser) : $_SESSION["btype"]; $block = $btype == "msie" ? "block" : "inline"; //echo "<!-- session:";print_r($_SESSION);echo "-->\n"; $nextact = getvardata("nextact", "home", 99); $activebrowser = getvardata("activebrowser", "msie", 99); $activetheme = getvardata("activetheme", "default", 99); $activepage = getvardata("activepage", "default", 99); $activesection = getvardata("activesection", "default", 99); $debug = getvardata("debug", "false", 99); $elaps = getvardata("elaps", "0.00", 99); $allstylesrbtn = getvardata("allstylesrbtn", "no", 99); // get default browser and default theme $sql = "select theme,css_name,css_selector from activecss where conditional=\"default\" and looking_for=\"browser\" limit 1";