Location: PHPKode > projects > Xcomic > Xcomic_0.8.3/includes/LatestComicDisplay.class.php
<?php
/**
Xcomic

$Id: LatestComicDisplay.class.php,v 1.4.2.1.2.1 2005/07/22 01:49:07 mikexstudios Exp $
*/

/*
define('IN_XCOMIC', true);

$xcomicRootPath='../';
*/

//$xcomicRootPath is defined in the file that includes this file
//Unfortunately, for sites with register_globals turned on, this poses
//a security theat--especially since $xcomicRootPath is being used in include
//statements. Therefore, check for hacking attempts
if ( !defined('IN_XCOMIC') )
{
	die("Hacking attempt");
}

include_once('ComicDisplay.class.php');



class LatestComicDisplay extends ComicDisplay {

	function LatestComicDisplay() {
		
		$this->ComicDisplay();
		
		$this->getComicInfo($this->getLatestComicId());
		
	}
	
	function getLatestComicId() {

		global $xcomicDb, $message;
		
		# [1074866] Bug with index fixed by Tom Parkison (hide@address.com)
		# Problem was pinpointed to MAX() SQL call requiring an 'AS cid' after MAX().
		$sql = 'SELECT MAX(cid) AS cid
			FROM '.XCOMIC_COMICS_TABLE;
			
		//Make the changes happen
		if(!($result = $xcomicDb->sql_query($sql)))
		{
			echo 'No comic found!';
		}
		
		//Get the result (only one)
		$row = $xcomicDb->sql_fetchrow($result);
		
		//Return latest comic id
		return $row['cid'];
	}
	
}

/*
//Testing ComicDisplay
$x = new LatestComicDisplay();
//$x->getComicInfo(1);
echo $x->getFilename();
*/

?>
Return current item: Xcomic