This page lists files in the current directory. You can view content, get download/execute commands for Wget, Curl, or PowerShell, or filter the list using wildcards (e.g., `*.sh`).
wget 'https://sme10.lists2.roe3.org/mdrone/newsletter/database.sql'
CREATE TABLE `newsletter` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `newsletter`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `email` (`email`),
ADD KEY `name` (`name`);
INSERT INTO `newsletter` (`id`, `name`, `email`) VALUES
(1, 'MD', 'mdrone@gmail.com'),
(2, 'Dooley Sworne', 'mdrone@roe3.org'),
(3, 'Mark Outlook', 'mdrone@outlook.com');
wget 'https://sme10.lists2.roe3.org/mdrone/newsletter/form.php'
<html>
<head>
<title>PHP NEWSLETTER</title>
<script src="https://cdn.ckeditor.com/ckeditor5/35.0.1/classic/ckeditor.js"></script>
<link rel="stylesheet" href="https://unpkg.com/mvp.css">
<style>
.ck-editor__editable_inline {
min-height: 300px;
}
div {
margin: 1.5em;
}
</style>
</head>
<body>
<div>
<h3>PHP NEWSLETTER</h3>
<form action="sendemail.php" method="post">
<label>Subject:</label>
<input type="text" name="subject" id="subject"/><br>
<label>Body of Newsletter Email:</label>
<textarea name="body" id="editor" class="ck-blurred ck-editor__editable ck-rounded-corners ck-editor__editable_inline" role="textbox" aria-label="Rich Text Editor, main" contenteditable="true"></textarea>
<input type="submit" name=submit value="Submit"/>
</form>
</div>
<script>
ClassicEditor
.create( document.querySelector( '#editor' ) )
.catch( error => {
console.error( error );
} );
</script>
</body>
</html>
wget 'https://sme10.lists2.roe3.org/mdrone/newsletter/newsletter.php'
<?php
class Newsletter {
private $pdo = null;
private $stmt = null;
private $headers = "";
private $subject = "";
// (A) CONSTRUCTOR - CONNECT TO DATABASE
function __construct () {
try {
$this->pdo = new PDO(
"mysql:host=".DB_HOST.";dbname=".DB_NAME.";charset=".DB_CHARSET,
DB_USER, DB_PASSWORD, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
]
);
} catch (Exception $ex) { exit($ex->getMessage()); }
}
// (B) DESTRUCTOR - CLOSE DATABASE CONNECTION
function __destruct () {
if ($this->stmt!==null) { $this->stmt = null; }
if ($this->pdo!==null) { $this->pdo = null; }
}
// (C) COUNT TOTAL NUMBER OF SUBSCRIBERS
function count () {
$sql = "SELECT COUNT(*) `cnt` FROM `newsletter`";
$this->stmt = $this->pdo->prepare($sql);
$this->stmt->execute();
$result = $this->stmt->fetchAll();
return $result[0]["cnt"];
}
// (D) GET SUBSCRIBERS
function get ($start=0, $end=10) {
$sql = "SELECT * FROM `newsletter` LIMIT $start,$end";
$this->stmt = $this->pdo->prepare($sql);
$this->stmt->execute();
return $this->stmt->fetchAll();
}
// (E) PRIME EMAIL HEADERS & SUBJECT
function prime($headers="", $subject=""){
$this->headers = $headers;
$this->subject = $subject;
}
// (F) SEND MAIL
function send ($to, $message) {
return @mail($to, $this->subject, $message, $this->headers);
}
}
wget 'https://sme10.lists2.roe3.org/mdrone/newsletter/process.php'
<?php
// (A) INIT + RUN SETTINGS
set_time_limit(0); // No timeout
$each = 10; // Get 10 subscribers each run
$pause = 1; // 1 sec pause between each email send
// (B) DATABASE SETTINGS - CHANGE TO YOUR OWN!
define("DB_HOST", "localhost");
define("DB_NAME", "myCalendar");
define("DB_CHARSET", "utf8");
define("DB_USER", "mdrone");
define("DB_PASSWORD", "einstein");
// (C) LOAD LIBRARY + EMAIL TEMPLATE FROM FILE
require "newsletter.php";
$news = new Newsletter();
$template = file_get_contents("template.html");
// (D) EMAIL SUBJECT + HEADER
$subject = "[NEWSLETTER] What's New";
$headers = implode("\r\n", [
"From: newsletter@lists2.roe3.org",
"Reply-To: mdrone@roe3.org",
"MIME-Version: 1.0",
"Content-Type: text/html; charset=utf-8"
]);
$news->prime($headers, $subject);
unset($subject); unset($headers);
// (E) SEND THE EMAIL - BATCH BY BATCH
$all = $news->count();
for ($i=0; $i<$all; $i+=$each) {
$subscribers = $news->get($i,$each);
foreach ($subscribers as $sub) {
$msg = str_replace("[NAME]", $sub["name"], $template);
$news->send($sub["email"], $msg);
// If you want to keep a pass/fail send log
// $pass = $news->send($sub["email"], $msg);
// if ($pass) { SAVE TO LOG FILE OR DATABASE }
}
sleep($pause);
}
wget 'https://sme10.lists2.roe3.org/mdrone/newsletter/sendemail.php'
<?php
// DB Connection
$user = "mdrone";
$password = "einstein";
$host = "localhost";
$dbase = "myCalendar";
$table = "newsletter";
// Mail headers prep
//$headers = "MIME-Version: 1.0" . "\r\n";
//$headers .= "Content-Type: text/html; charset=UTF-8" . "\r\n";
$headers = "MIME-Version: 1.0\r\n";
//$headers .= "Content-Transfer-Encoding: 8bit\r\n";
$headers .= "Content-Type: text/html; charset=\"UTF-8\"\r\n";
$headers .= "From: newsletter@lists2.roe3.org\r\n";
$headers .= "Reply-To: mdrone@roe3.org\r\n";
$subject= $_POST['subject'];
$body= $_POST['body'];
// DB connection string
$dbc= mysqli_connect($host,$user,$password, $dbase)
or die("Unable to select database");
// DB query and $result array
$query= "SELECT * FROM $table";
$result= mysqli_query ($dbc, $query)
or die ('Error querying database.');
// Loop through DB $result array
while ($row = mysqli_fetch_array($result)) {
$name= $row['name'];
$email= $row['email'];
// Set up the mail() message
$message = "Dear $name,\r\n $body";
/*
echo "<hr>";
echo $message;
echo "<br/><br/>";
echo $headers;
echo "<br/><br/>";
echo "<hr>";
*/
if(mail($email, $subject, $message, $headers)){
echo 'Email was sent successfully to '. $email . '<hr>';
}else{
echo 'Dammit! The Email failed.<hr>';
}
}
mysqli_close($dbc);
?>
wget 'https://sme10.lists2.roe3.org/mdrone/newsletter/template.html'
<html><body>
Dear [NAME],<br>
<p>This is a test of a PHP/MySQL newsletter system. It reads a list of
addresses from a data table, personalizes the content with the person's
name and sends the information from a template that you customize for each
message.</p>
<p>What it needs is a way to add/edit/delete members to the data table and
a nice editor for the template file (template.html)</p>
</body></html>