Пример #1
0
 public function finalize()
 {
     if (!in_array($_SERVER['REQUEST_METHOD'], $this->request_methods)) {
         error405();
         return;
     }
     $response = null;
     if ($this->text_html_strip && !is_html_useragent()) {
         if ($this->text_content_type) {
             header('Content-type: text/plain; charset=utf-8');
             header('X-Content-Type-Options: nosniff');
         }
         $response = $this->renderCLI();
     } else {
         $response = '';
         if ($this->wrap_html) {
             $title = idx($this->__help__, 'title', 'Welcome!');
             $response .= "<!doctype html>\n";
             $response .= '<html>';
             $response .= '  <head>';
             $response .= '    <meta charset="utf-8">';
             $response .= '    <meta name="keywords" content="dagd,da.gd,url,' . 'shorten,shortening,open,source,foss,github">';
             $response .= '    <meta name="description" content="The da.gd URL ' . 'shortening service">';
             $response .= '    <title>da.gd: ' . $title . '</title>';
             $response .= '    <style>';
             $response .= '      *:not(pre):not(code) { font-family: sans-serif; }';
             $response .= $this->style;
             $response .= '    </style>';
             $response .= '  </head>';
             $response .= '  <body>';
         }
         $controller_response = $this->render();
         if ($this->escape) {
             $controller_response = htmlspecialchars($controller_response);
         }
         if ($this->wrap_pre) {
             $controller_response = '<pre>' . $controller_response . '</pre>';
         }
         $response .= $controller_response;
         if ($this->wrap_html) {
             $response .= '  </body>';
             $response .= '</html>';
         }
     }
     return $response;
 }
Пример #2
0
function post_only()
{
    if ($_SERVER['REQUEST_METHOD'] != 'POST') {
        error405('POST');
    }
}