", ">", $traite); $traite = str_replace("<", "<", $traite); } // wiki syntax $traite = ereg_replace("!!!(('?[^\n'])*)!!!","

\\1

",$traite); $traite = ereg_replace("!!(('?[^\n'])*)!!","

\\1

",$traite); $traite = ereg_replace("!(('?[^\n'])*)!","

\\1

",$traite); $traite = ereg_replace("\*\*(('?[^\n'])*)\*\*", "\\1", $traite); $traite = ereg_replace("''(('?[^\n'])*)''", "\\1", $traite); $traite = ereg_replace("__(('?[^\n'])*)__", "\\1", $traite); $traite = ereg_replace("::(('?[^\n'])*)::", "
\\1
", $traite); $traite = str_replace("---", "
", $traite); $traite = eregi_replace("\[([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+)\]", "\\1", $traite); $traite = ereg_replace("\[(.*)\>([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])\]", "\\1", $traite); $traite = ereg_replace("\[(.*)>([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])\]", "\\1", $traite); $traite = eregi_replace("\[([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])\]", "\\1://\\2\\3", $traite); //$traite = ereg_replace( "\[(.*>[A-Z][a-z]+\)]", "\\2", $traite); $traite = ereg_replace( "\[(.*)\>(.*)\]", "\\1", $traite); $traite = ereg_replace( "\[(.*)>(.*)\]", "\\1", $traite); $traite = ereg_replace( "\[(.*)\]", "\\1", $traite); $traite = ereg_replace( "\{\{(.*)\|(.*)\|(.*)\|(.*)\|(.*)\|(.*)\}\}", "\\2", $traite); $traite = ereg_replace( "\{\{(.*)\|(.*)\|(.*)\|(.*)\|(.*)\}\}", "\\2", $traite); $traite = ereg_replace( "\{\{(.*)\|(.*)\|(.*)\|(.*)\}\}", "\\2", $traite); $traite = ereg_replace( "\{\{(.*)\|(.*)\|(.*)\}\}", "\\2", $traite); $traite = ereg_replace( "\{\{(.*)\|(.*)\}\}", "\\2", $traite); // smileys global $souriez; $traite = str_replace($souriez[0][0], "|:-)", $traite); $traite = str_replace($souriez[1][0], ";-)", $traite); $traite = str_replace($souriez[2][0], ";)", $traite); $traite = str_replace($souriez[3][0], ";o)", $traite); $traite = str_replace($souriez[4][0], ":-))", $traite); $traite = str_replace($souriez[5][0], ":))", $traite); $traite = str_replace($souriez[6][0], ":-)", $traite); $traite = str_replace($souriez[7][0], ":)", $traite); $traite = str_replace($souriez[8][0], ":-o", $traite); $traite = str_replace($souriez[9][0], ":o(", $traite); $traite = str_replace($souriez[10][0], ":o((", $traite); $traite = str_replace($souriez[11][0], ":((", $traite); $traite = str_replace($souriez[12][0], ":-(", $traite); $traite = str_replace($souriez[13][0], ":(", $traite); $traite = str_replace($souriez[14][0], "8-)", $traite); $traite = str_replace($souriez[15][0], ":-p", $traite); $traite = str_replace($souriez[16][0], ";-(", $traite); $traite = str_replace($souriez[17][0], ";-(", $traite); $traite = str_replace($souriez[18][0], ";-(", $traite); $traite = str_replace("\n","
",$traite); return $traite; } function mailalert($to, $subject, $from_name, $from_mail, $from_subject, $from_text) { $email = ""; if ($from_name != "") $email .= "Auteur:".$from_name; if ($from_mail != "") $email .= "<".$from_mail.">"; if ($from_subject != "") $email .= "\nTitre:".$from_subject; if ($from_subject != "") $email .= "\nTexte:".$from_text; $subject = "[Tourmentine] ".$subject; //mail($to, $subject, $email); mail($to, $subject, $from_text, "From: ".$from_name." <".$from_mail.">\r\nX-Mailer: PHP/" . phpversion()); } // renvoie la page ou le module en cours // (nécessaire car netscape ne reconnait pas la constante __SELF__) function caller() { include "include/theme.inc.php"; global $section; global $page; global $modulepage; global $theme; if (($section != "") && ($page != "")) $liencaller = "?section=$section&page=$page&theme=$theme"; else if ($modulepage != "") $liencaller = "?modulepage=$modulepage&theme=$theme"; else $liencaller = "?theme=$theme"; return $liencaller; } // renvoie la page ou le module en cours, à ajouter dans un formulaire // (pour le passage de paramètres par méthode get) function formcaller() { require_once "include/theme.inc.php"; global $section; global $page; global $modulepage; global $theme; if (($section != "") && ($page != "")) $formcaller = " "; else if ($modulepage != "") $formcaller = " "; else return $formcaller; } // formate un nombre pour stockage dans un fichier d'index function splitchar($Number) { $byte = strval(dechex($Number)); switch(strlen($byte)) { case 1: $byte0=$byte; $byte1=$byte2=$byte3=0; break; case 2: $byte0="$byte[0]$byte[1]"; $byte1=$byte2=$byte3=0; break; case 3: $byte0="$byte[1]$byte[2]"; $byte1=$byte[0]; $byte2=$byte3=0; break; case 4: $byte0="$byte[2]$byte[3]"; $byte1="$byte[0]$byte[1]"; $byte2=$byte3=0; break; case 5: $byte0="$byte[3]$byte[4]"; $byte1="$byte[1]$byte[2]"; $byte2=$byte[0]; $byte3=0; break; case 6: $byte0="$byte[4]$byte[5]"; $byte1="$byte[2]$byte[3]"; $byte2="$byte[0]$byte[1]"; $byte3=0; case 7: $byte0="$byte[5]$byte[6]"; $byte1="$byte[3]$byte[4]"; $byte2="$byte[1]$byte[2]"; $byte3=$byte[0]; break; case 8: $byte0="$byte[6]$byte[7]"; $byte1="$byte[4]$byte[5]"; $byte2="$byte[2]$byte[3]"; $byte3="$byte[0]$byte[1]"; break; default: echo "depassement !!!!!!"; } $string = sprintf("%c%c%c%c",hexdec($byte3),hexdec($byte2),hexdec($byte1),hexdec($byte0)); return $string; } // créé un fichier d'index function strfile($FileName) { $Nb = 0; $index[$Nb++] = "0"; $input = fopen("$FileName.csv","r"); while ($data = fgetcsv($input, 10000, ",")) $index[$Nb++] = ftell($input); fclose($input); $index[--$Nb] = 0; $output = fopen("$FileName.dat","w"); fwrite($output,splitchar($Nb)); for ($i = 0 ; $i < $Nb ; $i++) fwrite($output,splitchar($index[$i])); fclose($output); } // lit un fichier d'index et renvoie l'index correspondant au numéro d'enregistrement function unstr($FileName,$Num) { if (!file_exists("$FileName.dat")) strfile($FileName); $indexfile = fopen("$FileName.dat","r"); $total = hexdec(bin2hex(fread($indexfile,4))); if ($Num > $total) $Num = $total; fseek($indexfile,($Num*4)+4); $pos = hexdec(bin2hex(fread($indexfile,4))); fclose($indexfile); return $pos; } // retourne le nombre d'enregistrement d'après le fichier d'index function gettotal($FileName,$typefile="file") { if ($typefile == "db") { global $sqltimegen; $sqlstartgen = microtime(true); $db = sqlite_open("modules/db.sqlite"); $line = sqlite_query($db, "SELECT * FROM news ORDER BY id DESC LIMIT 1 OFFSET 0"); $row = sqlite_fetch_array($line); $total_records = $row["id"]; sqlite_close($db); $sqlendgen = microtime(true); $sqltimegen += $sqlendgen - $sqlstartgen; } else { if (!file_exists("$FileName.dat")) strfile($FileName); $indexfile = fopen("$FileName.dat","r"); $total_records = hexdec(bin2hex(fread($indexfile,4))); fclose($indexfile); } return $total_records; } // compte le nombre d'enregistrement d'un fichier csv function countcsv($File) { $max = 0; $fd = fopen("$File.csv","r"); while (fgetcsv($fd,10000 , ",")) $max++; fclose($fd); return $max; } // créé un fichier function createfile($FileName) { $fp = fopen($FileName,"w+"); fclose($fp); } // affiche une erreur 401 function err401($msg_err) { echo " Rapport d'erreur

Erreur 401



$msg_err

"; exit(); } // créé un fichier de log function addlog($url) { $File = "/logs/".str_replace("/","_",$url).".log"; // si le fichier n'existe pas, on le crée: if (!file_exists("$File.csv") ) createfile("$File.csv"); $date = strftime ("%d/%m/%Y", time()); $string = sprintf("\"".$date."\",\"".iheure()."\",\"".$_SERVER["REMOTE_ADDR"]."\",\"".$_SERVER["HTTP_REFERER"]."\",\"".$_SERVER["HTTP_USER_AGENT"]."\"\n"); $fp = fopen("$File.csv","a"); fwrite($fp,$string); fclose($fp); strfile($File); } // convertit les entités HTML en charactères spéciaux function html2ascii($inputstring) { $outputstring = eregi_replace("é","é",$inputstring); $outputstring = eregi_replace("è","è",$outputstring); $outputstring = eregi_replace("à","à",$outputstring); $outputstring = eregi_replace("ù","ù",$outputstring); $outputstring = eregi_replace("ô","ô",$outputstring); $outputstring = eregi_replace("ê","ê",$outputstring); $outputstring = eregi_replace("î","î",$outputstring); $outputstring = eregi_replace("â","â",$outputstring); $outputstring = eregi_replace("û","û",$outputstring); $outputstring = eregi_replace("ï","ï",$outputstring); $outputstring = eregi_replace("ë","ë",$outputstring); $outputstring = eregi_replace("ç","ç",$outputstring); $outputstring = eregi_replace(" "," ",$outputstring); $outputstring = eregi_replace(""","\"",$outputstring); $outputstring = eregi_replace("&","&",$outputstring); return $outputstring; } function wiki_help($lang) { if ($lang == "fr") return "
Gras**texte**texte
Italique''texte''texte
Souligné__texte__texte
Centré::texte::
texte
Lien interne[fichier]fichier
Lien interne nommé[lien>fichier]lien
Lien externe[http://serveur/fichier]http://serveur/fichier
Lien externe nommé[lien>http://serveur/fichier]lien
Adr. e-mail[nom@serveur]nom@serveur
Saut de ligne___
Images{{http://serveur/image|nom}}nom
   
Les tags HTML ne sont pas authorisés.Pour afficher le symbole €, vous devez taper « &euro; ».
"; else return"
Bold**text**text
Italic''text''text
Underline__text__text
Centered::text::
text
Internal link[file]file
Named internal link[link>file]link
External link[http://server/file]http://server/file
Named external link[lien>http://server/file]link
e-mail Adr.[name@server]name@server
New line___
Images{{http://server/picture|name}}name
   
HTML tags are not allowed.You have to put « &euro; » to print the € symbol.
"; } function fmtime(&$item,$key,$cache) { return (filemtime($cache) > filemtime($item)); } function cache($cachefile, $getfile, $dep) { // $cachefile = "tmp/titres.cache.php"; $FileNews = "modules/news/news"; $totalnews = gettotal($FileNews); if (file_exists($cachefile)) { if (array_walk ($dep, 'fmtime',$cachefile)) return "success"; else return "failed"; } else return "$cachefile not found"; echo "coucou!"; /* if (!file_exists($cachefile) || (filemtime($cachefile) < filemtime("modules/news/news.dat"))) { $cachecontent = "\n\n\n\n"; $cachecontent .= file_get_contents("http://".$_SERVER["SERVER_NAME"]."/modules/magicbox.php?module=affnews&titleonly=1&BoxNbMaxNews=$totalnews&NbMaxNews=$totalnews&cropdate=10&bodyclass=centerbody&start=$totalnews&titre=Les%20nouvelles%20anciennes%20de%20la%20Tourmentine"); $cachecontent .= "\n\n\n"; $cachecontent = str_replace("","?>",$cachecontent); $fp = fopen($cachefile,"w"); fwrite($fp,$cachecontent); fclose($fp); } include $cachefile;a*/ } //echo cache("../tmp/titres.cache.php","http://".$_SERVER["SERVER_NAME"]."/modules/magicbox.php?module=affnews&titleonly=1&BoxNbMaxNews=$totalnews&NbMaxNews=$totalnews&cropdate=10&bodyclass=centerbody&start=$totalnews&titre=Les%20nouvelles%20anciennes%20de%20la%20Tourmentine",array ("modules/news/news.dat")); /** * Check if the browser is on a mobile device * * Adapted from the example code at url below * * @link http://www.brainhandles.com/2007/10/15/detecting-mobile-browsers/#code */ function clientismobile(){ if(isset($_SERVER['HTTP_X_WAP_PROFILE'])) return true; if(preg_match('/wap\.|\.wap/i',$_SERVER['HTTP_ACCEPT'])) return true; if(!isset($_SERVER['HTTP_USER_AGENT'])) return false; $uamatches = 'midp|j2me|avantg|docomo|novarra|palmos|palmsource|240x320|opwv|chtml|pda|windows ce|mmp\/|blackberry|mib\/|symbian|wireless|nokia|hand|mobi|phone|cdm|up\.b|audio|SIE\-|SEC\-|samsung|HTC|mot\-|mitsu|sagem|sony|alcatel|lg|erics|vx|NEC|philips|mmm|xx|panasonic|sharp|wap|sch|rover|pocket|benq|java|pt|pg|vox|amoi|bird|compal|kg|voda|sany|kdd|dbt|sendo|sgh|gradi|jb|\d\d\di|moto'; if(preg_match("/$uamatches/i",$_SERVER['HTTP_USER_AGENT'])) return true; return false; } ?>