| @@ -1,0 +1,372 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace AcyMailing\Controllers\Campaigns; | |
| 4 | + | |
| 5 | +use AcyMailing\Classes\CampaignClass; | |
| 6 | +use AcyMailing\Classes\MailClass; | |
| 7 | +use AcyMailing\Classes\UserClass; | |
| 8 | +use AcyMailing\Helpers\MailerHelper; | |
| 9 | +use AcyMailing\Helpers\UpdatemeHelper; | |
| 10 | + | |
| 11 | + | |
| 12 | +trait Tests | |
| 13 | +{ | |
| 14 | + public function checkContent(): void | |
| 15 | + { | |
| 16 | + $campaignClass = new CampaignClass(); | |
| 17 | + $mailClass = new MailClass(); | |
| 18 | + | |
| 19 | + $campaignId = acym_getVar('int', 'campaignId', 0); | |
| 20 | + $campaign = $campaignClass->getOneById($campaignId); | |
| 21 | + | |
| 22 | + if (empty($campaign)) { | |
| 23 | + acym_sendAjaxResponse(acym_translation('ACYM_CAMPAIGN_NOT_FOUND'), [], false); | |
| 24 | + } | |
| 25 | + | |
| 26 | + $mailId = acym_getVar('int', 'mailId', 0); | |
| 27 | + $mail = $mailClass->getOneById(empty($mailId) ? $campaign->mail_id : $mailId); | |
| 28 | + | |
| 29 | + $result = ''; | |
| 30 | + $spamWords = [ | |
| 31 | + '4U', | |
| 32 | + 'you are a winner', | |
| 33 | + 'For instant access', | |
| 34 | + 'Accept credit cards', | |
| 35 | + 'Claims you registered with', | |
| 36 | + 'For just $', | |
| 37 | + 'Act now!', | |
| 38 | + 'Don’t hesitate!', | |
| 39 | + 'Click below', | |
| 40 | + 'Free', | |
| 41 | + 'income', | |
| 42 | + 'Click here', | |
| 43 | + 'Click to remove', | |
| 44 | + 'All natural', | |
| 45 | + 'Amazing', | |
| 46 | + 'Compare rates', | |
| 47 | + 'Apply Online', | |
| 48 | + 'your business', | |
| 49 | + 'As seen on', | |
| 50 | + 'all orders', | |
| 51 | + 'Auto email removal', | |
| 52 | + 'bankruptcy', | |
| 53 | + 'debt', | |
| 54 | + 'Be amazed', | |
| 55 | + 'Copy accurately', | |
| 56 | + 'Be your own boss', | |
| 57 | + 'Being a member', | |
| 58 | + 'Big bucks', | |
| 59 | + 'Credit card', | |
| 60 | + 'Bill', | |
| 61 | + 'Cures baldness', | |
| 62 | + 'Billing address', | |
| 63 | + 'Billion dollars', | |
| 64 | + 'Dear friend', | |
| 65 | + 'Brand new pager', | |
| 66 | + 'Bulk email', | |
| 67 | + 'Different reply to', | |
| 68 | + 'Buy direct', | |
| 69 | + 'Dig up dirt', | |
| 70 | + 'Full refund', | |
| 71 | + 'Buying judgments', | |
| 72 | + 'Direct email', | |
| 73 | + 'Get It Now', | |
| 74 | + 'Cable converter', | |
| 75 | + 'Direct marketing', | |
| 76 | + 'Get paid', | |
| 77 | + 'Get started now', | |
| 78 | + 'Call now', | |
| 79 | + 'Do it today', | |
| 80 | + 'Gift certificate', | |
| 81 | + 'Calling creditors', | |
| 82 | + 'Don’t delete', | |
| 83 | + 'Great offer', | |
| 84 | + 'Can’t live without', | |
| 85 | + 'Drastically reduced', | |
| 86 | + 'Guarantee', | |
| 87 | + 'Cancel at any time', | |
| 88 | + 'Earn per week', | |
| 89 | + 'Have you been turned down?', | |
| 90 | + 'Easy terms', | |
| 91 | + 'Hidden assets', | |
| 92 | + 'Eliminate bad credit', | |
| 93 | + 'Home employment', | |
| 94 | + 'Cash', | |
| 95 | + 'Email harvest', | |
| 96 | + 'Human growth hormone', | |
| 97 | + 'Casino', | |
| 98 | + 'Email marketing', | |
| 99 | + 'Expect to earn', | |
| 100 | + 'In accordance with laws', | |
| 101 | + 'Fantastic deal', | |
| 102 | + 'Increase sales', | |
| 103 | + 'Viagra', | |
| 104 | + 'Increase traffic', | |
| 105 | + 'Insurance', | |
| 106 | + 'Find out anything', | |
| 107 | + 'Investment decision', | |
| 108 | + 'it\'s legal', | |
| 109 | + 'It\'s effective', | |
| 110 | + 'Join millions of', | |
| 111 | + 'No questions asked', | |
| 112 | + 'Reverses aging', | |
| 113 | + 'No selling', | |
| 114 | + 'Risk', | |
| 115 | + 'Limited time only', | |
| 116 | + 'No strings attached', | |
| 117 | + 'Round the world', | |
| 118 | + 'Not intended', | |
| 119 | + 'Lose weight', | |
| 120 | + 'Off shore', | |
| 121 | + 'Safeguard notice', | |
| 122 | + 'Lower interest rates', | |
| 123 | + 'Offer expires', | |
| 124 | + 'Satisfaction guaranteed', | |
| 125 | + 'Lower monthly payment', | |
| 126 | + 'coupon', | |
| 127 | + 'Save $', | |
| 128 | + 'Lowest price', | |
| 129 | + 'Luxury car', | |
| 130 | + 'Save up to', | |
| 131 | + 'Once in a lifetime', | |
| 132 | + 'Score with babes', | |
| 133 | + 'Marketing solutions', | |
| 134 | + 'Mass email', | |
| 135 | + 'guaranteed', | |
| 136 | + 'See for yourself', | |
| 137 | + 'Meet singles', | |
| 138 | + 'One time mailing', | |
| 139 | + 'Sent in compliance', | |
| 140 | + 'Member stuff', | |
| 141 | + 'opportunity', | |
| 142 | + 'Online pharmacy', | |
| 143 | + 'Serious only', | |
| 144 | + 'MLM', | |
| 145 | + 'Only $', | |
| 146 | + 'Shopping spree', | |
| 147 | + 'Social security number', | |
| 148 | + 'trial offer', | |
| 149 | + 'Special promotion', | |
| 150 | + 'More Internet traffic', | |
| 151 | + 'Stock alert', | |
| 152 | + 'Outstanding values', | |
| 153 | + 'Pennies a day', | |
| 154 | + 'Stock pick', | |
| 155 | + 'New customers only', | |
| 156 | + 'money', | |
| 157 | + 'Stop snoring', | |
| 158 | + 'New domain extensions', | |
| 159 | + 'Please read', | |
| 160 | + 'Strong buy', | |
| 161 | + 'Potential earnings', | |
| 162 | + 'Stuff on sale', | |
| 163 | + 'No age restrictions', | |
| 164 | + 'Subject to credit', | |
| 165 | + 'No catch', | |
| 166 | + 'Supplies are limited', | |
| 167 | + 'No claim forms', | |
| 168 | + 'Produced and sent out', | |
| 169 | + 'Take action now', | |
| 170 | + 'No cost', | |
| 171 | + 'Profits', | |
| 172 | + 'hidden charges', | |
| 173 | + 'No credit check', | |
| 174 | + 'Promise you', | |
| 175 | + 'No disappointment', | |
| 176 | + 'Pure profit', | |
| 177 | + 'Real thing', | |
| 178 | + 'No fees', | |
| 179 | + 'Refinance home', | |
| 180 | + 'The best rates', | |
| 181 | + 'No gimmick', | |
| 182 | + 'The following form', | |
| 183 | + 'No inventory', | |
| 184 | + 'No investment', | |
| 185 | + 'giving it away', | |
| 186 | + 'No medical exams', | |
| 187 | + 'Removes wrinkles', | |
| 188 | + 'This isn’t junk', | |
| 189 | + 'No middleman', | |
| 190 | + 'This isn’t spam', | |
| 191 | + 'No obligation', | |
| 192 | + 'initial investment', | |
| 193 | + 'University diplomas', | |
| 194 | + 'No purchase necessary', | |
| 195 | + 'Reserves the right', | |
| 196 | + 'Unlimited', | |
| 197 | + 'We honor all', | |
| 198 | + 'Will not believe your eyes', | |
| 199 | + 'Urgent', | |
| 200 | + 'Winner', | |
| 201 | + 'US dollars', | |
| 202 | + 'What are you waiting for?', | |
| 203 | + 'Winning', | |
| 204 | + 'While supplies last', | |
| 205 | + 'Work at home', | |
| 206 | + 'drugs', | |
| 207 | + 'While you sleep', | |
| 208 | + 'You have been selected', | |
| 209 | + 'We hate spam', | |
| 210 | + 'Why pay more?', | |
| 211 | + ]; | |
| 212 | + | |
| 213 | + $spamWordsInContent = []; | |
| 214 | + foreach ($spamWords as $oneWord) { | |
| 215 | + if ((bool)preg_match('#'.preg_quote($oneWord, '#').'#Uis', $mail->subject.$mail->body)) { | |
| 216 | + $spamWordsInContent[] = $oneWord; | |
| 217 | + } | |
| 218 | + } | |
| 219 | + | |
| 220 | + if (count($spamWordsInContent) > 2) { | |
| 221 | + $result = acym_translation('ACYM_TESTS_CONTENT_DESC'); | |
| 222 | + $result .= '<ul class="acym__ul"><li>'.implode('</li><li>', $spamWordsInContent).'</li></ul>'; | |
| 223 | + } | |
| 224 | + | |
| 225 | + acym_sendAjaxResponse('', ['result' => $result]); | |
| 226 | + } | |
| 227 | + | |
| 228 | + public function checkLinks(): void | |
| 229 | + { | |
| 230 | + $campaignClass = new CampaignClass(); | |
| 231 | + $mailClass = new MailClass(); | |
| 232 | + | |
| 233 | + $campaignId = acym_getVar('int', 'campaignId', 0); | |
| 234 | + $campaign = $campaignClass->getOneById($campaignId); | |
| 235 | + | |
| 236 | + if (empty($campaign)) { | |
| 237 | + acym_sendAjaxResponse(acym_translation('ACYM_CAMPAIGN_NOT_FOUND'), [], false); | |
| 238 | + } | |
| 239 | + | |
| 240 | + $mailId = acym_getVar('int', 'mailId', 0); | |
| 241 | + $mail = $mailClass->getOneById(empty($mailId) ? $campaign->mail_id : $mailId); | |
| 242 | + | |
| 243 | + acym_trigger('replaceContent', [&$mail, false]); | |
| 244 | + $userClass = new UserClass(); | |
| 245 | + $receiver = $userClass->getOneByEmail(acym_currentUserEmail()); | |
| 246 | + if (empty($receiver)) { | |
| 247 | + $receiver = new \stdClass(); | |
| 248 | + $receiver->email = acym_currentUserEmail(); | |
| 249 | + $newID = $userClass->save($receiver); | |
| 250 | + $receiver = $userClass->getOneById($newID); | |
| 251 | + } | |
| 252 | + acym_trigger('replaceUserInformation', [&$mail, &$receiver, false]); | |
| 253 | + | |
| 254 | + preg_match_all('# (href|src)="([^"]+)"#Uis', acym_absoluteURL($mail->body), $URLs); | |
| 255 | + | |
| 256 | + $brokenLinks = []; | |
| 257 | + $processed = []; | |
| 258 | + $result = ''; | |
| 259 | + foreach ($URLs[2] as $oneURL) { | |
| 260 | + if (in_array($oneURL, $processed)) continue; | |
| 261 | + if (0 === strpos($oneURL, 'mailto:')) continue; | |
| 262 | + if (0 === strpos($oneURL, 'tel:')) continue; | |
| 263 | + if (strlen($oneURL) > 1 && (0 === strpos($oneURL, '#') || false !== strpos($oneURL, 'unsubscribe'))) continue; | |
| 264 | + | |
| 265 | + $processed[] = $oneURL; | |
| 266 | + | |
| 267 | + $headers = @get_headers($oneURL); | |
| 268 | + $headers = is_array($headers) ? implode("\n ", $headers) : $headers; | |
| 269 | + | |
| 270 | + if (empty($headers) || preg_match('#^HTTP/.*\s+[(200|301|302|304)]+\s#i', $headers) !== 1) { | |
| 271 | + $brokenLinks[] = '<a target="_blank" href="'.$oneURL.'">'.(strlen($oneURL) > 50 ? substr($oneURL, 0, 25).'...'.substr($oneURL, strlen($oneURL) - 20) | |
| 272 | + : $oneURL).'</a>'; | |
| 273 | + } | |
| 274 | + } | |
| 275 | + | |
| 276 | + if (!empty($brokenLinks)) { | |
| 277 | + $result = '<ul class="acym__ul"><li>'.implode('</li><li>', $brokenLinks).'</li></ul>'; | |
| 278 | + } | |
| 279 | + | |
| 280 | + acym_sendAjaxResponse('', ['result' => $result]); | |
| 281 | + } | |
| 282 | + | |
| 283 | + public function spamTestResults(): void | |
| 284 | + { | |
| 285 | + $url = acym_getVar('string', 'url', ''); | |
| 286 | + | |
| 287 | + if (empty($url) || strpos($url, 'mailtester.') === false) { | |
| 288 | + acym_sendAjaxResponse('Invalid URL', [], false); | |
| 289 | + } | |
| 290 | + | |
| 291 | + $url .= '&format=json'; | |
| 292 | + | |
| 293 | + $response = acym_fileGetContent($url); | |
| 294 | + | |
| 295 | + if ($response === false) { | |
| 296 | + acym_sendAjaxResponse('Could not fetch results', [], false); | |
| 297 | + } | |
| 298 | + | |
| 299 | + $data = json_decode($response, true); | |
| 300 | + | |
| 301 | + if (json_last_error() !== JSON_ERROR_NONE) { | |
| 302 | + acym_sendAjaxResponse('Invalid response', [], false); | |
| 303 | + } | |
| 304 | + | |
| 305 | + acym_sendAjaxResponse('', $data, true); | |
| 306 | + } | |
| 307 | + | |
| 308 | + public function checkSPAM(): void | |
| 309 | + { | |
| 310 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 311 | + | |
| 312 | + $message = ''; | |
| 313 | + $data = []; | |
| 314 | + $success = false; | |
| 315 | + | |
| 316 | + $campaignId = acym_getVar('int', 'campaignId', 0); | |
| 317 | + $campaignClass = new CampaignClass(); | |
| 318 | + $campaign = $campaignClass->getOneByIdWithMail($campaignId); | |
| 319 | + | |
| 320 | + $mailId = acym_getVar('int', 'mailId', 0); | |
| 321 | + if (empty($mailId)) { | |
| 322 | + $mailId = $campaign->mail_id; | |
| 323 | + } | |
| 324 | + | |
| 325 | + if (empty($mailId)) { | |
| 326 | + $message = acym_translation('ACYM_CAMPAIGN_NOT_FOUND'); | |
| 327 | + } else { | |
| 328 | + ob_start(); | |
| 329 | + $urlSite = trim(base64_encode(preg_replace('#https?://(www2?\.)?#i', '', ACYM_LIVE)), '=/'); | |
| 330 | + $level = strtolower($this->config->get('level', 'starter')); | |
| 331 | + $spamtestSystem = UpdatemeHelper::call('public/getSpamSystem?level='.$level.'&urlSite='.$urlSite); | |
| 332 | + $warnings = ob_get_clean(); | |
| 333 | + | |
| 334 | + // Could not load the information | |
| 335 | + if (empty($spamtestSystem) || !empty($warnings)) { | |
| 336 | + $message = acym_translation('ACYM_ERROR_LOAD_FROM_ACYBA').(!empty($warnings) && acym_isDebug() ? $warnings : ''); | |
| 337 | + } else { | |
| 338 | + if (!empty($spamtestSystem['messages']) || !empty($spamtestSystem['error'])) { | |
| 339 | + $msgError = empty($spamtestSystem['messages']) ? '' : $spamtestSystem['messages'].'<br />'; | |
| 340 | + $msgError .= empty($spamtestSystem['error']) ? '' : $spamtestSystem['error']; | |
| 341 | + $message = $msgError; | |
| 342 | + } else { | |
| 343 | + if (empty($spamtestSystem['email'])) { | |
| 344 | + $message = acym_translation('ACYM_SPAMTEST_MISSING_EMAIL'); | |
| 345 | + } else { | |
| 346 | + $mailerHelper = new MailerHelper(); | |
| 347 | + $mailerHelper->report = false; | |
| 348 | + | |
| 349 | + //send a message to [email protected] | |
| 350 | + $receiver = new \stdClass(); | |
| 351 | + $receiver->id = 0; | |
| 352 | + $receiver->email = $spamtestSystem['email']; | |
| 353 | + $receiver->name = $spamtestSystem['name']; | |
| 354 | + $receiver->confirmed = 1; | |
| 355 | + $receiver->enabled = 1; | |
| 356 | + $mailerHelper->isSpamTest = true; | |
| 357 | + | |
| 358 | + if ($mailerHelper->sendOne($mailId, $receiver)) { | |
| 359 | + $success = true; | |
| 360 | + $data['url'] = $spamtestSystem['displayURL']; | |
| 361 | + $data['lang'] = acym_getLanguageTag(true); | |
| 362 | + } else { | |
| 363 | + $message = $mailerHelper->reportMessage; | |
| 364 | + } | |
| 365 | + } | |
| 366 | + } | |
| 367 | + } | |
| 368 | + } | |
| 369 | + | |
| 370 | + acym_sendAjaxResponse($message, $data, $success); | |
| 371 | + } | |
| 372 | +} | |