Exemple #1
0
<?php

/**
 * $Id$
 *  
 * @category Outils
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
CCanDo::checkRead();
$session_id = CValue::get("session_id");
$timeout = CValue::get("timeout", 30);
if (!$session_id) {
    global $rootName;
    $session_name = preg_replace("/[^a-z0-9]/i", "", $rootName);
    $session_id = CValue::cookie($session_name);
}
$ip_server = $_SERVER["SERVER_ADDR"];
$smarty = new CSmartyDP();
$smarty->assign("session_id", $session_id);
$smarty->assign("timeout", $timeout);
$smarty->assign("ip_server", $ip_server);
$smarty->display("routage.tpl");
Exemple #2
0
 /**
  * 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;
 }
 /**
  * Log user authentication
  *
  * @param CUser $user The user logging-in
  *
  * @return void
  */
 static function logAuth(CUser $user)
 {
     if (!self::authReady() || $user->dont_log_connection) {
         return;
     }
     global $rootName;
     $session_name = preg_replace("/[^a-z0-9]/i", "", $rootName);
     $app = CAppUI::$instance;
     $auth = new self();
     $auth->user_id = $user->_id;
     $auth->previous_user_id = null;
     $auth->auth_method = $app->auth_method;
     $auth->datetime_login = CMbDT::dateTime();
     $auth->id_address = $app->ip;
     $auth->session_id = session_id();
     // Screen size
     $cookie = CValue::cookie("{$session_name}-uainfo");
     $uainfo = stripslashes($cookie);
     if ($uainfo) {
         $uainfo = json_decode($uainfo, true);
         if (isset($uainfo["screen"])) {
             $screen = $uainfo["screen"];
             $auth->screen_width = (int) $screen[0];
             $auth->screen_height = (int) $screen[1];
         }
     }
     // User agent
     $user_agent_string = CValue::read($_SERVER, "HTTP_USER_AGENT");
     if ($user_agent_string) {
         $user_agent = CUserAgent::createFromUA($user_agent_string);
         $auth->user_agent_id = $user_agent->_id;
     }
     $auth->store();
 }