select(['email'])->from('email')->where(null, ['token' => $email])->query(); if (empty($filtered_email)) { echo sprintf('loadScript("//%s/js/alertify.min.js",function() { alertify.alert("Invalid token"); });', $_SERVER['HTTP_HOST']); // TODO log for fail2ban exit; } else { $filtered_email = current($filtered_email); } $content = ''; $f = $xpath != '' ? @DomDocument::loadHTMLFile($url) : false; if ($f) { $xp = new DomXPath($f); $content = $xp->query($xpath) != false ? $f->saveXML($xp->query($xpath)->item(0)) : ''; } $body = "\n" . $title; $body .= "\nLink => " . $url; $body .= "\n" . $content; $body .= "\nThanks for using our service."; $body .= "\n\nShikiryu"; $body .= "\n\nAny complain or advise? http://shikiryu.com/contact/"; include 'phpmailer.php'; try { $mail = new PHPMailer(true); $mail->setFrom($config['from_email'], $config['from_name']); $mail->Subject = 'A new article to read : ' . $title; $mail->addAddress($filtered_email); if (!empty($config['bcc'])) { $mail->addBCC($config['bcc']); } if ($xpath == '') $mail->Body = $body; else $mail->Body = '
' . nl2br($body) . '
'; if ($mail->send()) { echo sprintf('loadScript("//%s/js/alertify.min.js",function() { alertify.alert("Email Sent."); });', $_SERVER['HTTP_HOST']); } else { echo sprintf('loadScript("//%s/js/alertify.min.js",function() { alertify.alert("Problem while sending email. Sorry."); });', $_SERVER['HTTP_HOST']); } } catch (phpmailerException $et) { echo sprintf('loadScript("//%s/js/alertify.min.js",function() { alertify.alert("Error from sendmail :("); });', $_SERVER['HTTP_HOST']); exit; } catch (Exception $ep) { echo sprintf('loadScript("//%s/js/alertify.min.js",function() { alertify.alert("Email from SMTP :("); });', $_SERVER['HTTP_HOST']); exit; } } else { if ($filtered_version === false) { echo sprintf('loadScript("//%s/js/alertify.min.js",function() { alertify.alert("Invalid Version"); });', $_SERVER['HTTP_HOST']); } if ($filtered_url === false) { echo sprintf('loadScript("//%s/js/alertify.min.js",function() { alertify.alert("Invalid URL"); });', $_SERVER['HTTP_HOST']); } } } else if (isset($_POST['email'])) { $filtered_email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL); if ($filtered_email !== false) { $token = bin2hex(random_bytes(72)); //ADDING STATS include "XMLSQL.php"; $stats = new XMLSQL('emails.xml'); $stats->insert(array('ip' => getenv('REMOTE_ADDR'), 'date' => date('d/m/Y'), 'token' => $token, 'email' => $_POST['email']))->into('emails')->query(); if ($_POST['html'] == 'on') { // bookmarklet pour l'envoi en HTML $include = 'Bookmark by email'; } else { // bookmarklet pour l'envoi normal $include = "Bookmark by email"; } } else { $include = '

Invalid email. Please go back

'; } include 'template.php'; } else { $include = '
'; include 'template.php'; }