From 67ee0a9d8c679b745fe643f307735df20d84f787 Mon Sep 17 00:00:00 2001 From: Dharmrajsinh Jadeja Date: Wed, 26 Jun 2024 23:18:40 +0530 Subject: [PATCH] Update generate.php --- generate.php | 92 ++++++++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 43 deletions(-) diff --git a/generate.php b/generate.php index bbd41dd..f7e954f 100644 --- a/generate.php +++ b/generate.php @@ -56,6 +56,14 @@ +
+ + +
+
+ + +
@@ -84,47 +92,45 @@ '; echo $content; -if (isset($_POST['uploadBtn']) && $_POST['uploadBtn'] == 'Upload & Send Emails') { - if (isset($_FILES['uploadedFile']) && $_FILES['uploadedFile']['error'] === UPLOAD_ERR_OK) { - // get details of the uploaded file - $fileTmpPath = $_FILES['uploadedFile']['tmp_name']; - $fileName = $_FILES['uploadedFile']['name']; - $fileSize = $_FILES['uploadedFile']['size']; - $fileType = $_FILES['uploadedFile']['type']; - $fileNameCmps = explode(".", $fileName); - $fileExtension = strtolower(end($fileNameCmps)); - $newFileName = md5($fileName).'.'. $fileExtension; //sanitize the filename - $allowedfileExtensions = array('csv'); - if (in_array($fileExtension, $allowedfileExtensions)) { - // directory in which the uploaded file will be moved - if (!file_exists(plugin_dir_path(__FILE__).'data/')) { - mkdir(plugin_dir_path(__FILE__).'data/', 0777, true); - } - $uploadFileDir = plugin_dir_path(__FILE__).'data/'; - $dest_path = $uploadFileDir . $newFileName; - - if(move_uploaded_file($fileTmpPath, $dest_path)) - { - echo 'CSV File is successfully uploaded.'; - $input_data['org_image'] = $_POST['org_image']; - $input_data['bg_image'] = $_POST['bg_image']; - $input_data['sender_name'] = $_POST['sender_name']; - $input_data['sender_email'] = $_POST['sender_email']; - $input_data['general_font_size'] = $_POST['general_font_size']; - $input_data['attendee_font_size'] = $_POST['attendee_font_size']; - $input_data['event_title_font_size'] = $_POST['event_title_font_size']; - $input_data['email_body'] = htmlspecialchars(str_replace('\\"', '"', $_POST['email_body'])); - do_action(read_data($dest_path,$input_data)); - exit(); - } - else - { - echo 'There was some error moving the file to upload directory. Please make sure the upload directory is writable by web server.'; - } - } - else{ - echo 'Unsupported file. Please try again.'; - exit(); - } - } +if ( isset( $_POST['uploadBtn'] ) && $_POST['uploadBtn'] == 'Upload & Send Emails' ) { + if ( isset( $_FILES['uploadedFile'] ) && $_FILES['uploadedFile']['error'] === UPLOAD_ERR_OK ) { + // get details of the uploaded file + $fileTmpPath = $_FILES['uploadedFile']['tmp_name']; + $fileName = $_FILES['uploadedFile']['name']; + $fileSize = $_FILES['uploadedFile']['size']; + $fileType = $_FILES['uploadedFile']['type']; + $fileNameCmps = explode( '.', $fileName ); + $fileExtension = strtolower( end( $fileNameCmps ) ); + $newFileName = md5( $fileName ) . '.' . $fileExtension; // sanitize the filename + $allowedfileExtensions = array( 'csv' ); + if ( in_array( $fileExtension, $allowedfileExtensions ) ) { + // directory in which the uploaded file will be moved + if ( ! file_exists( plugin_dir_path( __FILE__ ) . 'data/' ) ) { + mkdir( plugin_dir_path( __FILE__ ) . 'data/', 0777, true ); + } + $uploadFileDir = plugin_dir_path( __FILE__ ) . 'data/'; + $dest_path = $uploadFileDir . $newFileName; + + if ( move_uploaded_file( $fileTmpPath, $dest_path ) ) { + echo 'CSV File is successfully uploaded.'; + $input_data['org_image'] = $_POST['org_image']; + $input_data['bg_image'] = $_POST['bg_image']; + $input_data['sender_name'] = $_POST['sender_name']; + $input_data['sender_email'] = $_POST['sender_email']; + $input_data['start_sub_line'] = $_POST['start_sub_line']; + $input_data['second_sub_line'] = $_POST['second_sub_line']; + $input_data['general_font_size'] = $_POST['general_font_size']; + $input_data['attendee_font_size'] = $_POST['attendee_font_size']; + $input_data['event_title_font_size'] = $_POST['event_title_font_size']; + $input_data['email_body'] = htmlspecialchars( str_replace( '\\"', '"', $_POST['email_body'] ) ); + do_action( read_data( $dest_path, $input_data ) ); + exit(); + } else { + echo 'There was some error moving the file to upload directory. Please make sure the upload directory is writable by web server.'; + } + } else { + echo 'Unsupported file. Please try again.'; + exit(); + } + } }