14 if (!defined(
'IN_PEEL')) {
19 $GLOBALS[
'page_types_array'] = array(
'home_page',
'first_page_category',
'other_page_category',
'ad_page_details',
'search_engine_page',
'ad_creation_page');
39 if ($params[
'mode']==
'banner') {
40 $this_cache_object =
new Cache(null, array(
'group' =>
'affiche_banner_data'));
41 $this_cache_object->delete_cache_file(
true);
42 unset($this_cache_object);
63 function affiche_banner($position = null, $return_mode =
false, $page = null, $cat_id = null, $this_annonce_number = 0, $page_type=null, $keywords_array=null,
$lang = null, $return_array_with_raw_information =
false, $ad_id=null, $page_related_to_user_id = null, $disable_cache =
false)
65 static $is_module_banner_active;
66 if(!isset($is_module_banner_active)) {
73 $banner_position =
'';
74 $mobile_application_output_array = array();
80 if (!empty(
$GLOBALS[
'page_columns_count']) &&
$GLOBALS[
'page_columns_count'] == 2) {
81 $max_banner_width = 750;
82 $max_banner_height = 748;
84 $max_banner_width = 1200;
85 $max_banner_height = 748;
87 if ($is_module_banner_active) {
90 if(!empty($page_related_to_user_id)){
91 $sql_cond .=
' AND CONCAT(",",do_not_display_on_pages_related_to_user_ids_list,",") NOT LIKE ("%,' . intval($page_related_to_user_id) .
',%")';
92 $disable_cache =
true;
95 $sql_cond .=
' AND id_categorie IN ("0", "' . intval($cat_id) .
'")';
97 $sql_cond .=
' AND id_categorie="0"';
99 if (!empty($this_annonce_number)) {
101 $sql_cond .=
' AND annonce_number="' . intval($this_annonce_number) .
'"';
102 $disable_cache =
true;
106 if(in_array($page_type,
$GLOBALS[
'page_types_array'])) {
108 $sql_cond .=
' AND on_'.$page_type .
'=1';
109 }
elseif($page_type!==null) {
111 $sql_cond .=
' AND on_other_page=1';
113 if(!empty($keywords_array)) {
115 $keywords_array[]=
'';
116 $sql_cond .=
' AND ' .
build_terms_clause(array_unique($keywords_array), array(
'keywords'), 2);
118 $disable_cache =
true;
120 $sql_cond .=
' AND keywords=""';
123 if ((defined(
'IN_CATALOGUE_ANNONCE') || defined(
'IN_IPHONE_ADS_MODULE')) && !empty($page)) {
126 }
elseif ((defined(
'IN_CATALOGUE_ANNONCE_DETAILS') || defined(
'IN_IPHONE_ADS_MODULE')) && !empty($ad_id)) {
130 if(isset($tested_number)){
133 if($tested_number %2 == 0) {
134 $sql_cond .=
' AND pages_allowed IN ("all","even")';
135 }
elseif($tested_number %2 == 1) {
136 $sql_cond .=
' AND pages_allowed IN ("all","odd")';
139 if($return_array_with_raw_information){
140 $disable_cache =
true;
142 $sql_where =
"WHERE etat='1' " . (!empty($position) && is_numeric($position) ?
" AND position='" . intval($position) .
"'":
"") . $sql_cond .
" AND (lang='" .
nohtml_real_escape_string(
$lang) .
"' OR lang='')";
144 if(empty(
$GLOBALS[
'site_parameters'][
'banner_disable_cache']) && !$disable_cache) {
145 $cache_id = md5($sql_where);
146 $this_cache_object =
new Cache($cache_id, array(
'group' =>
'affiche_banner_data'));
148 if (!empty($this_cache_object) && $this_cache_object->testTime(
vb(
$GLOBALS[
'site_parameters'][
'banners_cache_duration_in_seconds'], 15*24*3600),
true)) {
150 $temp = explode(
'{'.$cache_id.
'}',$this_cache_object->get());
151 if(!empty($temp[1])){
152 foreach(explode(
',',$temp[0]) as $this_banner_id){
153 $GLOBALS[
'viewed_banners_array'][]=intval($this_banner_id);
158 $queryBanner =
query(
"SELECT *
160 " . $sql_where .
" AND date_fin>='" . date(
'Y-m-d') .
"' AND " .
get_filter_site_cond(
'banniere') .
"
161 ORDER BY rang ASC, id_categorie DESC, RAND() ASC");
167 if ($return_array_with_raw_information) {
168 if (!empty($banner[
'annonce_number'])) {
170 $banner_position = $banner[
'annonce_number'];
175 WHERE technical_code = "advertising' . intval($banner[
'position']) .
'" AND etat = 1 AND ' .
get_filter_site_cond(
'modules'));
177 $banner_location =
$result[
'location'];
180 $banner_position =
'top';
182 $banner_position =
'bottom';
186 if (!empty($banner[
'lien'])) {
187 $url =
$GLOBALS[
'wwwroot'] .
'/modules/banner/bannerHit.php?id=' . $banner[
'id'];
191 if(strpos($banner[
'tag_html'],
'[ADSENSE_MOBILE=') !==
false) {
192 $tag_infos = explode(
',', str_replace(array(
'[ADSENSE_MOBILE=',
']'),
'', $banner[
'tag_html']));
193 $banner[
'tag_html'] =
'';
194 $GLOBALS[
'google'][
'client']=$tag_infos[0];
197 $GLOBALS[
'google'][
'markup']=
'xhtml';
198 $GLOBALS[
'google'][
'output']=
'xhtml';
201 $GLOBALS[
'google'][
'slotname']=$tag_infos[1];
205 $GLOBALS[
'google'][
'useragent']=
'iPhone - Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en)';
211 if ($google_ad_handle) {
213 $banner[
'tag_html'] .= fread($google_ad_handle, 8192);
216 fclose($google_ad_handle);
219 $mobile_application_output_array[] = array(
"url_img" => (!empty($banner[
'image'])?
$GLOBALS[
'repertoire_upload'] .
'/' . $banner[
'image']:
''),
"url" =>
$url ,
"html"=>
vb($banner[
'tag_html']),
"position" => $banner_position);
220 }
elseif (!isset($last_rang) || $banner[
'rang'] != $last_rang) {
223 $width = min(intval($banner[
'width']), $max_banner_width);
224 $height = min(intval($banner[
'height']), $max_banner_height);
225 if(!empty($banner[
'image'])) {
227 $banner_file_extension = @pathinfo($banner[
'image'], PATHINFO_EXTENSION);
228 if ($banner_file_extension ==
'swf') {
229 if ($disable_cache && !empty($_SERVER[
'HTTP_USER_AGENT']) && (strstr($_SERVER[
'HTTP_USER_AGENT'],
'iPhone') || strstr($_SERVER[
'HTTP_USER_AGENT'],
'iPod') || strstr($_SERVER[
'HTTP_USER_AGENT'],
'iPad'))) {
231 unset($banner[
'image']);
234 unset($banner[
'tag_html']);
238 if (empty($banner[
'tag_html']) && !empty($banner[
'image'])) {
240 if ($banner_file_extension ==
'swf') {
253 $style_banner .=
' width="' . $width .
'" ';
255 if (!empty($height)){
256 $style_banner .=
' height="' . $height .
'" ';
259 if (!empty($banner[
'lien'])) {
260 $banner_html =
'<a href="' .
$GLOBALS[
'wwwroot'] .
'/modules/banner/bannerHit.php?id=' . $banner[
'id'] .
'" ' . $banner[
'extra_javascript'] .
' ' . (!empty($banner[
'target']) && $banner[
'target'] !=
'_self' ? ($banner[
'target'] ==
'_blank' &&
String::strpos($banner[
'extra_javascript'],
'onclick=') ===
false?
'onclick="return(window.open(this.href)?false:true);"':
'target="' . $banner[
'target'] .
'"'):
'') .
'>' . $banner_html .
'</a>';
265 $banner_html =
String::htmlentities($banner[
'tag_html'], ENT_COMPAT, GENERAL_ENCODING,
false,
true);
267 $output .=
'<div class="ba_pu" style="margin-top:3px;">' . $banner_html .
'</div>';
268 $last_rang = $banner[
'rang'];
271 $these_banners_id_array[]=$banner[
'id'];
272 $GLOBALS[
'viewed_banners_array'][]=$banner[
'id'];
274 if (!empty($this_cache_object)) {
276 $this_cache_object->save(implode(
',',$these_banners_id_array).
'{'.$cache_id.
'}'.
$output);
278 $this_cache_object->save(
'');
282 if (!empty($this_cache_object)) {
283 unset($this_cache_object);
285 if (!$return_array_with_raw_information) {
286 if(
String::strpos(
$output,
'.swf')!==
false && !empty($_SERVER[
'HTTP_USER_AGENT']) && (strstr($_SERVER[
'HTTP_USER_AGENT'],
'iPhone') || strstr($_SERVER[
'HTTP_USER_AGENT'],
'iPod') || strstr($_SERVER[
'HTTP_USER_AGENT'],
'iPad'))) {
288 if(!$disable_cache) {
292 return affiche_banner($position, $return_mode, $page, $cat_id, $this_annonce_number, $page_type, $keywords_array,
$lang, $return_array_with_raw_information, $ad_id, $page_related_to_user_id,
true);
314 if ($return_array_with_raw_information) {
315 return $mobile_application_output_array;
338 $sql_cond .=
' AND id_categorie IN ("0", "' . intval($cat_id) .
'")';
340 $sql_cond .=
' AND id_categorie="0"';
345 if(in_array($page_type,
$GLOBALS[
'page_types_array'])) {
347 $sql_cond .=
' AND on_'.$page_type .
'=1';
348 }
elseif($page_type!==null){
350 $sql_cond .=
' AND on_other_page=1';
352 $sql_where =
"WHERE etat = '1' " . (!empty($position) && is_numeric($position)?
" AND position='" . intval($position) .
"'":
"") . $sql_cond .
" AND (lang='" .
$_SESSION[
'session_langue'] .
"' OR lang='')";
354 $cache_id = md5($sql_where);
355 $this_cache_object =
new Cache($cache_id, array(
'group' =>
'get_possible_banner_positions_between_ads_data'));
356 if ($this_cache_object->testTime(1800,
true)) {
357 $output = $this_cache_object->get();
359 $annonce_number_array = array();
360 $queryBanner =
query(
"SELECT annonce_number
362 " . $sql_where .
" AND annonce_number>0 AND date_fin>='" . date(
'Y-m-d') .
"' AND " .
get_filter_site_cond(
'banniere'));
364 $annonce_number_array[] = $banner[
'annonce_number'];
366 $output = implode(
',', $annonce_number_array);
367 $this_cache_object->save(
$output);
379 if (!empty(
$GLOBALS[
'viewed_banners_array'])) {
380 foreach(
$GLOBALS[
'viewed_banners_array'] as $this_key => $this_id) {
381 $GLOBALS[
'viewed_banners_array'][$this_key] = intval($this_id);
383 query(
"UPDATE peel_banniere
390 return isset($_SERVER[$var]) ? $_SERVER[$var]:
'';
394 $url .=
'&' . $param .
'=' . urlencode($value);
403 $color_array = explode(
',',
$GLOBALS[
'google'][$param]);
405 $color_array[$google_dt % count($color_array)]);
410 if ($screen_res ==
'') {
411 $screen_res =
read_global(
'HTTP_X_UP_DEVCAP_SCREENPIXELS');
413 if ($screen_res ==
'') {
414 $screen_res =
read_global(
'HTTP_X_JPHONE_DISPLAY');
416 $res_array = preg_split(
'/[x,*]/', $screen_res);
417 if (count($res_array) == 2) {
418 $GLOBALS[
'google'][
'u_w']=$res_array[0];
419 $GLOBALS[
'google'][
'u_h']=$res_array[1];
455 $google_ad_url =
'http://pagead2.googlesyndication.com/pagead/ads?';
457 round(1000 * array_sum(explode(
' ', microtime()))));
458 foreach (
$GLOBALS[
'google'] as $param => $value) {
459 if (strpos($param,
'color_') === 0) {
461 }
else if (strpos($param,
'url') === 0) {
462 $google_scheme = (
$GLOBALS[
'google'][
'https'] ==
'on')
463 ?
'https://' :
'http://';
465 $google_scheme .
$GLOBALS[
'google'][$param]);
470 return $google_ad_url;
static htmlentities($string, $flags=ENT_COMPAT, $charset=GENERAL_ENCODING, $suppr_endline=false, $encode_only_isolated_amperstands=false, $decode_html_entities_first=false)
Convert all applicable characters to HTML entities Cette fonction sert si on veut afficher du contenu...
build_terms_clause($terms, $fields, $match_method)
builds the sql statement's where clause this will build the sql based on the given information Valeur...
static strpos($haystack, $needle, $offset=0)
Returns the numeric position of the first occurrence of needle in the haystack string.
get_possible_banner_positions_between_ads($position, $cat_id, $page, $page_type=null)
get_possible_ad_positions()
update_viewed_banners()
Met à jour le compteur "vue" de la table des bannières en une seule requête SQL.
nohtml_real_escape_string($value, $allowed_tags=null)
Protège les données pour insertion dans MySQL ET supprime les tags HTML pour protéger de toute sorte ...
if(!defined('IN_PEEL')) $GLOBALS['page_types_array']
real_escape_string($value)
real_escape_string()
google_append_color(&$url, $param)
banner_hook_close_page_generation($params)
Traitement de la fin de la génération d'une page.
static feof($handle)
Tests for end-of-file on a file pointer In contrary of the default feof function, it returns true if ...
getFlashBannerHTML($url, $width=680, $height=250, $mode_transparent=false)
Renvoie le HTML d'un tag corespondant à l'URL du fichier flash transmis en paramètre.
get_filter_site_cond($table_technical_code, $table_alias=null, $use_strict_rights_if_in_admin=false, $specific_site_id=null, $exclude_public_items=false, $admin_force_multisite_if_allowed=false)
Retourne la condition SQL permettant de filtrer les données pour une table.
query($query, $die_if_error=false, $database_object=null, $silent_if_error=false, $security_sql_filter=true)
The query() function is meant to be called anywhere you want to make a query.
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
fetch_assoc($query_result)
fetch_assoc()
banner_hook_rpc_status(&$params)
Gestion du changement de status d'un élément dans une table si pas prévu par défaut.
google_set_via_and_accept()
google_append_url(&$url, $param, $value)
get_url_from_uploaded_filename($filename)
get_url_from_uploaded_filename()
affiche_banner($position=null, $return_mode=false, $page=null, $cat_id=null, $this_annonce_number=0, $page_type=null, $keywords_array=null, $lang=null, $return_array_with_raw_information=false, $ad_id=null, $page_related_to_user_id=null, $disable_cache=false)
affiche_banner()
static substr($string, $start, $length=null)
Returns the portion of string specified by the start and length parameters.
google_append_globals(&$url, $param)
check_if_module_active($module_name, $specific_file_name=null)
Renvoie si un module est présent et activé ou non - Peut être appelé avant ou après le chargement d'u...
if(defined('IN_PEEL_ADMIN')||IN_INSTALLATION) $_SESSION['session_langue']