PluginProbe
AliNext – WooCommerce Dropshipping Plugin for AliExpress / trunk
AliNext – WooCommerce Dropshipping Plugin for AliExpress vtrunk
ali2woo-lite / includes / cdn.php

cdn.php in AliNext – WooCommerce Dropshipping Plugin for AliExpress trunk, at includes/cdn.php

94 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 //error_reporting(E_ALL);
3 //ini_set( 'display_errors', 1 );
4 // phpcs:ignoreFile WordPress.Security.NonceVerification.Recommended
5
6 use WpOrg\Requests\Requests;
7
8 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
9 header('HTTP/1.1 304 Not Modified');
10 header('Last-Modified: ' . $_SERVER['HTTP_IF_MODIFIED_SINCE'], true, 304);
11 exit;
12 }
13
14 function a2wl_mbstring_binary_safe_encoding($reset = false) {
15 static $encodings = [];
16 static $overloaded = null;
17
18 if (is_null($overloaded))
19 $overloaded = function_exists('mb_internal_encoding') && ( ini_get('mbstring.func_overload') & 2 );
20
21 if (false === $overloaded)
22 return;
23
24 if (!$reset) {
25 $encoding = mb_internal_encoding();
26 array_push($encodings, $encoding);
27 mb_internal_encoding('ISO-8859-1');
28 }
29
30 if ($reset && $encodings) {
31 $encoding = array_pop($encodings);
32 mb_internal_encoding($encoding);
33 }
34 }
35
36 try {
37 include('functions.php');
38
39 $key = "";
40 if (file_exists("../../../uploads/ali2woo/pk.php")) {
41 include ("../../../uploads/ali2woo/pk.php");
42 $key = a2wl_plugin_key();
43 }
44
45 if (empty($key) || !a2wl_verify_request($_REQUEST['_sign'], ['url'=> $_REQUEST['url'] ?? ''], $key)) {
46 header('HTTP/1.1 401 Unauthorized');
47 exit;
48 }
49
50 if (!class_exists('WpOrg\Requests\Requests')) {
51 include_once './../../../../wp-includes/Requests/src/Autoload.php';
52 WpOrg\Requests\Autoload::register();
53 }
54
55 // Avoid issues where mbstring.func_overload is enabled.
56 a2wl_mbstring_binary_safe_encoding();
57
58 $request_url = !empty($_REQUEST['url']) ? $_REQUEST['url'] : '';
59 if (base64_encode(base64_decode($request_url, true)) === $request_url) {
60 $request_url = base64_decode($request_url, true);
61 }
62
63 if ($request_url){
64 if (substr($request_url, 0, 4) !== "http") {
65 $request_url = "https:" . $request_url;
66 }
67 }
68
69 $requests_response = Requests::get(
70 $request_url,
71 ['Accept-Encoding' => ''],
72 [
73 'timeout' => 30,
74 'useragent' => 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36',
75 'verify' => false,
76 'sslverify' => false,
77 'verifyname' => false
78 ]
79 );
80
81 foreach ($requests_response->headers->getAll() as $name => $values) {
82 if (in_array(strtolower($name), ['content-length', 'content-type', 'cache-control', 'last-modified', 'expires', 'date'])) {
83 foreach ($values as $value) {
84 header("$name: $value");
85 }
86 }
87 }
88
89 echo $requests_response->body;
90 } catch (Exception $e) {
91 header('HTTP/1.1 400 Bad Request');
92 exit;
93 }
94