<commit_before><?php

//define('ADMIN_FORCE', true);

$start_time = time();
$start_microtime = microtime();
$GLOBALS['start_time'] = time();
$GLOBALS['start_microtime'] = $start_microtime;
define("APP_DOMAIN", arr_get($_SERVER, 'HTTP_HOST'));

$lastRouter = array('last');

$domain = array(
	APP_DOMAIN => array(
		'blog' => array(
			'/^(?:\/index\.php)?\/p\/([1-9][\d]*)/i'=>array(
				'param'=>array('pid'),
				'm'=>'index'
			)
		)
	)
);

defined('DEFAULT_THEME_NAME')||define('DEFAULT_THEME_NAME', get_theme());
defined('LANG_ZH_CN')||define('LANG_ZH_CN', 'zh_CN');
defined('LANG_EN_US')||define('LANG_EN_US', 'en_US');
defined('DEFAULT_LANG')||define('DEFAULT_LANG', get_lang());
defined('ADMIN_ACCOUNT_ID')||define('ADMIN_ACCOUNT_ID', 1);
defined('ADMIN_ROLE_ID')||define('ADMIN_ROLE_ID', 1);

$basecofig = require './App/conf/baseconfig.php';

if(($timezone = arr_get($basecofig, 'timezone')) !== ''){
	define('TIMEZONE', $timezone);
}


/**
 *
 * &theme=default&switch_theme_once
 *
 * @return string
 */
function get_theme() {

	$themes = array('mobile', 'default', 'new');
	if(preg_match('/^(?:\/index\.php)?\/admin/', arr_get($_SERVER, 'REQUEST_URI'))){
		$themes = array('mobile', 'default');
	}
	if( isset($_GET['theme']) && in_array($_GET['theme'], $themes ) ) {
		isset($_GET['switch_theme_once']) || setcookie('theme', $_GET['theme'], 0, '/');
		return $_GET['theme'];
	}

	if( isset($_COOKIE['theme']) && in_array($_COOKIE['theme'], $themes) ){
		return $_COOKIE['theme'];
	}

	$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
	if( preg_match('/windows|playstation|ipad|ucweb/i', $user_agent ) ) {
		return 'default';
	}

	if( preg_match('/android|iphone\s*os|mobile\s*safari|symbian|iemobile|series40/i', $user_agent ) ) {
		return 'mobile';
	}

	return 'default';
}

function get_lang(){

	$langs = array(LANG_EN_US, LANG_ZH_CN);
	if( isset($_GET['lang']) && in_array($_GET['lang'], $langs ) ) {
		isset($_GET['switch_lang_once']) || setcookie('lang', $_GET['lang'], 0, '/');
		return $_GET['lang'];
	}

	if( isset($_COOKIE['lang']) && in_array($_COOKIE['lang'], $langs) ){
		return $_COOKIE['lang'];
	}

	$http_accept_language = arr_get($_SERVER, 'HTTP_ACCEPT_LANGUAGE', '');
	if(!$http_accept_language){
		return LANG_EN_US;
	}
	$arr = explode(';', $http_accept_language);
	foreach($arr as $k=>$v){
		if(preg_match('/zh/i', $v)){
			return LANG_ZH_CN;
		}elseif(preg_match('/en/i', $v)){
			return LANG_EN_US;
		}
	}
	return LANG_EN_US;
}


/**
 * last router
 */
function last(){
	$rs = q('page')->getAll();
	foreach ($rs as $k=>$v){
		if($v['uri_regexp'] && preg_match($v['uri_regexp'], LML_REQUEST_URI)){
			return r($v['content']);
		}
	}
	Tool::notFoundPage();<commit_msg>template interpreter<commit_after><?php

//define('ADMIN_FORCE', true);

$start_time = time();
$start_microtime = microtime();
$GLOBALS['start_time'] = time();
$GLOBALS['start_microtime'] = $start_microtime;
define("APP_DOMAIN", arr_get($_SERVER, 'HTTP_HOST'));

$lastRouter = array('last');

$domain = array(
	APP_DOMAIN => array(
		'blog' => array(
			'/^(?:\/index\.php)?\/p\/([1-9][\d]*)/i'=>array(
				'param'=>array('pid'),
				'm'=>'index'
			)
		)
	)
);

defined('DEFAULT_THEME_NAME')||define('DEFAULT_THEME_NAME', get_theme());
defined('LANG_ZH_CN')||define('LANG_ZH_CN', 'zh_CN');
defined('LANG_EN_US')||define('LANG_EN_US', 'en_US');
defined('DEFAULT_LANG')||define('DEFAULT_LANG', get_lang());
defined('ADMIN_ACCOUNT_ID')||define('ADMIN_ACCOUNT_ID', 1);
defined('ADMIN_ROLE_ID')||define('ADMIN_ROLE_ID', 1);

$basecofig = require './App/conf/baseconfig.php';

if(($timezone = arr_get($basecofig, 'timezone')) !== ''){
	define('TIMEZONE', $timezone);
}


/**
 *
 * &theme=default&switch_theme_once
 *
 * @return string
 */
function get_theme() {

	$themes = array('mobile', 'default', 'new');
	if(preg_match('/^(?:\/index\.php)?\/admin/', arr_get($_SERVER, 'REQUEST_URI'))){
		$themes = array('mobile', 'default');
	}
	if( isset($_GET['theme']) && in_array($_GET['theme'], $themes ) ) {
		isset($_GET['switch_theme_once']) || setcookie('theme', $_GET['theme'], 0, '/');
		return $_GET['theme'];
	}

	if( isset($_COOKIE['theme']) && in_array($_COOKIE['theme'], $themes) ){
		return $_COOKIE['theme'];
	}

	$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
	if( preg_match('/windows|playstation|ipad|ucweb/i', $user_agent ) ) {
		return 'default';
	}

	if( preg_match('/android|iphone\s*os|mobile\s*safari|symbian|iemobile|series40/i', $user_agent ) ) {
		return 'mobile';
	}

	return 'default';
}

function get_lang(){

	$langs = array(LANG_EN_US, LANG_ZH_CN);
	if( isset($_GET['lang']) && in_array($_GET['lang'], $langs ) ) {
		isset($_GET['switch_lang_once']) || setcookie('lang', $_GET['lang'], 0, '/');
		return $_GET['lang'];
	}

	if( isset($_COOKIE['lang']) && in_array($_COOKIE['lang'], $langs) ){
		return $_COOKIE['lang'];
	}

	$http_accept_language = arr_get($_SERVER, 'HTTP_ACCEPT_LANGUAGE', '');
	if(!$http_accept_language){
		return LANG_EN_US;
	}
	$arr = explode(';', $http_accept_language);
	foreach($arr as $k=>$v){
		if(preg_match('/zh/i', $v)){
			return LANG_ZH_CN;
		}elseif(preg_match('/en/i', $v)){
			return LANG_EN_US;
		}
	}
	return LANG_EN_US;
}


/**
 * last router
 */
function last(){
	$rs = q('page')->getAll();
	foreach ($rs as $k=>$v){
		if($v['uri_regexp'] && preg_match($v['uri_regexp'], LML_REQUEST_URI)){
			return r(template_interpreter($v['content']));
		}
	}
	Tool::notFoundPage();
{'fraction_non_alphanumeric': 0.24286493364842757, 'fraction_numerical': 0.0029085620796218867, 'mean_word_length': 6.1454545454545455, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '1020470', 'n_tokens_mistral': 2265, 'n_tokens_neox': 2160, 'n_words': 300}