<?php 
/* utf-8 marker: äöü
************************************
FotoGalerie_XH plugin for CMSimple
Developed by: ge-webdesign.de
Version: FotoGalerie_XH v6.6
Released: 11/2012

Based on:  
- kissGallery: 			Claus Højberg (alias Softly)
- Shutter Reloaded:		digitalia.be
- TableSort:			javascript.jstruebig.de
************************************
License:  
Linkware License (private websites)
Remove Link License (private websites)
Commercial License (commercial websites)

For Licenses see: http://www.ge-webdesign.de/cmsimpleplugins/
************************************
*/

function fogaGetVar($variable) 
{
	$t = isset($_GET[$variable]) ? $_GET[$variable] : '';
	$t .= isset($_POST[$variable]) ? $_POST[$variable] : '';
	return $t;
}

function fogaGetNumber($n) 
{
	if (preg_match ("/^([0-9.,-]+)$/", $n)) { 
 		return $n;
	} else {
		return 0;
	}
}

function fogaIsTrue($var) 
{
	if (strcasecmp($var,'true')==0) return 1;
	else return 0;
}

function fogaWriteAccess($fn) {
	global $o, $plugin_tx;
	$file=basename($fn);
	if(!is_writable($fn))$o .='<p class="cmsimplecore_warning"><b>Warning: </b>'.$file.' '.$plugin_tx['fotogalerie']['message_not_writeable'].tag('br').'</p>';
}

function fogaRFile($fn) 
{
	$grp = file($fn);
	foreach ($grp as $num => $rec) 
	{
		$grp[$num] = explode("§§§", trim($rec,"\r\n"));
	}
	return $grp;
}

function fogaWFile($fn,$arr) 
{
	foreach ($arr as $key => $row) 
	{
		$ord[$key]  = $row[1];
	}
	array_multisort($ord, SORT_ASC, $arr);	
	$fhg=fopen($fn,'wb');
	foreach ($arr as $num => $rec) 
	{
		$out=implode("§§§",$rec)."\n";
		$rc=fwrite($fhg,$out,strlen($out));
	}
	fclose($fhg);
}

function fogaNextID($arr) 
{
	$id=0;
	foreach ($arr as $num => $rec) 
	{
		if ($rec[0]>$id) $id=$rec[0];
	}
	$id+=1;
	return $id;
}
?>