Code: Select all
<?php
// {LAST UPDATED} Returns the last time site was updated
// {LAST UPDATED:categoryID} Returns the last time section was updated
function get_newest_update($template_default, $cat, $dbcon) {
$cat = intval($cat);
if($cat){
$appendString="Section Last Updated: ";
}else{
$appendString="Site Last Updated: ";
}
$cat = ($cat) ? 'article_cid='.intval($cat).' AND ' : '';
$sql = "SELECT article_id, article_title, article_cid, UNIX_TIMESTAMP(article_tstamp) AS article_date ".
"FROM ".DB_PREPEND."phpwcms_article WHERE ".$cat.
"article_public=1 AND article_aktiv=1 AND article_deleted=0 AND ".
"article_begin < NOW() AND article_end > NOW() ".
"ORDER BY article_tstamp DESC LIMIT 1";
$updated = "";
if($result = mysql_query($sql, $dbcon)) {
while ($row = mysql_fetch_row($result)) {
$update_date = html_specialchars(international_date_format
($template_default["date_language"], "j F Y", $row[3]));
$updated .= $appendString.$update_date;
}
mysql_free_result($result);
}
return $updated;
}
if(!( strpos($content["all"],'{LAST UPDATED:')===false ) ) {
$content["all"] = preg_replace('/\{LAST UPDATED:{0,1}(\d*)\}/e','get_newest_update($template_default["news"],"$1",$db);',$content["all"]);
}
?>
Site Last Updated: 15 April 2005
Section Last Updated: 11 April 2005