From 4de2151306cee8ad7983f201a74d15a44d2b06b7 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Wed, 9 Jan 2013 16:54:12 -0800 Subject: Challenges, massEmail functions started --- pages/massemail.php | 209 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 pages/massemail.php (limited to 'pages/massemail.php') diff --git a/pages/massemail.php b/pages/massemail.php new file mode 100644 index 0000000..a861500 --- /dev/null +++ b/pages/massemail.php @@ -0,0 +1,209 @@ + + +Thank you for your feedback!
+ I'm Reading this right now.
+ Well, obviously I'm not reading it right NOW.
+ I guess what I meant to say is that I'll be reading it soon.
+ Wow this redirect is taking a while.. Sorry
+ Are you still here?
+ Something must be wrong, you should really have been redirected by now", $mydomain, 5); + exit; +} + + +include('./includes/sqli.php'); + +$res = mysqli_query($mysqli, "SELECT count(*) as _msg FROM `users`"); +$row = mysqli_fetch_assoc($res); +echo $row['_msg']; + +exit; + +function QueueEmail($unsanitizeduserID, $unsanitizedto, $unsanitizedSubject, $unsanitizedBody) { + + //Check if there's something in the queue already: + $sql = "SELECT `userID` FROM emailQueue WHERE '$userID' = "; + +} + +//new table +// emailQueue ID, userID, sent, to, subject, body, dateSubmited, dateSent + +$sql = "SELECT `ID`, `displayName`, `dateJoined`, `dateLogin`, `email`, `isAdmin` FROM `users`"; +$result = mysql_query($sql); + +echo " +
+
+

MASS EMAIL

+
+"; + + +?> + +
+ +

+ +Title:
+
+ Please email me back +

+ +
+ + +

EXAMPLE SET

+ + + +IDDisplay name:Joined On:Last LogonEmailAdministrator + +"; + +while (list($CUID, $CUsername, $Joined, $LastLogon, $email, $isAdmin) = mysql_fetch_row($result)) { + + //$Joined = Date("d/m/y - g:ia", $Joined); + $Joined = strtotime($Joined); + //$Joined = relative_date($Joined); + $Joined = date("Y-m-d", $Joined); + + $LastLogon = strtotime($LastLogon); + //$LastLogon = relative_date($LastLogon); + $LastLogon = date("Y-m-d", $LastLogon); + + if ($isAdmin == 1) + $isAdmin = "Yes"; + else + $isAdmin = "No"; + + + Echo " +$CUID +$CUsername +$Joined +$LastLogon +$email +$isAdmin +"; + +} + +Echo " + +
+
+ + + + +
+"; + + +function SendEmail($body, $subject = "Pathery Newsletter", $to = 'snapwilliam@gmail.com') { + // !! TODO + $to = 'snapwilliam@gmail.com'; + $mycompany = "Pathery"; + + $fromemail = "snap@pathery.com"; + $replyemail = "snap@pathery.com"; + + # -=-=-=- MIME BOUNDARY + $mime_boundary = "----$mycompany----".md5(time()); + # -=-=-=- MAIL HEADERS + $headers = "From: $mycompany <$fromemail>\n"; + $headers .= "Reply-To: $mycompany <$replyemail>\n"; + $headers .= "MIME-Version: 1.0\n"; + $headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n"; + + # -=-=-=- TEXT EMAIL PART + $message = "--$mime_boundary\n"; + $message .= "Content-Type: text/plain; charset=UTF-8\n"; + $message .= "Content-Transfer-Encoding: 8bit\n\n"; + + $message .= $body; + + # -=-=-=- HTML EMAIL PART + //None + # -=-=-=- FINAL BOUNDARY + $message .= "--$mime_boundary--\n\n"; + # -=-=-=- SEND MAIL + $mail_sent = @mail( $to, $subject, $message, $headers ); + Return $mail_sent; +} + + + +//Thank you: +//http://snippets.dzone.com/posts/show/196 +function relative_date($time) { + $today = strtotime(date('M j, Y')); + $reldays = ($time - $today)/86400; + if ($reldays >= 0 && $reldays < 1) { + return 'Today'; + } else if ($reldays >= 1 && $reldays < 2) { + return 'Tomorrow'; + } else if ($reldays >= -1 && $reldays < 0) { + return 'Yesterday'; + } + if (abs($reldays) < 7) { + if ($reldays > 0) { + $reldays = floor($reldays); + return 'in ' . $reldays . ' day' . ($reldays != 1 ? 's' : ''); + } else { + $reldays = abs(floor($reldays)); + return $reldays . ' day' . ($reldays != 1 ? 's' : '') . ' ago'; + } + } + if (abs($reldays) < 182) { + return date('l, F j',$time ? $time : time()); + } else { + return date('l, F j, Y',$time ? $time : time()); + } +} + +htmlFooter(); +?> \ No newline at end of file -- cgit v1.2.3