summaryrefslogtreecommitdiff
path: root/config_defaults_inc.php
blob: a3c5ec13b38bc9593a1d3e2f3fb6dba3bc4690e1 (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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<?php
/**
 * @package kernel
 * @subpackage functions
 */

/**
 * required setup
 */

// 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['REQUEST_URI'] = __FILE__;
	$_SERVER['SERVER_ADDR'] = 'localhost';
	$_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;
			}
		}
	}
}

// include the bitweaver configuration file - this needs to happen first
$config_file = empty( $_SERVER['CONFIG_INC'] ) ? BIT_ROOT_PATH.'config/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/kernel/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_CACHE_OBJECTS' ) ) {
	define( 'BIT_CACHE_OBJECTS', TRUE );
}
if( !defined( 'BIT_QUERY_CACHE_TIME' ) ) {
	define( 'BIT_QUERY_CACHE_TIME', 86400 );
}
// default theme after installation
if( !defined( 'DEFAULT_THEME' ) ) {
	define( 'DEFAULT_THEME', 'basic' );
}
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 & ~E_DEPRECATED & ~E_STRICT );
}
// 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" );
}

/* Uncomment to switch to role team model ...
if( !defined( 'ROLE_MODEL' )) {
	define( 'ROLE_MODEL', true );
} */

if( !defined( 'ANONYMOUS_TEAM_ID' ) ) {
	define( 'ANONYMOUS_TEAM_ID', -1 );
}

// Uncomment the following line if you require attachment and file id's to match the content id
// This is used to simplify content mamagment where fisheye and treasury content is used internally
//define( 'LINKED_ATTACHMENTS', true );
// Empty SCRIPT_NAME and incorrect SCRIPT_NAME due to php-cgiwrap - wolff_borg
if( empty( $_SERVER['SCRIPT_NAME'] ) ) {
	$_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['SCRIPT_NAME'], $match );
	$subpath = ( isset($match[0] ) ) ? $match[0] : '/';
	// version two which doesn't work well on it's own
	if( $subpath == "/" ) {
		$subpath = dirname( dirname( $_SERVER['SCRIPT_NAME'] ) );
		$subpath .= ( substr( $subpath,-1,1 )!='/' ) ? '/' : '';
	}
	$subpath = str_replace( '//', '/', str_replace( "\\", '/', $subpath ) ); // do some de-windows-ification
	define( 'BIT_ROOT_URL', $subpath );
}

// 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_BASE_URI' )) {
  // Added check for IIS $_SERVER['HTTPS'] uses 'off' value - wolff_borg
	define( 'BIT_BASE_URI', 'http'.((!empty($_SERVER['HTTPS'])&&$_SERVER['HTTPS'] != 'off')?'s':'').'://'.(empty($_SERVER['HTTP_HOST'])?'localhost':$_SERVER['HTTP_HOST']) );
}

if( !defined( 'BIT_ROOT_URI' )) {
  // Added check for IIS $_SERVER['HTTPS'] uses 'off' value - wolff_borg
	define( 'BIT_ROOT_URI', BIT_BASE_URI.BIT_ROOT_URL );
}

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

if( substr_count( $_SERVER['HTTP_HOST'], '.' ) >= 2 ) {
	define( 'BIT_BASE_HOST', substr( $_SERVER['HTTP_HOST'], strpos( $_SERVER['HTTP_HOST'], '.') + 1 ) );
} else {
	define( 'BIT_BASE_HOST',  $_SERVER['HTTP_HOST'] );
}

// set the currect version of bitweaver
// if this version of bitweaver needs a visit to the installer, update the number in /bit_setup_inc.php
if( !defined( 'BIT_MAJOR_VERSION' ) ) {
	define( 'BIT_MAJOR_VERSION',	'4' );
	define( 'BIT_MINOR_VERSION',	'0' );
	define( 'BIT_SUB_VERSION',		'0' );
	define( 'BIT_LEVEL',			'' ); // dev < alpha < beta < RC# < '' < pl
}

// When updating to certain versions of bitweaver, we need to force a visit to the installer to fix certain stuff in the database.
// Enter the minimum version number here in the format: '2.1.0-beta'
if( !defined( 'MIN_BIT_VERSION' ) ) {
	define( 'MIN_BIT_VERSION', '4.0.0' );
}

// 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( 'KERNEL_PKG_URL',    BIT_ROOT_URL.KERNEL_PKG_DIR.'/' );
define( 'CONFIG_PKG_PATH',    BIT_ROOT_PATH.'config/' );
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/' );
if( !defined( 'STORAGE_PKG_NAME' ) ) {
	define( 'STORAGE_PKG_NAME',   'storage' );
}
if( !defined( 'STORAGE_PKG_PATH' ) ) {
	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/' );
define( 'EXTERNAL_LIBS_PATH',      BIT_ROOT_PATH.'externals/' );


// =================== 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( 'config', 'kernel', 'storage', 'liberty', 'themes', 'users' );
}

// here we set the default thumbsizes we use in bitweaver.
// order matters since successively smaller thumbs are used from the preceding thumb for speed increase.
// you can override these by populating this hash in your config/kernel/config_inc.php
global $gThumbSizes;
if( empty( $gThumbSizes )) {
	$gThumbSizes = array(
		'large'  => array( 'width' => 1200, 'height' => 900 ),
		'medium' => array( 'width' => 800, 'height' => 600 ),
		'small'  => array( 'width' => 400, 'height' => 300 ),
		'avatar' => array( 'width' => 200, 'height' => 150 ),
		'icon'   => array( 'width' => 100,  'height' => 100 ),
	);
}
?>