4 require(
"XRC_class.prg");
7 $xrc_logfile =
"/tmp/xrc_everyone.log";
8 $xrc_directory =
"/home/httpd/hcupriv/";
9 $xrc_prefix =
"emailrpt";
11 $xrc_filename = $xrc_prefix . date(
"Ym");
14 $cl_args = arguments($argv);
19 if (isset($cl_args[
'limit'])) {
20 $limit = intval($cl_args[
'limit']);
34 if (isset($cl_args[
'debug'])) {
53 $start_time = date(
"m/d/Y h:i:s");
55 $xrc_fh = @fopen($xrc_logfile,
"w");
56 $rpt_fh = @fopen($xrc_directory . $xrc_filename,
"w");
61 fwrite ($xrc_fh,
"** START LOG FILE -- $start_time **\n");
64 fwrite ($xrc_fh,
"Unable to open output file for reporting domain email");
71 $RemoveLogDate = date(
"Ym", mktime(0, 0, 0, date(
"m") - 15, date(
"d"), date(
"Y")));
72 if (is_dir($xrc_directory)) {
73 if ($dir_hndl = opendir($xrc_directory)) {
74 while (($file = readdir($dir_hndl)) !==
false) {
75 if (filetype($xrc_directory . $file) ==
"file" && (substr($file, 0, strlen($xrc_prefix)) == $xrc_prefix)) {
76 if (substr($file, strlen($xrc_prefix)) <= $RemoveLogDate) {
78 unlink($xrc_directory . $file);
93 if ($debug) fwrite ($xrc_fh,
"Command - summarizeEmailClientsOfDistributor");
94 $report_XRC->setCmd(
'summarizeEmailClientsOfDistributor');
95 $report_XRC->SendRequest(
true);
96 if ($debug) fwrite ($xrc_fh,
" -- Completed\n");
98 $DefaultDomainOfferID = 0;
99 if (is_array($report_XRC->values[0])) {
100 foreach ($report_XRC->values[0] as $key=>$value) {
103 $DefaultDomainOfferID = $value[
'offerIDs'][0];
110 $mailsize_100_3yrArchive = 0;
111 $mailsize_100_5yrArchive = 0;
112 $mailsize_100_7yrArchive = 0;
117 if (($loop_cntr >= $limit) && $limit > 0) {
123 $client_XRC->setCmd(
'listUserNamesOfClient');
124 $client_XRC->addArgs(
"I", trim($value[
'clientID']));
125 if ($debug) fwrite ($xrc_fh,
"Command - listUserNamesOfClient:" . trim($value[
'clientID']));
126 $client_XRC->SendRequest(
true);
127 if ($debug) fwrite ($xrc_fh,
" -- Completed\n");
129 if ($client_XRC->is_success) {
132 foreach ($client_XRC->values[0] as $client_key=>$client_value) {
134 $acct_XRC->setCmd(
'getUserOffers');
135 $acct_XRC->addArgs(
"I", trim($value[
'clientID']));
136 $acct_XRC->addArgs(
"S", trim($client_value));
139 $acct_XRC->SendRequest(
true);
141 $CurrentUserOfferID = $acct_XRC->values[0][0];
144 $OfferIDtoUse = ($CurrentUserOfferID > 0 ? $CurrentUserOfferID : $DefaultDomainOfferID);
146 switch ($OfferIDtoUse) {
165 $mailsize_100_3yrArchive++;
169 $mailsize_100_5yrArchive++;
173 $mailsize_100_7yrArchive++;
178 $client_count = count($client_XRC->values[0]);
181 $domain_results[] = array($value[
'primaryEmailDomain'], $client_count, $mailsize_100, $mailsize_250, $mailsize_1000, $mailsize_2000, $mailsize_100_3yrArchive, $mailsize_100_5yrArchive, $mailsize_100_7yrArchive);
183 sort($domain_results);
185 foreach ($domain_results as $dom_key=>$dom_value) {
190 $tr_class = ($tr_class ==
"odd_small" ?
"even_small" :
"odd_small");
192 $dom_accts = intval($dom_value[2]) + intval($dom_value[3]) + intval($dom_value[4]) + intval($dom_value[5]) + intval($dom_value[6]) + intval($dom_value[7]) + intval($dom_value[8]);
194 $dom_accts_prem = (intval($dom_value[3]) * 1) + (intval($dom_value[4]) * 2) + (intval($dom_value[5]) * 3) + (intval($dom_value[6]) * 3) + (intval($dom_value[7]) * 4) + (intval($dom_value[8]) * 5);
195 $dom_total_bill = ($dom_accts - $dom_credit);
197 $dom_total_bill = ($dom_total_bill <= 0 ? 0 : $dom_total_bill) + $dom_accts_prem;
200 if ($dom_total_bill > 0 || $ALL) {
201 fwrite ($rpt_fh,
"{$dom_value[0]}\t{$dom_value[1]}\t{$dom_value[2]}\t{$dom_value[3]}\t{$dom_value[4]}\t{$dom_value[5]}\t{$dom_value[6]}\t{$dom_value[7]}\t{$dom_value[8]}\t{$dom_accts}\t{$dom_credit}\t{$dom_accts_prem}\t{$dom_total_bill}\t\n");
207 function end_xrc () {
208 global $xrc_fh, $rpt_fh;
210 $end_time = date(
"m/d/Y h:i:s");
213 fwrite ($xrc_fh,
"\n** END LOG FILE -- $end_time **\n");
220 function arguments($argv) {
222 foreach ($argv as $arg) {
223 if (preg_match(
'/--[a-zA-Z0-9]*=.*/',$arg)) {
224 $str = explode(
"=",$arg); $arg =
'';
225 $key = str_replace(
"--",
'',$str[0]);
226 for ( $i = 1; $i < count($str); $i++ ) {
230 } elseif(preg_match(
'/-[a-zA-Z0-9]/',$arg)) {
231 $arg = str_replace(
"-",
'',$arg);
232 $_ARG[$arg] =
'true';