-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbackend.php
99 lines (99 loc) · 3.92 KB
/
backend.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
header('Content-Type: text/xml');
header("Content-Type: application/rss+xml");
include 'include/config.php';
function convertir($cadena)
{ $cadena= stripslashes($cadena);
$buscar = array('<br>', '<p>', '</p>', '<br />',' ','@','"');
$reemplazar = array(' ');
$cadena = str_replace($buscar, $reemplazar, $cadena);
$buscar = array('á', 'é', 'í', 'ó','ú');
$reemplazar = array('a', 'e', 'i', 'o','u');
$cadena = str_replace($buscar, $reemplazar, $cadena);
$buscar = array('á', 'é', 'í', 'ó', 'ú');
$cadena_arreglada = str_replace($buscar, $reemplazar, $cadena);
return ($cadena_arreglada);
}
function RSS($url,$imagen,$leer_cant_feed,$largo_lectura)
{ global $entries;
$noticias = simplexml_load_file($url);
$largo=$largo_lectura;
$lee=$leer_cant_feed;
$ciclo = 1;
foreach ($noticias as $noticia) {
foreach($noticia as $reg){
if(!empty($reg->title) && $ciclo<$lee&& !empty($reg->description) && !empty($reg->pubDate)){
$pubdate = $reg->pubDate;
$title = trim(utf8_decode(convertir(strip_tags($reg->title))));
$link = $reg->link;
$description = trim(utf8_decode(convertir(substr(strip_tags($reg->description),0,$largo)))).'...';
$timestamp = strtotime(substr($reg->pubDate,0,25));
$entries[$timestamp]['pubdate'] = $timestamp;
$entries[$timestamp]['title'] = $title;
$entries[$timestamp]['link'] = $link;
$entries[$timestamp]['image'] = $imagen;
$entries[$timestamp]['description'] = $description;
$ciclo++;
}}}
krsort($entries);
return $entries;
}
foreach ($feeds as $imagen => $url)
{RSS($url,$imagen,$leer_cant_feed,$largo_lectura);}
$urlplanet = substr($urlplanet,0,strlen($urlplanet)-1);
$ahora = time();
$fecha = date("r",$ahora);
$year = date("Y",$ahora);
$icon = $urlplanet.'/themes/'.$theme.'/img/rss.png';
$xml = '';
$xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\r";
$xml .= '<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/">'."\n\r";
$xml .= "<channel>\n\r
<title>$nombre_sitio</title>\r
<link>$urlplanet</link>\r
<description>$descripcion</description>\r
<language>$lenguaje</language>\r
<copyright>Copyleft 2014 $year, $nombre_sitio</copyright>\r
<pubDate>$fecha</pubDate>\r
<lastBuildDate>$fecha</lastBuildDate>\r
<docs>$urlplanet</docs>\r
<generator>Script ViSeRProject http://viserproject.com</generator>\n\r
<webMaster>$emailinfo ($nombre_sitio)</webMaster>\r
<managingEditor>$emailinfo ($nombre_sitio)</managingEditor>\r
<image>\r
<title>$nombre_sitio</title>\r
<url>$icon</url>\r
<link>$urlplanet</link>\r
<description>$descripcion</description>\r
</image>\r
<atom:link href=\"$urlplanet/backend.xml\" rel=\"self\" type=\"application/rss+xml\" />
<ttl>600</ttl>\n\r";
foreach ($entries as $timestamp => $entry) {
$urltitle = urlencode($entry['title']);
$fecha = date("r",$entry['pubdate']);
$entry['title'] = trim(strip_tags($entry['title']));
$entry['description'] = trim(strip_tags($entry['description']));
$url_nota = "$urlplanet/index.php?r=".base64_encode("$entry[link]|$urltitle");
$xml .= "\n\r<item>\r
<title>$entry[title]</title>\r
<link>$url_nota</link>\r
<guid>$url_nota</guid>\r
<pubDate>$fecha</pubDate>\r
<description>\r
<![CDATA[<img src=\"$urlplanet/img/avatar/$entry[image].png\" alt=\"$entry[image]\" align=\"left\" style=\"float:left; width:95px; height:95px; margin-right:13px; margin-bottom:12px;\">$entry[description]]]></description>\r
</item>\r\n";
}
$xml .= "</channel>\n\r
</rss>\n\r";
$xml = trim($xml);
$filexml = fopen('backend.xml', 'w+');
fwrite($filexml, $xml);
fclose($filexml);
#include 'backend.xml';
?>