Changeset 3191773
- Timestamp:
- 11/19/2024 04:32:04 AM (17 months ago)
- Location:
- pdf-for-gravity-forms/trunk
- Files:
-
- 6 edited
-
backend/settings.php (modified) (3 diffs)
-
backend/shortcode.php (modified) (2 diffs)
-
frontend/index.php (modified) (1 diff)
-
gravityforms/index.php (modified) (3 diffs)
-
pdf-for-gravity-forms.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pdf-for-gravity-forms/trunk/backend/settings.php
r3189939 r3191773 8 8 add_action( 'yeepdf_custom_sizes', array($this,"add_sizes")); 9 9 add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) ); 10 } 11 public static function generateRandomString($length = 15) { 12 $characters = '0123456789abcdefghijklmnopqrstuvwxyz_'; 13 $charactersLength = strlen($characters); 14 $randomString = ''; 15 for ($i = 0; $i < $length; $i++) { 16 $randomString .= $characters[random_int(0, $charactersLength - 1)]; 17 } 18 return $randomString; 19 } 20 public static function maybe_get_random_dir() { 21 $uploads_folder = apply_filters("yeepdf_folder_download","pdfs/downloads"); 22 return $uploads_folder; 23 } 24 public static function maybe_add_random_dir() { 25 $upload_dir = wp_upload_dir(); 26 $uploads_folder = self::maybe_get_random_dir(); 27 $dir = $upload_dir['basedir'] . '/'.$uploads_folder.'/'; 28 $url = $upload_dir['baseurl'] . '/'.$uploads_folder.'/'; 29 do { 30 $rand_max = mt_getrandmax(); 31 $rand = self::generateRandomString(); 32 $dir_new = path_join( $dir, $rand ); 33 $url_new = $url.$rand; 34 } while ( file_exists( $dir_new ) ); 35 if ( wp_mkdir_p( $dir_new ) ) { 36 return array("path"=>$dir_new."/","url"=>$url_new."/"); 37 } 38 return array("path"=>$dir,"url"=>$url);; 39 } 40 public static function destroy_all_files($dirPath=null) { 41 if(!$dirPath) { 42 $upload_dir = wp_upload_dir(); 43 $uploads_folder = self::maybe_get_random_dir(); 44 $dirPath = $upload_dir['basedir'] . '/'.$uploads_folder.'/'; 45 if (! is_dir($dirPath)) { 46 throw new InvalidArgumentException("$dirPath must be a directory"); 47 } 48 if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') { 49 $dirPath .= '/'; 50 } 51 } 52 $files = glob($dirPath . '*', GLOB_MARK); 53 foreach ($files as $file) { 54 if (is_dir($file)) { 55 self::destroy_all_files($file); 56 } else { 57 unlink($file); 58 } 59 } 60 rmdir($dirPath); 10 61 } 11 62 public function plugins_loaded() { … … 149 200 $part = $path_main.$files['name']; 150 201 if ( ! file_exists( $path_main ) ) { 151 wp_mkdir_p( $path_main );152 }202 wp_mkdir_p( $path_main ); 203 } 153 204 if(file_exists($part)){ 154 205 unlink($part); … … 340 391 <?php $save = get_option("pdf_creator_save_pdf","") ?> 341 392 <input <?php checked($save,"yes") ?> type="checkbox" name="pdf_creator_save_pdf" value="yes"> 342 <?php esc_html_e("It will automatically delete pdf when sending attachment to email","pdf-for-wpforms") ?>393 <?php esc_html_e("It will automatically delete the PDF after attaching the file to the email.","pdf-for-wpforms") ?> 343 394 </td> 344 395 </tr> -
pdf-for-gravity-forms/trunk/backend/shortcode.php
r3169713 r3191773 31 31 "yeepdf_current_time" => "Current Time", 32 32 "yeepdf_images" => "Images(link,link,..)", 33 "yeepdf_random_number" => "Random Number", 33 34 ), 34 35 "User" => array( … … 90 91 return wp_date(get_option('date_format')); 91 92 break; 93 case "yeepdf_random_number": 94 return rand(10000,9999999); 95 break; 92 96 case "yeepdf_current_time": 93 97 return date(get_option('time_format')); -
pdf-for-gravity-forms/trunk/frontend/index.php
r3189939 r3191773 278 278 break; 279 279 case "upload": 280 $path_main = $upload_dir['basedir'] . '/pdfs/'; 281 if ( ! file_exists( $path_main ) ) { 282 wp_mkdir_p( $path_main ); 280 $upload_dir = Yeepdf_Settings_Main::maybe_add_random_dir(); 281 $path_name = $upload_dir["path"].$data_attrs["name"].".pdf"; 282 $url_name = $upload_dir["url"].$data_attrs["name"].".pdf"; 283 if(file_exists($path_name)){ 284 unlink($path_name); 283 285 } 284 $file_name = $path_main.$data_attrs["name"].".pdf";285 if(file_exists($file_name)){286 unlink($file_name);287 }288 286 $mpdf->WriteHTML($html); 289 $output = $mpdf->Output($ file_name,"F");290 return $file_name;287 $output = $mpdf->Output($path_name,"F"); 288 return array("path"=>$path_name,"url"=>$url_name); 291 289 break; 292 290 case "html": -
pdf-for-gravity-forms/trunk/gravityforms/index.php
r3174127 r3191773 24 24 add_action('wp_ajax_pdfbuilder_gf_re_generate', array($this,"pdfbuilder_gf_re_generate")); 25 25 add_filter("yeepdf_add_libs",array($this,"yeepdf_add_libs")); 26 } 26 add_action( "gform_after_email", array($this,"yeepdf_remove_all_file")); 27 } 28 function yeepdf_remove_all_file(){ 29 $check_settings = get_option("pdf_creator_save_pdf"); 30 if($check_settings == "yes"){ 31 Yeepdf_Settings_Main::destroy_all_files(); 32 } 33 } 27 34 function gform_replace_merge_tags($confirmation_message){ 28 35 if (preg_match('/pdf_download_gf entry_id="(\d+)"/', $confirmation_message, $matches)) { … … 156 163 } 157 164 } 158 if( $name != "" ){ 159 if(strpos($name, "entry_id") == false ){ 160 $name= GFCommon::replace_variables( $name , $form, $entry,false, false,false,"text" ); 161 $name = rand(1000,9999)."-".sanitize_file_name($name); 162 }else{ 163 $name= GFCommon::replace_variables( $name , $form, $entry,false, false,false,"text" ); 164 $name = sanitize_file_name($name); 165 } 166 }else{ 165 if( $name == "" ){ 167 166 $name = "contact"; 168 $name = rand(1000,9999)."-".sanitize_file_name($name); 169 } 167 } 168 $name= GFCommon::replace_variables( $name , $form, $entry,false, false,false,"text" ); 169 $name = sanitize_file_name($name); 170 170 if( $password != "" ){ 171 171 $password= GFCommon::replace_variables( $password , $form, $entry,false, false,false,"text" ); … … 301 301 "password" =>$password, 302 302 ); 303 $ path=Yeepdf_Create_PDF::pdf_creator_preview($data_send_settings_download);304 $pdf_lists[$id] = $ path;303 $folder_uploads =Yeepdf_Create_PDF::pdf_creator_preview($data_send_settings_download); 304 $pdf_lists[$id] = $folder_uploads["path"]; 305 305 update_option( "download_link_pdf_gf", $name ); 306 306 } -
pdf-for-gravity-forms/trunk/pdf-for-gravity-forms.php
r3189939 r3191773 4 4 * Description: Gravity Forms PDF is a helpful tool that helps you build and customize the PDF Templates for Gravity Forms. 5 5 * Plugin URI: https://add-ons.org/plugin/gravity-form-pdf-generator-attachment/ 6 * Version: 4. 2.06 * Version: 4.4.0 7 7 * Requires PHP: 5.6 8 8 * Author: add-ons.org … … 32 32 include_once YEEPDF_CREATOR_BUILDER_PATH."libs/phpqrcode.php"; 33 33 include_once YEEPDF_CREATOR_BUILDER_PATH."frontend/index.php"; 34 register_activation_hook( __FILE__, array($this,'register_activation_hook') );35 add_action( 'yeepdf_remove_all_file', array($this,"yeepdf_remove_all_file") );36 }37 function register_activation_hook(){38 if (! wp_next_scheduled ( 'yeepdf_remove_all_file' )) {39 wp_schedule_event( time(), 'daily', 'yeepdf_remove_all_file' );40 }41 }42 function yeepdf_remove_all_file(){43 $check_settings = get_option("pdf_creator_save_pdf");44 if($check_settings == "yes"){45 $upload_dir = wp_upload_dir();46 $path_main = $upload_dir['basedir'] . '/pdfs/*';47 $files = glob($path_main);48 foreach($files as $file){ // iterate files49 if(is_file($file)) {50 unlink($file); // delete file51 }52 }53 }54 34 } 55 35 } -
pdf-for-gravity-forms/trunk/readme.txt
r3189939 r3191773 4 4 Requires at least: 2.0 5 5 Tested up to: 6.7 6 Stable tag: 4. 2.06 Stable tag: 4.4.0 7 7 Requires PHP: 5.6 8 8 License: GPLv2 or later … … 74 74 75 75 == Changelog == 76 = 4.4.0 = 77 - Fixed: Do not save PDFs on the server 78 - Added: Secure the folder for downloading PDFs 79 80 = 4.3.0 = 81 - Added: Random number shortcode 82 76 83 = 4.2.0 = 77 84 - Fixed: Default Font
Note: See TracChangeset
for help on using the changeset viewer.