isError()) { exit_error($Group->getErrorMessage(),'summary'); } if (!$Group->usesSCM()) { exit_disabled(); } // check if the scm_box is located in another server $scm_box = $Group->getSCMBox(); //$external_scm = (gethostbyname(forge_get_config('web_host')) != gethostbyname($scm_box)); $external_scm = !forge_get_config('scm_single_host'); if (!forge_check_perm('scm', $Group->getID(), 'read')) { exit_permission_denied('scm'); } if ($external_scm) { //$server_script = "/cgi-bin/viewcvs.cgi"; $server_script = $GLOBALS["sys_path_to_scmweb"]."/viewcvs.cgi"; // remove leading / (if any) $server_script = preg_replace("/^\\//", "", $server_script); // pass the parameters passed to this script to the remote script in the same fashion $script_url = "http://".$scm_box."/".$server_script.$_SERVER["PATH_INFO"]."?".$_SERVER["QUERY_STRING"]; $fh = @fopen($script_url, "r"); if (!$fh) { exit_error(sprintf(_('Could not open script %s.'),$script_url),'home'); } // start reading the output of the script (in 8k chunks) $content = ""; while (!feof($fh)) { $content .= fread($fh, 8192); } if (viewcvs_is_html()) { // Now, we must replace the occurencies of $server_script with this script // (do this only of outputting HTML) // We must do this because we can't pass the environment variable SCRIPT_NAME // to the cvsweb script (maybe this can be fixed in the future?) $content = str_replace("/".$server_script, $_SERVER["SCRIPT_NAME"], $content); } } else { $unix_name = $Group->getUnixName(); // Call to ViewCVS CGI locally (see viewcvs_utils.php) // see what type of plugin this project if using if ($Group->usesPlugin('scmcvs')) { $repos_type = 'cvs'; } elseif ($Group->usesPlugin('scmsvn')) { $repos_type = 'svn'; } // HACK : getSiteMenu in Navigation.class.php use GLOBAL['group_id'] // to fix missing projet name tab $group_id = $Group->getID(); $content = viewcvs_execute($unix_name, $repos_type); } // Set content type header from the value set by ViewCVS // No other headers are generated by ViewCVS because in generate_etags // is set to 0 in the ViewCVS config file $found = false; $line = strtok($content,SEPARATOR); if ($line == 'Status: 301 Moved') { while ($line) { header($line); $line = strtok(SEPARATOR); } exit; } while ($line && !$found) { if (preg_match('/^Content-Type:(.*)$/',$line,$matches)) { header('Content-Type:' . $matches[1]); $found = true; } $line = strtok(SEPARATOR); } $content = substr($content, strpos($content,$line)); if (viewcvs_is_html()) { // If we output html and we found the mbstring extension, we // should try to encode the output of ViewCVS in UTF-8 if (extension_loaded('mbstring')) { $encoding = mb_detect_encoding($content, 'UTF-8, ISO-8859-1'); if($encoding != 'UTF-8') { $content = mb_convert_encoding($content, 'UTF-8', $encoding); } } scm_header(array('title'=>_("SCM Repository"), 'group'=>$Group->getID())); echo $content; scm_footer(array()); } else { // TODO does not seem to work when allow_tar = 1 in ViewCVS conf // (allow to generate on the fly a tar.gz): the generated file // seems to be corrupted echo $content; } // Local Variables: // mode: php // c-file-style: "bsd" // End: