/** * Forces a HTTP error page to be displayed. This does not stop script execution, but prevents further output. * * @author Art <*****@*****.**> * * @param int $code The HTTP response code */ protected function httpError($code = 404) { $this->echoOnDestruct = true; ob_clean(); $controller = Alo::$router->getErrController(); $controllerNamespaced = '\\Controller\\' . $controller; Alo::includeonceifexists(DIR_APP . 'controllers' . DIRECTORY_SEPARATOR . strtolower($controller) . '.php'); if (!class_exists($controllerNamespaced, true)) { http_response_code((int) $code); echo 'HTTP ' . Security::unXss($code) . '.'; } else { Alo::$controller = new $controllerNamespaced(); /** @noinspection PhpUndefinedMethodInspection */ Alo::$controller->error($code); ob_flush(); $this->echoOnDestruct = false; } }
/** * Sets the session ID variable & the cookie * * @author Art <*****@*****.**> * @return AbstractSession */ protected function setID() { $c = get($_COOKIE[ALO_SESSION_COOKIE]); if ($c && strlen($c) == 128) { session_id($c); } else { session_id(Security::getUniqid('sha512', 'session')); } \Log::debug('Session ID set to ' . session_id()); return $this; }
/** * Attempts to attach not a file from the disk, but generated contents * * @author Art <*****@*****.**> * * @param string $name The attachment filename * @param string $content The contents * * @return bool * @throws \Exception * @throws \phpmailerException */ function attachContent($name, $content) { $destFilename = Security::getUniqid('md5', 'email_attachment'); $dest = DIR_TMP . $destFilename; if (file_exists($dest)) { //try again return $this->attachContent($name, $content); } elseif (file_put_contents($dest, $content) !== false) { $this->attachedContent[] = $dest; return $this->addAttachment($dest, $name); } else { return false; } }