From: Joey Schulze Date: Sun, 4 Nov 2007 00:11:21 +0000 (+0000) Subject: Display current events on the main page automatically X-Git-Url: https://git.infodrom.org/?p=infodrom.org%2Foldenburg.linux.de;a=commitdiff_plain;h=d1c57fa0f7bc0711a303674938023bea7cc13541;ds=sidebyside Display current events on the main page automatically --- diff --git a/src/index.wml b/src/index.wml index 1962651..ab9d34c 100644 --- a/src/index.wml +++ b/src/index.wml @@ -1,6 +1,145 @@ #include #include +

%s

'; + $head .= ''; + $foot = '
WannWasWo
'; + $row = '%s%s%s'; + $pivot = time() + 60*60*24*$max_days; + $now = mktime(0,0,0, date('m'), date('d'), date('Y')); + + if (($dates = fopen($datedb,'r')) !== false) { + $lines = array(); + while (!feof($dates)) { + $line = fgets($dates, 200); + + if (!preg_match("/\|OL\|/", $line)) + continue; + + if (preg_match("/([0-9]{4})-([0-9]{2})-([0-9]{2})\|/", $line, $match)) { + $when = mktime(0,0,0, $match[2], $match[3], $match[1]); + if ($when > $pivot || $when < $now) + continue; + $lines[] = $line; + } + } + + if (count($lines)) { + sort($lines); + echo '
'."\n"; + printf($head."\n", "Kommende Termine in Oldenburg"); + + foreach ($lines as $line) { + if (preg_match("/([0-9]{4})-([0-9]{2})-([0-9]{2})\|([^\|]*)\|OL\|([^\|]*)\|([^\|]*)\|(.*)/", $line, $match)) { + $when = mktime(0,0,0, $match[2], $match[3], $match[1]); + + if ($when == $now) { + $date = 'heute, ' . $match[4].''; + $color = ' bgcolor="#79c2ef"'; + } else { + $date = strftime("%e.%m.%y", $when) . ', ' . $match[4]; + $color = ''; + } + + if (empty($match[7])) + $what = $match[5]; + else + $what = ''.$match[5].''; + + printf($row, $color, $date, $what, $match[6]); + } + } + echo $foot; + } + } +} +function display_news($when, $file) +{ + global $newsdir; + + $head = '

%s

'; + $foot = '
'; + + $date = strftime("%e. %B %Y", $when); + + if (($news = fopen($newsdir.'/'.$file,'r')) !== false) { + $needp = 0; // 0 = init, 1 =

need, 2 = no

needed + + printf($head."\n", $date); + while (!feof($news)) { + $line = fgets($news, 200); + + $line = str_replace ("\\\n", "", $line); + + if ($needp == 0) { + if (substr($_, 0, 3) == "

") { + $needp = 2; + } else { + $needp = 1; + $line = '

'.$line; + } + } + + echo $line; + } + if ($needp == 1) + echo '

'; + echo $foot; + } +} + +function newsbox() +{ + global $max_news; + global $max_age; + global $newsdir; + + setlocale(LC_TIME, "de_DE"); + + $pivot = time() - 60*60*24*$max_age; + $news = array(); + if (is_dir($newsdir)) { + if ($dir = opendir($newsdir)) { + while (($file = readdir($dir)) !== false) { + if (!preg_match("/news-([0-9]{4})-([0-9]{2})-([0-9]{2})\.txt/", $file, $matches)) + continue; + $when = mktime(0,0,0, $matches[2], $matches[3], $matches[1]); + if ($when < $pivot) + continue; + $news[$when] = $file; + } + closedir($dir); + } + } + + if (count($news)) { + echo '
'."\n"; + + krsort($news); + + $cnt = 0; + foreach ($news as $time => $file) { + if ($cnt >= $max_news) + continue; + display_news($time, $file); + $cnt++; + } + } +} +?> +

Die Linux User Group Oldenburg (LUGO) ist eine @@ -10,6 +149,8 @@ Oldenburg trifft sich regelm href="Infos/stammtisch.html">Oldenburger Linux-Stammtisch und unregelmäßig auf weiteren Treffen.

+ +

Außerhalb dieser Treffen wird auf der Mailing-Liste linux-stammtisch (Archiv) über @@ -29,59 +170,7 @@ seine breite Hardwareunterstützung ist es für Privatanwender genauso interessant, wie für den gewerblichen Einsatz.

-<: - - if (opendir (NEWS, "News/")) { - @news = sort (grep (/^news-.*\.txt$/,readdir (NEWS))); - closedir (NEWS); - } - - my ($date_sec,$date_min,$date_hour,$date_mday,$date_mon,$date_year,$date_wday,$date_isdst) - = localtime(time-24*60*60*10); - my $pivot = sprintf ("%04d-%02d-%02d", $date_year+1900, $date_mon+1, $date_mday); - - my @top = (); - foreach my $fname (@news) { - $fname =~ /news-(\d+-\d+-\d+).*/; - push (@top, $fname) if ($1 gt $pivot); - } - - $head = '

%s

'; - $foot = '
'; - @month = ('dummy','Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'); - if ($#top > -1) { - print '
'."\n"; - while (my $news = shift @top) { - $needp = 0; # 0 = init, 1 =

need, 2 = no

needed - $news =~ /news-(\d+)-(\d+)-(\d+).txt/; - $date = sprintf ("%d. %s %04d", $3, $month[$2], $1); - if (open (NEWS, "News/$news")) { - printf $head."\n", $date; - while () { - if (/\\$/) { - s,\\$,,; - chomp; - } - - if ($needp == 0) { - if (substr($_, 0, 3) eq "

") { - $needp = 2; - } else { - $needp = 1; - print "

"; - } - } - - print; - } - close (NEWS); - print "

" if ($needp == 1); - print $foot; - } - } - } - -:> +