#!/usr/bin/perl
require './commonlib.pl';
use strict;
use CGI;
my $customerroot = '../customerdata';
my $custregfile = '../regstration/customerdefine.csv';
my $success;
my $firstday;
my $status;
#主催会社の基本情報ファイル
my $adminbasicfile = '../regstration/admincompanyinfo.csv';
my $cgi=CGI::new();
my $customerid = $cgi->param('customerid');
my $trigger = $cgi->param('trigger');
my $no = $cgi->param('no');
my $url = $cgi->param('url');
my $mode = $cgi->param('mode');
if ((length($customerid) == 0) || (length($trigger) == 0) || (length($no) == 0) || (length($url) == 0) || (length($mode) == 0)){
error("
イリーガルアクセスは許可できません
");
exit;
}
#主催会社データの読込み
my @adminbasicdata = ();
($success, @adminbasicdata) = adminbasicread($adminbasicfile);
if ($success == 0){ exit; }
my ($acompany,$ahpname,$arepresent,$azipcode,$aaddress,$aaddress1,$atel,$afax,$aemailaddr,$ataxratio,$aurlroot,$aclickint,$aurlstopped) = datasparate($adminbasicdata[0]);
($success,$status,$firstday) = getcustinfo($customerid);
if ($success == 0){ exit; }
if ($status ne '有効'){ dummyhtml($aurlstopped); exit; }
my $customerdir = "$customerroot/$customerid";
dircheck($customerdir);
my $clicktime = GetTimestr();
my ($year,$month,$day) = getyearmonthday($clicktime);
if ($day < $firstday){
$month = $month - 1;
if ($month < 1){ $month = $month + 12; $year = $year - 1; }
}
my $customerlogfile = sprintf("%s/%04d_%02d_%slog.csv",$customerdir,$year,$month,$customerid);
my $remoteaddr = $ENV{'REMOTE_ADDR'};
my $remoteport = $ENV{'REMOTE_PORT'};
my $affiliatedata = joinlist($clicktime,$remoteaddr,$remoteport,$customerid,$trigger,$no,$url);
$success = affiliatelogaddwrite($customerlogfile,$affiliatedata);
if ($success == 0){ exit; }
if ($mode == 1){
flashhtml($url);
} elsif ($mode == 0){
dummyhtml($url);
}
#End of Main
#顧客の指定した月初日を入手
sub getcustinfo(){
my ($customerid1) = @_;
my ($customerid,$status,$starttime,$comptime,$password,$company,$division,$responsible,$zipcode,$address,$address1,$phoneno,$faxno,$emailaddr,$firstday,$unitfee,$payperiod,$note);
my ($success,@custregdata) = custregdataread($custregfile);
if ($success == 0){ return 0; }
my $match = 0;
for (my $i = 0; $i<@custregdata; $i++){
($customerid,$status,$starttime,$comptime,$password,$company,$division,$responsible,$zipcode,$address,$address1,$phoneno,$faxno,$emailaddr,$firstday,$unitfee,$payperiod,$note) = datasparate($custregdata[$i]);
if ($customerid eq $customerid1){ $match = 1; last; }
}
if ($match == 0){ error("
指定された顧客IDの顧客情報は存在しません。"); return (0,"",0); }
return (1,$status,$firstday);
}
sub getyearmonthday(){
my ($timestr) = @_;
my @k = split(/ /, $timestr, 3);
my @k1 = split(/\//, $k[0], 4);
return @k1;
}
sub flashhtml(){
my ($linkurl) = @_;
print "Content-type: text/html\n\n";
print <<"EOM";