2 * Worldvisions Weaver Software
:
3 * Copyright (C
) 1997-2004 Net Integration Technologies
, Inc
.
5 * Dave
's cheesy PlaNit thing
11 include( 'config
.inc
.php
' );
13 require_once( 'rss_fetch
.inc
' );
21 global $articles_per_person;
25 // grab all the feeds, and stick them in an array, indexed by URL.
26 // also make a new array containing the URL, timestamp, and item key,
27 // for each item in all the feeds.
28 foreach( $feeds as $userid => $feed ) {
29 if( $feed['hack
'] && !$hack )
33 $url2 = $feed['url2
'];
35 $urls[count( $urls )] = $url1;
37 $urls[count( $urls )] = $url2;
39 foreach( $urls as $url ) {
40 $allrss[$url] = fetch_rss( $url );
41 $cutoffs[$url] = $articles_per_person;
42 foreach( $allrss[$url]->items as $itemkey => $item ) {
43 // is this item too old?
44 $tmp = $item['pubdate
'];
46 list( $stuff, $junk ) = split( 'Z
', $item['created
'] );
47 list( $d, $t, $junk ) = split( 'T
', $stuff );
50 $timestamp = strtotime( $tmp );
51 if( time()-$timestamp > 3600*24*$maximum_days )
54 $allitems[count( $allitems )] =
56 timestamp => $timestamp,
64 // sort the allitems list in reverse chronological order
65 function itemcmp( $a, $b )
67 return $b['timestamp
'] - $a['timestamp
'];
69 usort( $allitems, 'itemcmp
' );
73 function do_articles()
81 $fd = @fopen( $tmpcontent, 'w
' );
83 print( "PlaNit is broken right now.\n" );
87 foreach( $allitems as $iteminfo ) {
88 $rss = $allrss[$iteminfo['url
']];
89 $timestamp = $iteminfo['timestamp
'];
90 $item = $rss->items[$iteminfo['itemkey
']];
91 $userid = $iteminfo['userid
'];
93 if( $cutoffs[$iteminfo['url
']] ) {
94 $cutoffs[$iteminfo['url
']]--;
96 // no longer sanitize() here, that's done in magpie before caching
97 $description = $item['description'];
98 if( $description == '' )
99 $description = $item['atom_content'];
101 while( substr( $description, 0, 4 ) == '<br>' )
102 $description = trim( substr( $description, 4 ) );
105 $len = strlen( $description );
106 $br_end = substr( $description, $len-4 );
107 if( $br_end == '<br>' )
108 $description = trim( substr( $description, 0, $len-4 ) );
109 } while( $br_end == '<br>' );
112 $title = $item['title'];
114 $title = gmdate( 'F j, Y', $timestamp );
117 if( file_exists( "$userid.jpg" ) )
118 $mugshot = "$userid.jpg";
119 else if( file_exists( "$userid.png" ) )
120 $mugshot = "$userid.png";
121 else if( file_exists( "$userid.gif" ) )
122 $mugshot = "$userid.gif";
124 $link = $item['link'];
126 $link = $item['link_'];
129 '<div class="header">' .
130 '<b><a href="' . $rss->channel
['link'] . '">' .
131 $feeds[$userid]['name'] . '</a></b>: <a href="' .
132 $link . '">' . $title .
134 '<div class="text">' );
137 "<img class=\"mugshot\" src=\"$mugshot\" border=0 " .
141 '<br><font size=-1><i><a class="greylink" href="' .
143 "($userid at " . gmdate( 'F j, Y H:i', $timestamp ) .
144 ' UTC)</a></i></font></div><br>' );
156 $fd = @fopen
( $tmpsidebox, 'w' );
157 if( $fd === false ) {
158 print( "PlaNit is broken right now.\n" );
162 foreach( $feeds as $userid => $feed ) {
163 $url1 = $feed['url'];
164 $url2 = $feed['url2'];
166 $urls[count( $urls )] = $url1;
168 $urls[count( $urls )] = $url2;
171 foreach( $urls as $url ) {
173 $uid = "$userid again";
177 $page = $allrss[$url]->channel
['link'];
179 "<b><a href=\"$page\">$uid</a></b> (<a " .
180 "href=\"$url\">xml</a>)<br>\n" );
189 print( 'PlaNit is a gluing-together of weblogs from people who work at ' .
190 '<a href="http://nit.ca/">NITI</a>. Some people talk about our ' .
191 '<a href="http://open.nit.ca/">open-source</a> stuff, some ' .
192 'people talk about their other projects, and some people are ' .
193 'just crazy. But this is us. Or at least a dysfunctional ' .
197 function do_staticpeople()
199 global $staticsidebox;
201 readfile( $staticsidebox );
204 function sidebox( $title, $func )
206 print( '<div class="header">' . $title . '</div>' .
207 '<div class="text">' );
209 print( "</div><br>\n" );
215 <meta http
-equiv
="content-type" content
="text/html; charset=UTF-8">
216 <meta name
=Keywords content
="PlaNit pla.nit.ca NITI Net Integration">
218 <style type
="text/css">
220 A
:link
{ text
-decoration
:none
; color
: #0000f0 }
221 A
:visited
{ text
-decoration
:none
; color
: #0000f0 }
222 A
:active
{ text
-decoration
: none
; color
: #0000f0 }
224 A
.greylink
:link
{ text
-decoration
:none
; color
: #aaaaaa }
225 A
.greylink
:visited
{ text
-decoration
:none
; color
: #aaaaaa }
226 A
.greylink
:active
{ text
-decoration
: none
; color
: #0000f0 }
227 A
.greylink
:hover
{ text
-decoration
: none
; color
: #0000f0 }
231 font
-family
: lucida
, helvetica
, sans
-serif
;
236 font
-family
: lucida
, helvetica
, sans
-serif
;
241 font
-family
: fixed
, lucidatypewriter
, courier
new;
251 background
-color
: #ffffff;
254 #sidebar div.header {
256 background
-color
: #333366;
259 padding
: 7px
6px
7px
6px
;
264 background
-color
: #bbbbff;
271 background
-color
: #ffffff;
275 background
-color
: #ddddff;
276 border
: 1px solid
#9999cc;
281 margin
: 20px
40px
20px
40px
;
287 margin
: 0px
0px
15px
15px
;
294 margin
: 0px
0px
0px
0px
;
297 background
-image
: url("planitback.gif");
298 background
-repeat
: repeat
-x
;
305 margin
: 0px
0px
0px
0px
;
306 padding
: 0px
0px
0px
0px
;
310 /*position: relative;*/
313 margin
: 0px
0px
0px
0px
;
314 padding
: 0px
0px
0px
0px
;
318 background-image: url("planitback2.gif");
319 background-repeat: repeat-x;
327 <head
><title
>PlaNit
</title
></head
>
332 <img src
="planit.gif" alt
="PlaNit">
338 sidebox( 'PlaNit', 'do_spiel' );
339 sidebox( 'People', 'do_staticpeople' );
349 copy( $tmpcontent, $staticcontent );
350 copy( $tmpsidebox, $staticsidebox );
352 readfile( $staticcontent );
358 print( "PlaNit Copyright (C) 2004 <a href=\"mailto:$email\">$admin" .
362 $fd = @fopen
( $logfile, 'a' );
363 if( $fd === false ) {
364 print( "Email Dave and tell him to fix his program!\n" );
366 fwrite( $fd, strftime( '%Y%m%d %H:%M' ) . " -- pla -- " .
367 "$REMOTE_ADDR -- $HTTP_REFERER\n" );