Location: PHPKode > scripts > ifbCache > lib/ifbFunc.php
<?php
/* IFB FUNCTIONS FOR IFBCACHE EXAMPLES
 * Copyright © 2011 Infobull.net, All Rights Reserved
 * License: http://www.gnu.org/licenses/gpl.html
 * Require php 5.2 & higher
 * $Id: ifbFunc.php rev 7 $ Ricko $ 2011/01/08
 * $charset = 'UTF-8'
*/
function displayExample($var,$file)
{
	$fileExt = array(0 => '.dat', 1 => '.php', 2 => '.gz', 3 => '.inc');
	echo '<fieldset><legend>Résultat de '.$file.'</legend>';
	if(is_array($var)):
		foreach($var as $id => $data)
		{
			echo '<strong>ID '.$id.':</strong><br />';
			foreach($data as $key => $val)
			{
				echo ''.$key.': '.$val.'<br />';
			}
			echo '<br />';
		}
	else:
		echo $var;
	endif;
	foreach($fileExt as $tmpExt)
	{
		if(file_exists('cache/'.$file.$tmpExt)):
			$ext = $tmpExt;
			break;
		endif;
	}
	echo 'Contenu de "cache/'.$file.$ext.'":<br />';
	highlight_num('cache/'.$file.$ext);
	echo '<br /></fieldset><br />';
}

function writeFile($file, $data)
{
	$fh = @fopen('cache/'.$file, 'wb');
	if ($fh):
		if(is_array($data)):
			fputs($fh, '<?php '."\n".'$c_test = '.var_export($data, true).'; '."\n".'?>');
		else:
			$data = gzcompress(serialize($data), 9);
			fputs($fh, $data);
		endif;
		return $file.' saved'."\n";
	endif;
	fclose($fh);	
}

function highlight_num($file)
{
	$lines = implode(range(1, count(file($file))), '<br />');
	$content = highlight_file($file, true);
	
	echo '<style type="text/css">
		.phpNum {
		float: left;
		color: gray;
		font-size: 13px;   
		font-family: monospace;
		text-align: right;
		margin-right: 6pt;
		padding-right: 6pt;
		border-right: 1px solid gray;}
		
		body {margin: 0px; margin-left: 5px;}
		td {vertical-align: top;}
		code {white-space: nowrap;}
	</style>';
	echo "<table><tr><td class=\"phpNum\">\n$lines\n</td><td>\n$content\n</td></tr></table>";
} 
?>
Return current item: ifbCache