#!/usr/bin/perl --
print "Content-type: text/vnd.wap.wml\n\n";
require "../cgi-bin/board/Date.pl";
require "../cgi-bin/database/today.cgi";
require "../cgi-bin/database/db.cfg";
$today = $showthedateback;
$yesterday = $showthedateback - 1;
$database=$UNshowsdb;
if ($input{'database'} eq ''){$db=$database;} else{$db=$input{'database'};}
@members=("Hans|Guitars/Vocals|Faber","Brian|Guitars|Carreon","Robert|Bass|Marks","Donnie|Vocals|Marhefka","Frank|Drums|Herrera");
@galleries=("20040626|Gathering Of The Bestial Legion Fest|52");
################################################################################################	
print <<mobiledoc;
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<head>
<meta http-equiv="Cache-Control" content="max-age=0"/>
</head>

<card id="card1" title="Unsanctified">
	<do type="accept" label="Answer"><go href="#\$(name)"/></do>
	<p>
	<img alt="Unsanctified" src="http://www.unsanctified.com/mobile/U.wbmp"/><br/>
	<small>UNSANCTIFIED.COM</small><br/>
	<select name="name">
	  <option value="Shows">Upcoming Shows</option>
	  <option value="News">Recent News</option>
	  <option value="Band">Band/Contact</option>
	  <option value="Photos">Photos</option>
	  <option value="Email">E-Mailing List</option>
	  <option value="Browser">BrowserID</option>
	  <!--<option value="Kings">NHL West Stdg</option>-->
	</select>
	</p>
</card>
mobiledoc
################################################################################################	
################################################################################################	
print <<mobiledoc;
<card id="Browser" title="\$(name)">
	<p>
		<img alt="Unsanctified" src="http://www.unsanctified.com/mobile/U.wbmp"/><br/>
	<anchor>MENU
<go href="#card1"/> 
</anchor><br/>
mobiledoc
$TEST = $ENV{'HTTP_USER_AGENT'};
print "\t$TEST\n";
print "
	</p>
</card>";
################################################################################################
################################################################################################	
print <<mobiledoc;
<card id="Shows" title="\$(name)">
mobiledoc
open (ORGDB,"<$database");
flock("$database",2);	
@ODB=<ORGDB>;
flock("$database",8);	
close (ORGDB);
$hff=0;
foreach $rec (@ODB){
	chomp($rec);
($id,$date,$datesort,$showtime,$venueurl,$venue,$venuemap,$addr,$city,$state,$zip,$miscadd,$phone,$title,$titleurl,$b1n,$b1cxl,$b1u,$b2n,$b2cxl,$b2u,$b3n,$b3cxl,$b3u,$b4n,$b4cxl,$b4u,$b5n,$b5cxl,$b5u,$b6n,$b6cxl,$b6u,$bandcomm,$price,$pricecomm,$tickets)=split(/\|/,$rec);
if ($date ne 'date'){
		if ($datesort gt $yesterday){
$hff=$hff+1;
}
}
}
if ($hff ge '1') {
print"		<do type=\"accept\" label=\"Answer\"><go href=\"#\$(showdt)\"/></do>";
}
print <<mobiledoc;
	<p>
	<img alt="Unsanctified" src="http://www.unsanctified.com/mobile/U.wbmp"/>
mobiledoc
open (ORGDB,"<$database");
flock("$database",2);	
@ODB=<ORGDB>;
flock("$database",8);	
close (ORGDB);
$hff=0;
foreach $rec (@ODB){
	chomp($rec);
($id,$date,$datesort,$showtime,$venueurl,$venue,$venuemap,$addr,$city,$state,$zip,$miscadd,$phone,$title,$titleurl,$b1n,$b1cxl,$b1u,$b2n,$b2cxl,$b2u,$b3n,$b3cxl,$b3u,$b4n,$b4cxl,$b4u,$b5n,$b5cxl,$b5u,$b6n,$b6cxl,$b6u,$bandcomm,$price,$pricecomm,$tickets)=split(/\|/,$rec);
if ($date ne 'date'){
		if ($datesort gt $yesterday){
$hff=$hff+1;
if ($hff eq '1') {
print"	<select name=\"showdt\">
	 	<option value=\"card1\">MENU</option>";
}
	print "<option value=\"t$datesort\">$date ($city,$state)</option>";	
}
}
}
if ($hff ge '1') {
print "</select>";
}
if ($hff eq "0") {
print "
	<anchor>MENU
<go href=\"#card1\"/> 
</anchor>
<br/>No shows scheduled at this time";
}
print "
	</p>
</card>
";
################################################################################################
################################################################################################
print <<mobiledoc;
<card id="News" title="\$(name)">
	<p>
	<img alt="Unsanctified" src="http://www.unsanctified.com/mobile/U.wbmp"/><br/>
	<anchor>MENU
<go href="#card1"/> 
</anchor><br/>
		<small>
		&gt;&gt; 2-14-04 The new EP is now available for purchase on www.unsanctified.com for $5.99
	<br/>		
		&gt;&gt; 12-30-04 The new EP titled Demons Of My Own Making is temporarily delayed until mid-January due to circumstances out of our control.
	<br/>		
		&gt;&gt; 11-15-04 The new EP titled Demons Of My Own Making will be released soon. It is ultra-brutal.
	<br/>
		&gt;&gt; 7-23-04 Unsanctified will begin re recording on August 22.
	<br/>
		&gt;&gt; 6-3-04 Unsanctified will return to the studio soon to retrack &quot;Banished From Heaven &quot;.
	<br/>
		&gt;&gt; 5-25-04 Frank Herrera has replaced Sean Harding on Drums.
	</small>
	</p>
</card>
mobiledoc
################################################################################################
################################################################################################
print <<mobiledoc;
<card id="Band" title="\$(name)">
	<do type="accept" label="Answer2"><go href="#\$(bmember)"/></do>
	<p>
	<img alt="Unsanctified" src="http://www.unsanctified.com/mobile/Group.wbmp"/>
	<select name="bmember">
	  <option value="card1">MENU</option>
mobiledoc
foreach $member (@members) {
($nm,$inst,$fn)=split(/\|/,$member);
print "	  <option value=\"$nm\">$nm $fn</option>";
}
print "
	</select>
	</p>
</card>";
foreach $member (@members) {
($nm,$inst,$fn)=split(/\|/,$member);
print <<mobiledoc
<card id="$nm" title="\$(bmember)">
<p>
	<anchor>MENU
<go href="#card1"/> 
</anchor><br/>
<anchor>BAND
<go href="#Band"/> 
</anchor><br/>
	\$(bmember) - $inst<br/>
<img alt="\$(bmember) - photo" src="http://www.unsanctified.com/mobile/\$(bmember).wbmp"/><br/>
\$(bmember)\@unsanctified.com<br/>
</p>
</card>
mobiledoc
}
################################################################################################
################################################################################################
open (ORGDB,"<$database");
flock("$database",2);	
@ODB=<ORGDB>;
flock("$database",8);	
close (ORGDB);
foreach $rec (@ODB){
	chomp($rec);
($id,$date,$datesort,$showtime,$venueurl,$venue,$venuemap,$addr,$city,$state,$zip,$miscadd,$phone,$title,$titleurl,$b1n,$b1cxl,$b1u,$b2n,$b2cxl,$b2u,$b3n,$b3cxl,$b3u,$b4n,$b4cxl,$b4u,$b5n,$b5cxl,$b5u,$b6n,$b6cxl,$b6u,$bandcomm,$price,$pricecomm,$tickets)=split(/\|/,$rec);
if ($date ne 'date'){
		if ($datesort gt $yesterday){
print <<hans;
<card id="t$datesort" title="$datesort">
	<p>
	<img alt="Unsanctified" src="http://www.unsanctified.com/mobile/U.wbmp"/>
	
	<anchor>MENU
<go href="#card1"/> 
</anchor><br/>
<anchor>SHOWS
<go href="#Shows"/> 
</anchor><br/>

$date<br/>
$showtime<br/>
hans
$venue =~ s/&acute;//gi;
print "$venue<br/>";
if ($addr ne "") { print"$addr<br/>";}
print"$city,$state $zip<br/>";
if ($phone ne "") { print"$phone<br/>";}
print"$title<br/><br/>
UNSANCTIFIED w/<br/>";
if ($b1n ne "") { print"$b1n<br/>";}
if ($b2n ne "") { print"$b2n<br/>";}
if ($b3n ne "") { print"$b3n<br/>";}
if ($b4n ne "") { print"$b4n<br/>";}
if ($b5n ne "") { print"$b5n<br/>";}
if ($b6n ne "") { print"$b6n<br/>";}
$bandcomm=~s/<center>//gi;
$bandcomm=~s/<b>//gi;
$bandcomm=~s/<\/center>//gi;
$bandcomm=~s/<\/b>//gi;
$bandcomm=~s/<br>/<br\/>/gi;
if ($b6n ne "") { print " and more<br/>";}
#print "PRICE: $price<br/>
print "</p>
</card>";
}
}
}
################################################################################################
################################################################################################
print <<mobiledoc;
<card id="Photos" title="Photos">
	<do type="accept" label="Answer2"><go href="\$(gal).wml"/></do>
	<p>
	<img alt="Unsanctified" src="http://www.unsanctified.com/mobile/U.wbmp"/>
	<select name="gal">
	  <option value="mobile">MENU</option>
mobiledoc
foreach $gallery (@galleries) {
($fn,$desc,$ct)=split(/\|/,$gallery);
print "	  <option value=\"$fn\">$fn $desc</option>";
}
print "
	</select>
	</p>
</card>
";
################################################################################################
################################################################################################
#foreach $gallery (@galleries) {
#($fn,$desc,$ct)=split(/\|/,$gallery);
#print <<mobiledoc;
#<card id="g-$fn" title="\$(gal)">
#<p>
#<anchor>MENU
#<go href="#card1"/> 
#</anchor><br/>
#<anchor>GALLERIES
#<go href="#Photos"/> 
#</anchor><br/>
#<br/>
#mobiledoc
#<!--<img alt="\$(bmember) - photo" src="http://www.unsanctified.com/mobile/\$(bmember).wbmp"/><br/>-->
#$j=1;
#while ($j<=$ct) {
#print "<anchor>$j
#<go href=\"#g-$fn-$j\"/> 
#</anchor><br/>";
#$j++;
#}
#print"
#Coming Soon
#<br/>
#</p>
#</card>
#";
#}
################################################################################################
################################################################################################
print <<mobiledoc;
<card id="Email" title="Email">
	<p>
	<img alt="Unsanctified" src="http://www.unsanctified.com/mobile/U.wbmp"/><br/>
	<anchor>MENU
<go href="#card1"/> 
</anchor><br/>
	** Coming Soon **
</p>
</card>
mobiledoc
################################################################################################
################################################################################################	
# HERE IS THE NHL WEST PIOINTS STANDINGS
sub lakings {
use LWP::Simple;
$STATS=get("http://www.nhl.com/onthefly/standings/20032004/print_conference_standings.html");
$STATS =~ s/\r\n//gi;
$STATS =~ s/\015//gi;
$STATS =~ s/\n//gi;
$startpos=0;
$endpos=0;
$startstr="Western Conference";
$endstr="<!-- end showByConference -->";
$STATlen=length($STATS);
$slen=length($startstr);
$elen=length($endstr);
for ($i=0;$i<$STATlen;$i++) {
if (substr($STATS,$i,$slen) eq $startstr) {
$startpos=$i;
}
}
for ($i=0;$i<$STATlen;$i++) {
if (substr($STATS,$i,length($endstr)) eq $endstr) {
$endpos=$i;
}
}
$newSTR = substr($STATS,$startpos,$endpos-$startpos);
$newSTR =~ s/ class="HEADLINEGRAPH" align="right"//gi;
$newSTR =~ s/ class="HEADLINEGRAPH"//gi;
$newSTR =~ s/ bgcolor="#E1D8B9"//gi;
$newSTR =~ s/ bgcolor="#ffffff"//gi;
$x="Western Conference";
$newSTR =~ s/
$x//gi;
$newSTR =~ s/Western Conference//gi;
$newSTR =~ s/class="HEADLINEGRAPH"//gi;
$newSTR =~ s/ bgcolor="#AFB088"//gi;
$x="</table>";
$newSTR =~ s/$x//gi;
$x="<p>";
$newSTR =~ s/$x//gi;
$x="</p>";
$newSTR =~ s/$x//gi;
$x="</b>";
$newSTR =~ s/$x//gi;
$x="</font>";
$newSTR =~ s/$x//gi;
$newSTR =~ s/>/>
/gi;
$newSTR =~ s/<td>
/<td>/gi;
$newSTR =~ s/<\/td>
<\/tr>//;
$newSTR =~ s/.html">
/.html">/gi;
$newSTR =~ s/<\/a>
\*<\/td>/<\/a>\*<\/td>/gi;
$newSTR =~ s/<\/a>
<\/td>/<\/a><\/td>/gi;
$newSTR =~ s/<tr>
<td colspan="13" height="1">/HANS/gi;
$newSTR =~ s/HANS
<\/td>/HANS/gi;
$newSTR =~ s/HANS
<\/tr>//gi;
$newSTR =~ s/<\/a>//gi;
$newSTR =~ s/<a href="\/lineups\/team\/det\/index.html">//gi;
$newSTR =~ s/<a href="\/lineups\/team\/col\/index.html">//gi;
$newSTR =~ s/<a href="\/lineups\/team\/san\/index.html">//gi;
$newSTR =~ s/<a href="\/lineups\/team\/van\/index.html">//gi;
$newSTR =~ s/<a href="\/lineups\/team\/dal\/index.html">//gi;
$newSTR =~ s/<a href="\/lineups\/team\/cal\/index.html">//gi;
$newSTR =~ s/<a href="\/lineups\/team\/stl\/index.html">//gi;
$newSTR =~ s/<a href="\/lineups\/team\/nas\/index.html">//gi;
$newSTR =~ s/<a href="\/lineups\/team\/los\/index.html">//gi;
$newSTR =~ s/<a href="\/lineups\/team\/edm\/index.html">//gi;
$newSTR =~ s/<a href="\/lineups\/team\/min\/index.html">//gi;
$newSTR =~ s/<a href="\/lineups\/team\/ana\/index.html">//gi;
$newSTR =~ s/<a href="\/lineups\/team\/pho\/index.html">//gi;
$newSTR =~ s/<a href="\/lineups\/team\/chi\/index.html">//gi;
$newSTR =~ s/<a href="\/lineups\/team\/clb\/index.html">//gi;
chomp $newSTR;
open (DATABASE,">temp.stats");
flock("temp.stats",2);
print DATABASE "$newSTR";
flock("temp.stats",8);
close (DATABASE);
open (ORGDB,"<temp.stats");
flock("temp.stats",2);	
@ODB=<ORGDB>;
flock("temp.stats",8);	
close (ORGDB);
$r=0;
print <<mobiledoc;
<card id="Kings" title="NHL West Stdgs">
	<p>
<anchor>MENU
<go href="#card1"/> 
</anchor><br/>
mobiledoc
print "<table columns=\"3\">\n";
foreach $rec (@ODB){
chomp($rec);
	if ($rec ne "") {
	$r++;
		if ($r>=1) {
			if (($r eq "1")|| ($r eq "2")  || ($r eq "3") || ($r eq "9") || ($r eq "15") ) {
if ($r eq "3") {
			#print substr($rec,1,7).substr($rec,4,7).substr($rec,length($rec)-6,length($rec));
			$h=$rec;
			$h =~ s/<td>//gi;
			$h =~ s/<\/td>//gi;
						if (substr($h,length($h)-1,1) eq "*") {
			$j="*";
			} else {
			$j="";
			}
			$h = substr($h,0,5);
			#if (substr($,length($rec)-1,length($rec)) eq "*") {
			#$h=$h."*";
			#}
			print "<td>$h$j</td>";
} else {
			print $rec."";
}
			}
		}
		if ($r eq "15") {
		$r=0;
		}
	}
}
print "</table>";
print "</p>";
print "</card>";
}
################################################################################################	
################################################################################################
print "</wml>";