| @@ -34,37 +34,8 @@ | ||
| 34 | 34 | ], |
| 35 | 35 | ]; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public function getOption(): void | |
| 39 | - { | |
| 40 | - acym_checkToken(); | |
| 41 | - | |
| 42 | - $field = acym_getVar('string', 'field', ''); | |
| 43 | - | |
| 44 | - $allowedFields = [ | |
| 45 | - 'level', | |
| 46 | - 'unsplash_key', | |
| 47 | - 'giphy_key', | |
| 48 | - ]; | |
| 49 | - | |
| 50 | - if (acym_isAdmin()) { | |
| 51 | - $allowedFields[] = 'save_thumbnail'; | |
| 52 | - } | |
| 53 | - | |
| 54 | - if (!in_array($field, $allowedFields)) { | |
| 55 | - acym_sendAjaxResponse(acym_translation('ACYM_COULD_NOT_LOAD_INFORMATION'), [], false); | |
| 56 | - } | |
| 57 | - | |
| 58 | - $res = $this->config->get($field); | |
| 59 | - | |
| 60 | - if (intval($res) !== 0 && empty($res)) { | |
| 61 | - acym_sendAjaxResponse(acym_translation('ACYM_COULD_NOT_LOAD_INFORMATION'), [], false); | |
| 62 | - } else { | |
| 63 | - acym_sendAjaxResponse('', ['value' => $res]); | |
| 64 | - } | |
| 65 | - } | |
| 66 | - | |
| 67 | 38 | public function displayMessage(string $message, bool $ajax = false): array |
| 68 | 39 | { |
| 69 | 40 | $correspondences = [ |
| 70 | 41 | 'WEBSITE_NOT_FOUND' => ['message' => 'ACYM_WEBSITE_NOT_FOUND', 'type' => 'error'], |
| @@ -120,9 +91,9 @@ | ||
| 120 | 91 | { |
| 121 | 92 | $filename = acym_getVar('string', 'filename', ''); |
| 122 | 93 | |
| 123 | 94 | if (empty($filename) || !acym_fileNameValid($filename)) { |
| 124 | - echo acym_translation('ACYM_FILENAME_EMPTY_OR_NOT_VALID'); | |
| 95 | + echo esc_html(acym_translation('ACYM_FILENAME_EMPTY_OR_NOT_VALID')); | |
| 125 | 96 | exit; |
| 126 | 97 | } |
| 127 | 98 | |
| 128 | 99 | $reportPath = acym_getLogPath($filename); |
| @@ -127,9 +98,9 @@ | ||
| 127 | 98 | |
| 128 | 99 | $reportPath = acym_getLogPath($filename); |
| 129 | 100 | |
| 130 | 101 | if (!file_exists($reportPath)) { |
| 131 | - echo acym_translation('ACYM_EXIST_LOG'); | |
| 102 | + echo esc_html(acym_translation('ACYM_EXIST_LOG')); | |
| 132 | 103 | exit; |
| 133 | 104 | } |
| 134 | 105 | |
| 135 | 106 | if (ACYM_CMS === 'wordpress') @ob_get_clean(); |
| @@ -134,9 +105,9 @@ | ||
| 134 | 105 | |
| 135 | 106 | if (ACYM_CMS === 'wordpress') @ob_get_clean(); |
| 136 | 107 | |
| 137 | 108 | $final = acym_fileGetContent($reportPath); |
| 138 | - echo nl2br($final); | |
| 109 | + echo nl2br(esc_html($final)); | |
| 139 | 110 | |
| 140 | 111 | exit; |
| 141 | 112 | } |
| 142 | 113 | |
| @@ -141,8 +112,9 @@ | ||
| 141 | 112 | } |
| 142 | 113 | |
| 143 | 114 | private function loginForOAuth2(bool $isSmtp = true): void |
| 144 | 115 | { |
| 116 | + // Step 1: prompt consent window to the user | |
| 145 | 117 | $this->store(); |
| 146 | 118 | |
| 147 | 119 | $redirectUrl = ''; |
| 148 | 120 | acym_trigger('onAcymOauthAuthenticate', [&$redirectUrl, $isSmtp]); |
| @@ -152,13 +124,14 @@ | ||
| 152 | 124 | |
| 153 | 125 | return; |
| 154 | 126 | } |
| 155 | 127 | |
| 156 | - acym_redirect($redirectUrl); | |
| 128 | + acym_redirect($redirectUrl, '', 'message', false); | |
| 157 | 129 | } |
| 158 | 130 | |
| 159 | 131 | public function handleOauthAuthentication(): void |
| 160 | 132 | { |
| 133 | + // Step 2: get the access and refresh tokens after the user is redirected to the config with a code in the URL | |
| 161 | 134 | $code = acym_getVar('string', 'code'); |
| 162 | 135 | |
| 163 | 136 | if (empty($code)) { |
| 164 | 137 | return; |