| 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 checkSPAM(): void |
| 284 |
{ |
| 285 |
$message = ''; |
| 286 |
$data = []; |
| 287 |
$success = false; |
| 288 |
|
| 289 |
$campaignId = acym_getVar('int', 'campaignId', 0); |
| 290 |
$campaignClass = new CampaignClass(); |
| 291 |
$campaign = $campaignClass->getOneByIdWithMail($campaignId); |
| 292 |
|
| 293 |
$mailId = acym_getVar('int', 'mailId', 0); |
| 294 |
if (empty($mailId)) { |
| 295 |
$mailId = $campaign->mail_id; |
| 296 |
} |
| 297 |
|
| 298 |
if (empty($mailId)) { |
| 299 |
$message = acym_translation('ACYM_CAMPAIGN_NOT_FOUND'); |
| 300 |
} else { |
| 301 |
ob_start(); |
| 302 |
$urlSite = trim(base64_encode(preg_replace('#https?://(www2?\.)?#i', '', ACYM_LIVE)), '=/'); |
| 303 |
$level = strtolower($this->config->get('level', 'starter')); |
| 304 |
$spamtestSystem = UpdatemeHelper::call('public/getSpamSystem?level='.$level.'&urlSite='.$urlSite); |
| 305 |
$warnings = ob_get_clean(); |
| 306 |
|
| 307 |
if (empty($spamtestSystem) || !empty($warnings)) { |
| 308 |
$message = acym_translation('ACYM_ERROR_LOAD_FROM_ACYBA').(!empty($warnings) && acym_isDebug() ? $warnings : ''); |
| 309 |
} else { |
| 310 |
if (!empty($spamtestSystem['messages']) || !empty($spamtestSystem['error'])) { |
| 311 |
$msgError = empty($spamtestSystem['messages']) ? '' : $spamtestSystem['messages'].'<br />'; |
| 312 |
$msgError .= empty($spamtestSystem['error']) ? '' : $spamtestSystem['error']; |
| 313 |
$message = $msgError; |
| 314 |
} else { |
| 315 |
if (empty($spamtestSystem['email'])) { |
| 316 |
$message = acym_translation('ACYM_SPAMTEST_MISSING_EMAIL'); |
| 317 |
} else { |
| 318 |
$mailerHelper = new MailerHelper(); |
| 319 |
$mailerHelper->report = false; |
| 320 |
|
| 321 |
$receiver = new \stdClass(); |
| 322 |
$receiver->id = 0; |
| 323 |
$receiver->email = $spamtestSystem['email']; |
| 324 |
$receiver->name = $spamtestSystem['name']; |
| 325 |
$receiver->confirmed = 1; |
| 326 |
$receiver->enabled = 1; |
| 327 |
$mailerHelper->isSpamTest = true; |
| 328 |
|
| 329 |
if ($mailerHelper->sendOne($mailId, $receiver)) { |
| 330 |
$success = true; |
| 331 |
$data['url'] = 'https://mailtester.acyba.com/'.(substr($spamtestSystem['email'], 0, strpos($spamtestSystem['email'], '@'))); |
| 332 |
$data['lang'] = acym_getLanguageTag(true); |
| 333 |
} else { |
| 334 |
$message = $mailerHelper->reportMessage; |
| 335 |
} |
| 336 |
} |
| 337 |
} |
| 338 |
} |
| 339 |
} |
| 340 |
|
| 341 |
acym_sendAjaxResponse($message, $data, $success); |
| 342 |
} |
| 343 |
} |
| 344 |
|