* Copyright (c) Xerox Corporation, CodeX / CodeX Team, 2001,2002. All Rights Reserved.
* http://codex.xerox.com
*
- * @version $ID$
+ * @version $Id$
*/
// make sure we're not compressing output if we are making a tarball
// Check permissions
$Group =& group_get_object_by_name($projectName);
-if (!$Group || !is_object($Group)) {
- exit_error($Language->getText('general','error'),
- $Language->getText('general','error_creating_group'));
-} else if ($Group->isError()) {
- exit_error($Language->getText('general','error'),
- $Group->getErrorMessage());
+if (!$Group || !is_object($Group) || $Group->isError()) {
+ exit_no_group();
}
if (!$Group->usesSCM()) {
- exit_error($Language->getText('general','error'),
- $Language->getText('scm_index','error_this_project_has_turned_off'));
+ exit_error($Language->getText('general','error'), $Language->getText('scm_index','error_this_project_has_turned_off'));
}
-$perm = & $Group->getPermission(session_get_user());
-if ((!$Group->enableAnonSCM() && !($perm && is_object($perm) && $perm->isMember()))
- || !isset($GLOBALS['sys_path_to_scmweb'])
- || !is_file($GLOBALS['sys_path_to_scmweb'].'/viewcvs.cgi')) {
+
+// check if the scm_box is located in another server
+$scm_box = $Group->getSCMBox();
+$external_scm = (gethostbyname($sys_default_domain) != gethostbyname($scm_box));
+
+if (session_loggedin()) {
+ if (user_ismember($Group->getID())) {
+ $perm = & $Group->getPermission(session_get_user());
+
+ if (!($perm && is_object($perm) && $perm->isCVSReader()) && !$Group->enableAnonSCM()) {
+ exit_permission_denied();
+ }
+ } else if (!$Group->enableAnonSCM()) {
+ exit_permission_denied();
+ }
+
+} else if (!$Group->enableAnonSCM()) { // user is not logged in... check if group accepts anonymous CVS
exit_permission_denied();
}
-// Call to ViewCVS CGI
-$content = viewcvs_execute();
+// User has access to the repository. Check for valid script
+// (only if we're working on a local SVN server, if the SVN server is external the variable
+// $sys_path_to_scmweb points to the path of the viewcvs script on the remote server)
+if (!isset($GLOBALS['sys_path_to_scmweb']) || (!$external_scm && !is_file($GLOBALS['sys_path_to_scmweb'].'/viewcvs.cgi'))) {
+ exit_error('Error',"viewcvs.cgi script doesn't exist in ".$GLOBALS['sys_path_to_scmweb']);
+}
+
+
+if ($external_scm) {
+ $server_script = "/cgi-bin/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('Error', 'Could not open script <b>'.$script_url.'</b>.');
+ }
+
+ // 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 {
+ // Call to ViewCVS CGI locally (see viewcvs_utils.php)
+ $content = viewcvs_execute();
+}
// Set content type header from the value set by ViewCVS
// No other headers are generated by ViewCVS because in generate_etags