You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Andy Gaskell <a....@nallatech.com> on 2006/07/31 09:31:39 UTC

Useful php webpage to use with viewvc and svn - lists repos and sizes with link to viewvc

Hi Svn users

Have just set up ViewVC on our svn repository server, and wrote a quick
php page (attached code and pasted it at the bottom of email) to list
the repositories and link to the ViewVC for each of them (we have a few
repositories), it also shows the size on disk of the repositories. I
wasn't sure whether to email the list as it's pretty basic code, but I
though some folk might find it useful.  It just sits in the htdocs (in
my case /srv/www/htdocs) folder in a typical svn setup and reads which
folder are in /srv/svn/repos and creates a link to the ViewVC page for
the repository. There is a bit of code that counts and displays the
repository size, but that's just bells and whistles.

Hope this is useful, sorry if not.
ta
Andy Gaskell







---------------------------------------------
Versions tested on

Subversion version 1.1.3 (r12730)
apache2 2.0.53-9
apache2-mod_php4 4.3.10-14 
SuSE 9.3

--------------------
The code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Subversion Repositories List</title>

<style type='text/css'><!--
body {
  font-family: sans-serif;
  background-color: #ffffff;
  margin-left:10px; margin-right:10px; 
  font-size:16px; 
}
--></style>
<meta name='robots' content='index,follow' />
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#000080"
alink="#FF0000"> <h2 align="center">Subversion Repositories List</h2>
<hr width="100%" size="1" /> Repositories - click on links to view with
ViewCVS <ul> <?php 

    // The path to the repo directory 
    $dirpath = "/srv/svn/repos"; 
    $dh = opendir($dirpath); 
    
    while (false !== ($file = readdir($dh))) { 
       
       // ignore the . and .. listings
       if ( '.' === $file | '..' === $file  )  {
           //do nowt
	} else {
           // find out the size
           $fullpath = "$dirpath/$file";
           $du = popen("/usr/bin/du -sk $fullpath", "r");
           $res = fgets($du, 256);
           pclose($du);
           $res = explode("/", $res);
           // see how big it is and show it in MB or GB depending on
result 
           if ( $res[0] > 1000000  )  {
           	$res[0] /= 1000000;
                $res[0] = number_format($res[0], 2);
           	$foldersize = "$res[0] GB"; 
           } else {
           	$res[0] /= 1000;
                $res[0] = number_format($res[0], 2);
           	$foldersize = "$res[0] MB"; 
           }
           // print all the stuff to the webpage
           echo "<li>";
           echo "<a href='/viewcvs/www/cgi/viewcvs.cgi/$file'> $file
</a>   &nbsp;&nbsp;&nbsp;&nbsp; <i> size: $foldersize </i>";
           echo "</li>";
	}
     } 
     // close the directory
     closedir($dh);  
?>
</ul>

<hr width="100%" size="1" />
</body>
</html>

#######################################################################
IMPORTANT - The information in this e-mail is sent in confidence for the 
addressee, may be legally privileged, and should not be communicated in 
any way to any person other than the addressee. If you are not the 
individual or organisation to whom this e-mail is addressed, please 
note that any form of distribution, copying, or use of this communication 
or the information in it, is strictly prohibited and may be unlawful. 
No confidentiality or privilege is waived or lost by any mistransmission. 
If you have received this communication in error, please return it with 
the title "received in error" and delete the message from your computer, 
or alternatively call us on +44 (0)1236 789 500.

Nallatech Ltd. and each of its subsidiaries reserve the right to monitor 
and record all e-mail communications through its networks, to the extent 
permitted by law. 

Any views expressed in this message are those of the individual sender.

Whilst all reasonable care has been taken to avoid the transmission of 
viruses, it is the responsibility of the recipient to ensure that the 
onward transmission, opening or use of this message and any attachments 
will not adversely affect its systems or data. No responsibility is 
accepted by Nallatech Ltd in this regard and the recipient should carry
out such virus and other checks as it considers appropriate.

######################################################################

Re: Useful php webpage to use with viewvc and svn - lists repos and sizes with link to viewvc

Posted by Nico Kadel-Garcia <nk...@comcast.net>.
Andy Gaskell wrote:
> Hi Svn users
> 
> Have just set up ViewVC on our svn repository server, and wrote a
> quick php page (attached code and pasted it at the bottom of email)
> to list the repositories and link to the ViewVC for each of them (we
> have a few repositories), it also shows the size on disk of the
> repositories. I wasn't sure whether to email the list as it's pretty
> basic code, but I though some folk might find it useful.  It just
> sits in the htdocs (in my case /srv/www/htdocs) folder in a typical
> svn setup and reads which folder are in /srv/svn/repos and creates a
> link to the ViewVC page for the repository. There is a bit of code
> that counts and displays the repository size, but that's just bells
> and whistles. 
> 
> Hope this is useful, sorry if not.
> ta
> Andy Gaskell

Why not send it to the viewvc authors directly?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org