source: trunk/client/modules/Elezioni/blocchi/myrss.php@ 354

Last change on this file since 354 was 273, checked in by roby, 5 years ago
File size: 2.5 KB
Line 
1<?php
2/************************************************************************/
3/* Eleonline - Raccolta e diffusione dei dati elettorali */
4/* by Roberto Gigli & Luciano Apolito */
5/* http://www.eleonline.it */
6/* info@eleonline.it luciano@aniene.net rgigli@libero.it */
7/************************************************************************/
8/* widget legge rss */
9
10
11
12# configurazione
13$url="http://www.guidonia.org/nuovo/comune/rss.php?siteid=24"; // link feed
14$sito="http://www.guidonia.org/portale/comune/index.php?siteid=24"; // link sito
15$titolo="News Ufficio Elettorale"; // titolo del blocco
16$footer_rss="Vai al sito Elettorale "; // descrizione fine blocco per il link
17# fine configurazione
18
19
20echo "<h5>$titolo</h5>"; // titolo
21$agent= $_SERVER['HTTP_USER_AGENT'];
22
23
24
25 $rdf = parse_url($url);
26 $fp = fsockopen($rdf['host'], 80, $errno, $errstr, 15);
27 //$fp = fsockopen($rdf['www.guidonia.org'], 80, $errno, $errstr, 15);
28 if ($fp) {
29
30 if (!empty($rdf['query']))$rdf['query'] = "?" . $rdf['query'];
31
32 fputs($fp, "GET " . $rdf['path'] . $rdf['query'] . " HTTP/1.0\r\n");
33 fputs($fp, "HOST: " . $rdf['host'] . "\r\n\r\n");
34 fputs($fp,"Content-type: application/x-www-form- urlencoded\r\n");
35 fputs($fp, "User-Agent: $agent \r\n");
36fputs($fp, "Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3\r\n");
37fputs($fp, "Accept-Encoding: gzip,deflate\r\n");
38fputs($fp, "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n");
39fputs($fp, "Keep-Alive: 300\r\n");
40$cont=0;
41 $string = "";
42 while(!feof($fp)) {
43 $pagetext = fgets($fp,300);
44 $string .= chop($pagetext);
45 }
46 fputs($fp,"Connection: close\r\n\r\n");
47 fclose($fp);
48 $items = explode("</item>",$string);
49 $content = "<font class=\"content\">";
50 for ($i=0;$i<5;$i++) {
51 $link = preg_replace("#.*<link>#","",$items[$i]);
52 $link = preg_replace("#</link>.*#","",$link);
53 $title2 = preg_replace("#.*<title>#","",$items[$i]);
54 $title2 = preg_replace("#</title>.*#","",$title2);
55 $title2 = stripslashes($title2);
56 if (empty($items[$i]) AND $cont != 1) {
57 $content = "";
58
59 return;
60 } else {
61
62 if (strcmp($link,$title2) AND !empty($items[$i])) {
63 $cont = 1;
64 $content .= "<p><strong><a href=\"$link\" target=\"new\">$title2</a></strong></p>\n";
65 }
66 }
67
68
69 }
70
71 }
72
73
74
75echo '<div>'.$content.'
76<p style="text-align:center"><br/>[ <a href="'.$sito.'" target="_blank">'.$footer_rss.' </a> ]</p></div>';
77?>
Note: See TracBrowser for help on using the repository browser.