-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexternal.php
209 lines (178 loc) · 5.74 KB
/
external.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?php
/*
Viscacha - A bulletin board solution for easily managing your content
Copyright (C) 2004-2009 The Viscacha Project
Author: Matthias Mohr (et al.)
Publisher: The Viscacha Project, http://www.viscacha.org
Start Date: May 22, 2004
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
error_reporting(E_ALL);
define('SCRIPTNAME', 'external');
define('VISCACHA_CORE', '1');
define('TEMPSHOWLOG', 1);
include ("data/config.inc.php");
include ("classes/function.viscacha_frontend.php");
$my->p = $slog->Permissions();
$my->pb = $slog->GlobalPermissions();
if ($config['syndication'] == 0) {
errorLogin();
}
// Get the correct formatted timzone
$posneg = substr($my->timezone, 0, 1);
if ($posneg != '+' && $posneg != '-') {
$posneg = '+';
$mtz = $my->timezone;
}
else {
$mtz = substr($my->timezone, 1);
}
if (strpos($mtz, '.') === false) {
$tz3 = '00';
$tz2 = leading_zero($mtz,2);
}
else {
$tz = explode('.',$mtz);
$tz3 = $tz[1]/100*60;
$tz2 = leading_zero($tz[1],2);
}
define("TIME_ZONE", $posneg.$tz2.':'.$tz3);
// Include the Feedcreator class
include("classes/class.feedcreator.php");
BBProfile($bbcode);
($code = $plugins->load('external_start')) ? eval($code) : null;
$action = strtoupper($_GET['action']);
$data = file('data/feedcreator.inc.php');
foreach ($data as $feed) {
$feed = explode("|", $feed);
$feed = array_map('trim', $feed);
$f[$feed[0]] = array(
'class' => $feed[0],
'file' => $feed[1],
'name' => $feed[2],
'active' => $feed[3],
'header' => $feed[4]
);
}
if (!isset($f[$action])) {
$t = current($f);
$action = $t['class'];
}
$format = $f[$action];
if ($format['header'] == 1) {
$h = false;
}
else {
$h = true;
}
// Header of feeds
$rss = new UniversalFeedCreator();
$rss->encoding = 'UTF-8';
$rss->setDir("feeds/topics_");
$rss->useCached($action, '', $h);
$rss->title = $config['fname'];
$rss->description = $config['fdesc'];
$rss->link = $config['furl']."/forum.php";
$rss->language = $lang->phrase('rss_language');
$rss->ttl = $config['rssttl'];
$rss->copyright = $config['fname'];
$rss->lastBuildDate = time();
$rss->editor = $config['fname'];
if ($config['syndication_insert_email'] == 1) {
$rss->editorEmail = $config['forenmail'];
}
else {
$rss->editorEmail = '';
}
// Dirty permission hack I
$my->p = $slog->Permissions(0, GROUP_GUEST, false);
$my->pb = $slog->GlobalPermissions();
$sqllimit = 15;
$sqlwhere = "r.tstart = '1' AND f.invisible != '2' AND f.active_topic = '1' AND f.opt != 'pw' ".$slog->sqlinboards('t.board');
$sqlorder = "t.date DESC";
$sqljoin = $sqlfields = '';
// Dirty permission hack II
$my->p = $slog->Permissions();
$my->pb = $slog->GlobalPermissions();
($code = $plugins->load('external_query')) ? eval($code) : null;
// Get the last 15 topics
$result = $db->query("
SELECT r.dowords, r.comment, r.guest, f.name as forum, u.name as uname, u.mail as umail, r.name as gname, r.email as gmail, t.topic, t.id, t.board, t.date, t.status {$sqlfields}
FROM {$db->pre}topics AS t LEFT JOIN {$db->pre}replies AS r ON t.id = r.topic_id
LEFT JOIN {$db->pre}user AS u ON r.name = u.id AND r.guest = '0'
LEFT JOIN {$db->pre}forums AS f ON t.board = f.id
{$sqljoin}
WHERE {$sqlwhere}
ORDER BY {$sqlorder}
LIMIT {$sqllimit}
");
// Loop through them if the site is not offline
if ($config['foffline'] == 0) {
while ($row = $db->fetch_object($result)) {
// Formats the data
if ($row->guest == 0) {
$row->email = $row->umail;
$row->name = $row->uname;
}
else {
$row->email = $row->gmail;
$row->name = $row->gname;
}
$bbcode->setSmileys(0);
if ($config['wordstatus'] == 0) {
$row->dowords = 0;
}
$bbcode->setReplace($row->dowords);
if ($row->status == 2) {
$row->comment = $bbcode->ReplaceTextOnce($row->comment, 'moved');
}
$row->comment = $bbcode->parse($row->comment, 'plain');
$row->comment = str_replace("\n", ' ', $row->comment);
if (strxlen($row->comment) > $config['rsschars']) {
$row->comment = FeedCreator::iTrunc($row->comment, $config['rsschars']);
}
$item = new FeedItem();
$item->title = $row->topic;
$item->link = $config['furl']."/showtopic.php?id=".$row->id;
$item->source = $config['furl']."/showforum.php?id=".$row->board;
$item->description = $row->comment;
$item->date = $row->date;
$item->author = $row->name;
if ($config['syndication_insert_email'] == 1) {
$item->authorEmail = $row->email;
}
else {
$item->authorEmail = '';
}
$item->pubDate = $row->date;
$item->category = $row->forum;
($code = $plugins->load('external_item_prepared')) ? eval($code) : null;
$rss->addItem($item);
}
}
else {
$item = new FeedItem();
$item->title = $lang->phrase('offline_head_ext');
$item->link = $config['furl'];
$item->description = $lang->phrase('offline_body_ext');
$item->date = time();
$item->author = $config['fname'];
($code = $plugins->load('external_offline')) ? eval($code) : null;
$rss->addItem($item);
}
($code = $plugins->load('external_prepared')) ? eval($code) : null;
$rss->saveFeed($format['class'], '', $h);
($code = $plugins->load('external_end')) ? eval($code) : null;
$phpdoc->Out();
$db->close();
?>