summary refs log tree commit diff stats
path: root/rss.php
blob: c9e866f6a83c3496023ae5b8da2b95c51f8a2e89 (plain) (blame)
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<?php
/*
       444444444  
      4::::::::4  
     4:::::::::4  
    4::::44::::4  
   4::::4 4::::4   Four Island
  4::::4  4::::4  
 4::::4   4::::4   Written and maintained by Starla Insigna
4::::444444::::444
4::::::::::::::::4  rss.php
4444444444:::::444
          4::::4   Please do not use, reproduce or steal the
          4::::4   contents of this file without explicit
          4::::4   permission from Hatkirby.
        44::::::44
        4::::::::4
        4444444444
*/

require('headerproc.php');

include('../security/config.php');
include('includes/db.php');
include('includes/bbcode.php');
include('includes/phpsvnclient.php');

header('Content-type: application/rss+xml');

echo('<?xml version="1.0" encoding="UTF-8"?>');

?>
<rss version="2.0">
	<channel>
		<title>Four Island<?php
if (isset($_GET['mode']))
{
	switch ($_GET['mode'])
	{
		case 'blog':
			if (isset($_GET['blog']))
			{
				switch ($_GET['blog'])
				{
					case 'author':
?> Blog Posts by <?php
						echo($_GET['author']);
						break;
					case 'tag':
?> Blog Posts tagged with <?php
						echo($_GET['tag']);
						break;
				}
			} else {
?> Blog Posts<?php
			}
			break;
		case 'quotes':
?> Quotes<?php
			break;
		case 'poll':
?> Polls<?php
			break;
		case 'projects':
?> Projects<?php
			break;
		case 'comments':
?> Comments<?php
			break;
	}
}
?></title>

		<description><?php
if (isset($_GET['mode']))
{
	switch ($_GET['mode'])
	{
		case 'blog':
			if (isset($_GET['blog']))
			{
				switch ($_GET['blog'])
				{
					case 'author':
?>An archive of all Four Island blog posts written by <?php
						echo($_GET['author']);
						break;
					case 'tag':
?>An archive of all Four Island blog posts tagged with <?php
						echo($_GET['tag']);
						break;
				}
			} else {
?>An archive of all Four Island blog posts<?php
			}
			break;
		case 'quotes':
?>An archive of all Four Island quotes<?php
			break;
		case 'poll':
?>An archive of all of the Four Island POTWs<?php
			break;
		case 'projects':
?>An archive of all of the Four Island Project checkins<?php
			break;
		case 'comments':
?>An archive of all of the comments people have left on Four Island<?php
			break;
	}
} else {
?>All the wonderfour going-ons on Four Island<?php
}
?></description>

		<language>en</language>

<?php

$i=0;

if (!isset($_GET['mode']) || ($_GET['mode'] == 'blog'))
{
	if ($_GET['blog'] == 'author')
	{
		$getposts = "SELECT * FROM updates WHERE author = \"" . $_GET['author'] . "\" ORDER BY id DESC";
	} else if ($_GET['blog'] == 'tag')
	{
		$getposts = "SELECT * FROM updates WHERE tag1 = \"" . $_GET['tag'] . "\" OR tag2 = \"" . $_GET['tag'] . "\" OR tag3 = \"" . $_GET['tag'] . "\" ORDER BY id DESC";
	} else if (!isset($_GET['blog'])) {
		$getposts = "SELECT * FROM updates ORDER BY id DESC";
	}
	$getposts2 = mysql_query($getposts);

//	$si = $i;

	while (($items[$i] = mysql_fetch_array($getposts2)))
	{
		$items[$i]['sortDate'] = strtotime($items[$i]['pubDate']);
		$items[$i]['itemType'] = 'post';
		$i++;
	}
}

if (!isset($_GET['mode']) || ($_GET['mode'] == 'quotes'))
{
	$getquotes = "SELECT * FROM rash_quotes";
	$getquotes2 = mysql_query($getquotes);

//	$si = $i;

	while (($items[$i] = mysql_fetch_array($getquotes2)))
	{
		$items[$i]['sortDate'] = $items[$i]['date'];
		$items[$i]['itemType'] = 'quote';
		$i++;
	}
}

if ($_GET['mode'] == 'poll')
{
	$getpolls = "SELECT * FROM polloftheweek";
	$getpolls2 = mysql_query($getpolls);
	while (($items[$i] = mysql_fetch_array($getpolls2)) && ($i < ($si+10)))
	{
		$items[$i]['sortDate'] = strtotime($items[$i]['week']);
		$items[$i]['itemType'] = 'poll';
		$i++;
	}
}

if (!isset($_GET['mode']) || ($_GET['mode'] == 'projects'))
{
	$svn = new phpSVNclient();
	ob_start();
	$projs = explode("  ",system('dir /var/svn'));
	ob_end_clean();

//	$si = $i;

	foreach ($projs as $name)
	{
		$svn->setRespository('http://svn.fourisland.com/' . $name);
//		$svn->setAuth('hatkirby','popstartwo506');
		$logs = $svn->getFileLogs('');

		$k=0;
		while (($items[$i] = $logs[$k]))
		{
			$items[$i]['sortDate'] = strtotime($items[$i]['date']);
			$items[$i]['itemType'] = 'project';
			$items[$i]['project'] = $name;
			$i++;
			$k++;
		}
	}
}

if (!isset($_GET['mode']) || ($_GET['mode'] == 'comments'))
{
	$getcomments = "SELECT * FROM comments ORDER BY id DESC LIMIT 0,10";
	$getcomments2 = mysql_query($getcomments);
	while ($items[$i] = mysql_fetch_array($getcomments2))
	{
		$items[$i]['sortDate'] = strtotime($items[$i]['posttime']);
		$items[$i]['itemType'] = 'comment';

		$page_id = $items[$i]['page_id'];
		$comType = substr($page_id,0,strpos($page_id,'-'));
		$comID = substr($page_id,strpos($page_id,'-')+1);

		switch ($comType)
		{
			case 'updates':
				$getpost = "SELECT * FROM updates WHERE id = " . $comID;
				$getpost2 = mysql_query($getpost);
				$getpost3 = mysql_fetch_array($getpost2);

				$items[$i]['title'] = $getpost3['title'];
				$items[$i]['url'] = 'blog/' . $getpost3['slug'] . '/';
				break;
			case 'poll':
				$getpoll = "SELECT * FROM polloftheweek WHERE id = " . $comID;
				$getpoll2 = mysql_query($getpoll);
				$getpoll3 = mysql_fetch_array($getpoll2);

				$items[$i]['title'] = $getpoll3['question'];
				$items[$i]['url'] = 'poll/' . $getpoll3['id'] . '.php';
				break;
			case 'quote':
				$getquote = "SELECT * FROM rash_quotes WHERE id = " . $comID;
				$getquote2 = mysql_query($getquote);
				$getquote3 = mysql_fetch_array($getquote2);

				$items[$i]['title'] = '#' . $getquote3['id'];
				$items[$i]['url'] = 'quotes/' . $getquote3['id'] . '.php';
				break;
		}
		$i++;
	}
}

function sortItems($a, $b)
{
	if ($a['sortDate'] < $b['sortDate'])
	{
		return 1;
	} else if ($a['sortDate'] == $b['sortDate'])
	{
		return 0;
	} else if ($a['sortDate'] > $b['sortDate'])
	{
		return -1;
	}
}

uasort($items,"sortItems");

$j=0;
foreach ($items as $key => $value)
{
	switch ($value['itemType'])
	{
		case 'post':
?>
		<item>
			<title><?php echo($value['title']); ?></title>

			<link>http://www.fourisland.com/blog/<?php echo($value['slug']); ?>/</link>

			<description><?php echo(stripslashes(htmlentities(parseBBCode($value['text'])))); ?></description>

			<pubDate><?php echo(date('D, d M Y H:i:s O',$value['sortDate'])); ?></pubDate>
		</item>
<?php
			break;
		case 'quote':
?>
		<item>
			<title>Quote #<?php echo($value['id']); ?></title>

			<link>http://www.fourisland.com/quotes/<?php echo(urlencode($value['id'])); ?>.php</link>

			<description><?php echo(htmlentities(nl2br($value['quote']))); ?></description>

			<pubDate><?php echo(date('D, d M Y H:i:s O',$value['sortDate'])); ?></pubDate>
		</item>
<?php
			break;
		case 'poll':
			break;
		case 'project':
			$value['comment'] = str_replace('[','',str_replace(']','',$value['comment']));
			if (strpos($value['comment'],"\n") !== FALSE)
			{
				$title = htmlentities(substr($value['comment'],0,strpos($value['comment'],"\n")));
			} else {
				$title = htmlentities($value['comment']);
			}
?>
		<item>
			<title><?php echo($value['project']); ?> r<?php echo($value['version']); ?> - <?php echo($title); ?></title>

			<link>http://www.fourisland.com/projects/<?php echo($value['project']); ?>/changeset/<?php echo(urlencode($value['version'])); ?></link>

			<description><?php echo(htmlentities(nl2br($value['comment']))); ?></description>

			<pubDate><?php echo(date('D, d M Y H:i:s O',$value['sortDate'])); ?></pubDate>
		</item>
<?php
			break;
		case 'comment':
?>
		<item>
			<title>Comment on <?php echo($value['title']); ?> by <?php echo($value['username']); ?></title>

			<link>http://www.fourisland.com/comments/<?php echo($value['id']); ?>/</link>

			<description><?php echo(stripslashes(htmlentities(parseBBCode($value['comment'])))); ?></description>

			<pubDate><?php echo(date('D, d M Y H:i:s O',$value['sortDate'])); ?></pubDate>
		</item>
<?php
			break;
	}
	$j++;
	if ($j==9)
	{
		break;
	}
}

?>
	</channel>
</rss>