m3 Security Fixes
This commit is contained in:
@@ -2,18 +2,10 @@
|
||||
|
||||
namespace Modules\M3\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Log;
|
||||
use Str;
|
||||
use Storage;
|
||||
use File;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
class DeleteOldLabels extends Command
|
||||
{
|
||||
@@ -48,44 +40,44 @@ class DeleteOldLabels extends Command
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
//$this->info('Start CallCloseAPI...');
|
||||
// $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'));
|
||||
ini_set('memory_limit', '1024M');
|
||||
|
||||
try {
|
||||
$this->info("Start Delete Old Labels Command...");
|
||||
Log::channel('dailyCron')->info("Cron...Start Delete Old Labels Command...");
|
||||
$this->info('Start Delete Old Labels Command...');
|
||||
Log::channel('dailyCron')->info('Cron...Start Delete Old Labels Command...');
|
||||
|
||||
$labelsDirectoryTmp = '/www/sentm3live/htdocs/labels/';
|
||||
$subFolders = ['CarrierLabel/','ContentLabel/','PackingList/']; // ,'CarrierLabel/','ContentLabel','PackingList',''
|
||||
$daysOld = 180; // Number of days to consider a file old : 180 =Six Months
|
||||
$filesToDeleteArr = [];
|
||||
$subFolders = ['CarrierLabel/', 'ContentLabel/', 'PackingList/']; // ,'CarrierLabel/','ContentLabel','PackingList',''
|
||||
$daysOld = 180; // Number of days to consider a file old : 180 =Six Months
|
||||
$filesToDeleteArr = [];
|
||||
|
||||
foreach ($subFolders as $key => $subFolder) {
|
||||
$labelsDirectory = $labelsDirectoryTmp.$subFolder;
|
||||
$labelsDirectory = $labelsDirectoryTmp . $subFolder;
|
||||
|
||||
$this->info("Getting Files From Directory: ".$labelsDirectory);
|
||||
Log::channel('dailyCron')->info("Getting Files From Directory: ".$labelsDirectory);
|
||||
$this->info('Getting Files From Directory: ' . $labelsDirectory);
|
||||
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');
|
||||
exec('find ' . $labelsDirectory . ' -ctime +180 -type f -exec rm {} \;');
|
||||
// exec('find '.$labelsDirectory.' -ctime +190 -type f -print | wc -l');
|
||||
}
|
||||
|
||||
$labelsFolder = $labelsDirectoryTmp;
|
||||
# Get Files from the specified Directory
|
||||
$labelsFolder = $labelsDirectoryTmp;
|
||||
// Get Files from the specified Directory
|
||||
$filesToDelete = File::allFiles($labelsFolder);
|
||||
|
||||
foreach ($filesToDelete as $file) {
|
||||
$lastAccessTime = new \DateTime("@".$file->getATime());
|
||||
$now = new \DateTime();
|
||||
$diff = $now->diff($lastAccessTime)->days;
|
||||
$lastAccessTime = new \DateTime('@' . $file->getATime());
|
||||
$now = new \DateTime;
|
||||
$diff = $now->diff($lastAccessTime)->days;
|
||||
|
||||
if ($diff >= $daysOld) {
|
||||
$this->info("File: ".$file." is Days Old: ".$diff);
|
||||
$this->info('File: ' . $file . ' is Days Old: ' . $diff);
|
||||
// Log::channel('dailyCron')->info("File: ".$file." is Days Old: ".$diff);
|
||||
# Add the File to Array
|
||||
// Add the File to Array
|
||||
$filesToDeleteArr[] = $file;
|
||||
}
|
||||
}
|
||||
@@ -93,14 +85,13 @@ class DeleteOldLabels extends Command
|
||||
// $this->info("Files to Delete...");
|
||||
// dump($filesToDeleteArr);
|
||||
|
||||
# Delete Old Files
|
||||
// Delete Old Files
|
||||
File::delete($filesToDeleteArr);
|
||||
|
||||
Log::channel('dailyCron')->info("Cron...End Delete Old Labels Command...");
|
||||
$this->info("End Delete Old Labels Command...");
|
||||
Log::channel('dailyCron')->info('Cron...End Delete Old Labels Command...');
|
||||
$this->info('End Delete Old Labels Command...');
|
||||
|
||||
}
|
||||
catch (\Throwable $th) {
|
||||
} catch (\Throwable $th) {
|
||||
// Log::error($th);
|
||||
Log::channel('dailyCron')->error($th);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user