Beispiel #1
0
 /**
 	Process the pipe.
 
 	This method should be called after the input of the pipe has been
 	sent into the output buffer.
 */
 public function process()
 {
     // Store LaTeX output in a temporary file
     $sTmpFilename = tempnam(null, null);
     file_put_contents($sTmpFilename, ob_get_clean());
     // Convert it to PDF
     $sTmpDir = sys_get_temp_dir();
     $sPdfLatex = 'cd ' . $sTmpDir . ' && pdflatex ' . array_value($this->aParams, 'options') . ' ' . $sTmpFilename;
     exec($sPdfLatex . ' > ' . $sTmpDir . '/pdflatex1.log');
     exec($sPdfLatex . ' > ' . $sTmpDir . '/pdflatex2.log');
     // filesize will trigger a warning if the file couldn't be stat'd (usually because it doesn't exist).
     $iSize = @filesize($sTmpFilename . '.pdf');
     $iSize === false and burn('UnexpectedValueException', _WT(sprintf('The conversion of file "%s" from LaTeX to PDF failed.', $sTmpFilename)));
     // Send the PDF to the browser
     safe_header('Content-Length: ' . $iSize);
     readfile($sTmpFilename . '.pdf');
     // Cleanup the temporary directory
     exec('rm ' . $sTmpFilename . '*');
 }
Beispiel #2
0
 protected function eventInitDB($aEvent)
 {
     $this->runSQLScript(ROOT_PATH . 'app/sql/pastebin.sql');
     safe_header('Location: ' . APP_PATH);
 }
Beispiel #3
0
 /**
 	Entry point for a wee application.
 
 	It translates the event sent by the browser,
 	then dispatch it to the frame and finally
 	orders the frame to render the resulting view.
 */
 public function main()
 {
     if ($this->cnf('app.output.buffer')) {
         if (ini_get('output_buffering') || ini_get('zlib.output_compression') || !$this->cnf('app.output.gzip') || false === ob_start('ob_gzhandler')) {
             ob_start();
         }
     }
     $this->dispatchEvent($this->translateEvent());
     if ($this->oFrame->getStatus() == weeFrame::UNAUTHORIZED_ACCESS) {
         // An UnauthorizedAccessException was thrown; show an error and exit.
         if (defined('WEE_CLI')) {
             echo _WT('You are not allowed to access the specified frame/event.') . "\n";
         } else {
             header('HTTP/1.0 403 Forbidden');
             $sPath = str_replace('//', ROOT_PATH, $this->aConfig['app.error.unauthorized']);
             empty($sPath) and burn(_WT('"app.error.unauthorized" must not be empty.'));
             require $sPath;
         }
         exit;
     }
     if (!defined('WEE_CLI')) {
         safe_header('Content-Type: ' . $this->oFrame->getMIMEType());
         if ($this->sFilename !== null) {
             safe_header('Content-Disposition: attachment; filename="' . urlencode($this->sFilename) . '"');
         }
     }
     $this->oFrame->render();
 }