MINI Sh3ll
<?php
require_once __DIR__.'/../define.php';
header('Content-Type:text/plain');
require __DIR__.'/../vendor/autoload.php';
/*use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;*/
$fromdate = date('Y-m-01');
$todate = date('Y-m-d', strtotime("-1 day"));
$today = date('d-M-Y');
$report_path = __DIR__.'/reports/';
if(!file_exists($report_path)){
mkdir($report_path, 0777, true);
}
//$day = date('j', strtotime($fromdate));
$day = date('j');
if($day == 1){
$fromdate = date('Y-m-01', strtotime("-1 month"));
$todate = date('Y-m-t', strtotime("-1 month"));
}
//print '['.$fromdate.']['.$todate.']['.$day.']';
$report_name = 'tollfree-sms-billing-report-'.$today.'.xlsx';
$report_path = $report_path.$report_name;
$report_data = getDailyBillingReport($fromdate, $todate);
$clients = array_unique(array_column($report_data, 'client_id'));
foreach($clients as $c){
$data = [];
$client_name = '';
foreach($report_data as $rd){
if($rd['client_id'] == $c){
$client_name = $rd['company'];
$d = [];
$d['date'] = $rd['date'];
$d['airtel_success'] = $rd['airtel_success'];
$d['airtel_failed'] = $rd['airtel_failed'];
$d['vodafone_success'] = $rd['vodafone_success'];
$d['vodafone_failed'] = $rd['vodafone_failed'];
$d['vodafone_idea_success'] = $rd['vodafone_idea_success'];
$d['vodafone_idea_failed'] = $rd['vodafone_idea_failed'];
$d['reliance_jio_success'] = $rd['reliance_jio_success'];
$d['reliance_jio_failed'] = $rd['reliance_jio_failed'];
$d['reliance_jio_binary_success'] = $rd['reliance_jio_binary'];
$d['reliance_jio_binary_failed'] = 0;
$d['total_success'] = $rd['airtel_success']+$rd['vodafone_success']+$rd['vodafone_idea_success']+$rd['reliance_jio_success']+$rd['reliance_jio_binary'];
$d['total_failed'] = $rd['airtel_failed']+$rd['vodafone_failed']+$rd['vodafone_idea_failed']+$rd['reliance_jio_failed'];
$data[] = $d;
}
}
if(count($data) > 0){
$client_name = $client_name == '' ? 'Invalids' : $client_name;
$path = saveReportToExcel($report_path, $client_name, $data);
print 'File updated for '.$client_name.PHP_EOL;
}
}
//print 'File is saved at '.$report_path;
//$to = '[email protected]';
$to = '[email protected]';
$cc = [];
$cc[] = '[email protected]';
$cc[] = '[email protected]';
$cc[] = '[email protected]';
$cc[] = '[email protected]';
$cc[] = '[email protected]';
$cc[] = '[email protected]';
$cc[] = '[email protected]';
$cc[] = '[email protected]';
if(count($clients) > 0){
$subject = 'Operatorwise Tollfree SMS Daily Report - '.date('d-M-Y');
$body = 'Hi,<br/> Please check the attached excel file for the daily operatorwise tollfree SMS Counts by Account as on '.date('d-M-Y', strtotime('-1 day')).'.<br/><br/>Thanks';
$attachments = [];
$attachments[] = $report_path;
$mresponse = sendMail($to, $cc, $subject, $body, $attachments);
unlink($report_path);
print '['.$report_path.']['.$mresponse.']';
}
?>
OHA YOOOO