-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathemsfb.php
More file actions
230 lines (194 loc) · 7.24 KB
/
emsfb.php
File metadata and controls
230 lines (194 loc) · 7.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?php
/**
* Plugin Name: Easy Form Builder
* Plugin URI: https://whitestudio.team
* Description: Easily create multi-step forms with a unique Confirmation Code feature and notification emails, all without any coding knowledge required, using the easy-to-use drag and drop form wizard of Easy Form Builder. This is the free version and provides an intuitive interface and functionality to create professional forms in minutes. With the unique Confirmation Code feature, you can easily associate each submission with a specific request or user.
* Version: 4.0.5
* Author: WhiteStudio
* Author URI: https://whitestudio.team
* Text Domain: easy-form-builder
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Domain Path: /languages
*/
if (!defined('ABSPATH')) {
die("Direct access of plugin files is not allowed.");
}
if (!defined('EMSFB_PLUGIN_FILE')) {
define('EMSFB_PLUGIN_FILE', __FILE__);
}
if (!defined("EMSFB_PLUGIN_DIRECTORY")) {
define("EMSFB_PLUGIN_DIRECTORY", plugin_dir_path(__FILE__));
}
if (!defined("EMSFB_PLUGIN_VERSION")) {
define("EMSFB_PLUGIN_VERSION", "4.0.6");
}
if (!defined("EMSFB_DB_VERSION")) {
define("EMSFB_DB_VERSION", 1.1);
}
if (!defined("EMSFB_PLUGIN_URL")) {
define("EMSFB_PLUGIN_URL", plugin_dir_url(__FILE__));
}
if (!defined("WP_PLUGIN_DIR")) {
define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
}
if (!defined("EMSFB_DEV_MODE")) {
$dev_mode = get_option('emsfb_dev_mode', '2');
if($dev_mode === '2') {
update_option('emsfb_dev_mode', '0');
define("EMSFB_DEV_MODE", false);
}else{
define("EMSFB_DEV_MODE", $dev_mode === '1' || $dev_mode === true ? true : false);
}
}
if (!defined("EMSFB_SERVER_URL")) {
if (EMSFB_DEV_MODE) {
define("EMSFB_SERVER_URL", "https://demo.whitestudio.team");
} else {
define("EMSFB_SERVER_URL", "https://whitestudio.team");
}
}
if (!defined("EMSFB_IS_FARSI")) {
if (get_locale() == 'fa_IR') {
//THIS LINE COMMENTED TO AVOID PROBLEMS WITH CDN IN FARSI LANGUAGE BECUSE OF SHUTDOWN IRAN NETWORK!!
define("CDN_ZONE_AREA", "https://cdn.easyformbuilder.ir/gh/Json-List-of-countries-states-and-cities-in-the-world/");
// define("CDN_ZONE_AREA", "https://cdn.jsdelivr.net/gh/hassantafreshi/Json-List-of-countries-states-and-cities-in-the-world@main/");
} else {
define("CDN_ZONE_AREA", "https://cdn.jsdelivr.net/gh/hassantafreshi/Json-List-of-countries-states-and-cities-in-the-world@main/");
}
}
require 'includes/class-Emsfb.php';
$emsfb = new Emsfb();
register_activation_hook(__FILE__, 'emsfb_schedule_file_access_check');
add_action('emsfb_check_file_access_after_activation', 'emsfb_perform_file_access_check_efb');
function emsfb_schedule_file_access_check() {
if (!wp_next_scheduled('emsfb_check_file_access_after_activation')) {
wp_schedule_single_event(time() + 20, 'emsfb_check_file_access_after_activation');
}
}
function emsfb_perform_file_access_check_efb() {
$result = emsfb_check_file_access_efb();
}
function emsfb_check_file_access_efb() {
$vendor_path = EMSFB_PLUGIN_DIRECTORY . 'vendor';
$temp_path = EMSFB_PLUGIN_DIRECTORY . 'temp';
$status = true;
$error_codes = [];
$details = [];
if (!file_exists($vendor_path)) {
$status = false;
$error_codes[] = 'VENDOR_NOT_EXIST';
} else {
$details['vendor_exists'] = true;
if (!is_writable($vendor_path)) {
$status = false;
$error_codes[] = 'VENDOR_NOT_WRITABLE';
} else {
$details['vendor_writable'] = true;
}
}
if (!file_exists($temp_path)) {
if (is_writable(dirname($temp_path))) {
$create_temp = wp_mkdir_p($temp_path);
if (!$create_temp) {
$status = false;
$error_codes[] = 'TEMP_CREATE_FAILED';
} else {
$details['temp_created'] = true;
}
} else {
$status = false;
$error_codes[] = 'TEMP_PARENT_NOT_WRITABLE';
}
} else {
$details['temp_exists'] = true;
if (!is_writable($temp_path)) {
$status = false;
$error_codes[] = 'TEMP_NOT_WRITABLE';
} else {
$details['temp_writable'] = true;
}
}
if (!is_writable(EMSFB_PLUGIN_DIRECTORY)) {
$status = false;
$error_codes[] = 'PLUGIN_DIR_NOT_WRITABLE';
} else {
$details['plugin_writable'] = true;
}
if (!function_exists('WP_Filesystem')) {
require_once(ABSPATH . 'wp-admin/includes/file.php');
}
if (!WP_Filesystem()) {
$status = false;
$error_codes[] = 'WP_FILESYSTEM_FAILED';
} else {
$details['wp_filesystem'] = true;
}
$free_bytes = disk_free_space(EMSFB_PLUGIN_DIRECTORY);
if (!$free_bytes || $free_bytes < (10 * 1024 * 1024)) {
$status = false;
$error_codes[] = 'INSUFFICIENT_DISK_SPACE';
} else {
$details['sufficient_space'] = true;
$details['free_space_mb'] = round($free_bytes / (1024 * 1024), 2);
}
if ($status && file_exists($vendor_path)) {
$test_file = $vendor_path . '/test_write_efb.txt';
$test_content = 'EFB addon test';
if (@file_put_contents($test_file, $test_content) === false) {
$status = false;
$error_codes[] = 'WRITE_TEST_FAILED';
} else {
if (@file_get_contents($test_file) !== $test_content) {
$status = false;
$error_codes[] = 'READ_TEST_FAILED';
} else {
$details['write_test'] = true;
}
@unlink($test_file);
}
}
$success_message = esc_html__('Addon directory is ready for file operations', 'easy-form-builder');
$error_message = sprintf(
esc_html__('Cannot install addons: %s', 'easy-form-builder'),
implode(', ', $error_codes)
);
$result = [
'status' => $status,
'checked_at' => current_time('mysql'),
'plugin_version' => EMSFB_PLUGIN_VERSION,
'error_codes' => $error_codes,
'details' => $details,
'success_message' => $success_message,
'error_message' => $error_message,
'current_message' => $status ? $success_message : $error_message
];
update_option('emsfb_file_access_status', $result);
return $result;
}
function emsfb_get_file_access_status_efb() {
$state= get_option('emsfb_file_access_status', null);
if (!$state) {
$state = emsfb_check_file_access_efb();
}
return $state;
}
function emsfb_is_addon_install_ready_efb() {
$status = emsfb_get_file_access_status_efb();
return $status && $status['status'] === true;
}
if (!function_exists('get_setting_Emsfb')) {
function get_setting_Emsfb($mode = 'decoded') {
return Emsfb::get_setting_Emsfb($mode);
}
if (!function_exists('get_efbFunction')) {
function get_efbFunction() {
return Emsfb::get_efbFunction();
}
}
}
if (!function_exists('get_locale_script_chars_efb')) {
function get_locale_script_chars_efb() {
return Emsfb::get_locale_script_chars_efb();
}
}