Created
December 15, 2021 01:24
-
-
Save dev-4458/9f7ff6c4271cd239c22dec2e060920ea to your computer and use it in GitHub Desktop.
Revisions
-
dev-4458 created this gist
Dec 15, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ <?php //CRON : `/usr/local/bin/ea-php74 /var/www/public_html/scan_pdf_and_make_zip.php 2>&1 | tee /var/www/public_html/scan_pdf.log $zip = new ZipArchive; $zip->open('/var/www/public_html/zipHavingPDFs.zip', ZipArchive::CREATE); $targetFolder = "/var/www/public_html/var/*"; if(file_exists('/var/www/public_html/zipHavingPDFs.zip')) { echo 'zipHavingPDFs file is exiss'.PHP_EOL; return; } foreach (glob($targetFolder) as $file) { $ext = pathinfo($file, PATHINFO_EXTENSION); if ($ext === 'pdf'){ //Remove below comment if you want to remove single PDF file //$flag = unlink($file); file_put_contents('/var/www/public_html/var/log/fd.log', $file.'==='.$flag.PHP_EOL , FILE_APPEND | LOCK_EX); $zip->addFile($file); } } $zip->close();