id AND !Config::get('demo_mode')) { vauth::logout(session_id()); exit; } /* Load preferences and theme */ $GLOBALS['user']->update_last_seen(); } elseif (!Config::get('use_auth')) { $auth['success'] = 1; $auth['username'] = '-1'; $auth['fullname'] = "Ampache User"; $auth['id'] = -1; $auth['offset_limit'] = 50; $auth['access'] = Config::get('default_auth_level') ? User::access_name_to_level(Config::get('default_auth_level')) : '100'; if (!vauth::session_exists('interface',$_COOKIE[Config::get('session_name')])) { vauth::create_cookie(); vauth::session_create($auth); vauth::check_session(); $GLOBALS['user'] = new User($auth['username']); $GLOBALS['user']->username = $auth['username']; $GLOBALS['user']->fullname = $auth['fullname']; $GLOBALS['user']->access = $auth['access']; } else { vauth::check_session(); if ($_SESSION['userdata']['username']) { $GLOBALS['user'] = User::get_from_username($_SESSION['userdata']['username']); } else { $GLOBALS['user'] = new User($auth['username']); $GLOBALS['user']->id = '-1'; $GLOBALS['user']->username = $auth['username']; $GLOBALS['user']->fullname = $auth['fullname']; $GLOBALS['user']->access = $auth['access']; } if (!$GLOBALS['user']->id AND !Config::get('demo_mode')) { vauth::logout(session_id()); exit; } $GLOBALS['user']->update_last_seen(); } } // If Auth, but no session is set else { if (isset($_REQUEST['sid'])) { session_name(Config::get('session_name')); session_id(scrub_in($_REQUEST['sid'])); session_start(); $GLOBALS['user'] = User::get_from_username($_SESSION['userdata']['username']); } else { $GLOBALS['user'] = new User(); } } // If NO_SESSION passed // Load the Preferences from the database Preference::init(); // We need to create the tmp playlist for our user only if we have a session if (session_id()) { $GLOBALS['user']->load_playlist(); } /* Add in some variables for ajax done here because we need the user */ Config::set('ajax_url',Config::get('web_path') . '/server/ajax.server.php',1); // Load gettext mojo load_gettext(); /* Set CHARSET */ header ("Content-Type: text/html; charset=" . Config::get('site_charset')); /* Clean up a bit */ unset($array); unset($results); /* Setup the flip class */ flip_class(array('odd','even')); /* Check to see if we need to perform an update */ if (!preg_match('/update\.php/', $_SERVER['PHP_SELF'])) { if (Update::need_update()) { header("Location: " . Config::get('web_path') . "/update.php"); exit(); } } // For the XMLRPC stuff $GLOBALS['xmlrpc_internalencoding'] = Config::get('site_charset'); // If debug is on GIMMIE DA ERRORS if (Config::get('debug')) { error_reporting(E_ALL); } ?>