Code :
- <?php
- // Verfier la synthaxe de l'email
- function test_mail($email) {
- $pattern = "^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}$";
- if (eregi ($pattern, $email))
- return TRUE;
- else
- return FALSE;
- }
- // Affichier les liens
- function affichage_liens($liste, $url_r=1, $fil=0) {
- global $tab_pr;
- while ($i=mysql_fetch_array($liste))
- {
- $tab_pr[$i["url"]] = $i["pr"];
-
- echo "\n".'<table><tr><td style="vertical-align : top; width : 130px;"><img src="http://www.thumbzor.com/tel.php?url='.$i["url"].'"> </td><td style="vertical-align : middle;">';
- echo '<div class="lien"><img src="images/drapal.png" alt="Ce site est québécois" border="0">'."\n".'<a onclick="window.open(this.href,\'_blank\');return false;" href="'.$i["url"].'" title="'.$i["name"].'">'.$i["name"].'</a>';
- if ($i["pr"] != 0)
- echo ' <img src="images/pr'.$i["pr"].'.gif" alt="Page Rank : '.$i["pr"].'" />';
- echo ' <a onclick="window.open(this.href,\'_blank\');" href="'.$i["name"].'.pdf." ><img src="images/depliant.gif" border="0" alt="téléchargez la brochure" /></a>';
- echo "<br />\n";
- echo "<br />\n";
- echo $i["description"].'<br />';
- if ($fil == 0)
- echo "\n<span>".$i["url"]."</span>\n</div>\n\n";
- else {
- echo "\n".'<span>'.$i["url"].'</span><br />';
- $title_chemin = show_me_the_way_clic($i['category'], $url_r);
- echo "\n<div class=\"ariane\">Catégorie :$title_chemin"."</div>\n</div>\n\n";
- }
- echo '</td></tr></table>';
- }
- }
- // Fonction pour montrer le chemin d'un lien
- function show_me_the_way($id) {
- $title_chemin = '';
- while ($id != 0)
- {
- $DB = mysql_query("SELECT name, root FROM `category` WHERE id='$id'" );
- $result = mysql_fetch_array($DB);
- $id = $result["root"];
- $title_chemin = ' > '.$result["name"].$title_chemin;
- }
- return $title_chemin;
- }
- // Fonction pour montrer le chemin d'un lien (avec les liens lol)
- function show_me_the_way_clic($id, $url_r) {
- global $titre_page;
- $title_chemin = '';
- while ($id != 0)
- {
- $DB = mysql_query("SELECT id, name, root FROM `category` WHERE id='$id'" );
- $result = mysql_fetch_array($DB);
- $id = $result["root"];
- if (!isset($titre_page)) $titre_page = $result["name"];
- if ($url_r == 1)
- $title_chemin = ' > <a href="'.code_url($result["name"]).'-'.$result["id"].'.html" title="'.$result["name"].'">'.$result["name"].'</a>'.$title_chemin;
- else
- $title_chemin = ' > <a href="index.php?dir='.$result["id"].'" title="'.$result["name"].'">'.$result["name"].'</a>'.$title_chemin;
- }
- return $title_chemin;
- }
- // Fonction pour la transformation des noms pour générer les pdf
- function code_pdf($string)
- {
- $string = strtolower($string);
- $string = str_replace("( |')", "-", $string);
- $accent = array('â','à','é','è','ê','î','ô','û','ç');
- $sans_accent = array('a','a','e','e','e','i','o','u','c');
- $string = str_replace($accent, $sans_accent, $string);
- $string = eregi_replace("[^a-z0-9]","-",$string);
- $string = eregi_replace("(^(_)*|(_)*$)","",$string);
- $string = eregi_replace("(-){2,3}","",$string);
- return $string;
- }
- // Fonction pour l'URL Rewriting
- function code_url($string)
- {
- $string = strtolower($string);
- $nom=ereg_replace(' ','-',$string);
- $nom=ereg_replace('\'','-',$string);
- $accent = array('â','à','é','è','ê','î','ô','û','ç');
- $sans_accent = array('a','a','e','e','e','i','o','u','c');
- $string = str_replace($accent, $sans_accent, $string);
- $string = eregi_replace("[^a-z0-9]","-",$string);
- $string = eregi_replace("(^(_)*|(_)*$)","",$string);
- $string = eregi_replace("(-){2,3}","",$string);
- return $string;
- }
- // Teste si l'URL répond
- function checkurl($url){
- // vérification du protocole HTTP
- if (!eregi("^http://", $url)) {
- return FALSE;
- }
- $details = parse_url($url);
- // vérification du port 80 lié au protocole HTTP
- if (!isset($details['port'])) {
- $details['port'] = "80";
- }
- // vérification du chemin
- if (!isset($details['path'])) {
- $details['path'] = "/";
- }
- // vérification de l'adresse du serveur
- if (!ereg("[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+", $details['host'])){
- $details['host'] = gethostbyname($details['host']);
- }
- // ouverture d'une connexion vers le serveur
- if ($sock = @fsockopen( $details['host'], $details['port'], $numero_erreur, $texte_erreur)){
- $requete = "GET ".$details['path']." HTTP/1.1\r\n";
- $requete .= "Host: ".$details['host']."\r\n\r\n";
- // envoie d'une requête HTTP GET
- fputs($sock, $requete);
- // réception de la réponse du serveur
- $str = fgets($sock, 1024);
- while(!ereg('^HTTP/1.1 ', $str)){
- $str = fgets($sock, 1024);
- }
- // fermeture de la connexion
- fclose($sock);
- list($http, $str, $texte) = explode(" ", $str, 3);
- return TRUE;
- }
- return FALSE;
- }
- // Calcul PR
- define('GMAG', 0xE6359A60);
- //unsigned shift right
- function zeroFill($a, $b)
- {
- $z = hexdec(80000000);
- if ($z & $a)
- {
- $a = ($a>>1);
- $a &= (~$z);
- $a |= 0x40000000;
- $a = ($a>>($b-1));
- }
- else
- {
- $a = ($a>>$b);
- }
- return $a;
- }
- function mix($a,$b,$c) {
- $a -= $b; $a -= $c; $a ^= (zeroFill($c,13));
- $b -= $c; $b -= $a; $b ^= ($a<<8);
- $c -= $a; $c -= $b; $c ^= (zeroFill($b,13));
- $a -= $b; $a -= $c; $a ^= (zeroFill($c,12));
- $b -= $c; $b -= $a; $b ^= ($a<<16);
- $c -= $a; $c -= $b; $c ^= (zeroFill($b,5));
- $a -= $b; $a -= $c; $a ^= (zeroFill($c,3));
- $b -= $c; $b -= $a; $b ^= ($a<<10);
- $c -= $a; $c -= $b; $c ^= (zeroFill($b,15));
-
- return array($a,$b,$c);
- }
- function GCH($adress, $length=null, $init=GMAG) {
- if(is_null($length)) {
- $length = sizeof($adress);
- }
- $a = $b = 0x9E3779B9;
- $c = $init;
- $k = 0;
- $len = $length;
- while($len >= 12) {
- $a += ($adress[$k+0] +($adress[$k+1]<<8) +($adress[$k+2]<<16)
- +($adress[$k+3]<<24));
- $b += ($adress[$k+4] +($adress[$k+5]<<8) +($adress[$k+6]<<16)
- +($adress[$k+7]<<24));
- $c += ($adress[$k+8] +($adress[$k+9]<<8)
- +($adress[$k+10]<<16)+($adress[$k+11]<<24));
- $mix = mix($a,$b,$c);
- $a = $mix[0]; $b = $mix[1]; $c = $mix[2];
- $k += 12;
- $len -= 12;
- }
- $c += $length;
- switch($len) /* all the case statements fall through */
- {
- case 11: $c+=($adress[$k+10]<<24);
- case 10: $c+=($adress[$k+9]<<16);
- case 9 : $c+=($adress[$k+8]<<8);
- /* the first byte of c is reserved for the length */
- case 8 : $b+=($adress[$k+7]<<24);
- case 7 : $b+=($adress[$k+6]<<16);
- case 6 : $b+=($adress[$k+5]<<8);
- case 5 : $b+=($adress[$k+4]);
- case 4 : $a+=($adress[$k+3]<<24);
- case 3 : $a+=($adress[$k+2]<<16);
- case 2 : $a+=($adress[$k+1]<<8);
- case 1 : $a+=($adress[$k+0]);
- /* case 0: nothing left to add */
- }
- $mix = mix($a,$b,$c);
- /*-------------------------------------------- report the result */
- return $mix[2];
- }
- //converts a string into an array of integers containing the numeric value of the char
- function strord($string) {
- for($i=0;$i<strlen($string);$i++) {
- $result[$i] = ord($string{$i});
- }
- return $result;
- }
- function getPR($_url) {
- $adress = 'info:'.$_url;
- $ch = GCH(strord($adress));
- $adress='info:'.urlencode($_url);
- $pr =
- @file("http://www.google.com/search?client=navclient-auto&ch=6$ch&ie=UTF-8&oe=UTF-8&features=Rank&q=$adress" );
- $pr_str = @implode("", $pr);
- return substr($pr_str,strrpos($pr_str, ":" )+1);
- }
- // Génère un mot secret pour la confirmation des sites
- function random_pass() {
- $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
- $password = '';
- for ($i = 0; $i < 32; ++$i)
- $password .= substr($chars, (mt_rand() % strlen($chars)), 1);
- return $password;
- }
- ?>
|