/** * $Id$ * * @category Forms * @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 */ $event_name = CValue::post("event_name"); $object_class = CValue::post("object_class"); $form_name = CValue::post("form_name"); $ids = CValue::post("ids"); CSessionHandler::writeClose(); //CExObject::$_load_lite = true; $ex_class_event = new CExClassEvent(); $ds = $ex_class_event->getDS(); $group_id = CGroups::loadCurrent()->_id; $where = array("ex_class_event.host_class" => $ds->prepare("=%", $object_class), "ex_class_event.event_name" => $ds->prepare("=%", $event_name), "ex_class.conditional" => $ds->prepare("=%", 0), $ds->prepare("ex_class.group_id = % OR ex_class.group_id IS NULL", $group_id)); $ljoin = array("ex_class" => "ex_class.ex_class_id = ex_class_event.ex_class_id"); /** @var CExClassEvent[] $ex_class_events */ $ex_class_events = $ex_class_event->loadList($where, null, null, null, $ljoin); $ex_classes = array(); $ex_objects = array(); $count_available = count($ex_class_events); foreach ($ex_class_events as $_ex_class_event) { $_ex_class = $_ex_class_event->loadRefExClass(); $_ex_class->getFormulaField(); $ex_classes[$_ex_class->_id] = $_ex_class;
// 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');
$tplLogin->assign("mediboardStyle", $mediboardStyle); // JS $tplLogin->assign("mediboardScript", CJSLoader::loadFiles()); $tplLogin->assign("errorMessage", CAppUI::getMsg()); $tplLogin->assign("time", time()); $tplLogin->assign("redirect", $redirect); $tplLogin->assign("uistyle", $uistyle); $tplLogin->assign("browser", $browser); $tplLogin->assign("nodebug", true); $tplLogin->assign("offline", false); $tplLogin->assign("allInOne", CValue::get("_aio")); $tplLogin->assign("applicationVersion", $applicationVersion); $tplLogin->display("login.tpl"); } // Destroy the current session and output login page CSessionHandler::end(true); CApp::rip(); } $tab = 1; $m = $m_get = CValue::get("m"); $post_request = $_SERVER['REQUEST_METHOD'] == 'POST'; if ($post_request) { $m = CValue::post("m") ?: $m; } $m = CAppUI::checkFileName($m); if (null == $m) { $m = CPermModule::getFirstVisibleModule(); $parts = explode("-", CAppUI::pref("DEFMODULE"), 2); $pref_module = $parts[0]; if ($pref_module && CPermModule::getViewModule(CModule::getInstalled($pref_module)->mod_id, PERM_READ)) { $m = $pref_module;
/** * PDF conversion of a file * * @param string $file_path path to the file * @param string $pdf_path path the pdf file * * @return bool */ function convertToPDF($file_path = null, $pdf_path = null) { global $rootName; // Vérifier si openoffice est lancé if (!CFile::openofficeLaunched()) { return 0; } // Vérifier sa charge en mémoire CFile::openofficeOverload(); if (!$file_path && !$pdf_path) { $file = new CFile(); $file->setObject($this); $file->private = $this->private; $file->file_name = $this->file_name . ".pdf"; $file->file_type = "application/pdf"; $file->author_id = CAppUI::$user->_id; $file->fillFields(); $file->updateFormFields(); $file->forceDir(); $save_name = $this->_file_path; if ($msg = $file->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); return 0; } $file_path = $this->_file_path; $pdf_path = $file->_file_path; } // Requête post pour la conversion. // Cela permet de mettre un time limit afin de garder le contrôle de la conversion. ini_set("default_socket_timeout", 10); $fileContents = base64_encode(file_get_contents($file_path)); $url = CAppUI::conf("base_url") . "/index.php?m=dPfiles&a=ajax_ooo_convert&suppressHeaders=1"; $data = array("file_data" => $fileContents, "pdf_path" => $pdf_path); // Fermeture de la session afin d'écrire dans le fichier de session CSessionHandler::writeClose(); // Le header Connection: close permet de forcer a couper la connexion lorsque la requête est effectuée $ctx = stream_context_create(array('http' => array('method' => 'POST', 'header' => "Content-type: application/x-www-form-urlencoded charset=UTF-8\r\n" . "Connection: close\r\n" . "Cookie: mediboard=" . session_id() . "\r\n", 'content' => http_build_query($data)))); // La requête post réouvre la session $res = file_get_contents($url, false, $ctx); if (isset($file) && $res == 1) { $file->doc_size = filesize($pdf_path); if ($msg = $file->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); return 0; } } // Si la conversion a échoué // on relance le service s'il ne répond plus. if ($res != 1) { CFile::openofficeOverload(1); } return $res; }
/** * Writes session data (in fact it writes, closes and starts it back) * * @return void */ static function write() { if (!self::$started) { return; } self::writeClose(); self::start(); self::$started = false; }
/** * 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; }
/** * Enable the current view to forced to slave based on a enslaving ratio * * @return void */ static function enableSlave() { // Enslaved views are supposably session stallers so close session preventively CSessionHandler::writeClose(); if (rand(0, 100) < CAppUI::conf("enslaving_ratio")) { self::enforceSlave(); return; } }
CApp::$chrono->start(); $do_login = false; // Load default preferences if not logged in if (!CAppUI::$instance->user_id) { CAppUI::loadPrefs(); try { CApp::notify("UserAuthentication", true); } catch (CUserAuthenticationFailure $e) { CApp::rip(); } catch (CUserAuthenticationSuccess $e) { CAppUI::$auth_info = $e; $do_login = true; } } // Update session lifetime CSessionHandler::setUserDefinedLifetime(); /* try { include __DIR__."/classes/CAuth.class.php"; //CAuth::login(); } catch (AuthenticationFailedException $e) { CAppUI::setMsg($e->getMessage()); } */ // If the user uses a token, his session should not be reset, but only redirected $token_hash = CValue::get("token"); if ($token_hash) { $token = CViewAccessToken::getByHash($token_hash); // If the user is already logged in (in a normal session), keep his session, but use the params if (CAppUI::$instance->user_id && !CAppUI::$token_expiration) {