summaryrefslogtreecommitdiff
path: root/config_defaults_inc.php
blob: 3553477b9c535faf952103ca121acee57f150e5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
/**
 * @version $Header: /cvsroot/bitweaver/_bit_kernel/config_defaults_inc.php,v 1.38 2008/07/24 08:33:09 squareing Exp $
 * @package kernel
 * @subpackage functions
 */

/**
 * required setup
 */

// include the bitweaver configuration file - this needs to happen first
$config_file = empty( $_SERVER['CONFIG_INC'] ) ? BIT_ROOT_PATH.'kernel/config_inc.php' : $_SERVER['CONFIG_INC'];
if( file_exists( $config_file ) ) {
	include_once( $config_file );
}

// =================== Essential Defines ===================
// These defines can be set in config_inc.php. If they haven't been set, we set default values here
// database settings
if( !defined( 'BIT_DB_PREFIX' ) ) {
	define( 'BIT_DB_PREFIX', '' );
}
if( !defined( 'BIT_QUERY_CACHE_TIME' ) ) {
	define( 'BIT_QUERY_CACHE_TIME', 86400 );
}
// default theme after installation
if( !defined( 'DEFAULT_THEME' ) ) {
	define( 'DEFAULT_THEME', 'basic' );
}
// default icon style. this is the fallback icon style when a {biticon} is missing
if( !defined( 'DEFAULT_ICON_STYLE' ) ) {
	define( 'DEFAULT_ICON_STYLE', 'tango' );
}
if( !defined( 'DISPLAY_ERRORS' ) ) {
	define( 'DISPLAY_ERRORS', 0 );
}
// name of session variable in browser cookie
if( !defined( 'BIT_SESSION_NAME' ) ) {
	define( 'BIT_SESSION_NAME', 'BWSESSION' );
}
// define where errors are sent
if( !defined( 'BIT_PHP_ERROR_REPORTING' ) ) {
	define( 'BIT_PHP_ERROR_REPORTING', E_ALL );
}
// don't change / set _IDs unless you know exactly what you are doing
if( !defined( 'ROOT_USER_ID' ) ) {
	define( 'ROOT_USER_ID', 1 );
}
if( !defined( 'ANONYMOUS_USER_ID' ) ) {
	define( 'ANONYMOUS_USER_ID', -1 );
}
if( !defined( 'ANONYMOUS_GROUP_ID' ) ) {
	define( 'ANONYMOUS_GROUP_ID', -1 );
}
if( !defined( 'EVIL_EXTENSION_PATTERN' )) {
	define( 'EVIL_EXTENSION_PATTERN', "#\.(htaccess|pl|php|php3|php4|phtml|py|cgi|asp|jsp|sh|shtml)$#i" );
}

// Empty PHP_SELF and incorrect SCRIPT_NAME due to php-cgiwrap - wolff_borg
if( empty( $_SERVER['PHP_SELF'] ) ) {
	$_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['SCRIPT_URL'];
}

// BIT_ROOT_URL should be set as soon as the system is installed. until then we
// need to make sure we have the correct value, otherwise installations won't
// work. The recent changes have caused problems during installation. i'll try
// combining both methods by applying the less successful one after the more
// successful one - xing
if( !defined( 'BIT_ROOT_URL' ) ) {
	// version one which seems to only cause problems seldomly
	preg_match( '/.*'.basename( dirname( dirname( __FILE__ ) ) ).'\//', $_SERVER['PHP_SELF'], $match );
	$subpath = ( isset($match[0] ) ) ? $match[0] : '/';
	// version two which doesn't work well on it's own
	if( $subpath == "/" ) {
		$subpath = dirname( dirname( $_SERVER['PHP_SELF'] ) );
		$subpath .= ( substr( $subpath,-1,1 )!='/' ) ? '/' : '';
	}
	$subpath = str_replace( '//', '/', str_replace( "\\", '/', $subpath ) ); // do some de-windows-ification
	define( 'BIT_ROOT_URL', $subpath );
}

// when running scripts
global $gShellScript;
if( !empty( $gShellScript ) ) {
	// keep notices quiet
	$_SERVER['SCRIPT_URL'] = '';
	$_SERVER['HTTP_HOST'] = 'localhost';
	$_SERVER['HTTP_USER_AGENT'] = 'cron';
	$_SERVER['SERVER_NAME'] = '';
	$_SERVER['HTTP_SERVER_VARS'] = '';
	$_SERVER['REMOTE_ADDR'] = 'localhost';
	if( empty( $_SERVER['SERVER_ADMIN'] ) ) {
		$_SERVER['SERVER_ADMIN'] = 'root@localhost';
	}

	// Process some global arguments
	global $gArgs, $argv;
	$gArgs = array();
	if( $argv ) {
		foreach( $argv AS $arg ) {
			switch( $arg ) {
				case '--debug':
					$gDebug = TRUE;
					break;
				case strpos( $arg, '--' ) === 0:
					if( strpos( $arg, '=' ) ) {
						$gArgs[substr( $arg, 2, strpos( $arg, '=' )-2 )] = (int)substr( $arg, (strpos( $arg, '=' ) +1) );
					} else {
						$gArgs[substr( $arg, 2 )] = TRUE;
					}
					break;
			}
		}
	}
}

// If BIT_ROOT_URI hasn't been set yet, we'll try to get one from the super global $_SERVER.
// This works with apache - not sure about other servers.
if( !defined( 'BIT_ROOT_URI' )) {
  // Added check for IIS $_SERVER['HTTPS'] uses 'off' value - wolff_borg
	define( 'BIT_ROOT_URI', 'http'.((!empty($_SERVER['HTTPS'])&&$_SERVER['HTTPS'] != 'off')?'s':'').'://'.$_SERVER['HTTP_HOST'].BIT_ROOT_URL );
}

// custom storage host
if( !defined( 'STORAGE_HOST_URI' ) ) {
	define( 'STORAGE_HOST_URI', BIT_ROOT_URI );
}

// set the currect version of bitweaver
define( 'BIT_MAJOR_VERSION',	'2' );
define( 'BIT_MINOR_VERSION',	'1' );
define( 'BIT_SUB_VERSION',		'0' );
define( 'BIT_LEVEL',			'beta' ); // dev < alpha < beta < '' < pl

// These defines have to happen FIRST because core classes depend on them.
// This means these packages *CANNOT* be renamed
define( 'INSTALL_PKG_PATH',   BIT_ROOT_PATH.'install/' );
define( 'INSTALL_PKG_URL',    BIT_ROOT_URL.'install/' );
define( 'KERNEL_PKG_DIR',     'kernel' );
define( 'KERNEL_PKG_NAME',    'kernel' );
define( 'KERNEL_PKG_PATH',    BIT_ROOT_PATH.'kernel/' );
define( 'LANGUAGES_PKG_PATH', BIT_ROOT_PATH.'languages/' );
define( 'LIBERTY_PKG_DIR',    'liberty' );
define( 'LIBERTY_PKG_NAME',   'liberty' );
define( 'LIBERTY_PKG_PATH',   BIT_ROOT_PATH.'liberty/' );
define( 'STORAGE_PKG_NAME',   'storage' );
define( 'STORAGE_PKG_PATH',   BIT_ROOT_PATH.'storage/' );
define( 'THEMES_PKG_PATH',    BIT_ROOT_PATH.'themes/' );
define( 'USERS_PKG_PATH',     BIT_ROOT_PATH.'users/' );
define( 'UTIL_PKG_PATH',      BIT_ROOT_PATH.'util/' );


// =================== Global Variables ===================
// If for any reason this isn't set, nothing will work - nada, zilch...
if( empty( $gBitDbHost ) ) {
	$gBitDbHost   = 'localhost';
}

// $gPreScan can be used to specify the order in which packages are scanned by
// the kernel.  In the example provided below, the kernel package is processed
// first, followed by the users and liberty packages.  Any packages not
// specified in $gPreScan are processed in the traditional order
global $gPreScan;
if( empty( $gPreScan ) ) {
	$gPreScan = array( 'kernel', 'storage', 'liberty', 'themes', 'users' );
}

// here we set the default thumbsizes we use in bitweaver.
// you can override these by populating this hash in your kernel/config_inc.php
global $gThumbSizes;
if( empty( $gThumbSizes )) {
	$gThumbSizes = array(
		'icon'   => array( 'width' => 48,  'height' => 48 ),
		'avatar' => array( 'width' => 100, 'height' => 100 ),
		'small'  => array( 'width' => 160, 'height' => 120 ),
		'medium' => array( 'width' => 400, 'height' => 300 ),
		'large'  => array( 'width' => 800, 'height' => 600 ),
	);
}
?>