"true" )); die(); } setlanguage(); $ajax = new Ajax(); $ajax->handleRequest(); /** * Manages all AJAX requests. */ class Ajax { /** * Manages an AJAX request. */ public function handleRequest() { $this->setHeader(); // check token validateSecurityToken(false); if (isset($_GET['module']) && isset($_GET['scope']) && in_array($_GET['module'], getAvailableModules($_GET['scope']))) { enforceUserIsLoggedIn(); if (isset($_GET['useContainer']) && ($_GET['useContainer'] == '1')) { if (!isset($_SESSION['account'])) die(); $module = $_SESSION['account']->getAccountModule($_GET['module']); $module->handleAjaxRequest(); } else { $module = new $_GET['module']($_GET['scope']); $module->handleAjaxRequest(); } } if (!isset($_GET['function'])) { die(); } $function = $_GET['function']; if (!isset($_POST['jsonInput'])) { die(); } $jsonInput = $_POST['jsonInput']; if ($function == 'passwordStrengthCheck') { $this->checkPasswordStrength($jsonInput); } enforceUserIsLoggedIn(); if ($function == 'passwordChange') { $this->managePasswordChange($jsonInput); } elseif ($function == 'upload') { include_once('../../lib/upload.inc'); $typeManager = new \LAM\TYPES\TypeManager(); $uploader = new LAM\UPLOAD\Uploader($typeManager->getConfiguredType($_GET['typeId'])); ob_start(); $jsonOut = $uploader->doUpload(); ob_end_clean(); echo $jsonOut; } } /** * Sets JSON HTTP header. */ private static function setHeader() { if (!headers_sent()) { header('Content-Type: application/json; charset=utf-8'); } } /** * Manages a password change request on the edit account page. * * @param array $input input parameters */ private static function managePasswordChange($input) { $return = $_SESSION['account']->setNewPassword($input); echo json_encode($return); } /** * Checks if a password is accepted by LAM's password policy. * * @param array $input input parameters */ private function checkPasswordStrength($input) { $password = $input['password']; $result = checkPasswordStrength($password, null, null); echo json_encode(array("result" => $result)); } } ?>