This repository has been archived by the owner on Jul 31, 2020. It is now read-only.
/
planet.php
124 lines (99 loc) · 3.23 KB
/
planet.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/**
*
* qPlanet.: Another free RSS planet.
* @author Jorge Fuertes - jorge@jorgefuertes.com
* @version 2.0
* @package qPlanet
*
**/
# Setup class autoload:
function __autoload($class)
{
require_once("include/".$class.".class.php");
}
# General configuration, options and feeds:
$Config = new Config;
$Config->SetOpts();
error_reporting($Config->getOpt('options', 'reporting'));
# Simplepie: 3rd-party rss processing:
#require_once('3rd-party/simplepie/SimplePieAutoloader.php');
#include_once('3rd-party/simplepie/idn/idna_convert.class.php');
# RSS init:
$rss = new Rss;
# Get the posts:
Debug::info("Getting the posts");
$posts = $rss->getPosts($Config->getFeeds());
# Write mode output openning:
Debug::info("Generating HTML output at ".OUTDIR."/".OUTFILE);
Debug::info("Generating RSS 2.0 output at ".OUTDIR."/rss20.xml");
$fOutput = new Output;
#
# Output files generation:
#
# Header:
Debug::info("Headers");
$fOutput->write(File::ReadAndParse('html/header.html'));
$fOutput->writeRss(File::ReadAndParse('xml/rss20_head.xml'));
# Javascript:
Debug::info("HTML: Javascript functions");
$fOutput->write(File::Read('html/functions.js'));
# Body:
Debug::info("Bodies");
# The posts:
Debug::info("The posts");
$fOutput->write('<div id="posts">');
# Posts loop:
foreach($posts as $post)
{
Debug::info(" Output (".$post['author'].") ".$post['title']);
$fOutput->write(File::ReadAndParse('html/post.html', $post));
$fOutput->writeRss(File::ReadAndParse('xml/rss20_item.xml', $post));
}
$fOutput->write('</div>');
Debug::info("Posts end");
# ----------------
# -----------------------------------------------------
# Sidebar construction and OPML generation:
# -----------------------------------------------------
Debug::info("HTML: Sidebar");
$fOutput->writeOpml(File::ReadAndParse('xml/opml_head.xml'));
$blog_list = "<ul>\n";
$previous = array();
foreach($posts as $post)
{
if(array_search($post['autor_link'], $previous) === false)
{
$previous[] = $post['autor_link'];
$blog_list .= "<li><a href='".$post['autor_link']."'><img src='/gfx/feed-icon-10x10.png' "
."alt='RSS feed' /></a>"
."<a href='".$post['blog_url']."'>".$post['blog_title']."</a></li>\n";
$fOutput->writeOpml(File::ReadAndParse('xml/opml_item.xml', $post));
}
}
$fOutput->writeOpml(File::ReadAndParse('xml/opml_foot.xml'));
$blog_list .= "</ul>\n";
define('BLOG_LIST', $blog_list); unset($blog_list);
# Other similar planets:
$planets = $Config->getPlanetas();
$planet_list = "<ul>\n";
foreach($planets as $planet)
{
$planet_list .= "<li><a href='".$planet['rss']."'><img src='/gfx/feed-icon-10x10.png' alt='Feed RSS' /></a>"
."<a href='".$planet['url']."'>".$planet['name']."</a></li>\n";
}
$planet_list .= "</ul>\n";
define('PLANET_LIST', $planet_list); unset($planet_list);
# Sidebar generation:
$fOutput->write(File::ReadAndParse('html/sidebar.html'));
# Extended content initially hidden:
$fOutput->write('<script type="text/javascript">$(".content").hide();</script>');
# Statistics:
Debug::info("HTML: Statistics code");
$fOutput->write(File::ReadAndParse('html/stats.html'));
# Closure:
Debug::info("Closures");
$fOutput->write(File::ReadAndParse('html/footer.html'));
$fOutput->writeRss(File::Read('xml/rss20_foot.xml'));
Debug::info("EOF");
?>