// Ignore aborted HTTP request, so that PHP finishes the current script ignore_user_abort(true); // Register shutdown function to end the session register_shutdown_function(array("CSessionHandler", "writeClose")); // Check if the session was made via a temporary token // and save its expiration date if (isset($_SESSION["token_expiration"])) { CAppUI::$token_expiration = $_SESSION["token_expiration"]; } // Reset session if it expired if (CAppUI::isTokenSessionExpired()) { CAppUI::$token_expiration = null; // Free the session data CSessionHandler::end(true); // Start it back CSessionHandler::start(); } // Check if session has previously been initialised if (empty($_SESSION["AppUI"]) || isset($_GET["logout"])) { $_SESSION["AppUI"] = CAppUI::init(); } CAppUI::$instance =& $_SESSION["AppUI"]; CAppUI::$instance->session_name = $session_name; if (!isset($_SESSION["locked"])) { $_SESSION["locked"] = false; } CAppUI::checkSessionUpdate(); if (!isset($_SESSION['browser'])) { /** Basic browser detection */ $browser = array('version' => '0.0.0', 'majorver' => 0, 'minorver' => 0, 'build' => 0, 'name' => 'unknown', 'mobile' => false, 'deprecated' => false, 'useragent' => '', 'ie8' => false); $browsers = array('firefox', 'msie', 'opera', 'chrome', 'safari', 'mozilla', 'seamonkey', 'konqueror', 'netscape', 'gecko', 'navigator', 'mosaic', 'lynx', 'amaya', 'omniweb', 'avant', 'camino', 'flock', 'aol');
/** * Send the request on the server * * @param String $url URL * @param String[] $post Parameters POST * * @return bool|string */ static function serverCall($url, $post = null) { CSessionHandler::writeClose(); global $rootName, $version; $session_name = preg_replace("/[^a-z0-9]/i", "", $rootName); $cookie = CValue::cookie($session_name); $result = array("code" => "", "body" => ""); try { $http_client = new CHTTPClient($url); $http_client->setCookie("{$session_name}={$cookie}"); $http_client->setUserAgent("Mediboard-" . $version["version"]); $http_client->setOption(CURLOPT_FOLLOWLOCATION, true); if ($post) { $request = $http_client->post(http_build_query($post)); } else { $request = $http_client->get(); } } catch (Exception $e) { CSessionHandler::start(); $result["body"] = $e->getMessage(); return $result; } CSessionHandler::start(); $result["code"] = $http_client->last_information["http_code"]; $result["body"] = $request; return $result; }