= $core->config['cache_max']) { $dirs = array_diff(scandir("media/themes/".$theme."/" ), Array( ".", ".." ) ); sort($dirs); @unlink($path."cache/".$theme.".cache"); $fp = fopen($path."cache/".$theme.".cache", 'x+'); if (flock($fp, LOCK_EX)) { // pose un verrou exclusif fwrite($fp,serialize($dirs)); flock($fp, LOCK_UN); fclose($fp); } else { echo $query." Ecriture du cache";return FALSE;} } else { $lines=file($path."cache/".$theme.".cache"); foreach ($lines as $line_num => $line) {$dirs=unserialize($line);} } } else { if(!is_dir("media/themes/".$theme)) {mkdir("media/themes/".$theme);} $dirs = array_diff(scandir("media/themes/".$theme."/" ), Array( ".", ".." ) ); sort($dirs); @unlink($path."cache/".$theme.".cache"); $fp = fopen($path."cache/".$theme.".cache", 'x+'); if (flock($fp, LOCK_EX)) { // pose un verrou exclusif fwrite($fp,serialize($dirs)); flock($fp, LOCK_UN); fclose($fp); } else { echo $query." Ecriture du cache";return FALSE;} } $nb=count($dirs); if($nb<1) {return "";} else { $num=mt_rand(0, $nb-1); return $core->config['url_images']."/media/themes/".$theme."/".$dirs[$num]; } } function cache_sql($nom,$emplacement,$page=1) { global $core; $db = new db($core->config['db_name']); if($page==0) {$page=1;} $req="SELECT contenu, UNIX_TIMESTAMP(date) AS temps FROM ".CACHE." WHERE nom LIKE '".$nom."' AND emplacement = '".$emplacement."' AND page='".$page."'"; $result = $db->query($req); $num = $db->num_rows($result); if($num>0) { $row=$db->get_object($result); if($row->temps>(time()-$core->config['cache_max'])) { $cache=true; $tab[1]=$row->contenu; } else {$cache=false;$tab[1]="";} } else { $req="INSERT INTO ".CACHE." SET contenu='',nom='".$nom."',emplacement= '".$emplacement."', page='".$page."'"; $db->query($req); $cache=false; $tab[1]=""; } $tab[0]=$cache; return $tab; } ?>config['url_tmp'].$value["name"]); $value=true; } else { $value=false; } break; default : $value=htmlspecialchars($value,ENT_QUOTES, 'UTF-8'); break; } return $value; } function get_nom($text){ $nom=trim($text); $sSearch = array ('/-/','/à|á|â|ä|ã|å/', '/À|Á|Â|Ä|Ã|Å/', '/è|é|ê|ë/', '/È|É|Ê|Ë/', '/ì|í|î|ï/', '/Ì|Í|Î|Ï/', '/ò|ó|ô|ö|ø/', '/Ò|Ó|Ô|Ö|Ø/', '/ù|ú|û|ü/', '/Ù|Ú|Û|Ü/', '/ÿ/', '/Ÿ/', '/ñ/', '/Ñ/', '/ç/', '/Ç/', '/[^a-z0-9]/i'); $sReplace = array ('_', 'a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U', 'y', 'Y', 'n', 'N', 'c', 'C', '_'); $nom=preg_replace ($sSearch, $sReplace, $nom); $tab=array('"',"'","\\","&","{","(","[","-","|","`","@",")","]","=","}","+",":","/",";",",","?","!","<",">","%"," ","*",'$','-'); $nom=str_replace($tab,"_",$nom); $nom=str_replace("___","_",$nom); $nom=str_replace("__","_",$nom); $nom=strtolower($nom); return $nom; } function get_nom2($text){ $nom=trim($text); $sSearch = array ('/-/','/à|á|â|ä|ã|å/', '/À|Á|Â|Ä|Ã|Å/', '/è|é|ê|ë/', '/È|É|Ê|Ë/', '/ì|í|î|ï/', '/Ì|Í|Î|Ï/', '/ò|ó|ô|ö|ø/', '/Ò|Ó|Ô|Ö|Ø/', '/ù|ú|û|ü/', '/Ù|Ú|Û|Ü/', '/ÿ/', '/Ÿ/', '/ñ/', '/Ñ/', '/ç/', '/Ç/', '/[^a-z0-9]/i'); $sReplace = array ('_', 'a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U', 'y', 'Y', 'n', 'N', 'c', 'C', '_'); $nom=preg_replace ($sSearch, $sReplace, $nom); $tab=array('"',"'","\\", "&", "&","{","(","[","-","|","`","@",")","]","=","}","+",":","/",";",",","?","!","<",">","%"," ","*",'$','-','_'); $nom=str_replace($tab,"-",$nom); $nom=str_replace("---","-",$nom); $nom=str_replace("--","-",$nom); $nom=strtolower($nom); return $nom; } function clean_str_soft($str){ $accents = array('à' => 'a', 'ä' => 'a', 'â' => 'a', 'é' => 'e', 'è' => 'e', 'ê' => 'e', 'ë' => 'e', 'ï' => 'i', 'î' => 'i', 'ö' => 'o', 'ô' => 'o', 'ü' => 'u', 'ç' => 'c'); $str = rtrim($str); $str = str_replace(array_keys($accents), array_values($accents), $str); $str = preg_replace('#[^a-zA-Z0-9\.]#si', '_', $str); return ($str); } function verif_rep($dir_name){ $size = strlen($dir_name); if ($dir_name{$size-1}=="/") { $dir_name = substr($dir_name,0,$size-1); } if (!is_dir($dir_name)) mkdir($dir_name,0775); } function hash_rep($rep,$nom_fichier) { $dir=''; for($i=0 ; $i<3 ; $i++) { $dir.= $nom_fichier{$i}."/"; verif_rep($rep.$dir); } return $dir; } function create_config_id_client() { global $core; if(isset($_SESSION['key_session'])) { //Initialisation de la fonction de cryptage $init_crypt=initialize_crypt(); //Récupération des données en session $key_sess=decode_crypt($_SESSION['key_session'],$init_crypt); if($key_sess!=false) { $core->config['id_client']=$key_sess[0]; $core->config['login']=$key_sess[1]; $connected="yes"; //$core->page['infos_client']=evalTemplate("tpl_infos_client.php","commun"); } else { $connected=""; //$err=-4; } } else { $connected=""; // $err=-4; } return $connected; } function rrmdir($dir) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { if ($object != "." && $object != "..") { if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object); } } reset($objects); rmdir($dir); } } ?>config=new StdClass(); $this->config->http_accepted = array( 'VND.WAP.WML' ); $this->config->agent_denied = array( 'OfficeLiveConnector', 'Swapper', ); $this->config->agent_accepted = array( 'airness', 'alcatel', 'amoi', 'android', //'asus', 'benq', //'bird', 'blackberry', 'cdm-', 'docomo', 'ericsson', //'eten', 'gigabyte', 'Google Wireless Transcoder', //'haier', 'Huawei', 'htc_', 'htc-', 'i-mate', 'i-mobile', 'ipaq', 'iphone', 'j-phone', 'kwc-', 'kddi', 'lenovo-', //'lg', 'lg-', 'lg/', 'lge-', 'midp', 'mitsu/', 'mot-', //'motor', 'motorola', 'nokia', //'nec', 'palm', 'panasonic', 'pantech', 'philips', //'ppc', 'pg-', 'portalmmm', 'qtek', 'sagem', 'samsung', 'sanyo', 'sch-', 'sec-', 'sendo', 'sgh-', 'sharp', 'sie-', 'siemens', 'sonyericsson', 'sph-', 'symbianos', 'treo', 'telit', 'toshiba', //'tsm', 'vk-', 'vodafone', 'wap2', //'wap', 'windows ce', 'wnd', 'wonu', 'zte-', ); $this->config->regex['http_accepted'] = '/(' . str_replace(',', '|', preg_quote(implode(',', $this->config->http_accepted), '/')) . ')/i'; $this->config->regex['agent_denied'] = '/(' . str_replace(',', '|', preg_quote(implode(',', $this->config->agent_denied), '/')) . ')/i'; $this->config->regex['agent_accepted'] = '/(' . str_replace(',', '|', preg_quote(implode(',', $this->config->agent_accepted), '/')) . ')/i'; } function check_http_accept($value = NULL) { return preg_match($this->config->regex['http_accepted'], $value); } function check_http_user_agent($value = NULL) { $status = false; if (!preg_match($this->config->regex['agent_denied'], $value)) { $status = preg_match($this->config->regex['agent_accepted'], $value); } return $status; } function redirect () { if ($this->check_http_accept($_SERVER['HTTP_ACCEPT'])) { return true; } if ($this->check_http_user_agent($_SERVER['HTTP_USER_AGENT'])) { return true; } return false; } } ?>host=$core->config['host']; $this->user=$core->config['user']; $this->pass=$core->config['password']; $this->base=$base; } // PRIVATE : connection à la DB function connect() { global $core; $host=$core->config['host']; $user=$core->config['user']; $pass=$core->config['password']; //=$core->config['dbname']; $this->connect_id = mysql_connect($host, $user, $pass); if ($this->connect_id) { if(mysql_select_db($this->base, $this->connect_id)){ mysql_query("SET NAMES UTF8"); return $this->connect_id; } else return FALSE; } else return FALSE; } // PRIVATE : connection à la DB function query($query,$cache=0,$path="") { global $core; if ( !$this->connect_id ) $this->connect($this->host,$this->user,$this->pass,$this->base); if($cache==0) { if ( $this->result_id = mysql_query($query, $this->connect_id) ) { $this->query = trim($query); return $this->result_id; } else { echo $query.$this->error= mysql_error(); return FALSE; } } else { $id_file=md5($query); if (!file_exists($path."cache/".$id_file.".sql") or (time() - filemtime($path."cache/".$id_file.".sql") >= $core->config['cache_max'])) { if ( $this->result_id = mysql_query($query, $this->connect_id) ) { $this->query = trim($query); $id=$this->result_id; } else { echo $query.$this->error= mysql_error(); return FALSE; } @unlink($path."cache/".$id_file.".sql"); $fp = fopen($path."cache/".$id_file.".sql", 'x+'); if (flock($fp, LOCK_EX)) { // pose un verrou exclusif while ($row = mysql_fetch_assoc($id)) {fwrite($fp, preg_replace("/\\r/"," ",preg_replace("/\\n/"," ",preg_replace("/\\r\\n/"," ",serialize($row))))."\r\n");} flock($fp, LOCK_UN); fclose($fp); } else { echo $query." Ecriture du cache";return FALSE;} } } } // PUBLIC : Dernier id inserer function last_insert_id() { return @mysql_insert_id(); } // PUBLIC : renvoi le nombre d'enregistrement affecté function num_rows($id="",$obj="",$cache=0){ if ($id=="") $id=$this->result_id; if($cache==1) { return count($obj); } else { if ( isset($id) ) { if ( preg_match('`^select`i',$this->query) ) { $i = mysql_num_rows($id); return $i; } if ( preg_match('`^(insert|update|delete)`i',$this->query) ) return mysql_affected_rows($id); } else { return count($this->records); } } } function get_object($id="") { if ($id=="") $id=$this->result_id; return @mysql_fetch_object($id); } function get_object_cache($query="",$path="") { $id_file=md5($query); $lines=file($path."cache/".$id_file.".sql"); foreach ($lines as $line_num => $line) {$php[]=unserialize($line);} return $php; } function get_array($query, $mode='BOTH') { /* switch($mode) { case 'NUMERIC' : $tab= @mysql_fetch_array($query, MYSQL_NUM); return $tab; break; case 'BOTH' : $tab= @mysql_fetch_array($query, MYSQL_BOTH); return $tab; break; case 'ASSOC' : default : $tab=@mysql_fetch_assoc($query); return $tab; break; } */ $i=0; while ($row = mysql_fetch_assoc($query)) { $tab[$i]=$row; $i++; } mysql_free_result($query); return $tab; } // PUBLIC : renvoi le msg d'erreur mysql function return_error() { return @mysql_error(); } // PUBLIC : ferme la connection; function close() { return @mysql_close($this->connect_id); } // PUBLIC : vide les resultat des requete function free_result() { return @mysql_free_result($this->connect_id); } } /* ***** Script pour se connecter : $maBD = new bd("base"); base est le nom de la base de donnée // executer une requete : $result = $maBD->query(SELECT * FROM ....); $row = $maBD->get_object($result); */ ?>config['db_name']); if($size==""){$size="bandeau";} if($id_site!=0) { $res=$db->query("SELECT * FROM ".SITES." WHERE id_site = '".$id_site."'"); if ($db->num_rows($res)>0) { $row=$db->get_object($res); $add_site=" theme ='".$row->theme."' "; } else {$add_site=" 1 ";} } else {$add_site=" 1 ";} if ($random=="random") { $res=$db->query("SELECT id_pubs FROM ".PUBS." WHERE taille = '".$size."' AND ".$add_site); $nb=$db->num_rows($res); if ($nb>0) { $tab=$db->get_array($res); $add_random=" AND id_pubs='".$tab[mt_rand(0,$nb-1)]['id_pubs']."'"; } } $pub=recup_donnee(PUBS, "taille",$size, "code",$add_site." ".$add_random." LIMIT 1 "); return $pub; } function aff_catcher($type="") { $inactive = 1*60; // 1 minute $session_life = time() - $_SESSION['catcher']; if($session_life > $inactive) { if ($type=="annonces") { //$pub=" "; } else { $pub=""; $_SESSION['catcher']=time(); } } else { $pub=""; } return $pub; } ?>config['secret_no_sess']); $init_crypt['iv'] = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND); return $init_crypt; } function decode_crypt($key,$init_crypt) { $data=base64url_decode($key); $result = mcrypt_decrypt(MCRYPT_RIJNDAEL_256,$init_crypt['secret'],$data,MCRYPT_MODE_ECB,$init_crypt['iv']); if(strpos($result, '##')) { $tab = explode('##',$result); } else { $tab=false; } return $tab; } function encode_crypt($data,$init_crypt) { $key = base64url_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256,$init_crypt['secret'],$data,MCRYPT_MODE_ECB,$init_crypt['iv'])); return $key; } ?>clear($div, "innerHTML"); if(is_array($text)) { $objResponse->assign($div,"innerHTML",$text[0]); $objResponse->script($text[1]); } else {$objResponse->assign($div,"innerHTML",$text);} if($script!="") {$objResponse->script(base64_decode($script));} return $objResponse; } /* AFFICHAGE DES MESSAGES D'ERREUR */ function affiche_msg_err($type,$err){ global $core; $db = new db($core->config['db_name']); $result=$db->query("SELECT text FROM ".TEXTES_INFO." WHERE num='$err' AND type='$type' AND lang='".$core->config['lang']."'"); if($db->num_rows($result)!=0) { $r = $db->get_object($result); $erreur = $r->text; } return $erreur; } function msg_err($err){ global $core; //Affichage des erreurs if(($err!='')&&($err!=0)) { $core->systeme['erreur']=affiche_msg_err('err',$err); if($err<0) {$core->page['err'].=evalTemplate("tpl_erreur.php","commun");} elseif($err>0) {$core->page['err'].=evalTemplate("tpl_message.php","commun");} } } // Pour appeler une page dans templates/ function evalTemplate($template,$add_path="") { global $core; if(($add_path!="")&&(substr($add_path,-1)!="/")) {$add_path=$add_path."/";} if ($add_path=="") { $add_path="templates/".$core->config['squelette_defaut']."/"; } if ((file_exists($core->config['path_site']."/templates/".$core->config['template']."/templates/".$template))) { $add_path="templates/".$core->config['template']."/"; } $return = file_get_contents($add_path."templates/".$template); $return = str_replace('"','\"',$return); $return = preg_replace('/\{'.'\$'.'(.*)\}/smiU','".'.'\$'.'$1."',$return); eval( "\$return = \"$return\";" ); // on va chercher toutes les images et on va vérifier qu'elles existent bien avec la langue actuelle, sinon, on affiche les images correspondantes à la langue par défaut $return=modif_image($return); return $return; } // Pour appeler une page html dans html/ function evalPageHtml($pageHtml) { global $core; $return = @file_get_contents("html/".$pageHtml); // si le fichier html n'existe pas dans la langue actuelle if(!$return) { // on ouvre le fichier html correspondant à la langue par défaut $tab_namefile = explode('_',$pageHtml); // reconstitution du nom du fichier avec l'extension correspondant au language par défaut for($i=0;$i<(sizeof($tab_namefile)-1);$i++) {$fichierHtml.=$tab_namefile[$i]."_";} $fichierHtml.=$core->config['lang_default'].".html"; $return = file_get_contents("html/".$fichierHtml); } $return = str_replace('"','\"',$return); $return = preg_replace('/\{'.'\$'.'(.*)\}/smiU','".'.'\$'.'$1."',$return); eval( "\$return = \"$return\";" ); modif_image($return); return $return; } // Pour traduire les JS/ function evalTemplateJS($template) { global $core; $return = file_get_contents("js/".$template); $return = str_replace('"','\"',$return); $return = str_replace('$','#dollar#',$return); $return = preg_replace('/\{'.'#dollar#'.'(.*)\}/smiU','".'.'\$'.'$1."',$return); eval( "\$return = \"$return\";" ); $return = str_replace('#dollar#','$',$return); return $return; } function set_text_site(){ global $core; $db = new db($core->config['db_name']); $req1="SELECT nom,text FROM ".TEXTES_SITE." WHERE lang='".$core->config['lang_default']."' ORDER BY nom"; $result1 = $db->query($req1); $nb1 = $db->num_rows($result1); if($nb1>0) { while($row1=$db->get_object($result1)) { $req="SELECT nom,text FROM ".TEXTES_SITE." WHERE lang='".$core->config['lang']."' AND nom LIKE '".$row1->nom."' LIMIT 1"; $result = $db->query($req); $nb = $db->num_rows($result); if($nb>0) { $row=$db->get_object($result); $core->text[$row->nom]=htmlspecialchars($row->text, ENT_QUOTES); } // si aucun texte de la langue en cours , on remplace par le texte de la langue par defaut else { $core->text[$row1->nom]=htmlspecialchars($row1->text, ENT_QUOTES); } } } } function set_text_page($page){ global $core; $db = new db($core->config['db_name']); $req1="SELECT nom,text FROM ".TEXTES_PAGE." WHERE lang LIKE'".$core->config['lang_default']."' AND page LIKE '$page' ORDER BY nom"; $result1 = $db->query($req1); $nb1 = $db->num_rows($result1); if($nb1>0) { while($row1=$db->get_object($result1)) { $req="SELECT nom,page,text FROM ".TEXTES_PAGE." WHERE lang LIKE'".$core->config['lang']."' AND page LIKE '$page' AND nom LIKE '".$row1->nom."' LIMIT 1"; $result = $db->query($req); $nb = $db->num_rows($result); if($nb>0) { $row=$db->get_object($result); $core->page[$row->page][$row->nom]=htmlspecialchars($row->text, ENT_QUOTES); } // si aucun texte de la langue en cours , on remplace par le texte de la langue par defaut else { $core->page[$row->page][$row1->nom]=htmlspecialchars($row1->text, ENT_QUOTES); } } } } function set_text_menu($zone,$style=''){ global $core; $db = new db($core->config['db_name']); $req="SELECT nom,text,url,rubrique,target FROM ".TEXTES_MENU." WHERE lang LIKE '".$core->config['lang']."' AND zone LIKE '$zone' AND level<='".$core->config['level']."' ORDER BY ordre"; $result = $db->query($req); $nb = $db->num_rows($result); if($nb>0) { $i=0; $core->page['menu']=''; } // si aucun texte de la langue en cours , on remplace par le texte de la langue par defaut else { $req="SELECT nom,text,url,rubrique,target FROM ".TEXTES_MENU." WHERE lang LIKE '".$core->config['lang_default']."' AND zone LIKE '$zone' AND level<='".$core->config['level']."' ORDER BY ordre"; $result = $db->query($req); $core->page['menu']=''; } } function set_text_sous_menu($zone,$rubrique,$style=''){ global $core; $db = new db($core->config['db_name']); $req="SELECT nom,text,url FROM ".TEXTES_SOUS_MENU." WHERE lang LIKE '".$core->config['lang']."' AND zone LIKE '$zone' AND rubrique LIKE '$rubrique' AND level<='".$core->config['level']."' ORDER BY ordre"; $result = $db->query($req); $nb = $db->num_rows($result); if($nb>0) { $i=0; $core->page['sous_menu']=''; $core->page['sous_menu'].="
"; } // si aucun texte de la langue en cours , on remplace par le texte de la langue par defaut else { $req="SELECT nom,text,url FROM ".TEXTES_SOUS_MENU." WHERE lang LIKE '".$core->config['lang_default']."' AND zone LIKE '$zone' AND rubrique LIKE '$rubrique' AND level<='".$core->config['level']."' ORDER BY ordre"; $result = $db->query($req); $core->page['sous_menu']=''; $core->page['sous_menu'].="
"; } } function create_selectbox($obj,$nom,$select,$class='',$js='') { global $core; $text='"; return $text; } function create_selbox_sql($name_sbox, $table, $champ_id, $champ_nom, $id_selected=0, $class_css="", $text_label="", $opt_suppl="", $js="", $where="", $order_by="", $limit="") { $req = "SELECT $champ_id, $champ_nom FROM $table ".$where." ".$order_by." ".$limit; $res = mysql_query($req); $nb_line = mysql_numrows($res); if ($nb_line > 0) { $label = (empty($text_label)) ? "" : ''; $sbox = ''; return $label.$sbox; } return false; } //voir plus haut pour le détail des champs //création de selectbox pour site avec template function create_selbox_sql_tpl($name_sbox, $table, $champ_id, $champ_nom, $id_selected=0, $class_css="", $text_label="", $opt_suppl="", $js="", $where="", $order_by="", $limit="") { global $core; $db = new db($core->config['db_name']); $req = "SELECT $champ_id, $champ_nom FROM $table ".$where." ".$order_by." ".$limit; $res = $db->query($req); $nb_line = $db->num_rows($res); if ($nb_line > 0) { $label = (empty($text_label)) ? "" : ""; $sbox = ''; return $label." ".$sbox; } return false; } function add_reload_div($fonction_php,$type,$div,$interval,$params='0',$add_js='',$script=''){ global $core; switch ($type) { case 'change': $js=" onchange=\"xajax_reload_div('$fonction_php','$div','$params','$script');".$add_js."\" "; break; case 'click': $js=" onclick=\"xajax_reload_div('$fonction_php','$div','$params','$script');".$add_js."\" "; break; case 'div': $js=""; break; } return $js; } /* CONTRUCTION DE TABLEAUX */ function create_tableau($page,$id,$contenu_tableau,$css="",$js="",$add_url=""){ global $core; $constuction_tableau.=""; $db = new db($core->config['db_name']); $req="SELECT nom,text,page,tri,largeur,align FROM ".TEXTES_TABLEAU." WHERE lang='".$core->config['lang']."' AND page='$page' ORDER BY ordre"; $result = $db->query($req); $nb = $db->num_rows($result); if($nb>0) { $i=0; $constuction_tableau.=""; while($row=$db->get_object($result)) { $text=$row->text; // Ce qui va s'afficher $nom=$row->nom; // Pour la recherche sur les flèches $page=$row->page; // Pour la recherche sur les flèches $tri=$row->tri; // Pour la recherche sur les flèches $largeur=$row->largeur; $align=$row->align; // Ajout des flèches hautes et basses if ($tri=='1') { $url_tri=$core->config['page_en_cours']."?tri=$tri&col=$nom"; $constuction_tableau.=""; } else { $constuction_tableau.=""; } $i++; } $constuction_tableau.=""; } // si aucun texte de la langue en cours , on remplace par le texte de la langue par defaut else { $constuction_tableau.=""; $req="SELECT nom,text,page,tri,largeur,align FROM ".TEXTES_TABLEAU." WHERE lang='".$core->config['lang_default']."' AND page='$page' ORDER BY ordre"; $result = $db->query($req); while($row=$db->get_object($result)) { $text=$row->text; // Ce qui va s'afficher $nom=$row->nom; // Pour la recherche sur les flèches $page=$row->page; // Pour la recherche sur les flèches $tri=$row->tri; // Pour la recherche sur les flèches $largeur=$row->largeur; $align=$row->align; // Ajout des flèches hautes et basses if ($tri=='1') { $url_tri=$core->config['page_en_cours']."?tri=$tri&col=$nom"; $constuction_tableau.=""; } else { $constuction_tableau.=""; } $i++; } $constuction_tableau.=""; } $constuction_tableau.="$contenu_tableau"; $constuction_tableau.="
$text$text
$text$text
"; return $constuction_tableau; } function create_pagination($nb_pages,$page=1,$params='',$url="", $rewrite="", $input_hidden="",$val="page") { global $core; if ($nb_pages!="1") { if (($input_hidden!="")&&($rewrite!='rewrite')) { $open_form="
config['page_en_cours']."\" method=\"post\"> ".$input_hidden.""; $close_form="
"; } if ($rewrite=="rewrite") { $url=str_replace(".html","",$url); $tab_rewrite=explode("?", $url); $url=$tab_rewrite[0]; if ($tab_rewrite[1]!="") {$add_url="?".$tab_rewrite[1];} } if($params!='') { for($i=0;$i0) { if($nb_pages<=10) { $fin_aff=$nb_pages+1; $i=1; } else { if(($page>($nb_pages-9))&&($page>10)) { $i=$nb_pages-9; $fin_aff=$nb_pages+1; } else { if($page>5) { $i=$page-5; $fin_aff=$page+5; } else { $i=1; $fin_aff=10; } } } $page_suivante=$page+1; $page_precendente=$page-1; if ($page_precendente<=1) {$page_precendente=1;} if ($page_suivante>=$nb_pages) {$page_suivante=$nb_pages;} if($fin_aff>$nb_pages) {$fin_aff=$nb_pages;} if ($page!=1) { if ($rewrite=="rewrite") { $construct_pagination.= "text['page_premiere']."\"><< "; if ($page_precendente=="1") { $construct_pagination.= "  text['page_precendente']."\">< Précédente  "; } else { $construct_pagination.= "  text['page_precendente']."\">< Précédente  "; } } elseif (($input_hidden!="")&&($rewrite!='rewrite')) { $construct_pagination.= $open_form."".$close_form; $construct_pagination.= $open_form."    ".$close_form; } else { $construct_pagination.= "config['page_en_cours']."?".$val."=1&key=$key".$url."\" title=\"".$core->text['page_premiere']."\"><< "; $construct_pagination.= " config['page_en_cours']."?".$val."=$page_precendente&key=$key".$url."\" title=\"".$core->text['page_precendente']."\">< Précédente  "; } } while($i <= $fin_aff) { if ($rewrite=="rewrite") { if ($i=="1") { $construct_pagination.= " "; } else { $construct_pagination.= " "; } } elseif (($input_hidden!="")&&($rewrite!='rewrite')) { $construct_pagination.= $open_form; } else { $construct_pagination.= " config['page_en_cours']."?".$val."=$i".$add_key.$url."\">"; } if($i==$page) { if (($input_hidden!="")&&($rewrite!='rewrite')) { $construct_pagination.="".$close_form; } else { $construct_pagination.=" ".$i." "; } } else { if (($input_hidden!="")&&($rewrite!='rewrite')) { $construct_pagination.="".$close_form; } else { $construct_pagination.=" $i "; } } $i++; } if ($page!=$nb_pages) { if ($rewrite=="rewrite") { $construct_pagination.= "  text['page_suivante']."\">Suivante > "; $construct_pagination.= " text['page_derniere']."\">>>"; } elseif (($input_hidden!="")&&($rewrite!='rewrite')) { $construct_pagination.= $open_form."   ".$close_form; $construct_pagination.= $open_form."".$close_form; } else { $construct_pagination.= "  config['page_en_cours']."?".$val."=$page_suivante".$add_sql.$url."\" title=\"".$core->text['page_suivante']."\">Suivante > "; $construct_pagination.= " config['page_en_cours']."?".$val."=$nb_pages".$add_key.$url."\" title=\"".$core->text['page_derniere']."\">>>"; } } } } $construct_pagination="
$construct_pagination
"; return $construct_pagination; } // _____________ PAGINATION AJAX _______________ function create_pagination_ajax($nb_pages,$page=1,$params='', $fonction_js, $div) { global $core; if ($params=="") {$params="tous";} if($nb_pages>1) { if($nb_pages<=10) { $fin_aff=$nb_pages+1; $i=1; } else { if(($page>($nb_pages-9))&&($page>10)) { $i=$nb_pages-9; $fin_aff=$nb_pages+1; } else { if($page>5) { $i=$page-5; $fin_aff=$page+5; } else { $i=1; $fin_aff=10; } } } $page_suivante=$page+1; $page_precendente=$page-1; if ($page_precendente<=1) {$page_precendente=1;} if ($page_suivante>=$nb_pages) {$page_suivante=$nb_pages;} if($fin_aff>$nb_pages) {$fin_aff=$nb_pages;} if ($page!=1) { $construct_pagination.= "text['page_premiere']."\"><< "; $construct_pagination.= "  text['page_precendente']."\">Précédent  "; } while($i <= $fin_aff) { $construct_pagination.= " "; if($i==$page) { $construct_pagination.=" ".$i." "; } else { $construct_pagination.=" $i "; } $i++; } if ($page!=$nb_pages) { $construct_pagination.= "  text['page_suivante']."\">Suivant "; $construct_pagination.= " text['page_derniere']."\">>>"; } } $construct_pagination="
$construct_pagination
"; return $construct_pagination; } function recup_text_long($nom,$page) { global $core; $db = new db($core->config['db_name']); $result = $db->query("SELECT text FROM ".TEXTES_LONG." WHERE lang LIKE '".$core->config['lang']."' AND nom = '$nom' AND page='$page'"); $nb = $db->num_rows($result); if($nb>0) { while ($row=$db->get_object($result)) { $text=$row->text; } } else { $result = $db->query("SELECT text FROM ".TEXTES_LONG." WHERE lang LIKE '".$core->config['lang_default']."' AND nom = '$nom' AND page='$page'"); while ($row=$db->get_object($result)) { $text=$row->text; } } return $text; } // fonction permettant d'afficher les images dans la langue par défaut si aucune image dans la langue actuelle function modif_image(&$return) { global $core; // premiere partie de remplacement de l'attribut src preg_match_all('/src=["\']\/templates\/([-\._\/:a-z0-9]*)["\']/i', $return, $matches, PREG_SET_ORDER); foreach ($matches as $val) { if(!file_exists($core->config['path_site']."/templates/".$val[1])) { $return=str_replace($core->config['template'], $core->config['squelette_defaut'], $return); } } return $return; /* // premiere partie de remplacement de l'attribut src preg_match_all('/src=["\']\/images\/trad\/([-._\/:a-zA-Z0-9]*)["\']/', $return, $matches, PREG_SET_ORDER); foreach ($matches as $val) { if(!file_exists("$val[1]")) { $tab_nameImg = explode('_',$val[1]); // reconstitution du nom du fichier avec l'extension correspondant au language par dꧡut //images multilangues if(sizeof($tab_nameImg) > 1) { for($i=0;$i<(sizeof($tab_nameImg)-1);$i++) {$img=$tab_nameImg[$i]."_";} // récupération de l'extension de l'image $tabExt = explode('.' , $val[1]); $format = $tabExt[1]; $img.=$core->config['lang_default'].".$format"; // permet le remplacement de l'url pour les attributs onMouseOver et onMouseOut $img_hover = str_replace("OFF", "ON",$val[1] ); $img_blur = str_replace("ON", "OFF", $val[1] ); $img_modif_hover = str_replace("OFF", "ON",$img ); $img_modif_blur = str_replace("ON", "OFF", $img ); // remplacement de l'image $return = str_replace($val[1],$img,$return); $return = str_replace($img_hover,$img_modif_hover,$return); $return = str_replace($img_blur,$img_modif_blur,$return); } } }*/ } function affichage_err($erreur) { global $core; //Affichage des erreurs if(sizeof($erreur)!=0) { for($i=0;$isysteme['erreur']=affiche_msg_err('err',$erreur[$i]); if($erreur[$i]<0) {$core->page['err'].=evalTemplate("tpl_erreur.php");} elseif($erreur[$i]>0) {$core->page['err'].=evalTemplate("tpl_message.php");} } } } function recup_jour() { global $core; $db = new db($core->config['db_name']); $i=0; $result = $db->query("SELECT text FROM ".PARAMETRES_STATIC." WHERE lang LIKE '".$core->config['lang']."' AND type LIKE 'jours' ORDER BY CAST(nom AS signed integer) ASC"); while ($row=$db->get_object($result)) { $NomDuJour[$i] = $row->text; $i++; } $i=1; $result = $db->query("SELECT text FROM ".PARAMETRES_STATIC." WHERE lang LIKE '".$core->config['lang']."' AND type LIKE 'mois' ORDER BY CAST(nom AS signed integer) ASC"); while ($row=$db->get_object($result)) { $NomDuMois[$i] = $row->text; $i++; } $lejour = date("d"); $lemois = date("m"); $annee = date("Y"); //$requete = $db->query("SELECT fetedujour FROM holydays WHERE lejour='$lejour' AND lemois='$lemois'"); //if($requete){ // $row=$db->get_object($requete); $retour="
"; $retour.=$NomDuJour[ date("w") ]; if($lejour==01){ $retour.=" 1er "; } else if($lejour<10){ $retour.=" $lejour[1] "; } else { $retour.=date (" d "); } $retour.=$NomDuMois[ date(intval($lemois)) ]; $retour.=date (" Y"); // $retour.=" \"".$core-text['saint_du_jour']."\" title=\"".$core->text['saint_du_jour']."\" Style=\"cursor:pointer;cursor:hand;\" >"; // $retour.=$row->fetedujour; $retour.="
"; // } return $retour; } // Traduction complète des pages function affichage_texte_page($page_site,$language_site,$site="",$txt="texte_page") { global $core; $db = new db($core->config['db_name']); if($site=="") {$site=$core->config['id_site'];} if($site!=""){$add_site=" AND id_site LIKE '$site'";} $result = $db->query("SELECT ".$txt." AS txt FROM ".TRADUCTION_PAGES." WHERE page_site='$page_site' AND lang='$language_site' $add_site LIMIT 1"); $nb = $db->num_rows($result); if ($nb==0) { $add_site=" AND id_site='0'"; $result = $db->query("SELECT ".$txt." AS txt FROM ".TRADUCTION_PAGES." WHERE page_site='$page_site' AND lang='$language_site' $add_site LIMIT 1"); } while ($row=$db->get_object($result)) { $texte_page=stripslashes($row->txt); $affichage_texte_page="
$texte_page
"; } return $affichage_texte_page; } function reload_sess() { session_start(); } //______ RECUPERER UN CHAMPS DANS UNE TABLE___________ function recup_donnee ($table,$champs,$id,$champs_a_recup, $ajout="", $debug="") { global $core; $db = new db($core->config['db_name']); if ($table==TRADUCTION_PAGES) { $site=$core->config['id_site']; if($site!=""){$add_site=" AND id_site LIKE '$site'";} } if ($ajout!="") {$add_where="AND $ajout";} if ($champs!="") {$add_champs="WHERE $champs='$id' $add_where $add_site";} $sql="SELECT $champs_a_recup as valeur_a_recup FROM $table $add_champs"; if ($debug=="debug") {echo "DEBUG : $sql
";} $result=$db->query($sql); while ($row=$db->get_object($result)) { $value=$row->valeur_a_recup; } return $value; } //______ RECUPERER UN CHAMPS DANS UNE TABLE DU BLOG___________ function recup_donnee_blog ($table,$champs,$id,$champs_a_recup, $ajout="") { global $core; $db = new db($core->config['db_blog']); if ($ajout!="") { $add_where="AND $ajout"; } if ($champs!="") { $add_champs="WHERE $champs='$id' $add_where"; } $sql="SELECT $champs_a_recup as valeur_a_recup FROM $table $add_champs"; $result=$db->query($sql); while ($row=$db->get_object($result)) { $value=$row->valeur_a_recup; } return $value; } function generate_chaine($car) { $string = ""; $chaine = "abcdefghijklmnpqrstuvwxy0123456789"; srand((double)microtime()*1000000); for($i=0; $i<$car; $i++) { $string .= $chaine[mt_rand()%strlen($chaine)]; } return $string; } function checkEncoding ( $string, $string_encoding ) { $fs = $string_encoding == 'UTF-8' ? 'UTF-32' : $string_encoding; $ts = $string_encoding == 'UTF-32' ? 'UTF-8' : $string_encoding; return $string === mb_convert_encoding ( mb_convert_encoding ( $string, $fs, $ts ), $ts, $fs ); } function nettoyage_br($chaine_de_caractere) { $chaine_de_caractere=urlencode($chaine_de_caractere); //$chaine_de_caractere=clean_str($chaine_de_caractere); $chaine_de_caractere=trim($chaine_de_caractere); $chaine_de_caractere=str_replace("\r\n", "", $chaine_de_caractere); $chaine_de_caractere=str_replace("\n", "", $chaine_de_caractere); $chaine_de_caractere=str_replace("\r", "", $chaine_de_caractere); $chaine_de_caractere=str_replace("
", "", $chaine_de_caractere); $chaine_de_caractere=str_replace("
", "", $chaine_de_caractere); $chaine_de_caractere=urldecode($chaine_de_caractere); $chaine_de_caractere=str_replace("n2Fa", "n/a", $chaine_de_caractere); return $chaine_de_caractere; } ?>