Skip to content

Commit ca98d77

Browse files
committed
v7.4.4
1 parent 57ce605 commit ca98d77

File tree

20 files changed

+735
-719
lines changed

20 files changed

+735
-719
lines changed

application/config/constants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php if ( ! defined( 'BASEPATH' ) ) {
22
exit( 'No direct script access allowed' );}
33

4-
define( 'UIFORM_VERSION', '7.4.3' );
4+
define( 'UIFORM_VERSION', '7.4.4' );
55
define( 'ZIGAFORM_F_LITE', 1 );
66
define( 'UIFORM_DEBUG', 0 );
77
define( 'UIFORM_DEMO', 0 );

application/modules/formbuilder/controllers/frontend.php

Lines changed: 71 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,16 @@ public function ajax_check_recaptchav3()
867867
}
868868
public function process_form_fields($form_fields, $form_id)
869869
{
870+
871+
// upload an image and document options
872+
$config = array();
873+
$config['upload_path'] = FCPATH . 'uploads';
874+
$config['allowed_types'] = 'jpg|png|gif|jpeg|JPG|PNG|GIF|JPEG|pdf|doc|docx|xls|xlsx|zip|rar';
875+
$config['max_size'] = '2097152'; // 0 = no file size limit
876+
$config['overwrite'] = false;
877+
$config['remove_spaces'] = true;
878+
$this->load->library( 'upload', $config );
879+
870880
$form_f_tmp = array();
871881
$form_f_rec_tmp = array();
872882
$form_errors = array();
@@ -988,67 +998,70 @@ public function process_form_fields($form_fields, $form_id)
988998
break;
989999
case 12:
9901000
/*file input field*/
991-
case 13:
992-
/*image upload*/
993-
$tmp_fdata = json_decode($tmp_field_name->data, true);
994-
995-
$tmp_options = array();
996-
$tmp_field_label = (!empty($tmp_fdata['label']['text'])) ? $tmp_fdata['label']['text'] : $tmp_field_name->fieldname;
997-
$form_f_tmp[$key]['type'] = $tmp_field_name->type;
998-
$form_f_tmp[$key]['fieldname'] = $tmp_field_name->fieldname;
999-
$form_f_tmp[$key]['label'] = $tmp_field_label;
1000-
1001-
$allowedext_default = array('aaaa', 'png', 'doc', 'docx', 'xls', 'xlsx', 'csv', 'txt', 'rtf', 'zip', 'mp3', 'wma', 'wmv', 'mpg', 'flv', 'avi', 'jpg', 'jpeg', 'png', 'gif', 'ods', 'rar', 'ppt', 'tif', 'wav', 'mov', 'psd', 'eps', 'sit', 'sitx', 'cdr', 'ai', 'mp4', 'm4a', 'bmp', 'pps', 'aif', 'pdf');
1002-
$custom_allowedext = (!empty($tmp_fdata['input16']['extallowed'])) ? array_map('trim', explode(',', $tmp_fdata['input16']['extallowed'])) : $allowedext_default;
1003-
$custom_maxsize = (!empty($tmp_fdata['input16']['maxsize'])) ? floatval($tmp_fdata['input16']['maxsize']) : 5;
1004-
$custom_attach_st = (isset($tmp_fdata['input16']['attach_st'])) ? intval($tmp_fdata['input16']['attach_st']) : 0;
1005-
1006-
if (
1007-
isset($_FILES['uiform_fields']['name'][$key])
1008-
&& !empty($_FILES['uiform_fields']['name'][$key])
1009-
) {
1010-
$fileSize = $_FILES['uiform_fields']['size'][$key];
1011-
if (floatval($fileSize) > $custom_maxsize * 1024 * 1024) {
1012-
$form_errors[] = __('Error! The file exceeds the allowed size of', 'frocket_front') . ' ' . $custom_maxsize . ' MB';
1013-
}
1014-
/*find attachment max size found*/
1015-
$attachment_status = ($attachment_status < $custom_attach_st) ? $custom_attach_st : $attachment_status;
1016-
1017-
$ext = strtolower(substr($_FILES['uiform_fields']['name'][$key], strrpos($_FILES['uiform_fields']['name'][$key], '.') + 1));
1018-
if (!in_array($ext, $custom_allowedext)) {
1019-
$form_errors[] = __('Error! Type of file is not allowed to upload', 'frocket_front');
1020-
}
1021-
if (empty($form_errors)) {
1022-
$upload_data = wp_upload_dir(); // look for this function in WordPress documentation at codex
1023-
$upload_dir = $upload_data['path'];
1024-
$upload_dirurl = $upload_data['baseurl'];
1025-
$upload_subdir = $upload_data['subdir'];
1026-
$rename = 'file_' . md5(uniqid($_FILES['uiform_fields']['name'][$key], true));
1027-
1028-
$_FILES['uiform_fields']['name'][$key] = $rename . '.' . strtolower($ext);
1029-
1030-
$form_f_tmp[$key]['input'] = $upload_dirurl . $upload_subdir . '/' . $_FILES['uiform_fields']['name'][$key];
1031-
$form_f_rec_tmp[$key] = $upload_dirurl . $upload_subdir . '/' . $_FILES['uiform_fields']['name'][$key];
1032-
$form_fields[$key] = $upload_dirurl . $upload_subdir . '/' . $_FILES['uiform_fields']['name'][$key];
1033-
1034-
// attachment
1035-
1036-
if ($_FILES['uiform_fields']['error'][$key] == UPLOAD_ERR_OK) {
1037-
$tmp_name = $_FILES['uiform_fields']['tmp_name'][$key]; // Get temp name of uploaded file
1038-
$name = $_FILES['uiform_fields']['name'][$key]; // rename it to whatever
1039-
move_uploaded_file($tmp_name, "$upload_dir/$name"); // move file to new location
1040-
if (intval($custom_attach_st) === 1) {
1041-
$attachments[] = "$upload_dir/$name"; // push the new uploaded file in attachment array
1001+
case 13:
1002+
/*image upload*/
1003+
$tmp_fdata = json_decode($tmp_field_name->data, true);
1004+
1005+
$tmp_options = array();
1006+
$tmp_field_label = (!empty($tmp_fdata['label']['text'])) ? $tmp_fdata['label']['text'] : $tmp_field_name->fieldname;
1007+
$form_f_tmp[$key]['type'] = $tmp_field_name->type;
1008+
$form_f_tmp[$key]['fieldname'] = $tmp_field_name->fieldname;
1009+
$form_f_tmp[$key]['label'] = $tmp_field_label;
1010+
1011+
$allowedext_default = array('aaaa', 'png', 'doc', 'docx', 'xls', 'xlsx', 'csv', 'txt', 'rtf', 'zip', 'mp3', 'wma', 'wmv', 'mpg', 'flv', 'avi', 'jpg', 'jpeg', 'png', 'gif', 'ods', 'rar', 'ppt', 'tif', 'wav', 'mov', 'psd', 'eps', 'sit', 'sitx', 'cdr', 'ai', 'mp4', 'm4a', 'bmp', 'pps', 'aif', 'pdf');
1012+
$custom_allowedext = (!empty($tmp_fdata['input16']['extallowed'])) ? array_map('trim', explode(',', $tmp_fdata['input16']['extallowed'])) : $allowedext_default;
1013+
$custom_maxsize = (!empty($tmp_fdata['input16']['maxsize'])) ? floatval($tmp_fdata['input16']['maxsize']) : 5;
1014+
$custom_attach_st = (isset($tmp_fdata['input16']['attach_st'])) ? intval($tmp_fdata['input16']['attach_st']) : 0;
1015+
1016+
if (
1017+
isset($_FILES['uiform_fields']['name'][$key])
1018+
&& !empty($_FILES['uiform_fields']['name'][$key])
1019+
) {
1020+
$fileSize = $_FILES['uiform_fields']['size'][$key];
1021+
if (floatval($fileSize) > $custom_maxsize * 1024 * 1024) {
1022+
$form_errors[] = __('Error! The file exceeds the allowed size of', 'frocket_front') . ' ' . $custom_maxsize . ' MB';
1023+
}
1024+
/*find attachment max size found*/
1025+
$attachment_status = ($attachment_status < $custom_attach_st) ? $custom_attach_st : $attachment_status;
1026+
1027+
$ext = strtolower(substr($_FILES['uiform_fields']['name'][$key], strrpos($_FILES['uiform_fields']['name'][$key], '.') + 1));
1028+
if (!in_array($ext, $custom_allowedext)) {
1029+
$form_errors[] = __('Error! Type of file is not allowed to upload', 'frocket_front');
1030+
}
1031+
if ( empty( $form_errors ) ) {
1032+
$config['allowed_types'] = '*';
1033+
$config['max_size'] = $custom_maxsize * 1024 * 1024; // 0 = no file size limit
1034+
$this->upload->initialize( $config );
1035+
1036+
$rename = 'file_' . md5( uniqid( $_FILES['uiform_fields']['name'][ $key ], true ) );
1037+
1038+
$_FILES['uiform_fields']['name'][ $key ] = $rename . '.' . strtolower( $ext );
1039+
1040+
// attachment
1041+
1042+
if ( ! $this->upload->do_upload2( $key ) ) {
1043+
$form_errors[] = __( 'Error! File not uploaded - ' . $this->upload->display_errors( '<span>', '</span>' ), 'frocket_front' );
1044+
} else {
1045+
$data_upload_files = $this->upload->data();
1046+
$image = base_url() . 'uploads/' . $data_upload_files['file_name'];
1047+
// getting image uploaed
1048+
if ( intval( $custom_attach_st ) === 1 ) {
1049+
$attachments[] = $data_upload_files['file_path'] . $data_upload_files['file_name'];
1050+
}
1051+
1052+
$form_f_tmp[ $key ]['input'] = $image;
1053+
$form_f_rec_tmp[ $key ] = $image;
1054+
$form_fields[ $key ] = $image;
1055+
10421056
}
10431057
}
1058+
} else {
1059+
unset($form_fields[$key]);
1060+
$form_f_tmp[$key]['input'] = '';
1061+
$form_f_rec_tmp[$key] = '';
10441062
}
1045-
} else {
1046-
unset($form_fields[$key]);
1047-
$form_f_tmp[$key]['input'] = '';
1048-
$form_f_rec_tmp[$key] = '';
1049-
}
1050-
1051-
break;
1063+
1064+
break;
10521065
case 16:
10531066
/*slider*/
10541067
case 18:

0 commit comments

Comments
 (0)