Location: PHPKode > projects > GBoook > gbook_v.3.3/inc/functions.inc.php
<?php

function FUNCT_SHOW_FORM($showcaptcha, $ccap = 'TRUE'){
	$themebody = file_get_contents('theme/form.theme.html');
	
	if ($showcaptcha == 1) {
		if ($ccap == 'FALSE'){
			$captcha = 'The validation code was incorrect.';
		}
		$captcha = '<img src="'.URL.'imgsec/image.php" height="30" width="100" align="absmiddle" class="captchaimg"> 
		<input type="text" name="code" class="captchafrm" /><br />';
	}else{
		$captcha = '';
	}
	$hdrpage	= file_get_contents('theme/header.theme.html');
	$ftrpage	= file_get_contents('theme/footer.theme.html');	
	$retval		= $hdrpage.str_replace('%CAPTCHA%',$captcha,$themebody).$ftrpage;
	
	return $retval;
}

function FUNCT_GET_POSTS($more = 10, $smail){
	$display = '';
	$i = '';
	$mainpage = '';
	
	if (!is_numeric($display)){
		$display = 10;
	}
	
	$themebody = file_get_contents('theme/body.theme.html');
	
	$result = mysql_query("SELECT * FROM  groones_guestbook ORDER BY ID DESC LIMIT 0, ".$more); 
	while ($row = @mysql_fetch_array($result)){
		$i++;
		$postdate	= str_replace('%','', $row['my_date']);
		$uname		= str_replace('%','', stripslashes($row['user_name']));
		$gbookmsg	= str_replace('%','', stripslashes($row['message']));
		$gbookmsg = addSmilies($gbookmsg);
		if($smail == 1){
				$uemail = str_replace('%','', $row['email_address']);
		}else{
			$uemail = '';
		}
		
		if (strlen(trim($row['website'])) >= 4){	
			$website = str_replace('%','', $row['website']);
		}else{
			$website = '';
		}
		
		$placeholder = $more - $display;
		if ($placeholder == $i){
			$showmore = '<a name="spot'.$placeholder.'"></a>';
		}else{
			$showmore = '';
		}
		$mainpage .= str_replace('%POSTDATE%',$postdate,$themebody);
		$mainpage = str_replace('%USERNAME%',$uname,$mainpage);
		$mainpage = str_replace('%GBOOKMSG%',$gbookmsg,$mainpage);
		$mainpage = str_replace('%UEMAIL%',$uemail,$mainpage);
		$mainpage = str_replace('%WEBSITE%',$website,$mainpage);
		$mainpage = str_replace('%SHOWMORE%',$showmore,$mainpage);
	}
	
	$anchorlnk = "#spot".$more;
	$display = $more + $display;
	$result = mysql_query("SELECT * FROM  groones_guestbook");
	$tmpcnt = mysql_num_rows($result);
	
	if($tmpcnt > $more){
		$showmore2 = FUNCT_MORE_BUTTON($display, $anchorlnk);
	}else{
		$showmore2 = '';
	}
	
	$hdrpage	= file_get_contents('theme/header.theme.html');
	$ftrpage	= file_get_contents('theme/footer.theme.html');
	$mainpage	= $mainpage.$showmore2;
	$retval		= $hdrpage.$mainpage.$ftrpage;
	
	return $retval;
}

function FUNCT_MORE_BUTTON($mmore, $manchor){
	
	$themepage	= file_get_contents('theme/more_button.theme.html');
	$themepage = str_replace('%PAGEANCHOR%',$manchor,$themepage);
	$retval = str_replace('%NUMBERUP%',$mmore,$themepage);

	return $retval;
}

function addSmilies($text) {

	$codesToConvert = array(
		':)'    =>  '<img src="theme/smilies/smile.png" alt="smile">',
		':-)'   =>  '<img src="theme/smilies/smile.png" alt="smile">',
		':D'    =>  '<img src="theme/smilies/laugh.png" alt="laugh">',
		':d'    =>  '<img src="theme/smilies/laugh.png" alt="laugh">',
		';)'    =>  '<img src="theme/smilies/wink.png" alt="wink">',
		':P'    =>  '<img src="theme/smilies/tounge.png" alt="tounge">',
		':-P'   =>  '<img src="theme/smilies/tounge.png" alt="tounge">',
		':-p'   =>  '<img src="theme/smilies/tounge.png" alt="tounge">',
		':p'    =>  '<img src="theme/smilies/tounge.png" alt="tounge">',
		':('    =>  '<img src="theme/smilies/sad.png" alt="sad">',
		':o'    =>  '<img src="theme/smilies/shock.png" alt="shock">',
		':O'    =>  '<img src="theme/smilies/shock.png" alt="shock">',
		':0'    =>  '<img src="theme/smilies/shock.png" alt="shock">',
		':|'    =>  '<img src="theme/smilies/straight.png" alt="straight">',
		':-|'   =>  '<img src="theme/smilies/straight.png" alt="straight">'
	);

	return (strtr($text, $codesToConvert));

}
?>
Return current item: GBoook