<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<?php
	/* Some basic checks are in place */
	isset($r) || die("CVSroot must be set\n");
	isset($m) || die("CVSmodule must be set\n");
	isset($f) || die("File must be set\n");
	if(strchr($r, "'") || strchr($m, "'") || strchr($f, "'"))
		die("Invalid characters in arguments\n");
?>
<html>
<head>
	<title> <?php echo "CvsGraph of '$f'\n"; ?></title>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<meta name="generator" content="handcrafted">
</head>
<body bgcolor="#f0f0f0">
<center>
<?php
	/* I'll be paranoid, set root and module here so no one can get access elsewhere */
	/* Remove this or change it to suit your needs */
//	$r = "/home/cvsgraph";
//	$m = "cvsgraph";

	/* Shell escape, PHP4 has functions for this, use them */
	$sr = "'" . $r . "'";
	$sm = "'" . $m . "'";
	$sf = "'" . $f . ",v'";

	/* Image references must be encoded properly */
	$ur = urlencode($r);
	$um = urlencode($m);
	$uf = urlencode($f);
	if(isset($cvsroot) && $cvsroot != "")
		$ucr= "&cvsroot=" . urlencode($cvsroot);	/* The cvsweb.cgi root */
	else
		$ucr = "";

	/* I expose the paths here (accessible via the server). */
	/* Set this to a private place to make it secure. */
	$prefix = "/usr/local";
	$exec_prefix = "${prefix}";
	$cvsgraph = "${exec_prefix}/bin/cvsgraph";
	$cvsgraph_conf = "${prefix}/etc/cvsgraph.conf";

	/* Print a head line */
	echo "<h1>CvsGraph of '$f'</h1>\n";

	/* Generate an imagemap */
	$mapname = "CvsGraphMap";
	$arg9 = "-9 './'";
	$arg8 = "-8 '$ucr'";
	$arg0 = "-0 'Branch:'";
	$arg1 = "-1 'Revision:'";
	$arg2 = "-2 'Diff:'";
	$argM = "-M '$mapname'";
	passthru("$cvsgraph $arg0 $arg1 $arg2 $arg8 $arg9 $argM -i -c $cvsgraph_conf -r $sr -m $sm $sf");

	/* Link a CvsGraph image */
	echo "<img border=\"0\" usemap=\"#$mapname\" src=\"./mkimage.php?r=$ur&amp;m=$um&amp;f=$uf\" alt=\"CvsGraph of '$f'\">\n";
	echo "<p>\nClick on the revisions/branches to display them\n";
	echo "<br>\nClick between the revisions to display the diffs\n";
?>
<hr>
</center>
<address>
Created with <a href="http://www.akhphd.au.dk/~bertho/cvsgraph/">CvsGraph</a>
</address>
</body>
</html>
