<?php
// -------------------------------------------------------------------------------------------------
// this file contains the preamble to execute before all other code runs on every page and AJAX request
// -------------------------------------------------------------------------------------------------


date_default_timezone_set("Europe/London");
define('__ROOT__', dirname(__FILE__)); 

// the versioning suffix, added to the end of all css/js paths; change this to force cache reload of new css/js across the site
define('__VERSUFFIX__', "?v=6666");

// enable output buffering
ob_start();

// -------------------------------------------------------------------------------------------------
// turn on FirePHP so that we have nicer debugging and tracing?
// if it isn't set, we load the FirePHP null adapter that disables all debugging across the site
if (isset($_SERVER["X_ABYSS_STATS_SERVER_TOTAL"]))
{

// fire up FirePHP; need to do this before we do anything else so all debug msgs are captured
require_once('FirePHPCore/FirePHP.class.php');
require_once('FirePHPCore/fb.php');               // FirePHP FB:: namespace
}
else
{
// FirePHP null adapter; disables all verbose debugging
require_once('FirePHPCore/fb-null.php');
}

// -------------------------------------------------------------------------------------------------
// __autoload handler will automatically try and load a class definition when it is first used - 
// this means we don't have to litter "require('class_Listopia.php')" or whatnot everywhere as long
// as we stick to the naming convention below
spl_autoload_register(function ($class_name) {
  $classFile = __ROOT__ . '/class_' . $class_name . '.php';
  require_once($classFile);
});

// -------------------------------------------------------------------------------------------------
class SideBarItem
{
  const __default = self::SignInOrListAdd;
  
  const Welcome = 0;
  const Profile = 1;                // log-in / sign-up if not logged in; otherwise profile overview
  const AddToList = 2;
  const BasicListNavigator = 3;
  const AdvancedListNavigator = 4;
  const Messages = 5;
  const MiniStats = 6;
  const NewListInstructions = 7;
  const NewUserInstructions = 8;
  const PublicDisplayStub = 9;
}

// -------------------------------------------------------------------------------------------------
require_once('inc_messages.php');
require_once('misc_utils.php');

// -------------------------------------------------------------------------------------------------
// make sure the _SESSION context is configured; if it's blank, check if we have an existing
// authentication cookie, which means the user is still signed in but needs their details moved
// back into the current session
Listopia::getInstance()->setupSession();

