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
View File
-73
View File
@@ -1,73 +0,0 @@
<?php
namespace Modules\M3\Console;
use Config;
use DB;
use Illuminate\Console\Command;
use Illuminate\Http\Request;
use Log;
use Modules\M3\Http\Controllers\API\CloseShipment;
use Str;
class CallCloseAPI extends Command
{
protected $signature = 'command:CallCloseAPI {user?} {manifest?} {co?} {whs?} ';
protected $description = 'Call Close API';
public function handle()
{
self::configureTimeouts();
try {
$manifest = (string) ($this->argument('manifest') ?? '');
if ($manifest !== '') {
return $this->closeSpecificManifest($manifest, (string) ($this->argument('co') ?? ''), (string) ($this->argument('whs') ?? ''));
}
$this->closePendingManifests();
return self::SUCCESS;
} catch (\Throwable $th) {
Log::channel('dailyCron')->error($th);
return self::FAILURE;
}
}
private static function configureTimeouts(): void
{
$timeout = Config::get('arrays.PHPTimeOut');
ini_set('max_execution_time', $timeout);
ini_set('max_input_time', $timeout);
ini_set('default_socket_timeout', $timeout);
}
private function closePendingManifests(): void
{
$rows = DB::connection(config('m3.connection', 'pgsql'))->table('icm705m1')
->select('APMANIFEST', 'APCO', 'APWHS')->where('APSPARE2', '')->where('APMANIFEST', '!=', '0')
->whereRaw('EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - APLDCLOZ)) / 60 > 15')->orderBy('APMANIFEST', 'desc')->get();
foreach ($rows as $row) {
$this->closeManifest((string) $row->APMANIFEST, (string) ($row->APCO ?? ''), (string) ($row->APWHS ?? ''));
}
}
private function closeSpecificManifest(string $manifest, string $co, string $whs): int
{
$exists = DB::connection(config('m3.connection', 'pgsql'))->table('icm705m1')
->where('APSPARE2', '')->where('APCO', $co)->where('APWHS', $whs)->where('APMANIFEST', $manifest)->exists();
if (! $exists) {
Log::channel('dailyCron')->warning('Manifest not available for close', compact('manifest', 'co', 'whs'));
return self::FAILURE;
}
$this->closeManifest($manifest, $co, $whs);
return self::SUCCESS;
}
private function closeManifest(string $manifest, string $co, string $whs): void
{
DB::connection(config('m3.connection', 'pgsql'))->table('icm705m1')
->where('APMANIFEST', $manifest)->where('APCO', $co)->where('APWHS', $whs)->update(['APSPARE2' => 'P']);
$request = Request::create('', 'POST', ['WHS' => $whs, 'COMPANY' => $co, 'TRANSTYPE' => 'M', 'MANIFEST' => $manifest]);
$response = CloseShipment::CloseShipmentCoChargeAPI($request);
$json = json_encode($response->getData());
Log::channel('dailyCron')->info('Close Shipment API Response for Manifest:' . $manifest . '-' . $json);
}
}
@@ -46,7 +46,6 @@ class ClosedOrderSaveXls extends Command
*/
public function handle()
{
// $this->info('Start CallCloseAPI...');
ini_set('max_execution_time', Config::get('arrays.PHPTimeOutCL'));
ini_set('max_input_time', Config::get('arrays.PHPTimeOutCL'));
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOutCL'));
@@ -122,7 +121,6 @@ class ClosedOrderSaveXls extends Command
AND A5CO=$COMPANY AND A5WHS=$WHS AND A5PLANT=$PLANT
");
// $newItem = ["A5MACPKR" => 'Delivery #', "A5ONO" => 'Order #', "A4REFORD" => 'Order Type',"A5PART" => 'Part #',"A5RSVQTY" => 'Reserved',
// "A5PACKED" => 'Packed',"CALCULATED_COLUMN" => 'Back Order Qty',"ANOTHER_CALCULATED_COLUMN" => 'Value Packed $',"A4SHSHNM" => 'Customer name',
// "SHDT" => 'Date',"SHTIME" => 'Time',"REASON" => 'Failure Reason','A1SHCURR'=> 'Currency Code','FREIGHT'=> 'Freight'];
@@ -208,7 +206,6 @@ class ClosedOrderSaveXls extends Command
AND A5CO=$COMPANY AND A5WHS=$WHS AND A5PLANT=$PLANT
");
// $newItem2 = ["A5MACPKR" => 'Delivery #', "A5ONO" => 'Order #', "A4REFORD" => 'Order Type',"A5PART" => 'Part #',"A5RSVQTY" => 'Reserved',
// "A5PACKED" => 'Packed',"CALCULATED_COLUMN" => 'Back Order Qty',"ANOTHER_CALCULATED_COLUMN" => 'Value Packed $',"A4SHSHNM" => 'Customer name',
// "SHDT" => 'Date',"SHTIME" => 'Time',"REASON" => 'Failure Reason','A1SHCURR'=> 'Currency Code','FREIGHT'=> 'Freight'];
@@ -245,7 +242,6 @@ class ClosedOrderSaveXls extends Command
$this->info('Cron...End Save Orders Closed Lines to Excel');
} catch (\Throwable $th) {
// Log::error($th);
Log::channel('dailyCron')->error($th);
}
}
-4
View File
@@ -40,7 +40,6 @@ class DeleteOldLabels extends Command
*/
public function handle(): void
{
// $this->info('Start CallCloseAPI...');
ini_set('max_execution_time', Config::get('arrays.PHPTimeOutCL'));
ini_set('max_input_time', Config::get('arrays.PHPTimeOutCL'));
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOutCL'));
@@ -62,7 +61,6 @@ class DeleteOldLabels extends Command
Log::channel('dailyCron')->info('Getting Files From Directory: ' . $labelsDirectory);
exec('find ' . $labelsDirectory . ' -ctime +180 -type f -exec rm {} \;');
// exec('find '.$labelsDirectory.' -ctime +190 -type f -print | wc -l');
}
$labelsFolder = $labelsDirectoryTmp;
@@ -82,7 +80,6 @@ class DeleteOldLabels extends Command
}
}
// $this->info("Files to Delete...");
// dump($filesToDeleteArr);
// Delete Old Files
@@ -92,7 +89,6 @@ class DeleteOldLabels extends Command
$this->info('End Delete Old Labels Command...');
} catch (\Throwable $th) {
// Log::error($th);
Log::channel('dailyCron')->error($th);
}
}
-5
View File
@@ -48,7 +48,6 @@ class GenerateGS1Cmd extends Command
*/
public function handle()
{
// $this->info('Start CallCloseAPI...');
ini_set('max_execution_time', Config::get('arrays.PHPTimeOutCL'));
ini_set('max_input_time', Config::get('arrays.PHPTimeOutCL'));
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOutCL'));
@@ -66,7 +65,6 @@ class GenerateGS1Cmd extends Command
// Get Manifest Array
$GSArray1 = $this->option('gsarray');
$GSArray = json_decode($GSArray1, true);
// dump($GSArray);
// MAK : Used for debug only
$GSArray = ['Macpkr' => '55555', 'Recipient_Address1' => '9571 Pan American DR', 'Recipient_Address2' => 'C/O AEE Solar', 'Recipient_City' => 'El Paso',
@@ -230,7 +228,6 @@ class GenerateGS1Cmd extends Command
}
$html .= '</body> </html>';
// dump($html);
// App::call('App\Http\Controllers\utilitiesContoller@generateGS128');
ob_start();
@@ -246,7 +243,6 @@ class GenerateGS1Cmd extends Command
// $dompdf->stream();
$pdfContent = $dompdf->output();
// dump($pdfContent);
$labelsPath = Config::get('arrays.PdfPath');
// Put the PDF in labels/CarrierLabel
@@ -266,7 +262,6 @@ class GenerateGS1Cmd extends Command
$this->info('<<< GS1-128...End of Label Creation');
} catch (\Throwable $th) {
// Log::error($th);
Log::channel('LabelCron')->error($th);
}
}
-4
View File
@@ -41,7 +41,6 @@ class UtilitiesCmd extends Command
*/
public function handle(): void
{
// $this->info('Start CallCloseAPI...');
ini_set('max_execution_time', Config::get('arrays.PHPTimeOutCL'));
ini_set('max_input_time', Config::get('arrays.PHPTimeOutCL'));
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOutCL'));
@@ -50,15 +49,12 @@ class UtilitiesCmd extends Command
try {
$this->info('Start Utilities Command...');
// $this->info('User: '.$SHUSER);
$myRequest = new Request;
utilitiesContoller::fixICM799MSentPKR($myRequest);
// Log::channel('dailyCron')->info("Cron...End Save Orders Closed Lines to Excel");
$this->info('End Utilities Command...');
} catch (\Throwable $th) {
// Log::error($th);
Log::channel('dailyCron')->error($th);
}
}
-8
View File
@@ -42,7 +42,6 @@ class WHSMetricsSaveXls extends Command
*/
public function handle()
{
// $this->info('Start CallCloseAPI...');
ini_set('max_execution_time', Config::get('arrays.PHPTimeOutCL'));
ini_set('max_input_time', Config::get('arrays.PHPTimeOutCL'));
ini_set('default_socket_timeout', Config::get('arrays.PHPTimeOutCL'));
@@ -56,13 +55,10 @@ class WHSMetricsSaveXls extends Command
$SHUSER = isset($userId) ? $userId : (m3_user() !== '' ? Str::upper(trim(m3_user())) : '');
$CO = $this->argument('co');
// $COMPANY = isset($CO) ? trim($CO) : '110';
$COMPANY = '110';
$PWHS = $this->argument('whs');
// $WHS = isset($PWHS) ? trim($PWHS) : '321';
$WHS = '321';
$PPL = $this->argument('pl');
// $PLANT = isset($PPL) ? trim($PPL) : '143';
$PLANT = '143';
$date = new \DateTime;
@@ -92,7 +88,6 @@ class WHSMetricsSaveXls extends Command
GROUP BY A4SHIPTYPE,STATUS,SOURCE
ORDER BY 1,3,2
");
// dd($ICM700MHeadSel);
$newItem = ['A4SHIPTYPE' => 'Method', 'STATUS' => 'Status', 'SOURCE' => 'Source', 'PICKERS' => 'Pickers',
'WEIGHT' => 'Weight', 'LINES' => 'Lines', 'DOLLARS' => 'Dollars'];
@@ -110,7 +105,6 @@ class WHSMetricsSaveXls extends Command
// Prepend Header to Collection
$ICM700MHeadCol->prepend($newItem);
// $this->info($ICM700MHeadCol);
// Log::channel('dailyCron')->info(">>> Header Content");
// Log::channel('dailyCron')->info($ICM700MHeadCol);
@@ -158,7 +152,6 @@ class WHSMetricsSaveXls extends Command
} else {
$ICM700MDetailsCol = collect();
}
// Log::channel('dailyCron')->info(">>> Detail Content");
// Log::channel('dailyCron')->info($ICM700MDetailsCol);
// Save Head and Details to XLS file
@@ -180,7 +173,6 @@ class WHSMetricsSaveXls extends Command
$this->info('Cron...End Save Today WHS Performance Report to Excel');
} catch (\Throwable $th) {
// Log::error($th);
Log::channel('dailyCron')->error($th);
}
}