summaryrefslogtreecommitdiff
path: root/cgi-bin/servernews.plx
blob: d7ae9ce7cbd2c83a24ed337f3bb2adf7a29703a8 (plain)
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
#!c:/perl/bin/perl

use CGI;
use strict;
use Globals;
use Globals qw(%ALLPLATTERS);
use Globals qw($bgcolour);

my $QUERY         = CGI::new();
my $exclude       = $QUERY->cookie("exclude");
my $emptytime     = 0;
my %servers;

# Generate server exclusion form
#
my $server; my $totartists; my $tottracks;
foreach $server ( keys %ALLPLATTERS )
{
    chomp $server;


    my $newsfile = '../inventory/'.$server.".news";
    my $thistime = $emptytime++;
    my $thisnews = '<p><a href="search.plx?searchFor=artist&inv='.$server.'&output=artistlist"><b><i>'.$server.'</i></b></a><br>';
    my ($tracks,$artists) = getPlatterStats($server);
    $totartists+=$artists; $tottracks+=$tracks;
    $thisnews .= '<small>'.$tracks.' tracks by '.$artists.' artists.<br>';
    # open the news file
    if (open NEWS, $newsfile) {
        $thistime = <NEWS>; chomp $thistime;
        $thisnews .= 'News last updated: '.localtime($thistime).' CET</small><br>';
        while ( <NEWS> ) { $thisnews .= $_; }
        close NEWS;
    }
    else {
    # add to 'hidden' servers list
        $thisnews .= 'No news found.</small><br>';
    }
    # check the box if it's a selected server
    my $checked = 'checked';
    if ($exclude =~ /$server/) { $checked = ''; }


    # write the selection box
    $thisnews.= '<br clear=left><small><input type="checkbox" name="'.$server.'" onClick="setServers()" '.$checked.'>Include <b><i>'.$server.'</i></b> in your selected servers.</small>';

    $servers{ $thistime } = $thisnews;

}

my $serverlist = '<h5>Today the platter contains '.$tottracks.' tracks by '.$totartists.' artists</h5>';

foreach (sort {$b <=> $a} keys %servers) {
    $serverlist.= $servers{$_};
}

# get the template
#
my $WEBPAGE = openTemplate("servernews");

# Put in what we know
#
$WEBPAGE =~ s/%SERVERS%/$serverlist/g;
$WEBPAGE =~ s/%BGCOLOUR%/$bgcolour/g;

# Display the finished Web page
#
print $WEBPAGE;

# Fin
#
exit;