Added a SUMMARY command to schedulator, which allows you to show a
[wvapps.git] / planit / index.php
bloba5cb7115562362d3b586f8c942493feb2b437e37
1 <!--
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2004 Net Integration Technologies, Inc.
5 * Dave's cheesy PlaNit thing
7 */
8 -->
10 <?php
11 include( 'config.inc.php' );
13 require_once( 'rss_fetch.inc' );
15 function grab_feeds()
17 global $feeds;
18 global $allrss;
19 global $allitems;
20 global $cutoffs;
21 global $articles_per_person;
22 global $maximum_days;
23 global $hack;
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 )
30 continue;
32 $url1 = $feed['url'];
33 $url2 = $feed['url2'];
34 unset( $urls );
35 $urls[count( $urls )] = $url1;
36 if( $feed['url2'] )
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'];
45 if( $tmp == '' ) {
46 list( $stuff, $junk ) = split( 'Z', $item['created'] );
47 list( $d, $t, $junk ) = split( 'T', $stuff );
48 $tmp = "$d $t GMT";
50 $timestamp = strtotime( $tmp );
51 if( time()-$timestamp > 3600*24*$maximum_days )
52 continue;
54 $allitems[count( $allitems )] =
55 array( url => $url,
56 timestamp => $timestamp,
57 itemkey => $itemkey,
58 userid => $userid,
59 name => $name );
64 // sort the allitems list in reverse chronological order
65 function itemcmp( $a, $b )
67 return $b['timestamp'] - $a['timestamp'];
69 usort( $allitems, 'itemcmp' );
70 reset( $allitems );
73 function do_articles()
75 global $allrss;
76 global $allitems;
77 global $cutoffs;
78 global $feeds;
79 global $tmpcontent;
81 $fd = @fopen( $tmpcontent, 'w' );
82 if( $fd === false ) {
83 print( "PlaNit is broken right now.\n" );
84 return;
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 ) );
104 do {
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>' );
111 if( $item['title'] )
112 $title = $item['title'];
113 else
114 $title = gmdate( 'F j, Y', $timestamp );
116 unset( $mugshot );
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'];
125 if( $link == '' )
126 $link = $item['link_'];
128 fwrite( $fd,
129 '<div class="header">' .
130 '<b><a href="' . $rss->channel['link'] . '">' .
131 $feeds[$userid]['name'] . '</a></b>: <a href="' .
132 $link . '">' . $title .
133 "</a></div>\n" .
134 '<div class="text">' );
135 if( $mugshot )
136 fwrite( $fd,
137 "<img class=\"mugshot\" src=\"$mugshot\" border=0 " .
138 'alt="">' );
139 fwrite( $fd,
140 $description .
141 '<br><font size=-1><i><a class="greylink" href="' .
142 $link . '">' .
143 "($userid at " . gmdate( 'F j, Y H:i', $timestamp ) .
144 ' UTC)</a></i></font></div><br>' );
147 fclose( $fd );
150 function do_people()
152 global $feeds;
153 global $allrss;
154 global $tmpsidebox;
156 $fd = @fopen( $tmpsidebox, 'w' );
157 if( $fd === false ) {
158 print( "PlaNit is broken right now.\n" );
159 return;
162 foreach( $feeds as $userid => $feed ) {
163 $url1 = $feed['url'];
164 $url2 = $feed['url2'];
165 unset( $urls );
166 $urls[count( $urls )] = $url1;
167 if( $feed['url2'] )
168 $urls[count( $urls )] = $url2;
170 $tmp=0;
171 foreach( $urls as $url ) {
172 if( $tmp )
173 $uid = "$userid again";
174 else
175 $uid = $userid;
176 $tmp++;
177 $page = $allrss[$url]->channel['link'];
178 fwrite( $fd,
179 "<b><a href=\"$page\">$uid</a></b> (<a " .
180 "href=\"$url\">xml</a>)<br>\n" );
184 fclose( $fd );
187 function do_spiel()
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 ' .
194 'subset of us.' );
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">' );
208 $func();
209 print( "</div><br>\n" );
213 <html>
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">
219 <!--
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 }
230 BODY {
231 font-family: lucida, helvetica, sans-serif;
232 font-size: 12pt;
235 TD, P, UL {
236 font-family: lucida, helvetica, sans-serif;
237 font-size: 12pt;
240 TT {
241 font-family: fixed, lucidatypewriter, courier new;
242 font-size: 12pt;
245 #sidebar {
246 position: absolute;
247 right: 0px;
248 width: 200px;
249 margin-left: 0px;
250 margin-right: 10px;
251 background-color: #ffffff;
254 #sidebar div.header {
255 width: 188px;
256 background-color: #333366;
257 color: #ffffff;
258 text-align: center;
259 padding: 7px 6px 7px 6px;
262 #sidebar div.text {
263 width: 188px;
264 background-color: #bbbbff;
265 padding: 6px;
268 #main {
269 margin-left: 10px;
270 margin-right: 220;
271 background-color: #ffffff;
274 #main div.header {
275 background-color: #ddddff;
276 border: 1px solid #9999cc;
277 padding: 6px;
280 #main div.text {
281 margin: 20px 40px 20px 40px;
282 min-height: 100px;
285 #main img.mugshot {
286 float: right;
287 margin: 0px 0px 15px 15px;
290 #header {
291 position: absolute;
292 left: 0px;
293 top: 0px;
294 margin: 0px 0px 0px 0px;
295 height: 64px;
296 width: 100%;
297 background-image: url("planitback.gif");
298 background-repeat: repeat-x;
301 #middle {
302 position: absolute;
303 top: 96px;
304 left: 0px;
305 margin: 0px 0px 0px 0px;
306 padding: 0px 0px 0px 0px;
309 #footer {
310 /*position: relative;*/
311 left: 0px;
312 bottom: 0px;
313 margin: 0px 0px 0px 0px;
314 padding: 0px 0px 0px 0px;
315 height: 64px;
316 width: 100%;
318 background-image: url("planitback2.gif");
319 background-repeat: repeat-x;
321 text-align: center;
325 </style>
327 <head><title>PlaNit</title></head>
329 <body>
331 <div id="header">
332 <img src="planit.gif" alt="PlaNit">
333 </div>
335 <div id="middle">
336 <div id="sidebar">
337 <?php
338 sidebox( 'PlaNit', 'do_spiel' );
339 sidebox( 'People', 'do_staticpeople' );
341 </div>
343 <div id="main">
344 <?php
345 if( $beslow == 1 ) {
346 grab_feeds();
347 do_articles();
348 do_people();
349 copy( $tmpcontent, $staticcontent );
350 copy( $tmpsidebox, $staticsidebox );
352 readfile( $staticcontent );
354 </div>
356 <div id="footer">
357 <?php
358 print( "PlaNit Copyright (C) 2004 <a href=\"mailto:$email\">$admin" .
359 '</a><br>' );
361 if( !$beslow ) {
362 $fd = @fopen( $logfile, 'a' );
363 if( $fd === false ) {
364 print( "Email Dave and tell him to fix his program!\n" );
365 } else {
366 fwrite( $fd, strftime( '%Y%m%d %H:%M' ) . " -- pla -- " .
367 "$REMOTE_ADDR -- $HTTP_REFERER\n" );
368 fclose( $fd );
372 </div>
373 </div>
375 </body>
376 </html>