Ensuite pensez bien à activer le plugin dans votre interface d'admin Wordpress (onglet Plugins > Activer) *************************/ class geturl_timeout { /* $strlocation - URL of the last web page retreived (could be different from what was requiested in case of HTTP redirect.) */ var $strLocation; var $aHeaderLines; // headers of last web page var $strFile; // last web page retreived /* $bResult - contains true if last web page was retrieved successfully, false otherwise. */ var $bResult; var $Location; // Liste de vieux emplacements var $old_url; // chemin en cas de redirections. var $total_headers; var $timeout; // defautl timeout when opening URI function getContent() { return $this->strFile; } function getHeader() { return $this->aHeaderLines; } /* ReadHttpFile - the function that does all the work. $strUrl - URL of the page we want to get. $iHttpRedirectMaxRecursiveCalls - maximum number of times following HTTP redirection (internal use only now). */ function read($strUrl, $iHttpRedirectMaxRecursiveCalls = 20) { // Initialise location if first call if($iHttpRedirectMaxRecursiveCalls == 20) { $this->Location = array(); $this->old_url = array(); $this->total_headers = array(); } // parsing the url getting web server name/IP, path and port. $url = parse_url($strUrl); // Vérifier si le nouveau schéma possède un nom d'hote if( !isset($url['host']) ) { $url['host'] = $this->old_url['host']; // Vérifier aussi si le chemin doit etre rajouté if($url['path']{0} != '/') $url['path'] = $this->old_url['path'] . $url['path']; } // Restituer username et password si nécessaire (untested) if( ($url['host'] == $this->old_url['host']) && ($url['port'] == $this->old_url['port']) ) { if( isset($this->old_url['user']) && (! isset($url['user']) ) ) { $url['user'] = $this->old_url['user']; $url['pass'] = $this->old_url['pass']; } } // setting path to "/" if not present in $strUrl if ($url["path"] == '') $url["path"] = "/"; // setting port to default HTTP server port 80 if (isset($url["port"]) == false) $url["port"] = 80; // Mise a jour, si nécessaire, de l'URL actuelle... $actu = count($this->Location); if( $actu != 0 ) { if(isset($url['user'])) $act = 'http://' . $url['user'] . ':' . $url['name'] . '@' . $url['host'] . $url['path']; else $act = 'http://' . $url['host'] . $url['path']; if(isset($url['query'])) $act .= "?" . $url['query']; // Supprimer le dernier ajoit array_pop($this->Location); // Et mettre le nouveau. $this->Location[] = $act; } // connecting to the server $fp = @fsockopen ($url["host"], $url["port"], $errno, $errstr, 4); @socket_set_timeout($fp, $this->timeout); // reseting class data $this->bResult = false; unset($this->strFile); unset($this->aHeaderLines); $this->strLocation = $strUrl; /* Return if the socket was not open $this->bResult is set to false. */ if (!$fp) { return; } else { // composing HTTP request $strQuery = "GET ".$url["path"]; if ( isset($url["query"]) ) $strQuery .= "?".$url["query"]; $strQuery .= " HTTP/1.0\r\n"; if ( isset($url['user']) ) $strQuery .= "Authorization: Basic " . base64_encode($url['user'] .':'. $url['pass']) . "\r\n"; $strQuery .= "Host: " . $url['host'] . "\r\n\r\n"; // sending the request to the server // If it didn't work, ends directly if(fputs($fp, $strQuery)==false) { fclose($fp); return; } /* $bHeader is set to true while we receive the HTTP header and after the empty line (end of HTTP header) it's set to false. */ $bHeader = true; // continuing reading a line of text from the socket not more than // 8192 symbols.untill there's no more text to read from the socket while ( ($strLine = fgets($fp, 8192)) !== false ) { // removing trailing \n and \r characters. $strLine = ereg_replace("[\r\n]", "", $strLine); if ($bHeader == false) $this->strFile .= $strLine."\n"; else $this->aHeaderLines[] = trim($strLine); if (strlen($strLine) == 0) $bHeader = false; } fclose ($fp); } $this->total_headers = @array_merge($this->total_headers, $this->aHeaderLines); /* Processing all HTTP header lines and checking for HTTP redirect directive 'location:'. */ for ($i = 0; $i < count($this->aHeaderLines); $i++) if (strcasecmp(substr($this->aHeaderLines[$i], 0, 9), "Location:") == 0) { $new_url = trim(substr($this->aHeaderLines[$i], 9)); // $url now is the URL of the web page we are relocated to // If $url is the same page we are requesting, just continue if ($new_url != $strUrl) { // rajouter un tableau à la liste... $this->Location[] = $new_url; // et stocker la vieille url... (en tronquant un poil le path) // not fully tested $taille = strlen($url['path']); while($url['path']{$taille} != '/') $taille--; $url['path'] = substr($url['path'], 0, $taille+1); $this->old_url = $url; /* If the maximum number of redirects is reached, just return. $this->bResult is set to false. */ if ($iHttpRedirectMaxRecursiveCalls == 0) return; /* Calling the function recursively with the new URL and the maximum number of redirections reduced by one. */ return $this->read( $new_url, $iHttpRedirectMaxRecursiveCalls-1); } } /* We should get here if there was no HTTP redirect directive found. Setting $this->bResult to true. Web page was retreived successfully. */ $this->bResult = true; /* If magic_quotes_runtime is enabled in php.ini, then all the quotes in the received text will be prefixed with slashes. */ if (ini_get("magic_quotes_runtime")) { $this->strFile = stripslashes($this->strFile); for ($i = 0; $i < count($this->aHeaderLines); $i++) $this->aHeaderLines[$i] = stripslashes($this->aHeaderLines[$i]); } } /* Just to make it easier to use this class, adding contructor which accepts URL as a parameter and calls ReadHttpFile functions. */ function geturl_timeout($time_o = 5, $strUrl = "") { $this->timeout = $time_o; if (strlen($strUrl) > 0) $this->read($strUrl); } }; function fuzzvote() { global $id; $url=htmlspecialchars(strip_tags(get_permalink()),ENT_QUOTES); // Recuperation du nombre de votes sur Fuzz avec un timeout $gu = new geturl_timeout(5, "http://www.fuzz.fr/fuzzvote.php?geturl=".$url); $strfuzzvote=$gu->getContent(); // Fuzz ne fonctionne pas ? Ne rien afficher alors ! if (! $strfuzzvote) return; $fuzzvote=0; if(eregi("([0-9]*)\|([0-9]*)",$strfuzzvote,$rg)) { $fuzzvote=$rg[1]; } $tempcat=get_the_category($id); $categoriefuzz=""; if(!empty($tempcat)) { foreach($tempcat AS $v) { $categoriefuzz.=$v->cat_name."|"; } $categoriefuzz=substr($categoriefuzz,0,-1); } elseif(!empty($tempcat[0]->cat_name)) { $categoriefuzz=$tempcat[0]->cat_name; } $trans=array("\r"=>"","\n"=>"","\t"=>"","

"=>"
",""=>"
",""=>"
",""=>"
",""=>"
",""=>"
",""=>"
","<"=>"<",">"=>">"); $content=htmlspecialchars(strip_tags(get_the_content(),"
"),ENT_QUOTES); $content=strtr($content,$trans); $title=htmlspecialchars(strip_tags(get_the_title(),"
"),ENT_QUOTES); $title=strtr($title,$trans); $categoriefuzz=htmlspecialchars(strip_tags($categoriefuzz),ENT_QUOTES); $categoriefuzz=strtr($categoriefuzz,$trans); $url=htmlspecialchars(strip_tags(get_permalink()),ENT_QUOTES); echo "
"; echo "

".$fuzzvote."
Fuzz

Voter

"; } ?>