<?php
/**
 * File to handle the config variables
 *
 * This file has various configuration variable required for the
 * entire project. Also using the special comment sytle for that
 * variable the admin can change the variable value from the
 * admin interface.
 *
 * PHP version 5.0
 *
 * @category	Anova
 * @package		###Common###
 * @author 		senthil_52ag05
 * @copyright	Copyright (c) 2009 {@link http://www.agriya.com Agriya Infoway}
 * @license		http://www.agriya.com Agriya Infoway Licence
 * @version		Release: @package_version@
 * @since 		2008-12-18
 */
// ==============================================================================
// 			Available special tags for editing configuration variable
// ==============================================================================
// @var <data type> <description>
// @cfg_sub_head <sub header label>
// @cfg_label <label of the config variable to display on editConfig page>
// @cfg_key <key name to edit config variable and it must be unique>
// @cfg_sec_name <config section label name to display in edit config page>
// @cfg_section <config section key name>
// @cfg_is_password <true/false>
// @cfg_arr_type <associative/key>
// Note : If the @cfg_arr_type is associative they the @cfg_arr_key and @cfg_arr_value are required.
//	   If the @cfg_arr_type is key then @cfg_arr_key is required.
// @cfg_arr_key <array key data type string/int>
// @cfg_arr_value <array value data type string/int>
// ==============================================================================

$CFG['parse_time']['start'] = explode(' ', microtime());
//@todo improve time zone settings
if (function_exists('date_default_timezone_set')) //dirty hack for < 5.1.0
	date_default_timezone_set('Asia/Calcutta');
//@todo remove these lines.. it has to be present in loadconfig.inc.php or so
//if (! ini_get('safe_mode')) //safe mode has no effect
//		set_time_limit(300); //time limit on the execution of script...
//ignore_user_abort(true); //Don't allow user to stop

//site config
//$CFG['site']['url'] = 'http://localhost/framework/';
//or autodetect....
$CFG['site']['modules_arr'] = array('answers', 'forums', 'blog', 'debate');
$folder_names_arr = array('common/', 'admin/', 'cron/');
foreach($CFG['site']['modules_arr'] as $module)
{
	$relative_modules_arr[] = $module.'/';
}
$site_url_arr = array_merge($folder_names_arr , $relative_modules_arr);

$default_ports = array('https' => 443, 'http' => 80);
$prefix = (!empty($_SERVER['HTTPS']) ? 'https' : 'http');
$host = '';
if (isset($_SERVER['HTTP_HOST'])) //some says that this might not be set in IIS
		$host = $_SERVER['HTTP_HOST'];
	else if (isset($_SERVER['SERVER_NAME']))
		$host = $_SERVER['SERVER_NAME'];
$CFG['site']['url'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
                       . $host
                       . str_replace(
					   			$site_url_arr,
					   			'',
								substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/')+1)
							);
$CFG['site']['url'] = strrpos($CFG['site']['url'], '/')==strlen($CFG['site']['url'])-1?$CFG['site']['url']:$CFG['site']['url'].'/';
foreach($CFG['site']['modules_arr'] as $module)
{
	$CFG['site'][$module.'_url']=$CFG['site']['url'].$module.'/';
}
$CFG['site']['relative_url'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
                       . $host
                       . substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/')+1);
$CFG['site']['current_url'] =  $prefix.
								(($_SERVER['SERVER_PORT']!=$default_ports[$prefix]) ?
								':'.$_SERVER['SERVER_PORT'] : '') . '://'
								.$host
								.$_SERVER['REQUEST_URI'];
//PATH_TRANSLATED is removed in SAPI version since PHP 5 or 4.3.2?? Don't use it for auto detection
//Important: Though DIRECTORY_SEPARATOR is always '\' under windows, $_SERVER variables are with '/' in some cases (in SAPI alone?). So fix it.
$slash = (stripos(php_sapi_name(), 'apache')!==false) ? '/' : DIRECTORY_SEPARATOR;
$CFG['site']['project_path'] = str_replace(
									array('\\') + $site_url_arr,
									array('/' ) + array_fill(0, count($folder_names_arr) + count($CFG['site']['modules_arr']), '' ),
								    substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], $slash)+1)
								);
$CFG['site']['project_path'] = strrpos($CFG['site']['project_path'], '/')==strlen($CFG['site']['project_path'])-1?$CFG['site']['project_path']:$CFG['site']['project_path'].'/';
$CFG['site']['project_path_relative'] = str_replace(
											$site_url_arr,
											'',
											substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/')+1)
										);
$CFG['site']['project_path_relative'] = strrpos($CFG['site']['project_path_relative'], '/')==strlen($CFG['site']['project_path_relative'])-1?$CFG['site']['project_path_relative']:$CFG['site']['project_path_relative'].'/';
$CFG['site']['script_name'] = substr($_SERVER['SCRIPT_NAME'], strrpos($_SERVER['SCRIPT_NAME'], '/')+1);
//For div/page id, we need to form "adminfoofoofoo" when...
//$_SERVER['SCRIPT_NAME'] ~ /foo/project/admin/~foo.foo/foo.php
//$CFG['site']['project_path_relative'] ~ /foo/project/
$rel_file_pos = strlen($CFG['site']['project_path_relative']); //@todo optimize
$ext_pos = strrpos($_SERVER['SCRIPT_NAME'], '.php');
$page_id_with_ill_chars = substr($_SERVER['SCRIPT_NAME'], $rel_file_pos, $ext_pos-$rel_file_pos);
$CFG['html']['page_id'] = str_replace( array('/', '.', '~'),  //remove chars that might affect CSS id
										'',
										$page_id_with_ill_chars);
$page_ids_to_remove = array('.', '~', 'admin/', 'answers/', 'forums/', 'blog/', 'debate/');
//$page_ids_to_remove = array('/', '.', '~', 'admin', 'anova', 'forums', 'blog', 'debate');
$CFG['html']['current_script_name'] = str_replace( $page_ids_to_remove,  //remove chars that might affect CSS id
										'',
										$page_id_with_ill_chars);

$CFG['site']['query_string'] = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'])+strlen($_SERVER['SCRIPT_NAME'])+1);
/**
 * @cfg_sub_head 	Site Details
 * @cfg_sec_name
 * @cfg_section 	general_settings
 * @var				string project site name
 * @cfg_label 		Your site name
 * @cfg_key 		site_name
 */
$CFG['site']['name'] = 'Anova';
/**
 * @var				string site title name
 * @cfg_label 		Your site title
 * @cfg_key 		site_title
 */
$CFG['site']['title'] = 'Anova';
/**
 * @var				string webmaster email
 * @cfg_sub_head 	Admin e-mail information
 * @cfg_label 		Webmaster e-mail
 * @cfg_key 		webmaster_email
 */
$CFG['site']['webmaster_email'] = '';
/**
 * @var				string support email
 * @cfg_label 		Support e-mail
 * @cfg_key 		support_email
 */
$CFG['site']['support_email'] = 'test@test.com';
/**
 * @var				string site no-reply name for e-mail
 * @cfg_label 		Site no-reply name for e-mail
 * @cfg_key 		noreply_name
 */
$CFG['site']['noreply_name'] = 'Anova Team';
/**
 * @var				string site no-reply e-mail
 * @cfg_label 		Site no-reply e-mail
 * @cfg_key 		noreply_email
 */
$CFG['site']['noreply_email'] = 'test@test.com';
//Charset
$CFG['site']['charset'] = 'UTF-8';
$CFG['site']['set_default_charset_for_mysqlconnection'] = true;
//SSL (https)
$CFG['ssl']['is_use_ssl'] = false;
//$CFG['ssl']['secure_pages'] = '*';
$CFG['ssl']['secure_pages'][] = $CFG['site']['project_path_relative'].'login.php';
//$CFG['ssl']['secure_pages'][] = $CFG['site']['project_path_relative'].'singup.php';
//Session
$CFG['session']['is_session'] = true;
$CFG['session']['is_custom_handler'] = false;
$CFG['session']['cache_limiter'] = ''; // 'private, must-revalidate' for page expired on back button problems
//html
$CFG['html']['is_use_header'] = true;
$CFG['html']['header'] = 'general/html_header.php';
//html
/**
 * @cfg_sub_head 	HTML information
 * @var				string Meta keywords
 * @cfg_label 		HTML meta keywords
 * @cfg_key 		keywords
 * @cfg_sec_name
 * @cfg_section 	html_settings
 */
$CFG['html']['meta']['keywords'] = 'Anova, Answers Over Video and Audio, Yahoo Answers, Wiki Answers, Video, Audio, Agriya, Text, Share, Knowledge, Rayzz, Online Community';
/**
 * @var				string Meta description
 * @cfg_label 		HTML meta description
 * @cfg_key 		description
 */
$CFG['html']['meta']['description'] = 'Anova - Answers Over Video and Audio. Anova is the first answers script to feature Text, Audio and Video. Making knowledge and learning fun, Anova brings a whole new concept to Answers sites.';
$CFG['html']['meta']['MSSmartTagsPreventParsing'] = true;
$CFG['html']['meta']['imagetoolbar'] = true;
//template
//$CFG['html']['template']['is_template_support'] = true;
//$CFG['html']['template']['default'] = 'anova_lightgreen';
//$CFG['html']['stylesheet']['screen']['default'] = 'screen_lightgreen';
//footer
$CFG['html']['is_use_footer'] = true;
$CFG['html']['footer'] = 'general/html_footer.php';

//data table listing.. records.. control the whole site data table from here
//possibly this can be put up as user preference or something
$CFG['data_tbl']['numperpage_list_arr'] = array(10, 50, 100);
$CFG['data_tbl']['css_alternative_row_classes'] = array('clsTblRow1', 'clsTblRow2', 'clsTblRow3');
$CFG['data_tbl']['min_record_select_limit'] = 1;
$CFG['data_tbl']['max_record_select_limit'] = 50;
//last 5 records are listing for event list.  control the whole site data table from here
//possibly this can be put up as user preference or something
//remote client...
$CFG['remote_client']['ip'] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; //@todo more work
$CFG['remote_client']['user_agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$CFG['remote_client']['is_ie'] = strstr($CFG['remote_client']['user_agent'], 'MSIE 6.0');
$CFG['remote_client']['country_code'] = '';
$CFG['remote_client']['country_name'] = '';
//Config file path relative to admin folder used for parsing in editConfig.php
$CFG['config_path'] = '../common/configs/config.inc.php';
//mods
$CFG['mods']['is_include_only']['html_header'] = false;   //default false
//database
$CFG['db']['is_use_db'] = true;
$CFG['db']['layer'] = 'MySQL 5.0';
$CFG['db']['abstraction'] = 'mysql';
$CFG['admin']['copy_right_year'] = '2009 - 2010';
$CFG['is']['ajax_page'] = false;
//don't change it
$CFG['admin']['module']['lite_version'] = false;

$CFG['mods']['is_include_only']['non_html_header_files'] = false; //default false

require_once($CFG['site']['project_path'].'common/configs/config_user.inc.php');
require_once($CFG['site']['project_path'].'common/configs/config_db.inc.php');
require_once($CFG['site']['project_path'].'common/configs/config_debugmode.inc.php');
require_once($CFG['site']['project_path'].'common/configs/config_redirecturl.inc.php');
require_once($CFG['site']['project_path'].'common/configs/config_mailer.inc.php');
require_once($CFG['site']['project_path'].'common/configs/config_auth.inc.php');
require_once($CFG['site']['project_path'].'common/configs/config_feature.inc.php');
require_once($CFG['site']['project_path'].'common/configs/config_http_headers.inc.php');
require_once($CFG['site']['project_path'].'common/configs/config_miscellaneous.inc.php');
require_once($CFG['site']['project_path'].'common/configs/config_lang.inc.php');
require_once($CFG['site']['project_path'].'common/configs/config_users_table.inc.php');
require_once($CFG['site']['project_path'].'common/configs/config_developer.inc.php');
require_once($CFG['site']['project_path'].'common/configs/config_templates.inc.php');
require_once($CFG['site']['project_path'].'common/configs/config_tables.inc.php');
require_once($CFG['site']['project_path'].'common/configs/config_anova.inc.php');
//include misc classes
require_once($CFG['site']['project_path'].'common/classes/class_FormHandler.lib.php');
require_once($CFG['site']['project_path'].'common/classes/class_HeaderHandler.lib.php');
//----Test cases in standalone mode-----*/
//@todo Remove these lines for security reasons.
if ($CFG['debug']['debug_standalone_modules'])
	{
		echo '<pre>'."\n";
		print_r($GLOBALS);
		//print_r($CFG);
		echo '</pre>'."\n";
	}
if ($CFG['feature']['rewrite_mode']== 'htaccess')
	{
		$CFG['auth']['login_url']['url'] = $CFG['site']['url'].'login/';
		$CFG['auth']['members_url']['url'] = $CFG['site']['url'].'home';
	}
else
	{
		$CFG['auth']['login_url']['url'] = $CFG['site']['url'].'login.php';
		$CFG['auth']['members_url']['url'] = $CFG['site']['url'].'index.php';
	}
?>