function getPage() { $page = checkPage(); $db = new db(); $db->connect(); $pageData = getPageData($page); if (count($pageData) <= 1) { $pageData = getPageData("404"); header("HTTP/1.1 404 Not Found"); } sendPage($pageData); }
$args[] = array('cssMinifier' => array('Minify_CSS', 'minify'), 'jsMinifier' => array('JSMin', 'minify')); } $func = array($_POST['method'], 'minify'); $tpl['inBytes'] = strlen($textIn); $startTime = microtime(true); try { $tpl['output'] = call_user_func_array($func, $args); } catch (Exception $e) { $tpl['exceptionMsg'] = getExceptionMsg($e, $textIn); $tpl['output'] = $textIn; sendPage($tpl); } $tpl['time'] = microtime(true) - $startTime; $tpl['outBytes'] = strlen($tpl['output']); } sendPage($tpl); /** * @param Exception $e * @param string $input * @return string HTML */ function getExceptionMsg(Exception $e, $input) { $msg = "<p>" . h($e->getMessage()) . "</p>"; if (0 === strpos(get_class($e), 'JSMin_Unterminated') && preg_match('~byte (\\d+)~', $e->getMessage(), $m)) { $msg .= "<pre>"; if ($m[1] > 200) { $msg .= h(substr($input, $m[1] - 200, 200)); } else { $msg .= h(substr($input, 0, $m[1])); }