[129] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 |
|
---|
| 4 | $url="http://www.guidonia.org/nuovo/comune/rss.php?siteid=24"; // link feed
|
---|
| 5 | $sito="http://www.guidonia.org/portale/comune/index.php?siteid=24"; // link sito
|
---|
| 6 | //$url="http://www.aniene.net/backend.php";
|
---|
| 7 | echo "<h5>News Ufficio Elettorale</h5>"; // titolo
|
---|
| 8 | $agent= $_SERVER['HTTP_USER_AGENT'];
|
---|
| 9 |
|
---|
| 10 |
|
---|
| 11 |
|
---|
| 12 | $rdf = parse_url($url);
|
---|
| 13 | $fp = fsockopen($rdf['host'], 80, $errno, $errstr, 15);
|
---|
| 14 | //$fp = fsockopen($rdf['www.guidonia.org'], 80, $errno, $errstr, 15);
|
---|
| 15 | if ($fp) {
|
---|
| 16 |
|
---|
| 17 | if (!empty($rdf['query']))$rdf['query'] = "?" . $rdf['query'];
|
---|
| 18 |
|
---|
| 19 | fputs($fp, "GET " . $rdf['path'] . $rdf['query'] . " HTTP/1.0\r\n");
|
---|
| 20 | fputs($fp, "HOST: " . $rdf['host'] . "\r\n\r\n");
|
---|
| 21 | fputs($fp,"Content-type: application/x-www-form- urlencoded\r\n");
|
---|
| 22 | fputs($fp, "User-Agent: $agent \r\n");
|
---|
| 23 | fputs($fp, "Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3\r\n");
|
---|
| 24 | fputs($fp, "Accept-Encoding: gzip,deflate\r\n");
|
---|
| 25 | fputs($fp, "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n");
|
---|
| 26 | fputs($fp, "Keep-Alive: 300\r\n");
|
---|
| 27 |
|
---|
| 28 | $string = "";
|
---|
| 29 | while(!feof($fp)) {
|
---|
| 30 | $pagetext = fgets($fp,300);
|
---|
| 31 | $string .= chop($pagetext);
|
---|
| 32 | }
|
---|
| 33 | fputs($fp,"Connection: close\r\n\r\n");
|
---|
| 34 | fclose($fp);
|
---|
| 35 | $items = explode("</item>",$string);
|
---|
| 36 | $content = "<font class=\"content\">";
|
---|
| 37 | for ($i=0;$i<5;$i++) {
|
---|
| 38 | $link = preg_replace("#.*<link>#","",$items[$i]);
|
---|
| 39 | $link = preg_replace("#</link>.*#","",$link);
|
---|
| 40 | $title2 = preg_replace("#.*<title>#","",$items[$i]);
|
---|
| 41 | $title2 = preg_replace("#</title>.*#","",$title2);
|
---|
| 42 | $title2 = stripslashes($title2);
|
---|
| 43 | if (empty($items[$i]) AND $cont != 1) {
|
---|
| 44 | $content = "";
|
---|
| 45 |
|
---|
| 46 | return;
|
---|
| 47 | } else {
|
---|
| 48 |
|
---|
| 49 | if (strcmp($link,$title2) AND !empty($items[$i])) {
|
---|
| 50 | $cont = 1;
|
---|
| 51 | $content .= "<p><strong><a href=\"$link\" target=\"new\">$title2</a></strong></p>\n";
|
---|
| 52 | }
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 |
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 |
|
---|
| 61 |
|
---|
| 62 | echo '<div>'.$content.'
|
---|
| 63 | <p style="text-align:center"><br/>[ <a href="'.$sito.'" target="_blank">Vai al sito Elettorale </a> ]</p></div>';
|
---|
| 64 | ?>
|
---|