diff --git a/app/Helpers/AppHelper.php b/app/Helpers/AppHelper.php index 3bae3a09..e898adb0 100644 --- a/app/Helpers/AppHelper.php +++ b/app/Helpers/AppHelper.php @@ -63,15 +63,18 @@ function getFtpResponse($download_file, $proc_file){ $login = ftp_login($ftp_conn, env('FTP_USERNAME'), env('FTP_USERPASS')); $login_pasv = ftp_pasv($ftp_conn, true) or die("Cannot switch to passive mode"); - if (ftp_get($ftp_conn, $download_file, $proc_file, FTP_BINARY) ) { - return true; - } else { - die("Cannot find specified file"); + try { + if (ftp_get($ftp_conn, $download_file, $proc_file, FTP_BINARY)) { + return true; + } else { + die("Cannot find specified file"); + ftp_close($ftp_conn); + return false; + } ftp_close($ftp_conn); + } catch (Exception $e) { return false; } - - ftp_close($ftp_conn); } function get_guid() { diff --git a/app/Http/Controllers/compressController.php b/app/Http/Controllers/compressController.php index 31f8e171..fc99f09e 100644 --- a/app/Http/Controllers/compressController.php +++ b/app/Http/Controllers/compressController.php @@ -4,6 +4,8 @@ use App\Helpers\AppHelper; use App\Models\compression_pdf; +use App\Models\init_pdf; +use Illuminate\Database\QueryException; use Illuminate\Http\Request; use Illuminate\Http\RedirectResponse; use Illuminate\Support\Facades\DB; @@ -24,18 +26,28 @@ public function pdf_init(Request $request): RedirectResponse{ $uuid = AppHelper::Instance()->get_guid(); if($validator->fails()) { - return redirect()->back()->withErrors(['error'=>$validator->messages(), 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_init')->insert([ + 'processId' => $uuid, + 'err_reason' => $validator->messages(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>$validator->messages(), 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } else { if(isset($_POST['formAction'])) { if($request->post('formAction') == "upload") { if($request->hasfile('file')) { - $str = rand(); + $str = rand(1000,10000000); $pdfUpload_Location = env('PDF_UPLOAD'); $file = $request->file('file'); - $randomizePdfFileName = md5($str); + $randomizePdfFileName = 'pdf_compress_'.substr(md5(uniqid($str)), 0, 8); $randomizePdfPath = $pdfUpload_Location.'/'.$randomizePdfFileName.'.pdf'; $pdfFileName = $file->getClientOriginalName(); + $fileSize = filesize($file); $file->storeAs('public/upload-pdf', $randomizePdfFileName.'.pdf'); if (Storage::disk('local')->exists('public/'.$randomizePdfPath)) { return redirect()->back()->with([ @@ -44,10 +56,40 @@ public function pdf_init(Request $request): RedirectResponse{ 'pdfOriName' => $pdfFileName, ]); } else { - return redirect()->back()->withErrors(['error'=>'PDF file not found on the server !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_compress')->insert([ + 'processId' => $uuid, + 'fileName' => $randomizePdfFileName.'.pdf', + 'fileSize' => $fileSize, + 'compFileSize' => 'null', + 'compMethod' => 'null', + 'result' => false, + 'err_reason' => 'PDF file not found on the server !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF file not found on the server !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } else { - return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_compress')->insert([ + 'processId' => $uuid, + 'fileName' => 'null', + 'fileSize' => 'null', + 'compFileSize' => 'null', + 'compMethod' => 'null', + 'result' => false, + 'err_reason' => 'PDF failed to upload !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } else if ($request->post('formAction') == "compress") { if(isset($_POST['fileAlt'])) { @@ -60,6 +102,7 @@ public function pdf_init(Request $request): RedirectResponse{ $file = $request->post('fileAlt'); $pdfUpload_Location = env('PDF_UPLOAD'); $pdfProcessed_Location = env('PDF_DOWNLOAD'); + $pdfEncKey = bin2hex(random_bytes(16)); $pdfName = basename($file); $pdfNameWithoutExtension = basename($pdfName, '.pdf'); $pdfNewPath = Storage::disk('local')->path('public/'.$pdfUpload_Location.'/'.$pdfName); @@ -68,116 +111,152 @@ public function pdf_init(Request $request): RedirectResponse{ try { $ilovepdf = new Ilovepdf(env('ILOVEPDF_PUBLIC_KEY'),env('ILOVEPDF_SECRET_KEY')); $ilovepdfTask = $ilovepdf->newTask('compress'); - $ilovepdfTask->setFileEncryption(env('ILOVEPDF_ENC_KEY')); + $ilovepdfTask->setFileEncryption($pdfEncKey); + $ilovepdfTask->setEncryptKey($pdfEncKey); + $ilovepdfTask->setEncryption(true); $pdfFile = $ilovepdfTask->addFile($pdfNewPath); - $ilovepdfTask->setOutputFileName($pdfNameWithoutExtension); + $pdfFile->setPassword($pdfEncKey); $ilovepdfTask->setCompressionLevel($compMethod); + $ilovepdfTask->setOutputFileName($pdfNameWithoutExtension); $ilovepdfTask->execute(); $ilovepdfTask->download(Storage::disk('local')->path('public/'.$pdfProcessed_Location)); + $ilovepdfTask->delete(); } catch (\Ilovepdf\Exceptions\StartException $e) { - DB::table('pdf_compress')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'compFileSize' => null, - 'compMethod' => $compMethod, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on StartException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Compression failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_compress')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'compFileSize' => 'null', + 'compMethod' => $compMethod, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on StartException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Compression failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\AuthException $e) { - DB::table('pdf_compress')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'compFileSize' => null, - 'compMethod' => $compMethod, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on AuthException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Compression failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_compress')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'compFileSize' => 'null', + 'compMethod' => $compMethod, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on AuthException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Compression failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\UploadException $e) { - DB::table('pdf_compress')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'compFileSize' => null, - 'compMethod' => $compMethod, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on UploadException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Compression failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_compress')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'compFileSize' => 'null', + 'compMethod' => $compMethod, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on UploadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Compression failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\ProcessException $e) { - DB::table('pdf_compress')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'compFileSize' => null, - 'compMethod' => $compMethod, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on ProcessException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Compression failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_compress')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'compFileSize' => 'null', + 'compMethod' => $compMethod, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on ProcessException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Compression failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\DownloadException $e) { - DB::table('pdf_compress')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'compFileSize' => null, - 'compMethod' => $compMethod, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on DownloadException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Compression failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_compress')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'compFileSize' => 'null', + 'compMethod' => $compMethod, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on DownloadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Compression failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\TaskException $e) { - DB::table('pdf_compress')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'compFileSize' => null, - 'compMethod' => $compMethod, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on TaskException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Compression failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_compress')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'compFileSize' => 'null', + 'compMethod' => $compMethod, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on TaskException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Compression failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\PathException $e) { - DB::table('pdf_compress')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'compFileSize' => null, - 'compMethod' => $compMethod, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on PathException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Compression failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_compress')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'compFileSize' => 'null', + 'compMethod' => $compMethod, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on PathException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Compression failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Exception $e) { - DB::table('pdf_compress')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'compFileSize' => null, - 'compMethod' => $compMethod, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on Exception', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Compression failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_compress')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'compFileSize' => 'null', + 'compMethod' => $compMethod, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on Exception', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Compression failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } if (file_exists($pdfNewPath)) { @@ -187,46 +266,99 @@ public function pdf_init(Request $request): RedirectResponse{ if (file_exists(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfName))) { $compFileSize = filesize(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfName)); $newCompFileSize = AppHelper::instance()->convert($compFileSize, "MB"); - DB::table('pdf_compress')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'compFileSize' => $newCompFileSize, - 'compMethod' => $compMethod, - 'result' => true, - 'err_reason' => null, - 'err_api_reason' => null, - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->with([ - "stats" => "scs", - "res"=>Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfName), - "curFileSize"=>$newFileSize, - "newFileSize"=>$newCompFileSize, - "compMethod"=>$compMethod - ]); + try { + DB::table('pdf_compress')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'compFileSize' => $newCompFileSize, + 'compMethod' => $compMethod, + 'result' => true, + 'err_reason' => 'null', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with([ + "stats" => "scs", + "res"=>Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfName), + "curFileSize"=>$newFileSize, + "newFileSize"=>$newCompFileSize, + "compMethod"=>$compMethod + ]); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } else { + try { + DB::table('pdf_compress')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'compFileSize' => 'null', + 'compMethod' => $compMethod, + 'result' => false, + 'err_reason' => 'Failed to download file from iLovePDF API !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Compression failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } + } else { + try { DB::table('pdf_compress')->insert([ 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'compFileSize' => null, - 'compMethod' => $compMethod, + 'fileName' => 'null', + 'fileSize' => 'null', + 'compFileSize' => 'null', + 'compMethod' => 'null', 'result' => false, - 'err_reason' => 'Failed to download file from iLovePDF API !', - 'err_api_reason' => null, + 'err_reason' => 'PDF failed to upload !', + 'err_api_reason' => 'null', 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() ]); - return redirect()->back()->withErrors(['error'=>'PDF Compression failed !', 'processId'=>$uuid])->withInput(); + return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); } - } else { - return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); } } else { - return redirect()->back()->withErrors(['error'=>'INVALID_REQUEST_ERROR !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_compress')->insert([ + 'processId' => $uuid, + 'fileName' => 'null', + 'fileSize' => 'null', + 'compFileSize' => 'null', + 'compMethod' => 'null', + 'result' => false, + 'err_reason' => 'INVALID_REQUEST_ERROR !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF process unknown error !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } else { - return redirect()->back()->withErrors(['error'=>'REQUEST_ERROR_OUT_OF_BOUND !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_compress')->insert([ + 'processId' => $uuid, + 'fileName' => 'null', + 'fileSize' => 'null', + 'compFileSize' => 'null', + 'compMethod' => 'null', + 'result' => false, + 'err_reason' => 'OUT_OF_BOUND_ERROR !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF process unknown error !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } } diff --git a/app/Http/Controllers/convertController.php b/app/Http/Controllers/convertController.php index 22f708f5..3eb7bd39 100644 --- a/app/Http/Controllers/convertController.php +++ b/app/Http/Controllers/convertController.php @@ -3,10 +3,12 @@ namespace App\Http\Controllers; use App\Helpers\AppHelper; +use App\Models\init_pdf; use App\Models\pdf_convert; use Aspose\Words\WordsApi; use Aspose\Words\Model\Requests\{SaveAsRequest, UploadFileRequest}; use Aspose\Words\Model\{DocxSaveOptionsData}; +use Illuminate\Database\QueryException; use Illuminate\Http\Request; use Illuminate\Http\RedirectResponse; use Illuminate\Support\Facades\DB; @@ -15,9 +17,9 @@ use Illuminate\Support\Facades\Validator; use Ilovepdf\Ilovepdf; use Ilovepdf\Exceptions; +use Ilovepdf\ImagepdfTask; use Ilovepdf\OfficepdfTask; use Ilovepdf\PdfjpgTask; -use Spatie\PdfToImage\Pdf; use Symfony\Component\Process\Process; use Symfony\Component\Process\Exception\ProcessFailedException; use Symfony\Component\Process\Exception\RuntimeException; @@ -26,26 +28,36 @@ class convertController extends Controller { public function pdf_init(Request $request): RedirectResponse{ $validator = Validator::make($request->all(),[ - 'file' => 'mimes:pdf,pptx,docx,xlsx|max:25600', + 'file' => 'mimes:pdf,pptx,docx,xlsx,jpg,png,jpeg,tiff|max:25600', 'fileAlt' => '' ]); $uuid = AppHelper::Instance()->get_guid(); if($validator->fails()) { - return redirect()->back()->withErrors(['error'=>$validator->messages(), 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_init')->insert([ + 'processId' => $uuid, + 'err_reason' => $validator->messages(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>$validator->messages(), 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } else { if(isset($_POST['formAction'])) { if($request->post('formAction') == "upload") { if($request->hasfile('file')) { - $str = rand(); + $str = rand(1000,10000000); $pdfUpload_Location = env('PDF_UPLOAD'); $file = $request->file('file'); - $randomizePdfFileName = md5($str); + $randomizePdfFileName = 'pdf_convert_'.substr(md5(uniqid($str)), 0, 8); $randomizePdfExtension = pathinfo($file->getClientOriginalName(), PATHINFO_EXTENSION); $randomizePdfPath = $pdfUpload_Location.'/'.$randomizePdfFileName.'.'.$randomizePdfExtension; $pdfFileName = $file->getClientOriginalName(); + $fileSize = filesize($file); $file->storeAs('public/upload-pdf', $randomizePdfFileName.'.'.$randomizePdfExtension); if (Storage::disk('local')->exists('public/'.$randomizePdfPath)) { return redirect()->back()->with([ @@ -54,16 +66,45 @@ public function pdf_init(Request $request): RedirectResponse{ 'pdfOriName' => $pdfFileName, ]); } else { - return redirect()->back()->withErrors(['error'=>'PDF file not found on the server !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $randomizePdfFileName.'.pdf', + 'fileSize' => $fileSize, + 'container' => 'null', + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'PDF file not found on the server !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF file not found on the server !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } else { - return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => 'null', + 'fileSize' => 'null', + 'container' => 'null', + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'PDF failed to upload !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } else if ($request->post('formAction') == "convert") { if(isset($_POST['convertType'])) { $convertType = $request->post('convertType'); - if ($convertType == 'excel') { if(isset($_POST['fileAlt'])) { $pdfUpload_Location = env('PDF_UPLOAD'); @@ -92,76 +133,112 @@ public function pdf_init(Request $request): RedirectResponse{ $asposeAPI->setTimeout(600); $asposeAPI->run(); } catch (RuntimeException $message) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'PDF Conversion running out of time !', - 'err_api_reason' => $message->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - //throw new ProcessFailedException($asposeAPI); - - return redirect()->back()->withErrors(['error'=>'PDF Conversion running out of time !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'PDF Conversion running out of time !', + 'err_api_reason' => $message->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion running out of time !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (ProcessFailedException $message) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'Symfony runtime process fail exception !', - 'err_api_reason' => $message->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - //throw new ProcessFailedException($asposeAPI); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); - } - if (!$asposeAPI->isSuccessful()) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'Python process fail !', - 'err_api_reason' => $asposeAPI->getOutput(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - //throw new ProcessFailedException($asposeAPI); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); - } else { - if (AppHelper::instance()->getFtpResponse(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.xlsx'), $pdfNameWithoutExtension.".xlsx") == true) { - $download_excel = Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.xlsx'); + try { DB::table('pdf_convert')->insert([ 'processId' => $uuid, 'fileName' => $pdfName, 'fileSize' => $newFileSize, 'container' => $convertType, - 'result' => true, - 'err_reason' => null, - 'err_api_reason' => $asposeAPI->getOutput(), + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'Symfony runtime process fail exception !', + 'err_api_reason' => $message->getMessage(), 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() ]); - return redirect()->back()->with(["stats" => "scs", "res"=>$download_excel]); - } else { + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } + if (!$asposeAPI->isSuccessful()) { + try { DB::table('pdf_convert')->insert([ 'processId' => $uuid, 'fileName' => $pdfName, 'fileSize' => $newFileSize, 'container' => $convertType, + 'img_extract' => false, 'result' => false, - 'err_reason' => 'Converted file not found on the server !', + 'err_reason' => 'Python process fail !', 'err_api_reason' => $asposeAPI->getOutput(), 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() ]); - return redirect()->back()->withErrors(['error'=>'Converted file not found on the server !', 'processId'=>$uuid])->withInput(); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } else { + if (AppHelper::instance()->getFtpResponse(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.xlsx'), $pdfNameWithoutExtension.".xlsx") == true) { + $download_excel = Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.xlsx'); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => true, + 'err_reason' => 'null', + 'err_api_reason' => $asposeAPI->getOutput(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with(["stats" => "scs", "res"=>$download_excel]); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } else { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'Converted file not found on the server !', + 'err_api_reason' => $asposeAPI->getOutput(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'Converted file not found on the server !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } } else { - return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => 'null', + 'fileSize' => 'null', + 'container' => 'null', + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'PDF failed to upload !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } else if ($convertType == 'pptx') { if(isset($_POST['fileAlt'])) { @@ -191,75 +268,112 @@ public function pdf_init(Request $request): RedirectResponse{ $asposeAPI->setTimeout(600); $asposeAPI->run(); } catch (RuntimeException $message) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'Symfony runtime process out of time !', - 'err_api_reason' => $message->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - //throw new ProcessFailedException($asposeAPI); - return redirect()->back()->withErrors(['error'=>'PDF Conversion running out of time !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'Symfony runtime process out of time !', + 'err_api_reason' => $message->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion running out of time !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (ProcessFailedException $message) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'Symfony runtime process fail exception !', - 'err_api_reason' => $message->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - //throw new ProcessFailedException($asposeAPI); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); - } - if (!$asposeAPI->isSuccessful()) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'Python process fail !', - 'err_api_reason' => $asposeAPI->getOutput(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - //throw new ProcessFailedException($asposeAPI); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); - } else { - if (AppHelper::instance()->getFtpResponse(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.pptx'), $pdfNameWithoutExtension.".pptx") == true) { - $download_excel = Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.pptx'); + try { DB::table('pdf_convert')->insert([ 'processId' => $uuid, 'fileName' => $pdfName, 'fileSize' => $newFileSize, 'container' => $convertType, - 'result' => true, - 'err_reason' => null, - 'err_api_reason' => $asposeAPI->getOutput(), + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'Symfony runtime process fail exception !', + 'err_api_reason' => $message->getMessage(), 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() ]); - return redirect()->back()->with(["stats" => "scs", "res"=>$download_excel]); - } else { + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } + if (!$asposeAPI->isSuccessful()) { + try { DB::table('pdf_convert')->insert([ 'processId' => $uuid, 'fileName' => $pdfName, 'fileSize' => $newFileSize, 'container' => $convertType, + 'img_extract' => false, 'result' => false, - 'err_reason' => 'Converted file not found on the server !', + 'err_reason' => 'Python process fail !', 'err_api_reason' => $asposeAPI->getOutput(), 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() ]); - return redirect()->back()->withErrors(['error'=>'Converted file not found on the server !', 'processId'=>$uuid])->withInput(); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } else { + if (AppHelper::instance()->getFtpResponse(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.pptx'), $pdfNameWithoutExtension.".pptx") == true) { + $download_excel = Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.pptx'); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => true, + 'err_reason' => 'null', + 'err_api_reason' => $asposeAPI->getOutput(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with(["stats" => "scs", "res"=>$download_excel]); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } else { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'Converted file not found on the server !', + 'err_api_reason' => $asposeAPI->getOutput(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'Converted file not found on the server !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } } else { - return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => 'null', + 'fileSize' => 'null', + 'container' => 'null', + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'PDF failed to upload !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } else if ($convertType == 'docx') { if(isset($_POST['fileAlt'])) { @@ -291,71 +405,121 @@ public function pdf_init(Request $request): RedirectResponse{ ); $result = $wordsApi->saveAs($request); } catch (Exception $e) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'Aspose PDF API Error !', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); - } - if (file_exists($pdfNewPath)) { - unlink($pdfNewPath); - } - if (json_decode($result, true) !== NULL) { - if (AppHelper::instance()->getFtpResponse(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfNameWithoutExtension.".docx"), $pdfNameWithoutExtension.".docx") == true) { - $download_word = Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfNameWithoutExtension.".docx"); + try { DB::table('pdf_convert')->insert([ 'processId' => $uuid, 'fileName' => $pdfName, 'fileSize' => $newFileSize, 'container' => $convertType, - 'result' => true, - 'err_reason' => null, - 'err_api_reason' => null, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'Aspose PDF API Error !', + 'err_api_reason' => $e->getMessage(), 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() ]); - return redirect()->back()->with([ - "stats" => "scs", - "res"=>$download_word - ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } + if (file_exists($pdfNewPath)) { + unlink($pdfNewPath); + } + if (json_decode($result, true) !== NULL) { + if (AppHelper::instance()->getFtpResponse(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfNameWithoutExtension.".docx"), $pdfNameWithoutExtension.".docx") == true) { + $download_word = Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfNameWithoutExtension.".docx"); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => true, + 'err_reason' => 'null', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with([ + "stats" => "scs", + "res"=>$download_word + ]); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } else { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'FTP Server Connection Failed !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'FTP Server Connection Failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } + } else { + try { DB::table('pdf_convert')->insert([ 'processId' => $uuid, 'fileName' => $pdfName, 'fileSize' => $newFileSize, 'container' => $convertType, + 'img_extract' => false, 'result' => false, - 'err_reason' => 'FTP Server Connection Failed !', - 'err_api_reason' => null, + 'err_reason' => 'Aspose Clouds API has fail while process, Please look on Aspose Dashboard !', + 'err_api_reason' => 'null', 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() ]); - return redirect()->back()->withErrors(['error'=>'FTP Server Connection Failed !', 'processId'=>$uuid])->withInput(); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); } - } else { + } + } else { + try { DB::table('pdf_convert')->insert([ 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, + 'fileName' => 'null', + 'fileSize' => 'null', + 'container' => 'null', + 'img_extract' => false, 'result' => false, - 'err_reason' => 'Aspose Clouds API has fail while process, Please look on Aspose Dashboard !', - 'err_api_reason' => null, + 'err_reason' => 'PDF failed to upload !', + 'err_api_reason' => 'null', 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() ]); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed', 'processId'=>$uuid])->withInput(); + return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); } - } else { - return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); } } else if ($convertType == 'jpg') { if(isset($_POST['fileAlt'])) { + if(isset($_POST['extImage'])) + { + $extImage = $request->post('extImage'); + if ($extImage) { + $imageModes = 'extract'; + $extMode = true; + } else { + $imageModes = 'pages'; + $extMode = false; + } + } else { + $imageModes = 'pages'; + $extMode = false; + } $pdfUpload_Location = env('PDF_UPLOAD'); $pdfProcessed_Location = env('PDF_DOWNLOAD'); + $pdfEncKey = bin2hex(random_bytes(16)); $file = $request->post('fileAlt'); $pdfName = basename($file); $pdfNameWithoutExtension = basename($pdfName, ".pdf"); @@ -365,156 +529,213 @@ public function pdf_init(Request $request): RedirectResponse{ $newFileSize = AppHelper::instance()->convert($fileSize, "MB"); try { $ilovepdfTask = new PdfjpgTask(env('ILOVEPDF_PUBLIC_KEY'),env('ILOVEPDF_SECRET_KEY')); - $ilovepdfTask->setFileEncryption(env('ILOVEPDF_ENC_KEY')); + $ilovepdfTask->setFileEncryption($pdfEncKey); + $ilovepdfTask->setEncryptKey($pdfEncKey); + $ilovepdfTask->setEncryption(true); $pdfFile = $ilovepdfTask->addFile($pdfNewPath); - $ilovepdfTask->setMode('pages'); + $ilovepdfTask->setMode($imageModes); $ilovepdfTask->setOutputFileName($pdfNameWithoutExtension); $ilovepdfTask->setPackagedFilename($pdfNameWithoutExtension); $ilovepdfTask->execute(); $ilovepdfTask->download(Storage::disk('local')->path('public/'.$pdfProcessed_Location)); } catch (\Ilovepdf\Exceptions\StartException $e) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on StartException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => $extMode, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on StartException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\AuthException $e) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on AuthException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => $extMode, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on AuthException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\UploadException $e) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on UploadException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => $extMode, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on UploadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\ProcessException $e) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on ProcessException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => $extMode, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on ProcessException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\DownloadException $e) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on DownloadException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => $extMode, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on DownloadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\TaskException $e) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on TaskException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => $extMode, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on TaskException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\PathException $e) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on PathException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => $extMode, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on PathException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Exception $e) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on Exception', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => $extMode, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on Exception', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } if (file_exists($pdfNewPath)) { unlink($pdfNewPath); } if (file_exists(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.zip'))) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => true, - 'err_reason' => null, - 'err_api_reason' => null, - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->with([ - "stats" => "scs", - "res"=>Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.zip') - ]); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => $extMode, + 'result' => true, + 'err_reason' => null, + 'err_api_reason' => null, + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with([ + "stats" => "scs", + "res"=>Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.zip') + ]); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } else if (Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'-0001.jpg')) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => true, - 'err_reason' => null, - 'err_api_reason' => null, - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->with([ - "stats" => "scs", - "res"=>Storage::disk('local')->url('temp/'.$pdfNameWithoutExtension.'-0001.jpg'), - 'processId'=>$uuid - ])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => $extMode, + 'result' => true, + 'err_reason' => null, + 'err_api_reason' => null, + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with([ + "stats" => "scs", + "res"=>Storage::disk('local')->url('temp/'.$pdfNameWithoutExtension.'-0001.jpg'), + 'processId'=>$uuid + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } else { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'Failed to download converted file from iLovePDF API !', - 'err_api_reason' => null, - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => $extMode, + 'result' => false, + 'err_reason' => 'Failed to download converted file from iLovePDF API !', + 'err_api_reason' => null, + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } else { return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); @@ -523,162 +744,439 @@ public function pdf_init(Request $request): RedirectResponse{ if(isset($_POST['fileAlt'])) { $pdfUpload_Location = env('PDF_UPLOAD'); $pdfProcessed_Location = env('PDF_DOWNLOAD'); + $pdfEncKey = bin2hex(random_bytes(16)); $file = $request->post('fileAlt'); $pdfName = basename($file); + $pdfNameWithExtension = pathinfo($pdfName, PATHINFO_EXTENSION); $pdfNameWithoutExtension = pathinfo($pdfName, PATHINFO_FILENAME); $pdfNewPath = Storage::disk('local')->path('public/'.$pdfUpload_Location.'/'.$pdfName); $fileSize = filesize($pdfNewPath); - $hostName = AppHelper::instance()->getUserIpAddr(); $newFileSize = AppHelper::instance()->convert($fileSize, "MB"); - try { - $ilovepdfTask = new OfficepdfTask(env('ILOVEPDF_PUBLIC_KEY'),env('ILOVEPDF_SECRET_KEY')); - $ilovepdfTask->setFileEncryption(env('ILOVEPDF_ENC_KEY')); - $pdfFile = $ilovepdfTask->addFile($pdfNewPath); - $ilovepdfTask->setOutputFileName($pdfNameWithoutExtension); - $ilovepdfTask->execute(); - $ilovepdfTask->download(Storage::disk('local')->path('public/'.$pdfProcessed_Location)); - } catch (\Ilovepdf\Exceptions\StartException $e) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on StartException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); - } catch (\Ilovepdf\Exceptions\AuthException $e) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on AuthException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); - } catch (\Ilovepdf\Exceptions\UploadException $e) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on UploadException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); - } catch (\Ilovepdf\Exceptions\ProcessException $e) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on ProcessException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); - } catch (\Ilovepdf\Exceptions\DownloadException $e) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on DownloadException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); - } catch (\Ilovepdf\Exceptions\TaskException $e) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on TaskException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); - } catch (\Ilovepdf\Exceptions\PathException $e) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on PathException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); - } catch (\Exception $e) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on Exception', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + if ($pdfNameWithExtension == "jpg" || $pdfNameWithExtension == "jpeg" || $pdfNameWithExtension == "png" || $pdfNameWithExtension == "tiff") { + try { + $ilovepdfTask = new ImagepdfTask(env('ILOVEPDF_PUBLIC_KEY'),env('ILOVEPDF_SECRET_KEY')); + $ilovepdfTask->setFileEncryption($pdfEncKey); + $ilovepdfTask->setEncryptKey($pdfEncKey); + $ilovepdfTask->setEncryption(true); + $pdfFile = $ilovepdfTask->addFile($pdfNewPath); + $ilovepdfTask->setPageSize('fit'); + $ilovepdfTask->setOutputFileName($pdfNameWithoutExtension); + $ilovepdfTask->setPackagedFilename($pdfNameWithoutExtension); + $ilovepdfTask->execute(); + $ilovepdfTask->download(Storage::disk('local')->path('public/'.$pdfProcessed_Location)); + } catch (\Ilovepdf\Exceptions\StartException $e) { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on StartException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } catch (\Ilovepdf\Exceptions\AuthException $e) { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on AuthException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } catch (\Ilovepdf\Exceptions\UploadException $e) { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on UploadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } catch (\Ilovepdf\Exceptions\ProcessException $e) { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on ProcessException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } catch (\Ilovepdf\Exceptions\DownloadException $e) { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on DownloadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } catch (\Ilovepdf\Exceptions\TaskException $e) { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on TaskException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } catch (\Ilovepdf\Exceptions\PathException $e) { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on PathException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } catch (\Exception $e) { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on Exception', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } + } else { + try { + $ilovepdfTask = new OfficepdfTask(env('ILOVEPDF_PUBLIC_KEY'),env('ILOVEPDF_SECRET_KEY')); + $ilovepdfTask->setFileEncryption(env('ILOVEPDF_ENC_KEY')); + $pdfFile = $ilovepdfTask->addFile($pdfNewPath); + $ilovepdfTask->setOutputFileName($pdfNameWithoutExtension); + $ilovepdfTask->execute(); + $ilovepdfTask->download(Storage::disk('local')->path('public/'.$pdfProcessed_Location)); + } catch (\Ilovepdf\Exceptions\StartException $e) { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on StartException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } catch (\Ilovepdf\Exceptions\AuthException $e) { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on AuthException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } catch (\Ilovepdf\Exceptions\UploadException $e) { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on UploadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } catch (\Ilovepdf\Exceptions\ProcessException $e) { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on ProcessException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } catch (\Ilovepdf\Exceptions\DownloadException $e) { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on DownloadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } catch (\Ilovepdf\Exceptions\TaskException $e) { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on TaskException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } catch (\Ilovepdf\Exceptions\PathException $e) { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on PathException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } catch (\Exception $e) { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on Exception', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Conversion failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } } if (file_exists($pdfNewPath)) { unlink($pdfNewPath); } if (file_exists(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.pdf'))) { - DB::table('pdf_convert')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, - 'result' => true, - 'err_reason' => null, - 'err_api_reason' => null, - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->with([ - "stats" => "scs", - "res"=>Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.pdf') - ]); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => true, + 'err_reason' => 'null', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with([ + "stats" => "scs", + "res"=>Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.pdf') + ]); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } else { + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'container' => $convertType, + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'Failed to download converted file from iLovePDF API !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'Failed to download converted file from iLovePDF API !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } + } else { + try { DB::table('pdf_convert')->insert([ 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'container' => $convertType, + 'fileName' => 'null', + 'fileSize' => 'null', + 'container' => 'null', + 'img_extract' => false, 'result' => false, - 'err_reason' => 'Failed to download converted file from iLovePDF API !', - 'err_api_reason' => null, + 'err_reason' => 'PDF failed to upload !', + 'err_api_reason' => 'null', 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() ]); - return redirect()->back()->withErrors(['error'=>'Failed to download converted file from iLovePDF API !', 'processId'=>$uuid])->withInput(); + return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); } - } else { - return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); } } else { - return redirect()->back()->withErrors(['error'=>'REQUEST_ERROR_OUT_OF_BOUND !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => 'null', + 'fileSize' => 'null', + 'container' => 'null', + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'REQUEST_ERROR_OUT_OF_BOUND !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF process unknown error !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } else { - return redirect()->back()->withErrors(['error'=>'REQUEST_TYPE_NOT_FOUND !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => 'null', + 'fileSize' => 'null', + 'container' => 'null', + 'img_extract' => false, + 'result' => false, + 'err_reason' => 'REQUEST_TYPE_NOT_FOUND !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF process unknown error !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } else { - return redirect()->back()->withErrors(['error'=>'000', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => 'null', + 'fileSize' => 'null', + 'container' => 'null', + 'img_extract' => false, + 'result' => false, + 'err_reason' => '000', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF process unknown error !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } else { - return redirect()->back()->withErrors(['error'=>'0x0', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_convert')->insert([ + 'processId' => $uuid, + 'fileName' => 'null', + 'fileSize' => 'null', + 'container' => 'null', + 'img_extract' => false, + 'result' => false, + 'err_reason' => '0x0', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF process unknown error !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } } diff --git a/app/Http/Controllers/htmltopdfController.php b/app/Http/Controllers/htmltopdfController.php index 4258f454..eec750e5 100644 --- a/app/Http/Controllers/htmltopdfController.php +++ b/app/Http/Controllers/htmltopdfController.php @@ -4,6 +4,8 @@ use App\Helpers\AppHelper; use App\Models\html_pdf; +use App\Models\init_pdf; +use Illuminate\Database\QueryException; use Illuminate\Http\Request; use Illuminate\Http\RedirectResponse; use Illuminate\Support\Facades\DB; @@ -24,12 +26,23 @@ public function html_pdf(Request $request): RedirectResponse{ $uuid = AppHelper::Instance()->get_guid(); if($validator->fails()) { - return redirect()->back()->withErrors(['error'=>$validator->messages(), 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_init')->insert([ + 'processId' => $uuid, + 'err_reason' => $validator->messages(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>$validator->messages(), 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } else { $pdfProcessed_Location = env('PDF_DOWNLOAD'); $pdfUpload_Location = env('PDF_UPLOAD'); + $pdfEncKey = bin2hex(random_bytes(16)); $pdfUrl = $request->post('urlToPDF'); $newUrl = ''; + $str = rand(1000,10000000); if (AppHelper::Instance()->checkWebAvailable($pdfUrl)) { $newUrl = $pdfUrl; } else { @@ -40,126 +53,172 @@ public function html_pdf(Request $request): RedirectResponse{ } else if (AppHelper::Instance()->checkWebAvailable('www.'.$pdfUrl)) { $newUrl = 'www.'.$pdfUrl; } else { - DB::table('pdf_html')->insert([ - 'processId' => $uuid, - 'urlName' => $request->post('urlToPDF'), - 'result' => false, - 'err_reason' => 'URL not valid or not found !', - 'err_api_reason' => '404', - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'URL not valid or not found !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_html')->insert([ + 'processId' => $uuid, + 'urlName' => $request->post('urlToPDF'), + 'result' => false, + 'err_reason' => 'URL not valid or not found !', + 'err_api_reason' => '404', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'URL not valid or not found !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } try { $ilovepdfTask = new HtmlpdfTask(env('ILOVEPDF_PUBLIC_KEY'),env('ILOVEPDF_SECRET_KEY')); - $ilovepdfTask->setFileEncryption(env('ILOVEPDF_ENC_KEY')); + $ilovepdfTask->setFileEncryption($pdfEncKey); + $ilovepdfTask->setEncryptKey($pdfEncKey); + $ilovepdfTask->setEncryption(true); $pdfFile = $ilovepdfTask->addUrl($newUrl); - $ilovepdfTask->setOutputFileName('captured'); + $ilovepdfTask->setOutputFileName('pdf_convert_'.substr(md5(uniqid($str)), 0, 8)); $ilovepdfTask->execute(); $ilovepdfTask->download(Storage::disk('local')->path('public/'.$pdfProcessed_Location)); } catch (\Ilovepdf\Exceptions\StartException $e) { - DB::table('pdf_html')->insert([ - 'processId' => $uuid, - 'urlName' => $newUrl, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on StartException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'HTML To PDF process failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_html')->insert([ + 'processId' => $uuid, + 'urlName' => $newUrl, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on StartException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'HTML To PDF process failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\AuthException $e) { - DB::table('pdf_html')->insert([ - 'processId' => $uuid, - 'urlName' => $newUrl, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on AuthException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'HTML To PDF process failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_html')->insert([ + 'processId' => $uuid, + 'urlName' => $newUrl, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on AuthException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'HTML To PDF process failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\UploadException $e) { - DB::table('pdf_html')->insert([ - 'processId' => $uuid, - 'urlName' => $newUrl, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on UploadException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'HTML To PDF process failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_html')->insert([ + 'processId' => $uuid, + 'urlName' => $newUrl, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on UploadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'HTML To PDF process failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\ProcessException $e) { - DB::table('pdf_html')->insert([ - 'processId' => $uuid, - 'urlName' => $newUrl, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on ProcessException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'HTML To PDF process failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_html')->insert([ + 'processId' => $uuid, + 'urlName' => $newUrl, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on ProcessException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'HTML To PDF process failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\DownloadException $e) { - DB::table('pdf_html')->insert([ - 'processId' => $uuid, - 'urlName' => $newUrl, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on DownloadException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'HTML To PDF process failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_html')->insert([ + 'processId' => $uuid, + 'urlName' => $newUrl, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on DownloadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'HTML To PDF process failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\TaskException $e) { - DB::table('pdf_html')->insert([ - 'processId' => $uuid, - 'urlName' => $newUrl, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on TaskException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'HTML To PDF process failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_html')->insert([ + 'processId' => $uuid, + 'urlName' => $newUrl, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on TaskException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'HTML To PDF process failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\PathException $e) { - DB::table('pdf_html')->insert([ - 'processId' => $uuid, - 'urlName' => $newUrl, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on PathException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'HTML To PDF process failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_html')->insert([ + 'processId' => $uuid, + 'urlName' => $newUrl, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on PathException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'HTML To PDF process failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Exception $e) { - DB::table('pdf_html')->insert([ - 'processId' => $uuid, - 'urlName' => $newUrl, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on Exception', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'HTML To PDF process failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_html')->insert([ + 'processId' => $uuid, + 'urlName' => $newUrl, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on Exception', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'HTML To PDF process failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } - if (file_exists(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/captured.pdf'))) { - $download_pdf = Storage::disk('local')->url($pdfProcessed_Location.'/captured.pdf'); - DB::table('pdf_html')->insert([ - 'processId' => $uuid, - 'urlName' => $newUrl, - 'result' => true, - 'err_reason' => null, - 'err_api_reason' => null, - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->with(["stats" => "scs", "res"=>$download_pdf]); + if (file_exists(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'pdf_convert_'.substr(md5(uniqid($str)), 0, 8)))) { + $download_pdf = Storage::disk('local')->url($pdfProcessed_Location.'pdf_convert_'.substr(md5(uniqid($str)), 0, 8)); + try { + DB::table('pdf_html')->insert([ + 'processId' => $uuid, + 'urlName' => $newUrl, + 'result' => true, + 'err_reason' => 'null', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with(["stats" => "scs", "res"=>$download_pdf]); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } else { - DB::table('pdf_html')->insert([ - 'processId' => $uuid, - 'urlName' => $newUrl, - 'result' => false, - 'err_reason' => 'Failed to download converted file from iLovePDF API !', - 'err_api_reason' => null, - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'HTML To PDF process failed !'])->withInput(); + try { + DB::table('pdf_html')->insert([ + 'processId' => $uuid, + 'urlName' => $newUrl, + 'result' => false, + 'err_reason' => 'Failed to download converted file from iLovePDF API !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'HTML To PDF process failed !'])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } } diff --git a/app/Http/Controllers/mergeController.php b/app/Http/Controllers/mergeController.php index 90e283df..1cf1c8b2 100644 --- a/app/Http/Controllers/mergeController.php +++ b/app/Http/Controllers/mergeController.php @@ -4,7 +4,9 @@ use App\Models\File; use App\Helpers\AppHelper; +use App\Models\init_pdf; use App\Models\merge_pdf; +use Illuminate\Database\QueryException; use Illuminate\Http\Request; use Illuminate\Http\RedirectResponse; use Illuminate\Support\Facades\DB; @@ -26,15 +28,24 @@ public function pdf_merge(Request $request): RedirectResponse{ $uuid = AppHelper::Instance()->get_guid(); if($validator->fails()) { - return redirect()->back()->withErrors(['error'=>$validator->messages(), 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_init')->insert([ + 'processId' => $uuid, + 'err_reason' => $validator->messages(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>$validator->messages(), 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } else { if(isset($_POST['formAction'])) { if($request->post('formAction') == "upload") { if ($request->hasfile('file')) { foreach ($request->file('file') as $file) { - $str = rand(); - $randomizePdfFileName = md5($str); + $str = rand(1000,10000000); + $randomizePdfFileName = 'pdf_merge_'.substr(md5(uniqid($str)), 0, 8); $origFileName = $file->getClientOriginalName(); $file->storeAs('public/'.env('PDF_MERGE_TEMP'), $randomizePdfFileName.'.pdf'); $pdfResponse[] = Storage::disk('local')->url(env('PDF_MERGE_TEMP').'/'.$randomizePdfFileName.'.pdf'); @@ -46,7 +57,20 @@ public function pdf_merge(Request $request): RedirectResponse{ 'pdfOrigName' => implode(',', $pdfOrigNameResponse), ]); } else { - return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_merge')->insert([ + 'processId' => $uuid, + 'fileName' => 'null', + 'fileSize' => 'null', + 'result' => false, + 'err_reason' => 'PDF failed to upload !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } else if ($request->post('formAction') == "merge") { if(isset($_POST['fileAlt'])) { @@ -58,6 +82,7 @@ public function pdf_merge(Request $request): RedirectResponse{ } $str = rand(); $randomizePdfFileName = md5($str); + $pdfEncKey = bin2hex(random_bytes(16)); $fileNameArray = $request->post('fileAlt'); $fileSizeArray = AppHelper::instance()->folderSize(Storage::disk('local')->path('public/'.env('PDF_MERGE_TEMP'))); $fileSizeInMB = AppHelper::instance()->convert($fileSizeArray, "MB"); @@ -68,7 +93,9 @@ public function pdf_merge(Request $request): RedirectResponse{ try { $ilovepdf = new Ilovepdf(env('ILOVEPDF_PUBLIC_KEY'),env('ILOVEPDF_SECRET_KEY')); $ilovepdfTask = $ilovepdf->newTask('merge'); - $ilovepdfTask->setFileEncryption(env('ILOVEPDF_ENC_KEY')); + $ilovepdfTask->setFileEncryption($pdfEncKey); + $ilovepdfTask->setEncryptKey($pdfEncKey); + $ilovepdfTask->setEncryption(true); foreach($pdfArray as $value) { if (strlen($value) >= 4) { $arrayCount = 1; @@ -80,93 +107,125 @@ public function pdf_merge(Request $request): RedirectResponse{ $ilovepdfTask->execute(); $ilovepdfTask->download(Storage::disk('local')->path('public/'.$pdfProcessed_Location)); } catch (\Ilovepdf\Exceptions\StartException $e) { - DB::table('pdf_merge')->insert([ - 'processId' => $uuid, - 'fileName' => $fileNameArray, - 'fileSize' => $fileSizeInMB, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on StartException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Merged failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_merge')->insert([ + 'processId' => $uuid, + 'fileName' => $fileNameArray, + 'fileSize' => $fileSizeInMB, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on StartException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Merged failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\AuthException $e) { - DB::table('pdf_merge')->insert([ - 'processId' => $uuid, - 'fileName' => $fileNameArray, - 'fileSize' => $fileSizeInMB, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on AuthException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Merged failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_merge')->insert([ + 'processId' => $uuid, + 'fileName' => $fileNameArray, + 'fileSize' => $fileSizeInMB, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on AuthException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Merged failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\UploadException $e) { - DB::table('pdf_merge')->insert([ - 'processId' => $uuid, - 'fileName' => $fileNameArray, - 'fileSize' => $fileSizeInMB, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on UploadException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Merged failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_merge')->insert([ + 'processId' => $uuid, + 'fileName' => $fileNameArray, + 'fileSize' => $fileSizeInMB, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on UploadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Merged failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\ProcessException $e) { - DB::table('pdf_merge')->insert([ - 'processId' => $uuid, - 'fileName' => $fileNameArray, - 'fileSize' => $fileSizeInMB, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on ProcessException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Merged failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_merge')->insert([ + 'processId' => $uuid, + 'fileName' => $fileNameArray, + 'fileSize' => $fileSizeInMB, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on ProcessException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Merged failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\DownloadException $e) { - DB::table('pdf_merge')->insert([ - 'processId' => $uuid, - 'fileName' => $fileNameArray, - 'fileSize' => $fileSizeInMB, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on DownloadException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Merged failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_merge')->insert([ + 'processId' => $uuid, + 'fileName' => $fileNameArray, + 'fileSize' => $fileSizeInMB, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on DownloadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Merged failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\TaskException $e) { - DB::table('pdf_merge')->insert([ - 'processId' => $uuid, - 'fileName' => $fileNameArray, - 'fileSize' => $fileSizeInMB, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on TaskException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Merged failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_merge')->insert([ + 'processId' => $uuid, + 'fileName' => $fileNameArray, + 'fileSize' => $fileSizeInMB, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on TaskException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Merged failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\PathException $e) { - DB::table('pdf_merge')->insert([ - 'processId' => $uuid, - 'fileName' => $fileNameArray, - 'fileSize' => $fileSizeInMB, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on PathException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Merged failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_merge')->insert([ + 'processId' => $uuid, + 'fileName' => $fileNameArray, + 'fileSize' => $fileSizeInMB, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on PathException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Merged failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Exception $e) { - DB::table('pdf_merge')->insert([ - 'processId' => $uuid, - 'fileName' => $fileNameArray, - 'fileSize' => $fileSizeInMB, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on Exception', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Merged failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_merge')->insert([ + 'processId' => $uuid, + 'fileName' => $fileNameArray, + 'fileSize' => $fileSizeInMB, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on Exception', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Merged failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } $tempPDFfiles = glob(Storage::disk('local')->path('public/'.$pdfPreProcessed_Location.'/*')); foreach($tempPDFfiles as $file){ @@ -177,46 +236,83 @@ public function pdf_merge(Request $request): RedirectResponse{ if (file_exists(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/merged.pdf'))) { Storage::disk('local')->move('public/'.$pdfProcessed_Location.'/merged.pdf', 'public/'.$pdfProcessed_Location.'/'.$randomizePdfFileName.'.pdf'); $download_pdf = Storage::disk('local')->url($pdfProcessed_Location.'/'.$randomizePdfFileName.'.pdf'); - - DB::table('pdf_merge')->insert([ - 'processId' => $uuid, - 'fileName' => $fileNameArray, - 'fileSize' => $fileSizeInMB, - 'result' => true, - 'err_reason' => null, - 'err_api_reason' => null, - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->with(["stats" => "scs", "res"=>$download_pdf]); + try { + DB::table('pdf_merge')->insert([ + 'processId' => $uuid, + 'fileName' => $fileNameArray, + 'fileSize' => $fileSizeInMB, + 'result' => true, + 'err_reason' => 'null', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with(["stats" => "scs", "res"=>$download_pdf]); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } else { + try { + DB::table('pdf_merge')->insert([ + 'processId' => $uuid, + 'fileName' => $fileNameArray, + 'fileSize' => $fileSizeInMB, + 'result' => false, + 'err_reason' => 'Failed to download file from iLovePDF API !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Merged failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } + } else { + try { DB::table('pdf_merge')->insert([ 'processId' => $uuid, 'fileName' => $fileNameArray, 'fileSize' => $fileSizeInMB, 'result' => false, - 'err_reason' => 'Failed to download file from iLovePDF API !', - 'err_api_reason' => null, + 'err_reason' => 'PDF failed to upload !', + 'err_api_reason' => 'null', 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() ]); - return redirect()->back()->withErrors(['error'=>'PDF Merged failed !', 'processId'=>$uuid])->withInput(); + return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); } - } else { + } + } else { + try { DB::table('pdf_merge')->insert([ 'processId' => $uuid, - 'fileName' => $fileNameArray, - 'fileSize' => $fileSizeInMB, + 'fileName' => 'null', + 'fileSize' => 'null', 'result' => false, - 'err_reason' => 'PDF failed to upload !', - 'err_api_reason' => null, + 'err_reason' => 'INVALID_REQUEST_ERROR !', + 'err_api_reason' => 'null', 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() ]); - return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); - } - } else { - return redirect()->back()->withErrors(['error'=>'INVALID_REQUEST_ERROR !', 'processId'=>$uuid])->withInput(); + return redirect()->back()->withErrors(['error'=>'PDF process unknown error !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } else { - return redirect()->back()->withErrors(['error'=>'REQUEST_ERROR_OUT_OF_BOUND !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_merge')->insert([ + 'processId' => $uuid, + 'fileName' => 'null', + 'fileSize' => 'null', + 'result' => false, + 'err_reason' => 'REQUEST_ERROR_OUT_OF_BOUND !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF process unknown error !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } } diff --git a/app/Http/Controllers/splitController.php b/app/Http/Controllers/splitController.php index 7785d5c1..1a33af28 100644 --- a/app/Http/Controllers/splitController.php +++ b/app/Http/Controllers/splitController.php @@ -3,8 +3,10 @@ namespace App\Http\Controllers; use App\Helpers\AppHelper; -use App\Models\extract_pdf; +use App\Models\delete_pdf; +use App\Models\init_pdf; use App\Models\split_pdf; +use Illuminate\Database\QueryException; use Illuminate\Http\Request; use Illuminate\Http\RedirectResponse; use Illuminate\Support\Facades\DB; @@ -25,16 +27,30 @@ public function pdf_split(Request $request): RedirectResponse{ $uuid = AppHelper::Instance()->get_guid(); if($validator->fails()) { - return redirect()->back()->withErrors(['error'=>$validator->messages(), 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_init')->insert([ + 'processId' => $uuid, + 'err_reason' => $validator->messages(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>$validator->messages(), + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to split !', + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } else { if(isset($_POST['formAction'])) { if($request->post('formAction') == "upload") { if($request->hasfile('file')) { - $str = rand(); + $str = rand(1000,10000000); $pdfUpload_Location = env('PDF_UPLOAD'); $file = $request->file('file'); - $randomizePdfFileName = md5($str); + $fileSize = filesize($file); + $randomizePdfFileName = 'pdf_split_'.substr(md5(uniqid($str)), 0, 8); $randomizePdfPath = $pdfUpload_Location.'/'.$randomizePdfFileName.'.pdf'; $pdfFileName = $file->getClientOriginalName(); $pdfTotalPages = AppHelper::instance()->count($file); @@ -47,10 +63,56 @@ public function pdf_split(Request $request): RedirectResponse{ 'pdfTotalPages' => $pdfTotalPages ]); } else { - return redirect()->back()->withErrors(['error'=>'PDF file not found on the server !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_split')->insert([ + 'processId' => $uuid, + 'fileName' => $randomizePdfFileName.'.pdf', + 'fileSize' => $fileSize, + 'fromPage' => 'null', + 'toPage' => 'null', + 'customPage' => 'null', + 'fixedPage' => 'null', + 'fixedPageRange' => 'null', + 'mergePDF' => 'null', + 'result' => false, + 'err_reason' => 'PDF file not found on the server !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF file not found on the server !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to split !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } else { - return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_split')->insert([ + 'processId' => $uuid, + 'fileName' => 'null', + 'fileSize' => 'null', + 'fromPage' => 'null', + 'toPage' => 'null', + 'customPage' => 'null', + 'fixedPage' => 'null', + 'fixedPageRange' => 'null', + 'mergePDF' => 'null', + 'result' => false, + 'err_reason' => 'PDF failed to upload !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF failed to upload !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to split !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } else if ($request->post('formAction') == "split") { if(isset($_POST['fileAlt'])) { @@ -58,11 +120,7 @@ public function pdf_split(Request $request): RedirectResponse{ $pdfUpload_Location = env('PDF_UPLOAD'); $pdfProcessed_Location = env('PDF_DOWNLOAD'); - $pdfName = basename($file); - $pdfNameWithoutExtension = basename($pdfName, '.pdf'); - $pdfNewPath = Storage::disk('local')->path('public/'.$pdfUpload_Location.'/'.$pdfName); - $fileSize = filesize($pdfNewPath); - $newFileSize = AppHelper::instance()->convert($fileSize, "MB"); + $pdfEncKey = bin2hex(random_bytes(16)); if(isset($_POST['fromPage'])) { $fromPage = $request->post('fromPage'); @@ -103,23 +161,92 @@ public function pdf_split(Request $request): RedirectResponse{ } else { $customPage = ''; } + $pdfName = basename($file); + $pdfNewPath = Storage::disk('local')->path('public/'.$pdfUpload_Location.'/'.$pdfName); + if ($mergePDF) { + $pdfNameWithoutExtension = basename($file, '.pdf'); + } else { + $pdfNameWithoutExtension = basename($pdfName, '.pdf').'_page'; + } + $fileSize = filesize($pdfNewPath); + $newFileSize = AppHelper::instance()->convert($fileSize, "MB"); if ($fromPage != ''){ $pdfTotalPages = AppHelper::instance()->count($pdfNewPath); if ($toPage > $pdfTotalPages) { - return redirect()->back()->withErrors([ - 'error'=>'Last page has more pages than total PDF pages ! (total pages: '.$pdfTotalPages.')', - 'processId'=>$uuid + try { + DB::table('pdf_split')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $fileSize, + 'fromPage' => $fromPage, + 'toPage' => $toPage, + 'customPage' => 'null', + 'fixedPage' => 'null', + 'fixedPageRange' => 'null', + 'mergePDF' => $mergeDBpdf, + 'result' => false, + 'err_reason' => 'Last page has more page than total PDF page ! (total page: '.$pdfTotalPages.')', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'Last page has more page than total PDF page ! (total page: '.$pdfTotalPages.')', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to split !' ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } else if ($fromPage > $pdfTotalPages) { - return redirect()->back()->withErrors([ - 'error'=>'First page has more pages than total PDF pages ! (total pages: '.$pdfTotalPages.')', - 'processId'=>$uuid + try { + DB::table('pdf_split')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $fileSize, + 'fromPage' => $fromPage, + 'toPage' => $toPage, + 'customPage' => 'null', + 'fixedPage' => 'null', + 'fixedPageRange' => 'null', + 'mergePDF' => $mergeDBpdf, + 'result' => false, + 'err_reason' => 'First page has more page than total PDF page ! (total page: '.$pdfTotalPages.')', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'First page has more page than total PDF page ! (total page: '.$pdfTotalPages.')', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to split !' ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } else if ($fromPage > $toPage) { - return redirect()->back()->withErrors([ - 'error'=>'First Page has more pages than last page !', - 'processId'=>$uuid + try { + DB::table('pdf_split')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $fileSize, + 'fromPage' => $fromPage, + 'toPage' => $toPage, + 'customPage' => 'null', + 'fixedPage' => 'null', + 'fixedPageRange' => 'null', + 'mergePDF' => $mergeDBpdf, + 'result' => false, + 'err_reason' => 'First Page has more page than last page ! (total page: '.$pdfTotalPages.')', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'First Page has more page than last page !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to split !' ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } else { if ($mergeDBpdf == "true") { $fixedPageRanges = $fromPage.'-'.$toPage; @@ -140,260 +267,409 @@ public function pdf_split(Request $request): RedirectResponse{ try { $ilovepdf = new Ilovepdf(env('ILOVEPDF_PUBLIC_KEY'),env('ILOVEPDF_SECRET_KEY')); $ilovepdfTask = $ilovepdf->newTask('split'); - $ilovepdfTask->setFileEncryption(env('ILOVEPDF_ENC_KEY')); + $ilovepdfTask->setFileEncryption($pdfEncKey); + $ilovepdfTask->setEncryptKey($pdfEncKey); + $ilovepdfTask->setEncryption(true); $pdfFile = $ilovepdfTask->addFile($pdfNewPath); $ilovepdfTask->setRanges($fixedPageRanges); $ilovepdfTask->setMergeAfter($mergePDF); - $ilovepdfTask->setPackagedFilename($pdfNameWithoutExtension); - $ilovepdfTask->setOutputFileName($pdfNameWithoutExtension); + if ($mergePDF) { + $ilovepdfTask->setPackagedFilename($pdfNameWithoutExtension); + $ilovepdfTask->setOutputFileName($pdfName); + } else { + $altPdfNameWithoutExtension = basename($pdfName, '.pdf'); + $ilovepdfTask->setPackagedFilename($altPdfNameWithoutExtension); + $ilovepdfTask->setOutputFileName($pdfNameWithoutExtension); + } $ilovepdfTask->execute(); $ilovepdfTask->download(Storage::disk('local')->path('public/'.$pdfProcessed_Location)); } catch (\Ilovepdf\Exceptions\StartException $e) { - DB::table('pdf_split')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'fromPage' => $fromPage, - 'toPage' => $toPage, - 'customPage' => $customPage, - 'fixedPage' => $fixedPage, - 'fixedPageRange' => $fixedPageRanges, - 'mergePDF' => $mergeDBpdf, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on StartException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Split failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_split')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'fromPage' => $fromPage, + 'toPage' => $toPage, + 'customPage' => $customPage, + 'fixedPage' => $fixedPage, + 'fixedPageRange' => $fixedPageRanges, + 'mergePDF' => $mergeDBpdf, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on StartException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF split fail !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to split !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\AuthException $e) { - DB::table('pdf_split')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'fromPage' => $fromPage, - 'toPage' => $toPage, - 'customPage' => $customPage, - 'fixedPage' => $fixedPage, - 'fixedPageRange' => $fixedPageRanges, - 'mergePDF' => $mergeDBpdf, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on AuthException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Split failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_split')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'fromPage' => $fromPage, + 'toPage' => $toPage, + 'customPage' => $customPage, + 'fixedPage' => $fixedPage, + 'fixedPageRange' => $fixedPageRanges, + 'mergePDF' => $mergeDBpdf, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on AuthException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF split fail !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to split !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\UploadException $e) { - DB::table('pdf_split')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'fromPage' => $fromPage, - 'toPage' => $toPage, - 'customPage' => $customPage, - 'fixedPage' => $fixedPage, - 'fixedPageRange' => $fixedPageRanges, - 'mergePDF' => $mergeDBpdf, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on UploadException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Split failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_split')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'fromPage' => $fromPage, + 'toPage' => $toPage, + 'customPage' => $customPage, + 'fixedPage' => $fixedPage, + 'fixedPageRange' => $fixedPageRanges, + 'mergePDF' => $mergeDBpdf, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on UploadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF split fail !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to split !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\ProcessException $e) { - DB::table('pdf_split')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'fromPage' => $fromPage, - 'toPage' => $toPage, - 'customPage' => $customPage, - 'fixedPage' => $fixedPage, - 'fixedPageRange' => $fixedPageRanges, - 'mergePDF' => $mergeDBpdf, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on ProcessException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Split failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_split')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'fromPage' => $fromPage, + 'toPage' => $toPage, + 'customPage' => $customPage, + 'fixedPage' => $fixedPage, + 'fixedPageRange' => $fixedPageRanges, + 'mergePDF' => $mergeDBpdf, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on ProcessException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF split fail !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to split !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\DownloadException $e) { - DB::table('pdf_split')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'fromPage' => $fromPage, - 'toPage' => $toPage, - 'customPage' => $customPage, - 'fixedPage' => $fixedPage, - 'fixedPageRange' => $fixedPageRanges, - 'mergePDF' => $mergeDBpdf, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on DownloadException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Split failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_split')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'fromPage' => $fromPage, + 'toPage' => $toPage, + 'customPage' => $customPage, + 'fixedPage' => $fixedPage, + 'fixedPageRange' => $fixedPageRanges, + 'mergePDF' => $mergeDBpdf, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on DownloadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF split fail !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to split !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\TaskException $e) { - DB::table('pdf_split')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'fromPage' => $fromPage, - 'toPage' => $toPage, - 'customPage' => $customPage, - 'fixedPage' => $fixedPage, - 'fixedPageRange' => $fixedPageRanges, - 'mergePDF' => $mergeDBpdf, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on TaskException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Split failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_split')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'fromPage' => $fromPage, + 'toPage' => $toPage, + 'customPage' => $customPage, + 'fixedPage' => $fixedPage, + 'fixedPageRange' => $fixedPageRanges, + 'mergePDF' => $mergeDBpdf, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on TaskException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF split fail !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to split !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\PathException $e) { - DB::table('pdf_split')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'fromPage' => $fromPage, - 'toPage' => $toPage, - 'customPage' => $customPage, - 'fixedPage' => $fixedPage, - 'fixedPageRange' => $fixedPageRanges, - 'mergePDF' => $mergeDBpdf, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on PathException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Split failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_split')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'fromPage' => $fromPage, + 'toPage' => $toPage, + 'customPage' => $customPage, + 'fixedPage' => $fixedPage, + 'fixedPageRange' => $fixedPageRanges, + 'mergePDF' => $mergeDBpdf, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on PathException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF split fail !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to split !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Exception $e) { - DB::table('pdf_split')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'fromPage' => $fromPage, - 'toPage' => $toPage, - 'customPage' => $customPage, - 'fixedPage' => $fixedPage, - 'fixedPageRange' => $fixedPageRanges, - 'mergePDF' => $mergeDBpdf, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on Exception', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Split failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_split')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'fromPage' => $fromPage, + 'toPage' => $toPage, + 'customPage' => $customPage, + 'fixedPage' => $fixedPage, + 'fixedPageRange' => $fixedPageRanges, + 'mergePDF' => $mergeDBpdf, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on Exception', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF split fail !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to split !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } if (file_exists($pdfNewPath)) { unlink($pdfNewPath); } if (file_exists(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.zip'))) { $download_pdf = Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.zip'); - DB::table('pdf_split')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'fromPage' => $fromPage, - 'toPage' => $toPage, - 'customPage' => $customPage, - 'fixedPage' => $fixedPage, - 'fixedPageRange' => $fixedPageRanges, - 'mergePDF' => $mergeDBpdf, - 'result' => true, - 'err_reason' => null, - 'err_api_reason' => null, - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->with([ - "stats" => "scs", - "res"=>$download_pdf, - ]); + try { + DB::table('pdf_split')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'fromPage' => $fromPage, + 'toPage' => $toPage, + 'customPage' => $customPage, + 'fixedPage' => $fixedPage, + 'fixedPageRange' => $fixedPageRanges, + 'mergePDF' => $mergeDBpdf, + 'result' => true, + 'err_reason' => 'null', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with([ + "stats" => "scs", + "res"=>$download_pdf, + "titleMessage"=>"PDF page has successfully splitted !" + ]); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } else if (file_exists(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfName))) { $download_pdf = Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfName); - DB::table('pdf_split')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'fromPage' => $fromPage, - 'toPage' => $toPage, - 'customPage' => $customPage, - 'fixedPage' => $fixedPage, - 'fixedPageRange' => $fixedPageRanges, - 'mergePDF' => $mergeDBpdf, - 'result' => true, - 'err_reason' => null, - 'err_api_reason' => null, - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->with([ - "stats" => "scs", - "res"=>$download_pdf, - ]); + try { + DB::table('pdf_split')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'fromPage' => $fromPage, + 'toPage' => $toPage, + 'customPage' => $customPage, + 'fixedPage' => $fixedPage, + 'fixedPageRange' => $fixedPageRanges, + 'mergePDF' => $mergeDBpdf, + 'result' => true, + 'err_reason' => 'null', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with([ + "stats" => "scs", + "res"=>$download_pdf, + "titleMessage"=>"PDF page has successfully splitted !" + ]); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } else if (file_exists(Storage::disk('local')->path('public/'.$pdfUpload_Location.'/'.$pdfNameWithoutExtension.'.pdf'))) { + $download_pdf = Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.pdf'); + try { + DB::table('pdf_split')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'fromPage' => $fromPage, + 'toPage' => $toPage, + 'customPage' => $customPage, + 'fixedPage' => $fixedPage, + 'fixedPageRange' => $fixedPageRanges, + 'mergePDF' => $mergeDBpdf, + 'result' => true, + 'err_reason' => 'null', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with([ + "stats" => "scs", + "res"=>$download_pdf, + "titleMessage"=>"PDF page has successfully splitted !" + ]); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } else if (file_exists(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.zip'))) { $download_pdf = Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.zip'); + try { + DB::table('pdf_split')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'fromPage' => $fromPage, + 'toPage' => $toPage, + 'customPage' => $customPage, + 'fixedPage' => $fixedPage, + 'fixedPageRange' => $fixedPageRanges, + 'mergePDF' => $mergeDBpdf, + 'result' => true, + 'err_reason' => 'null', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with([ + "stats" => "scs", + "res"=>$download_pdf, + "titleMessage"=>"PDF page has successfully splitted !" + ]); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } else if (file_exists(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$altPdfNameWithoutExtension.'.zip'))) { + $download_pdf = Storage::disk('local')->url($pdfProcessed_Location.'/'.$altPdfNameWithoutExtension.'.zip'); + try { + DB::table('pdf_split')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'fromPage' => $fromPage, + 'toPage' => $toPage, + 'customPage' => $customPage, + 'fixedPage' => $fixedPage, + 'fixedPageRange' => $fixedPageRanges, + 'mergePDF' => $mergeDBpdf, + 'result' => true, + 'err_reason' => 'null', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with([ + "stats" => "scs", + "res"=>$download_pdf, + "titleMessage"=>"PDF page has successfully splitted !" + ]); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } else { + try { + DB::table('pdf_split')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'fromPage' => $fromPage, + 'toPage' => $toPage, + 'customPage' => $customPage, + 'fixedPage' => $fixedPage, + 'fixedPageRange' => $fixedPageRanges, + 'mergePDF' => $mergeDBpdf, + 'result' => false, + 'err_reason' => 'Failed to download file from iLovePDF API !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF split fail !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to split !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } + } else { + try { DB::table('pdf_split')->insert([ 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'fromPage' => $fromPage, - 'toPage' => $toPage, - 'customPage' => $customPage, - 'fixedPage' => $fixedPage, - 'fixedPageRange' => $fixedPageRanges, - 'mergePDF' => $mergeDBpdf, - 'result' => true, - 'err_reason' => null, - 'err_api_reason' => null, - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->with([ - "stats" => "scs", - "res"=>$download_pdf, - ]); - } else if (file_exists(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'-'.$customPage.'.pdf'))) { - $download_pdf = Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'-'.$customPage.'.pdf'); - DB::table('pdf_split')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'fromPage' => $fromPage, - 'toPage' => $toPage, - 'customPage' => $customPage, - 'fixedPage' => $fixedPage, - 'fixedPageRange' => $fixedPageRanges, - 'mergePDF' => $mergeDBpdf, - 'result' => true, - 'err_reason' => null, - 'err_api_reason' => null, - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->with([ - "stats" => "scs", - "res"=>$download_pdf, - ]); - } else { - DB::table('pdf_split')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'fromPage' => $fromPage, - 'toPage' => $toPage, - 'customPage' => $customPage, - 'fixedPage' => $fixedPage, - 'fixedPageRange' => $fixedPageRanges, - 'mergePDF' => $mergeDBpdf, + 'fileName' => 'null', + 'fileSize' => 'null', + 'fromPage' => 'null', + 'toPage' => 'null', + 'customPage' => 'null', + 'fixedPage' => 'null', + 'fixedPageRange' => 'null', + 'mergePDF' => 'null', 'result' => false, - 'err_reason' => 'Failed to download file from iLovePDF API !', - 'err_api_reason' => null, + 'err_reason' => 'PDF page has failed to split !', + 'err_api_reason' => 'null', 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() ]); - return redirect()->back()->withErrors(['error'=>'PDF Split failed !', 'processId'=>$uuid])->withInput(); + return redirect()->back()->withErrors([ + 'error'=>'PDF failed to upload !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to split !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); } - } else { - return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); } - } else if ($request->post('formAction') == "extract") { + } else if ($request->post('formAction') == "delete") { if(isset($_POST['fileAlt'])) { $file = $request->post('fileAlt'); @@ -410,193 +686,377 @@ public function pdf_split(Request $request): RedirectResponse{ } $pdfUpload_Location = env('PDF_UPLOAD'); $pdfProcessed_Location = env('PDF_DOWNLOAD'); + $pdfEncKey = bin2hex(random_bytes(16)); $pdfNewRanges = $customPage; $pdfName = basename($file); - $pdfNameWithoutExtension = basename($pdfName, '.pdf'); $pdfNewPath = Storage::disk('local')->path('public/'.$pdfUpload_Location.'/'.$pdfName); - $fileSize = filesize($pdfNewPath); - $hostName = AppHelper::instance()->getUserIpAddr(); - $newFileSize = AppHelper::instance()->convert($fileSize, "MB"); + $pdfNameWithoutExtension = basename($pdfName, '.pdf'); + $fileSize = filesize($pdfNewPath); + $newFileSize = AppHelper::instance()->convert($fileSize, "MB"); try { $ilovepdf = new Ilovepdf(env('ILOVEPDF_PUBLIC_KEY'),env('ILOVEPDF_SECRET_KEY')); $ilovepdfTask = $ilovepdf->newTask('split'); - $ilovepdfTask->setFileEncryption(env('ILOVEPDF_ENC_KEY')); + $ilovepdfTask->setFileEncryption($pdfEncKey); + $ilovepdfTask->setEncryptKey($pdfEncKey); + $ilovepdfTask->setEncryption(true); $pdfFile = $ilovepdfTask->addFile($pdfNewPath); - $ilovepdfTask->setRanges($pdfNewRanges); - $ilovepdfTask->setMergeAfter(false); + $ilovepdfTask->setRemovePages($pdfNewRanges); $ilovepdfTask->setPackagedFilename($pdfNameWithoutExtension); - $ilovepdfTask->setOutputFileName($pdfNameWithoutExtension); + $ilovepdfTask->setOutputFileName($pdfName); $ilovepdfTask->execute(); $ilovepdfTask->download(Storage::disk('local')->path('public/'.$pdfProcessed_Location)); } catch (\Ilovepdf\Exceptions\StartException $e) { - DB::table('pdf_extract')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'customPage' => $customPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on StartException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Split failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_delete')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'deletePage' => $customPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on StartException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF delete fail !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to delete !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\AuthException $e) { - DB::table('pdf_extract')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'customPage' => $customPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on AuthException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Split failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_delete')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'deletePage' => $customPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on AuthException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF delete fail !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to delete !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\UploadException $e) { - DB::table('pdf_extract')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'customPage' => $customPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on UploadException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Split failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_delete')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'deletePage' => $customPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on UploadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF delete fail !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to delete !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\ProcessException $e) { - DB::table('pdf_extract')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'customPage' => $customPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on ProcessException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Split failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_delete')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'deletePage' => $customPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on ProcessException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF delete fail !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to delete !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\DownloadException $e) { - DB::table('pdf_extract')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'customPage' => $customPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on DownloadException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Split failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_delete')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'deletePage' => $customPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on DownloadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF delete fail !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to delete !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\TaskException $e) { - DB::table('pdf_extract')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'customPage' => $customPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on TaskException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Split failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_delete')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'deletePage' => $customPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on TaskException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF delete fail !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to delete !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\PathException $e) { - DB::table('pdf_extract')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'customPage' => $customPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on PathException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Split failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_delete')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'deletePage' => $customPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on PathException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF delete fail !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to delete !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Exception $e) { - DB::table('pdf_extract')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'customPage' => $customPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error ! Catch on Exception', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Split failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_delete')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'deletePage' => $customPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error ! Catch on Exception', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF delete fail !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to delete !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } if (file_exists($pdfNewPath)) { unlink($pdfNewPath); } - if (file_exists(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfName))) { + if (file_exists(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.zip'))) { + $download_pdf = Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.zip'); + try { + DB::table('pdf_delete')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'deletePage' => $customPage, + 'result' => true, + 'err_reason' => 'null', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with([ + "stats" => "scs", + "res"=>$download_pdf, + "titleMessage"=>"PDF page has successfully deleted !" + ]); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } else if (file_exists(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfName))) { $download_pdf = Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfName); - DB::table('pdf_extract')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'customPage' => $customPage, - 'result' => true, - 'err_reason' => null, - 'err_api_reason' => null, - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->with([ - "stats" => "scs", - "res"=>$download_pdf, - ]); + try { + DB::table('pdf_delete')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'deletePage' => $customPage, + 'result' => true, + 'err_reason' => 'null', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with([ + "stats" => "scs", + "res"=>$download_pdf, + "titleMessage"=>"PDF page has successfully deleted !" + ]); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } else if (file_exists(Storage::disk('local')->path('public/'.$pdfUpload_Location.'/'.$pdfNameWithoutExtension.'.pdf'))) { + $download_pdf = Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.pdf'); + try { + DB::table('pdf_delete')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'deletePage' => $customPage, + 'result' => true, + 'err_reason' => 'null', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with([ + "stats" => "scs", + "res"=>$download_pdf, + "titleMessage"=>"PDF page has successfully deleted !" + ]); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } else if (file_exists(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.zip'))) { $download_pdf = Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'.zip'); - DB::table('pdf_extract')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'customPage' => $customPage, - 'result' => true, - 'err_reason' => null, - 'err_api_reason' => null, - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->with([ - "stats" => "scs", - "res"=>$download_pdf, - ]); - } else if (file_exists(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'-'.$customPage.'.pdf'))) { - $download_pdf = Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfNameWithoutExtension.'-'.$customPage.'.pdf'); - DB::table('pdf_extract')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'customPage' => $customPage, - 'result' => true, - 'err_reason' => null, - 'err_api_reason' => null, - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->with([ - "stats" => "scs", - "res"=>$download_pdf, - ]); - } else { - DB::table('pdf_extract')->insert([ + try { + DB::table('pdf_delete')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'deletePage' => $customPage, + 'result' => true, + 'err_reason' => 'null', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with([ + "stats" => "scs", + "res"=>$download_pdf, + "titleMessage"=>"PDF page has successfully deleted !" + ]); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } else if (file_exists(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$altPdfNameWithoutExtension.'.zip'))) { + $download_pdf = Storage::disk('local')->url($pdfProcessed_Location.'/'.$altPdfNameWithoutExtension.'.zip'); + try { + DB::table('pdf_delete')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'deletePage' => $customPage, + 'result' => true, + 'err_reason' => 'null', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with([ + "stats" => "scs", + "res"=>$download_pdf, + "titleMessage"=>"PDF page has successfully deleted !" + ]); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } else { + try { + DB::table('pdf_delete')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'deletePage' => $customPage, + 'result' => false, + 'err_reason' => 'Failed to download file from iLovePDF API !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'PDF delete fail !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to delete !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } + } else { + try { + DB::table('pdf_delete')->insert([ 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'customPage' => $customPage, + 'fileName' => 'null', + 'fileSize' => 'null', + 'deletePage' => 'null', 'result' => false, - 'err_reason' => 'Failed to download file from iLovePDF API !', - 'err_api_reason' => null, + 'err_reason' => 'PDF page has failed to delete !', + 'err_api_reason' => 'null', 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() ]); - return redirect()->back()->withErrors(['error'=>'PDF Split failed !', 'processId'=>$uuid])->withInput(); + return redirect()->back()->withErrors([ + 'error'=>'PDF failed to upload !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF page has failed to delete !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); } - } else { - return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); } } else { - return redirect()->back()->withErrors(['error'=>'INVALID_REQUEST_ERROR !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_delete')->insert([ + 'processId' => $uuid, + 'fileName' => 'null', + 'fileSize' => 'null', + 'deletePage' => 'null', + 'result' => false, + 'err_reason' => 'INVALID_REQUEST_ERROR !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'INVALID_REQUEST_ERROR !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF process unknown error !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } else { - return redirect()->back()->withErrors(['error'=>'ERROR_OUT_OF_BOUND !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_delete')->insert([ + 'processId' => $uuid, + 'fileName' => 'null', + 'fileSize' => 'null', + 'deletePage' => 'null', + 'result' => false, + 'err_reason' => 'ERROR_OUT_BOUND !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors([ + 'error'=>'ERROR_OUT_BOUND !', + 'processId'=>$uuid, + 'titleMessage'=>'PDF process unknown error !' + ])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } } diff --git a/app/Http/Controllers/watermarkController.php b/app/Http/Controllers/watermarkController.php index 72ce54c3..c140c2de 100644 --- a/app/Http/Controllers/watermarkController.php +++ b/app/Http/Controllers/watermarkController.php @@ -3,7 +3,9 @@ namespace App\Http\Controllers; use App\Helpers\AppHelper; +use App\Models\init_pdf; use App\Models\watermark_pdf; +use Illuminate\Database\QueryException; use Illuminate\Http\Request; use Illuminate\Http\RedirectResponse; use Illuminate\Support\Facades\DB; @@ -29,17 +31,27 @@ public function pdf_watermark(Request $request): RedirectResponse{ $uuid = AppHelper::Instance()->get_guid(); if($validator->fails()) { - return redirect()->back()->withErrors(['error'=>$validator->messages(), 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_init')->insert([ + 'processId' => $uuid, + 'err_reason' => $validator->messages(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>$validator->messages(), 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } else { if(isset($_POST['formAction'])) { if($request->post('formAction') == "upload") { if($request->hasfile('file')) { - $str = rand(); + $str = rand(1000,10000000); $pdfUpload_Location = env('PDF_UPLOAD'); $file = $request->file('file'); - $randomizePdfFileName = md5($str); + $randomizePdfFileName = 'pdf_watermark_'.substr(md5(uniqid($str)), 0, 8); $randomizePdfPath = $pdfUpload_Location.'/'.$randomizePdfFileName.'.pdf'; + $fileSize = filesize($file); $pdfFileName = $file->getClientOriginalName(); $file->storeAs('public/upload-pdf', $randomizePdfFileName.'.pdf'); if (Storage::disk('local')->exists('public/'.$randomizePdfPath)) { @@ -49,10 +61,58 @@ public function pdf_watermark(Request $request): RedirectResponse{ 'pdfOriName' => $pdfFileName, ]); } else { - return redirect()->back()->withErrors(['error'=>'PDF file not found on the server !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => $randomizePdfFileName.'.pdf', + 'fileSize' => $fileSize, + 'watermarkFontFamily' => 'null', + 'watermarkFontStyle' => 'null', + 'watermarkFontSize' => 'null', + 'watermarkFontTransparency' => 'null', + 'watermarkImage' => 'null', + 'watermarkLayout' => 'null', + 'watermarkMosaic' => 'null', + 'watermarkRotation' => 'null', + 'watermarkStyle' => 'null', + 'watermarkText' => 'null', + 'watermarkPage' => 'null', + 'result' => false, + 'err_reason' => 'PDF file not found on the server !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF file not found on the server !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } else { - return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => 'null', + 'fileSize' => 'null', + 'watermarkFontFamily' => 'null', + 'watermarkFontStyle' => 'null', + 'watermarkFontSize' => 'null', + 'watermarkFontTransparency' => 'null', + 'watermarkImage' => 'null', + 'watermarkLayout' => 'null', + 'watermarkMosaic' => 'null', + 'watermarkRotation' => 'null', + 'watermarkStyle' => 'null', + 'watermarkText' => 'null', + 'watermarkPage' => 'null', + 'result' => false, + 'err_reason' => 'PDF failed to upload !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } else if ($request->post('formAction') == "watermark") { if(isset($_POST['fileAlt'])) { @@ -156,6 +216,7 @@ public function pdf_watermark(Request $request): RedirectResponse{ $file = $request->post('fileAlt'); $pdfUpload_Location = env('PDF_UPLOAD'); $pdfProcessed_Location = env('PDF_DOWNLOAD'); + $pdfEncKey = bin2hex(random_bytes(16)); $pdfName = basename($file); $pdfNameWithoutExtention = basename($pdfName, '.pdf'); $pdfNewPath = Storage::disk('local')->path('public/'.$pdfUpload_Location.'/'.$pdfName); @@ -172,7 +233,9 @@ public function pdf_watermark(Request $request): RedirectResponse{ $randomizeImageExtension = pathinfo($watermarkImage->getClientOriginalName(), PATHINFO_EXTENSION); $watermarkImage->storeAs('public/upload-pdf', $randomizeImageFileName.'.'.$randomizeImageExtension); $ilovepdfTask = new WatermarkTask(env('ILOVEPDF_PUBLIC_KEY'),env('ILOVEPDF_SECRET_KEY')); - $ilovepdfTask->setFileEncryption(env('ILOVEPDF_ENC_KEY')); + $ilovepdfTask->setFileEncryption($pdfEncKey); + $ilovepdfTask->setEncryptKey($pdfEncKey); + $ilovepdfTask->setEncryption(true); $pdfFile = $ilovepdfTask->addFile($pdfNewPath); $wmImage = $ilovepdfTask->addElementFile(Storage::disk('local')->path('public/'.$pdfUpload_Location.'/'.$randomizeImageFileName.'.'.$randomizeImageExtension)); $ilovepdfTask->setMode("image"); @@ -185,160 +248,216 @@ public function pdf_watermark(Request $request): RedirectResponse{ $ilovepdfTask->execute(); $ilovepdfTask->download(Storage::disk('local')->path('public/'.$pdfProcessed_Location)); } catch (\Ilovepdf\Exceptions\StartException $e) { - DB::table('pdf_watermark')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'watermarkFontFamily' => $watermarkFontFamily, - 'watermarkFontStyle' => $watermarkFontStyle, - 'watermarkFontSize' => $watermarkFontSize, - 'watermarkFontTransparency' => $watermarkFontTransparency, - 'watermarkImage' => $randomizeImageFileName, - 'watermarkLayout' => $watermarkLayoutStyle, - 'watermarkMosaic' => $isMosaicDB, - 'watermarkRotation' => $watermarkRotation, - 'watermarkStyle' => $watermarkStyle, - 'watermarkText' => $watermarkText, - 'watermarkPage' => $watermarkPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on StartException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'watermarkFontFamily' => $watermarkFontFamily, + 'watermarkFontStyle' => $watermarkFontStyle, + 'watermarkFontSize' => $watermarkFontSize, + 'watermarkFontTransparency' => $watermarkFontTransparency, + 'watermarkImage' => $randomizeImageFileName, + 'watermarkLayout' => $watermarkLayoutStyle, + 'watermarkMosaic' => $isMosaicDB, + 'watermarkRotation' => $watermarkRotation, + 'watermarkStyle' => $watermarkStyle, + 'watermarkText' => $watermarkText, + 'watermarkPage' => $watermarkPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on StartException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\AuthException $e) { - DB::table('pdf_watermark')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'watermarkFontFamily' => $watermarkFontFamily, - 'watermarkFontStyle' => $watermarkFontStyle, - 'watermarkFontSize' => $watermarkFontSize, - 'watermarkFontTransparency' => $watermarkFontTransparency, - 'watermarkImage' => $randomizeImageFileName, - 'watermarkLayout' => $watermarkLayoutStyle, - 'watermarkMosaic' => $isMosaicDB, - 'watermarkRotation' => $watermarkRotation, - 'watermarkStyle' => $watermarkStyle, - 'watermarkText' => $watermarkText, - 'watermarkPage' => $watermarkPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on AuthException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'watermarkFontFamily' => $watermarkFontFamily, + 'watermarkFontStyle' => $watermarkFontStyle, + 'watermarkFontSize' => $watermarkFontSize, + 'watermarkFontTransparency' => $watermarkFontTransparency, + 'watermarkImage' => $randomizeImageFileName, + 'watermarkLayout' => $watermarkLayoutStyle, + 'watermarkMosaic' => $isMosaicDB, + 'watermarkRotation' => $watermarkRotation, + 'watermarkStyle' => $watermarkStyle, + 'watermarkText' => $watermarkText, + 'watermarkPage' => $watermarkPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on AuthException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\UploadException $e) { - DB::table('pdf_watermark')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'watermarkFontFamily' => $watermarkFontFamily, - 'watermarkFontStyle' => $watermarkFontStyle, - 'watermarkFontSize' => $watermarkFontSize, - 'watermarkFontTransparency' => $watermarkFontTransparency, - 'watermarkImage' => $randomizeImageFileName, - 'watermarkLayout' => $watermarkLayoutStyle, - 'watermarkMosaic' => $isMosaicDB, - 'watermarkRotation' => $watermarkRotation, - 'watermarkStyle' => $watermarkStyle, - 'watermarkText' => $watermarkText, - 'watermarkPage' => $watermarkPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on UploadException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'watermarkFontFamily' => $watermarkFontFamily, + 'watermarkFontStyle' => $watermarkFontStyle, + 'watermarkFontSize' => $watermarkFontSize, + 'watermarkFontTransparency' => $watermarkFontTransparency, + 'watermarkImage' => $randomizeImageFileName, + 'watermarkLayout' => $watermarkLayoutStyle, + 'watermarkMosaic' => $isMosaicDB, + 'watermarkRotation' => $watermarkRotation, + 'watermarkStyle' => $watermarkStyle, + 'watermarkText' => $watermarkText, + 'watermarkPage' => $watermarkPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on UploadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\ProcessException $e) { - DB::table('pdf_watermark')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'watermarkFontFamily' => $watermarkFontFamily, - 'watermarkFontStyle' => $watermarkFontStyle, - 'watermarkFontSize' => $watermarkFontSize, - 'watermarkFontTransparency' => $watermarkFontTransparency, - 'watermarkImage' => $randomizeImageFileName, - 'watermarkLayout' => $watermarkLayoutStyle, - 'watermarkMosaic' => $isMosaicDB, - 'watermarkRotation' => $watermarkRotation, - 'watermarkStyle' => $watermarkStyle, - 'watermarkText' => $watermarkText, - 'watermarkPage' => $watermarkPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on ProcessException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'watermarkFontFamily' => $watermarkFontFamily, + 'watermarkFontStyle' => $watermarkFontStyle, + 'watermarkFontSize' => $watermarkFontSize, + 'watermarkFontTransparency' => $watermarkFontTransparency, + 'watermarkImage' => $randomizeImageFileName, + 'watermarkLayout' => $watermarkLayoutStyle, + 'watermarkMosaic' => $isMosaicDB, + 'watermarkRotation' => $watermarkRotation, + 'watermarkStyle' => $watermarkStyle, + 'watermarkText' => $watermarkText, + 'watermarkPage' => $watermarkPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on ProcessException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\DownloadException $e) { - DB::table('pdf_watermark')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'watermarkFontFamily' => $watermarkFontFamily, - 'watermarkFontStyle' => $watermarkFontStyle, - 'watermarkFontSize' => $watermarkFontSize, - 'watermarkFontTransparency' => $watermarkFontTransparency, - 'watermarkImage' => $randomizeImageFileName, - 'watermarkLayout' => $watermarkLayoutStyle, - 'watermarkMosaic' => $isMosaicDB, - 'watermarkRotation' => $watermarkRotation, - 'watermarkStyle' => $watermarkStyle, - 'watermarkText' => $watermarkText, - 'watermarkPage' => $watermarkPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on DownloadException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'watermarkFontFamily' => $watermarkFontFamily, + 'watermarkFontStyle' => $watermarkFontStyle, + 'watermarkFontSize' => $watermarkFontSize, + 'watermarkFontTransparency' => $watermarkFontTransparency, + 'watermarkImage' => $randomizeImageFileName, + 'watermarkLayout' => $watermarkLayoutStyle, + 'watermarkMosaic' => $isMosaicDB, + 'watermarkRotation' => $watermarkRotation, + 'watermarkStyle' => $watermarkStyle, + 'watermarkText' => $watermarkText, + 'watermarkPage' => $watermarkPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on DownloadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\TaskException $e) { - DB::table('pdf_watermark')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'watermarkFontFamily' => $watermarkFontFamily, - 'watermarkFontStyle' => $watermarkFontStyle, - 'watermarkFontSize' => $watermarkFontSize, - 'watermarkFontTransparency' => $watermarkFontTransparency, - 'watermarkImage' => $randomizeImageFileName, - 'watermarkLayout' => $watermarkLayoutStyle, - 'watermarkMosaic' => $isMosaicDB, - 'watermarkRotation' => $watermarkRotation, - 'watermarkStyle' => $watermarkStyle, - 'watermarkText' => $watermarkText, - 'watermarkPage' => $watermarkPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on TaskException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'watermarkFontFamily' => $watermarkFontFamily, + 'watermarkFontStyle' => $watermarkFontStyle, + 'watermarkFontSize' => $watermarkFontSize, + 'watermarkFontTransparency' => $watermarkFontTransparency, + 'watermarkImage' => $randomizeImageFileName, + 'watermarkLayout' => $watermarkLayoutStyle, + 'watermarkMosaic' => $isMosaicDB, + 'watermarkRotation' => $watermarkRotation, + 'watermarkStyle' => $watermarkStyle, + 'watermarkText' => $watermarkText, + 'watermarkPage' => $watermarkPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on TaskException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\PathException $e) { - DB::table('pdf_watermark')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'watermarkFontFamily' => $watermarkFontFamily, - 'watermarkFontStyle' => $watermarkFontStyle, - 'watermarkFontSize' => $watermarkFontSize, - 'watermarkFontTransparency' => $watermarkFontTransparency, - 'watermarkImage' => $randomizeImageFileName, - 'watermarkLayout' => $watermarkLayoutStyle, - 'watermarkMosaic' => $isMosaicDB, - 'watermarkRotation' => $watermarkRotation, - 'watermarkStyle' => $watermarkStyle, - 'watermarkText' => $watermarkText, - 'watermarkPage' => $watermarkPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on PathException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'watermarkFontFamily' => $watermarkFontFamily, + 'watermarkFontStyle' => $watermarkFontStyle, + 'watermarkFontSize' => $watermarkFontSize, + 'watermarkFontTransparency' => $watermarkFontTransparency, + 'watermarkImage' => $randomizeImageFileName, + 'watermarkLayout' => $watermarkLayoutStyle, + 'watermarkMosaic' => $isMosaicDB, + 'watermarkRotation' => $watermarkRotation, + 'watermarkStyle' => $watermarkStyle, + 'watermarkText' => $watermarkText, + 'watermarkPage' => $watermarkPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on PathException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Exception $e) { + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'watermarkFontFamily' => $watermarkFontFamily, + 'watermarkFontStyle' => $watermarkFontStyle, + 'watermarkFontSize' => $watermarkFontSize, + 'watermarkFontTransparency' => $watermarkFontTransparency, + 'watermarkImage' => $randomizeImageFileName, + 'watermarkLayout' => $watermarkLayoutStyle, + 'watermarkMosaic' => $isMosaicDB, + 'watermarkRotation' => $watermarkRotation, + 'watermarkStyle' => $watermarkStyle, + 'watermarkText' => $watermarkText, + 'watermarkPage' => $watermarkPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on Exception', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } + } else { + try { DB::table('pdf_watermark')->insert([ 'processId' => $uuid, 'fileName' => $pdfName, @@ -355,40 +474,22 @@ public function pdf_watermark(Request $request): RedirectResponse{ 'watermarkText' => $watermarkText, 'watermarkPage' => $watermarkPage, 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on Exception', - 'err_api_reason' => $e->getMessage(), + 'err_reason' => 'Image file not found on the server !', + 'err_api_reason' => 'null', 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() ]); - return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + return redirect()->back()->withErrors(['error'=>'Image file not found on the server !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); } - } else { - DB::table('pdf_watermark')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'watermarkFontFamily' => $watermarkFontFamily, - 'watermarkFontStyle' => $watermarkFontStyle, - 'watermarkFontSize' => $watermarkFontSize, - 'watermarkFontTransparency' => $watermarkFontTransparency, - 'watermarkImage' => $randomizeImageFileName, - 'watermarkLayout' => $watermarkLayoutStyle, - 'watermarkMosaic' => $isMosaicDB, - 'watermarkRotation' => $watermarkRotation, - 'watermarkStyle' => $watermarkStyle, - 'watermarkText' => $watermarkText, - 'watermarkPage' => $watermarkPage, - 'result' => false, - 'err_reason' => 'Image file not found on the server !', - 'err_api_reason' => null, - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'Image file not found on the server !', 'processId'=>$uuid])->withInput(); } } else if ($watermarkStyle == "text") { if ($watermarkText != '') { try { $ilovepdfTask = new WatermarkTask(env('ILOVEPDF_PUBLIC_KEY'),env('ILOVEPDF_SECRET_KEY')); - $ilovepdfTask->setFileEncryption(env('ILOVEPDF_ENC_KEY')); + $ilovepdfTask->setFileEncryption($pdfEncKey); + $ilovepdfTask->setEncryptKey($pdfEncKey); + $ilovepdfTask->setEncryption(true); $pdfFile = $ilovepdfTask->addFile($pdfNewPath); $ilovepdfTask->setMode("text"); $ilovepdfTask->setText($watermarkText); @@ -406,160 +507,216 @@ public function pdf_watermark(Request $request): RedirectResponse{ $ilovepdfTask->execute(); $ilovepdfTask->download(Storage::disk('local')->path('public/'.$pdfProcessed_Location)); } catch (\Ilovepdf\Exceptions\StartException $e) { - DB::table('pdf_watermark')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'watermarkFontFamily' => $watermarkFontFamily, - 'watermarkFontStyle' => $watermarkFontStyle, - 'watermarkFontSize' => $watermarkFontSize, - 'watermarkFontTransparency' => $watermarkFontTransparency, - 'watermarkImage' => $randomizeImageFileName, - 'watermarkLayout' => $watermarkLayoutStyle, - 'watermarkMosaic' => $isMosaicDB, - 'watermarkRotation' => $watermarkRotation, - 'watermarkStyle' => $watermarkStyle, - 'watermarkText' => $watermarkText, - 'watermarkPage' => $watermarkPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on StartException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'watermarkFontFamily' => $watermarkFontFamily, + 'watermarkFontStyle' => $watermarkFontStyle, + 'watermarkFontSize' => $watermarkFontSize, + 'watermarkFontTransparency' => $watermarkFontTransparency, + 'watermarkImage' => $randomizeImageFileName, + 'watermarkLayout' => $watermarkLayoutStyle, + 'watermarkMosaic' => $isMosaicDB, + 'watermarkRotation' => $watermarkRotation, + 'watermarkStyle' => $watermarkStyle, + 'watermarkText' => $watermarkText, + 'watermarkPage' => $watermarkPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on StartException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\AuthException $e) { - DB::table('pdf_watermark')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'watermarkFontFamily' => $watermarkFontFamily, - 'watermarkFontStyle' => $watermarkFontStyle, - 'watermarkFontSize' => $watermarkFontSize, - 'watermarkFontTransparency' => $watermarkFontTransparency, - 'watermarkImage' => $randomizeImageFileName, - 'watermarkLayout' => $watermarkLayoutStyle, - 'watermarkMosaic' => $isMosaicDB, - 'watermarkRotation' => $watermarkRotation, - 'watermarkStyle' => $watermarkStyle, - 'watermarkText' => $watermarkText, - 'watermarkPage' => $watermarkPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on AuthException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'watermarkFontFamily' => $watermarkFontFamily, + 'watermarkFontStyle' => $watermarkFontStyle, + 'watermarkFontSize' => $watermarkFontSize, + 'watermarkFontTransparency' => $watermarkFontTransparency, + 'watermarkImage' => $randomizeImageFileName, + 'watermarkLayout' => $watermarkLayoutStyle, + 'watermarkMosaic' => $isMosaicDB, + 'watermarkRotation' => $watermarkRotation, + 'watermarkStyle' => $watermarkStyle, + 'watermarkText' => $watermarkText, + 'watermarkPage' => $watermarkPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on AuthException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\UploadException $e) { - DB::table('pdf_watermark')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'watermarkFontFamily' => $watermarkFontFamily, - 'watermarkFontStyle' => $watermarkFontStyle, - 'watermarkFontSize' => $watermarkFontSize, - 'watermarkFontTransparency' => $watermarkFontTransparency, - 'watermarkImage' => $randomizeImageFileName, - 'watermarkLayout' => $watermarkLayoutStyle, - 'watermarkMosaic' => $isMosaicDB, - 'watermarkRotation' => $watermarkRotation, - 'watermarkStyle' => $watermarkStyle, - 'watermarkText' => $watermarkText, - 'watermarkPage' => $watermarkPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on UploadException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'watermarkFontFamily' => $watermarkFontFamily, + 'watermarkFontStyle' => $watermarkFontStyle, + 'watermarkFontSize' => $watermarkFontSize, + 'watermarkFontTransparency' => $watermarkFontTransparency, + 'watermarkImage' => $randomizeImageFileName, + 'watermarkLayout' => $watermarkLayoutStyle, + 'watermarkMosaic' => $isMosaicDB, + 'watermarkRotation' => $watermarkRotation, + 'watermarkStyle' => $watermarkStyle, + 'watermarkText' => $watermarkText, + 'watermarkPage' => $watermarkPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on UploadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\ProcessException $e) { - DB::table('pdf_watermark')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'watermarkFontFamily' => $watermarkFontFamily, - 'watermarkFontStyle' => $watermarkFontStyle, - 'watermarkFontSize' => $watermarkFontSize, - 'watermarkFontTransparency' => $watermarkFontTransparency, - 'watermarkImage' => $randomizeImageFileName, - 'watermarkLayout' => $watermarkLayoutStyle, - 'watermarkMosaic' => $isMosaicDB, - 'watermarkRotation' => $watermarkRotation, - 'watermarkStyle' => $watermarkStyle, - 'watermarkText' => $watermarkText, - 'watermarkPage' => $watermarkPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on ProcessException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'watermarkFontFamily' => $watermarkFontFamily, + 'watermarkFontStyle' => $watermarkFontStyle, + 'watermarkFontSize' => $watermarkFontSize, + 'watermarkFontTransparency' => $watermarkFontTransparency, + 'watermarkImage' => $randomizeImageFileName, + 'watermarkLayout' => $watermarkLayoutStyle, + 'watermarkMosaic' => $isMosaicDB, + 'watermarkRotation' => $watermarkRotation, + 'watermarkStyle' => $watermarkStyle, + 'watermarkText' => $watermarkText, + 'watermarkPage' => $watermarkPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on ProcessException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\DownloadException $e) { - DB::table('pdf_watermark')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'watermarkFontFamily' => $watermarkFontFamily, - 'watermarkFontStyle' => $watermarkFontStyle, - 'watermarkFontSize' => $watermarkFontSize, - 'watermarkFontTransparency' => $watermarkFontTransparency, - 'watermarkImage' => $randomizeImageFileName, - 'watermarkLayout' => $watermarkLayoutStyle, - 'watermarkMosaic' => $isMosaicDB, - 'watermarkRotation' => $watermarkRotation, - 'watermarkStyle' => $watermarkStyle, - 'watermarkText' => $watermarkText, - 'watermarkPage' => $watermarkPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on DownloadException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'watermarkFontFamily' => $watermarkFontFamily, + 'watermarkFontStyle' => $watermarkFontStyle, + 'watermarkFontSize' => $watermarkFontSize, + 'watermarkFontTransparency' => $watermarkFontTransparency, + 'watermarkImage' => $randomizeImageFileName, + 'watermarkLayout' => $watermarkLayoutStyle, + 'watermarkMosaic' => $isMosaicDB, + 'watermarkRotation' => $watermarkRotation, + 'watermarkStyle' => $watermarkStyle, + 'watermarkText' => $watermarkText, + 'watermarkPage' => $watermarkPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on DownloadException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\TaskException $e) { - DB::table('pdf_watermark')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'watermarkFontFamily' => $watermarkFontFamily, - 'watermarkFontStyle' => $watermarkFontStyle, - 'watermarkFontSize' => $watermarkFontSize, - 'watermarkFontTransparency' => $watermarkFontTransparency, - 'watermarkImage' => $randomizeImageFileName, - 'watermarkLayout' => $watermarkLayoutStyle, - 'watermarkMosaic' => $isMosaicDB, - 'watermarkRotation' => $watermarkRotation, - 'watermarkStyle' => $watermarkStyle, - 'watermarkText' => $watermarkText, - 'watermarkPage' => $watermarkPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on TaskException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'watermarkFontFamily' => $watermarkFontFamily, + 'watermarkFontStyle' => $watermarkFontStyle, + 'watermarkFontSize' => $watermarkFontSize, + 'watermarkFontTransparency' => $watermarkFontTransparency, + 'watermarkImage' => $randomizeImageFileName, + 'watermarkLayout' => $watermarkLayoutStyle, + 'watermarkMosaic' => $isMosaicDB, + 'watermarkRotation' => $watermarkRotation, + 'watermarkStyle' => $watermarkStyle, + 'watermarkText' => $watermarkText, + 'watermarkPage' => $watermarkPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on TaskException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Ilovepdf\Exceptions\PathException $e) { - DB::table('pdf_watermark')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'watermarkFontFamily' => $watermarkFontFamily, - 'watermarkFontStyle' => $watermarkFontStyle, - 'watermarkFontSize' => $watermarkFontSize, - 'watermarkFontTransparency' => $watermarkFontTransparency, - 'watermarkImage' => $randomizeImageFileName, - 'watermarkLayout' => $watermarkLayoutStyle, - 'watermarkMosaic' => $isMosaicDB, - 'watermarkRotation' => $watermarkRotation, - 'watermarkStyle' => $watermarkStyle, - 'watermarkText' => $watermarkText, - 'watermarkPage' => $watermarkPage, - 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on PathException', - 'err_api_reason' => $e->getMessage(), - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'watermarkFontFamily' => $watermarkFontFamily, + 'watermarkFontStyle' => $watermarkFontStyle, + 'watermarkFontSize' => $watermarkFontSize, + 'watermarkFontTransparency' => $watermarkFontTransparency, + 'watermarkImage' => $randomizeImageFileName, + 'watermarkLayout' => $watermarkLayoutStyle, + 'watermarkMosaic' => $isMosaicDB, + 'watermarkRotation' => $watermarkRotation, + 'watermarkStyle' => $watermarkStyle, + 'watermarkText' => $watermarkText, + 'watermarkPage' => $watermarkPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on PathException', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } catch (\Exception $e) { + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => $pdfName, + 'fileSize' => $newFileSize, + 'watermarkFontFamily' => $watermarkFontFamily, + 'watermarkFontStyle' => $watermarkFontStyle, + 'watermarkFontSize' => $watermarkFontSize, + 'watermarkFontTransparency' => $watermarkFontTransparency, + 'watermarkImage' => $randomizeImageFileName, + 'watermarkLayout' => $watermarkLayoutStyle, + 'watermarkMosaic' => $isMosaicDB, + 'watermarkRotation' => $watermarkRotation, + 'watermarkStyle' => $watermarkStyle, + 'watermarkText' => $watermarkText, + 'watermarkPage' => $watermarkPage, + 'result' => false, + 'err_reason' => 'iLovePDF API Error !, Catch on Exception', + 'err_api_reason' => $e->getMessage(), + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } + } else { + try { DB::table('pdf_watermark')->insert([ 'processId' => $uuid, 'fileName' => $pdfName, @@ -576,13 +733,22 @@ public function pdf_watermark(Request $request): RedirectResponse{ 'watermarkText' => $watermarkText, 'watermarkPage' => $watermarkPage, 'result' => false, - 'err_reason' => 'iLovePDF API Error !, Catch on Exception', - 'err_api_reason' => $e->getMessage(), + 'err_reason' => 'Watermark text can not empty !', + 'err_api_reason' => 'null', 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() ]); - return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + return redirect()->back()->withErrors(['error'=>'Watermark text can not empty !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); } - } else { + } + } + if (file_exists($pdfNewPath)) { + unlink($pdfNewPath); + } + if (file_exists(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfName))) { + $download_pdf = Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfName); + try { DB::table('pdf_watermark')->insert([ 'processId' => $uuid, 'fileName' => $pdfName, @@ -598,74 +764,125 @@ public function pdf_watermark(Request $request): RedirectResponse{ 'watermarkStyle' => $watermarkStyle, 'watermarkText' => $watermarkText, 'watermarkPage' => $watermarkPage, + 'result' => true, + 'err_reason' => 'null', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->with([ + "stats" => "scs", + "res"=>$download_pdf, + ]); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } + } else { + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => basename($file), + 'fileSize' => $newFileSize, + 'watermarkFontFamily' => $watermarkFontFamily, + 'watermarkFontStyle' => $watermarkFontStyle, + 'watermarkFontSize' => $watermarkFontSize, + 'watermarkFontTransparency' => $watermarkFontTransparency, + 'watermarkImage' => $randomizeImageFileName, + 'watermarkLayout' => $watermarkLayoutStyle, + 'watermarkMosaic' => $isMosaicDB, + 'watermarkRotation' => $watermarkRotation, + 'watermarkStyle' => $watermarkStyle, + 'watermarkText' => $watermarkText, + 'watermarkPage' => $watermarkPage, 'result' => false, - 'err_reason' => 'Watermark text can not empty !', - 'err_api_reason' => null, + 'err_reason' => 'Failed to download file from iLovePDF API !', + 'err_api_reason' => 'null', 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() ]); - return redirect()->back()->withErrors(['error'=>'Watermark text can not empty !', 'processId'=>$uuid])->withInput(); + return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); } - } - if (file_exists($pdfNewPath)) { - unlink($pdfNewPath); } - if (file_exists(Storage::disk('local')->path('public/'.$pdfProcessed_Location.'/'.$pdfName))) { - $download_pdf = Storage::disk('local')->url($pdfProcessed_Location.'/'.$pdfName); - DB::table('pdf_watermark')->insert([ - 'processId' => $uuid, - 'fileName' => $pdfName, - 'fileSize' => $newFileSize, - 'watermarkFontFamily' => $watermarkFontFamily, - 'watermarkFontStyle' => $watermarkFontStyle, - 'watermarkFontSize' => $watermarkFontSize, - 'watermarkFontTransparency' => $watermarkFontTransparency, - 'watermarkImage' => $randomizeImageFileName, - 'watermarkLayout' => $watermarkLayoutStyle, - 'watermarkMosaic' => $isMosaicDB, - 'watermarkRotation' => $watermarkRotation, - 'watermarkStyle' => $watermarkStyle, - 'watermarkText' => $watermarkText, - 'watermarkPage' => $watermarkPage, - 'result' => true, - 'err_reason' => null, - 'err_api_reason' => null, - 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() - ]); - return redirect()->back()->with([ - "stats" => "scs", - "res"=>$download_pdf, - ]); - } else { + } else { + try { DB::table('pdf_watermark')->insert([ 'processId' => $uuid, - 'fileName' => basename($file), - 'fileSize' => $newFileSize, - 'watermarkFontFamily' => $watermarkFontFamily, - 'watermarkFontStyle' => $watermarkFontStyle, - 'watermarkFontSize' => $watermarkFontSize, - 'watermarkFontTransparency' => $watermarkFontTransparency, - 'watermarkImage' => $randomizeImageFileName, - 'watermarkLayout' => $watermarkLayoutStyle, - 'watermarkMosaic' => $isMosaicDB, - 'watermarkRotation' => $watermarkRotation, - 'watermarkStyle' => $watermarkStyle, - 'watermarkText' => $watermarkText, - 'watermarkPage' => $watermarkPage, + 'fileName' => 'null', + 'fileSize' => 'null', + 'watermarkFontFamily' => 'null', + 'watermarkFontStyle' => 'null', + 'watermarkFontSize' => 'null', + 'watermarkFontTransparency' => 'null', + 'watermarkImage' => 'null', + 'watermarkLayout' => 'null', + 'watermarkMosaic' => 'null', + 'watermarkRotation' => 'null', + 'watermarkStyle' => 'null', + 'watermarkText' => 'null', + 'watermarkPage' => 'null', 'result' => false, - 'err_reason' => 'Failed to download file from iLovePDF API !', - 'err_api_reason' => null, + 'err_reason' => 'PDF failed to upload !', + 'err_api_reason' => 'null', 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() ]); - return redirect()->back()->withErrors(['error'=>'PDF Watermark failed !', 'processId'=>$uuid])->withInput(); + return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); } - } else { - return redirect()->back()->withErrors(['error'=>'PDF failed to upload !', 'processId'=>$uuid])->withInput(); } } else { - return redirect()->back()->withErrors(['error'=>'INVALID_REQUEST_ERROR !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => 'null', + 'fileSize' => 'null', + 'watermarkFontFamily' => 'null', + 'watermarkFontStyle' => 'null', + 'watermarkFontSize' => 'null', + 'watermarkFontTransparency' => 'null', + 'watermarkImage' => 'null', + 'watermarkLayout' => 'null', + 'watermarkMosaic' => 'null', + 'watermarkRotation' => 'null', + 'watermarkStyle' => 'null', + 'watermarkText' => 'null', + 'watermarkPage' => 'null', + 'result' => false, + 'err_reason' => 'INVALID_REQUEST_ERROR !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF process unknown error !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } else { - return redirect()->back()->withErrors(['error'=>'REQUEST_ERROR_OUT_OF_BOUND !', 'processId'=>$uuid])->withInput(); + try { + DB::table('pdf_watermark')->insert([ + 'processId' => $uuid, + 'fileName' => 'null', + 'fileSize' => 'null', + 'watermarkFontFamily' => 'null', + 'watermarkFontStyle' => 'null', + 'watermarkFontSize' => 'null', + 'watermarkFontTransparency' => 'null', + 'watermarkImage' => 'null', + 'watermarkLayout' => 'null', + 'watermarkMosaic' => 'null', + 'watermarkRotation' => 'null', + 'watermarkStyle' => 'null', + 'watermarkText' => 'null', + 'watermarkPage' => 'null', + 'result' => false, + 'err_reason' => 'REQUEST_ERROR_OUT_OF_BOUND !', + 'err_api_reason' => 'null', + 'procStartAt' => AppHelper::instance()->getCurrentTimeZone() + ]); + return redirect()->back()->withErrors(['error'=>'PDF process unknown error !', 'processId'=>$uuid])->withInput(); + } catch (QueryException $ex) { + return redirect()->back()->withErrors(['error'=>'Database connection error !', 'processId'=>'null'])->withInput(); + } } } } diff --git a/app/Models/compression_pdf.php b/app/Models/compression_pdf.php index 47c3e9cc..2e019e8b 100644 --- a/app/Models/compression_pdf.php +++ b/app/Models/compression_pdf.php @@ -16,7 +16,6 @@ class compression_pdf extends Model 'compMethod', 'result', 'err_reason', - 'err_api_reason', - 'uuid' + 'err_api_reason' ]; } diff --git a/app/Models/extract_pdf.php b/app/Models/delete_pdf.php similarity index 75% rename from app/Models/extract_pdf.php rename to app/Models/delete_pdf.php index 980c767d..06f4233e 100644 --- a/app/Models/extract_pdf.php +++ b/app/Models/delete_pdf.php @@ -5,18 +5,17 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; -class extract_pdf extends Model +class delete_pdf extends Model { use HasFactory; protected $fillable = [ 'fileName', 'fileSize', - 'customPage', + 'deletePage', 'mergePDF', 'result', 'err_reason', - 'err_api_reason', - 'uuid' + 'err_api_reason' ]; } diff --git a/app/Models/html_pdf.php b/app/Models/html_pdf.php index 0df94993..e2818257 100644 --- a/app/Models/html_pdf.php +++ b/app/Models/html_pdf.php @@ -13,7 +13,6 @@ class html_pdf extends Model 'urlName', 'result', 'err_reason', - 'err_api_reason', - 'uuid' + 'err_api_reason' ]; } diff --git a/app/Models/init_pdf.php b/app/Models/init_pdf.php new file mode 100644 index 00000000..a4838b3d --- /dev/null +++ b/app/Models/init_pdf.php @@ -0,0 +1,16 @@ +=5.0.0" + }, + "require-dev": { + "doctrine/dbal": "^4.0.0", + "nesbot/carbon": "^2.71.0 || ^3.0.0", + "phpunit/phpunit": "^10.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Carbon\\Doctrine\\": "src/Carbon/Doctrine/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "KyleKatarn", + "email": "kylekatarnls@gmail.com" + } + ], + "description": "Types to use Carbon in Doctrine", + "keywords": [ + "carbon", + "date", + "datetime", + "doctrine", + "time" + ], + "support": { + "issues": "https://github.com/CarbonPHP/carbon-doctrine-types/issues", + "source": "https://github.com/CarbonPHP/carbon-doctrine-types/tree/3.0.0" + }, + "funding": [ + { + "url": "https://github.com/kylekatarnls", + "type": "github" + }, + { + "url": "https://opencollective.com/Carbon", + "type": "open_collective" + }, + { + "url": "https://tidelift.com/funding/github/packagist/nesbot/carbon", + "type": "tidelift" + } + ], + "time": "2023-10-01T14:36:55+00:00" + }, { "name": "dflydev/dot-access-data", "version": "v3.0.2", @@ -526,16 +595,16 @@ }, { "name": "firebase/php-jwt", - "version": "v6.9.0", + "version": "v6.10.0", "source": { "type": "git", "url": "https://github.com/firebase/php-jwt.git", - "reference": "f03270e63eaccf3019ef0f32849c497385774e11" + "reference": "a49db6f0a5033aef5143295342f1c95521b075ff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/firebase/php-jwt/zipball/f03270e63eaccf3019ef0f32849c497385774e11", - "reference": "f03270e63eaccf3019ef0f32849c497385774e11", + "url": "https://api.github.com/repos/firebase/php-jwt/zipball/a49db6f0a5033aef5143295342f1c95521b075ff", + "reference": "a49db6f0a5033aef5143295342f1c95521b075ff", "shasum": "" }, "require": { @@ -583,9 +652,9 @@ ], "support": { "issues": "https://github.com/firebase/php-jwt/issues", - "source": "https://github.com/firebase/php-jwt/tree/v6.9.0" + "source": "https://github.com/firebase/php-jwt/tree/v6.10.0" }, - "time": "2023-10-05T00:24:42+00:00" + "time": "2023-12-01T16:26:39+00:00" }, { "name": "fruitcake/php-cors", @@ -722,16 +791,16 @@ }, { "name": "guzzlehttp/guzzle", - "version": "7.8.0", + "version": "7.8.1", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "1110f66a6530a40fe7aea0378fe608ee2b2248f9" + "reference": "41042bc7ab002487b876a0683fc8dce04ddce104" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/1110f66a6530a40fe7aea0378fe608ee2b2248f9", - "reference": "1110f66a6530a40fe7aea0378fe608ee2b2248f9", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/41042bc7ab002487b876a0683fc8dce04ddce104", + "reference": "41042bc7ab002487b876a0683fc8dce04ddce104", "shasum": "" }, "require": { @@ -746,11 +815,11 @@ "psr/http-client-implementation": "1.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.1", + "bamarni/composer-bin-plugin": "^1.8.2", "ext-curl": "*", "php-http/client-integration-tests": "dev-master#2c025848417c1135031fdf9c728ee53d0a7ceaee as 3.0.999", "php-http/message-factory": "^1.1", - "phpunit/phpunit": "^8.5.29 || ^9.5.23", + "phpunit/phpunit": "^8.5.36 || ^9.6.15", "psr/log": "^1.1 || ^2.0 || ^3.0" }, "suggest": { @@ -828,7 +897,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.8.0" + "source": "https://github.com/guzzle/guzzle/tree/7.8.1" }, "funding": [ { @@ -844,28 +913,28 @@ "type": "tidelift" } ], - "time": "2023-08-27T10:20:53+00:00" + "time": "2023-12-03T20:35:24+00:00" }, { "name": "guzzlehttp/promises", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "111166291a0f8130081195ac4556a5587d7f1b5d" + "reference": "bbff78d96034045e58e13dedd6ad91b5d1253223" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/111166291a0f8130081195ac4556a5587d7f1b5d", - "reference": "111166291a0f8130081195ac4556a5587d7f1b5d", + "url": "https://api.github.com/repos/guzzle/promises/zipball/bbff78d96034045e58e13dedd6ad91b5d1253223", + "reference": "bbff78d96034045e58e13dedd6ad91b5d1253223", "shasum": "" }, "require": { "php": "^7.2.5 || ^8.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.1", - "phpunit/phpunit": "^8.5.29 || ^9.5.23" + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.36 || ^9.6.15" }, "type": "library", "extra": { @@ -911,7 +980,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.0.1" + "source": "https://github.com/guzzle/promises/tree/2.0.2" }, "funding": [ { @@ -927,20 +996,20 @@ "type": "tidelift" } ], - "time": "2023-08-03T15:11:55+00:00" + "time": "2023-12-03T20:19:20+00:00" }, { "name": "guzzlehttp/psr7", - "version": "2.6.1", + "version": "2.6.2", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "be45764272e8873c72dbe3d2edcfdfcc3bc9f727" + "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/be45764272e8873c72dbe3d2edcfdfcc3bc9f727", - "reference": "be45764272e8873c72dbe3d2edcfdfcc3bc9f727", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/45b30f99ac27b5ca93cb4831afe16285f57b8221", + "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221", "shasum": "" }, "require": { @@ -954,9 +1023,9 @@ "psr/http-message-implementation": "1.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.1", + "bamarni/composer-bin-plugin": "^1.8.2", "http-interop/http-factory-tests": "^0.9", - "phpunit/phpunit": "^8.5.29 || ^9.5.23" + "phpunit/phpunit": "^8.5.36 || ^9.6.15" }, "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" @@ -1027,7 +1096,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.6.1" + "source": "https://github.com/guzzle/psr7/tree/2.6.2" }, "funding": [ { @@ -1043,32 +1112,38 @@ "type": "tidelift" } ], - "time": "2023-08-27T10:13:57+00:00" + "time": "2023-12-03T20:05:35+00:00" }, { "name": "guzzlehttp/uri-template", - "version": "v1.0.2", + "version": "v1.0.3", "source": { "type": "git", "url": "https://github.com/guzzle/uri-template.git", - "reference": "61bf437fc2197f587f6857d3ff903a24f1731b5d" + "reference": "ecea8feef63bd4fef1f037ecb288386999ecc11c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/uri-template/zipball/61bf437fc2197f587f6857d3ff903a24f1731b5d", - "reference": "61bf437fc2197f587f6857d3ff903a24f1731b5d", + "url": "https://api.github.com/repos/guzzle/uri-template/zipball/ecea8feef63bd4fef1f037ecb288386999ecc11c", + "reference": "ecea8feef63bd4fef1f037ecb288386999ecc11c", "shasum": "" }, "require": { "php": "^7.2.5 || ^8.0", - "symfony/polyfill-php80": "^1.17" + "symfony/polyfill-php80": "^1.24" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.1", - "phpunit/phpunit": "^8.5.19 || ^9.5.8", + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.36 || ^9.6.15", "uri-template/tests": "1.0.0" }, "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, "autoload": { "psr-4": { "GuzzleHttp\\UriTemplate\\": "src" @@ -1107,7 +1182,7 @@ ], "support": { "issues": "https://github.com/guzzle/uri-template/issues", - "source": "https://github.com/guzzle/uri-template/tree/v1.0.2" + "source": "https://github.com/guzzle/uri-template/tree/v1.0.3" }, "funding": [ { @@ -1123,7 +1198,7 @@ "type": "tidelift" } ], - "time": "2023-08-27T10:19:19+00:00" + "time": "2023-12-03T19:50:20+00:00" }, { "name": "ilovepdf/ilovepdf-php", @@ -1175,16 +1250,16 @@ }, { "name": "laravel/framework", - "version": "v10.31.0", + "version": "v10.35.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "507ce9b28bce4b5e4140c28943092ca38e9a52e4" + "reference": "91ec2d92d2f6007e9084fe06438b99c91845da69" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/507ce9b28bce4b5e4140c28943092ca38e9a52e4", - "reference": "507ce9b28bce4b5e4140c28943092ca38e9a52e4", + "url": "https://api.github.com/repos/laravel/framework/zipball/91ec2d92d2f6007e9084fe06438b99c91845da69", + "reference": "91ec2d92d2f6007e9084fe06438b99c91845da69", "shasum": "" }, "require": { @@ -1217,7 +1292,7 @@ "symfony/console": "^6.2", "symfony/error-handler": "^6.2", "symfony/finder": "^6.2", - "symfony/http-foundation": "^6.3", + "symfony/http-foundation": "^6.4", "symfony/http-kernel": "^6.2", "symfony/mailer": "^6.2", "symfony/mime": "^6.2", @@ -1285,7 +1360,7 @@ "league/flysystem-sftp-v3": "^3.0", "mockery/mockery": "^1.5.1", "nyholm/psr7": "^1.2", - "orchestra/testbench-core": "^8.12", + "orchestra/testbench-core": "^8.15.1", "pda/pheanstalk": "^4.0", "phpstan/phpstan": "^1.4.7", "phpunit/phpunit": "^10.0.7", @@ -1373,7 +1448,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2023-11-07T13:48:30+00:00" + "time": "2023-12-05T14:50:33+00:00" }, { "name": "laravel/prompts", @@ -1500,16 +1575,16 @@ }, { "name": "laravel/serializable-closure", - "version": "v1.3.2", + "version": "v1.3.3", "source": { "type": "git", "url": "https://github.com/laravel/serializable-closure.git", - "reference": "076fe2cf128bd54b4341cdc6d49b95b34e101e4c" + "reference": "3dbf8a8e914634c48d389c1234552666b3d43754" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/076fe2cf128bd54b4341cdc6d49b95b34e101e4c", - "reference": "076fe2cf128bd54b4341cdc6d49b95b34e101e4c", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/3dbf8a8e914634c48d389c1234552666b3d43754", + "reference": "3dbf8a8e914634c48d389c1234552666b3d43754", "shasum": "" }, "require": { @@ -1556,7 +1631,7 @@ "issues": "https://github.com/laravel/serializable-closure/issues", "source": "https://github.com/laravel/serializable-closure" }, - "time": "2023-10-17T13:38:16+00:00" + "time": "2023-11-08T14:08:06+00:00" }, { "name": "laravel/tinker", @@ -1817,16 +1892,16 @@ }, { "name": "league/flysystem", - "version": "3.19.0", + "version": "3.23.0", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "1b2aa10f2326e0351399b8ce68e287d8e9209a83" + "reference": "d4ad81e2b67396e33dc9d7e54ec74ccf73151dcc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/1b2aa10f2326e0351399b8ce68e287d8e9209a83", - "reference": "1b2aa10f2326e0351399b8ce68e287d8e9209a83", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/d4ad81e2b67396e33dc9d7e54ec74ccf73151dcc", + "reference": "d4ad81e2b67396e33dc9d7e54ec74ccf73151dcc", "shasum": "" }, "require": { @@ -1854,7 +1929,7 @@ "friendsofphp/php-cs-fixer": "^3.5", "google/cloud-storage": "^1.23", "microsoft/azure-storage-blob": "^1.1", - "phpseclib/phpseclib": "^3.0.14", + "phpseclib/phpseclib": "^3.0.34", "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^9.5.11|^10.0", "sabre/dav": "^4.3.1" @@ -1891,7 +1966,7 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem/issues", - "source": "https://github.com/thephpleague/flysystem/tree/3.19.0" + "source": "https://github.com/thephpleague/flysystem/tree/3.23.0" }, "funding": [ { @@ -1903,20 +1978,20 @@ "type": "github" } ], - "time": "2023-11-07T09:04:28+00:00" + "time": "2023-12-04T10:16:17+00:00" }, { "name": "league/flysystem-local", - "version": "3.19.0", + "version": "3.23.0", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem-local.git", - "reference": "8d868217f9eeb4e9a7320db5ccad825e9a7a4076" + "reference": "5cf046ba5f059460e86a997c504dd781a39a109b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/8d868217f9eeb4e9a7320db5ccad825e9a7a4076", - "reference": "8d868217f9eeb4e9a7320db5ccad825e9a7a4076", + "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/5cf046ba5f059460e86a997c504dd781a39a109b", + "reference": "5cf046ba5f059460e86a997c504dd781a39a109b", "shasum": "" }, "require": { @@ -1951,7 +2026,7 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem-local/issues", - "source": "https://github.com/thephpleague/flysystem-local/tree/3.19.0" + "source": "https://github.com/thephpleague/flysystem-local/tree/3.23.0" }, "funding": [ { @@ -1963,7 +2038,7 @@ "type": "github" } ], - "time": "2023-11-06T20:35:28+00:00" + "time": "2023-12-04T10:14:46+00:00" }, { "name": "league/mime-type-detection", @@ -2124,19 +2199,20 @@ }, { "name": "nesbot/carbon", - "version": "2.71.0", + "version": "2.72.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "98276233188583f2ff845a0f992a235472d9466a" + "reference": "a6885fcbad2ec4360b0e200ee0da7d9b7c90786b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/98276233188583f2ff845a0f992a235472d9466a", - "reference": "98276233188583f2ff845a0f992a235472d9466a", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/a6885fcbad2ec4360b0e200ee0da7d9b7c90786b", + "reference": "a6885fcbad2ec4360b0e200ee0da7d9b7c90786b", "shasum": "" }, "require": { + "carbonphp/carbon-doctrine-types": "*", "ext-json": "*", "php": "^7.1.8 || ^8.0", "psr/clock": "^1.0", @@ -2148,8 +2224,8 @@ "psr/clock-implementation": "1.0" }, "require-dev": { - "doctrine/dbal": "^2.0 || ^3.1.4", - "doctrine/orm": "^2.7", + "doctrine/dbal": "^2.0 || ^3.1.4 || ^4.0", + "doctrine/orm": "^2.7 || ^3.0", "friendsofphp/php-cs-fixer": "^3.0", "kylekatarnls/multi-tester": "^2.0", "ondrejmirtes/better-reflection": "*", @@ -2226,7 +2302,7 @@ "type": "tidelift" } ], - "time": "2023-09-25T11:31:05+00:00" + "time": "2023-11-28T10:13:25+00:00" }, { "name": "nette/schema", @@ -2712,16 +2788,16 @@ }, { "name": "phpseclib/phpseclib", - "version": "3.0.33", + "version": "3.0.34", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "33fa69b2514a61138dd48e7a49f99445711e0ad0" + "reference": "56c79f16a6ae17e42089c06a2144467acc35348a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/33fa69b2514a61138dd48e7a49f99445711e0ad0", - "reference": "33fa69b2514a61138dd48e7a49f99445711e0ad0", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/56c79f16a6ae17e42089c06a2144467acc35348a", + "reference": "56c79f16a6ae17e42089c06a2144467acc35348a", "shasum": "" }, "require": { @@ -2802,7 +2878,7 @@ ], "support": { "issues": "https://github.com/phpseclib/phpseclib/issues", - "source": "https://github.com/phpseclib/phpseclib/tree/3.0.33" + "source": "https://github.com/phpseclib/phpseclib/tree/3.0.34" }, "funding": [ { @@ -2818,7 +2894,7 @@ "type": "tidelift" } ], - "time": "2023-10-21T14:00:39+00:00" + "time": "2023-11-27T11:13:31+00:00" }, { "name": "psr/clock", @@ -3537,78 +3613,18 @@ ], "time": "2023-11-08T05:53:05+00:00" }, - { - "name": "spatie/pdf-to-image", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/spatie/pdf-to-image.git", - "reference": "9b8d5bae5b77f6023e87b2401028e52b7addbd48" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/spatie/pdf-to-image/zipball/9b8d5bae5b77f6023e87b2401028e52b7addbd48", - "reference": "9b8d5bae5b77f6023e87b2401028e52b7addbd48", - "shasum": "" - }, - "require": { - "ext-imagick": "*", - "php": "^7.2|^8.0" - }, - "require-dev": { - "pestphp/pest": "^1.21" - }, - "type": "library", - "autoload": { - "psr-4": { - "Spatie\\PdfToImage\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Freek Van der Herten", - "email": "freek@spatie.be", - "homepage": "https://spatie.be", - "role": "Developer" - } - ], - "description": "Convert a pdf to an image", - "homepage": "https://github.com/spatie/pdf-to-image", - "keywords": [ - "convert", - "image", - "pdf", - "pdf-to-image", - "spatie" - ], - "support": { - "issues": "https://github.com/spatie/pdf-to-image/issues", - "source": "https://github.com/spatie/pdf-to-image/tree/2.2.0" - }, - "funding": [ - { - "url": "https://github.com/spatie", - "type": "github" - } - ], - "time": "2022-03-08T07:52:26+00:00" - }, { "name": "symfony/console", - "version": "v6.3.8", + "version": "v6.4.1", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "0d14a9f6d04d4ac38a8cea1171f4554e325dae92" + "reference": "a550a7c99daeedef3f9d23fb82e3531525ff11fd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/0d14a9f6d04d4ac38a8cea1171f4554e325dae92", - "reference": "0d14a9f6d04d4ac38a8cea1171f4554e325dae92", + "url": "https://api.github.com/repos/symfony/console/zipball/a550a7c99daeedef3f9d23fb82e3531525ff11fd", + "reference": "a550a7c99daeedef3f9d23fb82e3531525ff11fd", "shasum": "" }, "require": { @@ -3616,7 +3632,7 @@ "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-mbstring": "~1.0", "symfony/service-contracts": "^2.5|^3", - "symfony/string": "^5.4|^6.0" + "symfony/string": "^5.4|^6.0|^7.0" }, "conflict": { "symfony/dependency-injection": "<5.4", @@ -3630,12 +3646,16 @@ }, "require-dev": { "psr/log": "^1|^2|^3", - "symfony/config": "^5.4|^6.0", - "symfony/dependency-injection": "^5.4|^6.0", - "symfony/event-dispatcher": "^5.4|^6.0", - "symfony/lock": "^5.4|^6.0", - "symfony/process": "^5.4|^6.0", - "symfony/var-dumper": "^5.4|^6.0" + "symfony/config": "^5.4|^6.0|^7.0", + "symfony/dependency-injection": "^5.4|^6.0|^7.0", + "symfony/event-dispatcher": "^5.4|^6.0|^7.0", + "symfony/http-foundation": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/lock": "^5.4|^6.0|^7.0", + "symfony/messenger": "^5.4|^6.0|^7.0", + "symfony/process": "^5.4|^6.0|^7.0", + "symfony/stopwatch": "^5.4|^6.0|^7.0", + "symfony/var-dumper": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -3669,7 +3689,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.3.8" + "source": "https://github.com/symfony/console/tree/v6.4.1" }, "funding": [ { @@ -3685,20 +3705,20 @@ "type": "tidelift" } ], - "time": "2023-10-31T08:09:35+00:00" + "time": "2023-11-30T10:54:28+00:00" }, { "name": "symfony/css-selector", - "version": "v6.3.2", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "883d961421ab1709877c10ac99451632a3d6fa57" + "reference": "d036c6c0d0b09e24a14a35f8292146a658f986e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/883d961421ab1709877c10ac99451632a3d6fa57", - "reference": "883d961421ab1709877c10ac99451632a3d6fa57", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/d036c6c0d0b09e24a14a35f8292146a658f986e4", + "reference": "d036c6c0d0b09e24a14a35f8292146a658f986e4", "shasum": "" }, "require": { @@ -3734,7 +3754,7 @@ "description": "Converts CSS selectors to XPath expressions", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/css-selector/tree/v6.3.2" + "source": "https://github.com/symfony/css-selector/tree/v6.4.0" }, "funding": [ { @@ -3750,11 +3770,11 @@ "type": "tidelift" } ], - "time": "2023-07-12T16:00:22+00:00" + "time": "2023-10-31T08:40:20+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v3.3.0", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", @@ -3801,7 +3821,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.4.0" }, "funding": [ { @@ -3821,30 +3841,31 @@ }, { "name": "symfony/error-handler", - "version": "v6.3.5", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/error-handler.git", - "reference": "1f69476b64fb47105c06beef757766c376b548c4" + "reference": "c873490a1c97b3a0a4838afc36ff36c112d02788" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/error-handler/zipball/1f69476b64fb47105c06beef757766c376b548c4", - "reference": "1f69476b64fb47105c06beef757766c376b548c4", + "url": "https://api.github.com/repos/symfony/error-handler/zipball/c873490a1c97b3a0a4838afc36ff36c112d02788", + "reference": "c873490a1c97b3a0a4838afc36ff36c112d02788", "shasum": "" }, "require": { "php": ">=8.1", "psr/log": "^1|^2|^3", - "symfony/var-dumper": "^5.4|^6.0" + "symfony/var-dumper": "^5.4|^6.0|^7.0" }, "conflict": { - "symfony/deprecation-contracts": "<2.5" + "symfony/deprecation-contracts": "<2.5", + "symfony/http-kernel": "<6.4" }, "require-dev": { "symfony/deprecation-contracts": "^2.5|^3", - "symfony/http-kernel": "^5.4|^6.0", - "symfony/serializer": "^5.4|^6.0" + "symfony/http-kernel": "^6.4|^7.0", + "symfony/serializer": "^5.4|^6.0|^7.0" }, "bin": [ "Resources/bin/patch-type-declarations" @@ -3875,7 +3896,7 @@ "description": "Provides tools to manage errors and ease debugging PHP code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/error-handler/tree/v6.3.5" + "source": "https://github.com/symfony/error-handler/tree/v6.4.0" }, "funding": [ { @@ -3891,20 +3912,20 @@ "type": "tidelift" } ], - "time": "2023-09-12T06:57:20+00:00" + "time": "2023-10-18T09:43:34+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v6.3.2", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "adb01fe097a4ee930db9258a3cc906b5beb5cf2e" + "reference": "d76d2632cfc2206eecb5ad2b26cd5934082941b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/adb01fe097a4ee930db9258a3cc906b5beb5cf2e", - "reference": "adb01fe097a4ee930db9258a3cc906b5beb5cf2e", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d76d2632cfc2206eecb5ad2b26cd5934082941b6", + "reference": "d76d2632cfc2206eecb5ad2b26cd5934082941b6", "shasum": "" }, "require": { @@ -3921,13 +3942,13 @@ }, "require-dev": { "psr/log": "^1|^2|^3", - "symfony/config": "^5.4|^6.0", - "symfony/dependency-injection": "^5.4|^6.0", - "symfony/error-handler": "^5.4|^6.0", - "symfony/expression-language": "^5.4|^6.0", - "symfony/http-foundation": "^5.4|^6.0", + "symfony/config": "^5.4|^6.0|^7.0", + "symfony/dependency-injection": "^5.4|^6.0|^7.0", + "symfony/error-handler": "^5.4|^6.0|^7.0", + "symfony/expression-language": "^5.4|^6.0|^7.0", + "symfony/http-foundation": "^5.4|^6.0|^7.0", "symfony/service-contracts": "^2.5|^3", - "symfony/stopwatch": "^5.4|^6.0" + "symfony/stopwatch": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -3955,7 +3976,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v6.3.2" + "source": "https://github.com/symfony/event-dispatcher/tree/v6.4.0" }, "funding": [ { @@ -3971,11 +3992,11 @@ "type": "tidelift" } ], - "time": "2023-07-06T06:56:43+00:00" + "time": "2023-07-27T06:52:43+00:00" }, { "name": "symfony/event-dispatcher-contracts", - "version": "v3.3.0", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", @@ -4031,7 +4052,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.3.0" + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.4.0" }, "funding": [ { @@ -4051,23 +4072,23 @@ }, { "name": "symfony/finder", - "version": "v6.3.5", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "a1b31d88c0e998168ca7792f222cbecee47428c4" + "reference": "11d736e97f116ac375a81f96e662911a34cd50ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/a1b31d88c0e998168ca7792f222cbecee47428c4", - "reference": "a1b31d88c0e998168ca7792f222cbecee47428c4", + "url": "https://api.github.com/repos/symfony/finder/zipball/11d736e97f116ac375a81f96e662911a34cd50ce", + "reference": "11d736e97f116ac375a81f96e662911a34cd50ce", "shasum": "" }, "require": { "php": ">=8.1" }, "require-dev": { - "symfony/filesystem": "^6.0" + "symfony/filesystem": "^6.0|^7.0" }, "type": "library", "autoload": { @@ -4095,7 +4116,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v6.3.5" + "source": "https://github.com/symfony/finder/tree/v6.4.0" }, "funding": [ { @@ -4111,20 +4132,20 @@ "type": "tidelift" } ], - "time": "2023-09-26T12:56:25+00:00" + "time": "2023-10-31T17:30:12+00:00" }, { "name": "symfony/http-foundation", - "version": "v6.3.8", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "ce332676de1912c4389222987193c3ef38033df6" + "reference": "44a6d39a9cc11e154547d882d5aac1e014440771" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/ce332676de1912c4389222987193c3ef38033df6", - "reference": "ce332676de1912c4389222987193c3ef38033df6", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/44a6d39a9cc11e154547d882d5aac1e014440771", + "reference": "44a6d39a9cc11e154547d882d5aac1e014440771", "shasum": "" }, "require": { @@ -4139,12 +4160,12 @@ "require-dev": { "doctrine/dbal": "^2.13.1|^3|^4", "predis/predis": "^1.1|^2.0", - "symfony/cache": "^6.3", - "symfony/dependency-injection": "^5.4|^6.0", - "symfony/expression-language": "^5.4|^6.0", - "symfony/http-kernel": "^5.4.12|^6.0.12|^6.1.4", - "symfony/mime": "^5.4|^6.0", - "symfony/rate-limiter": "^5.2|^6.0" + "symfony/cache": "^6.3|^7.0", + "symfony/dependency-injection": "^5.4|^6.0|^7.0", + "symfony/expression-language": "^5.4|^6.0|^7.0", + "symfony/http-kernel": "^5.4.12|^6.0.12|^6.1.4|^7.0", + "symfony/mime": "^5.4|^6.0|^7.0", + "symfony/rate-limiter": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -4172,7 +4193,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v6.3.8" + "source": "https://github.com/symfony/http-foundation/tree/v6.4.0" }, "funding": [ { @@ -4188,29 +4209,29 @@ "type": "tidelift" } ], - "time": "2023-11-07T10:17:15+00:00" + "time": "2023-11-20T16:41:16+00:00" }, { "name": "symfony/http-kernel", - "version": "v6.3.8", + "version": "v6.4.1", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "929202375ccf44a309c34aeca8305408442ebcc1" + "reference": "2953274c16a229b3933ef73a6898e18388e12e1b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/929202375ccf44a309c34aeca8305408442ebcc1", - "reference": "929202375ccf44a309c34aeca8305408442ebcc1", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/2953274c16a229b3933ef73a6898e18388e12e1b", + "reference": "2953274c16a229b3933ef73a6898e18388e12e1b", "shasum": "" }, "require": { "php": ">=8.1", "psr/log": "^1|^2|^3", "symfony/deprecation-contracts": "^2.5|^3", - "symfony/error-handler": "^6.3", - "symfony/event-dispatcher": "^5.4|^6.0", - "symfony/http-foundation": "^6.3.4", + "symfony/error-handler": "^6.4|^7.0", + "symfony/event-dispatcher": "^5.4|^6.0|^7.0", + "symfony/http-foundation": "^6.4|^7.0", "symfony/polyfill-ctype": "^1.8" }, "conflict": { @@ -4218,7 +4239,7 @@ "symfony/cache": "<5.4", "symfony/config": "<6.1", "symfony/console": "<5.4", - "symfony/dependency-injection": "<6.3.4", + "symfony/dependency-injection": "<6.4", "symfony/doctrine-bridge": "<5.4", "symfony/form": "<5.4", "symfony/http-client": "<5.4", @@ -4228,7 +4249,7 @@ "symfony/translation": "<5.4", "symfony/translation-contracts": "<2.5", "symfony/twig-bridge": "<5.4", - "symfony/validator": "<5.4", + "symfony/validator": "<6.4", "symfony/var-dumper": "<6.3", "twig/twig": "<2.13" }, @@ -4237,26 +4258,26 @@ }, "require-dev": { "psr/cache": "^1.0|^2.0|^3.0", - "symfony/browser-kit": "^5.4|^6.0", - "symfony/clock": "^6.2", - "symfony/config": "^6.1", - "symfony/console": "^5.4|^6.0", - "symfony/css-selector": "^5.4|^6.0", - "symfony/dependency-injection": "^6.3.4", - "symfony/dom-crawler": "^5.4|^6.0", - "symfony/expression-language": "^5.4|^6.0", - "symfony/finder": "^5.4|^6.0", + "symfony/browser-kit": "^5.4|^6.0|^7.0", + "symfony/clock": "^6.2|^7.0", + "symfony/config": "^6.1|^7.0", + "symfony/console": "^5.4|^6.0|^7.0", + "symfony/css-selector": "^5.4|^6.0|^7.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/dom-crawler": "^5.4|^6.0|^7.0", + "symfony/expression-language": "^5.4|^6.0|^7.0", + "symfony/finder": "^5.4|^6.0|^7.0", "symfony/http-client-contracts": "^2.5|^3", - "symfony/process": "^5.4|^6.0", - "symfony/property-access": "^5.4.5|^6.0.5", - "symfony/routing": "^5.4|^6.0", - "symfony/serializer": "^6.3", - "symfony/stopwatch": "^5.4|^6.0", - "symfony/translation": "^5.4|^6.0", + "symfony/process": "^5.4|^6.0|^7.0", + "symfony/property-access": "^5.4.5|^6.0.5|^7.0", + "symfony/routing": "^5.4|^6.0|^7.0", + "symfony/serializer": "^6.3|^7.0", + "symfony/stopwatch": "^5.4|^6.0|^7.0", + "symfony/translation": "^5.4|^6.0|^7.0", "symfony/translation-contracts": "^2.5|^3", - "symfony/uid": "^5.4|^6.0", - "symfony/validator": "^6.3", - "symfony/var-exporter": "^6.2", + "symfony/uid": "^5.4|^6.0|^7.0", + "symfony/validator": "^6.4|^7.0", + "symfony/var-exporter": "^6.2|^7.0", "twig/twig": "^2.13|^3.0.4" }, "type": "library", @@ -4285,7 +4306,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v6.3.8" + "source": "https://github.com/symfony/http-kernel/tree/v6.4.1" }, "funding": [ { @@ -4301,20 +4322,20 @@ "type": "tidelift" } ], - "time": "2023-11-10T13:47:32+00:00" + "time": "2023-12-01T17:02:02+00:00" }, { "name": "symfony/mailer", - "version": "v6.3.5", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/mailer.git", - "reference": "d89611a7830d51b5e118bca38e390dea92f9ea06" + "reference": "ca8dcf8892cdc5b4358ecf2528429bb5e706f7ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mailer/zipball/d89611a7830d51b5e118bca38e390dea92f9ea06", - "reference": "d89611a7830d51b5e118bca38e390dea92f9ea06", + "url": "https://api.github.com/repos/symfony/mailer/zipball/ca8dcf8892cdc5b4358ecf2528429bb5e706f7ba", + "reference": "ca8dcf8892cdc5b4358ecf2528429bb5e706f7ba", "shasum": "" }, "require": { @@ -4322,8 +4343,8 @@ "php": ">=8.1", "psr/event-dispatcher": "^1", "psr/log": "^1|^2|^3", - "symfony/event-dispatcher": "^5.4|^6.0", - "symfony/mime": "^6.2", + "symfony/event-dispatcher": "^5.4|^6.0|^7.0", + "symfony/mime": "^6.2|^7.0", "symfony/service-contracts": "^2.5|^3" }, "conflict": { @@ -4334,10 +4355,10 @@ "symfony/twig-bridge": "<6.2.1" }, "require-dev": { - "symfony/console": "^5.4|^6.0", - "symfony/http-client": "^5.4|^6.0", - "symfony/messenger": "^6.2", - "symfony/twig-bridge": "^6.2" + "symfony/console": "^5.4|^6.0|^7.0", + "symfony/http-client": "^5.4|^6.0|^7.0", + "symfony/messenger": "^6.2|^7.0", + "symfony/twig-bridge": "^6.2|^7.0" }, "type": "library", "autoload": { @@ -4365,7 +4386,7 @@ "description": "Helps sending emails", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/mailer/tree/v6.3.5" + "source": "https://github.com/symfony/mailer/tree/v6.4.0" }, "funding": [ { @@ -4381,20 +4402,20 @@ "type": "tidelift" } ], - "time": "2023-09-06T09:47:15+00:00" + "time": "2023-11-12T18:02:22+00:00" }, { "name": "symfony/mime", - "version": "v6.3.5", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "d5179eedf1cb2946dbd760475ebf05c251ef6a6e" + "reference": "ca4f58b2ef4baa8f6cecbeca2573f88cd577d205" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/d5179eedf1cb2946dbd760475ebf05c251ef6a6e", - "reference": "d5179eedf1cb2946dbd760475ebf05c251ef6a6e", + "url": "https://api.github.com/repos/symfony/mime/zipball/ca4f58b2ef4baa8f6cecbeca2573f88cd577d205", + "reference": "ca4f58b2ef4baa8f6cecbeca2573f88cd577d205", "shasum": "" }, "require": { @@ -4408,16 +4429,16 @@ "phpdocumentor/reflection-docblock": "<3.2.2", "phpdocumentor/type-resolver": "<1.4.0", "symfony/mailer": "<5.4", - "symfony/serializer": "<6.2.13|>=6.3,<6.3.2" + "symfony/serializer": "<6.3.2" }, "require-dev": { "egulias/email-validator": "^2.1.10|^3.1|^4", "league/html-to-markdown": "^5.0", "phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0", - "symfony/dependency-injection": "^5.4|^6.0", - "symfony/property-access": "^5.4|^6.0", - "symfony/property-info": "^5.4|^6.0", - "symfony/serializer": "~6.2.13|^6.3.2" + "symfony/dependency-injection": "^5.4|^6.0|^7.0", + "symfony/property-access": "^5.4|^6.0|^7.0", + "symfony/property-info": "^5.4|^6.0|^7.0", + "symfony/serializer": "^6.3.2|^7.0" }, "type": "library", "autoload": { @@ -4449,7 +4470,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v6.3.5" + "source": "https://github.com/symfony/mime/tree/v6.4.0" }, "funding": [ { @@ -4465,7 +4486,7 @@ "type": "tidelift" } ], - "time": "2023-09-29T06:59:36+00:00" + "time": "2023-10-17T11:49:05+00:00" }, { "name": "symfony/polyfill-ctype", @@ -5207,16 +5228,16 @@ }, { "name": "symfony/process", - "version": "v6.3.4", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "0b5c29118f2e980d455d2e34a5659f4579847c54" + "reference": "191703b1566d97a5425dc969e4350d32b8ef17aa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/0b5c29118f2e980d455d2e34a5659f4579847c54", - "reference": "0b5c29118f2e980d455d2e34a5659f4579847c54", + "url": "https://api.github.com/repos/symfony/process/zipball/191703b1566d97a5425dc969e4350d32b8ef17aa", + "reference": "191703b1566d97a5425dc969e4350d32b8ef17aa", "shasum": "" }, "require": { @@ -5248,7 +5269,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v6.3.4" + "source": "https://github.com/symfony/process/tree/v6.4.0" }, "funding": [ { @@ -5264,20 +5285,20 @@ "type": "tidelift" } ], - "time": "2023-08-07T10:39:22+00:00" + "time": "2023-11-17T21:06:49+00:00" }, { "name": "symfony/routing", - "version": "v6.3.5", + "version": "v6.4.1", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "82616e59acd3e3d9c916bba798326cb7796d7d31" + "reference": "0c95c164fdba18b12523b75e64199ca3503e6d40" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/82616e59acd3e3d9c916bba798326cb7796d7d31", - "reference": "82616e59acd3e3d9c916bba798326cb7796d7d31", + "url": "https://api.github.com/repos/symfony/routing/zipball/0c95c164fdba18b12523b75e64199ca3503e6d40", + "reference": "0c95c164fdba18b12523b75e64199ca3503e6d40", "shasum": "" }, "require": { @@ -5293,11 +5314,11 @@ "require-dev": { "doctrine/annotations": "^1.12|^2", "psr/log": "^1|^2|^3", - "symfony/config": "^6.2", - "symfony/dependency-injection": "^5.4|^6.0", - "symfony/expression-language": "^5.4|^6.0", - "symfony/http-foundation": "^5.4|^6.0", - "symfony/yaml": "^5.4|^6.0" + "symfony/config": "^6.2|^7.0", + "symfony/dependency-injection": "^5.4|^6.0|^7.0", + "symfony/expression-language": "^5.4|^6.0|^7.0", + "symfony/http-foundation": "^5.4|^6.0|^7.0", + "symfony/yaml": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -5331,7 +5352,7 @@ "url" ], "support": { - "source": "https://github.com/symfony/routing/tree/v6.3.5" + "source": "https://github.com/symfony/routing/tree/v6.4.1" }, "funding": [ { @@ -5347,20 +5368,20 @@ "type": "tidelift" } ], - "time": "2023-09-20T16:05:51+00:00" + "time": "2023-12-01T14:54:37+00:00" }, { "name": "symfony/service-contracts", - "version": "v3.3.0", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4" + "reference": "b3313c2dbffaf71c8de2934e2ea56ed2291a3838" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/40da9cc13ec349d9e4966ce18b5fbcd724ab10a4", - "reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/b3313c2dbffaf71c8de2934e2ea56ed2291a3838", + "reference": "b3313c2dbffaf71c8de2934e2ea56ed2291a3838", "shasum": "" }, "require": { @@ -5413,7 +5434,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.3.0" + "source": "https://github.com/symfony/service-contracts/tree/v3.4.0" }, "funding": [ { @@ -5429,20 +5450,20 @@ "type": "tidelift" } ], - "time": "2023-05-23T14:45:45+00:00" + "time": "2023-07-30T20:28:31+00:00" }, { "name": "symfony/string", - "version": "v6.3.8", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "13880a87790c76ef994c91e87efb96134522577a" + "reference": "b45fcf399ea9c3af543a92edf7172ba21174d809" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/13880a87790c76ef994c91e87efb96134522577a", - "reference": "13880a87790c76ef994c91e87efb96134522577a", + "url": "https://api.github.com/repos/symfony/string/zipball/b45fcf399ea9c3af543a92edf7172ba21174d809", + "reference": "b45fcf399ea9c3af543a92edf7172ba21174d809", "shasum": "" }, "require": { @@ -5456,11 +5477,11 @@ "symfony/translation-contracts": "<2.5" }, "require-dev": { - "symfony/error-handler": "^5.4|^6.0", - "symfony/http-client": "^5.4|^6.0", - "symfony/intl": "^6.2", + "symfony/error-handler": "^5.4|^6.0|^7.0", + "symfony/http-client": "^5.4|^6.0|^7.0", + "symfony/intl": "^6.2|^7.0", "symfony/translation-contracts": "^2.5|^3.0", - "symfony/var-exporter": "^5.4|^6.0" + "symfony/var-exporter": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -5499,7 +5520,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.3.8" + "source": "https://github.com/symfony/string/tree/v6.4.0" }, "funding": [ { @@ -5515,20 +5536,20 @@ "type": "tidelift" } ], - "time": "2023-11-09T08:28:21+00:00" + "time": "2023-11-28T20:41:49+00:00" }, { "name": "symfony/translation", - "version": "v6.3.7", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "30212e7c87dcb79c83f6362b00bde0e0b1213499" + "reference": "b1035dbc2a344b21f8fa8ac451c7ecec4ea45f37" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/30212e7c87dcb79c83f6362b00bde0e0b1213499", - "reference": "30212e7c87dcb79c83f6362b00bde0e0b1213499", + "url": "https://api.github.com/repos/symfony/translation/zipball/b1035dbc2a344b21f8fa8ac451c7ecec4ea45f37", + "reference": "b1035dbc2a344b21f8fa8ac451c7ecec4ea45f37", "shasum": "" }, "require": { @@ -5553,17 +5574,17 @@ "require-dev": { "nikic/php-parser": "^4.13", "psr/log": "^1|^2|^3", - "symfony/config": "^5.4|^6.0", - "symfony/console": "^5.4|^6.0", - "symfony/dependency-injection": "^5.4|^6.0", - "symfony/finder": "^5.4|^6.0", + "symfony/config": "^5.4|^6.0|^7.0", + "symfony/console": "^5.4|^6.0|^7.0", + "symfony/dependency-injection": "^5.4|^6.0|^7.0", + "symfony/finder": "^5.4|^6.0|^7.0", "symfony/http-client-contracts": "^2.5|^3.0", - "symfony/http-kernel": "^5.4|^6.0", - "symfony/intl": "^5.4|^6.0", + "symfony/http-kernel": "^5.4|^6.0|^7.0", + "symfony/intl": "^5.4|^6.0|^7.0", "symfony/polyfill-intl-icu": "^1.21", - "symfony/routing": "^5.4|^6.0", + "symfony/routing": "^5.4|^6.0|^7.0", "symfony/service-contracts": "^2.5|^3", - "symfony/yaml": "^5.4|^6.0" + "symfony/yaml": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -5594,7 +5615,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v6.3.7" + "source": "https://github.com/symfony/translation/tree/v6.4.0" }, "funding": [ { @@ -5610,20 +5631,20 @@ "type": "tidelift" } ], - "time": "2023-10-28T23:11:45+00:00" + "time": "2023-11-29T08:14:36+00:00" }, { "name": "symfony/translation-contracts", - "version": "v3.3.0", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/translation-contracts.git", - "reference": "02c24deb352fb0d79db5486c0c79905a85e37e86" + "reference": "dee0c6e5b4c07ce851b462530088e64b255ac9c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/02c24deb352fb0d79db5486c0c79905a85e37e86", - "reference": "02c24deb352fb0d79db5486c0c79905a85e37e86", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/dee0c6e5b4c07ce851b462530088e64b255ac9c5", + "reference": "dee0c6e5b4c07ce851b462530088e64b255ac9c5", "shasum": "" }, "require": { @@ -5672,7 +5693,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/translation-contracts/tree/v3.3.0" + "source": "https://github.com/symfony/translation-contracts/tree/v3.4.0" }, "funding": [ { @@ -5688,20 +5709,20 @@ "type": "tidelift" } ], - "time": "2023-05-30T17:17:10+00:00" + "time": "2023-07-25T15:08:44+00:00" }, { "name": "symfony/uid", - "version": "v6.3.8", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/uid.git", - "reference": "819fa5ac210fb7ddda4752b91a82f50be7493dd9" + "reference": "8092dd1b1a41372110d06374f99ee62f7f0b9a92" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/uid/zipball/819fa5ac210fb7ddda4752b91a82f50be7493dd9", - "reference": "819fa5ac210fb7ddda4752b91a82f50be7493dd9", + "url": "https://api.github.com/repos/symfony/uid/zipball/8092dd1b1a41372110d06374f99ee62f7f0b9a92", + "reference": "8092dd1b1a41372110d06374f99ee62f7f0b9a92", "shasum": "" }, "require": { @@ -5709,7 +5730,7 @@ "symfony/polyfill-uuid": "^1.15" }, "require-dev": { - "symfony/console": "^5.4|^6.0" + "symfony/console": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -5746,7 +5767,7 @@ "uuid" ], "support": { - "source": "https://github.com/symfony/uid/tree/v6.3.8" + "source": "https://github.com/symfony/uid/tree/v6.4.0" }, "funding": [ { @@ -5762,20 +5783,20 @@ "type": "tidelift" } ], - "time": "2023-10-31T08:07:48+00:00" + "time": "2023-10-31T08:18:17+00:00" }, { "name": "symfony/var-dumper", - "version": "v6.3.8", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "81acabba9046550e89634876ca64bfcd3c06aa0a" + "reference": "c40f7d17e91d8b407582ed51a2bbf83c52c367f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/81acabba9046550e89634876ca64bfcd3c06aa0a", - "reference": "81acabba9046550e89634876ca64bfcd3c06aa0a", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/c40f7d17e91d8b407582ed51a2bbf83c52c367f6", + "reference": "c40f7d17e91d8b407582ed51a2bbf83c52c367f6", "shasum": "" }, "require": { @@ -5788,10 +5809,11 @@ }, "require-dev": { "ext-iconv": "*", - "symfony/console": "^5.4|^6.0", - "symfony/http-kernel": "^5.4|^6.0", - "symfony/process": "^5.4|^6.0", - "symfony/uid": "^5.4|^6.0", + "symfony/console": "^5.4|^6.0|^7.0", + "symfony/error-handler": "^6.3|^7.0", + "symfony/http-kernel": "^5.4|^6.0|^7.0", + "symfony/process": "^5.4|^6.0|^7.0", + "symfony/uid": "^5.4|^6.0|^7.0", "twig/twig": "^2.13|^3.0.4" }, "bin": [ @@ -5830,7 +5852,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v6.3.8" + "source": "https://github.com/symfony/var-dumper/tree/v6.4.0" }, "funding": [ { @@ -5846,7 +5868,7 @@ "type": "tidelift" } ], - "time": "2023-11-08T10:42:36+00:00" + "time": "2023-11-09T08:28:32+00:00" }, { "name": "tijsverkoyen/css-to-inline-styles", @@ -6311,16 +6333,16 @@ }, { "name": "laravel/pint", - "version": "v1.13.6", + "version": "v1.13.7", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "3e3d2ab01c7d8b484c18e6100ecf53639c744fa7" + "reference": "4157768980dbd977f1c4b4cc94997416d8b30ece" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/3e3d2ab01c7d8b484c18e6100ecf53639c744fa7", - "reference": "3e3d2ab01c7d8b484c18e6100ecf53639c744fa7", + "url": "https://api.github.com/repos/laravel/pint/zipball/4157768980dbd977f1c4b4cc94997416d8b30ece", + "reference": "4157768980dbd977f1c4b4cc94997416d8b30ece", "shasum": "" }, "require": { @@ -6373,20 +6395,20 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2023-11-07T17:59:57+00:00" + "time": "2023-12-05T19:43:12+00:00" }, { "name": "laravel/sail", - "version": "v1.26.0", + "version": "v1.26.3", "source": { "type": "git", "url": "https://github.com/laravel/sail.git", - "reference": "c60fe037004e272efd0d81f416ed2bfc623d70b4" + "reference": "fa1ad5fbb03686dfc752bfd1861d86091cc1c32d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/sail/zipball/c60fe037004e272efd0d81f416ed2bfc623d70b4", - "reference": "c60fe037004e272efd0d81f416ed2bfc623d70b4", + "url": "https://api.github.com/repos/laravel/sail/zipball/fa1ad5fbb03686dfc752bfd1861d86091cc1c32d", + "reference": "fa1ad5fbb03686dfc752bfd1861d86091cc1c32d", "shasum": "" }, "require": { @@ -6438,7 +6460,7 @@ "issues": "https://github.com/laravel/sail/issues", "source": "https://github.com/laravel/sail" }, - "time": "2023-10-18T13:57:15+00:00" + "time": "2023-12-02T18:26:39+00:00" }, { "name": "mockery/mockery", @@ -6793,16 +6815,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "10.1.7", + "version": "10.1.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "355324ca4980b8916c18b9db29f3ef484078f26e" + "reference": "a56a9ab2f680246adcf3db43f38ddf1765774735" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/355324ca4980b8916c18b9db29f3ef484078f26e", - "reference": "355324ca4980b8916c18b9db29f3ef484078f26e", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/a56a9ab2f680246adcf3db43f38ddf1765774735", + "reference": "a56a9ab2f680246adcf3db43f38ddf1765774735", "shasum": "" }, "require": { @@ -6859,7 +6881,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.7" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.9" }, "funding": [ { @@ -6867,7 +6889,7 @@ "type": "github" } ], - "time": "2023-10-04T15:34:17+00:00" + "time": "2023-11-23T12:23:20+00:00" }, { "name": "phpunit/php-file-iterator", @@ -7114,16 +7136,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.4.2", + "version": "10.5.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "cacd8b9dd224efa8eb28beb69004126c7ca1a1a1" + "reference": "5aedff46afba98dddecaa12349ec044d9103d4fe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/cacd8b9dd224efa8eb28beb69004126c7ca1a1a1", - "reference": "cacd8b9dd224efa8eb28beb69004126c7ca1a1a1", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5aedff46afba98dddecaa12349ec044d9103d4fe", + "reference": "5aedff46afba98dddecaa12349ec044d9103d4fe", "shasum": "" }, "require": { @@ -7163,7 +7185,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "10.4-dev" + "dev-main": "10.5-dev" } }, "autoload": { @@ -7195,7 +7217,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.4.2" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.2" }, "funding": [ { @@ -7211,7 +7233,7 @@ "type": "tidelift" } ], - "time": "2023-10-26T07:21:45+00:00" + "time": "2023-12-05T14:54:33+00:00" }, { "name": "sebastian/cli-parser", @@ -8437,16 +8459,16 @@ }, { "name": "symfony/yaml", - "version": "v6.3.8", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "3493af8a8dad7fa91c77fa473ba23ecd95334a92" + "reference": "4f9237a1bb42455d609e6687d2613dde5b41a587" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/3493af8a8dad7fa91c77fa473ba23ecd95334a92", - "reference": "3493af8a8dad7fa91c77fa473ba23ecd95334a92", + "url": "https://api.github.com/repos/symfony/yaml/zipball/4f9237a1bb42455d609e6687d2613dde5b41a587", + "reference": "4f9237a1bb42455d609e6687d2613dde5b41a587", "shasum": "" }, "require": { @@ -8458,7 +8480,7 @@ "symfony/console": "<5.4" }, "require-dev": { - "symfony/console": "^5.4|^6.0" + "symfony/console": "^5.4|^6.0|^7.0" }, "bin": [ "Resources/bin/yaml-lint" @@ -8489,7 +8511,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v6.3.8" + "source": "https://github.com/symfony/yaml/tree/v6.4.0" }, "funding": [ { @@ -8505,20 +8527,20 @@ "type": "tidelift" } ], - "time": "2023-11-06T10:58:05+00:00" + "time": "2023-11-06T11:00:25+00:00" }, { "name": "theseer/tokenizer", - "version": "1.2.1", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" + "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b2ad5003ca10d4ee50a12da31de12a5774ba6b96", + "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96", "shasum": "" }, "require": { @@ -8547,7 +8569,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + "source": "https://github.com/theseer/tokenizer/tree/1.2.2" }, "funding": [ { @@ -8555,7 +8577,7 @@ "type": "github" } ], - "time": "2021-07-28T10:34:58+00:00" + "time": "2023-11-20T00:12:19+00:00" } ], "aliases": [], diff --git a/database/migrations/2023_04_26_034953_create_extract_pdfs_table.php b/database/migrations/2023_04_26_034953_create_delete_pdfs_table.php similarity index 85% rename from database/migrations/2023_04_26_034953_create_extract_pdfs_table.php rename to database/migrations/2023_04_26_034953_create_delete_pdfs_table.php index d7cfb608..3363a51f 100644 --- a/database/migrations/2023_04_26_034953_create_extract_pdfs_table.php +++ b/database/migrations/2023_04_26_034953_create_delete_pdfs_table.php @@ -18,11 +18,11 @@ */ public function up(): void { - Schema::create('pdf_extract', function (Blueprint $table) { + Schema::create('pdf_delete', function (Blueprint $table) { $table->uuid('processId'); $table->text('fileName'); $table->string('fileSize', 25); - $table->text('customPage')->nullable(); + $table->text('deletePage')->nullable(); $table->string('mergePDF')->nullable(); $table->boolean('result'); $table->text('err_reason')->nullable(); @@ -38,6 +38,6 @@ public function up(): void */ public function down(): void { - Schema::dropIfExists('pdf_extract'); + Schema::dropIfExists('pdf_delete'); } }; diff --git a/database/migrations/2023_04_26_115938_create_pdf_cnv_table.php b/database/migrations/2023_04_26_115938_create_pdf_cnv_table.php index a55ee500..cc63a5c3 100644 --- a/database/migrations/2023_04_26_115938_create_pdf_cnv_table.php +++ b/database/migrations/2023_04_26_115938_create_pdf_cnv_table.php @@ -23,6 +23,7 @@ public function up(): void $table->text('fileName'); $table->string('fileSize', 25); $table->string('container', 25); + $table->boolean('img_extract'); $table->boolean('result'); $table->text('err_reason')->nullable(); $table->text('err_api_reason')->nullable(); diff --git a/database/migrations/2023_11_26_171345_init_pdf.php b/database/migrations/2023_11_26_171345_init_pdf.php new file mode 100644 index 00000000..aef6de59 --- /dev/null +++ b/database/migrations/2023_11_26_171345_init_pdf.php @@ -0,0 +1,37 @@ +uuid('processId'); + $table->text('err_reason')->nullable(); + $table->timestamp('procStartAt')->nullable(); + + $table->primary('processId'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('pdf_init'); + } +}; diff --git a/public/ext-js/kao-controller.js b/public/ext-js/kao-controller.js new file mode 100644 index 00000000..5cdcb080 --- /dev/null +++ b/public/ext-js/kao-controller.js @@ -0,0 +1,133 @@ +// Global controller +var firstArea = document.getElementById('firstChk') +var secondArea = document.getElementById('secondChk') +var thirdArea = document.getElementById('thirdChk') +var fourthArea = document.getElementById('fourthChk') +var firstColumnArea = document.getElementById('firstCol') +var secondColumnArea = document.getElementById('secondCol') +var thirdColumnArea = document.getElementById('thirdCol') +var fourthColumnArea = document.getElementById('fourthCol') +var firstAreaText = document.getElementById("firstRadioText") +var secondAreaText = document.getElementById("secondRadioText") +var thirdAreaText = document.getElementById("thirdRadioText") +var fourthAreaText = document.getElementById("fourthRadioText") +var firstAreaInput = document.getElementById("firstRadio") +var secondAreaInput = document.getElementById("secondRadio") +var thirdAreaInput = document.getElementById("thirdRadio") +var fourthAreaInput = document.getElementById("fourthRadio") +var firstAreaAltInput = document.getElementById('firstInput') +var secondAreaAltInput = document.getElementById('secondInput') +var thirdAreaAltInput = document.getElementById('thirdInput') +var fourthAreaAltInput = document.getElementById('fourthInput') +var extImageChkBox = document.getElementById('extImageLayout') +var extImageSwitch = document.getElementById('extImage') +var timerId = setInterval("reloadIFrame();", 2000) + +// Watermark image separate controller +var wmLayoutImageStyleAreaA = document.getElementById('wmChkImageLayoutStyleA') +var wmLayoutImageStyleAreaB = document.getElementById('wmChkImageLayoutStyleB') +var wmImageRotationAreaA = document.getElementById('wmChkImageRotationA') +var wmImageRotationAreaB = document.getElementById('wmChkImageRotationB') +var wmImageRotationAreaC = document.getElementById('wmChkImageRotationC') +var wmImageRotationAreaD = document.getElementById('wmChkImageRotationD') +var wmLayoutImageStyleColumnAreaA = document.getElementById('wmColImageLayoutStyleA') +var wmLayoutImageStyleColumnAreaB = document.getElementById('wmColImageLayoutStyleB') +var wmImageRotationColumnAreaA = document.getElementById('wmColImageRotationA') +var wmImageRotationColumnAreaB = document.getElementById('wmColImageRotationB') +var wmImageRotationColumnAreaC = document.getElementById('wmColImageRotationC') +var wmImageRotationColumnAreaD = document.getElementById('wmColImageRotationD') +var wmLayoutImageStyleAreaTextA = document.getElementById("wmRadioImageLayoutStyleTextA") +var wmLayoutImageStyleAreaTextB = document.getElementById("wmRadioImageLayoutStyleTextB") +var wmImageRotationRadioAreaTextA = document.getElementById("wmRadioImageRotationTextA") +var wmImageRotationRadioAreaTextB = document.getElementById("wmRadioImageRotationTextB") +var wmImageRotationRadioAreaTextC = document.getElementById("wmRadioImageRotationTextC") +var wmImageRotationRadioAreaTextD = document.getElementById("wmRadioImageRotationTextD") +var wmImageRotationRadioAreaInputA = document.getElementById("wmRadioImageRotationA") +var wmImageRotationRadioAreaInputB = document.getElementById("wmRadioImageRotationB") +var wmImageRotationRadioAreaInputC = document.getElementById("wmRadioImageRotationC") +var wmImageRotationRadioAreaInputD = document.getElementById("wmRadioImageRotationD") +var wmLayoutImageRadioAreaInputA = document.getElementById("wmRadioImageLayoutStyleA") +var wmLayoutImageRadioAreaInputB = document.getElementById("wmRadioImageLayoutStyleB") +var wmLayoutImageRadioAltInputA = document.getElementById("wmColImageLayoutStyleInputA") +var wmLayoutImageRadioAltInputB = document.getElementById("wmColImageLayoutStyleInputB") +var wmImageRotationRadioAltInputA = document.getElementById("wmColImageRotationInputA") +var wmImageRotationRadioAltInputB = document.getElementById("wmColImageRotationInputB") +var wmImageRotationRadioAltInputC = document.getElementById("wmColImageRotationInputC") +var wmImageRotationRadioAltInputB = document.getElementById("wmColImageRotationInputD") + +// Watermark text separate controller +var wmChkFontFamilyA = document.getElementById('wmChkFontFamilyA') +var wmChkFontFamilyB = document.getElementById('wmChkFontFamilyB') +var wmChkFontFamilyC = document.getElementById('wmChkFontFamilyC') +var wmChkFontFamilyD = document.getElementById('wmChkFontFamilyD') +var wmChkFontFamilyE = document.getElementById('wmChkFontFamilyE') +var wmChkFontFamilyF = document.getElementById('wmChkFontFamilyF') +var wmChkFontStyleA = document.getElementById('wmChkFontStyleA') +var wmChkFontStyleB = document.getElementById('wmChkFontStyleB') +var wmChkFontStyleC = document.getElementById('wmChkFontStyleC') +var wmChkLayoutStyleA = document.getElementById('wmChkLayoutStyleA') +var wmChkLayoutStyleB = document.getElementById('wmChkLayoutStyleB') +var wmChkRotationA = document.getElementById('wmChkRotationA') +var wmChkRotationB = document.getElementById('wmChkRotationB') +var wmChkRotationC = document.getElementById('wmChkRotationC') +var wmChkRotationD = document.getElementById('wmChkRotationD') +var wmColFontFamilyA = document.getElementById('wmColFontFamilyA') +var wmColFontFamilyB = document.getElementById('wmColFontFamilyB') +var wmColFontFamilyC = document.getElementById('wmColFontFamilyC') +var wmColFontFamilyD = document.getElementById('wmColFontFamilyD') +var wmColFontFamilyE = document.getElementById('wmColFontFamilyE') +var wmColFontFamilyF = document.getElementById('wmColFontFamilyF') +var wmColFontStyleA = document.getElementById('wmColFontStyleA') +var wmColFontStyleB = document.getElementById('wmColFontStyleB') +var wmColFontStyleC = document.getElementById('wmColFontStyleC') +var wmColLayoutStyleA = document.getElementById('wmColLayoutStyleA') +var wmColLayoutStyleB = document.getElementById('wmColLayoutStyleB') +var wmColRotationA = document.getElementById('wmColRotationA') +var wmColRotationB = document.getElementById('wmColRotationB') +var wmColRotationC = document.getElementById('wmColRotationC') +var wmColRotationD = document.getElementById('wmColRotationD') +var wmColFontFamilyInputA = document.getElementById('wmColFontFamilyInputA') +var wmColFontFamilyInputB = document.getElementById('wmColFontFamilyInputB') +var wmColFontFamilyInputC = document.getElementById('wmColFontFamilyInputC') +var wmColFontFamilyInputD = document.getElementById('wmColFontFamilyInputD') +var wmColFontFamilyInputE = document.getElementById('wmColFontFamilyInputE') +var wmColFontFamilyInputF = document.getElementById('wmColFontFamilyInputF') +var wmColFontStyleInputA = document.getElementById('wmColFontStyleInputA') +var wmColFontStyleInputB = document.getElementById('wmColFontStyleInputB') +var wmColFontStyleInputC = document.getElementById('wmColFontStyleInputC') +var wmColLayoutStyleInputA = document.getElementById('wmColLayoutStyleInputA') +var wmColLayoutStyleInputB = document.getElementById('wmColLayoutStyleInputB') +var wmColRotationInputA = document.getElementById('wmColRotationInputA') +var wmColRotationInputB = document.getElementById('wmColRotationInputB') +var wmColRotationInputC = document.getElementById('wmColRotationInputC') +var wmColRotationInputD = document.getElementById('wmColRotationInputD') +var wmRadioFontFamilyA = document.getElementById('wmRadioFontFamilyA') +var wmRadioFontFamilyB = document.getElementById('wmRadioFontFamilyB') +var wmRadioFontFamilyC = document.getElementById('wmRadioFontFamilyC') +var wmRadioFontFamilyD = document.getElementById('wmRadioFontFamilyD') +var wmRadioFontFamilyE = document.getElementById('wmRadioFontFamilyE') +var wmRadioFontFamilyF = document.getElementById('wmRadioFontFamilyF') +var wmRadioFontStyleA = document.getElementById('wmRadioFontStyleA') +var wmRadioFontStyleB = document.getElementById('wmRadioFontStyleB') +var wmRadioFontStyleC = document.getElementById('wmRadioFontStyleC') +var wmRadioLayoutStyleA = document.getElementById('wmRadioLayoutStyleA') +var wmRadioLayoutStyleB = document.getElementById('wmRadioLayoutStyleB') +var wmRadioRotationA = document.getElementById('wmRadioRotationA') +var wmRadioRotationB = document.getElementById('wmRadioRotationB') +var wmRadioRotationC = document.getElementById('wmRadioRotationC') +var wmRadioRotationD = document.getElementById('wmRadioRotationD') +var wmRadioFontFamilyTextA = document.getElementById('wmRadioFontFamilyTextA') +var wmRadioFontFamilyTextB = document.getElementById('wmRadioFontFamilyTextB') +var wmRadioFontFamilyTextC = document.getElementById('wmRadioFontFamilyTextC') +var wmRadioFontFamilyTextD = document.getElementById('wmRadioFontFamilyTextD') +var wmRadioFontFamilyTextE = document.getElementById('wmRadioFontFamilyTextE') +var wmRadioFontFamilyTextF = document.getElementById('wmRadioFontFamilyTextF') +var wmRadioFontStyleTextA = document.getElementById('wmRadioFontStyleTextA') +var wmRadioFontStyleTextB = document.getElementById('wmRadioFontStyleTextB') +var wmRadioFontStyleTextC = document.getElementById('wmRadioFontStyleTextC') +var wmRadioLayoutStyleTextA = document.getElementById('wmRadioLayoutStyleTextA') +var wmRadioLayoutStyleTextB = document.getElementById('wmRadioLayoutStyleTextB') +var wmRadioRotationTextA = document.getElementById('wmRadioRotationTextA') +var wmRadioRotationTextB = document.getElementById('wmRadioRotationTextB') +var wmRadioRotationTextC = document.getElementById('wmRadioRotationTextC') +var wmRadioRotationTextD = document.getElementById('wmRadioRotationTextD') diff --git a/public/ext-js/kao-main.js b/public/ext-js/kao-main.js index 249115ef..8a5e7b2f 100644 --- a/public/ext-js/kao-main.js +++ b/public/ext-js/kao-main.js @@ -1,3 +1,538 @@ +if (firstArea) { + firstArea.onclick = function() { + firstColumnArea.style.borderColor = '#38bdf8' + firstAreaText.style.color = '#38bdf8' + firstAreaInput.checked = true + if (secondAreaAltInput.value == "comp" || secondAreaAltInput.value == "cnvFrPDF") { + secondAreaText.style.color = '#1e293b' + } else { + secondAreaText.style.color = '#6b7280' + } + secondColumnArea.style = null + if (thirdArea) { + if (firstAreaAltInput.value !== "split") { + if (thirdAreaAltInput.value == "comp" || thirdAreaAltInput.value == "cnvFrPDF") { + thirdAreaText.style.color = '#1e293b' + } else { + thirdAreaText.style.color = '#6b7280' + } + thirdAreaInput.checked = false + thirdColumnArea.style = null + } else { + if (thirdAreaInput.checked == true) { + thirdColumnArea.style.borderColor = '#38bdf8' + thirdAreaText.style.color = '#38bdf8' + splitLayout3_wthn() + } + } + } + if (fourthArea) { + if (firstAreaAltInput.value !== "split") { + if (fourthAreaAltInput.value == "comp" || fourthAreaAltInput.value == "cnvFrPDF") { + fourthAreaText.style.color = '#1e293b' + } else { + fourthAreaText.style.color = '#6b7280' + } + fourthAreaInput.checked = false + fourthColumnArea.style = null + } else { + if (fourthAreaInput.checked == true) { + fourthColumnArea.style.borderColor = '#38bdf8' + fourthAreaText.style.color = '#38bdf8' + splitLayout3_cstm() + } + } + } + if (firstAreaAltInput.value == "split") { + splitLayout2_split(); + if (thirdColumnArea.style.borderColor == "rgb(56, 189, 248)" || fourthColumnArea.style.borderColor == "rgb(56, 189, 248)") { + document.getElementById("submitBtn_2").style.display = null; + document.getElementById("submitBtn_3").style.display = "none"; + } else { + splitLayout2_splitClean() + } + } else if (firstAreaAltInput.value == "cnvFrPDF") { + extImageChkBox.style.display = null + } else if (firstAreaAltInput.value == "watermark") { + wmLayout_ImageInputRestore() + wmLayout_image() + } + } +} + +if (secondArea) { + secondArea.onclick = function() { + secondColumnArea.style.borderColor = '#38bdf8' + secondAreaText.style.color = '#38bdf8' + secondAreaInput.checked = true + if (firstAreaAltInput.value == "comp" || firstAreaAltInput.value == "cnvFrPDF") { + firstAreaText.style.color = '#1e293b' + if (firstAreaAltInput.value == "cnvFrPDF") { + extImageChkBox.style.display = 'none' + extImageSwitch.checked = false + } + } else { + firstAreaText.style.color = '#6b7280' + } + firstColumnArea.style = null + if (thirdArea) { + if (thirdAreaAltInput.value == "comp" || thirdAreaAltInput.value == "cnvFrPDF") { + thirdAreaText.style.color = '#1e293b' + } else { + thirdAreaText.style.color = '#6b7280' + } + thirdColumnArea.style = null + } + if (fourthArea) { + if (fourthAreaAltInput.value == "comp" || fourthAreaAltInput.value == "cnvFrPDF") { + fourthAreaText.style.color = '#1e293b' + } else { + fourthAreaText.style.color = '#6b7280' + } + fourthColumnArea.style = null + } + if (secondAreaAltInput.value == "split") { + splitLayout2_delete(); + } else if (firstAreaAltInput.value == "watermark") { + wmLayout_TextInputRestore() + wmLayout_text() + } + } +} + +if (thirdArea) { + thirdArea.onclick = function() { + thirdColumnArea.style.borderColor = '#38bdf8' + thirdAreaText.style.color = '#38bdf8' + thirdAreaInput.checked = true + if (firstAreaAltInput.value == "comp" || firstAreaAltInput.value == "cnvFrPDF") { + firstAreaText.style.color = '#1e293b' + if (firstAreaAltInput.value == "cnvFrPDF") { + extImageChkBox.style.display = 'none' + extImageSwitch.checked = false + } + } else { + firstAreaText.style.color = '#6b7280' + } + firstColumnArea.style = null + if (secondAreaAltInput.value == "comp" || secondAreaAltInput.value == "cnvFrPDF") { + secondAreaText.style.color = '#1e293b' + } else { + secondAreaText.style.color = '#6b7280' + } + secondColumnArea.style = null + if (fourthArea) { + if (fourthAreaAltInput.value == "comp" || fourthAreaAltInput.value == "cnvFrPDF") { + fourthAreaText.style.color = '#1e293b' + } else { + fourthAreaText.style.color = '#6b7280' + } + fourthColumnArea.style = null + } + if (thirdAreaAltInput.value == "split") { + splitLayout3_wthn() + if (firstAreaInput.checked == true) { + firstColumnArea.style.borderColor = '#38bdf8' + firstAreaText.style.color = '#38bdf8' + } + } + } +} + +if (fourthArea) { + fourthArea.onclick = function() { + fourthColumnArea.style.borderColor = '#38bdf8' + fourthAreaText.style.color = '#38bdf8' + fourthAreaInput.checked = true + if (firstAreaAltInput.value == "comp" || firstAreaAltInput.value == "cnvFrPDF") { + firstAreaText.style.color = '#1e293b' + if (firstAreaAltInput.value == "cnvFrPDF") { + extImageChkBox.style.display = 'none' + extImageSwitch.checked = false + } + } else { + firstAreaText.style.color = '#6b7280' + } + firstColumnArea.style = null + if (secondAreaAltInput.value == "comp" || secondAreaAltInput.value == "cnvFrPDF") { + secondAreaText.style.color = '#1e293b' + } else { + secondAreaText.style.color = '#6b7280' + } + secondColumnArea.style = null + if (thirdArea) { + if (thirdAreaAltInput.value == "comp" || thirdAreaAltInput.value == "cnvFrPDF") { + thirdAreaText.style.color = '#1e293b' + } else { + thirdAreaText.style.color = '#6b7280' + } + thirdColumnArea.style = null + } + if (fourthAreaAltInput.value == "split") { + splitLayout3_cstm() + if (firstAreaInput.checked == true) { + firstColumnArea.style.borderColor = '#38bdf8' + firstAreaText.style.color = '#38bdf8' + } + } + } +} + +if (wmLayoutImageStyleAreaA) { + wmLayoutImageStyleAreaA.onclick = function() { + reuseOnClickWmLayoutImageStyleAreaA() + if (firstAreaInput.checked == true) { + firstColumnArea.style.borderColor = '#38bdf8' + firstAreaText.style.color = '#38bdf8' + firstAreaInput.checked = true + } else if (secondAreaInput.checked == true) { + secondColumnArea.style.borderColor = '#38bdf8' + secondAreaText.style.color = '#38bdf8' + secondAreaInput.checked = true + } + } +} + +if (wmLayoutImageStyleAreaB) { + wmLayoutImageStyleAreaB.onclick = function() { + reuseOnClickWmLayoutImageStyleAreaB() + if (firstAreaInput.checked == true) { + firstColumnArea.style.borderColor = '#38bdf8' + firstAreaText.style.color = '#38bdf8' + firstAreaInput.checked = true + } else if (secondAreaInput.checked == true) { + secondColumnArea.style.borderColor = '#38bdf8' + secondAreaText.style.color = '#38bdf8' + secondAreaInput.checked = true + } + } +} + +if (wmImageRotationAreaA) { + wmImageRotationAreaA.onclick = function() { + wmImageRotationColumnAreaA.style.borderColor = '#38bdf8' + wmImageRotationRadioAreaTextA.style.color = '#38bdf8' + wmImageRotationRadioAreaInputA.checked = true + wmImageRotationColumnAreaB.style = null + wmImageRotationRadioAreaTextB.style.color = '#6b7280' + wmImageRotationColumnAreaC.style = null + wmImageRotationRadioAreaTextC.style.color = '#6b7280' + wmImageRotationColumnAreaD.style = null + wmImageRotationRadioAreaTextD.style.color = '#6b7280' + if (wmLayoutImageRadioAreaInputA.checked == true) { + reuseOnClickWmLayoutImageStyleAreaA() + } else if (wmLayoutImageRadioAreaInputB.checked == true) { + reuseOnClickWmLayoutImageStyleAreaB() + } + } +} + +if (wmImageRotationAreaB) { + wmImageRotationAreaB.onclick = function() { + wmImageRotationColumnAreaB.style.borderColor = '#38bdf8' + wmImageRotationRadioAreaTextB.style.color = '#38bdf8' + wmImageRotationRadioAreaInputB.checked = true + wmImageRotationColumnAreaA.style = null + wmImageRotationRadioAreaTextA.style.color = '#6b7280' + wmImageRotationColumnAreaC.style = null + wmImageRotationRadioAreaTextC.style.color = '#6b7280' + wmImageRotationColumnAreaD.style = null + wmImageRotationRadioAreaTextD.style.color = '#6b7280' + if (wmLayoutImageRadioAreaInputA.checked == true) { + reuseOnClickWmLayoutImageStyleAreaA() + } else if (wmLayoutImageRadioAreaInputB.checked == true) { + reuseOnClickWmLayoutImageStyleAreaB() + } + } +} + +if (wmImageRotationAreaC) { + wmImageRotationAreaC.onclick = function() { + wmImageRotationColumnAreaC.style.borderColor = '#38bdf8' + wmImageRotationRadioAreaTextC.style.color = '#38bdf8' + wmImageRotationRadioAreaInputC.checked = true + wmImageRotationColumnAreaA.style = null + wmImageRotationRadioAreaTextA.style.color = '#6b7280' + wmImageRotationColumnAreaB.style = null + wmImageRotationRadioAreaTextB.style.color = '#6b7280' + wmImageRotationColumnAreaD.style = null + wmImageRotationRadioAreaTextD.style.color = '#6b7280' + if (wmLayoutImageRadioAreaInputA.checked == true) { + reuseOnClickWmLayoutImageStyleAreaA() + } else if (wmLayoutImageRadioAreaInputB.checked == true) { + reuseOnClickWmLayoutImageStyleAreaB() + } + } +} + +if (wmImageRotationAreaD) { + wmImageRotationAreaD.onclick = function() { + wmImageRotationColumnAreaD.style.borderColor = '#38bdf8' + wmImageRotationRadioAreaTextD.style.color = '#38bdf8' + wmImageRotationRadioAreaInputD.checked = true + wmImageRotationColumnAreaA.style = null + wmImageRotationRadioAreaTextA.style.color = '#6b7280' + wmImageRotationColumnAreaB.style = null + wmImageRotationRadioAreaTextB.style.color = '#6b7280' + wmImageRotationColumnAreaC.style = null + wmImageRotationRadioAreaTextC.style.color = '#6b7280' + if (wmLayoutImageRadioAreaInputA.checked == true) { + reuseOnClickWmLayoutImageStyleAreaA() + } else if (wmLayoutImageRadioAreaInputB.checked == true) { + reuseOnClickWmLayoutImageStyleAreaB() + } + } +} + +if (wmChkFontFamilyA) { + wmChkFontFamilyA.onclick = function() { + wmColFontFamilyA.style.borderColor = '#38bdf8' + wmRadioFontFamilyTextA.style.color = '#38bdf8' + wmRadioFontFamilyA.checked = true + wmColFontFamilyB.style = null + wmRadioFontFamilyTextB.style.color = '#6b7280' + wmColFontFamilyC.style = null + wmRadioFontFamilyTextC.style.color = '#6b7280' + wmColFontFamilyD.style = null + wmRadioFontFamilyTextD.style.color = '#6b7280' + wmColFontFamilyE.style = null + wmRadioFontFamilyTextE.style.color = '#6b7280' + wmColFontFamilyF.style = null + wmRadioFontFamilyTextF.style.color = '#6b7280' + } +} + +if (wmChkFontFamilyB) { + wmChkFontFamilyB.onclick = function() { + wmColFontFamilyB.style.borderColor = '#38bdf8' + wmRadioFontFamilyTextB.style.color = '#38bdf8' + wmRadioFontFamilyB.checked = true + wmColFontFamilyA.style = null + wmRadioFontFamilyTextA.style.color = '#6b7280' + wmColFontFamilyC.style = null + wmRadioFontFamilyTextC.style.color = '#6b7280' + wmColFontFamilyD.style = null + wmRadioFontFamilyTextD.style.color = '#6b7280' + wmColFontFamilyE.style = null + wmRadioFontFamilyTextE.style.color = '#6b7280' + wmColFontFamilyF.style = null + wmRadioFontFamilyTextF.style.color = '#6b7280' + } +} + +if (wmChkFontFamilyC) { + wmChkFontFamilyC.onclick = function() { + wmColFontFamilyC.style.borderColor = '#38bdf8' + wmRadioFontFamilyTextC.style.color = '#38bdf8' + wmRadioFontFamilyC.checked = true + wmColFontFamilyB.style = null + wmRadioFontFamilyTextB.style.color = '#6b7280' + wmColFontFamilyA.style = null + wmRadioFontFamilyTextA.style.color = '#6b7280' + wmColFontFamilyD.style = null + wmRadioFontFamilyTextD.style.color = '#6b7280' + wmColFontFamilyE.style = null + wmRadioFontFamilyTextE.style.color = '#6b7280' + wmColFontFamilyF.style = null + wmRadioFontFamilyTextF.style.color = '#6b7280' + } +} + +if (wmChkFontFamilyD) { + wmChkFontFamilyD.onclick = function() { + wmColFontFamilyD.style.borderColor = '#38bdf8' + wmRadioFontFamilyTextD.style.color = '#38bdf8' + wmRadioFontFamilyD.checked = true + wmColFontFamilyB.style = null + wmRadioFontFamilyTextB.style.color = '#6b7280' + wmColFontFamilyC.style = null + wmRadioFontFamilyTextC.style.color = '#6b7280' + wmColFontFamilyA.style = null + wmRadioFontFamilyTextA.style.color = '#6b7280' + wmColFontFamilyE.style = null + wmRadioFontFamilyTextE.style.color = '#6b7280' + wmColFontFamilyF.style = null + wmRadioFontFamilyTextF.style.color = '#6b7280' + } +} + +if (wmChkFontFamilyE) { + wmChkFontFamilyE.onclick = function() { + wmColFontFamilyE.style.borderColor = '#38bdf8' + wmRadioFontFamilyTextE.style.color = '#38bdf8' + wmRadioFontFamilyE.checked = true + wmColFontFamilyB.style = null + wmRadioFontFamilyTextB.style.color = '#6b7280' + wmColFontFamilyC.style = null + wmRadioFontFamilyTextC.style.color = '#6b7280' + wmColFontFamilyD.style = null + wmRadioFontFamilyTextD.style.color = '#6b7280' + wmColFontFamilyA.style = null + wmRadioFontFamilyTextA.style.color = '#6b7280' + wmColFontFamilyF.style = null + wmRadioFontFamilyTextF.style.color = '#6b7280' + } +} + +if (wmChkFontFamilyF) { + wmChkFontFamilyF.onclick = function() { + wmColFontFamilyF.style.borderColor = '#38bdf8' + wmRadioFontFamilyTextF.style.color = '#38bdf8' + wmRadioFontFamilyF.checked = true + wmColFontFamilyB.style = null + wmRadioFontFamilyTextB.style.color = '#6b7280' + wmColFontFamilyC.style = null + wmRadioFontFamilyTextC.style.color = '#6b7280' + wmColFontFamilyD.style = null + wmRadioFontFamilyTextD.style.color = '#6b7280' + wmColFontFamilyE.style = null + wmRadioFontFamilyTextE.style.color = '#6b7280' + wmColFontFamilyA.style = null + wmRadioFontFamilyTextA.style.color = '#6b7280' + } +} + +if (wmChkFontStyleA) { + wmChkFontStyleA.onclick = function() { + wmColFontStyleA.style.borderColor = '#38bdf8' + wmRadioFontStyleTextA.style.color = '#38bdf8' + wmRadioFontStyleA.checked = true + wmColFontStyleB.style = null + wmRadioFontStyleTextB.style.color = '#6b7280' + wmColFontStyleC.style = null + wmRadioFontStyleTextC.style.color = '#6b7280' + } +} + +if (wmChkFontStyleB) { + wmChkFontStyleB.onclick = function() { + wmColFontStyleB.style.borderColor = '#38bdf8' + wmRadioFontStyleTextB.style.color = '#38bdf8' + wmRadioFontStyleB.checked = true + wmColFontStyleA.style = null + wmRadioFontStyleTextA.style.color = '#6b7280' + wmColFontStyleC.style = null + wmRadioFontStyleTextC.style.color = '#6b7280' + } +} + +if (wmChkFontStyleC) { + wmChkFontStyleC.onclick = function() { + wmColFontStyleC.style.borderColor = '#38bdf8' + wmRadioFontStyleTextC.style.color = '#38bdf8' + wmRadioFontStyleC.checked = true + wmColFontStyleB.style = null + wmRadioFontStyleTextB.style.color = '#6b7280' + wmColFontStyleA.style = null + wmRadioFontStyleTextA.style.color = '#6b7280' + } +} + +if (wmChkLayoutStyleA) { + wmChkLayoutStyleA.onclick = function() { + wmColLayoutStyleA.style.borderColor = '#38bdf8' + wmRadioLayoutStyleTextA.style.color = '#38bdf8' + wmRadioLayoutStyleA.checked = true + wmColLayoutStyleB.style = null + wmRadioLayoutStyleTextB.style.color = '#6b7280' + + } +} + +if (wmChkLayoutStyleB) { + wmChkLayoutStyleB.onclick = function() { + + wmColLayoutStyleB.style.borderColor = '#38bdf8' + wmRadioLayoutStyleTextB.style.color = '#38bdf8' + wmRadioLayoutStyleB.checked = true + wmColLayoutStyleA.style = null + wmRadioLayoutStyleTextA.style.color = '#6b7280' + } +} + +if (wmChkRotationA) { + wmChkRotationA.onclick = function() { + wmColRotationA.style.borderColor = '#38bdf8' + wmRadioRotationTextA.style.color = '#38bdf8' + wmRadioRotationA.checked = true + wmColRotationB.style = null + wmRadioRotationTextB.style.color = '#6b7280' + wmColRotationC.style = null + wmRadioRotationTextC.style.color = '#6b7280' + wmColRotationD.style = null + wmRadioRotationTextD.style.color = '#6b7280' + } +} + +if (wmChkRotationB) { + wmChkRotationB.onclick = function() { + wmColRotationB.style.borderColor = '#38bdf8' + wmRadioRotationTextB.style.color = '#38bdf8' + wmRadioRotationB.checked = true + wmColRotationA.style = null + wmRadioRotationTextA.style.color = '#6b7280' + wmColRotationC.style = null + wmRadioRotationTextC.style.color = '#6b7280' + wmColRotationD.style = null + wmRadioRotationTextD.style.color = '#6b7280' + } +} + +if (wmChkRotationC) { + wmChkRotationC.onclick = function() { + wmColRotationC.style.borderColor = '#38bdf8' + wmRadioRotationTextC.style.color = '#38bdf8' + wmRadioRotationC.checked = true + wmColRotationB.style = null + wmRadioRotationTextB.style.color = '#6b7280' + wmColRotationA.style = null + wmRadioRotationTextA.style.color = '#6b7280' + wmColRotationD.style = null + wmRadioRotationTextD.style.color = '#6b7280' + } +} + +if (wmChkRotationD) { + wmChkRotationD.onclick = function() { + wmColRotationD.style.borderColor = '#38bdf8' + wmRadioRotationTextD.style.color = '#38bdf8' + wmRadioRotationD.checked = true + wmColRotationB.style = null + wmRadioRotationTextB.style.color = '#6b7280' + wmColRotationC.style = null + wmRadioRotationTextC.style.color = '#6b7280' + wmColRotationA.style = null + wmRadioRotationTextA.style.color = '#6b7280' + } +} + +if (document.getElementById('multiple_files')) { + document.getElementById('multiple_files').addEventListener('change', function(e) { + var list = document.getElementById('filelist'); + var newList = document.getElementById('pre-title'); + if (document.getElementById('multiple_files').value !== '') { + if (newList.innerHTML !== '') { + newList.innerHTML = ``; + for (var i = 0; i < this.files.length; i++) { + generateMesssage(this.files[i].name) + } + } else { + for (var i = 0; i < this.files.length; i++) { + generateMesssage(this.files[i].name) + } + } + if (newList.innerHTML == '') { + list.style.display = 'none'; + } else { + list.style.display = 'block'; + } + } else { + list.style.display = 'none'; + newList.innerHTML = ``; + } + }); +} + function changeButtonColor(kaoInput) { if (kaoInput == 'kaoA') { document.getElementById('file_input').addEventListener('change', function(e) { @@ -57,85 +592,13 @@ function changeButtonColor(kaoInput) { } function checkValidation(validation) { - if (validation == 'compMethod') { - if (!document.getElementById('comp-low').checked && !document.getElementById('comp-rec').checked && !document.getElementById('comp-high').checked) { - document.getElementById('lowestChk').style.borderColor = '#dc2626' - document.getElementById('recChk').style.borderColor = '#dc2626' - document.getElementById('highestChk').style.borderColor = '#dc2626' - } else { - if (document.getElementById('comp-low').checked) { - document.getElementById("lowestChk").style.borderColor = '#38bdf8' - document.getElementById("lowest-txt").style.color = '#38bdf8' - document.getElementById("recChk").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt").style.color = '#1e293b' - document.getElementById("highestChk").style.borderColor = '#e2e8f0' - document.getElementById("highest-txt").style.color = '#1e293b' - } else if (document.getElementById('comp-rec').checked) { - document.getElementById("lowestChk").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt").style.color = '#1e293b' - document.getElementById("recChk").style.borderColor = '#38bdf8' - document.getElementById("rec-txt").style.color = '#38bdf8' - document.getElementById("highestChk").style.borderColor = '#e2e8f0' - document.getElementById("highest-txt").style.color = '#1e293b' - } else if (document.getElementById('comp-high').checked) { - document.getElementById("lowestChk").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt").style.color = '#1e293b' - document.getElementById("recChk").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt").style.color = '#1e293b' - document.getElementById("highestChk").style.borderColor = '#38bdf8' - document.getElementById("highest-txt").style.color = '#38bdf8' - } - document.getElementById("submitBtn_1").style.backgroundColor="#38bdf8" - document.getElementById("submitBtn_1").style.color = "white" - } + if (validation == 'comp') { + document.getElementById("submitBtn_1").style.backgroundColor="#38bdf8" + document.getElementById("submitBtn_1").style.color = "white" } if (validation == 'cnvFrPDF') { - if (!document.getElementById('lowestChkA').checked && !document.getElementById('ulChkA').checked && !document.getElementById('recChkA').checked && !document.getElementById('highestChkA').checked) { - document.getElementById('lowestChkA').style.borderColor = '#dc2626' - document.getElementById('recChkA').style.borderColor = '#dc2626' - document.getElementById('highestChkA').style.borderColor = '#dc2626' - document.getElementById('ulChkA').style.borderColor = '#dc2626' - } else { - if (document.getElementById('lowestChkA').checked) { - document.getElementById("lowestChk").style.borderColor = '#38bdf8' - document.getElementById("lowest-txt").style.color = '#38bdf8' - document.getElementById("recChk").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt").style.color = '#1e293b' - document.getElementById("highestChk").style.borderColor = '#e2e8f0' - document.getElementById("highest-txt").style.color = '#1e293b' - document.getElementById("ulChk").style.borderColor = '#e2e8f0' - document.getElementById("ul-txt").style.color = '#1e293b' - } else if (document.getElementById('recChkA').checked) { - document.getElementById("lowestChk").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt").style.color = '#1e293b' - document.getElementById("recChk").style.borderColor = '#38bdf8' - document.getElementById("rec-txt").style.color = '#38bdf8' - document.getElementById("highestChk").style.borderColor = '#e2e8f0' - document.getElementById("highest-txt").style.color = '#1e293b' - document.getElementById("ulChk").style.borderColor = '#e2e8f0' - document.getElementById("ul-txt").style.color = '#1e293b' - } else if (document.getElementById('highestChkA').checked) { - document.getElementById("lowestChk").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt").style.color = '#1e293b' - document.getElementById("recChk").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt").style.color = '#1e293b' - document.getElementById("highestChk").style.borderColor = '#38bdf8' - document.getElementById("highest-txt").style.color = '#38bdf8' - document.getElementById("ulChk").style.borderColor = '#e2e8f0' - document.getElementById("ul-txt").style.color = '#1e293b' - } else if (document.getElementById('ulChkA').checked) { - document.getElementById("lowestChk").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt").style.color = '#1e293b' - document.getElementById("recChk").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt").style.color = '#1e293b' - document.getElementById("highestChk").style.borderColor = '#e2e8f0' - document.getElementById("highest-txt").style.color = '#1e293b' - document.getElementById("ulChk").style.borderColor = '#38bdf8' - document.getElementById("ul-txt").style.color = '#38bdf8' - } - document.getElementById("submitBtn_1").style.backgroundColor="#38bdf8" - document.getElementById("submitBtn_1").style.color = "white" - } + document.getElementById("submitBtn_1").style.backgroundColor="#38bdf8" + document.getElementById("submitBtn_1").style.color = "white" } if (validation == 'extCustomPage' || validation == 'splitCustomPage') { if (document.getElementById("customPage").value != '') { @@ -179,24 +642,6 @@ function checkValidation(validation) { document.getElementById("wm_file_input").style.borderColor = "#dc2626" } } - if (validation == 'urlToPDF') { - if (document.getElementById("urlToPDF").value != '') { - document.getElementById("urlToPDF").style.borderColor = "#d1d5db" - } else { - document.getElementById("urlToPDF").style.borderColor = "#dc2626" - } - } -} - -function dropdownManage() { - if (document.getElementById('dropdownNavbarLink').value == "1") { - document.getElementById('dropdownNavbarImage').style.transform = 'rotate(-90deg)'; - document.getElementById('dropdownNavbarLink').value = "0"; - } else { - document.getElementById('dropdownNavbarImage').style.transform = 'rotate(0deg)'; - document.getElementById('dropdownNavbarLink').value = "1"; - - } } function dropdownCnvToPDF() { @@ -228,6 +673,37 @@ function dropdownCnvFromPDF() { } } +function dropdownManage() { + if (document.getElementById('dropdownNavbarLink').value == "1") { + document.getElementById('dropdownNavbarImage').style.transform = 'rotate(-90deg)'; + document.getElementById('dropdownNavbarLink').value = "0"; + } else { + document.getElementById('dropdownNavbarImage').style.transform = 'rotate(0deg)'; + document.getElementById('dropdownNavbarLink').value = "1"; + + } +} + +function formatBytes(bytes, decimals = 2) { + if (!+bytes) return '0 Bytes' + + const k = 1024 + const dm = decimals < 0 ? 0 : decimals + const sizes = ['Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'] + + const i = Math.floor(Math.log(bytes) / Math.log(k)) + + return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}` +} + +function generateMesssage(subMessage) { + var ul = document.getElementById("pre-title"); + var li = document.createElement("li"); + li.id = "pre-list_"+ul.childElementCount; + li.appendChild(document.createTextNode(subMessage)); + ul.appendChild(li); +} + function init() { if (document.getElementById('cnvFrPDF') !== null || document.getElementById('compPDF') !== null || document.getElementById('cnvToPDF') !== null) { var fullPath = document.getElementById('caption'); @@ -282,7 +758,7 @@ function init() { splitLayout.style.display="none" } } - } else if (document.getElementById("wmLayout1") !== null) { + } else if (document.getElementById("wmColImageLayoutStyleA") !== null) { var fullPath = document.getElementById('caption') var btnLayout = document.getElementById('submitBtn') var mergeLayout = document.getElementById('submitBtn_1') @@ -312,273 +788,6 @@ function init() { } } -function formatBytes(bytes, decimals = 2) { - if (!+bytes) return '0 Bytes' - - const k = 1024 - const dm = decimals < 0 ? 0 : decimals - const sizes = ['Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'] - - const i = Math.floor(Math.log(bytes) / Math.log(k)) - - return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}` -} - -function generateMesssage(subMessage) { - var ul = document.getElementById("pre-title"); - var li = document.createElement("li"); - li.id = "pre-list_"+ul.childElementCount; - li.appendChild(document.createTextNode(subMessage)); - ul.appendChild(li); -} - -function HiChkSplit3Click() { - document.getElementById("lowestChk3").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt3").style.color = '#6b7280' - document.getElementById("recChk3").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt3").style.color = '#6b7280' - document.getElementById("hiChk3").style.borderColor = '#38bdf8' - document.getElementById("hi-txt3").style.color = '#38bdf8' - document.getElementById("ulChk3").style.borderColor = '#e2e8f0' - document.getElementById("ul-txt3").style.color = '#6b7280' -} - -function HiChkSplit4Click() { - document.getElementById("lowestChk4").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt4").style.color = '#6b7280' - document.getElementById("recChk4").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt4").style.color = '#6b7280' - document.getElementById("hiChk4").style.borderColor = '#38bdf8' - document.getElementById("hi-txt4").style.color = '#38bdf8' - document.getElementById("ulChk4").style.borderColor = '#e2e8f0' - document.getElementById("ul-txt4").style.color = '#6b7280' - document.getElementById("srChk4").style.borderColor = '#e2e8f0' - document.getElementById("sr-txt4").style.color = '#6b7280' - document.getElementById("ssrChk4").style.borderColor = '#e2e8f0' - document.getElementById("ssr-txt4").style.color = '#6b7280' -} - -function HiChkSplit5Click() { - document.getElementById("lowestChk5").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt5").style.color = '#6b7280' - document.getElementById("recChk5").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt5").style.color = '#6b7280' - document.getElementById("hiChk5").style.borderColor = '#38bdf8' - document.getElementById("hi-txt5").style.color = '#38bdf8' -} - -function HiChkSplit7Click() { - document.getElementById("lowestChk7").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt7").style.color = '#6b7280' - document.getElementById("recChk7").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt7").style.color = '#6b7280' - document.getElementById("hiChk7").style.borderColor = '#38bdf8' - document.getElementById("hi-txt7").style.color = '#38bdf8' - document.getElementById("ulChk7").style.borderColor = '#e2e8f0' - document.getElementById("ul-txt7").style.color = '#6b7280' -} - -function LowChkSplitClick() { - document.getElementById("lowestChk").style.borderColor = '#38bdf8' - document.getElementById("lowest-txt").style.color = '#38bdf8' - document.getElementById("recChk").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt").style.color = '#1e293b' -} - -function LowChkSplit2Click() { - document.getElementById("lowestChk2").style.borderColor = '#38bdf8' - document.getElementById("lowest-txt2").style.color = '#38bdf8' - document.getElementById("recChk2").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt2").style.color = '#1e293b' -} - -function LowChkSplit3Click() { - document.getElementById("lowestChk3").style.borderColor = '#38bdf8' - document.getElementById("lowest-txt3").style.color = '#38bdf8' - document.getElementById("recChk3").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt3").style.color = '#6b7280' - document.getElementById("hiChk3").style.borderColor = '#e2e8f0' - document.getElementById("hi-txt3").style.color = '#6b7280' - document.getElementById("ulChk3").style.borderColor = '#e2e8f0' - document.getElementById("ul-txt3").style.color = '#6b7280' -} - -function LowChkSplit4Click() { - document.getElementById("lowestChk4").style.borderColor = '#38bdf8' - document.getElementById("lowest-txt4").style.color = '#38bdf8' - document.getElementById("recChk4").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt4").style.color = '#6b7280' - document.getElementById("hiChk4").style.borderColor = '#e2e8f0' - document.getElementById("hi-txt4").style.color = '#6b7280' - document.getElementById("ulChk4").style.borderColor = '#e2e8f0' - document.getElementById("ul-txt4").style.color = '#6b7280' - document.getElementById("srChk4").style.borderColor = '#e2e8f0' - document.getElementById("sr-txt4").style.color = '#6b7280' - document.getElementById("ssrChk4").style.borderColor = '#e2e8f0' - document.getElementById("ssr-txt4").style.color = '#6b7280' -} - -function LowChkSplit5Click() { - document.getElementById("lowestChk5").style.borderColor = '#38bdf8' - document.getElementById("lowest-txt5").style.color = '#38bdf8' - document.getElementById("recChk5").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt5").style.color = '#6b7280' - document.getElementById("hiChk5").style.borderColor = '#e2e8f0' - document.getElementById("hi-txt5").style.color = '#6b7280' -} - -function LowChkSplit6Click() { - document.getElementById("lowestChk6").style.borderColor = '#38bdf8' - document.getElementById("lowest-txt6").style.color = '#38bdf8' - document.getElementById("recChk6").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt6").style.color = '#6b7280' -} - -function LowChkSplit7Click() { - document.getElementById("lowestChk7").style.borderColor = '#38bdf8' - document.getElementById("lowest-txt7").style.color = '#38bdf8' - document.getElementById("recChk7").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt7").style.color = '#6b7280' - document.getElementById("hiChk7").style.borderColor = '#e2e8f0' - document.getElementById("hi-txt7").style.color = '#6b7280' - document.getElementById("ulChk7").style.borderColor = '#e2e8f0' - document.getElementById("ul-txt7").style.color = '#6b7280' -} - -function RecChkSplitClick() { - document.getElementById("lowestChk").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt").style.color = '#1e293b' - document.getElementById("recChk").style.borderColor = '#38bdf8' - document.getElementById("rec-txt").style.color = '#38bdf8' -} - -function RecChkSplit2Click() { - document.getElementById("lowestChk2").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt2").style.color = '#1e293b' - document.getElementById("recChk2").style.borderColor = '#38bdf8' - document.getElementById("rec-txt2").style.color = '#38bdf8' -} - -function RecChkSplit3Click() { - document.getElementById("lowestChk3").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt3").style.color = '#6b7280' - document.getElementById("recChk3").style.borderColor = '#38bdf8' - document.getElementById("rec-txt3").style.color = '#38bdf8' - document.getElementById("hiChk3").style.borderColor = '#e2e8f0' - document.getElementById("hi-txt3").style.color = '#6b7280' - document.getElementById("ulChk3").style.borderColor = '#e2e8f0' - document.getElementById("ul-txt3").style.color = '#6b7280' -} - -function RecChkSplit4Click() { - document.getElementById("lowestChk4").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt4").style.color = '#6b7280' - document.getElementById("recChk4").style.borderColor = '#38bdf8' - document.getElementById("rec-txt4").style.color = '#38bdf8' - document.getElementById("hiChk4").style.borderColor = '#e2e8f0' - document.getElementById("hi-txt4").style.color = '#6b7280' - document.getElementById("ulChk4").style.borderColor = '#e2e8f0' - document.getElementById("ul-txt4").style.color = '#6b7280' - document.getElementById("srChk4").style.borderColor = '#e2e8f0' - document.getElementById("sr-txt4").style.color = '#6b7280' - document.getElementById("ssrChk4").style.borderColor = '#e2e8f0' - document.getElementById("ssr-txt4").style.color = '#6b7280' -} - -function RecChkSplit5Click() { - document.getElementById("lowestChk5").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt5").style.color = '#6b7280' - document.getElementById("recChk5").style.borderColor = '#38bdf8' - document.getElementById("rec-txt5").style.color = '#38bdf8' - document.getElementById("hiChk5").style.borderColor = '#e2e8f0' - document.getElementById("hi-txt5").style.color = '#6b7280' -} - -function RecChkSplit6Click() { - document.getElementById("lowestChk6").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt6").style.color = '#6b7280' - document.getElementById("recChk6").style.borderColor = '#38bdf8' - document.getElementById("rec-txt6").style.color = '#38bdf8' -} - -function RecChkSplit7Click() { - document.getElementById("lowestChk7").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt7").style.color = '#6b7280' - document.getElementById("recChk7").style.borderColor = '#38bdf8' - document.getElementById("rec-txt7").style.color = '#38bdf8' - document.getElementById("hiChk7").style.borderColor = '#e2e8f0' - document.getElementById("hi-txt7").style.color = '#6b7280' - document.getElementById("ulChk7").style.borderColor = '#e2e8f0' - document.getElementById("ul-txt7").style.color = '#6b7280' -} - -function SRChkSplit4Click() { - document.getElementById("lowestChk4").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt4").style.color = '#6b7280' - document.getElementById("recChk4").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt4").style.color = '#6b7280' - document.getElementById("hiChk4").style.borderColor = '#e2e8f0' - document.getElementById("hi-txt4").style.color = '#6b7280' - document.getElementById("ulChk4").style.borderColor = '#e2e8f0' - document.getElementById("ul-txt4").style.color = '#6b7280' - document.getElementById("srChk4").style.borderColor = '#38bdf8' - document.getElementById("sr-txt4").style.color = '#38bdf8' - document.getElementById("ssrChk4").style.borderColor = '#e2e8f0' - document.getElementById("ssr-txt4").style.color = '#6b7280' -} - -function SSRChkSplit4Click() { - document.getElementById("lowestChk4").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt4").style.color = '#6b7280' - document.getElementById("recChk4").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt4").style.color = '#6b7280' - document.getElementById("hiChk4").style.borderColor = '#e2e8f0' - document.getElementById("hi-txt4").style.color = '#6b7280' - document.getElementById("ulChk4").style.borderColor = '#e2e8f0' - document.getElementById("ul-txt4").style.color = '#6b7280' - document.getElementById("srChk4").style.borderColor = '#e2e8f0' - document.getElementById("sr-txt4").style.color = '#6b7280' - document.getElementById("ssrChk4").style.borderColor = '#38bdf8' - document.getElementById("ssr-txt4").style.color = '#38bdf8' -} - -function UlChkSplit3Click() { - document.getElementById("lowestChk3").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt3").style.color = '#6b7280' - document.getElementById("recChk3").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt3").style.color = '#6b7280' - document.getElementById("hiChk3").style.borderColor = '#e2e8f0' - document.getElementById("hi-txt3").style.color = '#6b7280' - document.getElementById("ulChk3").style.borderColor = '#38bdf8' - document.getElementById("ul-txt3").style.color = '#38bdf8' -} - -function UlChkSplit4Click() { - document.getElementById("lowestChk4").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt4").style.color = '#6b7280' - document.getElementById("recChk4").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt4").style.color = '#6b7280' - document.getElementById("hiChk4").style.borderColor = '#e2e8f0' - document.getElementById("hi-txt4").style.color = '#6b7280' - document.getElementById("ulChk4").style.borderColor = '#38bdf8' - document.getElementById("ul-txt4").style.color = '#38bdf8' - document.getElementById("srChk4").style.borderColor = '#e2e8f0' - document.getElementById("sr-txt4").style.color = '#6b7280' - document.getElementById("ssrChk4").style.borderColor = '#e2e8f0' - document.getElementById("ssr-txt4").style.color = '#6b7280' -} - -function UlChkSplit7Click() { - document.getElementById("lowestChk7").style.borderColor = '#e2e8f0' - document.getElementById("lowest-txt7").style.color = '#6b7280' - document.getElementById("recChk7").style.borderColor = '#e2e8f0' - document.getElementById("rec-txt7").style.color = '#6b7280' - document.getElementById("hiChk7").style.borderColor = '#e2e8f0' - document.getElementById("hi-txt7").style.color = '#6b7280' - document.getElementById("ulChk7").style.borderColor = '#38bdf8' - document.getElementById("ul-txt7").style.color = '#38bdf8' -} - function reloadIFrame() { var iframe = document.getElementById("iFrame"); if (iframe !== null) { @@ -598,23 +807,46 @@ function reloadIFrame() { } -function remove_wm() { - var pdfComp = document.getElementById('pdfCompLayout'); - var pdfImage = document.getElementById('pdfPreview'); - var pdfWMlayout = document.getElementById('grid-layout_2'); - pdfComp.style.display="none"; - pdfWMlayout.style.display="none"; - pdfImage.style.display="none"; -} - -function showLayout() { - var layout = document.getElementById('wmLayout1'); - layout.style = null +function reuseOnClickWmLayoutImageStyleAreaA() { + wmLayoutImageStyleColumnAreaA.style.borderColor = '#38bdf8' + wmLayoutImageStyleAreaTextA.style.color = '#38bdf8' + wmLayoutImageRadioAreaInputA.checked = true + firstColumnArea.style = null + firstAreaText.color = '#6b7280' + secondColumnArea.style = null + secondAreaText.color = '#6b7280' + wmLayoutImageStyleColumnAreaB.style = null + wmLayoutImageStyleAreaTextB.style.color = '#6b7280' + if (firstAreaInput.checked == true) { + firstColumnArea.style.borderColor = '#38bdf8' + firstAreaText.style.color = '#38bdf8' + firstAreaInput.checked = true + } else if (secondAreaInput.checked == true) { + secondColumnArea.style.borderColor = '#38bdf8' + secondAreaText.style.color = '#38bdf8' + secondAreaInput.checked = true + } } -function showLayout3() { - var layout = document.getElementById('splitLayout3'); - layout.style = null +function reuseOnClickWmLayoutImageStyleAreaB() { + wmLayoutImageStyleColumnAreaB.style.borderColor = '#38bdf8' + wmLayoutImageStyleAreaTextB.style.color = '#38bdf8' + wmLayoutImageRadioAreaInputB.checked = true + firstColumnArea.style = null + firstAreaText.color = '#6b7280' + secondColumnArea.style = null + secondAreaText.color = '#6b7280' + wmLayoutImageStyleColumnAreaA.style = null + wmLayoutImageStyleAreaTextA.style.color = '#6b7280' + if (firstAreaInput.checked == true) { + firstColumnArea.style.borderColor = '#38bdf8' + firstAreaText.style.color = '#38bdf8' + firstAreaInput.checked = true + } else if (secondAreaInput.checked == true) { + secondColumnArea.style.borderColor = '#38bdf8' + secondAreaText.style.color = '#38bdf8' + secondAreaInput.checked = true + } } function showVal(newVal){ @@ -622,451 +854,103 @@ function showVal(newVal){ } function splitLayout2_split(){ - document.getElementById("splitLayout2").innerHTML = ` -
Image (Max. 25 MB)
-It will stamp a 3x3 matrix mosaic of into your document
-It will stamp a 3x3 matrix mosaic of into your document
-