$value) { $results[$key] = $value; } } $results['raw_web_path'] = $results['web_path']; if (empty($results['http_host'])) { $results['http_host'] = $_SERVER['SERVER_NAME']; } if (empty($results['local_web_path'])) { $results['local_web_path'] = $http_type . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $results['raw_web_path']; } $results['http_port'] = (!empty($results['http_port'])) ? $results['http_port'] : $http_port; $results['web_path'] = $http_type . $results['http_host'] . (($results['http_port'] != 80 && $results['http_port'] != 443) ? ':' . $results['http_port'] : '') . $results['web_path']; $results['site_charset'] = $results['site_charset'] ?: 'UTF-8'; $results['raw_web_path'] = $results['raw_web_path'] ?: '/'; if (!isset($results['max_upload_size'])) { $results['max_upload_size'] = 1048576; } $_SERVER['SERVER_NAME'] = $_SERVER['SERVER_NAME'] ?: ''; if (isset($results['user_ip_cardinality']) && !$results['user_ip_cardinality']) { $results['user_ip_cardinality'] = 42; } /* Variables needed for Auth class */ $results['cookie_path'] = $results['raw_web_path']; $results['cookie_domain'] = $results['http_port']; $results['cookie_life'] = $results['session_cookielife']; $results['cookie_secure'] = $results['session_cookiesecure']; // Library and module includes we can't do with the autoloader require_once $prefix . '/modules/infotools/AmazonSearchEngine.class.php'; require_once $prefix . '/modules/ampacheapi/AmpacheApi.lib.php'; //require_once $prefix . '/lib/vendor/james-heinrich/getid3/getid3/getid3.php'; //require_once $prefix . '/lib/vendor/phpmailer/phpmailer/class.phpmailer.php'; //require_once $prefix . '/lib/vendor/phpmailer/phpmailer/class.smtp.php'; //require_once $prefix . '/lib/vendor/mikealmond/musicbrainz/src/MusicBrainz.php'; //require_once $prefix . '/lib/vendor/mikealmond/musicbrainz/src/Exception.php'; //require_once $prefix . '/lib/vendor/mikealmond/musicbrainz/src/Clients/MbClient.php'; //require_once $prefix . '/lib/vendor/mikealmond/musicbrainz/src/Clients/RequestsMbClient.php'; //require_once $prefix . '/lib/vendor/mikealmond/musicbrainz/src/Artist.php'; //require_once $prefix . '/lib/vendor/mikealmond/musicbrainz/src/Filters/AbstractFilter.php'; //require_once $prefix . '/lib/vendor/mikealmond/musicbrainz/src/Filters/FilterInterface.php'; //require_once $prefix . '/lib/vendor/mikealmond/musicbrainz/src/Filters/ArtistFilter.php'; /* Temp Fixes */ $results = Preference::fix_preferences($results); AmpConfig::set_by_array($results, true); // Modules (These are conditionally included depending upon config values) if (AmpConfig::get('ratings')) { require_once $prefix . '/lib/rating.lib.php'; } /* Set a new Error Handler */ $old_error_handler = set_error_handler('ampache_error_handler'); /* Check their PHP Vars to make sure we're cool here */ $post_size = @ini_get('post_max_size'); if (substr($post_size,strlen($post_size)-1,strlen($post_size)) != 'M') { /* Sane value time */ ini_set('post_max_size','8M'); } // In case the local setting is 0 ini_set('session.gc_probability','5'); if (!isset($results['memory_limit']) || (UI::unformat_bytes($results['memory_limit']) < UI::unformat_bytes('32M')) ) { $results['memory_limit'] = '32M'; } set_memory_limit($results['memory_limit']); /**** END Set PHP Vars ****/ // If we want a session if (!defined('NO_SESSION') && AmpConfig::get('use_auth')) { /* Verify their session */ if (!Session::exists('interface', $_COOKIE[AmpConfig::get('session_name')])) { if (!Session::auth_remember()) { Auth::logout($_COOKIE[AmpConfig::get('session_name')]); exit; } } // This actually is starting the session Session::check(); /* Create the new user */ $GLOBALS['user'] = User::get_from_username($_SESSION['userdata']['username']); /* If the user ID doesn't exist deny them */ if (!$GLOBALS['user']->id && !AmpConfig::get('demo_mode')) { Auth::logout(session_id()); exit; } /* Load preferences and theme */ $GLOBALS['user']->update_last_seen(); } elseif (!AmpConfig::get('use_auth')) { $auth['success'] = 1; $auth['username'] = '-1'; $auth['fullname'] = "Ampache User"; $auth['id'] = -1; $auth['offset_limit'] = 50; $auth['access'] = AmpConfig::get('default_auth_level') ? User::access_name_to_level(AmpConfig::get('default_auth_level')) : '100'; if (!Session::exists('interface', $_COOKIE[AmpConfig::get('session_name')])) { Session::create_cookie(); Session::create($auth); Session::check(); $GLOBALS['user'] = new User($auth['username']); $GLOBALS['user']->username = $auth['username']; $GLOBALS['user']->fullname = $auth['fullname']; $GLOBALS['user']->access = intval($auth['access']); } else { Session::check(); 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 = intval($auth['access']); } if (!$GLOBALS['user']->id AND !AmpConfig::get('demo_mode')) { Auth::logout(session_id()); exit; } $GLOBALS['user']->update_last_seen(); } } // If Auth, but no session is set else { if (isset($_REQUEST['sid'])) { session_name(AmpConfig::get('session_name')); session_id(scrub_in($_REQUEST['sid'])); session_start(); $GLOBALS['user'] = new User($_SESSION['userdata']['uid']); } else { $GLOBALS['user'] = new User(); } } // If NO_SESSION passed $GLOBALS['user']->format(false); // Load the Preferences from the database Preference::init(); if (session_id()) { Session::extend(session_id()); // We only need to create the tmp playlist if we have a session $GLOBALS['user']->load_playlist(); } /* Add in some variables for ajax done here because we need the user */ AmpConfig::set('ajax_url', AmpConfig::get('web_path') . '/server/ajax.server.php', true); AmpConfig::set('ajax_server', AmpConfig::get('web_path') . '/server', true); // Load gettext mojo load_gettext(); /* Set CHARSET */ header ("Content-Type: text/html; charset=" . AmpConfig::get('site_charset')); /* Clean up a bit */ unset($array); unset($results); /* Check to see if we need to perform an update */ if (!defined('OUTDATED_DATABASE_OK')) { if (Update::need_update()) { header("Location: " . AmpConfig::get('web_path') . "/update.php"); exit(); } } // For the XMLRPC stuff $GLOBALS['xmlrpc_internalencoding'] = AmpConfig::get('site_charset'); // If debug is on GIMMIE DA ERRORS if (AmpConfig::get('debug')) { error_reporting(E_ALL); }