view usrlogin.php @ 180:a3f0f2a3551a

Split stylesheets into separate files for different platforms and also split certain page-specifics into their own files.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 07 Nov 2013 11:17:15 +0200
parents 8df523e6326a
children 7181350076c1
line wrap: on
line source

<?
//
// FAPWeb Simple Demoparty System
// Administration interface session login handler
// (C) Copyright 2012-2013 Tecnic Software productions (TNSP)
//
$sessionType = "user";
require_once "mconfig.inc.php";
require_once "msite.inc.php";
require_once "msession.inc.php";

//
// Initialize
//
stSetupCacheControl();

if (!stConnectSQLDB())
  die("Could not connect to SQL database.");

stReloadSettings();


//
// Authenticate
//
$gotoPage = stGetRequestItem("goto", FALSE);
$password = stGetRequestItem("key", FALSE);

$sql = stPrepareSQL("SELECT id FROM votekeys WHERE key=%s", $password);
if (($votekey_id = stFetchSQLColumn($sql)) !== false)
{
  if (!stSessionStart(SESS_USER, $password, "userTimeout"))
  {
    error_log("User session AUTH LOGIN failed (session setup)");
    $gotoPage = "loginerror";
  }
  else
    stSetSessionItem("mode", stGetRequestItem("mode", "error"));
}
else
{
  error_log("User session AUTH LOGIN failed (password)");
  $gotoPage = "loginerror";
}

header("Location: ".($gotoPage !== FALSE ? $gotoPage : stGetSetting("defaultPage")));
?>