<!-- Script PHP/MYSQL of management of classifieds ads developed by Script PAG Script PAG all rights reserved. Use under license. http://www.script-pag.com -->
<?php

foreach($cache_advertisement as $row)
{	
	$id_reg = (int) $row['id_reg'];
	$id_county = (int) $row['id_county'];
	$id_cat = (int) $row['id_cat'];
	$code_lang = stripslashes(htmlspecialchars($row['code_lang'], ENT_QUOTES));
	$name = stripslashes(htmlspecialchars($row['name'], ENT_QUOTES));
	$picture = stripslashes(htmlspecialchars($row['picture'], ENT_QUOTES));
	$url = stripslashes(htmlspecialchars($row['url'], ENT_QUOTES));
	$text_adv = stripslashes(htmlspecialchars($row['text'], ENT_QUOTES));
	$script = $row['script'];
	$submit_cookies = (int) $row['submit_cookies'];
	$adv = (int) $row['adv'];
	
	if((($id_reg == 0 || (isset($search_data['reg']) && $id_reg == $search_data['reg'])) && ($id_county == 0 || (isset($search_data['county']) && $id_county == $search_data['county'])) && ($id_cat == 0 || (isset($search_data['cat']) && $id_cat == $search_data['cat'])) && ($code_lang == '' || $code_lang == $_SESSION['code_lang'])) && (($type_search == 1 && $adv == 5) || ($type_search == 2 && $adv == 8)))
	{
		if(!empty($text_adv))
		{
			echo '<div class="bloc-advertisement-area text-center">';
			echo '<div class="flex-container">';
			echo '<p><a href="'. $url .'" target="_blank"><img src="'. URL .'/upload/advertisement/'. $picture .'" alt="'. $name .'" /></a>';
			echo '<p><a href="'. $url .'" target="_blank">'. $text_adv .'</a></p>';
			echo '</div>';
			echo '</div>';
		}
			
		if(empty($text_adv) && empty($script))
		{
			echo '<div class="bloc-advertisement-area text-center">';
			echo '<a href="'. $url .'" target="_blank"><img src="'. URL .'/upload/advertisement/'. $picture .'" alt="'. $name .'" /></a>';
			echo '</div>';
		}
							 
		if((!empty($script) && $submit_cookies == 0) || (!empty($script) && $submit_cookies == 1 && is_allowed_cookie('publicity')))
		{
			echo '<div class="bloc-advertisement-area text-center">';
			echo $script;
			echo '</div>';
		}
	}
}