PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.11.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.11.1
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / back / Core / wordpress / file.php

file.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.11.1, at back/Core/wordpress/file.php

57 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 function acym_fileGetContent(string $url, int $timeout = 10)
4 {
5 if (strpos($url, '_custom.ini') !== false && !file_exists($url)) {
6 return '';
7 }
8
9 ob_start();
10 $data = '';
11
12 $allowUrlFopen = ini_get('allow_url_fopen');
13
14 if (function_exists('file_get_contents') && (!empty($allowUrlFopen) || strpos($url, 'http') !== 0)) {
15 if (!empty($timeout)) {
16 ini_set('default_socket_timeout', $timeout);
17 }
18 $streamContext = stream_context_create(['ssl' => ['verify_peer' => false, 'verify_peer_name' => false]]);
19 $data = file_get_contents($url, false, $streamContext);
20 }
21
22 if (empty($data) && strpos($url, 'http') === 0 && class_exists('WP_Http') && method_exists('WP_Http', 'request')) {
23 $args = ['timeout' => $timeout];
24 $request = new WP_Http();
25 $data = $request->request($url, $args);
26 $data = (empty($data) || !is_array($data) || empty($data['body'])) ? '' : $data['body'];
27 }
28
29 if (empty($data) && function_exists('fopen') && function_exists('stream_get_contents')) {
30 $handle = fopen($url, 'r');
31 if (!empty($handle)) {
32 if (!empty($timeout)) {
33 stream_set_timeout($handle, $timeout);
34 }
35 $data = stream_get_contents($handle);
36 }
37 }
38 $warnings = ob_get_clean();
39
40 if (acym_isDebug()) {
41 echo $warnings;
42 }
43
44 return $data;
45 }
46
47 function acym_extractArchive(string $archive, string $destination): bool
48 {
49 if (substr($archive, strlen($archive) - 4) !== '.zip') {
50 return false;
51 }
52
53 WP_Filesystem();
54
55 return true === unzip_file($archive, $destination);
56 }
57