<commit_before><?php

	#################################################################

	#
	# make sure the users is signed in. if not, bounce them
	# to the login page, with an optional post-login redirect.
	#

	function login_ensure_loggedin($redir=null){

		if ($GLOBALS['cfg']['user']['id']){
			return;
		}

		if (! $redir){
			# $redir = ltrim($_SERVER['REQUEST_URI'], "/");
			$redir = $_SERVER['REQUEST_URI'];
		}

		header("location: {$GLOBALS['cfg']['abs_root_url']}signin/?redir={$redir}");
		exit;
	}

	#################################################################

	#
	# make sure the user is NOT logged in. if they are, redirect them,
	# optionally logging them out first.
	#

	function login_ensure_loggedout($redir="", $force_logout=false){

		if (! $GLOBALS['cfg']['user']['id']){
			return;
		}

		if ($force_logout){
			login_do_logout();
		}

		header("location: {$GLOBALS['cfg']['abs_root_url']}{$redir}");
		exit;
	}

	#################################################################

	function login_check_login(){<commit_msg>enc_redir all the things<commit_after><?php

	#################################################################

	#
	# make sure the users is signed in. if not, bounce them
	# to the login page, with an optional post-login redirect.
	#

	function login_ensure_loggedin($redir=null){

		if ($GLOBALS['cfg']['user']['id']){
			return;
		}

		if (! $redir){
			$redir = $_SERVER['REQUEST_URI'];
		}

		$enc_redir = urlencode($redir);

		header("location: {$GLOBALS['cfg']['abs_root_url']}signin/?redir={$enc_redir}");
		exit;
	}

	#################################################################

	#
	# make sure the user is NOT logged in. if they are, redirect them,
	# optionally logging them out first.
	#

	function login_ensure_loggedout($redir="", $force_logout=false){

		if (! $GLOBALS['cfg']['user']['id']){
			return;
		}

		if ($force_logout){
			login_do_logout();
		}

		header("location: {$GLOBALS['cfg']['abs_root_url']}{$redir}");
		exit;
	}

	#################################################################

	function login_check_login(){
{'fraction_non_alphanumeric': 0.3330175272382757, 'fraction_numerical': 0.0, 'mean_word_length': 5.380664652567976, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '7455569', 'n_tokens_mistral': 731, 'n_tokens_neox': 642, 'n_words': 136}