News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu

Paste-1225843922:v:use_geshi-1:v:type-php

Started by SleePy, Nov 05, 2008, 12:12 AM

Previous topic - Next topic

0 Members and 5 Guests are viewing this topic.

SleePy

// 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];
}
No siggy! :D