Changeset 151

Show
Ignore:
Timestamp:
20/07/05 19:08:12 (3 years ago)
Author:
davea
Message:

-- Like This! --
Blog is now aware of what SVN revision it is, and this is displayed at the bottom of each page.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • blog.lib.php

    r149 r151  
    1212// Some useful validation functions 
    1313require_once("validation.lib.php"); 
     14 
     15// Some useful miscellaneous functions 
     16require_once("miscfunctions.lib.php"); 
    1417 
    1518/* a stub of an error handler 
     
    4447        var $entryTags;         //what we allow in the entry 
    4548        var $currentEntry;      // the shortsubject of the current entry (where applicable) 
     49        var $svnRevision;       // the SVN revision number of the currently running blog 
    4650                 
    4751        //Constructor - checks we've been given a valid username, and pulls in generic blog info 
     
    8589                        $this->entryTags = array('<b>','<i>','<strong>','<em>','<p>','<a>','<img>','<hr>','<br>'); 
    8690                        $this->currentEntry = ""; 
     91                        $this->svnRevision = getSVNRevision(); 
    8792 
    8893                        // setup the session 
     
    473478        var $adminPath; 
    474479        var $cssFile; 
     480        var $svnRevision;       // the SVN revision number of the currently running blog 
    475481 
    476482        // don't do anything apart from setting up default variables 
     
    486492                $this->adminPath = $this->httpPath."admin.php/"; 
    487493                $this->cssFile = "blog.css"; 
     494                $this->svnRevision = getSVNRevision(); 
    488495 
    489496                // setup the session purely so we get the debug bits.. 
  • index.php

    r145 r151  
    4242                <p class="sideblurb"> 
    4343                <br /> 
    44                 <a href="http://sucs.org"><img src="<? echo $blog->httpPath."img/sucspow.png"; ?>" alt="<? echo _("Powered by SUCS"); ?>" height="13" width="80" /></a> 
     44                <a href="http://sucs.org"><img alt="<?php echo _("Powered by SUCS Blog r").$blog->svnRevision; ?>" src="<? echo $blog->httpPath."img/sucspow.png"; ?>" height="13" width="80" /></a> 
    4545            </p> 
    4646        </div> 
     
    8686                echo "RSS"; 
    8787        } 
     88        echo " :: "._("SUCS Blog version ").$blog->svnRevision; 
    8889?> 
    8990        </p> 
  • miscfunctions.lib.php

    r148 r151  
    3939} 
    4040 
     41$revision = "unknown"; 
     42function startElement($parser, $name, $attrs) 
     43{ 
     44        global $revision; 
     45        if($name=="ENTRY" && $attrs['NAME']=="") { 
     46                $revision = $attrs['REVISION']; 
     47        } 
     48} 
     49 
     50function endElement($parser, $name){} 
     51 
     52function getSVNRevision() 
     53{ 
     54        global $revision; 
     55        $xml_parser = xml_parser_create(); 
     56        xml_set_element_handler($xml_parser, "startElement", "endElement"); 
     57        if (!($fp = fopen(".svn/entries", "r"))) { 
     58                return "unknown - couldn't open SVN XML file."; 
     59        } 
     60        while(($data = fread($fp, 1024)) && $revision=="unknown") { 
     61                if (!xml_parse($xml_parser, $data, feof($fp))) { 
     62                        return "unknown - couldn't parse SVN XML file"; 
     63                } 
     64        } 
     65        xml_parser_free($xml_parser); 
     66        return $revision; 
     67} 
    4168?>