summaryrefslogtreecommitdiff
path: root/cgi-bin/front.plx
diff options
context:
space:
mode:
Diffstat (limited to 'cgi-bin/front.plx')
-rw-r--r--cgi-bin/front.plx109
1 files changed, 109 insertions, 0 deletions
diff --git a/cgi-bin/front.plx b/cgi-bin/front.plx
new file mode 100644
index 0000000..6c64cc0
--- /dev/null
+++ b/cgi-bin/front.plx
@@ -0,0 +1,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;