[^\S ]+/s', // strip whitespaces after tags, except space '/[^\S ]+\','<','\\1' ); $buffer = preg_replace($search, $replace, $buffer); return $buffer; } ///// // Error Page: ---------------------------------------------------------------------- function showErrorPage(){ global $cfg, $DB_LINK; $DB_LINK = mysqli_connect($cfg['dbHost'], $cfg['dbUser'], $cfg['dbPass'], $cfg['dbName']); // Rigenero il link al database (richiesto finche esistono pagine dal vecchio database) header("HTTP/1.0 404 Not Found"); include( "data/pages/error.php" ); exit(); } ///// // Get Page-Link: ------------------------------------------------------------------- // - Restituisce l'url di una pagina del sito; function getPageUrl( $type, $v=false, $v2=false ){ global $cfg; $url = '#'; switch($type){ // PAGES: ------------------------------------- case 'home': // getPageLink( 'home' ); /* TEST */if( $cfg['test_mode'] ){ $url=$cfg['domain_name'].$cfg['base_dir'].'index.php?action=home'; } /* NOTEST */else{ $url=$cfg['domain_name'].'/'; } break; case 'merchant': // name_url /* TEST */if( $cfg['test_mode'] ){ $url=$cfg['domain_name'].$cfg['base_dir'].'index.php?action=merchant&name='.$v.($v2?'&o='.$v2:''); } /* NOTEST */else{ $url=$cfg['domain_name'].'/store/'.$v.'.html'.($v2?'?o='.$v2:''); } break; case 'offer': /* TEST */if( $cfg['test_mode'] ){ $url=$cfg['domain_name'].$cfg['base_dir'].'index.php?action=offer&name='.$v.($v2?'&o='.$v2:''); } /* NOTEST */else{ $url=$cfg['domain_name'].'/offer/'.$v.'.html'.($v2?'?o='.$v2:''); } break; case 'tag': // name_url /* TEST */if( $cfg['test_mode'] ){ $url=$cfg['domain_name'].$cfg['base_dir'].'index.php?action=tag&name='.$v; } /* NOTEST */else{ $url=$cfg['domain_name'].'/offers/'.$v; } break; case 'search': /* TEST */if( $cfg['test_mode'] ){ $url=$cfg['domain_name'].$cfg['base_dir'].'index.php?action=search&value='.$v; } /* NOTEST */else{ $url=$cfg['domain_name'].'/search/?'.$v; } break; // SERVICE: ----------------------------------- case 'about-us': //$v=merchID; /* TEST */if( $cfg['test_mode'] ){ $url=$cfg['domain_name'].$cfg['base_dir'].'index.php?action=about-us'; } /* NOTEST */else{ $url=$cfg['domain_name'].'/about-us.html'; } break; case 'contact-us': //$v=merchID; /* TEST */if( $cfg['test_mode'] ){ $url=$cfg['domain_name'].$cfg['base_dir'].'index.php?action=contact-us'; } /* NOTEST */else{ $url=$cfg['domain_name'].'/contact-us.html'; } break; case 'privacy': //$v=merchID; /* TEST */if( $cfg['test_mode'] ){ $url=$cfg['domain_name'].$cfg['base_dir'].'index.php?action=privacy'; } /* NOTEST */else{ $url=$cfg['domain_name'].'/privacy.html'; } break; // SOCIAL: ------------------------------------ case 'social-facebook': //$v=merchID; $url='https://www.facebook.com/webbyplanet.freecoupons.promotioncodes'; break; case 'social-twitter': $url='https://twitter.com/webbyplanet'; break; case 'social-instagram': $url='https://www.instagram.com/webbyplanet/'; break; // REDIRECT: ---------------------------------- case 'redirect-merchant': //$v=merchID; /* TEST */if( $cfg['test_mode'] ){ $url=$cfg['domain_name'].$cfg['base_dir'].'index.php?action=redirect&mid='.$v; } /* NOTEST */else{ $url=$cfg['domain_name'].'/out/'.$v.'m/'; } break; case 'redirect-offer': //$v=dealID; /* TEST */if( $cfg['test_mode'] ){ $url=$cfg['domain_name'].$cfg['base_dir'].'index.php?action=redirect&did='.$v; } /* NOTEST */else{ $url=$cfg['domain_name'].'/out/'.$v.'/'; } break; } return $url; } // Aggiunge una festività alla lista (e riordina l'array): -------------------------- // id, name, name_url, expire $holidayList; function addHoliday( $id, $name, $name_url, $d, $m ){ // 'NAME', 'D', 'M' global $holidayList; $y = ( $m < date('m') )? date('y')+1 : date('y'); // Se la festività è gia passata l'anno è il successivo altrimenti è il corrente; $m = ( strlen($m)<2 )? '0'.$m : $m; $d = ( strlen($d)<2 )? '0'.$d : $d; $holidayList[] = array( 'id'=>$id, 'name'=>$name, 'name_url'=>$name_url, 'expire'=>$y.$m.$d ); // Le date sono espresse nel formato AA/MM/GG per essere ordinate; // Ordino l'array: $var1 = array(); foreach ($holidayList as $key => $row){ $var1[$key] = $row['expire']; } array_multisort($var1, SORT_ASC, $holidayList); } // Restituisce la posizione in array della festività attualmente attiva: ------------ // - ( bottone header ) function getCurrentHoliday( $filter=false, $offset=false){ global $holidayList; $today = date('ymd'); foreach($holidayList AS $key=>$value ){ if( $today<=$value['expire'] ){ if($filter){ foreach($value AS $key=>$value ){ // Eseguito una sola volta posso sovrascrivere $key=>$value if( $filter==$key ){ return $value; } } } return $holidayList[$key]; break; } } return false; } // Get Image-Url: [merchant|tag] ---------------------------------------------------- // - Restituisce l'url di un'immagine in base al type; function getImageUrl( $type=false, $v=false ){ global $cfg; $url = '#'; switch($type){ case 'merchant-logo': if( $v ){ $url = $cfg['domain_name'].'/image/merchant_logo/'.$v.'.png'; }break; case 'merchant-logo_old': case 'merchant-logo-old': // Vecchie immagini: if( $v ){ //OLD // siteurl $search = array("http://" ,"https://" ,"/" ,"?" ," "); $replace = array("" ,"---" ,"-" ,"-" ,"" ); $url = str_replace($search,$replace,$v); $url = $cfg['domain_name'].'/img/screenshot/'.$url.'.png'; }break; default: // Immagine di Default: $url = $cfg['domain_name'].$cfg['img_dir']."default.png"; } return $url; } // Converte i caratteri in UTF8 per evitare simboli strani: function utf8encode($string){ if (mb_detect_encoding($string, 'utf-8', true) === false){ $string = mb_convert_encoding($string, 'utf-8', 'iso-8859-1'); } return $string; } // Filtro Offerte Add (merchant-tag): ----------------------------------------------- $offersFilter = array(); function addOfferFilter( $type,$name ){ global $offersFilter; if( !isset($offersFilter[$type]) ){ $offersFilter[$type]['name'] = $name; $offersFilter[$type]['num'] = 1; }else{ $offersFilter[$type]['num']++; } } ///// // Filtro Offerte Get (merchant-tag): ----------------------------------------------- function getOfferFilter(){ global $offersFilter; return $offersFilter; } ///// function getAds($type=false){ global $cfg; if( $cfg['test_mode'] ){ return; } // No Ads in testmode; switch($type){ case 'home': $ads = ''. ''. ''; break; case 'merchant': $ads = ''. ''. ''; break; case 'merchant-center_offer':// Pagina merchant banner tra le offerte: return ''. ''. ''; case 'tag-search': $ads = ''. ''. ''; break; default: $ads = ''. ''; } return $ads; } ?>