#!/usr/bin/perl # index.cgi created by Pip Stuart to provide a CGI # interface to generated Poker data. Please e-mail me if you # need the scripts to generate the card images. # This code is distributed under the GNU General Public License (version 2). use CGI ":standard"; use LWP::UserAgent; my $this = 'http://Your.URL.Org/cgi-bin/pokr/index.cgi'; my $imgp = 'http://Your.URL.Org/img/'; my $oddp = '/home/your_path/public_html/pokr/OddsTabl.htm'; my $meth = $ENV{'REQUEST_METHOD'}; my $quer = $ENV{'QUERY_STRING'}; my $nqur = $quer; my $tqur; my $uage = new LWP::UserAgent; $uage->agent("AgentName/0.1 " . $uage->agent); my $oppo = param('oppo') || 9; my $hol0 = param('hol0') || ''; my $hol1 = param('hol1') || ''; my $shrt = ''; my @rnkz = qw( A K Q J T 9 8 7 6 5 4 3 2 ); my @sutz = qw( s h d c ); my $runs = ''; my $wins = ''; # prep tests && params $nqur = "oppo=$oppo" unless($nqur =~ /^oppo=/); if($hol0) { if($hol1) { $shrt = substr($hol0, 0, 1) . substr($hol1, 0, 1); my $ndx0 = 0; my $ndx1 = 0; for(my $indx = 0; $indx < @rnkz; $indx++) { $ndx0 = $indx if(substr($hol0, 0, 1) eq $rnkz[$indx]); $ndx1 = $indx if(substr($hol1, 0, 1) eq $rnkz[$indx]); } $shrt = reverse($shrt) if($ndx0 > $ndx1); $shrt .= 's' if(substr($hol0, 1, 1) eq substr($hol1, 1, 1)); open(ODDP, "<$oddp"); while() { if(s/^$shrt<\/th>//) { my $topp = $oppo; s/^(\d+)<\/td>(\d+\.\d+)%<\/td>// while($topp-- > 1); #AA71385.83%255977.06%575769.55%857163.21%881958.28%634253.74%344447.50%188338.50%152531.34% if(/^(\d+)<\/td>(\d+\.\d+)%<\/td>/) { $runs = $1; $wins = $2; } } } close(ODDP); $nqur = "oppo=$oppo"; # RESET } else { $nqur .= '&hol1='; } } else { $nqur .= '&hol0='; } print "Content-type: text/html\n\n"; $tqur = $quer; $tqur =~ s/((oppo=)\d+)?/oppo=1/; print qq| Pick Your HoldEm Hole Odds
\n|; } print qq| \n|; foreach my $suit (@sutz) { print qq| \n|; foreach my $rank (@rnkz) { print qq| \n|; } print qq| \n|; } print qq|
|; for(my $indx = 9; $indx >= 2; $indx--) { $tqur = $quer; $tqur =~ s/((oppo=)\d+)?/oppo=$indx/; print qq|
|; if((!$hol0 || $hol0 ne "$rank$suit") && (!$hol1 || $hol1 ne "$rank$suit")) { if($hol0 && $hol1) { print qq||; } else { print qq||; } } print qq|
Hole \n|; if($hol0) { $tqur = "oppo=$oppo"; print qq| \n|; } else { print qq| \n|; } if($hol1) { $tqur = $quer; $tqur =~ s/&hol1=..$//; print qq| \n|; } else { print qq| \n|; } print qq|
\n|; # print qq| \n|; # print qq|
Opponents: $oppo     Runs: $runs
Hole: $shrt     Wins: $wins%
\n|; open(ODDP, "<$oddp"); while() { print $_ if(/Total Runs:/); } close(ODDP); print qq| |;