cvs: phpweb / events.php index.php
| From: | Rasmus Lerdorf | Date: | Wed, 26 Sep 2001 08:02:08 +0000 |
| Subject: | cvs: phpweb / events.php index.php | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-6700@lists.php.net to get a copy of this message | ||
rasmus Wed Sep 26 04:02:08 2001 EDT
Added files:
/phpweb events.php
Modified files:
/phpweb index.php
Log:
Event viewer page
Index: phpweb/index.php
diff -u phpweb/index.php:1.147 phpweb/index.php:1.148
--- phpweb/index.php:1.147 Sat Sep 22 15:34:39 2001
+++ phpweb/index.php Wed Sep 26 04:01:57 2001
@@ -56,12 +56,13 @@
if($fp) {
$cm=0;
while(!feof($fp)) {
- list($d,$m,$y,$url,$desc) = fgetcsv($fp,1024);
+ list($d,$m,$y,$url,$desc) = fgetcsv($fp,4096);
if($cm!=(int)$m) {
if($cm) $RSIDEBAR_DATA.= "<br>\n";
else $RSIDEBAR_DATA.='<h3>Upcoming
Events<br> <a href="http://www.php.net/cal.php?a=1">[add
event]</a></h3>';
$cm = (int)$m;
$RSIDEBAR_DATA .=
"<h4>".strftime('%B',mktime(12,0,0,$cm,$d,$y))."</h4>\n";
+ unset($seen);
}
if(!$seen[$desc]) {
$RSIDEBAR_DATA .= "$d. <a href=\"$url\">$desc</a><br>\n";
Index: phpweb/events.php
+++ phpweb/events.php
<?php
include_once 'prepend.inc';
$RSIDEBAR_DATA = <<<EOF
<br><br>
<a href="http://www.php.net/cal.php">Complete Event
Calendar</a><br><br>
<a href="http://www.php.net/cal.php?a=1">Add an
Event</a><br><br>
EOF;
commonHeader('Upcoming Events');
?>
<h1>Upcoming Events</h1>
<?
$re =
array(1=>'First',2=>'Second',3=>'Third',4=>'Fourth',-1=>'Last',-2=>'2nd
Last',-3=>'3rd Last');
function load_events() {
global $re;
$days = days();
$fp = @fopen("backend/events.csv",'r');
while(!feof($fp)) {
list($d,$m,$y,,$sdesc,$id,$ldesc,$url,$recur,$tipo,$sdato,$edato) = fgetcsv($fp,4096);
if(!$seen[$m][$id]) {
switch($tipo) {
case 1:
$events[] = array($id,$sdato,$sdesc,$ldesc,$url,$d,$m,$y);
break;
case 2:
$events[] = array($id,$sdato.' to '.$edato,$sdesc,$ldesc,$url,$d,$m,$y);
break;
case 3:
list($which,$day) = explode(':',$recur);
$events[] = array($id,'Every '.$re[(int)$which].' '.$days[$day].' of
the month',$sdesc,$ldesc,$url,$d,$m,$y);
break;
}
$seen[$m][$id] = true;
}
}
return $events;
}
/* returns array of Days starting with 1 = Sunday */
function days() {
static $days=NULL;
if(!$days) for($i=1;$i<=7;$i++) {
$days[$i] = strftime('%A',mktime(12,0,0,4,$i,2001));
}
return $days;
}
?>
<?
$events = load_events();
?>
<table cellpadding="5" cellspacing="1" border="0">
<?
$cm = 0;
foreach($events as $event) {
$m = $event[6];
if($cm!=$m) {
$cm = $m;
$month = strftime('%B',mktime(12,0,0,$event[6],$event[5],$event[7]));
echo "</table><h2> $month</h2><table
cellpadding=\"5\" cellspacing=\"1\" border=\"0\">\n";
}
echo '<tr bgcolor=#cccccc><td align=left><b><a
name="'.$event[5].'_'.$event[6].'">'.$month.'</a>
'.$event[5].'</b> <a
href="'.$event[4].'">'.$event[2].'</a>
('.$event[1].")</td></tr>\n";
echo '<tr><td
bgcolor=#e0e0e0> '.$event[3]."</td></tr>\n";
}
?>
</table>
<?php
commonFooter();
?>