view usrlogin.php @ 156:fa7f3defffd0

Comments.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 25 Oct 2013 16:12:05 +0300
parents 5b92f130ba87
children 8df523e6326a
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 "mconfig.inc.php";
require "msite.inc.php";
require "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")));
?>