// Find the SVN revision number
function findSVNrevision($svn_dir)
{
// No file, forget it.
if (!file_exists($svn_dir . '/.svn/entries'))
return date('Y-m-d_H-i', time());
// Open the file, read it and close it.
$opened_file = fopen($svn_dir . '/.svn/entries', "r");
$junk = fread($opened_file, 13);
fclose($opened_file);
// Pull out the revision
preg_match("~dir([0-9]*)~mis", str_replace(array("\r", "\n", "\r\n"), '', $junk), $match);
// If it fails.. I guess we get out.
if (empty($match[0]) || empty($match[1]))
return date('Y-m-d_H-i', time());
// woohoo!
return $match[1];
}