<commit_before><?php


/**
 *
 * Friendica
 *
 */

/**
 *
 * bootstrap the application
 *
 */

require_once('boot.php');
require_once('object/BaseObject.php');

$a = new App;
BaseObject::set_app($a);

/**
 *
 * Load the configuration file which contains our DB credentials.
 * Ignore errors. If the file doesn't exist or is empty, we are running in installation mode.
 *
 */

$install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false : true);

@include(".htconfig.php");





/**
 *
 * Try to open the database;
 *
 */

require_once("include/dba.php");

if(!$install) {
	$db = new dba($db_host, $db_user, $db_pass, $db_data, $install);
    	    unset($db_host, $db_user, $db_pass, $db_data);

	/**
	 * Load configs from db. Overwrite configs from .htconfig.php
	 */

	load_config('config');
	load_config('system');

	$maxsysload_frontend = intval(get_config('system','maxloadavg_frontend'));
	if($maxsysload_frontend < 1)
		$maxsysload_frontend = 50;

	$load = current_load();
	if($load) {
		if($load > $maxsysload_frontend) {
			logger('system: load ' . $load . ' too high. Service Temporarily Unavailable.');
			header($_SERVER["SERVER_PROTOCOL"].' 503 Service Temporarily Unavailable');
			header('Retry-After: 300');
			die("System is currently unavailable. Please try again later");
		}
	}


	if (get_config('system','force_ssl') AND ($a->get_scheme() == "http") AND
		(intval(get_config('system','ssl_policy')) == SSL_POLICY_FULL) AND
		(substr($a->get_baseurl(), 0, 8) == "https://")) {
		header("HTTP/1.1 302 Moved Temporarily");
		header("location: ".$a->get_baseurl()."/".$a->query_string);
	}

	require_once("include/session.php");
	load_hooks();
	call_hooks('init_1');

	$maintenance = get_config('system', 'maintenance');
}

$lang = get_browser_language();

load_translation_table($lang);

/**
 *
 * Important stuff we always need to do.
 *
 * The order of these may be important so use caution if you think they're all
 * intertwingled with no logical order and decide to sort it out. Some of the
 * dependencies have changed, but at least at one time in the recent past - the
 * order was critical to everything working properly
 *
 */

session_start();

/**
 * Language was set earlier, but we can over-ride it in the session.<commit_msg>Don't miss to add exit() after header('Location: bla') as header() does *NOT* exit the script quickly enough. Always use an explicit exit() or you get real trouble.<commit_after><?php


/**
 *
 * Friendica
 *
 */

/**
 *
 * bootstrap the application
 *
 */

require_once('boot.php');
require_once('object/BaseObject.php');

$a = new App;
BaseObject::set_app($a);

/**
 *
 * Load the configuration file which contains our DB credentials.
 * Ignore errors. If the file doesn't exist or is empty, we are running in installation mode.
 *
 */

$install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false : true);

@include(".htconfig.php");





/**
 *
 * Try to open the database;
 *
 */

require_once("include/dba.php");

if(!$install) {
	$db = new dba($db_host, $db_user, $db_pass, $db_data, $install);
    	    unset($db_host, $db_user, $db_pass, $db_data);

	/**
	 * Load configs from db. Overwrite configs from .htconfig.php
	 */

	load_config('config');
	load_config('system');

	$maxsysload_frontend = intval(get_config('system','maxloadavg_frontend'));
	if($maxsysload_frontend < 1)
		$maxsysload_frontend = 50;

	$load = current_load();
	if($load) {
		if($load > $maxsysload_frontend) {
			logger('system: load ' . $load . ' too high. Service Temporarily Unavailable.');
			header($_SERVER["SERVER_PROTOCOL"].' 503 Service Temporarily Unavailable');
			header('Retry-After: 300');
			die("System is currently unavailable. Please try again later");
		}
	}


	if (get_config('system','force_ssl') AND ($a->get_scheme() == "http") AND
		(intval(get_config('system','ssl_policy')) == SSL_POLICY_FULL) AND
		(substr($a->get_baseurl(), 0, 8) == "https://")) {
		header("HTTP/1.1 302 Moved Temporarily");
		header("Location: ".$a->get_baseurl()."/".$a->query_string);
		exit();
	}

	require_once("include/session.php");
	load_hooks();
	call_hooks('init_1');

	$maintenance = get_config('system', 'maintenance');
}

$lang = get_browser_language();

load_translation_table($lang);

/**
 *
 * Important stuff we always need to do.
 *
 * The order of these may be important so use caution if you think they're all
 * intertwingled with no logical order and decide to sort it out. Some of the
 * dependencies have changed, but at least at one time in the recent past - the
 * order was critical to everything working properly
 *
 */

session_start();

/**
 * Language was set earlier, but we can over-ride it in the session.
{'fraction_non_alphanumeric': 0.16019520475281138, 'fraction_numerical': 0.007214088690855082, 'mean_word_length': 4.272930648769575, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7091477', 'n_tokens_mistral': 1634, 'n_tokens_neox': 1545, 'n_words': 430}