diff options
author | Patrick Davison <snapwilliam@gmail.com> | 2013-01-09 16:54:12 -0800 |
---|---|---|
committer | Patrick Davison <snapwilliam@gmail.com> | 2013-01-09 16:54:12 -0800 |
commit | 4de2151306cee8ad7983f201a74d15a44d2b06b7 (patch) | |
tree | 3b16bdc62f8cdd3765dd64da3b45f99b096b80e2 /pages/massemail.php | |
parent | 16567167343024754247818e92115ed83255ed0d (diff) | |
download | pathery-4de2151306cee8ad7983f201a74d15a44d2b06b7.tar.xz |
Challenges, massEmail functions started
Diffstat (limited to 'pages/massemail.php')
-rw-r--r-- | pages/massemail.php | 209 |
1 files changed, 209 insertions, 0 deletions
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 @@ +<?php
+htmlHeader();
+?>
+<body>
+<?php
+topbar($Links);
+
+include('./includes/datas.php');
+include('./includes/db.inc.php');
+
+
+if (isset($_POST['massemail']) AND isset($_SESSION['accepted'])) {
+ if (!$accepted)
+ return;
+ if ($_SESSION['isAdmin'] !== true)
+ return;
+
+ $data = $_POST;
+ $data['session'] = print_r($_SESSION, true);
+
+ $userID = $_SESSION['userID'] * 1;
+ if (!is_int($userID))
+ return;
+
+ include_once "includes/db.inc.php";
+ $sql = "SELECT `email` FROM `users`
+ WHERE `ID` = '$userID'";
+ $result = mysql_query($sql);
+
+ $email = mysql_result($result, 0, 'email');
+
+ $data['email'] = $email;
+
+ EmailError($data, "Pathery Feedback");
+ DoRedirect("<b>Thank you for your feedback!</b> <br />
+ I'm Reading this right now.<br />
+ Well, obviously I'm not reading it right NOW.<br />
+ I guess what I meant to say is that I'll be reading it soon.<br />
+ Wow this redirect is taking a while.. Sorry<br />
+ Are you still here?<br />
+ 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 "
+<div class='wrapper'>
+ <center>
+ <h3>MASS EMAIL</h3>
+ </center>
+";
+
+
+?>
+
+<form action="massemail" method="post" name="massemail">
+<select id='Regarding' name='regarding'>
+ <option value='Feedback' selected='selected'>General Feedback</option>
+ <option value='Bug'>Bug report</option>
+ <option value='Suggestion'>Suggestion</option>
+ <option value='Question'>Question</option>
+ <option value='Hi'>Just saying Hi</option>
+ <option value='Other'>Other</option>
+</select>
+<br /><br />
+
+Title: <input type="text" size="25" maxlength="60" value="" name="title" class="forminput" /><br />
+<textarea name='body' rows="10" cols="30"></textarea><br />
+<input type="checkbox" name="emailback" value="yes" /> Please email me back
+<br /><br />
+<input type="submit" value="Submit" />
+</form>
+
+
+<h3> EXAMPLE SET </h3>
+
+<?
+
+echo "<table style='padding-left:20px;'>
+<tr>
+<th>ID</th><th>Display name:</th><th>Joined On:</th><th>Last Logon</th><th>Email</th><th>Administrator</th>
+</tr>
+";
+
+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 "<tr>
+<td>$CUID</td>
+<td><a href='javascript:;'>$CUsername</a></td>
+<td>$Joined</td>
+<td>$LastLogon</td>
+<td>$email</td>
+<td>$isAdmin</td>
+</tr>";
+
+}
+
+Echo "
+ </table>
+ <br />
+ <br />
+ </td>
+ </tr>
+</table>
+<!-- end wrapper --!>
+</div>
+";
+
+
+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 |