M3 Security Fixes for pass 28

This commit is contained in:
Mark Gregory
2026-09-17 10:50:37 +01:00
parent 1037c1c202
commit ed3db89018
77 changed files with 82 additions and 2387 deletions
@@ -5,7 +5,6 @@ namespace Modules\M3\Http\Controllers;
use Config;
use DB;
use File;
// use Datatables;
use Illuminate\Http\Request;
use Smalot\PdfParser\Parser;
use Str;
@@ -20,7 +19,6 @@ class M3GetPDFFromCacheController extends Controller
$aggno = $aggmsg = '';
$IC670M = $PDFArray = $carrier = $trackingno = $ICM688M1 = [];
$AYMACPKR = $WHDDA = $COMPANY = $PLANT = $WHS = '';
// $carrier = $trackingno = "";
// PDF File PATH
$pdfFilePath = Config::get('arrays.PdfPath');
@@ -29,7 +27,6 @@ class M3GetPDFFromCacheController extends Controller
$PDFArray = $trackingno = $carrier = $ICM688M1 = [];
$SHUSER = m3_user() !== '' ? Str::upper(trim(m3_user())) : '';
// dd($SHUSER);
if ($SHUSER != '') {
// Get User CO & WH
@@ -55,7 +52,6 @@ class M3GetPDFFromCacheController extends Controller
$AYMACPKR = isset($urlParams['MACPKR']) ? trim($urlParams['MACPKR']) : ''; // Delivery note number
$DOCTYPE = isset($urlParams['DOCTYPE']) ? trim($urlParams['DOCTYPE']) : ''; // Document type (PackingList, CarrierLabel, ContentLabel)
$WHDDA = $COMPANY . $PLANT . $WHS;
// dump($WHDDA);
// Check Doctype fisrt
$docTypes = $DOCTYPE != '' ? [$DOCTYPE] : ['PackingList', 'ContentLabel', 'CarrierLabel', 'GSLabel']; // document type (PackingList, CarrierLabel, ContentLabel)
@@ -73,15 +69,12 @@ class M3GetPDFFromCacheController extends Controller
->where('AYWHS', $WHS)
->where('AYMACPKR', $AYMACPKR)
->first();
// dump($ICM695M1Agg);
$aggno = isset($ICM695M1Agg->AYTRUCK) ? trim($ICM695M1Agg->AYTRUCK) : '';
if ($aggno != '' && $aggno != '0') {
// dump($aggno);
$aggmsg = "This delivery note is part of aggregation $aggno ";
$ICM688M1 = DB::connection(config('m3.connection', 'pgsql'))->select("select A4MACPKR from ICM688M1 where A4SHPAGGCD='$aggno'");
// dump($ICM688M1);
// foreach($ICM688M1 as $key => $ICM688M1R) {
// $aggmsg.=' <a href="M3GetPDFFromCache?MACPKR='.$ICM688M1R->A4MACPKR.'&COMPANY='.$COMPANY.'&PLANT='.$PLANT.'&WHS='.$WHS.'">'.$ICM688M1R->A4MACPKR.'</a>';
// }
@@ -108,7 +101,6 @@ class M3GetPDFFromCacheController extends Controller
->orderBy('AYMACPKR')
->get();
}
// dump($ICM695M1);
$allLabels = [];
@@ -127,7 +119,6 @@ class M3GetPDFFromCacheController extends Controller
// Make Key and Test Validity
if ($AYMACPKR != '' && $COMPANY != '' && $WHS != '') {
// echo "<script>alert('2');</script>";
$CarrierLabel = '';
$ContentLabel = '';
$PackingList = '';
@@ -160,7 +151,6 @@ class M3GetPDFFromCacheController extends Controller
if ($value == 'GSLabel') {
$PDFKey = $value . '/' . $value . '_' . $AYMACPKR . '_' . $COMPANY . '_' . $WHS . '_' . $DOCNUM;
// if ($ContentLabel=='LTL' ) {
// $PDFKey = $value.'/'.$value.'_'.$AYMACPKR.'_'.$COMPANY.'_'.$WHS;
// }
// else{
@@ -173,35 +163,27 @@ class M3GetPDFFromCacheController extends Controller
}
}
}
// dump($tmpCacheArr);
// Get unique values from array $PDFArray
$tmpCacheArr = collect($tmpCacheArr)->unique();
// dump($tmpCacheArr);
foreach ($tmpCacheArr as $key => $value) {
// $isCarrierLabel = Str::contains($value, 'CarrierLabel');
$pdfFileName = $pdfFilePath . $value . '.pdf';
if (File::exists($pdfFileName)) {
// dump($pdfFileName);
$pdfFile = File::get($pdfFileName);
// Transform content to base64
// $base64PDF = $pdfFile;
$base64PDF = base64_encode($pdfFile);
// dd($base64PDF);
$PDFArray[] = $base64PDF;
}
}
// dump($PDFArray);
} else {
// Nothing Found
}
}
} catch (\Throwable $th) {
// Log::error($th);
}
// dump($PDFArray);
// dump($AYMACPKR);
// dump($IC670M);
// dump($ICM695M1);