<?php

$file = $GalerieRootVerzeichnis.'list/manuell/'.strtolower(preg_replace("/[^A-Za-z0-9\-\_\.]/",'',$wahl)).'.inc';
$fileIDs = $GalerieRootVerzeichnis.'list/manuell/'.strtolower(preg_replace("/[^A-Za-z0-9\-\_\.]/",'',$wahl)).'_ids.inc';

if ($list>=20) {
	$file = str_replace("manuell","tattoo",$file);
	$fileIDs = str_replace("manuell","tattoo",$fileIDs);

// echo $fileIDs;

}


// --------------------------- Check for MANUELLE Kategorie --------------------------- 
if (!@is_file($file)) 	
{
	if (@is_file($fileIDs)) 
	{
		$lines = array();
		$handle = @fopen($fileIDs, "r");
		if ($handle) {
   			while (!feof($handle)) {
       			$lines[] = fgets($handle, 4096);
   			}
		}
   		fclose($handle);
		$handle = @fopen ($file, "w");
		@fputs($handle,"<?php".chr(13).chr(10));
		$DateiInfo = '$value_id = array();		$value_price_xl = array();	$value_original_width = array();	$value_original_height = array();	$value_thumbnail_height = array();	$value_thumbnail_width = array();	$value_title = array();	$value_thumbnail_url = array();';
		@fputs($handle,"$DateiInfo".chr(13).chr(10));
		for ($i=0; $i<count($lines);$i++)
		{
		   if ($lines[$i]) {
			$results = $api->getSearchResults(
    				array(
					'words' => $lines[$i],
					'language_id' => $language_id,
					'thumbnail_size' => 160,
    				));
			if ($results['nb_results'] >= 1) 
			{
				foreach( $results as $key => $value) 
				{
					if ( is_numeric($key) ) 
					{
						$price_xl=0;
						$V=0; $lizenz=0; 
						foreach ($value[licenses] as $k => $price_detail ) 
						{
							if ($price_detail[name] == "L")	{ $lizenz="L"; $price_xl = $price_detail[price]*1.5; }
							if ($price_detail[name] == "XL")	{ $lizenz="XL"; $price_xl = $price_detail[price]*1.5; }
							if ($price_detail[name] == "XXL")	{ $lizenz="XXL"; $price_xl = $price_detail[price]*1.5; }
							if ($price_detail[name] == "V")	$V=1;
						}
						if ($price_xl)
						{
								if ($price_xl < $minFotoliaPreis) $price_xl = $minFotoliaPreis;
								$fileW = 0;
								$fileH = 0;
								if (!$V)
								{
									$fileW = $value[width];
									$fileH = $value[height];
								}
								$DateiInfo = '$value_id[]='.$value[id].';	$value_price_xl[]='.$price_xl.';	$value_original_width[]='.$fileW.';	$value_original_height[]='.$fileH.';	$value_thumbnail_height[]='.$value[thumbnail_height].';	$value_thumbnail_width[]='.$value[thumbnail_width].';	$value_title[]="'.preg_replace("/[^A-Za-z0-9\-\_\.]/",'',str_replace("  "," ",$value[title])).'";	$value_thumbnail_url[]="'.$value[thumbnail_url].'";';
								@fputs($handle,"$DateiInfo".chr(13).chr(10));
						}
					}
				}
			}
		   }
		}
		@fputs($handle,"?>".chr(13).chr(10));
		@fclose($handle);

		echo '<div class="col-md-12 bottom14"><hr>File DONE mit : ' .count($lines). ' Motive<hr></div>';
	}






}
else include ("galerie_listview.inc");
if ($words || $cat1 || $cat2 || $serie) { include ("galerie_getSearchResults.inc"); }
?>




