This commit has been accessed 880 times via Git panel.
commit 7ee2c8c1f3bc3e5a61cbcec1f7bb348b02487b5e
tree a041f850a521b9eadf1508df7e754d9647e364bf
parent 4f125f218b4587ddfbbe65bd854cd628fed6ad43
author Engels Antonio <engels@majcms.org> 1297788591 +0800
committer Engels Antonio <engels@majcms.org> 1297788591 +0800
Add basic webmail for subscriber login
diff --git a/core.php b/core.php
new file mode 100644
index 0000000..927cc97
--- /dev/null
+++ b/core.php
@@ -0,0 +1,122 @@
+<?php
+
+if (isset($_POST['mbox_min']) and !empty($_POST['mbox_min']) and is_numeric($_POST['mbox_min'])) {
+ $mbox_min = $_POST['mbox_min'];
+}
+else {
+ $mbox_min = "0";
+}
+
+if (isset($_POST['mbox_ppg']) and !empty($_POST['mbox_ppg']) and is_numeric($_POST['mbox_ppg'])) {
+ $mbox_ppg = $_POST['mbox_ppg'];
+}
+else {
+ $mbox_ppg = "14";
+}
+
+
+$mbox_max = $mbox_min + $mbox_ppg;
+
+function time_elapsed_string($ptime) {
+ $etime = time() - $ptime;
+
+ if ($etime < 1) {
+ return '0 seconds';
+ }
+
+ $a = array( 12 * 30 * 24 * 60 * 60 => 'year',
+ 30 * 24 * 60 * 60 => 'month',
+ 7 * 24 * 60 * 60 => 'week',
+ 24 * 60 * 60 => 'day',
+ 60 * 60 => 'hour',
+ 60 => 'minute',
+ 1 => 'second'
+ );
+
+ foreach ($a as $secs => $str) {
+ $d = $etime / $secs;
+ if ($d >= 1) {
+ $r = round($d);
+ return $r . ' ' . $str . ($r > 1 ? 's' : '');
+ }
+ }
+}
+
+function HumanReadableFilesize($size) {
+
+ // Adapted from: http://www.php.net/manual/en/function.filesize.php
+
+ $mod = 1024;
+
+ $units = explode(' ','B KB MB GB TB PB');
+ for ($i = 0; $size > $mod; $i++) {
+ $size /= $mod;
+ }
+
+ return round($size, 2) . ' ' . $units[$i];
+}
+
+function get_mime_type(&$struct) {
+
+ $primary_mime_type = array("TEXT", "MULTIPART","MESSAGE", "APPLICATION", "AUDIO", "IMAGE", "VIDEO", "OTHER");
+
+ if($struct->subtype) {
+ return $primary_mime_type[(int) $struct->type] . '/' .$struct->subtype;
+ }
+
+ return "TEXT/PLAIN";
+}
+
+function get_part($stream, $msg_number, $mime_type, $structure = false, $part_number = false) {
+
+ if (!$structure) {
+ $structure = imap_fetchstructure($stream, $msg_number);
+ }
+
+ if ($structure) {
+
+ if ($mime_type == get_mime_type($structure)) {
+
+ if (!$part_number) {
+ $part_number = "1";
+ }
+
+ $text = imap_fetchbody($stream, $msg_number, $part_number);
+
+ if ($structure->encoding == 3) {
+ return imap_base64($text);
+ }
+ else if ($structure->encoding == 4) {
+ return imap_qprint($text);
+ }
+ else {
+ return $text;
+ }
+ }
+
+ if ($structure->type == 1) /* multipart */ {
+
+ while (list($index, $sub_structure) = each($structure->parts)) {
+
+ if ($part_number) {
+ $prefix = $part_number . '.';
+ }
+
+ $data = get_part($stream, $msg_number, $mime_type, $sub_structure,$prefix . ($index + 1));
+
+ if ($data) {
+ return $data;
+ }
+ } // END OF WHILE
+ } // END OF MULTIPART
+ } // END OF STRUTURE
+ return false;
+} // END OF FUNCTION
+
+function extract_emails_from($string){
+ preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $string, $matches);
+ return $matches[0];
+}
+
+
+?>
diff --git a/css.php b/css.php
index ca350d1..5d0f86b 100644
--- a/css.php
+++ b/css.php
@@ -1,7 +1,12 @@
-body,p,td {
+* {
+ font-size: 1em;
+ outline: none;
+}
+
+body {
color: #666666;
background: #ffffff;
- font-size: 11px;
+ font-size: 0.75em;
font-family: arial,helvetica,sans-serif;
}
@@ -11,31 +16,29 @@ a,a:link,a:visited,a:hover,a:active {
color: #666666;
}
-.input {
+.input,.button {
color: #666666;
background: #ffffff;
border: #999999 solid 1px;
width: 100%;
- font-size: 11px;
font-family: arial,helvetica,sans-serif;
}
-.rinput {
- color: #666666;
- background: #ffffff;
- border: #999999 solid 1px;
- width: 75px;
- font-size: 11px;
- font-family: arial,helvetica,sans-serif;
- text-align: right;
- padding: 0px 1px 0px 0px;
+.input {
+ -moz-box-shadow: inset 0 0 2px #dedede;
+ -khtml-box-shadow: inset 0 0 2px #dedede;
+ -webkit-box-shadow: inset 0 0 2px #dedede;
+ box-shadow: inset 0 0 2px #dedede;
+}
+
+.input:focus {
+ background: #ffffcc;
}
.ack {
color: #74ae0b;
background: #cde2a7;
border: #74ae0b solid 1px;
- font-size: 11px;
font-weight: bold;
font-family: arial,helvetica,sans-serif;
text-align: center;
@@ -50,7 +53,6 @@ a,a:link,a:visited,a:hover,a:active {
color: #ff6666;
background: #ffbbbb;
border: #ff6666 solid 1px;
- font-size: 11px;
font-weight: bold;
font-family: arial,helvetica,sans-serif;
text-align: center;
@@ -65,7 +67,6 @@ a,a:link,a:visited,a:hover,a:active {
color: #f3e533;
background: #fcffcd;
border: #f3e533 solid 1px;
- font-size: 11px;
font-weight: bold;
font-family: arial,helvetica,sans-serif;
text-align: center;
@@ -75,3 +76,44 @@ a,a:link,a:visited,a:hover,a:active {
filter: alpha(opacity=90);
opacity: 0.9;
}
+
+.folders {
+ border: solid 1px #ccc;
+ padding: 5px;
+ -moz-box-shadow: 0 0 2px #dedede;
+ -khtml-box-shadow: 0 0 2px #dedede;
+ -webkit-box-shadow: 0 0 2px #dedede;
+ box-shadow: 0 0 2px #dedede;
+}
+
+.main {
+ border: solid 1px #ccc;
+ padding: 2px;
+ -moz-box-shadow: 0 0 2px #dedede;
+ -khtml-box-shadow: 0 0 2px #dedede;
+ -webkit-box-shadow: 0 0 2px #dedede;
+ box-shadow: 0 0 2px #dedede;
+}
+
+.message {
+ border: 1px solid #ccc;
+ padding: 5px;
+}
+
+.spacer {
+ height: 2px;
+}
+
+.login {
+ width: 300px;
+ border: none;
+ margin-top: 10%;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.label {
+ width: 40px;
+ text-align: center;
+ font-size: 0.75em;
+}
diff --git a/folders.php b/folders.php
new file mode 100644
index 0000000..9ffce98
--- /dev/null
+++ b/folders.php
@@ -0,0 +1,112 @@
+<?php
+
+session_start();
+
+if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
+ exit;
+}
+
+$conn = '{127.0.0.1:143/imap/notls/norsh}';
+
+$mbox = imap_open($conn, $_SESSION['logged_uid'], $_SESSION['logged_key'], OP_HALFOPEN) or die("can't connect: " . imap_last_error());
+
+echo "<div class=\"folders\"><table border=\"0\" cellspacing=\"1\" callpadding=\"2\">";
+echo "<form method=\"post\">";
+echo "<input type=\"hidden\" name=\"new\" value=\"1\">";
+echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-new.png\"></td><td>Compose</td></tr>";
+echo "</form>";
+
+if (!isset($_POST['get']) and !isset($_POST['rep'])) {
+
+ $mbox_prev = $mbox_min - $mbox_ppg;
+
+ if ($mbox_prev >= 0) {
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_prev\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ //echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-next.png\"></td><td>Prev $mbox_ppg Msgs</td></tr>";
+ echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-next.png\"></td><td>Prev</td></tr>";
+ echo "</form>";
+ }
+
+ $mbox_next = $mbox_min + $mbox_ppg;
+
+ if ($mbox_next < $msgCount) {
+
+ if (($msgCount - $mbox_next) < $mbox_ppg) {
+ $mbox_ppg = $msgCount - $mbox_next;
+ }
+
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_next\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ //echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-prev.png\"></td><td>Next $mbox_ppg Msgs</td></tr>";
+ echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-prev.png\"></td><td>Next</td></tr>";
+ echo "</form>";
+ }
+}
+
+if ($_POST['box'] == "Trash") {
+
+ $trash_status = imap_status($mbox, "{$conn}Trash", SA_MESSAGES+SA_UNSEEN);
+
+ if ($trash_status->messages > 0) {
+
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"emt\" value=\"1\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"Trash\">";
+ echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/trashcan_purge.png\"></td><td><nobr>Empty Trash</nobr></td></tr>";
+ echo "</form>";
+ }
+}
+
+echo "</table></div>";
+
+echo "<div style=\"height: 4px;\"></div>";
+
+$folders = imap_list($mbox, $conn, "*");
+
+if (is_array($folders)) {
+
+ reset($folders);
+ sort($folders);
+
+ $folder_images = glob("images/folder*");
+
+ foreach ($folder_images as $folder_image) {
+ echo "\n\n<script>\n\tvar img_preload = new Image();\n\timg_preload.src = \"$folder_image\";\n</script>";
+ }
+
+ echo "\n\n<div class=\"folders\"><table border=\"0\" cellspacing=\"1\" callpadding=\"2\">";
+
+ foreach ($folders as $folder) {
+
+ $status = imap_status($mbox, $folder, SA_MESSAGES+SA_UNSEEN);
+
+ $status_folder = "(" . $status->unseen . "/" . $status->messages . ")";
+
+ $folder = str_replace($conn,"",$folder);
+
+ echo "<tr><form method=\"post\"><td align=\"center\"><input type=\"hidden\" name=\"box\" value=\"$folder\">";
+
+ if ((!isset($_POST['box']) and ($folder == "INBOX")) or (isset($_POST['box']) and ($_POST['box'] == $folder))) {
+ echo "<input type=\"image\" src=\"images/folder-open.png\"></td></form>";
+ echo "<td><nobr><b>$folder</b> $status_folder</nobr></td></tr>";
+ }
+ else {
+ echo "<input type=\"image\" src=\"images/folder-close.png\"></td></form>";
+ echo "<td><nobr>$folder $status_folder</nobr></td></tr>";
+ }
+
+
+ }
+
+ echo "</table></div>";
+}
+else {
+ echo "imap_getmailboxes failed: " . imap_last_error() . "\n";
+}
+
+imap_close($mbox);
+
+?>
diff --git a/images/attach.png b/images/attach.png
new file mode 100644
index 0000000..a026e3e
Binary files /dev/null and b/images/attach.png differ
diff --git a/images/file.png b/images/file.png
new file mode 100644
index 0000000..0316c31
Binary files /dev/null and b/images/file.png differ
diff --git a/images/folder-close.png b/images/folder-close.png
new file mode 100644
index 0000000..10cf31e
Binary files /dev/null and b/images/folder-close.png differ
diff --git a/images/folder-open.png b/images/folder-open.png
new file mode 100644
index 0000000..63a5206
Binary files /dev/null and b/images/folder-open.png differ
diff --git a/images/logo.png b/images/logo.png
new file mode 100644
index 0000000..9d975ee
Binary files /dev/null and b/images/logo.png differ
diff --git a/images/mail-forward.png b/images/mail-forward.png
new file mode 100644
index 0000000..bd805f3
Binary files /dev/null and b/images/mail-forward.png differ
diff --git a/images/mail-new.png b/images/mail-new.png
new file mode 100644
index 0000000..f9666ee
Binary files /dev/null and b/images/mail-new.png differ
diff --git a/images/mail-next.png b/images/mail-next.png
new file mode 100644
index 0000000..66168af
Binary files /dev/null and b/images/mail-next.png differ
diff --git a/images/mail-prev.png b/images/mail-prev.png
new file mode 100644
index 0000000..dd8d16f
Binary files /dev/null and b/images/mail-prev.png differ
diff --git a/images/mail-read.png b/images/mail-read.png
new file mode 100644
index 0000000..a14e05a
Binary files /dev/null and b/images/mail-read.png differ
diff --git a/images/mail-replied.png b/images/mail-replied.png
new file mode 100644
index 0000000..c7d5e68
Binary files /dev/null and b/images/mail-replied.png differ
diff --git a/images/mail-reply-all.png b/images/mail-reply-all.png
new file mode 100644
index 0000000..0d2c165
Binary files /dev/null and b/images/mail-reply-all.png differ
diff --git a/images/mail-reply.png b/images/mail-reply.png
new file mode 100644
index 0000000..5b1e693
Binary files /dev/null and b/images/mail-reply.png differ
diff --git a/images/mail-unread.png b/images/mail-unread.png
new file mode 100644
index 0000000..4a71da1
Binary files /dev/null and b/images/mail-unread.png differ
diff --git a/images/trashcan_empty.png b/images/trashcan_empty.png
new file mode 100644
index 0000000..cc5d1d2
Binary files /dev/null and b/images/trashcan_empty.png differ
diff --git a/images/trashcan_full.png b/images/trashcan_full.png
new file mode 100644
index 0000000..335e67e
Binary files /dev/null and b/images/trashcan_full.png differ
diff --git a/images/trashcan_purge.png b/images/trashcan_purge.png
new file mode 100644
index 0000000..cc5d1d2
Binary files /dev/null and b/images/trashcan_purge.png differ
diff --git a/inbox.php b/inbox.php
new file mode 100644
index 0000000..db9c5d8
--- /dev/null
+++ b/inbox.php
@@ -0,0 +1,207 @@
+<?php
+
+session_start();
+
+if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
+ exit;
+}
+
+if (!isset($_POST['box']) or empty($_POST['box'])) {
+ $folder = "INBOX";
+}
+else {
+ $folder = trim(strip_tags($_POST['box']));
+}
+
+$host = "{127.0.0.1:143/imap/notls/norsh}";
+
+$mbox = @imap_open("{$host}$folder", $_SESSION['logged_uid'], $_SESSION['logged_key']) or die("Connection to server failed");
+
+if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])) {
+
+ $msgno = trim(strip_tags($_POST['msg']));
+
+ if ($_POST['del'] == "1") {
+ imap_createmailbox($mbox,"{$host}Trash");
+ imap_mail_move($mbox,$msgno,"Trash");
+ imap_expunge($mbox);
+ }
+
+ if ($_POST['del'] == "0") {
+ imap_mail_move($mbox,$msgno,"Inbox");
+ imap_expunge($mbox);
+ }
+}
+
+
+if ($hdr = imap_check($mbox)) {
+ $msgCount = $hdr->Nmsgs;
+}
+else {
+ echo "failed";
+}
+
+if (!isset($_POST['show_max']) or empty($_POST['show_max']) or !is_numeric($_POST['show_max'])) {
+ $show_max = $msgCount;
+}
+else {
+ $show_max = $_POST['show_max'];
+}
+
+imap_headers($mbox);
+
+$mbox_sort = imap_sort($mbox,"SORTARRIVAL",1);
+
+$mail_images = glob("images/mail*");
+
+foreach ($mail_images as $mail_image) {
+ echo "\n\n<script>\n\tvar img_preload = new Image();\n\timg_preload.src = \"$mail_image\";\n</script>";
+}
+
+require_once("core.php");
+
+echo "<title>Kartero - $folder ($msgCount) - " . $_SESSION['logged_uid'] . "</title>";
+
+echo "\n\n<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\" width=\"800\">";
+
+echo "<tr bgcolor=\"#eeeeee\"><td align=\"center\" width=\"32\">";
+
+if ($folder == "Trash") {
+ echo "un";
+}
+
+echo "del</td><td align=\"center\" width=\"200\">";
+
+if ($folder == "Sent") {
+ echo "recipient";
+}
+else {
+ echo "sender";
+}
+
+echo "</td><td align=\"center\" width=\"300\">subject</td><td align=\"center\" width=\"64\">";
+
+if ($folder == "Sent") {
+ echo "sent";
+}
+else {
+ echo "received";
+}
+
+echo "</td><td align=\"center\" width=\"64\">size</td><td align=\"center\" width=\"32\">read</td></tr>\n";
+
+foreach ($mbox_sort as $mbox_num => $mbox_row) {
+
+ if ($mbox_num < $mbox_min) {
+ continue;
+ }
+
+ if ($mbox_num >= $mbox_max) {
+ continue;
+ }
+
+ $val = imap_fetch_overview($mbox,$mbox_row);
+ $msgno=$val[0]->msgno;
+ $seen=$val[0]->seen;
+ $recent=$val[0]->recent;
+ $answered=$val[0]->answered;
+ $size=$val[0]->size;
+
+ if ($folder == "Sent") {
+ $from=$val[0]->to;
+ }
+ else {
+ $from=$val[0]->from;
+ }
+
+ $subj=$val[0]->subject;
+ $date=$val[0]->date;
+
+ $subj = imap_utf8($subj);
+ $subj = utf8_decode($subj);
+
+ $from = imap_utf8($from);
+ $from = utf8_decode($from);
+
+ $from = htmlentities($from,ENT_QUOTES);
+ $from = "<b>" . $from;
+ $from = str_replace(""","",$from);
+ $from = str_replace(">","",$from);
+ $from = str_replace(" <","</b><br>",$from);
+
+ $date = strtotime($date);
+ $date = time_elapsed_string($date);
+
+ $size = HumanReadableFilesize($size);
+
+ $from = ereg_replace("\"","",$from);
+
+ if ($bgColor == "#ffffff") {
+ $bgColor = "#fdfdfd";
+ }
+ else {
+ $bgColor = "#ffffff";
+ }
+
+ if (strlen($subj) > 75) {
+ $subj = substr($subj,0,74) . "...";
+ }
+
+ $subj = htmlentities($subj,ENT_QUOTES);
+
+ if ($seen == "0") {
+ $status_img = "mail-unread.png";
+ }
+
+ if ($seen == "1") {
+ $status_img = "mail-read.png";
+ }
+
+ if ($recent == "1") {
+ $status_img = "mail-new.png";
+ }
+
+ if ($answered == "1") {
+ $status_img = "mail-replied.png";
+ }
+
+ echo "<tr bgcolor=\"$bgColor\">";
+
+ echo "<form method=\"post\"><td>";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+
+ if ($folder == "Trash") {
+ echo "<input type=\"hidden\" name=\"del\" value=\"0\">";
+ echo "<input type=\"image\" src=\"images/trashcan_full.png\">";
+ }
+ else {
+ echo "<input type=\"hidden\" name=\"del\" value=\"1\">";
+ echo "<input type=\"image\" src=\"images/trashcan_empty.png\">";
+ }
+
+ echo "</td></form>";
+
+ echo "<td>$from</td>";
+
+ echo "<td>$subj</td>";
+
+ echo "<td align=\"center\"><nobr>$date ago</nobr></td>";
+ echo "<td align=\"right\"><nobr>$size</nobr></td>";
+
+ echo "<form method=\"post\"><td align=\"center\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+ echo "<input type=\"hidden\" name=\"get\" value=\"1\">";
+ echo "<input type=\"image\" src=\"images/$status_img\"></td></form>";
+
+ echo "</tr>\n";
+}
+
+echo "</table>";
+
+imap_close($mbox);
+
+?>
diff --git a/index.php b/index.php
index 0cb3492..fd5c90f 100644
--- a/index.php
+++ b/index.php
@@ -4,10 +4,10 @@
$db_host = "localhost";
$db_name = "kartero";
-$db_user = "root";
-$db_pass = "password";
+$db_user = "kartero";
+$db_pass = "fr1ng3!";
-$mail_root = "/var/www/html/mailroot";
+$mail_root = "/var/spool/kartero";
/* feel free to hack the succeeding code to suit your needs (basic php and mysql skills required) */
@@ -133,13 +133,22 @@ if (!is_int($pw_put)) {
}
$pw_put = strip_tags($pw_put);
+
+$pw_mbox = $pw_put;
+
$pw_put = crypt($pw_put,$pw_get);
if ($pw_put == $pw_get) {
$_SESSION['logged_uid'] = $id_put;
$_SESSION['logged_lvl'] = $lvl_put;
+
+ if ($_SESSION['logged_lvl'] == "subscriber") {
+ $_SESSION['logged_key'] = $pw_mbox;
+ }
}
+unset($pw_mbox);
+
if (isset($_GET['do']) and ($_GET['do'] == "logout")) {
$_SESSION = array();
session_destroy();
@@ -150,20 +159,33 @@ if (isset($_GET['do']) and ($_GET['do'] == "logout")) {
/* logo here? */
if (!isset($_SESSION['logged_uid']) and (($pw_put != $pw_get) or !isset($_POST['id']) or !isset($_POST['pw']) or empty($_POST['id']) or empty($_POST['pw']))) {
+
+ echo "<title>Kartero</title>";
+
+ echo "<div class=\"login\"><center>";
+
+ echo "<img src=\"images/logo.png\" border=\"0\" width=\"100\" height=\"100\">";
+ echo "<br>kartero v1.0 at {$_SERVER['SERVER_NAME']}<br><br>";
+
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
echo "<form method=\"post\">";
- echo "<tr bgcolor=\"#ffffff\"><td width=\"150\"><select class=\"input\" name=\"lvl\"><option value=\"subscriber\">subscriber</option><option value=\"postmaster\">postmaster</option><option value=\"administrator\">administrator</option></select></td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td width=\"150\"><input class=\"input\" type=\"text\" name=\"id\" autocomplete=\"off\" maxlength=\"128\"></td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td width=\"150\"><input class=\"input\" type=\"password\" name=\"pw\" autocomplete=\"off\" maxlength=\"64\"></td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td width=\"150\"><input class=\"input\" type=\"submit\" value=\"login\"></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td><select class=\"input\" name=\"lvl\"><option value=\"subscriber\">subscriber</option><option value=\"postmaster\">postmaster</option><option value=\"administrator\">administrator</option></select></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"text\" name=\"id\" autocomplete=\"off\" maxlength=\"128\"></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"pw\" autocomplete=\"off\" maxlength=\"64\"></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"button\" type=\"submit\" value=\"login\"></td></tr>";
echo "</form>";
echo "</table>";
+
+ echo "</center></div>";
+
exit;
}
if (isset($_SESSION['logged_uid'])) {
- echo "<p><nobr>You are currently logged in to your {$_SESSION['logged_uid']} {$_SESSION['logged_lvl']} account. Click <a href=\"?do=logout\">here</a> to logout.</nobr></p>";
+ //echo "<center>";
+
+ echo "<nobr>You are currently logged in to your {$_SESSION['logged_uid']} {$_SESSION['logged_lvl']} account. Click <a href=\"?do=logout\">here</a> to logout.</nobr><br><br>";
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
echo "<tr><td colspan=\"3\" valign=\"top\">";
@@ -739,23 +761,121 @@ if (isset($_SESSION['logged_uid'])) {
if ($_SESSION['logged_lvl'] == "subscriber") {
- echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
+
+ if (isset($_POST['reply_from']) and isset($_POST['reply_to']) and isset($_POST['reply_subj']) and isset($_POST['reply_body'])) {
+
+ $reply_from = trim($_POST['reply_from']);
+ $reply_to = trim($_POST['reply_to']);
+ $reply_subj = trim($_POST['reply_subj']);
+ $reply_body = trim($_POST['reply_body']);
+
+
+ $reply_headers = "From: $reply_from\r\nX-Mailer: Kartero/1.0 (PHP/" . phpversion() . ")";
+
+ if (isset($_POST['reply_cc']) and !empty($_POST['reply_cc'])) {
+
+ $reply_cc = trim($_POST['reply_cc']);
+
+ $reply_headers = "$reply_headers\r\nCc: $reply_cc";
+ }
+
+ if (isset($_POST['reply_bcc']) and !empty($_POST['reply_bcc'])) {
+
+ $reply_bcc = trim($_POST['reply_bcc']);
+
+ $reply_headers = "$reply_headers\r\nBcc: $reply_bcc";
+ }
+
+ $reply_body = preg_replace("#(?<!\r)\n#si", "\r\n", $reply_body);
+ $reply_headers = preg_replace('#(?<!\r)\n#si', "\r\n", $reply_headers);
+
+ mail($reply_to, $reply_subj, $reply_body, $reply_headers);
+
+ $host = "{127.0.0.1:143/imap/notls/norsh}";
+
+ $mbox = @imap_open($host, $_SESSION['logged_uid'], $_SESSION['logged_key']) or die("Connection to server failed");
+
+ imap_createmailbox($mbox,"{$host}Sent");
+
+ $reply_date = date ("d-M-Y H:i:s O");
+
+ imap_append($mbox,"{$host}Sent","To: $reply_to\r\nSubject: $reply_subj\r\nDate: $reply_date\r\n$reply_headers\r\n\r\n$reply_body\r\n");
+
+ if ($_POST['ack'] == 1) {
+
+ imap_reopen($mbox, "{$host}{$_POST['box']}");
+ imap_setflag_full($mbox, $_POST['msg'], '\\Answered');
+ }
+
+ imap_close($mbox);
+ }
+
+ if (isset($_POST['not']) and !empty($_POST['not']) and is_numeric($_POST['not'])) {
+
+ $host = "{127.0.0.1:143/imap/notls/norsh}";
+
+ $mbox = @imap_open("{$host}{$_POST['box']}", $_SESSION['logged_uid'], $_SESSION['logged_key']) or die("Connection to server failed");
+
+ imap_clearflag_full($mbox, $_POST['msg'], '\\Seen');
+
+ imap_close($mbox, CL_EXPUNGE);
+ }
+
+ if (isset($_POST['emt']) and !empty($_POST['emt']) and is_numeric($_POST['emt'])) {
+
+ $host = "{127.0.0.1:143/imap/notls/norsh}";
+
+ $mbox = @imap_open("{$host}{$_POST['box']}", $_SESSION['logged_uid'], $_SESSION['logged_key']) or die("Connection to server failed");
+
+ imap_delete($mbox,'1:*');
+
+ imap_close($mbox, CL_EXPUNGE);
+ }
+
+ echo "<tr><td valign=\"top\" width=\"700\"><div class=\"main\">";
+
+ if (isset($_POST['get']) and !empty($_POST['get'])) {
+ include("read.php");
+ }
+ elseif (isset($_POST['rep']) and !empty($_POST['rep'])) {
+ include("send.php");
+ }
+ elseif (isset($_POST['new']) and !empty($_POST['new'])) {
+ include("post.php");
+ }
+ else {
+ include("inbox.php");
+ }
+
+ echo "</div></td>";
+
+ echo "<td width=\"10\"></td>";
+
+ echo "<td valign=\"top\" width=\"100\">";
+ include("folders.php");
+ echo "</td>";
+/*
+ echo "<td valign=\"top\" width=\"100\">";
+ echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\">";
echo "<form method=\"post\">";
- echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"><img src=\"images/user.png\" border=\"0\" width=\"16\" height=\"16\"></td><td><input class=\"input\" type=\"text\" name=\"usr_name\" value=\"$usr_name\" autocomplete=\"off\" maxlength=\"128\"></td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"><img src=\"images/pass.png\" border=\"0\" width=\"16\" height=\"16\"></td><td><input class=\"input\" type=\"password\" name=\"usr_pw1\" autocomplete=\"off\" maxlength=\"64\"></td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"><img src=\"images/pass.png\" border=\"0\" width=\"16\" height=\"16\"></td><td><input class=\"input\" type=\"password\" name=\"usr_pw2\" autocomplete=\"off\" maxlength=\"64\"></td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"><img src=\"images/pass.png\" border=\"0\" width=\"16\" height=\"16\"></td><td><input class=\"input\" type=\"password\" name=\"usr_pw3\" autocomplete=\"off\" maxlength=\"64\"></td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"></td><td><input class=\"input\" type=\"submit\" value=\"update\"></td></tr>";
- echo "</form>";
- echo "</table>";
+ echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"><img src=\"images/preferences-desktop-personal.png\" border=\"0\" width=\"22\" height=\"22\"></td><td><input class=\"input\" type=\"text\" name=\"usr_name\" value=\"$usr_name\" autocomplete=\"off\" maxlength=\"128\"></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"><img src=\"images/flag-red.png\" border=\"0\" width=\"22\" height=\"22\"></td><td><input class=\"input\" type=\"password\" name=\"usr_pw1\" autocomplete=\"off\" maxlength=\"64\"></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"><img src=\"images/flag-green.png\" border=\"0\" width=\"22\" height=\"22\"></td><td><input class=\"input\" type=\"password\" name=\"usr_pw2\" autocomplete=\"off\" maxlength=\"64\"></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"><img src=\"images/flag-green.png\" border=\"0\" width=\"22\" height=\"22\"></td><td><input class=\"input\" type=\"password\" name=\"usr_pw3\" autocomplete=\"off\" maxlength=\"64\"></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"></td><td><input class=\"button\" type=\"submit\" value=\"update\"></td></tr>";
+ echo "</form></table>";
+ echo "</td>";
+*/
+ echo "</tr></table>";
}
if ($_SESSION['logged_lvl'] == "postmaster") {
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
- echo "<tr bgcolor=\"#ffffff\"><td colspan=\"4\" align=\"center\"><b>status</b></td><td align=\"center\"><b>username</b></td><td align=\"center\"><b>complete name</b></td><td align=\"center\"><b>password</b></td><td align=\"center\"><b>host</b></td><td align=\"center\" colspan=\"2\"><b>action</b></td></tr>";
+ echo "<tr bgcolor=\"#eeeeee\"><td colspan=\"4\" align=\"center\">status</td><td align=\"center\">username</td><td align=\"center\">complete name</td><td align=\"center\">password</td><td align=\"center\">host</td><td align=\"center\" colspan=\"2\">action</td></tr>";
echo "<form method=\"post\">";
- echo "<tr bgcolor=\"#ffffff\"><td align=\"center\">new</td><td align=\"center\">cur</td><td align=\"center\">aka</td><td align=\"center\">rcv</td><td><input class=\"input\" type=\"text\" name=\"pm_id\" autocomplete=\"off\" maxlength=\"255\"></td><td><input class=\"input\" type=\"text\" name=\"pm_name\" autocomplete=\"off\" maxlength=\"128\"></td><td><input class=\"input\" type=\"text\" name=\"pm_pw\" autocomplete=\"off\" maxlength=\"64\"></td><td><input class=\"input\" type=\"text\" name=\"pm_host\" autocomplete=\"off\" maxlength=\"255\"></td><td colspan=\"2\"><input class=\"input\" type=\"submit\" value=\"add\"></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td align=\"center\">new</td><td align=\"center\">cur</td><td align=\"center\">aka</td><td align=\"center\">rcv</td><td><input class=\"input\" type=\"text\" name=\"pm_id\" autocomplete=\"off\" maxlength=\"255\"></td><td><input class=\"input\" type=\"text\" name=\"pm_name\" autocomplete=\"off\" maxlength=\"128\"></td><td><input class=\"input\" type=\"text\" name=\"pm_pw\" autocomplete=\"off\" maxlength=\"64\"></td><td><input class=\"input\" type=\"text\" name=\"pm_host\" autocomplete=\"off\" maxlength=\"255\"></td><td colspan=\"2\"><input class=\"button\" type=\"submit\" value=\"add\"></td></tr>";
echo "</form>";
$pm_get = mysql_query("select * from users where domain='{$_SESSION['logged_uid']}' order by id");
@@ -781,7 +901,7 @@ if (isset($_SESSION['logged_uid'])) {
$pm_aka = mysql_query("select * from aliases where alias='{$pm_row[0]}'");
$pm_aka = mysql_num_rows($pm_aka);
- echo "<tr bgcolor=\"$pm_bg\"><td align=\"right\">$msg_new</td><td align=\"right\">$msg_cur</td><td align=\"right\">$pm_aka</td><form method=\"post\"><input type=\"hidden\" name=\"pm_set\" value=\"{$pm_row[0]}\"><input type=\"hidden\" name=\"pm_do\" value=\"$pm_do\"><td align=\"center\" valign=\"middle\" width=\"10\"><input type=\"image\" src=\"images/{$pm_do}.png\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"pm_mod\" value=\"{$pm_row[0]}\"><td><b>{$pm_row[0]}</b></td><td><input class=\"input\" type=\"text\" name=\"pm_name\" maxlength=\"128\" autocomplete=\"off\" value=\"{$pm_row[3]}\"></td><td><input class=\"input\" type=\"text\" name=\"pm_pass\" maxlength=\"64\" autocomplete=\"off\"></td><td><input class=\"input\" type=\"text\" name=\"pm_host\" maxlength=\"255\" autocomplete=\"off\" value=\"{$pm_row[6]}\"></td><td><input class=\"input\" type=\"submit\" value=\"mod\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"pm_del\" value=\"{$pm_row[0]}\"><td><input class=\"input\" type=\"submit\" value=\"del\" onclick=\"if (confirm('Do you really want to delete {$pm_row[0]} plus all messages and aliases associated with this account?')) {return true;} else {return false;}\"></td></form></tr>";
+ echo "<tr bgcolor=\"$pm_bg\"><td align=\"right\">$msg_new</td><td align=\"right\">$msg_cur</td><td align=\"right\">$pm_aka</td><form method=\"post\"><input type=\"hidden\" name=\"pm_set\" value=\"{$pm_row[0]}\"><input type=\"hidden\" name=\"pm_do\" value=\"$pm_do\"><td align=\"center\" valign=\"middle\" width=\"10\"><input type=\"image\" src=\"images/{$pm_do}.png\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"pm_mod\" value=\"{$pm_row[0]}\"><td>{$pm_row[0]}</td><td><input class=\"input\" type=\"text\" name=\"pm_name\" maxlength=\"128\" autocomplete=\"off\" value=\"{$pm_row[3]}\"></td><td><input class=\"input\" type=\"text\" name=\"pm_pass\" maxlength=\"64\" autocomplete=\"off\"></td><td><input class=\"input\" type=\"text\" name=\"pm_host\" maxlength=\"255\" autocomplete=\"off\" value=\"{$pm_row[6]}\"></td><td><input class=\"button\" type=\"submit\" value=\"mod\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"pm_del\" value=\"{$pm_row[0]}\"><td><input class=\"button\" type=\"submit\" value=\"del\" onclick=\"if (confirm('Do you really want to delete {$pm_row[0]} plus all messages and aliases associated with this account?')) {return true;} else {return false;}\"></td></form></tr>";
}
echo "</table>";
@@ -790,8 +910,8 @@ if (isset($_SESSION['logged_uid'])) {
if ($_SESSION['logged_lvl'] == "administrator") {
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
- echo "<tr bgcolor=\"#ffffff\"><td colspan=\"2\" align=\"center\"><b>status</b></td><td align=\"center\"><nobr><b>domain name</b></nobr></td><td align=\"center\"><nobr><b>account limit</b></nobr></td><td align=\"center\"><nobr><b>postmaster password</b></nobr></td><td align=\"center\" colspan=\"2\"><b>action</b></td></tr>";
- echo "<form method=\"post\"><tr bgcolor=\"#ffffff\"><td align=\"center\">usr</td><td align=\"center\">rcv</td><td align=\"center\"><input class=\"input\" type=\"text\" name=\"dom_name\" maxlength=\"128\" autocomplete=\"off\"></td><td align=\"center\"><input class=\"rinput\" type=\"text\" name=\"dom_max\" maxlength=\"6\" autocomplete=\"off\" value=\"0\"></td><td align=\"center\"><input class=\"input\" type=\"text\" name=\"dom_pass\" maxlength=\"64\" autocomplete=\"off\"></td><td align=\"center\" colspan=\"2\"><input class=\"input\" type=\"submit\" value=\"add\" autocomplete=\"off\"></td></tr></form>";
+ echo "<tr bgcolor=\"#eeeeee\"><td colspan=\"2\" align=\"center\">status</td><td align=\"center\"><nobr>domain name</nobr></td><td align=\"center\"><nobr>account limit</nobr></td><td align=\"center\"><nobr>postmaster password</nobr></td><td align=\"center\" colspan=\"2\">action</td></tr>";
+ echo "<form method=\"post\"><tr bgcolor=\"#ffffff\"><td align=\"center\">usr</td><td align=\"center\">rcv</td><td align=\"center\"><input class=\"input\" type=\"text\" name=\"dom_name\" maxlength=\"128\" autocomplete=\"off\"></td><td align=\"center\"><input class=\"input\" style=\"text-align: right;\" type=\"text\" name=\"dom_max\" maxlength=\"6\" autocomplete=\"off\" value=\"0\"></td><td align=\"center\"><input class=\"input\" type=\"text\" name=\"dom_pass\" maxlength=\"64\" autocomplete=\"off\"></td><td align=\"center\" colspan=\"2\"><input class=\"button\" type=\"submit\" value=\"add\"></td></tr></form>";
$dom_get = mysql_query("select * from domains order by id");
@@ -810,7 +930,7 @@ if (isset($_SESSION['logged_uid'])) {
$dom_bg = "#eeeeee";
}
- echo "<tr bgcolor=\"$dom_bg\"><td align=\"right\">$dom_usr</td><form method=\"post\"><input type=\"hidden\" name=\"dom_set\" value=\"{$dom_row[0]}\"><input type=\"hidden\" name=\"dom_do\" value=\"$dom_do\"><td align=\"center\" valign=\"middle\" width=\"10\"><input type=\"image\" src=\"images/{$dom_do}.png\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"dom_mod\" value=\"{$dom_row[0]}\"><td><b>{$dom_row[0]}</b></td><td><input class=\"rinput\" type=\"text\" name=\"dom_max\" maxlength=\"6\" autocomplete=\"off\" value=\"{$dom_row[2]}\"></td><td><input class=\"input\" type=\"text\" name=\"dom_pass\" maxlength=\"64\" autocomplete=\"off\"></td><td><input class=\"input\" type=\"submit\" value=\"mod\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"dom_del\" value=\"{$dom_row[0]}\"><td><input class=\"input\" type=\"submit\" value=\"del\" onclick=\"if (confirm('Do you really want to delete {$dom_row[0]} plus all accounts and messages associated with this domain?')) {return true;} else {return false;}\"></td></form></tr>";
+ echo "<tr bgcolor=\"$dom_bg\"><td align=\"right\">$dom_usr</td><form method=\"post\"><input type=\"hidden\" name=\"dom_set\" value=\"{$dom_row[0]}\"><input type=\"hidden\" name=\"dom_do\" value=\"$dom_do\"><td align=\"center\" valign=\"middle\" width=\"10\"><input type=\"image\" src=\"images/{$dom_do}.png\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"dom_mod\" value=\"{$dom_row[0]}\"><td>{$dom_row[0]}</td><td><input class=\"input\" style=\"text-align: right;\" type=\"text\" name=\"dom_max\" maxlength=\"6\" autocomplete=\"off\" value=\"{$dom_row[2]}\"></td><td><input class=\"input\" type=\"text\" name=\"dom_pass\" maxlength=\"64\" autocomplete=\"off\"></td><td><input class=\"button\" type=\"submit\" value=\"mod\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"dom_del\" value=\"{$dom_row[0]}\"><td><input class=\"button\" type=\"submit\" value=\"del\" onclick=\"if (confirm('Do you really want to delete {$dom_row[0]} plus all accounts and messages associated with this domain?')) {return true;} else {return false;}\"></td></form></tr>";
}
echo "</table>";
@@ -823,9 +943,9 @@ if (isset($_SESSION['logged_uid'])) {
echo "<td width=\"10\"></td><td valign=\"top\">";
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
- echo "<tr bgcolor=\"#ffffff\"><td align=\"center\"><b>alias</b></td><td align=\"center\"><b>recipient</b></td><td align=\"center\" colspan=\"3\"><b>action</b></td></tr>";
+ echo "<tr bgcolor=\"#eeeeee\"><td align=\"center\">alias</td><td align=\"center\">recipient</td><td align=\"center\" colspan=\"3\">action</td></tr>";
echo "<form method=\"post\">";
- echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"text\" name=\"alias_add\" autocomplete=\"off\" maxlength=\"255\"></td><td><input class=\"input\" type=\"text\" name=\"alias_to\" autocomplete=\"off\" maxlength=\"128\"></td><td colspan=\"3\"><input class=\"input\" type=\"submit\" value=\"add\"></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"text\" name=\"alias_add\" autocomplete=\"off\" maxlength=\"255\"></td><td><input class=\"input\" type=\"text\" name=\"alias_to\" autocomplete=\"off\" maxlength=\"128\"></td><td colspan=\"3\"><input class=\"button\" type=\"submit\" value=\"add\"></td></tr>";
echo "</form>";
$get_aliases = mysql_query("select * from aliases where domain='{$_SESSION['logged_uid']}' order by id");
@@ -842,7 +962,7 @@ if (isset($_SESSION['logged_uid'])) {
$alias_bg = "#eeeeee";
}
- echo "<tr bgcolor=\"$alias_bg\"><form method=\"post\"><input type=\"hidden\" name=\"alias_mod\" value=\"{$aliases_row[0]}\"><td><b>{$aliases_row[0]}</b></td><td><input class=\"input\" type=\"text\" name=\"alias_to\" maxlength=\"255\" autocomplete=\"off\" value=\"{$aliases_row[1]}\"></td><td><input class=\"input\" type=\"submit\" value=\"mod\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"alias_set\" value=\"{$aliases_row[0]}\"><input type=\"hidden\" name=\"alias_do\" value=\"$alias_do\"><td align=\"center\" valign=\"middle\" width=\"10\"><input type=\"image\" src=\"images/{$alias_do}.png\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"alias_del\" value=\"{$aliases_row[0]}\"><td><input class=\"input\" type=\"submit\" value=\"del\" onclick=\"if (confirm('Do you really want to delete the {$aliases_row[0]} alias of {$aliases_row[1]}?')) {return true;} else {return false;}\"></td></form></tr>";
+ echo "<tr bgcolor=\"$alias_bg\"><form method=\"post\"><input type=\"hidden\" name=\"alias_mod\" value=\"{$aliases_row[0]}\"><td>{$aliases_row[0]}</td><td><input class=\"input\" type=\"text\" name=\"alias_to\" maxlength=\"255\" autocomplete=\"off\" value=\"{$aliases_row[1]}\"></td><td><input class=\"button\" type=\"submit\" value=\"mod\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"alias_set\" value=\"{$aliases_row[0]}\"><input type=\"hidden\" name=\"alias_do\" value=\"$alias_do\"><td align=\"center\" valign=\"middle\" width=\"10\"><input type=\"image\" src=\"images/{$alias_do}.png\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"alias_del\" value=\"{$aliases_row[0]}\"><td><input class=\"button\" type=\"submit\" value=\"del\" onclick=\"if (confirm('Do you really want to delete the {$aliases_row[0]} alias of {$aliases_row[1]}?')) {return true;} else {return false;}\"></td></form></tr>";
}
echo "</table>";
diff --git a/post.php b/post.php
new file mode 100644
index 0000000..e600cf3
--- /dev/null
+++ b/post.php
@@ -0,0 +1,45 @@
+<?php
+
+session_start();
+
+if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
+ exit;
+}
+
+require_once("core.php");
+
+if (isset($_POST['new']) and !empty($_POST['new']) and is_numeric($_POST['new'])) {
+
+ $reply_from = "\"$usr_name\" <{$_SESSION['logged_uid']}>";
+ $reply_from = htmlentities($reply_from,ENT_QUOTES);
+
+ echo "<title>Kartero - Compose - {$_SESSION['logged_uid']}</title>";
+
+ echo "<table border=\"0\" cellspacing=\"0\" callpadding=\"0\" width=\"800\"><tr><td valign=\"top\">";
+
+ echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\" width=\"100%\">";
+
+ echo "<form method=\"post\">";
+
+ echo "<tr><td width=\"50\"><b>From:</b></td><td rowspan=\"7\" width=\"5\"></td><td><input class=\"input\" type=\"text\" name=\"reply_from\" value=\"$reply_from\" readonly></td></tr>";
+ echo "<tr><td><b>To:</b></td><td><input class=\"input\" type=\"text\" name=\"reply_to\"></td></tr>";
+ echo "<tr><td><b>Cc:</b></td><td><input class=\"input\" type=\"text\" name=\"reply_cc\"></td></tr>";
+ echo "<tr><td><b>Bcc:</b></td><td><input class=\"input\" type=\"text\" name=\"reply_bcc\"></td></tr>";
+ echo "<tr><td><b>Subject:</b></td><td><input class=\"input\" type=\"text\" name=\"reply_subj\"></td></tr>";
+
+ echo "<tr><td></td><td><textarea class=\"input\" name=\"reply_body\" rows=\"10\">";
+
+ echo "</textarea></td></tr>";
+
+ echo "<tr><td></td><td align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\"></div><div class=\"label\">send</div></td></tr>";
+
+ echo "</table>";
+
+ echo "</form>";
+
+ echo "</td></tr>";
+ echo "</table>";
+
+}
+
+?>
diff --git a/read.php b/read.php
new file mode 100644
index 0000000..9550ecf
--- /dev/null
+++ b/read.php
@@ -0,0 +1,313 @@
+<?php
+
+session_start();
+
+if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
+ exit;
+}
+
+require_once("core.php");
+
+if (!isset($_POST['box']) or empty($_POST['box'])) {
+ $folder = "INBOX";
+}
+else {
+ $folder = trim(strip_tags($_POST['box']));
+}
+
+$host = "{127.0.0.1:143/imap/notls/norsh}";
+
+$mbox = @imap_open("{$host}$folder", $_SESSION['logged_uid'], $_SESSION['logged_key']) or die("Connection to server failed");
+
+if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])) {
+
+ $msgno = trim(strip_tags($_POST['msg']));
+
+ $header = imap_headerinfo($mbox, $msgno);
+
+ $header_subject = htmlentities($header->subject,ENT_QUOTES);
+ $header_fromaddress = htmlentities($header->fromaddress,ENT_QUOTES);
+ $header_date = htmlentities($header->date,ENT_QUOTES);
+ $header_date_age = time_elapsed_string(strtotime($header_date));
+ $header_toaddress = htmlentities($header->toaddress,ENT_QUOTES);
+ $header_ccaddress = htmlentities($header->ccaddress,ENT_QUOTES);
+
+ $header_fetch = imap_fetchheader($mbox,$msgno);
+
+ $header_raw_lines = explode("\r\n",$header_fetch);
+
+ foreach ($header_raw_lines as $header_raw_line) {
+
+ if (strstr($header_raw_line,"X-Mailer:")) {
+
+ $header_mailer = $header_raw_line;
+ }
+ }
+
+ $mbox_sort = imap_sort($mbox,"SORTARRIVAL",1);
+
+ foreach ($mbox_sort as $mbox_row => $mbox_num) {
+
+ if ($msgno == $mbox_num) {
+
+ $mbox_row_prev = $mbox_row - 1;
+ $mbox_row_next = $mbox_row + 1;
+ }
+ }
+
+ $msgno_next = $mbox_sort[$mbox_row_prev];
+ $msgno_prev = $mbox_sort[$mbox_row_next];
+
+ echo "<title>Kartero - $folder - $header_subject</title>";
+
+ echo "<table border=\"0\" cellspacing=\"0\" callpadding=\"0\" width=\"800\"><tr><td valign=\"top\">";
+
+ echo "<div class=\"message\">";
+
+ echo "<b>Subject: $header_subject</b>";
+ echo "<br><br>From: $header_fromaddress";
+ echo "<br>To: $header_toaddress";
+
+ if ($header_ccaddress != "") {
+ echo "<br>Cc: $header_ccaddress";
+ }
+
+ echo "<br>Date: $header_date ($header_date_age ago)";
+
+ if ($header_mailer != "") {
+ echo "<br>$header_mailer";
+ }
+
+ echo "</div>";
+
+
+ echo "<div class=\"spacer\"></div>";
+
+
+ echo "<div class=\"message\" style=\"padding: 2px;\">";
+
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadidng=\"0\" width=\"100%\"><tr>";
+
+ echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+
+ if ($folder == "Trash") {
+ echo "<input type=\"hidden\" name=\"del\" value=\"0\">";
+ echo "<input type=\"image\" src=\"images/trashcan_full.png\">";
+ }
+ else {
+ echo "<input type=\"hidden\" name=\"del\" value=\"1\">";
+ echo "<input type=\"image\" src=\"images/trashcan_empty.png\">";
+ }
+
+ echo "</td></form>";
+
+ echo "<td></td>";
+
+ echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+ echo "<input type=\"hidden\" name=\"not\" value=\"1\">";
+ echo "<input type=\"image\" src=\"images/mail-unread.png\">";
+ echo "</td></form>";
+
+ echo "<td width=\"5\"></td>";
+
+ echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+ echo "<input type=\"hidden\" name=\"rep\" value=\"2\">";
+ echo "<input type=\"image\" src=\"images/mail-forward.png\">";
+ echo "</td></form>";
+
+ echo "<td width=\"5\"></td>";
+
+ if (strpos($header->toaddress,",")) {
+
+ echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+ echo "<input type=\"hidden\" name=\"rep\" value=\"3\">";
+ echo "<input type=\"image\" src=\"images/mail-reply-all.png\">";
+ echo "</td></form>";
+
+ echo "<td width=\"5\"></td>";
+ }
+
+ echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+ echo "<input type=\"hidden\" name=\"rep\" value=\"1\">";
+ echo "<input type=\"image\" src=\"images/mail-reply.png\">";
+ echo "</td></form>";
+
+ echo "<td width=\"5\"></td>";
+
+ if ($msgno_next != "") {
+ echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno_next\">";
+ echo "<input type=\"hidden\" name=\"get\" value=\"1\">";
+ echo "<input type=\"image\" src=\"images/mail-next.png\">";
+ echo "</td></form>";
+
+ echo "<td width=\"5\"></td>";
+ }
+
+ if ($msgno_prev != "") {
+ echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno_prev\">";
+ echo "<input type=\"hidden\" name=\"get\" value=\"1\">";
+ echo "<input type=\"image\" src=\"images/mail-prev.png\">";
+ echo "</td></form>";
+ }
+
+ echo "</tr><tr>";
+
+ echo "<td class=\"label\">delete</td>";
+ echo "<td></td>";
+ echo "<td class=\"label\">unread</td>";
+ echo "<td width=\"5\"></td>";
+ echo "<td class=\"label\">forward</td>";
+ echo "<td width=\"5\"></td>";
+
+ if (strpos($header->toaddress,",")) {
+ echo "<td class=\"label\"><nobr>reply all</nobr></td>";
+ echo "<td width=\"5\"></td>";
+ }
+
+ echo "<td class=\"label\">reply</td>";
+ echo "<td width=\"5\"></td>";
+
+ if ($msgno_next != "") {
+ echo "<td class=\"label\"><nobr>prev msg</nobr></td>";
+ echo "<td width=\"5\"></td>";
+ }
+
+ if ($msgno_prev != "") {
+ echo "<td class=\"label\"><nobr>next msg</nobr></td>";
+ }
+
+ echo "</tr></table>";
+
+ echo "</div>";
+
+
+ echo "<div class=\"spacer\"></div>";
+
+
+ echo "<div class=\"message\">";
+
+ $dataTxt = get_part($mbox, $msgno, "TEXT/PLAIN");
+ $dataHtml = get_part($mbox, $msgno, "TEXT/HTML");
+
+ if ($dataHtml != "") {
+ $msgBody = $dataHtml;
+ } else {
+ $msgBody = $dataTxt;
+ $msgBody = imap_utf8($msgBody);
+ $msgBody = utf8_decode($msgBody);
+ $msgBody = ereg_replace("\n","<br>",$msgBody);
+ $msgBody = preg_replace("/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i","$1http://$2",$msgBody);
+ $msgBody = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i","<a target=\"_blank\" href=\"$1\">$1</a>",$msgBody);
+ $msgBody = preg_replace("/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?))/i","<a href=\"mailto:$1\">$1</a>",$msgBody);
+ }
+
+ echo $msgBody;
+
+ $struct = imap_fetchstructure($mbox, $msgno);
+
+ $contentParts = count($struct->parts);
+
+ if ($contentParts >= 2) {
+
+ for ($i=2;$i<=$contentParts;$i++) {
+ $att[$i-2] = imap_bodystruct($mbox,$msgno,$i);
+ }
+
+ for ($k=0;$k<sizeof($att);$k++) {
+
+ if ($att[$k]->parameters[0]->value == "us-ascii" || $att[$k]->parameters[0]->value == "US-ASCII") {
+
+ if ($att[$k]->parameters[1]->value != "") {
+ $attachDisplay[$k] = $att[$k]->parameters[1]->value;
+ }
+
+ }
+ elseif ($att[$k]->parameters[0]->value != "iso-8859-1" && $att[$k]->parameters[0]->value != "ISO-8859-1") {
+ $attachDisplay[$k] = $att[$k]->parameters[0]->value;
+ }
+ }
+ }
+
+ echo "</div>";
+
+ foreach ($attachDisplay as $attachD => $attachE) {
+
+ if (strtolower($attachE) == "utf-8") {
+ unset($attachDisplay[$attachD]);
+ }
+
+ if (strtolower($attachE) == "windows-1252") {
+ unset($attachDisplay[$attachD]);
+ }
+
+ if (strtolower($attachE) == "iso-8859-15") {
+ unset($attachDisplay[$attachD]);
+ }
+ }
+
+ sort($attachDisplay);
+ reset($attachDisplay);
+
+ if (sizeof($attachDisplay) > 0) {
+
+ $filePath = "attachments/" . sha1($_SERVER['SERVER_NAME']) ."/" . sha1($header->subject);
+
+ echo "<div class=\"spacer\"></div>";
+
+ echo "<div class=\"message\" style=\"position: relative;\">";
+
+
+ echo "<div style=\"position: absolute; top: -15; right: -15;\"><img src=\"images/attach.png\" border=\"0\" width=\"48\" height=\"48\"></div>";
+
+ echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\">";
+
+ for ($j=0;$j<sizeof($attachDisplay);$j++) {
+
+ if (($dataHtml != "") and (strtolower($attachDisplay[$j]) != "utf-8") and (strtolower($attachDisplay[$j]) != "windows-1252")) {
+ $file = $j;
+ $fileContent = base64_decode(imap_fetchbody($mbox,$msgno,$file+2));
+ $fileName = preg_replace("/[^a-z0-9_\-\.]/i","",$attachDisplay[$j]);
+
+ if (!file_exists($filePath)) {
+ mkdir($filePath,0700,1);
+ }
+
+ if (!file_exists("$filePath/$fileName")) {
+ file_put_contents("$filePath/$fileName",$fileContent);
+ }
+
+ $fileSize = filesize("$filePath/$fileName");
+ $fileSize = HumanReadableFilesize($fileSize);
+ echo "<tr><td><a href=\"$filePath/$fileName\"><img src=\"images/file.png\" border=\"0\" width=\"36\" height=\"36\"></a></td><td><a href=\"$fileName\">$fileName</a><br>$fileSize</td></tr>";
+ }
+ }
+
+ echo "</table>";
+ echo "</div>";
+ }
+
+ echo "</td></tr></table>";
+}
+
+imap_close($mbox);
+
+?>
diff --git a/send.php b/send.php
new file mode 100644
index 0000000..becdcca
--- /dev/null
+++ b/send.php
@@ -0,0 +1,163 @@
+<?php
+
+session_start();
+
+if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
+ exit;
+}
+
+require_once("core.php");
+
+if (!isset($_POST['box']) or empty($_POST['box'])) {
+ $folder = "INBOX";
+}
+else {
+ $folder = trim(strip_tags($_POST['box']));
+}
+
+$host = "{127.0.0.1:143/imap/notls/norsh}";
+
+$mbox = @imap_open("{$host}$folder", $_SESSION['logged_uid'], $_SESSION['logged_key']) or die("Connection to server failed");
+
+if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])) {
+
+ $msgno = trim(strip_tags($_POST['msg']));
+
+ $header = imap_headerinfo($mbox, $msgno);
+
+ $header_subject = $header->subject;
+ $header_fromaddress = $header->senderaddress;
+ $header_date = $header->date;
+ $header_toaddress = $header->toaddress;
+ $header_ccaddress = $header->ccaddress;
+
+ $reply_quote = wordwrap(trim(get_part($mbox, $msgno, "TEXT/PLAIN")),75,"\r\n");
+
+ $reply_quote_lines = explode("\n",$reply_quote);
+
+ if (count($reply_quote_lines) < 10) {
+ $reply_quote_rows = "10";
+ }
+ else {
+ $reply_quote_rows = count($reply_quote_lines) + 1;
+ }
+
+ $reply_from = "\"$usr_name\" <{$_SESSION['logged_uid']}>";
+
+ $reply_to = $header->reply_toaddress;
+
+ if ($reply_to != "") {
+ $reply_to = $header->reply_toaddress;
+ }
+ else {
+ $reply_to = $header->fromaddress;
+ }
+
+ if (($_POST['rep'] == 3) and strpos($header->toaddress,",")) {
+
+ $reply_to = $reply_to . ", " . $header->toaddress;
+ }
+
+ if ($_POST['rep'] == 2) {
+
+ $reply_cc ="";
+ }
+ else {
+ $reply_cc = $header->ccaddress;
+ }
+
+ $reply_subject = $header->subject;
+
+ if ($_POST['rep'] == 2) {
+
+ $reply_to = "";
+
+ $reply_subject = "Fwd: " . $reply_subject;
+ $reply_subject = str_replace("Fwd: Fwd: ","Fwd: ",$reply_subject);
+ }
+ else {
+ $reply_subject = "Re: " . $reply_subject;
+ $reply_subject = str_replace("Re: Re: ","Re: ",$reply_subject);
+ }
+
+ $reply_from = htmlentities($reply_from,ENT_QUOTES);
+ $reply_to = htmlentities($reply_to,ENT_QUOTES);
+ $reply_subject = htmlentities($reply_subject,ENT_QUOTES);
+ $reply_cc = htmlentities($reply_cc,ENT_QUOTES);
+
+ echo "<title>Kartero - $folder - $reply_subject</title>";
+
+ echo "<table border=\"0\" cellspacing=\"0\" callpadding=\"0\" width=\"800\"><tr><td valign=\"top\">";
+
+ echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\" width=\"100%\">";
+
+ echo "<form method=\"post\">";
+
+ if (($_POST['rep'] == 1) or ($_POST['rep'] == 3)) {
+
+ echo "<input type=\"hidden\" name=\"ack\" value=\"1\">";
+ }
+
+ echo "<tr><td width=\"50\"><b>From:</b></td><td rowspan=\"7\" width=\"5\"></td><td><input class=\"input\" type=\"text\" name=\"reply_from\" value=\"$reply_from\" readonly></td></tr>";
+ echo "<tr><td><b>To:</b></td><td><input class=\"input\" type=\"text\" name=\"reply_to\" value=\"$reply_to\"></td></tr>";
+ echo "<tr><td><b>Cc:</b></td><td><input class=\"input\" type=\"text\" name=\"reply_cc\" value=\"$reply_cc\"></td></tr>";
+ echo "<tr><td><b>Bcc:</b></td><td><input class=\"input\" type=\"text\" name=\"reply_bcc\"></td></tr>";
+ echo "<tr><td><b>Subject:</b></td><td><input class=\"input\" type=\"text\" name=\"reply_subj\" value=\"$reply_subject\"></td></tr>";
+
+ echo "<tr><td></td><td><textarea class=\"input\" name=\"reply_body\" rows=\"$reply_quote_rows\">";
+
+ if ($_POST['rep'] == 2) {
+
+ echo "---------------------------------------- Begin Forwarded Message ----------------------------------------\r\n";
+ }
+ else {
+ $reply_personal = $header->fromaddress;
+ echo "On $header_date, $reply_personal wrote:\r\n";
+ }
+
+ foreach ($reply_quote_lines as $reply_quote_line) {
+
+ $reply_quote_line = "> $reply_quote_line";
+ $reply_quote_line = preg_replace("/(^> >)/",">>",$reply_quote_line);
+
+ echo $reply_quote_line;
+ }
+
+ if ($_POST['rep'] == 2) {
+
+ $filePath = "attachments/" . sha1($_SERVER['SERVER_NAME']) ."/" . sha1($header->subject);
+
+ if (file_exists("$filePath")) {
+
+ $fileNames = glob("$filePath/*");
+
+ if (count($fileNames) > 0) {
+
+ foreach ($fileNames as $fileName) {
+
+ echo "\r\n\r\n" . str_replace("$filePath/","",$fileName) . " (" . HumanReadableFilesize(filesize($fileName)) . ")\r\n";
+ echo "http://" . $_SERVER['SERVER_NAME'] . "/$fileName";
+ }
+ }
+
+ }
+ }
+
+ echo "</textarea></td></tr>";
+
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+ echo "<tr><td></td><td align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\"></div><div class=\"label\">send</div></td></tr>";
+
+ echo "</table>";
+
+ echo "</form>";
+
+ echo "</td></tr>";
+ echo "</table>";
+
+ imap_close($mbox);
+}
+
+?>
tree a041f850a521b9eadf1508df7e754d9647e364bf
parent 4f125f218b4587ddfbbe65bd854cd628fed6ad43
author Engels Antonio <engels@majcms.org> 1297788591 +0800
committer Engels Antonio <engels@majcms.org> 1297788591 +0800
Add basic webmail for subscriber login
diff --git a/core.php b/core.php
new file mode 100644
index 0000000..927cc97
--- /dev/null
+++ b/core.php
@@ -0,0 +1,122 @@
+<?php
+
+if (isset($_POST['mbox_min']) and !empty($_POST['mbox_min']) and is_numeric($_POST['mbox_min'])) {
+ $mbox_min = $_POST['mbox_min'];
+}
+else {
+ $mbox_min = "0";
+}
+
+if (isset($_POST['mbox_ppg']) and !empty($_POST['mbox_ppg']) and is_numeric($_POST['mbox_ppg'])) {
+ $mbox_ppg = $_POST['mbox_ppg'];
+}
+else {
+ $mbox_ppg = "14";
+}
+
+
+$mbox_max = $mbox_min + $mbox_ppg;
+
+function time_elapsed_string($ptime) {
+ $etime = time() - $ptime;
+
+ if ($etime < 1) {
+ return '0 seconds';
+ }
+
+ $a = array( 12 * 30 * 24 * 60 * 60 => 'year',
+ 30 * 24 * 60 * 60 => 'month',
+ 7 * 24 * 60 * 60 => 'week',
+ 24 * 60 * 60 => 'day',
+ 60 * 60 => 'hour',
+ 60 => 'minute',
+ 1 => 'second'
+ );
+
+ foreach ($a as $secs => $str) {
+ $d = $etime / $secs;
+ if ($d >= 1) {
+ $r = round($d);
+ return $r . ' ' . $str . ($r > 1 ? 's' : '');
+ }
+ }
+}
+
+function HumanReadableFilesize($size) {
+
+ // Adapted from: http://www.php.net/manual/en/function.filesize.php
+
+ $mod = 1024;
+
+ $units = explode(' ','B KB MB GB TB PB');
+ for ($i = 0; $size > $mod; $i++) {
+ $size /= $mod;
+ }
+
+ return round($size, 2) . ' ' . $units[$i];
+}
+
+function get_mime_type(&$struct) {
+
+ $primary_mime_type = array("TEXT", "MULTIPART","MESSAGE", "APPLICATION", "AUDIO", "IMAGE", "VIDEO", "OTHER");
+
+ if($struct->subtype) {
+ return $primary_mime_type[(int) $struct->type] . '/' .$struct->subtype;
+ }
+
+ return "TEXT/PLAIN";
+}
+
+function get_part($stream, $msg_number, $mime_type, $structure = false, $part_number = false) {
+
+ if (!$structure) {
+ $structure = imap_fetchstructure($stream, $msg_number);
+ }
+
+ if ($structure) {
+
+ if ($mime_type == get_mime_type($structure)) {
+
+ if (!$part_number) {
+ $part_number = "1";
+ }
+
+ $text = imap_fetchbody($stream, $msg_number, $part_number);
+
+ if ($structure->encoding == 3) {
+ return imap_base64($text);
+ }
+ else if ($structure->encoding == 4) {
+ return imap_qprint($text);
+ }
+ else {
+ return $text;
+ }
+ }
+
+ if ($structure->type == 1) /* multipart */ {
+
+ while (list($index, $sub_structure) = each($structure->parts)) {
+
+ if ($part_number) {
+ $prefix = $part_number . '.';
+ }
+
+ $data = get_part($stream, $msg_number, $mime_type, $sub_structure,$prefix . ($index + 1));
+
+ if ($data) {
+ return $data;
+ }
+ } // END OF WHILE
+ } // END OF MULTIPART
+ } // END OF STRUTURE
+ return false;
+} // END OF FUNCTION
+
+function extract_emails_from($string){
+ preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $string, $matches);
+ return $matches[0];
+}
+
+
+?>
diff --git a/css.php b/css.php
index ca350d1..5d0f86b 100644
--- a/css.php
+++ b/css.php
@@ -1,7 +1,12 @@
-body,p,td {
+* {
+ font-size: 1em;
+ outline: none;
+}
+
+body {
color: #666666;
background: #ffffff;
- font-size: 11px;
+ font-size: 0.75em;
font-family: arial,helvetica,sans-serif;
}
@@ -11,31 +16,29 @@ a,a:link,a:visited,a:hover,a:active {
color: #666666;
}
-.input {
+.input,.button {
color: #666666;
background: #ffffff;
border: #999999 solid 1px;
width: 100%;
- font-size: 11px;
font-family: arial,helvetica,sans-serif;
}
-.rinput {
- color: #666666;
- background: #ffffff;
- border: #999999 solid 1px;
- width: 75px;
- font-size: 11px;
- font-family: arial,helvetica,sans-serif;
- text-align: right;
- padding: 0px 1px 0px 0px;
+.input {
+ -moz-box-shadow: inset 0 0 2px #dedede;
+ -khtml-box-shadow: inset 0 0 2px #dedede;
+ -webkit-box-shadow: inset 0 0 2px #dedede;
+ box-shadow: inset 0 0 2px #dedede;
+}
+
+.input:focus {
+ background: #ffffcc;
}
.ack {
color: #74ae0b;
background: #cde2a7;
border: #74ae0b solid 1px;
- font-size: 11px;
font-weight: bold;
font-family: arial,helvetica,sans-serif;
text-align: center;
@@ -50,7 +53,6 @@ a,a:link,a:visited,a:hover,a:active {
color: #ff6666;
background: #ffbbbb;
border: #ff6666 solid 1px;
- font-size: 11px;
font-weight: bold;
font-family: arial,helvetica,sans-serif;
text-align: center;
@@ -65,7 +67,6 @@ a,a:link,a:visited,a:hover,a:active {
color: #f3e533;
background: #fcffcd;
border: #f3e533 solid 1px;
- font-size: 11px;
font-weight: bold;
font-family: arial,helvetica,sans-serif;
text-align: center;
@@ -75,3 +76,44 @@ a,a:link,a:visited,a:hover,a:active {
filter: alpha(opacity=90);
opacity: 0.9;
}
+
+.folders {
+ border: solid 1px #ccc;
+ padding: 5px;
+ -moz-box-shadow: 0 0 2px #dedede;
+ -khtml-box-shadow: 0 0 2px #dedede;
+ -webkit-box-shadow: 0 0 2px #dedede;
+ box-shadow: 0 0 2px #dedede;
+}
+
+.main {
+ border: solid 1px #ccc;
+ padding: 2px;
+ -moz-box-shadow: 0 0 2px #dedede;
+ -khtml-box-shadow: 0 0 2px #dedede;
+ -webkit-box-shadow: 0 0 2px #dedede;
+ box-shadow: 0 0 2px #dedede;
+}
+
+.message {
+ border: 1px solid #ccc;
+ padding: 5px;
+}
+
+.spacer {
+ height: 2px;
+}
+
+.login {
+ width: 300px;
+ border: none;
+ margin-top: 10%;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.label {
+ width: 40px;
+ text-align: center;
+ font-size: 0.75em;
+}
diff --git a/folders.php b/folders.php
new file mode 100644
index 0000000..9ffce98
--- /dev/null
+++ b/folders.php
@@ -0,0 +1,112 @@
+<?php
+
+session_start();
+
+if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
+ exit;
+}
+
+$conn = '{127.0.0.1:143/imap/notls/norsh}';
+
+$mbox = imap_open($conn, $_SESSION['logged_uid'], $_SESSION['logged_key'], OP_HALFOPEN) or die("can't connect: " . imap_last_error());
+
+echo "<div class=\"folders\"><table border=\"0\" cellspacing=\"1\" callpadding=\"2\">";
+echo "<form method=\"post\">";
+echo "<input type=\"hidden\" name=\"new\" value=\"1\">";
+echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-new.png\"></td><td>Compose</td></tr>";
+echo "</form>";
+
+if (!isset($_POST['get']) and !isset($_POST['rep'])) {
+
+ $mbox_prev = $mbox_min - $mbox_ppg;
+
+ if ($mbox_prev >= 0) {
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_prev\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ //echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-next.png\"></td><td>Prev $mbox_ppg Msgs</td></tr>";
+ echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-next.png\"></td><td>Prev</td></tr>";
+ echo "</form>";
+ }
+
+ $mbox_next = $mbox_min + $mbox_ppg;
+
+ if ($mbox_next < $msgCount) {
+
+ if (($msgCount - $mbox_next) < $mbox_ppg) {
+ $mbox_ppg = $msgCount - $mbox_next;
+ }
+
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_next\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ //echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-prev.png\"></td><td>Next $mbox_ppg Msgs</td></tr>";
+ echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-prev.png\"></td><td>Next</td></tr>";
+ echo "</form>";
+ }
+}
+
+if ($_POST['box'] == "Trash") {
+
+ $trash_status = imap_status($mbox, "{$conn}Trash", SA_MESSAGES+SA_UNSEEN);
+
+ if ($trash_status->messages > 0) {
+
+ echo "<form method=\"post\">";
+ echo "<input type=\"hidden\" name=\"emt\" value=\"1\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"Trash\">";
+ echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/trashcan_purge.png\"></td><td><nobr>Empty Trash</nobr></td></tr>";
+ echo "</form>";
+ }
+}
+
+echo "</table></div>";
+
+echo "<div style=\"height: 4px;\"></div>";
+
+$folders = imap_list($mbox, $conn, "*");
+
+if (is_array($folders)) {
+
+ reset($folders);
+ sort($folders);
+
+ $folder_images = glob("images/folder*");
+
+ foreach ($folder_images as $folder_image) {
+ echo "\n\n<script>\n\tvar img_preload = new Image();\n\timg_preload.src = \"$folder_image\";\n</script>";
+ }
+
+ echo "\n\n<div class=\"folders\"><table border=\"0\" cellspacing=\"1\" callpadding=\"2\">";
+
+ foreach ($folders as $folder) {
+
+ $status = imap_status($mbox, $folder, SA_MESSAGES+SA_UNSEEN);
+
+ $status_folder = "(" . $status->unseen . "/" . $status->messages . ")";
+
+ $folder = str_replace($conn,"",$folder);
+
+ echo "<tr><form method=\"post\"><td align=\"center\"><input type=\"hidden\" name=\"box\" value=\"$folder\">";
+
+ if ((!isset($_POST['box']) and ($folder == "INBOX")) or (isset($_POST['box']) and ($_POST['box'] == $folder))) {
+ echo "<input type=\"image\" src=\"images/folder-open.png\"></td></form>";
+ echo "<td><nobr><b>$folder</b> $status_folder</nobr></td></tr>";
+ }
+ else {
+ echo "<input type=\"image\" src=\"images/folder-close.png\"></td></form>";
+ echo "<td><nobr>$folder $status_folder</nobr></td></tr>";
+ }
+
+
+ }
+
+ echo "</table></div>";
+}
+else {
+ echo "imap_getmailboxes failed: " . imap_last_error() . "\n";
+}
+
+imap_close($mbox);
+
+?>
diff --git a/images/attach.png b/images/attach.png
new file mode 100644
index 0000000..a026e3e
Binary files /dev/null and b/images/attach.png differ
diff --git a/images/file.png b/images/file.png
new file mode 100644
index 0000000..0316c31
Binary files /dev/null and b/images/file.png differ
diff --git a/images/folder-close.png b/images/folder-close.png
new file mode 100644
index 0000000..10cf31e
Binary files /dev/null and b/images/folder-close.png differ
diff --git a/images/folder-open.png b/images/folder-open.png
new file mode 100644
index 0000000..63a5206
Binary files /dev/null and b/images/folder-open.png differ
diff --git a/images/logo.png b/images/logo.png
new file mode 100644
index 0000000..9d975ee
Binary files /dev/null and b/images/logo.png differ
diff --git a/images/mail-forward.png b/images/mail-forward.png
new file mode 100644
index 0000000..bd805f3
Binary files /dev/null and b/images/mail-forward.png differ
diff --git a/images/mail-new.png b/images/mail-new.png
new file mode 100644
index 0000000..f9666ee
Binary files /dev/null and b/images/mail-new.png differ
diff --git a/images/mail-next.png b/images/mail-next.png
new file mode 100644
index 0000000..66168af
Binary files /dev/null and b/images/mail-next.png differ
diff --git a/images/mail-prev.png b/images/mail-prev.png
new file mode 100644
index 0000000..dd8d16f
Binary files /dev/null and b/images/mail-prev.png differ
diff --git a/images/mail-read.png b/images/mail-read.png
new file mode 100644
index 0000000..a14e05a
Binary files /dev/null and b/images/mail-read.png differ
diff --git a/images/mail-replied.png b/images/mail-replied.png
new file mode 100644
index 0000000..c7d5e68
Binary files /dev/null and b/images/mail-replied.png differ
diff --git a/images/mail-reply-all.png b/images/mail-reply-all.png
new file mode 100644
index 0000000..0d2c165
Binary files /dev/null and b/images/mail-reply-all.png differ
diff --git a/images/mail-reply.png b/images/mail-reply.png
new file mode 100644
index 0000000..5b1e693
Binary files /dev/null and b/images/mail-reply.png differ
diff --git a/images/mail-unread.png b/images/mail-unread.png
new file mode 100644
index 0000000..4a71da1
Binary files /dev/null and b/images/mail-unread.png differ
diff --git a/images/trashcan_empty.png b/images/trashcan_empty.png
new file mode 100644
index 0000000..cc5d1d2
Binary files /dev/null and b/images/trashcan_empty.png differ
diff --git a/images/trashcan_full.png b/images/trashcan_full.png
new file mode 100644
index 0000000..335e67e
Binary files /dev/null and b/images/trashcan_full.png differ
diff --git a/images/trashcan_purge.png b/images/trashcan_purge.png
new file mode 100644
index 0000000..cc5d1d2
Binary files /dev/null and b/images/trashcan_purge.png differ
diff --git a/inbox.php b/inbox.php
new file mode 100644
index 0000000..db9c5d8
--- /dev/null
+++ b/inbox.php
@@ -0,0 +1,207 @@
+<?php
+
+session_start();
+
+if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
+ exit;
+}
+
+if (!isset($_POST['box']) or empty($_POST['box'])) {
+ $folder = "INBOX";
+}
+else {
+ $folder = trim(strip_tags($_POST['box']));
+}
+
+$host = "{127.0.0.1:143/imap/notls/norsh}";
+
+$mbox = @imap_open("{$host}$folder", $_SESSION['logged_uid'], $_SESSION['logged_key']) or die("Connection to server failed");
+
+if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])) {
+
+ $msgno = trim(strip_tags($_POST['msg']));
+
+ if ($_POST['del'] == "1") {
+ imap_createmailbox($mbox,"{$host}Trash");
+ imap_mail_move($mbox,$msgno,"Trash");
+ imap_expunge($mbox);
+ }
+
+ if ($_POST['del'] == "0") {
+ imap_mail_move($mbox,$msgno,"Inbox");
+ imap_expunge($mbox);
+ }
+}
+
+
+if ($hdr = imap_check($mbox)) {
+ $msgCount = $hdr->Nmsgs;
+}
+else {
+ echo "failed";
+}
+
+if (!isset($_POST['show_max']) or empty($_POST['show_max']) or !is_numeric($_POST['show_max'])) {
+ $show_max = $msgCount;
+}
+else {
+ $show_max = $_POST['show_max'];
+}
+
+imap_headers($mbox);
+
+$mbox_sort = imap_sort($mbox,"SORTARRIVAL",1);
+
+$mail_images = glob("images/mail*");
+
+foreach ($mail_images as $mail_image) {
+ echo "\n\n<script>\n\tvar img_preload = new Image();\n\timg_preload.src = \"$mail_image\";\n</script>";
+}
+
+require_once("core.php");
+
+echo "<title>Kartero - $folder ($msgCount) - " . $_SESSION['logged_uid'] . "</title>";
+
+echo "\n\n<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\" width=\"800\">";
+
+echo "<tr bgcolor=\"#eeeeee\"><td align=\"center\" width=\"32\">";
+
+if ($folder == "Trash") {
+ echo "un";
+}
+
+echo "del</td><td align=\"center\" width=\"200\">";
+
+if ($folder == "Sent") {
+ echo "recipient";
+}
+else {
+ echo "sender";
+}
+
+echo "</td><td align=\"center\" width=\"300\">subject</td><td align=\"center\" width=\"64\">";
+
+if ($folder == "Sent") {
+ echo "sent";
+}
+else {
+ echo "received";
+}
+
+echo "</td><td align=\"center\" width=\"64\">size</td><td align=\"center\" width=\"32\">read</td></tr>\n";
+
+foreach ($mbox_sort as $mbox_num => $mbox_row) {
+
+ if ($mbox_num < $mbox_min) {
+ continue;
+ }
+
+ if ($mbox_num >= $mbox_max) {
+ continue;
+ }
+
+ $val = imap_fetch_overview($mbox,$mbox_row);
+ $msgno=$val[0]->msgno;
+ $seen=$val[0]->seen;
+ $recent=$val[0]->recent;
+ $answered=$val[0]->answered;
+ $size=$val[0]->size;
+
+ if ($folder == "Sent") {
+ $from=$val[0]->to;
+ }
+ else {
+ $from=$val[0]->from;
+ }
+
+ $subj=$val[0]->subject;
+ $date=$val[0]->date;
+
+ $subj = imap_utf8($subj);
+ $subj = utf8_decode($subj);
+
+ $from = imap_utf8($from);
+ $from = utf8_decode($from);
+
+ $from = htmlentities($from,ENT_QUOTES);
+ $from = "<b>" . $from;
+ $from = str_replace(""","",$from);
+ $from = str_replace(">","",$from);
+ $from = str_replace(" <","</b><br>",$from);
+
+ $date = strtotime($date);
+ $date = time_elapsed_string($date);
+
+ $size = HumanReadableFilesize($size);
+
+ $from = ereg_replace("\"","",$from);
+
+ if ($bgColor == "#ffffff") {
+ $bgColor = "#fdfdfd";
+ }
+ else {
+ $bgColor = "#ffffff";
+ }
+
+ if (strlen($subj) > 75) {
+ $subj = substr($subj,0,74) . "...";
+ }
+
+ $subj = htmlentities($subj,ENT_QUOTES);
+
+ if ($seen == "0") {
+ $status_img = "mail-unread.png";
+ }
+
+ if ($seen == "1") {
+ $status_img = "mail-read.png";
+ }
+
+ if ($recent == "1") {
+ $status_img = "mail-new.png";
+ }
+
+ if ($answered == "1") {
+ $status_img = "mail-replied.png";
+ }
+
+ echo "<tr bgcolor=\"$bgColor\">";
+
+ echo "<form method=\"post\"><td>";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+
+ if ($folder == "Trash") {
+ echo "<input type=\"hidden\" name=\"del\" value=\"0\">";
+ echo "<input type=\"image\" src=\"images/trashcan_full.png\">";
+ }
+ else {
+ echo "<input type=\"hidden\" name=\"del\" value=\"1\">";
+ echo "<input type=\"image\" src=\"images/trashcan_empty.png\">";
+ }
+
+ echo "</td></form>";
+
+ echo "<td>$from</td>";
+
+ echo "<td>$subj</td>";
+
+ echo "<td align=\"center\"><nobr>$date ago</nobr></td>";
+ echo "<td align=\"right\"><nobr>$size</nobr></td>";
+
+ echo "<form method=\"post\"><td align=\"center\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+ echo "<input type=\"hidden\" name=\"get\" value=\"1\">";
+ echo "<input type=\"image\" src=\"images/$status_img\"></td></form>";
+
+ echo "</tr>\n";
+}
+
+echo "</table>";
+
+imap_close($mbox);
+
+?>
diff --git a/index.php b/index.php
index 0cb3492..fd5c90f 100644
--- a/index.php
+++ b/index.php
@@ -4,10 +4,10 @@
$db_host = "localhost";
$db_name = "kartero";
-$db_user = "root";
-$db_pass = "password";
+$db_user = "kartero";
+$db_pass = "fr1ng3!";
-$mail_root = "/var/www/html/mailroot";
+$mail_root = "/var/spool/kartero";
/* feel free to hack the succeeding code to suit your needs (basic php and mysql skills required) */
@@ -133,13 +133,22 @@ if (!is_int($pw_put)) {
}
$pw_put = strip_tags($pw_put);
+
+$pw_mbox = $pw_put;
+
$pw_put = crypt($pw_put,$pw_get);
if ($pw_put == $pw_get) {
$_SESSION['logged_uid'] = $id_put;
$_SESSION['logged_lvl'] = $lvl_put;
+
+ if ($_SESSION['logged_lvl'] == "subscriber") {
+ $_SESSION['logged_key'] = $pw_mbox;
+ }
}
+unset($pw_mbox);
+
if (isset($_GET['do']) and ($_GET['do'] == "logout")) {
$_SESSION = array();
session_destroy();
@@ -150,20 +159,33 @@ if (isset($_GET['do']) and ($_GET['do'] == "logout")) {
/* logo here? */
if (!isset($_SESSION['logged_uid']) and (($pw_put != $pw_get) or !isset($_POST['id']) or !isset($_POST['pw']) or empty($_POST['id']) or empty($_POST['pw']))) {
+
+ echo "<title>Kartero</title>";
+
+ echo "<div class=\"login\"><center>";
+
+ echo "<img src=\"images/logo.png\" border=\"0\" width=\"100\" height=\"100\">";
+ echo "<br>kartero v1.0 at {$_SERVER['SERVER_NAME']}<br><br>";
+
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
echo "<form method=\"post\">";
- echo "<tr bgcolor=\"#ffffff\"><td width=\"150\"><select class=\"input\" name=\"lvl\"><option value=\"subscriber\">subscriber</option><option value=\"postmaster\">postmaster</option><option value=\"administrator\">administrator</option></select></td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td width=\"150\"><input class=\"input\" type=\"text\" name=\"id\" autocomplete=\"off\" maxlength=\"128\"></td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td width=\"150\"><input class=\"input\" type=\"password\" name=\"pw\" autocomplete=\"off\" maxlength=\"64\"></td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td width=\"150\"><input class=\"input\" type=\"submit\" value=\"login\"></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td><select class=\"input\" name=\"lvl\"><option value=\"subscriber\">subscriber</option><option value=\"postmaster\">postmaster</option><option value=\"administrator\">administrator</option></select></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"text\" name=\"id\" autocomplete=\"off\" maxlength=\"128\"></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"password\" name=\"pw\" autocomplete=\"off\" maxlength=\"64\"></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"button\" type=\"submit\" value=\"login\"></td></tr>";
echo "</form>";
echo "</table>";
+
+ echo "</center></div>";
+
exit;
}
if (isset($_SESSION['logged_uid'])) {
- echo "<p><nobr>You are currently logged in to your {$_SESSION['logged_uid']} {$_SESSION['logged_lvl']} account. Click <a href=\"?do=logout\">here</a> to logout.</nobr></p>";
+ //echo "<center>";
+
+ echo "<nobr>You are currently logged in to your {$_SESSION['logged_uid']} {$_SESSION['logged_lvl']} account. Click <a href=\"?do=logout\">here</a> to logout.</nobr><br><br>";
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
echo "<tr><td colspan=\"3\" valign=\"top\">";
@@ -739,23 +761,121 @@ if (isset($_SESSION['logged_uid'])) {
if ($_SESSION['logged_lvl'] == "subscriber") {
- echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
+
+ if (isset($_POST['reply_from']) and isset($_POST['reply_to']) and isset($_POST['reply_subj']) and isset($_POST['reply_body'])) {
+
+ $reply_from = trim($_POST['reply_from']);
+ $reply_to = trim($_POST['reply_to']);
+ $reply_subj = trim($_POST['reply_subj']);
+ $reply_body = trim($_POST['reply_body']);
+
+
+ $reply_headers = "From: $reply_from\r\nX-Mailer: Kartero/1.0 (PHP/" . phpversion() . ")";
+
+ if (isset($_POST['reply_cc']) and !empty($_POST['reply_cc'])) {
+
+ $reply_cc = trim($_POST['reply_cc']);
+
+ $reply_headers = "$reply_headers\r\nCc: $reply_cc";
+ }
+
+ if (isset($_POST['reply_bcc']) and !empty($_POST['reply_bcc'])) {
+
+ $reply_bcc = trim($_POST['reply_bcc']);
+
+ $reply_headers = "$reply_headers\r\nBcc: $reply_bcc";
+ }
+
+ $reply_body = preg_replace("#(?<!\r)\n#si", "\r\n", $reply_body);
+ $reply_headers = preg_replace('#(?<!\r)\n#si', "\r\n", $reply_headers);
+
+ mail($reply_to, $reply_subj, $reply_body, $reply_headers);
+
+ $host = "{127.0.0.1:143/imap/notls/norsh}";
+
+ $mbox = @imap_open($host, $_SESSION['logged_uid'], $_SESSION['logged_key']) or die("Connection to server failed");
+
+ imap_createmailbox($mbox,"{$host}Sent");
+
+ $reply_date = date ("d-M-Y H:i:s O");
+
+ imap_append($mbox,"{$host}Sent","To: $reply_to\r\nSubject: $reply_subj\r\nDate: $reply_date\r\n$reply_headers\r\n\r\n$reply_body\r\n");
+
+ if ($_POST['ack'] == 1) {
+
+ imap_reopen($mbox, "{$host}{$_POST['box']}");
+ imap_setflag_full($mbox, $_POST['msg'], '\\Answered');
+ }
+
+ imap_close($mbox);
+ }
+
+ if (isset($_POST['not']) and !empty($_POST['not']) and is_numeric($_POST['not'])) {
+
+ $host = "{127.0.0.1:143/imap/notls/norsh}";
+
+ $mbox = @imap_open("{$host}{$_POST['box']}", $_SESSION['logged_uid'], $_SESSION['logged_key']) or die("Connection to server failed");
+
+ imap_clearflag_full($mbox, $_POST['msg'], '\\Seen');
+
+ imap_close($mbox, CL_EXPUNGE);
+ }
+
+ if (isset($_POST['emt']) and !empty($_POST['emt']) and is_numeric($_POST['emt'])) {
+
+ $host = "{127.0.0.1:143/imap/notls/norsh}";
+
+ $mbox = @imap_open("{$host}{$_POST['box']}", $_SESSION['logged_uid'], $_SESSION['logged_key']) or die("Connection to server failed");
+
+ imap_delete($mbox,'1:*');
+
+ imap_close($mbox, CL_EXPUNGE);
+ }
+
+ echo "<tr><td valign=\"top\" width=\"700\"><div class=\"main\">";
+
+ if (isset($_POST['get']) and !empty($_POST['get'])) {
+ include("read.php");
+ }
+ elseif (isset($_POST['rep']) and !empty($_POST['rep'])) {
+ include("send.php");
+ }
+ elseif (isset($_POST['new']) and !empty($_POST['new'])) {
+ include("post.php");
+ }
+ else {
+ include("inbox.php");
+ }
+
+ echo "</div></td>";
+
+ echo "<td width=\"10\"></td>";
+
+ echo "<td valign=\"top\" width=\"100\">";
+ include("folders.php");
+ echo "</td>";
+/*
+ echo "<td valign=\"top\" width=\"100\">";
+ echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\">";
echo "<form method=\"post\">";
- echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"><img src=\"images/user.png\" border=\"0\" width=\"16\" height=\"16\"></td><td><input class=\"input\" type=\"text\" name=\"usr_name\" value=\"$usr_name\" autocomplete=\"off\" maxlength=\"128\"></td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"><img src=\"images/pass.png\" border=\"0\" width=\"16\" height=\"16\"></td><td><input class=\"input\" type=\"password\" name=\"usr_pw1\" autocomplete=\"off\" maxlength=\"64\"></td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"><img src=\"images/pass.png\" border=\"0\" width=\"16\" height=\"16\"></td><td><input class=\"input\" type=\"password\" name=\"usr_pw2\" autocomplete=\"off\" maxlength=\"64\"></td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"><img src=\"images/pass.png\" border=\"0\" width=\"16\" height=\"16\"></td><td><input class=\"input\" type=\"password\" name=\"usr_pw3\" autocomplete=\"off\" maxlength=\"64\"></td></tr>";
- echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"></td><td><input class=\"input\" type=\"submit\" value=\"update\"></td></tr>";
- echo "</form>";
- echo "</table>";
+ echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"><img src=\"images/preferences-desktop-personal.png\" border=\"0\" width=\"22\" height=\"22\"></td><td><input class=\"input\" type=\"text\" name=\"usr_name\" value=\"$usr_name\" autocomplete=\"off\" maxlength=\"128\"></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"><img src=\"images/flag-red.png\" border=\"0\" width=\"22\" height=\"22\"></td><td><input class=\"input\" type=\"password\" name=\"usr_pw1\" autocomplete=\"off\" maxlength=\"64\"></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"><img src=\"images/flag-green.png\" border=\"0\" width=\"22\" height=\"22\"></td><td><input class=\"input\" type=\"password\" name=\"usr_pw2\" autocomplete=\"off\" maxlength=\"64\"></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"><img src=\"images/flag-green.png\" border=\"0\" width=\"22\" height=\"22\"></td><td><input class=\"input\" type=\"password\" name=\"usr_pw3\" autocomplete=\"off\" maxlength=\"64\"></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td align=\"center\" valign=\"middle\"></td><td><input class=\"button\" type=\"submit\" value=\"update\"></td></tr>";
+ echo "</form></table>";
+ echo "</td>";
+*/
+ echo "</tr></table>";
}
if ($_SESSION['logged_lvl'] == "postmaster") {
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
- echo "<tr bgcolor=\"#ffffff\"><td colspan=\"4\" align=\"center\"><b>status</b></td><td align=\"center\"><b>username</b></td><td align=\"center\"><b>complete name</b></td><td align=\"center\"><b>password</b></td><td align=\"center\"><b>host</b></td><td align=\"center\" colspan=\"2\"><b>action</b></td></tr>";
+ echo "<tr bgcolor=\"#eeeeee\"><td colspan=\"4\" align=\"center\">status</td><td align=\"center\">username</td><td align=\"center\">complete name</td><td align=\"center\">password</td><td align=\"center\">host</td><td align=\"center\" colspan=\"2\">action</td></tr>";
echo "<form method=\"post\">";
- echo "<tr bgcolor=\"#ffffff\"><td align=\"center\">new</td><td align=\"center\">cur</td><td align=\"center\">aka</td><td align=\"center\">rcv</td><td><input class=\"input\" type=\"text\" name=\"pm_id\" autocomplete=\"off\" maxlength=\"255\"></td><td><input class=\"input\" type=\"text\" name=\"pm_name\" autocomplete=\"off\" maxlength=\"128\"></td><td><input class=\"input\" type=\"text\" name=\"pm_pw\" autocomplete=\"off\" maxlength=\"64\"></td><td><input class=\"input\" type=\"text\" name=\"pm_host\" autocomplete=\"off\" maxlength=\"255\"></td><td colspan=\"2\"><input class=\"input\" type=\"submit\" value=\"add\"></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td align=\"center\">new</td><td align=\"center\">cur</td><td align=\"center\">aka</td><td align=\"center\">rcv</td><td><input class=\"input\" type=\"text\" name=\"pm_id\" autocomplete=\"off\" maxlength=\"255\"></td><td><input class=\"input\" type=\"text\" name=\"pm_name\" autocomplete=\"off\" maxlength=\"128\"></td><td><input class=\"input\" type=\"text\" name=\"pm_pw\" autocomplete=\"off\" maxlength=\"64\"></td><td><input class=\"input\" type=\"text\" name=\"pm_host\" autocomplete=\"off\" maxlength=\"255\"></td><td colspan=\"2\"><input class=\"button\" type=\"submit\" value=\"add\"></td></tr>";
echo "</form>";
$pm_get = mysql_query("select * from users where domain='{$_SESSION['logged_uid']}' order by id");
@@ -781,7 +901,7 @@ if (isset($_SESSION['logged_uid'])) {
$pm_aka = mysql_query("select * from aliases where alias='{$pm_row[0]}'");
$pm_aka = mysql_num_rows($pm_aka);
- echo "<tr bgcolor=\"$pm_bg\"><td align=\"right\">$msg_new</td><td align=\"right\">$msg_cur</td><td align=\"right\">$pm_aka</td><form method=\"post\"><input type=\"hidden\" name=\"pm_set\" value=\"{$pm_row[0]}\"><input type=\"hidden\" name=\"pm_do\" value=\"$pm_do\"><td align=\"center\" valign=\"middle\" width=\"10\"><input type=\"image\" src=\"images/{$pm_do}.png\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"pm_mod\" value=\"{$pm_row[0]}\"><td><b>{$pm_row[0]}</b></td><td><input class=\"input\" type=\"text\" name=\"pm_name\" maxlength=\"128\" autocomplete=\"off\" value=\"{$pm_row[3]}\"></td><td><input class=\"input\" type=\"text\" name=\"pm_pass\" maxlength=\"64\" autocomplete=\"off\"></td><td><input class=\"input\" type=\"text\" name=\"pm_host\" maxlength=\"255\" autocomplete=\"off\" value=\"{$pm_row[6]}\"></td><td><input class=\"input\" type=\"submit\" value=\"mod\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"pm_del\" value=\"{$pm_row[0]}\"><td><input class=\"input\" type=\"submit\" value=\"del\" onclick=\"if (confirm('Do you really want to delete {$pm_row[0]} plus all messages and aliases associated with this account?')) {return true;} else {return false;}\"></td></form></tr>";
+ echo "<tr bgcolor=\"$pm_bg\"><td align=\"right\">$msg_new</td><td align=\"right\">$msg_cur</td><td align=\"right\">$pm_aka</td><form method=\"post\"><input type=\"hidden\" name=\"pm_set\" value=\"{$pm_row[0]}\"><input type=\"hidden\" name=\"pm_do\" value=\"$pm_do\"><td align=\"center\" valign=\"middle\" width=\"10\"><input type=\"image\" src=\"images/{$pm_do}.png\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"pm_mod\" value=\"{$pm_row[0]}\"><td>{$pm_row[0]}</td><td><input class=\"input\" type=\"text\" name=\"pm_name\" maxlength=\"128\" autocomplete=\"off\" value=\"{$pm_row[3]}\"></td><td><input class=\"input\" type=\"text\" name=\"pm_pass\" maxlength=\"64\" autocomplete=\"off\"></td><td><input class=\"input\" type=\"text\" name=\"pm_host\" maxlength=\"255\" autocomplete=\"off\" value=\"{$pm_row[6]}\"></td><td><input class=\"button\" type=\"submit\" value=\"mod\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"pm_del\" value=\"{$pm_row[0]}\"><td><input class=\"button\" type=\"submit\" value=\"del\" onclick=\"if (confirm('Do you really want to delete {$pm_row[0]} plus all messages and aliases associated with this account?')) {return true;} else {return false;}\"></td></form></tr>";
}
echo "</table>";
@@ -790,8 +910,8 @@ if (isset($_SESSION['logged_uid'])) {
if ($_SESSION['logged_lvl'] == "administrator") {
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
- echo "<tr bgcolor=\"#ffffff\"><td colspan=\"2\" align=\"center\"><b>status</b></td><td align=\"center\"><nobr><b>domain name</b></nobr></td><td align=\"center\"><nobr><b>account limit</b></nobr></td><td align=\"center\"><nobr><b>postmaster password</b></nobr></td><td align=\"center\" colspan=\"2\"><b>action</b></td></tr>";
- echo "<form method=\"post\"><tr bgcolor=\"#ffffff\"><td align=\"center\">usr</td><td align=\"center\">rcv</td><td align=\"center\"><input class=\"input\" type=\"text\" name=\"dom_name\" maxlength=\"128\" autocomplete=\"off\"></td><td align=\"center\"><input class=\"rinput\" type=\"text\" name=\"dom_max\" maxlength=\"6\" autocomplete=\"off\" value=\"0\"></td><td align=\"center\"><input class=\"input\" type=\"text\" name=\"dom_pass\" maxlength=\"64\" autocomplete=\"off\"></td><td align=\"center\" colspan=\"2\"><input class=\"input\" type=\"submit\" value=\"add\" autocomplete=\"off\"></td></tr></form>";
+ echo "<tr bgcolor=\"#eeeeee\"><td colspan=\"2\" align=\"center\">status</td><td align=\"center\"><nobr>domain name</nobr></td><td align=\"center\"><nobr>account limit</nobr></td><td align=\"center\"><nobr>postmaster password</nobr></td><td align=\"center\" colspan=\"2\">action</td></tr>";
+ echo "<form method=\"post\"><tr bgcolor=\"#ffffff\"><td align=\"center\">usr</td><td align=\"center\">rcv</td><td align=\"center\"><input class=\"input\" type=\"text\" name=\"dom_name\" maxlength=\"128\" autocomplete=\"off\"></td><td align=\"center\"><input class=\"input\" style=\"text-align: right;\" type=\"text\" name=\"dom_max\" maxlength=\"6\" autocomplete=\"off\" value=\"0\"></td><td align=\"center\"><input class=\"input\" type=\"text\" name=\"dom_pass\" maxlength=\"64\" autocomplete=\"off\"></td><td align=\"center\" colspan=\"2\"><input class=\"button\" type=\"submit\" value=\"add\"></td></tr></form>";
$dom_get = mysql_query("select * from domains order by id");
@@ -810,7 +930,7 @@ if (isset($_SESSION['logged_uid'])) {
$dom_bg = "#eeeeee";
}
- echo "<tr bgcolor=\"$dom_bg\"><td align=\"right\">$dom_usr</td><form method=\"post\"><input type=\"hidden\" name=\"dom_set\" value=\"{$dom_row[0]}\"><input type=\"hidden\" name=\"dom_do\" value=\"$dom_do\"><td align=\"center\" valign=\"middle\" width=\"10\"><input type=\"image\" src=\"images/{$dom_do}.png\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"dom_mod\" value=\"{$dom_row[0]}\"><td><b>{$dom_row[0]}</b></td><td><input class=\"rinput\" type=\"text\" name=\"dom_max\" maxlength=\"6\" autocomplete=\"off\" value=\"{$dom_row[2]}\"></td><td><input class=\"input\" type=\"text\" name=\"dom_pass\" maxlength=\"64\" autocomplete=\"off\"></td><td><input class=\"input\" type=\"submit\" value=\"mod\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"dom_del\" value=\"{$dom_row[0]}\"><td><input class=\"input\" type=\"submit\" value=\"del\" onclick=\"if (confirm('Do you really want to delete {$dom_row[0]} plus all accounts and messages associated with this domain?')) {return true;} else {return false;}\"></td></form></tr>";
+ echo "<tr bgcolor=\"$dom_bg\"><td align=\"right\">$dom_usr</td><form method=\"post\"><input type=\"hidden\" name=\"dom_set\" value=\"{$dom_row[0]}\"><input type=\"hidden\" name=\"dom_do\" value=\"$dom_do\"><td align=\"center\" valign=\"middle\" width=\"10\"><input type=\"image\" src=\"images/{$dom_do}.png\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"dom_mod\" value=\"{$dom_row[0]}\"><td>{$dom_row[0]}</td><td><input class=\"input\" style=\"text-align: right;\" type=\"text\" name=\"dom_max\" maxlength=\"6\" autocomplete=\"off\" value=\"{$dom_row[2]}\"></td><td><input class=\"input\" type=\"text\" name=\"dom_pass\" maxlength=\"64\" autocomplete=\"off\"></td><td><input class=\"button\" type=\"submit\" value=\"mod\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"dom_del\" value=\"{$dom_row[0]}\"><td><input class=\"button\" type=\"submit\" value=\"del\" onclick=\"if (confirm('Do you really want to delete {$dom_row[0]} plus all accounts and messages associated with this domain?')) {return true;} else {return false;}\"></td></form></tr>";
}
echo "</table>";
@@ -823,9 +943,9 @@ if (isset($_SESSION['logged_uid'])) {
echo "<td width=\"10\"></td><td valign=\"top\">";
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#cccccc\">";
- echo "<tr bgcolor=\"#ffffff\"><td align=\"center\"><b>alias</b></td><td align=\"center\"><b>recipient</b></td><td align=\"center\" colspan=\"3\"><b>action</b></td></tr>";
+ echo "<tr bgcolor=\"#eeeeee\"><td align=\"center\">alias</td><td align=\"center\">recipient</td><td align=\"center\" colspan=\"3\">action</td></tr>";
echo "<form method=\"post\">";
- echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"text\" name=\"alias_add\" autocomplete=\"off\" maxlength=\"255\"></td><td><input class=\"input\" type=\"text\" name=\"alias_to\" autocomplete=\"off\" maxlength=\"128\"></td><td colspan=\"3\"><input class=\"input\" type=\"submit\" value=\"add\"></td></tr>";
+ echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"text\" name=\"alias_add\" autocomplete=\"off\" maxlength=\"255\"></td><td><input class=\"input\" type=\"text\" name=\"alias_to\" autocomplete=\"off\" maxlength=\"128\"></td><td colspan=\"3\"><input class=\"button\" type=\"submit\" value=\"add\"></td></tr>";
echo "</form>";
$get_aliases = mysql_query("select * from aliases where domain='{$_SESSION['logged_uid']}' order by id");
@@ -842,7 +962,7 @@ if (isset($_SESSION['logged_uid'])) {
$alias_bg = "#eeeeee";
}
- echo "<tr bgcolor=\"$alias_bg\"><form method=\"post\"><input type=\"hidden\" name=\"alias_mod\" value=\"{$aliases_row[0]}\"><td><b>{$aliases_row[0]}</b></td><td><input class=\"input\" type=\"text\" name=\"alias_to\" maxlength=\"255\" autocomplete=\"off\" value=\"{$aliases_row[1]}\"></td><td><input class=\"input\" type=\"submit\" value=\"mod\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"alias_set\" value=\"{$aliases_row[0]}\"><input type=\"hidden\" name=\"alias_do\" value=\"$alias_do\"><td align=\"center\" valign=\"middle\" width=\"10\"><input type=\"image\" src=\"images/{$alias_do}.png\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"alias_del\" value=\"{$aliases_row[0]}\"><td><input class=\"input\" type=\"submit\" value=\"del\" onclick=\"if (confirm('Do you really want to delete the {$aliases_row[0]} alias of {$aliases_row[1]}?')) {return true;} else {return false;}\"></td></form></tr>";
+ echo "<tr bgcolor=\"$alias_bg\"><form method=\"post\"><input type=\"hidden\" name=\"alias_mod\" value=\"{$aliases_row[0]}\"><td>{$aliases_row[0]}</td><td><input class=\"input\" type=\"text\" name=\"alias_to\" maxlength=\"255\" autocomplete=\"off\" value=\"{$aliases_row[1]}\"></td><td><input class=\"button\" type=\"submit\" value=\"mod\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"alias_set\" value=\"{$aliases_row[0]}\"><input type=\"hidden\" name=\"alias_do\" value=\"$alias_do\"><td align=\"center\" valign=\"middle\" width=\"10\"><input type=\"image\" src=\"images/{$alias_do}.png\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"alias_del\" value=\"{$aliases_row[0]}\"><td><input class=\"button\" type=\"submit\" value=\"del\" onclick=\"if (confirm('Do you really want to delete the {$aliases_row[0]} alias of {$aliases_row[1]}?')) {return true;} else {return false;}\"></td></form></tr>";
}
echo "</table>";
diff --git a/post.php b/post.php
new file mode 100644
index 0000000..e600cf3
--- /dev/null
+++ b/post.php
@@ -0,0 +1,45 @@
+<?php
+
+session_start();
+
+if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
+ exit;
+}
+
+require_once("core.php");
+
+if (isset($_POST['new']) and !empty($_POST['new']) and is_numeric($_POST['new'])) {
+
+ $reply_from = "\"$usr_name\" <{$_SESSION['logged_uid']}>";
+ $reply_from = htmlentities($reply_from,ENT_QUOTES);
+
+ echo "<title>Kartero - Compose - {$_SESSION['logged_uid']}</title>";
+
+ echo "<table border=\"0\" cellspacing=\"0\" callpadding=\"0\" width=\"800\"><tr><td valign=\"top\">";
+
+ echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\" width=\"100%\">";
+
+ echo "<form method=\"post\">";
+
+ echo "<tr><td width=\"50\"><b>From:</b></td><td rowspan=\"7\" width=\"5\"></td><td><input class=\"input\" type=\"text\" name=\"reply_from\" value=\"$reply_from\" readonly></td></tr>";
+ echo "<tr><td><b>To:</b></td><td><input class=\"input\" type=\"text\" name=\"reply_to\"></td></tr>";
+ echo "<tr><td><b>Cc:</b></td><td><input class=\"input\" type=\"text\" name=\"reply_cc\"></td></tr>";
+ echo "<tr><td><b>Bcc:</b></td><td><input class=\"input\" type=\"text\" name=\"reply_bcc\"></td></tr>";
+ echo "<tr><td><b>Subject:</b></td><td><input class=\"input\" type=\"text\" name=\"reply_subj\"></td></tr>";
+
+ echo "<tr><td></td><td><textarea class=\"input\" name=\"reply_body\" rows=\"10\">";
+
+ echo "</textarea></td></tr>";
+
+ echo "<tr><td></td><td align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\"></div><div class=\"label\">send</div></td></tr>";
+
+ echo "</table>";
+
+ echo "</form>";
+
+ echo "</td></tr>";
+ echo "</table>";
+
+}
+
+?>
diff --git a/read.php b/read.php
new file mode 100644
index 0000000..9550ecf
--- /dev/null
+++ b/read.php
@@ -0,0 +1,313 @@
+<?php
+
+session_start();
+
+if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
+ exit;
+}
+
+require_once("core.php");
+
+if (!isset($_POST['box']) or empty($_POST['box'])) {
+ $folder = "INBOX";
+}
+else {
+ $folder = trim(strip_tags($_POST['box']));
+}
+
+$host = "{127.0.0.1:143/imap/notls/norsh}";
+
+$mbox = @imap_open("{$host}$folder", $_SESSION['logged_uid'], $_SESSION['logged_key']) or die("Connection to server failed");
+
+if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])) {
+
+ $msgno = trim(strip_tags($_POST['msg']));
+
+ $header = imap_headerinfo($mbox, $msgno);
+
+ $header_subject = htmlentities($header->subject,ENT_QUOTES);
+ $header_fromaddress = htmlentities($header->fromaddress,ENT_QUOTES);
+ $header_date = htmlentities($header->date,ENT_QUOTES);
+ $header_date_age = time_elapsed_string(strtotime($header_date));
+ $header_toaddress = htmlentities($header->toaddress,ENT_QUOTES);
+ $header_ccaddress = htmlentities($header->ccaddress,ENT_QUOTES);
+
+ $header_fetch = imap_fetchheader($mbox,$msgno);
+
+ $header_raw_lines = explode("\r\n",$header_fetch);
+
+ foreach ($header_raw_lines as $header_raw_line) {
+
+ if (strstr($header_raw_line,"X-Mailer:")) {
+
+ $header_mailer = $header_raw_line;
+ }
+ }
+
+ $mbox_sort = imap_sort($mbox,"SORTARRIVAL",1);
+
+ foreach ($mbox_sort as $mbox_row => $mbox_num) {
+
+ if ($msgno == $mbox_num) {
+
+ $mbox_row_prev = $mbox_row - 1;
+ $mbox_row_next = $mbox_row + 1;
+ }
+ }
+
+ $msgno_next = $mbox_sort[$mbox_row_prev];
+ $msgno_prev = $mbox_sort[$mbox_row_next];
+
+ echo "<title>Kartero - $folder - $header_subject</title>";
+
+ echo "<table border=\"0\" cellspacing=\"0\" callpadding=\"0\" width=\"800\"><tr><td valign=\"top\">";
+
+ echo "<div class=\"message\">";
+
+ echo "<b>Subject: $header_subject</b>";
+ echo "<br><br>From: $header_fromaddress";
+ echo "<br>To: $header_toaddress";
+
+ if ($header_ccaddress != "") {
+ echo "<br>Cc: $header_ccaddress";
+ }
+
+ echo "<br>Date: $header_date ($header_date_age ago)";
+
+ if ($header_mailer != "") {
+ echo "<br>$header_mailer";
+ }
+
+ echo "</div>";
+
+
+ echo "<div class=\"spacer\"></div>";
+
+
+ echo "<div class=\"message\" style=\"padding: 2px;\">";
+
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadidng=\"0\" width=\"100%\"><tr>";
+
+ echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+
+ if ($folder == "Trash") {
+ echo "<input type=\"hidden\" name=\"del\" value=\"0\">";
+ echo "<input type=\"image\" src=\"images/trashcan_full.png\">";
+ }
+ else {
+ echo "<input type=\"hidden\" name=\"del\" value=\"1\">";
+ echo "<input type=\"image\" src=\"images/trashcan_empty.png\">";
+ }
+
+ echo "</td></form>";
+
+ echo "<td></td>";
+
+ echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+ echo "<input type=\"hidden\" name=\"not\" value=\"1\">";
+ echo "<input type=\"image\" src=\"images/mail-unread.png\">";
+ echo "</td></form>";
+
+ echo "<td width=\"5\"></td>";
+
+ echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+ echo "<input type=\"hidden\" name=\"rep\" value=\"2\">";
+ echo "<input type=\"image\" src=\"images/mail-forward.png\">";
+ echo "</td></form>";
+
+ echo "<td width=\"5\"></td>";
+
+ if (strpos($header->toaddress,",")) {
+
+ echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+ echo "<input type=\"hidden\" name=\"rep\" value=\"3\">";
+ echo "<input type=\"image\" src=\"images/mail-reply-all.png\">";
+ echo "</td></form>";
+
+ echo "<td width=\"5\"></td>";
+ }
+
+ echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+ echo "<input type=\"hidden\" name=\"rep\" value=\"1\">";
+ echo "<input type=\"image\" src=\"images/mail-reply.png\">";
+ echo "</td></form>";
+
+ echo "<td width=\"5\"></td>";
+
+ if ($msgno_next != "") {
+ echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno_next\">";
+ echo "<input type=\"hidden\" name=\"get\" value=\"1\">";
+ echo "<input type=\"image\" src=\"images/mail-next.png\">";
+ echo "</td></form>";
+
+ echo "<td width=\"5\"></td>";
+ }
+
+ if ($msgno_prev != "") {
+ echo "<form method=\"post\"><td class=\"label\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno_prev\">";
+ echo "<input type=\"hidden\" name=\"get\" value=\"1\">";
+ echo "<input type=\"image\" src=\"images/mail-prev.png\">";
+ echo "</td></form>";
+ }
+
+ echo "</tr><tr>";
+
+ echo "<td class=\"label\">delete</td>";
+ echo "<td></td>";
+ echo "<td class=\"label\">unread</td>";
+ echo "<td width=\"5\"></td>";
+ echo "<td class=\"label\">forward</td>";
+ echo "<td width=\"5\"></td>";
+
+ if (strpos($header->toaddress,",")) {
+ echo "<td class=\"label\"><nobr>reply all</nobr></td>";
+ echo "<td width=\"5\"></td>";
+ }
+
+ echo "<td class=\"label\">reply</td>";
+ echo "<td width=\"5\"></td>";
+
+ if ($msgno_next != "") {
+ echo "<td class=\"label\"><nobr>prev msg</nobr></td>";
+ echo "<td width=\"5\"></td>";
+ }
+
+ if ($msgno_prev != "") {
+ echo "<td class=\"label\"><nobr>next msg</nobr></td>";
+ }
+
+ echo "</tr></table>";
+
+ echo "</div>";
+
+
+ echo "<div class=\"spacer\"></div>";
+
+
+ echo "<div class=\"message\">";
+
+ $dataTxt = get_part($mbox, $msgno, "TEXT/PLAIN");
+ $dataHtml = get_part($mbox, $msgno, "TEXT/HTML");
+
+ if ($dataHtml != "") {
+ $msgBody = $dataHtml;
+ } else {
+ $msgBody = $dataTxt;
+ $msgBody = imap_utf8($msgBody);
+ $msgBody = utf8_decode($msgBody);
+ $msgBody = ereg_replace("\n","<br>",$msgBody);
+ $msgBody = preg_replace("/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i","$1http://$2",$msgBody);
+ $msgBody = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i","<a target=\"_blank\" href=\"$1\">$1</a>",$msgBody);
+ $msgBody = preg_replace("/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?))/i","<a href=\"mailto:$1\">$1</a>",$msgBody);
+ }
+
+ echo $msgBody;
+
+ $struct = imap_fetchstructure($mbox, $msgno);
+
+ $contentParts = count($struct->parts);
+
+ if ($contentParts >= 2) {
+
+ for ($i=2;$i<=$contentParts;$i++) {
+ $att[$i-2] = imap_bodystruct($mbox,$msgno,$i);
+ }
+
+ for ($k=0;$k<sizeof($att);$k++) {
+
+ if ($att[$k]->parameters[0]->value == "us-ascii" || $att[$k]->parameters[0]->value == "US-ASCII") {
+
+ if ($att[$k]->parameters[1]->value != "") {
+ $attachDisplay[$k] = $att[$k]->parameters[1]->value;
+ }
+
+ }
+ elseif ($att[$k]->parameters[0]->value != "iso-8859-1" && $att[$k]->parameters[0]->value != "ISO-8859-1") {
+ $attachDisplay[$k] = $att[$k]->parameters[0]->value;
+ }
+ }
+ }
+
+ echo "</div>";
+
+ foreach ($attachDisplay as $attachD => $attachE) {
+
+ if (strtolower($attachE) == "utf-8") {
+ unset($attachDisplay[$attachD]);
+ }
+
+ if (strtolower($attachE) == "windows-1252") {
+ unset($attachDisplay[$attachD]);
+ }
+
+ if (strtolower($attachE) == "iso-8859-15") {
+ unset($attachDisplay[$attachD]);
+ }
+ }
+
+ sort($attachDisplay);
+ reset($attachDisplay);
+
+ if (sizeof($attachDisplay) > 0) {
+
+ $filePath = "attachments/" . sha1($_SERVER['SERVER_NAME']) ."/" . sha1($header->subject);
+
+ echo "<div class=\"spacer\"></div>";
+
+ echo "<div class=\"message\" style=\"position: relative;\">";
+
+
+ echo "<div style=\"position: absolute; top: -15; right: -15;\"><img src=\"images/attach.png\" border=\"0\" width=\"48\" height=\"48\"></div>";
+
+ echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\">";
+
+ for ($j=0;$j<sizeof($attachDisplay);$j++) {
+
+ if (($dataHtml != "") and (strtolower($attachDisplay[$j]) != "utf-8") and (strtolower($attachDisplay[$j]) != "windows-1252")) {
+ $file = $j;
+ $fileContent = base64_decode(imap_fetchbody($mbox,$msgno,$file+2));
+ $fileName = preg_replace("/[^a-z0-9_\-\.]/i","",$attachDisplay[$j]);
+
+ if (!file_exists($filePath)) {
+ mkdir($filePath,0700,1);
+ }
+
+ if (!file_exists("$filePath/$fileName")) {
+ file_put_contents("$filePath/$fileName",$fileContent);
+ }
+
+ $fileSize = filesize("$filePath/$fileName");
+ $fileSize = HumanReadableFilesize($fileSize);
+ echo "<tr><td><a href=\"$filePath/$fileName\"><img src=\"images/file.png\" border=\"0\" width=\"36\" height=\"36\"></a></td><td><a href=\"$fileName\">$fileName</a><br>$fileSize</td></tr>";
+ }
+ }
+
+ echo "</table>";
+ echo "</div>";
+ }
+
+ echo "</td></tr></table>";
+}
+
+imap_close($mbox);
+
+?>
diff --git a/send.php b/send.php
new file mode 100644
index 0000000..becdcca
--- /dev/null
+++ b/send.php
@@ -0,0 +1,163 @@
+<?php
+
+session_start();
+
+if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
+ exit;
+}
+
+require_once("core.php");
+
+if (!isset($_POST['box']) or empty($_POST['box'])) {
+ $folder = "INBOX";
+}
+else {
+ $folder = trim(strip_tags($_POST['box']));
+}
+
+$host = "{127.0.0.1:143/imap/notls/norsh}";
+
+$mbox = @imap_open("{$host}$folder", $_SESSION['logged_uid'], $_SESSION['logged_key']) or die("Connection to server failed");
+
+if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])) {
+
+ $msgno = trim(strip_tags($_POST['msg']));
+
+ $header = imap_headerinfo($mbox, $msgno);
+
+ $header_subject = $header->subject;
+ $header_fromaddress = $header->senderaddress;
+ $header_date = $header->date;
+ $header_toaddress = $header->toaddress;
+ $header_ccaddress = $header->ccaddress;
+
+ $reply_quote = wordwrap(trim(get_part($mbox, $msgno, "TEXT/PLAIN")),75,"\r\n");
+
+ $reply_quote_lines = explode("\n",$reply_quote);
+
+ if (count($reply_quote_lines) < 10) {
+ $reply_quote_rows = "10";
+ }
+ else {
+ $reply_quote_rows = count($reply_quote_lines) + 1;
+ }
+
+ $reply_from = "\"$usr_name\" <{$_SESSION['logged_uid']}>";
+
+ $reply_to = $header->reply_toaddress;
+
+ if ($reply_to != "") {
+ $reply_to = $header->reply_toaddress;
+ }
+ else {
+ $reply_to = $header->fromaddress;
+ }
+
+ if (($_POST['rep'] == 3) and strpos($header->toaddress,",")) {
+
+ $reply_to = $reply_to . ", " . $header->toaddress;
+ }
+
+ if ($_POST['rep'] == 2) {
+
+ $reply_cc ="";
+ }
+ else {
+ $reply_cc = $header->ccaddress;
+ }
+
+ $reply_subject = $header->subject;
+
+ if ($_POST['rep'] == 2) {
+
+ $reply_to = "";
+
+ $reply_subject = "Fwd: " . $reply_subject;
+ $reply_subject = str_replace("Fwd: Fwd: ","Fwd: ",$reply_subject);
+ }
+ else {
+ $reply_subject = "Re: " . $reply_subject;
+ $reply_subject = str_replace("Re: Re: ","Re: ",$reply_subject);
+ }
+
+ $reply_from = htmlentities($reply_from,ENT_QUOTES);
+ $reply_to = htmlentities($reply_to,ENT_QUOTES);
+ $reply_subject = htmlentities($reply_subject,ENT_QUOTES);
+ $reply_cc = htmlentities($reply_cc,ENT_QUOTES);
+
+ echo "<title>Kartero - $folder - $reply_subject</title>";
+
+ echo "<table border=\"0\" cellspacing=\"0\" callpadding=\"0\" width=\"800\"><tr><td valign=\"top\">";
+
+ echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\" width=\"100%\">";
+
+ echo "<form method=\"post\">";
+
+ if (($_POST['rep'] == 1) or ($_POST['rep'] == 3)) {
+
+ echo "<input type=\"hidden\" name=\"ack\" value=\"1\">";
+ }
+
+ echo "<tr><td width=\"50\"><b>From:</b></td><td rowspan=\"7\" width=\"5\"></td><td><input class=\"input\" type=\"text\" name=\"reply_from\" value=\"$reply_from\" readonly></td></tr>";
+ echo "<tr><td><b>To:</b></td><td><input class=\"input\" type=\"text\" name=\"reply_to\" value=\"$reply_to\"></td></tr>";
+ echo "<tr><td><b>Cc:</b></td><td><input class=\"input\" type=\"text\" name=\"reply_cc\" value=\"$reply_cc\"></td></tr>";
+ echo "<tr><td><b>Bcc:</b></td><td><input class=\"input\" type=\"text\" name=\"reply_bcc\"></td></tr>";
+ echo "<tr><td><b>Subject:</b></td><td><input class=\"input\" type=\"text\" name=\"reply_subj\" value=\"$reply_subject\"></td></tr>";
+
+ echo "<tr><td></td><td><textarea class=\"input\" name=\"reply_body\" rows=\"$reply_quote_rows\">";
+
+ if ($_POST['rep'] == 2) {
+
+ echo "---------------------------------------- Begin Forwarded Message ----------------------------------------\r\n";
+ }
+ else {
+ $reply_personal = $header->fromaddress;
+ echo "On $header_date, $reply_personal wrote:\r\n";
+ }
+
+ foreach ($reply_quote_lines as $reply_quote_line) {
+
+ $reply_quote_line = "> $reply_quote_line";
+ $reply_quote_line = preg_replace("/(^> >)/",">>",$reply_quote_line);
+
+ echo $reply_quote_line;
+ }
+
+ if ($_POST['rep'] == 2) {
+
+ $filePath = "attachments/" . sha1($_SERVER['SERVER_NAME']) ."/" . sha1($header->subject);
+
+ if (file_exists("$filePath")) {
+
+ $fileNames = glob("$filePath/*");
+
+ if (count($fileNames) > 0) {
+
+ foreach ($fileNames as $fileName) {
+
+ echo "\r\n\r\n" . str_replace("$filePath/","",$fileName) . " (" . HumanReadableFilesize(filesize($fileName)) . ")\r\n";
+ echo "http://" . $_SERVER['SERVER_NAME'] . "/$fileName";
+ }
+ }
+
+ }
+ }
+
+ echo "</textarea></td></tr>";
+
+ echo "<input type=\"hidden\" name=\"mbox_min\" value=\"$mbox_min\">";
+ echo "<input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<input type=\"hidden\" name=\"msg\" value=\"$msgno\">";
+ echo "<tr><td></td><td align=\"right\"><div class=\"label\"><input type=\"image\" src=\"images/mail-reply.png\"></div><div class=\"label\">send</div></td></tr>";
+
+ echo "</table>";
+
+ echo "</form>";
+
+ echo "</td></tr>";
+ echo "</table>";
+
+ imap_close($mbox);
+}
+
+?>