function parser_open($uu_args, &$real_uri, &$rq_err, &$out_add_headers, &$out_contenttype)
 {
     global $lf, $htreq_headers, $htreq_content, $add_errmsg, $docroot;
     // guess final error code
     if (!file_exists($docroot . $real_uri)) {
         $rq_err = NW_METHOD_PUT_CREATED;
         $add_errmsg = "<b>Resource created.</b><br><br>";
     } else {
         $rq_err = NW_METHOD_PUT_OVERWRITTEN;
         $add_errmsg = "<b>Resource overwritten.</b><br><br>";
     }
     // unsupported stuff
     if (!empty($htreq_headers["CONTENT-RANGE"])) {
         $rq_err = 501;
         $add_errmsg = "Partially overwriting resources is not implemented. ";
     } else {
         // authentication is handled by httpd kernel
         if (!access_query("writeaccess", 0)) {
             $rq_err = 403;
             $add_errmsg = "Only wizards can do that. ";
         } else {
             // backup code goes here
             #...
             // try to open the file
             $put_there = fopen($docroot . $real_uri, NW_BSAFE_WRITE_OPEN);
             // if open failed
             if (!$put_there) {
                 // may be we'll try ftp-method instead?
                 #... (!is_writeable($docroot.$real_uri) && !trim($logged_user))
                 $rq_err = 403;
                 $add_errmsg = "Could not open URI for write access. ";
             } else {
                 fwrite($put_there, $htreq_content);
                 fclose($put_there);
             }
         }
     }
     // replacing ourselfes with a standard error response
     $lf = new static_response(nw_error_page($rq_err, $add_errmsg));
 }
 function parser_open($pri_parser_args, &$real_uri, &$rq_err, &$out_add_headers, &$out_contenttype)
 {
     global $lf, $http_action, $htreq_content;
     global $docroot, $http_uri, $path_info, $pri_parser, $add_nsv;
     // remove "*" again
     $http_action = $this->http_action;
     // handler cgi needs absolute path
     if (!($handler = realpath($docroot . $this->handler))) {
         $lf = new static_response(nw_error_page($rq_err = 500));
     }
     $rq_dest = pathinfo($handler);
     $path_info = "/" . $http_uri;
     $http_uri = $this->handler;
     #-- $add_nsv["SCRIPT_FILENAME"] =
     $add_nsv["PATH_TRANSLATED"] = $handler;
     $add_nsv["REDIRECT_STATUS"] = "200";
     $add_nsv["SCRIPT_NAME"] = $path_info;
     $add_nsv["REDIRECT_URL"] = $path_info;
     $add_nsv["REQUEST_URI"] = $path_info;
     // replace $this with CGI module
     return $ps = loadfile($handler, $rq_dest["extension"], $rq_err, $out_add_headers, $pri_parser);
 }
Пример #3
0
     // Error messages
     if ($rq_err >= 400) {
         if (($errordoc = trim(access_query("_errordocument", "_" . $rq_err))) && @is_readable($docroot . $errordoc)) {
             $add_nsv["REDIRECT_STATUS"] = $rq_err;
             $add_nsv["REDIRECT_URL"] = "/" . $GLOBALS["real_uri"];
             $http_uri = $errordoc;
             $errext = substr(strrchr($errordoc, "."), 1);
             $lf = loadfile($docroot . $errordoc, $errext, $rq_err, $out_add_headers);
             if ($mimetype = $mime[strtolower($errext)]) {
                 $out_contenttype = $mimetype;
             } else {
                 $out_contenttype = $default_ct;
             }
         } else {
             $out_contenttype = "text/html";
             $lf =& new static_response(nw_error_page($rq_err));
             if ($errordoc) {
                 techo("WARN: unable to read error document : [" . $rq_err . "] " . $errordoc, NW_EL_WARNING);
             }
         }
         $cnx = false;
     } else {
         if ($rq_err >= 301) {
             $lf = $null_response;
         }
     }
 }
 if ($http_action == "HEAD") {
     $plen = $lf->content_length;
     $hlf = $lf;
     $lf = $null_response;