/** * If the user is logged in, returns signature URL snippet, in form &signature=SOMETHING. * Otherwise, empty string is returned */ public static function get_signature_text() { global $usr; if (is_array($usr)) { if (isset($_SESSION['signature'])) { $signature = $_SESSION['signature']; } else { $signature = null; } if ($signature == null) { // TODO grhhh, it's not cryptographically strong RNG $signature = sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535)); $_SESSION['signature'] = $signature; } Php7Handler::apc_store($signature, $usr, 3600); # cache it for 1 hour return '&signature=' . $signature; } else { return ''; } }
static function getConfig() { global $debug_page; if (self::$config !== null) { return self::$config; } $useCache = !(isset($debug_page) ? $debug_page : false); $cache_key = 'HTMLPurifierConfig'; $result = $useCache ? Php7Handler::apc_fetch($cache_key) : false; if ($result === false) { $result = self::createConfig(); // finalize and lock the config $result->getHTMLDefinition(); $result->getCSSDefinition(); $result->getURIDefinition(); if ($useCache) { Php7Handler::apc_store($cache_key, $result, 60); # cache it for 60 seconds } } return self::$config = $result; }