Compare commits
2 commits
a7de9454ae
...
6bd0f58e9d
Author | SHA1 | Date | |
---|---|---|---|
|
6bd0f58e9d | ||
|
e776d41d95 |
2 changed files with 69 additions and 27 deletions
62
sender.php
62
sender.php
|
@ -3,6 +3,7 @@ require_once 'vendor/phpmailer/phpmailer/PHPMailerAutoload.php';
|
||||||
include_once 'config/config.php';
|
include_once 'config/config.php';
|
||||||
include_once "vendor/notorm/NotORM.php";
|
include_once "vendor/notorm/NotORM.php";
|
||||||
|
|
||||||
|
exit('Commentami, lanciami e ricommentami.');
|
||||||
|
|
||||||
function getToken($length = 12){
|
function getToken($length = 12){
|
||||||
return uniqId();
|
return uniqId();
|
||||||
|
@ -11,7 +12,7 @@ function getToken($length = 12){
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateLink($url, $token, $ml, $email){
|
function generateLink($url, $token, $ml, $email){
|
||||||
$link = $url."/mlrollmember/stayin.php?";
|
$link = $url."/mlMemberRoller/stayin.php?";
|
||||||
$token = "token=".$token;
|
$token = "token=".$token;
|
||||||
$ml = "&ml=".$ml;
|
$ml = "&ml=".$ml;
|
||||||
$email = "&email=".$email;
|
$email = "&email=".$email;
|
||||||
|
@ -25,42 +26,49 @@ $pdo = new PDO("mysql:host=".$db_host.";dbname=".$db_dbname,
|
||||||
);
|
);
|
||||||
|
|
||||||
$db = new NotORM($pdo);
|
$db = new NotORM($pdo);
|
||||||
var_dump($db);
|
|
||||||
exit();
|
|
||||||
$mail = new PHPMailer;
|
$mail = new PHPMailer;
|
||||||
|
$mail->setLanguage($lang, 'vendor/phpmailer/phpmailer/language/phpmailer.lang-'.$lang.'.php');
|
||||||
|
$mail->CharSet = 'utf-8';
|
||||||
|
|
||||||
//$mail->SMTPDebug = 3; // Enable verbose debug output
|
//$mail->SMTPDebug = 5; // Enable verbose debug output
|
||||||
|
//$mail->isSMTP(); // Set mailer to use SMTP
|
||||||
$mail->isSMTP(); // Set mailer to use SMTP
|
$mail->Host = $smtpHost; // Specify main and backup SMTP servers
|
||||||
$mail->Host = $smtpHost; // Specify main and backup SMTP servers
|
//$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
//$mail->Username = $sender; // SMTP username
|
||||||
$mail->Username = $sender; // SMTP username
|
//$mail->Password = $credential_pw; // SMTP password
|
||||||
$mail->Password = $credential_pw; // SMTP password
|
//$mail->SMTPSecure = $algo_sec; // Enable TLS encryption, `ssl` also accepted
|
||||||
$mail->SMTPSecure = $algo_sec; // Enable TLS encryption, `ssl` also accepted
|
$mail->Port = $port; // TCP port to connect to
|
||||||
$mail->Port = $post; // TCP port to connect to
|
$mail->isHTML(false); // Set email format to HTML
|
||||||
$mail->isHTML(false); // Set email format to HTML
|
|
||||||
|
|
||||||
$mail->setFrom($sender, $senderName);
|
$mail->setFrom($sender, $senderName);
|
||||||
$mail->Subject = $subject;
|
$mail->Subject = $subject;
|
||||||
|
|
||||||
|
//$db->debug = true;
|
||||||
|
|
||||||
$file = fopen($filename, "r");
|
$file = fopen($filename, "r");
|
||||||
while(!feof($file)){
|
while(!feof($file)){
|
||||||
$line = fgets($file);
|
$line = fgets($file);
|
||||||
$sanitized_mail = filter_var($line, FILTER_SANITIZE_EMAIL);
|
$sanitized_mail = filter_var($line, FILTER_SANITIZE_EMAIL);
|
||||||
if($sanitized_mail !== false) {
|
if($sanitized_mail !== "") {
|
||||||
$mail->addAddress($sanitized_mail);
|
$mail->addAddress($sanitized_mail);
|
||||||
$token = getToken();
|
$token = getToken();
|
||||||
$link = generateLink($mlrollmember_url, $token, $ml, $sanitized_mail);
|
$link = generateLink($mlrollmember_url, $token, $ml, $sanitized_mail);
|
||||||
$mail->AltBody = $def_body.$link;
|
$mail->Body = $def_body.$link;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(!$mail->send()) {
|
$db->$db_table()->insert(array(
|
||||||
echo 'Message could not be sent.';
|
"token" => $token,
|
||||||
echo 'Mailer Error: ' . $mail->ErrorInfo;
|
"ml" => $ml,
|
||||||
} else {
|
"email" => $sanitized_mail
|
||||||
echo 'Message has been sent';
|
));
|
||||||
}
|
|
||||||
|
if(!$mail->send()) {
|
||||||
|
echo 'Message could not be sent.'."\n";
|
||||||
|
echo 'Mailer Error: ' . $mail->ErrorInfo."\n";
|
||||||
|
} else {
|
||||||
|
echo 'Message has been sent'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fclose($file);
|
fclose($file);
|
||||||
|
|
34
stayin.php
34
stayin.php
|
@ -1,3 +1,37 @@
|
||||||
<?php
|
<?php
|
||||||
|
include_once 'config/config.php';
|
||||||
|
include_once "vendor/notorm/NotORM.php";
|
||||||
|
|
||||||
|
$pdo = new PDO("mysql:host=".$db_host.";dbname=".$db_dbname,
|
||||||
|
$db_user,
|
||||||
|
$db_pass
|
||||||
|
);
|
||||||
|
|
||||||
|
$db = new NotORM($pdo);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if( isset($_GET['token']) && !empty($_GET['token']) &&
|
||||||
|
isset($_GET['ml']) && !empty($_GET['ml']) &&
|
||||||
|
isset($_GET['email']) && !empty($_GET['email']) ) {
|
||||||
|
|
||||||
|
$token = $_GET['token'];
|
||||||
|
$ml = $_GET['ml'];
|
||||||
|
$email = $_GET['email'];
|
||||||
|
|
||||||
|
$affected = $db->$db_table()->where(array(
|
||||||
|
"token" => $token,
|
||||||
|
"ml" => $ml,
|
||||||
|
"email" => $email
|
||||||
|
))->update(array(
|
||||||
|
"renewed" => 1,
|
||||||
|
));
|
||||||
|
|
||||||
|
if($affected == 1) {
|
||||||
|
echo "Hai rinnovato l'inscrizione.";
|
||||||
|
} else {
|
||||||
|
echo "Si è verificato un errore.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue