gforge-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gforge-commits] gforge-plugin-scmcvs/www cvsweb.php,1.1.1.1,1.2


From: cbayle
Subject: [Gforge-commits] gforge-plugin-scmcvs/www cvsweb.php,1.1.1.1,1.2
Date: Fri, 23 Jul 2004 11:20:13 -0500

Update of /cvsroot/gforge/gforge-plugin-scmcvs/www
In directory db.perdue.net:/tmp/cvs-serv32285/www

Modified Files:
        cvsweb.php 
Log Message:
New version adapted mainly by Guillaume Smet to work with new 3.0.1 cvsweb cgi


Index: cvsweb.php
===================================================================
RCS file: /cvsroot/gforge/gforge-plugin-scmcvs/www/cvsweb.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- cvsweb.php  16 May 2004 16:52:22 -0000      1.1.1.1
+++ cvsweb.php  23 Jul 2004 16:20:11 -0000      1.2
@@ -1,38 +1,82 @@
 <?php
+
 /**
   *
   * Gforge cvsweb php wrapper
   *
-  * Copyright 2003 (c) Gforge 
+  * Copyright 2003-2004 (c) Gforge 
   * http://gforge.org
   *
   * @version   $Id$
   *
   */
 
-require_once('www/include/pre.php');    // Initial db and session library, 
opens session
+require_once('pre.php');    // Initial db and session library, opens session
 
-if ("${contenttype}" != "text/plain") {
-       
$HTML->header(array('title'=>$Language->getText('index','welcome'),'pagename'=>'home'));
-} else {
-       header("Content-type: $contenttype" );
+if (!$sys_use_scm) {
+       exit_disabled();
 }
 
-/*
-echo "<H3>QUERY_STRING    =====> $QUERY_STRING <=====</H3>";
-echo "<H3>PATH_INFO       =====> $PATH_INFO <=====</H3>";
-echo "<H3>HTTP_USER_AGENT =====> $HTTP_USER_AGENT <=====</H3>";
-echo "<H3>SCRIPT_NAME     =====> $SCRIPT_NAME <=====</H3>";
-echo "<H3>contenttype     =====> ${contenttype} <=====</H3>";
-*/
+$supportedContentTypes = array('text/html', 'text/x-cvsweb-markup');
 
-passthru("PHPWRAPPER=$SCRIPT_NAME 
/usr/lib/gforge/plugins/scmcvs/cgi-bin/cvsweb.cgi \"$PATH_INFO\" 
\"$QUERY_STRING\" ");
-//putenv("PHPWRAPPER=/scm/cvsweb.php");
-//passthru("/usr/lib/gforge/cgi-bin/cvsweb.cgi \"$PATH_INFO\" 
\"$QUERY_STRING\" ");
-//passthru("PHPWRAPPER=/scm/cvsweb.php /usr/lib/gforge/cgi-bin/cvsweb.cgi 
\"$PATH_INFO\" \"$QUERY_STRING\" ");
+$contentType = 'text/html';
+if(getStringFromGet('cvsroot') && strpos(getStringFromGet('cvsroot'), ';') === 
false) {
+       $projectName = getStringFromGet('cvsroot');
+} else {
+       $queryString = getStringFromServer('QUERY_STRING');
+       if(preg_match_all('/[;]?([^\?;=]+)=([^;]+)/', $queryString, $matches, 
PREG_SET_ORDER)) {
+               for($i = 0, $size = sizeof($matches); $i < $size; $i++) {
+                       $query[$matches[$i][1]] = urldecode($matches[$i][2]);
+               }
+               $projectName = $query['cvsroot'];
+               if(isset($query['content-type'])) {
+                       $contentType = $query['content-type'];
+               }
+       }
+}
+// Remove eventual leading /cvsroot/ or cvsroot/
+$projectName = ereg_replace('^..[^/]*/','', $projectName);
 
-if ("$contenttype" != "text/plain") {
-$HTML->footer(array());
+if ($projectName) {
+       $Group =& group_get_object_by_name($projectName);
+       if (!$Group || !is_object($Group) || $Group->isError()) {
+               exit_no_group();
+       }
+       if (!$Group->isProject()) {
+               
exit_error('Error',$Language->getText('scm_index','error_only_projects_can_use_cvs'));
+       }
+       if (!$Group->usesSCM()) {
+               
exit_error('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'].'/cvsweb')) {
+               exit_permission_denied();
+       }
+       if (in_array($contentType, $supportedContentTypes)) {
+               
site_project_header(array('title'=>$Language->getText('scm_index','cvs_repository'),'group'=>$Group->getID(),'toptab'=>'scm_index','pagename'=>'scm_index','sectionvals'=>array($Group->getPublicName())));
+       } else {
+               header("Content-type: $contentType" );
+       }
+       
+       ob_start();
+       passthru('PHP_WRAPPER="1" 
SCRIPT_NAME="'.getStringFromServer('SCRIPT_NAME').'" 
PATH_INFO="'.getStringFromServer('PATH_INFO').'" 
QUERY_STRING="'.getStringFromServer('QUERY_STRING').'" 
'.$GLOBALS['sys_path_to_scmweb'].'/cvsweb 2>&1');
+       $content = ob_get_contents();
+       ob_end_clean();
+       
+       if(extension_loaded('mb_string')) {
+               $encoding = mb_detect_encoding($content);
+               if($encoding != 'UTF-8') {
+                       $content = mb_convert_encoding($content, 'UTF-8', 
$encoding);
+               }
+       }
+       
+       echo $content;
+       
+       if (in_array($contentType, $supportedContentTypes)) {
+               site_project_footer(array());
+       }
+} else {
+       exit_no_group();
 }
 
 ?>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]