PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.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
← All changes | back/Helpers/UpdatemeHelper.php +0 -107 10.10.2 → 11.1.1 View file →
@@ -1,107 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Helpers;
4 -
5 -use AcyMailing\Core\AcymObject;
6 -
7 -class UpdatemeHelper extends AcymObject
8 -{
9 - public static function getDefaultHeaders(): array
10 - {
11 - $config = acym_config();
12 - $apiKey = $config->get('license_key', '');
13 -
14 - return [
15 - 'Content-Type' => 'application/json',
16 - 'API-KEY' => $apiKey,
17 - ];
18 - }
19 -
20 - public static function call(string $path, string $method = 'GET', array $data = [], array $headers = [], array $options = []): array
21 - {
22 - $url = ACYM_UPDATEME_API_URL.$path;
23 -
24 - $headers = $headers + self::getDefaultHeaders();
25 -
26 - if (ACYM_CMS === 'joomla' && acym_getCMSConfig('proxy_enable', false)) {
27 - $options['proxy'] = ['host' => acym_getCMSConfig('proxy_host', '').':'.acym_getCMSConfig('proxy_port', '')];
28 - if (!empty(acym_getCMSConfig('proxy_user', '')) && !empty(acym_getCMSConfig('proxy_pass', ''))) {
29 - $options['proxy']['auth'] = acym_getCMSConfig('proxy_user', '').':'.acym_getCMSConfig('proxy_pass', '');
30 - }
31 - }
32 - $options['verifySsl'] = false;
33 - $options['headers'] = $headers;
34 - $options['method'] = $method;
35 - $options['data'] = $data;
36 - $request = acym_makeCurlCall($url, $options);
37 -
38 - if (!empty($request['error'])) {
39 - acym_logError('Error while calling our API on path '.$path.' with the message: '.$request['error'], 'updateme');
40 -
41 - return [];
42 - }
43 -
44 - $return = $request;
45 - $return['success'] = true;
46 -
47 - if ($request['status_code'] < 200 || $request['status_code'] > 299) {
48 - acym_logError('Error while calling updateme on path '.$path.' with the status code: '.$request['status_code']."\r\n and body".json_encode($request), 'updateme');
49 - if (!empty($request['message']) && $request['message'] === 'MAX_SITES_ATTACH') {
50 - acym_enqueueMessage(acym_translation('ACYM_REACHED_MAX_SITES_ATTACHED'), 'error');
51 - }
52 - $return['success'] = false;
53 - }
54 -
55 - return $return;
56 - }
57 -
58 - public static function getLicenseInfo(bool $ajax = false): void
59 - {
60 - ob_start();
61 - $config = acym_config(true);
62 - $url = 'public/getLicenseInfo';
63 - $url .= '?level='.urlencode(strtolower($config->get('level', 'starter')));
64 - if (acym_level(ACYM_ESSENTIAL) || $config->get('isTrial', 0) == 1) {
65 - if ($config->get('different_admin_url_toggle', 0) === 1) {
66 - $url .= '&domain='.$config->get('different_admin_url_value', 0);
67 - } else {
68 - $url .= '&domain='.urlencode(rtrim(ACYM_LIVE, '/'));
69 - }
70 - }
71 - $url .= '&version=latest';
72 - $userInformation = self::call($url);
73 - $warnings = ob_get_clean();
74 - $result = (!empty($warnings) && acym_isDebug()) ? $warnings : '';
75 -
76 - if (empty($userInformation)) {
77 - $config->saveConfig(['lastlicensecheck' => time()]);
78 - if ($ajax) {
79 - acym_sendAjaxResponse(
80 - '',
81 - [
82 - 'content' => '<br/><span style="color:#C10000;">'.acym_translation('ACYM_ERROR_LOAD_FROM_ACYBA').'</span><br/>'.$result,
83 - 'lastcheck' => acym_date(time(), 'ACYM_DATE_FORMAT_LC2'),
84 - ],
85 - false
86 - );
87 - } else {
88 - return;
89 - }
90 - }
91 -
92 - $newConfig = [
93 - 'latestversion' => $userInformation['latestversion'],
94 - 'expirationdate' => $userInformation['expiration'],
95 - 'lastlicensecheck' => time(),
96 - ];
97 -
98 - $licenseKey = $config->get('license_key');
99 - if (!empty($licenseKey)) {
100 - $newConfig['isTrial'] = empty($userInformation['isTrial']) ? 0 : 1;
101 - }
102 -
103 - $config->saveConfig($newConfig);
104 -
105 - acym_checkPluginsVersion();
106 - }
107 -}