<commit_before><?php
// (c) Copyright 2002-2012 by authors of the Tiki Wiki CMS Groupware Project
// 
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$

//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
	header("location: index.php");
	exit;
}
require_once ('tiki-filter-base.php');
// ---------------------------------------------------------------------
// basic php conf adjustment
// xhtml compliance
ini_set('arg_separator.output', '&amp;');
// URL session handling is not safe or pretty
// better avoid using trans_sid for security reasons
ini_set('session.use_only_cookies', 1);
// true, but you cannot change the url_rewriter.tags in safe mode ...
// its usually safe to leave it as is.
//ini_set('url_rewriter.tags', '');
// use shared memory for sessions (useful in shared space)
// ini_set('session.save_handler', 'mm');
// ... or if you use turck mmcache
// ini_set('session.save_handler', 'mmcache');
// ... or if you just cant to store sessions in file
// ini_set('session.save_handler', 'files');
// Smarty workaround - if this would be 'On' in php.ini Smarty fails to parse tags
ini_set('magic_quotes_sybase', 'Off');
ini_set('magic_quotes_runtime', 0);
ini_set('allow_call_time_pass_reference', 'On');
// ---------------------------------------------------------------------
// inclusions of mandatory stuff and setup
require_once ('lib/tikiticketlib.php');
require_once ('db/tiki-db.php');
require_once ('lib/tikilib.php');
$tikilib = new TikiLib;
// Get tiki-setup_base needed preferences in one query
$prefs = array();
$needed_prefs = array(
	'session_lifetime' => '0',
	'session_storage' => 'default',
	'session_silent' => 'n',
	'session_cookie_name' => session_name(),
	'session_protected' => 'n',
	'tiki_cdn' => '',
	'tiki_cdn_ssl' => '',
	'language' => 'en',
	'lang_use_db' => 'n',
	'feature_fullscreen' => 'n',
	'error_reporting_level' => 0,
	'smarty_notice_reporting' => 'n',
	'memcache_enabled' => 'n',
	'memcache_expiration' => 3600,
	'memcache_prefix' => 'tiki_',
	'memcache_compress' => 'y',
	'memcache_servers' => false,
	'min_pass_length' => 5,
	'pass_chr_special' => 'n',
	'smarty_compilation' => 'modified',
);
// check that tiki_preferences is there
if ($tikilib->query("SHOW TABLES LIKE 'tiki_preferences'")->numRows() == 0) {
	// smarty not initialised at this point to do a polite message, sadly
	header('location: tiki-install.php');
	exit;
}
$tikilib->get_preferences($needed_prefs, true, true);

if ($prefs['session_protected'] == 'y' && ! isset($_SERVER['HTTPS'])) {
	header("Location: https://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}");
	exit;
}

global $cachelib;
require_once ('lib/cache/cachelib.php');
global $logslib;
require_once ('lib/logs/logslib.php');
include_once ('lib/init/tra.php');
require_once ('lib/tikidate.php');
$tikidate = new TikiDate();
// set session lifetime
if ($prefs['session_lifetime'] > 0) {
	ini_set('session.gc_maxlifetime', $prefs['session_lifetime'] * 60);
}
// is session data  stored in DB or in filesystem?
if ($prefs['session_storage'] == 'db') {
	if ($api_tiki == 'adodb') {
		require_once ('lib/tikisession-adodb.php');
	} elseif ($api_tiki == 'pdo') {
		require_once ('lib/tikisession-pdo.php');
	}
} elseif ( $prefs['session_storage'] == 'memcache' && TikiLib::lib("memcach")->isEnabled() ) {
	require_once ('lib/tikisession-memcache.php');
}

if ( ! isset( $prefs['session_cookie_name'] ) || empty( $prefs['session_cookie_name'] ) ) {
	$prefs['session_cookie_name'] = session_name();
}

session_name($prefs['session_cookie_name']);

// Only accept PHP's session ID in URL when the request comes from the tiki server itself
// This is used by features that need to query the server to retrieve tiki's generated html and images (e.g. pdf export)
if (isset($_GET[session_name()]) && $tikilib->get_ip_address() == '127.0.0.1') {
	$_COOKIE[session_name()] = $_GET[session_name()];
	session_id($_GET[session_name()]);
}

$start_session = true;
if ( $prefs['session_silent'] == 'y' && empty($_COOKIE[session_name()]) ) {
	$start_session = false;
}

// If called from the CDN, refuse to execute anything
$cdn_pref = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? $prefs['tiki_cdn_ssl'] : $prefs['tiki_cdn'];
if ( $cdn_pref ) {
	$host = parse_url($cdn_pref, PHP_URL_HOST);
	if (isset($_SERVER['HTTP_HOST']) && $host == $_SERVER['HTTP_HOST'] ) {
		header("HTTP/1.0 410 Gone");
		echo "This is a Content Delivery Network (CDN) to speed up delivery of images, CSS, and javascript files. However, PHP code is not executed.";
		exit;
	}
}
if (isset($_SERVER["REQUEST_URI"])) {
	ini_set('session.cookie_path', str_replace("\\", "/", $tikiroot));
	if ( $start_session ) {
		// enabing silent sessions mean a session is only started when a cookie is presented
		$session_params = session_get_cookie_params();
		session_set_cookie_params($session_params['lifetime'], $tikiroot);
		unset($session_params);
	
		try {
			require_once "Zend/Session.php";
			Zend_Session::start();
		} catch( Zend_Session_Exception $e ) {
			// Ignore
		}
	}
}

// Moved here from tiki-setup.php because smarty use a copy of session
if ($prefs['feature_fullscreen'] == 'y') {
	require_once ('lib/setup/fullscreen.php');
}
// Retrieve all preferences
require_once ('lib/setup/prefs.php');
// Smarty needs session since 2.6.25
global $smarty; require_once ('lib/init/smarty.php');

if ($prefs['ids_enabled'] == 'y') {<commit_msg>[FIX] Check if the pref ids_enabled is set before comparing, to get rid of warning<commit_after><?php
// (c) Copyright 2002-2012 by authors of the Tiki Wiki CMS Groupware Project
// 
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$

//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
	header("location: index.php");
	exit;
}
require_once ('tiki-filter-base.php');
// ---------------------------------------------------------------------
// basic php conf adjustment
// xhtml compliance
ini_set('arg_separator.output', '&amp;');
// URL session handling is not safe or pretty
// better avoid using trans_sid for security reasons
ini_set('session.use_only_cookies', 1);
// true, but you cannot change the url_rewriter.tags in safe mode ...
// its usually safe to leave it as is.
//ini_set('url_rewriter.tags', '');
// use shared memory for sessions (useful in shared space)
// ini_set('session.save_handler', 'mm');
// ... or if you use turck mmcache
// ini_set('session.save_handler', 'mmcache');
// ... or if you just cant to store sessions in file
// ini_set('session.save_handler', 'files');
// Smarty workaround - if this would be 'On' in php.ini Smarty fails to parse tags
ini_set('magic_quotes_sybase', 'Off');
ini_set('magic_quotes_runtime', 0);
ini_set('allow_call_time_pass_reference', 'On');
// ---------------------------------------------------------------------
// inclusions of mandatory stuff and setup
require_once ('lib/tikiticketlib.php');
require_once ('db/tiki-db.php');
require_once ('lib/tikilib.php');
$tikilib = new TikiLib;
// Get tiki-setup_base needed preferences in one query
$prefs = array();
$needed_prefs = array(
	'session_lifetime' => '0',
	'session_storage' => 'default',
	'session_silent' => 'n',
	'session_cookie_name' => session_name(),
	'session_protected' => 'n',
	'tiki_cdn' => '',
	'tiki_cdn_ssl' => '',
	'language' => 'en',
	'lang_use_db' => 'n',
	'feature_fullscreen' => 'n',
	'error_reporting_level' => 0,
	'smarty_notice_reporting' => 'n',
	'memcache_enabled' => 'n',
	'memcache_expiration' => 3600,
	'memcache_prefix' => 'tiki_',
	'memcache_compress' => 'y',
	'memcache_servers' => false,
	'min_pass_length' => 5,
	'pass_chr_special' => 'n',
	'smarty_compilation' => 'modified',
);
// check that tiki_preferences is there
if ($tikilib->query("SHOW TABLES LIKE 'tiki_preferences'")->numRows() == 0) {
	// smarty not initialised at this point to do a polite message, sadly
	header('location: tiki-install.php');
	exit;
}
$tikilib->get_preferences($needed_prefs, true, true);

if ($prefs['session_protected'] == 'y' && ! isset($_SERVER['HTTPS'])) {
	header("Location: https://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}");
	exit;
}

global $cachelib;
require_once ('lib/cache/cachelib.php');
global $logslib;
require_once ('lib/logs/logslib.php');
include_once ('lib/init/tra.php');
require_once ('lib/tikidate.php');
$tikidate = new TikiDate();
// set session lifetime
if ($prefs['session_lifetime'] > 0) {
	ini_set('session.gc_maxlifetime', $prefs['session_lifetime'] * 60);
}
// is session data  stored in DB or in filesystem?
if ($prefs['session_storage'] == 'db') {
	if ($api_tiki == 'adodb') {
		require_once ('lib/tikisession-adodb.php');
	} elseif ($api_tiki == 'pdo') {
		require_once ('lib/tikisession-pdo.php');
	}
} elseif ( $prefs['session_storage'] == 'memcache' && TikiLib::lib("memcach")->isEnabled() ) {
	require_once ('lib/tikisession-memcache.php');
}

if ( ! isset( $prefs['session_cookie_name'] ) || empty( $prefs['session_cookie_name'] ) ) {
	$prefs['session_cookie_name'] = session_name();
}

session_name($prefs['session_cookie_name']);

// Only accept PHP's session ID in URL when the request comes from the tiki server itself
// This is used by features that need to query the server to retrieve tiki's generated html and images (e.g. pdf export)
if (isset($_GET[session_name()]) && $tikilib->get_ip_address() == '127.0.0.1') {
	$_COOKIE[session_name()] = $_GET[session_name()];
	session_id($_GET[session_name()]);
}

$start_session = true;
if ( $prefs['session_silent'] == 'y' && empty($_COOKIE[session_name()]) ) {
	$start_session = false;
}

// If called from the CDN, refuse to execute anything
$cdn_pref = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? $prefs['tiki_cdn_ssl'] : $prefs['tiki_cdn'];
if ( $cdn_pref ) {
	$host = parse_url($cdn_pref, PHP_URL_HOST);
	if (isset($_SERVER['HTTP_HOST']) && $host == $_SERVER['HTTP_HOST'] ) {
		header("HTTP/1.0 410 Gone");
		echo "This is a Content Delivery Network (CDN) to speed up delivery of images, CSS, and javascript files. However, PHP code is not executed.";
		exit;
	}
}
if (isset($_SERVER["REQUEST_URI"])) {
	ini_set('session.cookie_path', str_replace("\\", "/", $tikiroot));
	if ( $start_session ) {
		// enabing silent sessions mean a session is only started when a cookie is presented
		$session_params = session_get_cookie_params();
		session_set_cookie_params($session_params['lifetime'], $tikiroot);
		unset($session_params);
	
		try {
			require_once "Zend/Session.php";
			Zend_Session::start();
		} catch( Zend_Session_Exception $e ) {
			// Ignore
		}
	}
}

// Moved here from tiki-setup.php because smarty use a copy of session
if ($prefs['feature_fullscreen'] == 'y') {
	require_once ('lib/setup/fullscreen.php');
}
// Retrieve all preferences
require_once ('lib/setup/prefs.php');
// Smarty needs session since 2.6.25
global $smarty; require_once ('lib/init/smarty.php');

if (isset($prefs['ids_enabled']) && $prefs['ids_enabled'] == 'y') {
{'fraction_non_alphanumeric': 0.19187020544925493, 'fraction_numerical': 0.00634864650383564, 'mean_word_length': 4.413842482100239, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1415655', 'n_tokens_mistral': 3947, 'n_tokens_neox': 3794, 'n_words': 993}