5 Jappix - An open social platform
6 This is the hosts configuration reader
8 -------------------------------------------------
12 Last revision: 29/05/11
16 // Someone is trying to hack us?
17 if(!defined('JAPPIX_BASE'))
20 // Get the protocol we use
21 if(isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on'))
27 $http_host = 'jappix.com';
29 if($_SERVER['HTTP_HOST']) {
30 $http_host_split = str_replace('www.', '', $_SERVER['HTTP_HOST']);
31 $http_host_split = preg_replace('/:[0-9]+$/i', '', $http_host_split);
34 $http_host = $http_host_split;
37 // Define the default hosts configuration values
40 'muc' => 'muc.'.$http_host,
41 'pubsub' => 'pubsub.'.$http_host,
42 'vjud' => 'vjud.'.$http_host,
43 'anonymous' => 'anonymous.'.$http_host,
44 'bosh' => 'http://'.$http_host.':5280/http-bind',
51 // Define a default values array
52 $hosts_default = $hosts_conf;
54 // Read the hosts configuration file
55 $hosts_data = readXML('conf', 'hosts');
57 // Read the hosts configuration file
59 // Initialize the hosts configuration XML data
60 $hosts_xml = new SimpleXMLElement($hosts_data);
62 // Loop the hosts configuration elements
63 foreach($hosts_xml->children() as $hosts_child) {
64 $hosts_value = $hosts_child->getName();
66 // Only push this to the array if it exists
67 if(isset($hosts_conf[$hosts_value]) && $hosts_child)
68 $hosts_conf[$hosts_value] = str_replace('{PROTOCOL}', $protocol, $hosts_child);
72 // Finally, define the hosts configuration globals
73 define('HOST_MAIN', $hosts_conf['main']);
74 define('HOST_MUC', $hosts_conf['muc']);
75 define('HOST_PUBSUB', $hosts_conf['pubsub']);
76 define('HOST_VJUD', $hosts_conf['vjud']);
77 define('HOST_ANONYMOUS', $hosts_conf['anonymous']);
78 define('HOST_BOSH', $hosts_conf['bosh']);
79 define('HOST_BOSH_MAIN', $hosts_conf['bosh_main']);
80 define('HOST_BOSH_MINI', $hosts_conf['bosh_mini']);
81 define('HOST_STATIC', $hosts_conf['static']);
82 define('HOST_UPLOAD', $hosts_conf['upload']);