summaryrefslogtreecommitdiff
path: root/cgi-bin/front.plx
blob: 6c64cc0b8cdbe55b8948a52fb092e926eea63abb (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!c:/perl/bin/perl

use CGI;
use Globals;
use Globals qw(@CUSTOM);
use Globals qw($VERSION);
use Globals qw($target);
use Globals qw($bgcolour);
use strict;

my $QUERY         = CGI::new();

my $WEBPAGE;      # Source for the webpage will be written here
my $CUSTOM;

# Screw with the $target variable
#
$target =~ s/narrow/iframe/g;

# Gather current user info
#
my $USER;
my $HOST = $QUERY->remote_host();
open USERS, "../data/users.txt" or die;
while( <USERS> )
{
  if ( $_ =~ /$HOST/ )
  {
    chomp;
    my @THISUSER = split (';');
    
    $USER = "<b>$THISUSER[1]</b> ($THISUSER[0]/$THISUSER[2])";
  }
}
close USERS;
if (!defined $USER) { $USER = $HOST }

# fill in custom folders

foreach (@CUSTOM) {
    my $folder = $_;
    if ( length $CUSTOM > 0 )
    {
      $CUSTOM .= ", ";
    }
    
    $CUSTOM.='<a href="artist.plx?name='.makeUnNice($folder).'"  target="'.$target.'"><b>'.$folder."</b></a>";
}

# decide the start page
my $start;
if (defined $QUERY->param('artist')) {
    if (defined $QUERY->param('album')) {
    	$start="artist.plx?name=".makeUnNice($QUERY->param('artist'))."&album=".makeUnNice($QUERY->param('album'));
    }
    else 
    {
    	$start="search.plx?artist=".makeUnNice($QUERY->param('artist'))."&exact=0&searchFor=artist&output=tracks&filter=music,video,shortcut&scope=all";
    }
}
else 
{
    $start = "news.plx";
    $start = "servernews.plx" if ($QUERY->cookie('start') eq 'servernews');
}

# load the headlines

my $NEWS;
if (open(NEWS, '../data/news.txt')) {
    while(<NEWS>) {
        chomp;
        if (/^\[*(.*)\]$/) {
            $NEWS .= ', ' if ($NEWS);
            $NEWS.= '<a href="news.plx#'.$1.'" target="iframe">'.$1.'</a>';
        }
    }
}

# put the iframe in if we're not small screen
my $iframe = '';
if ($target ne '_top') {
	$iframe = '<iframe src="%START%" name="iframe" id="iframe" width="100%" height="100%" frameborder="0"></iframe>';
}

# open the template file
#
$WEBPAGE = openTemplate("front");

# Put in what we know
#
$WEBPAGE =~ s/%IFRAME%/$iframe/g;
$WEBPAGE =~ s/%TARGET%/$target/g;
$WEBPAGE =~ s/%VERSION%/$VERSION/g;
$WEBPAGE =~ s/%USER%/$USER/g;
$WEBPAGE =~ s/%HOST%/$HOST/g;
$WEBPAGE =~ s/%CUSTOM%/$CUSTOM/g;
$WEBPAGE =~ s/%START%/$start/g;
$WEBPAGE =~ s/%HEADLINES%/$NEWS/g;
$WEBPAGE =~ s/%BGCOLOUR%/$bgcolour/g;

# Display the finished Web page
#
print $WEBPAGE;

# Fin
#
close TEMPLATE;
exit;