BMLT Root Server
index.php
Go to the documentation of this file.
1 <?php
2 /**
3  This file is part of the Basic Meeting List Toolbox (BMLT).
4 
5  Find out more at: https://bmlt.app
6 
7  BMLT is free software: you can redistribute it and/or modify
8  it under the terms of the MIT License.
9 
10  BMLT is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  MIT License for more details.
14 
15  You should have received a copy of the MIT License along with this code.
16  If not, see <https://opensource.org/licenses/MIT>.
17 
18  Version: 1.2.0
19 */
20 
21 // Comment out for release version.
22 define('DEBUG', 1);
23 define('BMLT_EXEC', 1);
24 require_once(dirname(__FILE__).'/bmlt_semantic.class.php');
25 $uri = '';
26 
27 // If we are inside the Root Server, we simply fetch the local Root Server automatically.
28 if (file_exists(dirname(dirname(__FILE__)).'/server/shared/classes/comdef_utilityclasses.inc.php') && !isset($_GET['ajaxCall'])) {
29  require_once(dirname(dirname(__FILE__)).'/server/config/get-config.php');
30  global $g_do_not_force_port;
31 
32  $from_proxy = array_key_exists("HTTP_X_FORWARDED_PROTO", $_SERVER);
33  if ($from_proxy) {
34  $https = $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https';
35  if (array_key_exists("HTTP_X_FORWARDED_PORT", $_SERVER)) {
36  $port = intval($_SERVER['HTTP_X_FORWARDED_PORT']);
37  } elseif ($https) {
38  $port = 443;
39  } else {
40  $port = 80;
41  }
42  } else {
43  $port = intval($_SERVER['SERVER_PORT']);
44  $https = !empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] !== 'off' || $port == 443) ? true : false;
45  }
46 
47  $url_path = $_SERVER['SERVER_NAME'];
48  $file_path = str_replace('\\', '/', dirname(dirname(dirname(dirname(dirname(__FILE__))))));
49  $my_path = str_replace('\\', '/', dirname(dirname($_SERVER['PHP_SELF'])));
50  $subsequent_path = str_replace($file_path, '', $my_path);
51 
52  // See if we need to add an explicit port to the URI.
53  if (!isset($g_do_not_force_port) || !$g_do_not_force_port) {
54  if (!$https && ($port != 80)) {
55  $url_path .= ":$port";
56  } elseif ($https && ($port != 443)) {
57  $url_path .= ":$port";
58  }
59  }
60 
61  $url_path .= '/'.trim($subsequent_path, '/').'/';
62  $uri = 'http'.($https ? 's' : '').'://'.$url_path;
63  $api_key = get_api_key($uri);
64  $_GET = array ( 'root_server' => $uri, 'direct_workshop' => 1, 'google_api_key' => $api_key, );
65 }
66 
68 
69 /**************************************************************/
70 /** \brief Query the server for its version.
71  This requires that the _bmltRootServerURI data member be valid.
72 
73  \returns an integer that will be MMMmmmfff (M = Major Version, m = Minor Version, f = Fix Version).
74 */
75 /**************************************************************/
76 function get_api_key($bmltRootServerURI)
77 {
78  $ret = "";
79 
80  if ($bmltRootServerURI) {
81  $error = null;
82 
83  $uri = $bmltRootServerURI.'/client_interface/xml/index.php?switcher=GetServerInfo';
84  $xml = bmlt_semantic::call_curl($uri, $error);
85  if (!$error && $xml) {
86  $info_file = new DOMDocument;
87  if ($info_file instanceof DOMDocument) {
88  if (@$info_file->loadXML($xml)) {
89  $api_key = $info_file->getElementsByTagName("google_api_key");
90  $ret = $api_key->item(0)->nodeValue;
91  }
92  }
93  }
94  }
95 
96  return $ret;
97 }
98 
99 ob_start();
100 ?><!DOCTYPE html>
101 <html lang="en">
102  <head>
103  <meta charset="utf-8" />
104  <title>BMLT Semantic Wizard</title>
105  </head>
106  <body>
107  <?php echo $bmlt_semantic_instance->get_wizard_page_html(); ?>
108 
109  </body>
110 </html><?php ob_end_flush(); ?>
$uri
Definition: index.php:25
if(file_exists($config_file_path)) $url_path
Definition: index.php:64
$ret
Definition: index.php:33
if(file_exists(dirname(dirname(__FILE__)).'/server/shared/classes/comdef_utilityclasses.inc.php')&&!isset($_GET['ajaxCall'])) $bmlt_semantic_instance
Definition: index.php:67
get_api_key($bmltRootServerURI)
Query the server for its version. This requires that the _bmltRootServerURI data member be valid...
Definition: index.php:76
static call_curl($in_uri, &$in_out_http_status=null)
Class function that calls out to a Web site, using cURL.
$https
Definition: installer.php:72
$_GET['switcher']