⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.145
Server IP:
13.127.59.50
Server:
Linux ip-172-31-46-210 5.15.0-1033-aws #37~20.04.1-Ubuntu SMP Fri Mar 17 11:39:30 UTC 2023 x86_64
Server Software:
Apache/2.4.41 (Ubuntu)
PHP Version:
7.4.3-4ubuntu2.29
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
var
/
www
/
ecommerce_pg
/
View File Name :
ExportController.php
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use DB; class ExportController extends Controller { // function filterData(&$str) { $str = preg_replace("/\t/", "\\t", $str); $str = preg_replace("/\r?\n/", "\\n", $str); if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"'; } public function exportTransactions(Request $request) { $fileName = "pg-transaction-data_" . date('Y-m-d') . ".csv"; $fields = array( 'REF#', 'USER ID', 'ORDER ID','TRANSACTION ID', 'AMOUNT', 'TYPE', 'STATUS','PAYOUT STATUS', 'UTR', 'GATEWAY', 'NOTES','AC NAME','AC NUMBER','IFSC','ADDED BY', 'APPROVED BY', 'PROCESSED BY', 'PAYOUT BANK', 'PROCESSED AT', 'PROCESSED IP', 'AGENT PROCESS TIME','DATE TIME' ); $excelData = implode("\t", array_values($fields)) . "\n"; $q = DB::table('transactions as t')->orderBy('id','ASC'); $q->leftjoin('users as ad','ad.id','=','t.added_by'); $q->leftjoin('users as ap','ap.id','=','t.approved_by'); $q->leftjoin('users as pr','pr.id','=','t.processed_by'); if (isset($request['report_date'])) { $split = explode('-',$request['report_date']); $split[0] = date('Y-m-d',strtotime(trim($split[0]))); $split[1] = date('Y-m-d',strtotime(trim($split[1]))); $q->where('t.created_at', '>=', $split[0] . ' 00:00:00'); $q->where('t.created_at', '<=', $split[1] . ' 23:59:59'); } $q->select( 't.id', 't.user_id', 't.order_id', 't.transaction_id', 't.amount', 't.type', 't.status','t.cashfree_status', 't.utr', 't.gateway', 't.notes','t.withdrawal_details', 't.added_by','t.approved_by', 't.processed_by', 'ad.name as ad_name', 'ap.name as ap_name', 'pr.name as pr_name', 't.payout_bank', 't.processed_at', 't.processed_ip', 't.agent_process_time', 't.created_at' ); $transactions = $q->get(); if(count($transactions) > 0){ foreach ($transactions as $key => $t) { $withdrawal_details = json_decode($t->withdrawal_details,true); $lineData = array( $t->id, $t->user_id, $t->order_id, $t->transaction_id,$t->amount, 'Withdraw', config('app.status')[$t->status],$t->cashfree_status, $t->utr, $t->gateway, $t->notes, $withdrawal_details['name'], (string)$withdrawal_details['ac_number'], $withdrawal_details['ifsc'], $t->ad_name,$t->ap_name, $t->pr_name, $t->payout_bank, $t->processed_at, $t->processed_ip, $t->agent_process_time,date('d-m-Y h:i a',strtotime($t->created_at)) ); array_walk($lineData, 'self::filterData'); $excelData .= implode("\t", array_values($lineData)) . "\n"; } }else{ $excelData .= 'No records found...'. "\n"; } header("Content-Type: application/vnd.csv"); header("Content-Disposition: attachment; filename=\"$fileName\""); echo $excelData; exit; } public function exportTransactionsNew(Request $request) { $fileName = "pg-new-transaction-data_" . date('Y-m-d') . ".xls"; $fields = array( 'REF#', 'USERNAME', 'ORDER ID', 'AMOUNT', 'TYPE', 'STATUS','PAYOUT STATUS', 'UTR', 'GATEWAY', 'NOTES','AC NAME','AC NUMBER','IFSC', 'ADDED BY', 'APPROVED BY', 'PROCESSED BY', 'PAYOUT BANK', 'PROCESSED AT', 'PROCESSED IP', 'AGENT PROCESS TIME' ); $excelData = implode("\t", array_values($fields)) . "\n"; $q = DB::table('new_transactions as t')->orderBy('id','ASC'); $q->leftjoin('users as ad','ad.id','=','t.added_by'); $q->leftjoin('users as ap','ap.id','=','t.approved_by'); $q->leftjoin('users as pr','pr.id','=','t.processed_by'); if (isset($request['report_date'])) { $split = explode('-',$request['report_date']); $split[0] = date('Y-m-d',strtotime(trim($split[0]))); $split[1] = date('Y-m-d',strtotime(trim($split[1]))); $q->where('t.created_at', '>=', $split[0] . ' 00:00:00'); $q->where('t.created_at', '<=', $split[1] . ' 23:59:59'); } $q->select( 't.id', 't.username', 't.order_id', 't.amount', 't.type', 't.status','t.cashfree_status', 't.utr', 't.gateway', 't.notes','t.withdrawal_details', 't.added_by','t.approved_by', 't.processed_by', 'ad.name as ad_name', 'ap.name as ap_name', 'pr.name as pr_name', 't.payout_bank', 't.processed_at', 't.processed_ip', 't.agent_process_time' ); $transactions = $q->get(); if(count($transactions) > 0){ foreach ($transactions as $key => $t) { $withdrawal_details = json_decode($t->withdrawal_details,true); $lineData = array( $t->id, $t->username, $t->order_id, $t->amount, 'Withdraw', config('app.status')[$t->status],$t->cashfree_status, $t->utr, $t->gateway, $t->notes, $withdrawal_details['name'], $withdrawal_details['ac_number'], $withdrawal_details['ifsc'], $t->ad_name,$t->ap_name, $t->pr_name, $t->payout_bank, $t->processed_at, $t->processed_ip, $t->agent_process_time ); array_walk($lineData, 'self::filterData'); $excelData .= implode("\t", array_values($lineData)) . "\n"; } }else{ $excelData .= 'No records found...'. "\n"; } header("Content-Type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=\"$fileName\""); echo $excelData; exit; } }