#!/usr/local/bin/perl # # get_reports.cgi - Creates Monthly and Daily Rewards report for user viewing # # Belongs in /html/u/rewards # 07/03/01 @(#)get_reports.cgi 1.2 #BEGIN{ # use CGI::Carp qw(carpout); # open (ERROR, "> ./regtypes.log") || die "cant open regtypes.log \n $!"; # carpout(*ERROR); #} use CGI; require '/html/u/rewards/redemptions/programs/CommonSubs.pm'; require '/html/u/rewards/club_lib.pl'; require '/html/u/rewards/clean_info.pl'; require '/html/u/generic/cgilib.pl'; require '/html/u/generic/login_lib.pl'; $system = `uname -n`; chomp($system); $form = new CGI; $report_type = $form->param('report_type'); $report_type = "daily" unless $report_type; $hbpage = "http:/" . $ENV{'SCRIPT_NAME'} . "/$report_type"; @time = localtime(time); ($mday, $mon, $year) = @time[3..5]; $year += 1900; $mday = "0" . $mday if $mday < 10; ++$mon; $mon = "0" . $mon if $mon < 10; $today = $year . $mon . $mday; # Get sportsclub_id $id = $form->param('user'); if (!$id) { %spl = $form->cookie('SportsLine'); $id = $spl{'userid'}; } $id =~ tr/A-Z/a-z/; $id = &clean_info($id); $info = &get_user_info($id); @meminfo = split(':,:', $info); $sportsclub_id = $meminfo[15]; print $form->header(); if (($meminfo[0] ne "0" || !$sportsclub_id || $meminfo[23] eq "0") && $report_type!~/(redemptions|auctions|bid_history)/) { $msg="You must log in with your Rewards User ID to view your Rewards Points Daily Activity.
Click here to sign in.
\n"; &process_http_file("/u/generic/new_ui.htm", \&print_it, 0); exit; } $class[0]='bg3'; $class[1]='bg2'; $class_now=0; # Figure out report type, and set variables accordingly $redemption_month = ''; #used only by the redemptions report if ($report_type=~/daily/) { $table_header = "DAILY ACTIVITY"; $date_type="DATE"; $next_report = "monthly"; $next_name = "Account History"; $next_next_report = "bid"; $next_next_name = "Auction Bid"; } elsif ($report_type=~/redemptions/) { $table_header = "PAST REWARD WINNERS"; $date_type="DATE"; $next_report="monthly"; $next_name = "Account History"; $next_next_report = "bid"; $next_next_name = "Auction Bid"; $date_return = `date '+%Y-%m'`; #if month is passed in, set it to the month being reported on #otherwise use the current month if ($form->param('month')){ $redemption_month = $form->param('month'); $redemption_month =~ /(\d\d\d\d)(\d\d)/; $YEAR = $1; $MONTH = $2; } else { ($YEAR, $MONTH) = split (/-/,$date_return); $redemption_month = "$YEAR$MONTH"; } } elsif ($report_type eq "bid") { # Auction bidding report $table_header = "AUCTION BID REPORT"; $next_report = "daily"; $next_name = "Daily Activity"; $next_next_report="monthly"; $next_next_name = "Account History"; } elsif ($report_type eq "bid_history") { # Auction bidding report $table_header = "AUCTION BID HISTORY"; $next_report = "auctions"; $next_name = "Active Auctions"; $next_next_report="monthly"; $next_next_name = "Account History"; $auction_id = $form->param("auction_id"); $auction_name = $form->param("auction_name"); } else { $table_header = "ACCOUNT HISTORY"; $date_type="MONTH"; $next_report="daily"; $next_name = "Daily Activity"; $next_next_report = "bid"; $next_next_name = "Auction Bid"; } $sportsclub_id = "na" unless $sportsclub_id; $full_name = "$meminfo[5] $meminfo[6]"; $rewards_inc_dir = "/html/u/includes/rewards"; $left_nav = `cat $rewards_inc_dir/ln_about.htm`; $header_free = `cat $rewards_inc_dir/hdr_a.htm`; $header_plus = `cat $rewards_inc_dir/hdr_plus.htm`; $report_type = "curr_auctions" if ($report_type eq "auctions"); $report_type = "history" if ($report_type eq "bid_history"); if ($report_type eq "history") { @report_return = `/html/u/rewards/rewards_report $auction_id $report_type $redemption_month`; } else { @report_return = `/html/u/rewards/rewards_report $sportsclub_id $report_type $redemption_month`; } if ($report_type=~/redemptions/) { $infile = "/html/u/rewards/redemption_report.htm"; foreach $element (@report_return) { chomp($element); @elements = split ':,:', $element; $status = $elements[0]; if ($status ne "0") { print "We're sorry, there have been processing errors in getting your points. Please check back later for your point report"; exit; } $date = $elements[1]; $points = add_commas($elements[2]); $type = $elements[3]; $name = "$elements[4]. $elements[5]"; $line = $line . "" . "$date" . "$name" . "$type" . "$points" . "\n"; $class_now = ($class_now+1) % 2; } } elsif ($report_type =~ /bid/) { # Auction bid report $infile = "/html/u/rewards/bid_report.htm"; $old_auct_class_now = 0; foreach $element (@report_return) { chomp($element); @elements = split ':,:', $element; $status = $elements[0]; if ($status ne "0") { print "We're sorry, there have been processing errors in getting your points. Please check back later fo r your point report"; exit; } $auction = $elements[1]; $your_high_bid = add_commas($elements[2]); $last_bid_date = $elements[3]; $auction_code = $elements[4]; $ai_id = $elements[5]; $auction_end_date = $elements[6]; $high_bidder = $elements[7]; $your_high_bid = "$your_high_bid" if ($high_bidder eq $id); $high_bid = add_commas($elements[8]); @auction_end = split('/', $auction_end_date); $auction_end_reform = "$auction_end[2]$auction_end[0]$auction_end[1]"; if ($today < $auction_end_reform) { $line = $line . "" . "$auction" . "$your_high_bid" . "$high_bid" . "$last_bid_date" . "$auction_end_date" . "\n"; $class_now = ($class_now+1) % 2; } else { # Auction has ended - put under completed $end_line = "" . "$auction" . "$your_high_bid" . "$high_bid" . "$last_bid_date" . "$auction_end_date" . "\n" . $end_line; $old_auct_class_now = ($old_auct_class_now+1) % 2; } } } elsif ($report_type=~/curr_auctions/) { $report_month = $form->param('month'); $report_month = "active" if (!$report_month); # Active auctions $infile = ($report_month eq "active" ? "/html/u/rewards/active_auctions.htm" : "/html/u/rewards/ended_auctions.htm"); $old_class_now = 0; $totals = shift(@report_return); ($total_bids, $total_uniq_bidders) = split(":,:", $totals); foreach $element (@report_return) { chomp($element); ($status, $rcode, $rname, $ai_id, $start, $end, $loc, $evdate, $min, $high, $high_bidder, $daysleft, $user_type, $bid_count, $uniq_bid_count, $active) = split(":,:", $element); if ($status ne "0") { print "We're sorry, there have been processing errors. Please check back later."; exit; } $min = add_commas($min); $high = add_commas($high); $loc = " " if (!$loc); $evdate = " " if (!$evdate); $high_bidder = " " if (!$high_bidder); $tmp_rname = $rname; $tmp_rname =~ s/\s/+/g; $high = "$high"; $hoursleft = int(($daysleft - int($daysleft)) * 24); $minutesleft = int((($daysleft - int($daysleft)) * 24 * 60) % 60); $daysleft = int($daysleft); $timeleft = "$daysleft day" . ($daysleft == 1 ? "" : "s") . "
$hoursleft hour" . ($hoursleft == 1 ? "" : "s") . "
$minutesleft minute" . ($minutesleft == 1 ? "" : "s"); $ed = substr($end, 3); if ($active && $report_month eq "active") { $line = $line . "" . "$rname" . "$loc" . "$evdate" . "$min" . "$high" . "$high_bidder" . "$start" . "$end" . "$timeleft" . "$user_type" . "$bid_count" . "$uniq_bid_count" . "\n"; $class_now = ($class_now+1) % 2; } elsif (!$active && $report_month eq "active") { if (!$end_months{$ed}) { $links .= "Ended auctions for $ed
"; $end_months{$ed} = 1; } } elsif ($report_month ne "active" && !$active && $ed eq $report_month) { $end_line = $end_line . "" . "$rname" . "$loc" . "$evdate" . "$min" . "$high" . "$high_bidder" . "$start" . "$end" . "0 days" . "$user_type" . "$bid_count" . "$uniq_bid_count" . "\n"; $old_class_now = ($old_class_now+1) % 2; } } } elsif ($report_type=~/history/) { $infile = "/html/u/rewards/bid_history.htm"; foreach $element (@report_return) { chomp($element); ($status, $bidder, $points, $bdate) = split(":,:", $element); if ($status ne "0") { print "We're sorry, there have been processing errors. Please check back later."; exit; } $points = add_commas($points); $line = $line . "" . "$bidder" . "$points" . "$bdate" . "\n"; $class_now = ($class_now+1) % 2; } } else{ $infile = "/html/u/rewards/rewards_report.htm"; foreach $element (@report_return) { chomp($element); @elements = split ':,:', $element; $status = $elements[0]; if ($status != 0) { print "We're sorry, there have been processing errors in getting your points. Please check back later for your point report"; exit; } $date = $elements[1]; $points = add_commas($elements[2]); $type = $elements[3]; $activity = $elements[4]; chomp($activity); if ($activity =~/R/) { $points = "-" . $points; } $line = $line . "" . "$type" . "$points" . "$date" . "\n"; $class_now = ($class_now+1) % 2; } } if (!$line && !$end_line) { $line = "We're sorry, but we didn't find any information for this report. If you feel this is incorrect, please let us know."; } $points = `/html/u/rewards/contests/register/get_rwmaster $sportsclub_id`; @points_array = split ':,:', $points; $total_points = add_commas($points_array[5]); $points_on_hold =add_commas($points_array[6]); $active_points = add_commas($points_array[7]); if ($points_on_hold > 0) { $pointsum = "Points Earned $total_points     Points on Hold $points_on_hold    Points Available $active_points"; } $next="

View your $next_name Report or your $next_next_name Report"; $upgrade_msg = ""; ##### # give option for 12 months of redemption report ##### if ($report_type=~/redemptions/){ #$redemption_months = "

\n"; ($YEAR, $MONTH) = split (/-/,$date_return); @months = ("","January","February","March","April","May","June","July","August","September","October","November","December"); chomp($MONTH); for ($count=0,$tmp_month=$MONTH,$tmp_year=$YEAR;$count<12;++$count){ if ($tmp_month < 10) { $tmp_month = "0$tmp_month"; } $redemption_months .= "$months[$tmp_month] $tmp_year Winners
\n"; if ($tmp_month != 1){ --$tmp_month; } else{ $tmp_month = '12'; --$tmp_year; } } } # Open file and do substitutions $| = 1; open (IN, $infile); while() { if (/\#include/) { chomp; &read_inc($_); } elsif (/\#insert/) { if ($membtype eq "club") { $popup = `cat $popup_file`; print "$popup\n"; } } else { s!X_BONUS1_X!$bonus1!; s!X_BONUS2_X!$bonus2!; s!X_REWARD1_X!$reward1!; s!X_REWARD2_X!$reward2!; s!X_PROV1_X!$prov1!; s!X_PROV2_X!$prov2!; s!X_DATE_X!$asof!; s!X_POINTS_X!$active_points!; s!X_PLUS_X!$plus!; s!X_USER_X!$user!; s!X_MILLION_X!$million!; s!X_FULLNAME_X!$full_name!; s!X_TOT_POINTS_X!$total_points!; s!X_POINTS_REDEEMED_X!$total_redeemed!; s!X_POINTS_AVAILABLE_X!$active_points!; s!X_POINTS_ON_HOLD_X!$points_on_hold!; s!X_POINTSUM_X!$pointsum!; s!X_NEXT_X!$next!; s!X_REPORT_X!$line!; s!X_OLD_X!$end_line!; s!X_TABLE_HDR_X!$table_header!; s!X_DATE_DEF_X!$date_type!; s!X_LN_X!$left_nav!; s!X_RM_X!$redemption_months!; s!X_AUCTION_X!$auction_name!; s!X_TOTALBIDS_X!$total_bids!; s!X_TOTALUNIQ_X!$total_uniq_bidders!; s!X_UPGPLUS_X!$upgrade_msg!; s!X_LINKS_X!$links!; s!X_HITBOX_X!$hbpage!; print; } } exit; sub print_it { my $line = $_[0]; if($line=~/\$_/) { while($line=~m/\$_/g) { $var = pos $line; pos $line = $var + 1; $line=~m/[^0-9_A-Za-z]/g; $end_word = pos $line; $word = substr $line, $var, ($end_word-$var-1) ; $line=~s/\$_$word/${$word}/; pos $line = $var-1; } } print $line . "\n"; }