/** * Reads $length bytes from specified input stream (8192 by default, depending on PHP configuration) * and puts the result in $data as a SimpleXmlElement object. * * @param mixed &$data * @return int * @throws EyeIOException */ public function read(&$data, $length = IInputStream::DEFAULT_READ_LENGTH) { $rawData = null; $res = parent::read($rawData, $length); $data = simplexml_load_string($rawData); return $res; }
public function processRequest(MMapRequest $request, MMapResponse $response) { ob_start("ob_gzhandler"); // header $expires = 60 * 60 * 24 * 90; $response->getHeaders()->append("Pragma: public"); $response->getHeaders()->append("Cache-Control: max-age=" . $expires . ", must-revalidate"); $response->getHeaders()->append('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); if (SYSTEM_TYPE == 'release') { $eyeosjs = file_get_contents('extern/js/eyeos.compressed.js'); if (!file_exists(SERVICE_MMAP_PATH . '/cache/basesystem.cache')) { $fileInputStreams = array(); foreach (self::$scripts as &$scriptPath) { $fileInputStreams[] = new FileInputStream($scriptPath); } $data = ""; foreach ($fileInputStreams as $file) { $reader = new BasicInputStreamReader($file); $data .= $reader->readAll(); } file_put_contents(SERVICE_MMAP_PATH . '/cache/basesystem.cache', JSMin::minify($data)); } } $body = '<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="icon" type="image/png" href="index.php?extern=images/favicon.png" /> <script type="text/javascript"'; if (SYSTEM_TYPE == 'release') { $body .= '>' . $eyeosjs; } else { $body .= ' src="index.php?extern=js/eyeos.js">'; } $body .= '</script> <script type="text/javascript"> ' . file_get_contents('extern/js/qx.js') . ' </script> '; if (SYSTEM_TYPE == 'release') { $body .= '<script>' . file_get_contents(SERVICE_MMAP_PATH . '/cache/basesystem.cache') . '</script>'; } else { foreach (self::$scripts as $script) { $body .= '<script type="text/javascript" src="eyeos/'; $body .= $script; $body .= '"></script>' . "\n"; } } $body .= '<script src="eyeos/extern/js/tinymce/jscripts/tiny_mce/tiny_mce_gzip.js"></script> <script type="text/javascript"> if (document.addEventListener) { document.addEventListener("DOMContentLoaded", eyeos.bootstrap, false); } else if (document.attachEvent) { document.attachEvent("onreadystatechange", function () { if (document.readyState == "complete") { eyeos.bootstrap(); } }); } else { window.onload = eyeos.bootstrap; } </script> <title>Welcome to eyeOS ' . EYE_VERSION . '</title> </head> <body></body> </html>'; $response->setBody($body); }
public function getRenderedBody() { $buffer = ''; foreach ($this->inputStreams as $inputStream) { $reader = new BasicInputStreamReader($inputStream); $buffer .= $reader->readAll(); unset($reader); } return $buffer; }
/** * Reads the file and returns its content. * Note: At the end of the operation, the handler on the file will be closed. * * @param int $chunkSize The length of the chunks (in bytes) that will be read in the * loop until the end of the file. * @return string The content of the file. * @throws EyeIOException * @throws EyeFileNotFoundException */ public function readFile($chunkSize = IInputStream::DEFAULT_READ_LENGTH) { return parent::readAll($chunkSize); }