コード例 #1
0
ファイル: ViewVCProxy.class.php プロジェクト: ansarbek/tuleap
 public function getContent(HTTPRequest $request)
 {
     $parse = $this->displayViewVcHeader($request);
     $headers = "";
     $body = "";
     //this is very important. default path must be /
     $path = "/";
     if ($request->getFromServer('PATH_INFO') != "") {
         $path = $request->getFromServer('PATH_INFO');
         // hack: path must always end with /
         if (strrpos($path, "/") != strlen($path) - 1) {
             $path .= "/";
         }
     }
     $command = 'HTTP_COOKIE=' . $this->escapeStringFromServer($request, 'HTTP_COOKIE') . ' ' . 'HTTP_USER_AGENT=' . $this->escapeStringFromServer($request, 'HTTP_USER_AGENT') . ' ' . 'REMOTE_ADDR=' . escapeshellarg(HTTPRequest::instance()->getIPAddress()) . ' ' . 'QUERY_STRING=' . $this->cleanQueryString($request) . ' ' . 'SERVER_SOFTWARE=' . $this->escapeStringFromServer($request, 'SERVER_SOFTWARE') . ' ' . 'SCRIPT_NAME=' . $this->escapeStringFromServer($request, 'SCRIPT_NAME') . ' ' . 'HTTP_ACCEPT_ENCODING=' . $this->escapeStringFromServer($request, 'HTTP_ACCEPT_ENCODING') . ' ' . 'HTTP_ACCEPT_LANGUAGE=' . $this->escapeStringFromServer($request, 'HTTP_ACCEPT_LANGUAGE') . ' ' . 'PATH_INFO=' . $this->setLocaleOnFileName($path) . ' ' . 'PATH=' . $this->escapeStringFromServer($request, 'PATH') . ' ' . 'HTTP_HOST=' . $this->escapeStringFromServer($request, 'HTTP_HOST') . ' ' . 'DOCUMENT_ROOT=' . $this->escapeStringFromServer($request, 'DOCUMENT_ROOT') . ' ' . 'CODENDI_LOCAL_INC=' . $this->escapeStringFromServer($request, 'CODENDI_LOCAL_INC') . ' ' . '/var/www/cgi-bin/viewvc.cgi 2>&1';
     $content = $this->setLocaleOnCommand($command);
     list($headers, $body) = http_split_header_body($content);
     $content_type_line = strtok($content, "\n\t\r\v");
     $viewvc_content_type = $this->getViewVcContentType($content_type_line, $path);
     $content = substr($content, strpos($content, $content_type_line));
     $location_line = strtok($content, "\n\t\r\v");
     $viewvc_location = $this->getViewVcLocationHeader($location_line);
     if ($viewvc_location) {
         $content = substr($content, strpos($content, $location_line));
     }
     if ($parse) {
         //parse the html doc that we get from viewvc.
         //remove the http header part as well as the html header and
         //html body tags
         $begin_body = stripos($content, "<body");
         $begin_doc = strpos($content, ">", $begin_body) + 1;
         $length = strpos($content, "</body>\n</html>") - $begin_doc;
         // Now insert references, and display
         return util_make_reference_links(substr($content, $begin_doc, $length), $request->get('group_id'));
     } else {
         if ($viewvc_location) {
             $redirect = new \URLRedirect();
             $redirect->makeReturnToUrl($request, $viewvc_location);
             // TODO: need to test this
             // header('Location: '.$viewvc_location);
             // exit(1);
         }
         header('Content-Type:' . $viewvc_content_type . '; charset=utf-8');
         return $body;
     }
 }
コード例 #2
0
ファイル: utils.php プロジェクト: pombredanne/tuleap
function util_return_to($url)
{
    $request = HTTPRequest::instance();
    $url_redirect = new URLRedirect();
    $GLOBALS['Response']->redirect($url_redirect->makeReturnToUrl($request, $url));
    exit;
}