aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/configuration.php
blob: d60b7b8f3f37882f81eefd30e42c17c91cd03a1a (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
<?php

	/**
	 * Elgg configuration library
	 * Contains functions for managing system configuration
	 * 
	 * @package Elgg
	 * @subpackage Core
	 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
	 * @author Curverider Ltd
	 * @copyright Curverider Ltd 2008
	 * @link http://elgg.org/
	 */

	/**
	 * If certain configuration elements don't exist, autodetect sensible defaults 
	 * 
	 * @uses $CONFIG The main configuration global
	 *
	 */
		function set_default_config() {
			
			global $CONFIG;
			
			if (empty($CONFIG->path))
				$CONFIG->path = str_replace("\\","/",dirname(dirname(dirname(__FILE__)))) . "/";

			if (empty($CONFIG->viewpath))
				$CONFIG->viewpath = $CONFIG->path . "views/";	

			if (empty($CONFIG->pluginspath))
				$CONFIG->pluginspath = $CONFIG->path . "mod/";
				
			if (empty($CONFIG->wwwroot)) {
				$CONFIG->wwwroot = "http://" . $_SERVER['SERVER_NAME'];
				if (strripos($_SERVER['DOCUMENT_ROOT'],"/") < (sizeof($_SERVER['DOCUMENT_ROOT']) - 1)) {
					$CONFIG->wwwroot .= "/";
				}
				$CONFIG->wwwroot .= str_replace($_SERVER['DOCUMENT_ROOT'],"",$CONFIG->path);
			}
			
			if (empty($CONFIG->url))
				$CONFIG->url = $CONFIG->wwwroot;
			
			if (empty($CONFIG->sitename))
				$CONFIG->sitename = "New Elgg site";
			
		}

?>