This commit has been accessed 679 times via Git panel.
commit 822b6c1476ed60dc9c9dbb701b086ee457e4646d
tree a5b1caa33d57f745a4837206da1e1dca59e8670c
parent de68c2d9438b49c18449bde4a0c7d33919325a97
author Engels Antonio <engels@majcms.org> 1332703262 +0800
committer Engels Antonio <engels@majcms.org> 1332703262 +0800
Consolidate imap_open() calls
diff --git a/folders.php b/folders.php
index ca7f19e..d351752 100644
--- a/folders.php
+++ b/folders.php
@@ -1,15 +1,11 @@
<?php
-session_start();
+require_once("core.php");
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\">";
@@ -59,9 +55,9 @@ if (!isset($_POST['get']) and !isset($_POST['rep'])) {
}
}
-if ($_POST['box'] == "Trash") {
+if ($folder == "Trash") {
- $trash_status = imap_status($mbox, "{$conn}Trash", SA_MESSAGES+SA_UNSEEN);
+ $trash_status = imap_status($mbox, "{$host}Trash", SA_MESSAGES+SA_UNSEEN);
if ($trash_status->messages > 0) {
@@ -89,46 +85,44 @@ echo "</table></div>";
echo "<div style=\"height: 4px;\"></div>";
-$folders = imap_list($mbox, $conn, "*");
+$get_folders = imap_list($mbox, $host, "*");
-if (is_array($folders)) {
+if (is_array($get_folders)) {
- if (in_array("{$conn}INBOX",$folders)) {
+ if (in_array("{$host}INBOX",$get_folders)) {
- $inbox = array_search("{$conn}INBOX",$folders);
+ $inbox = array_search("{$host}INBOX",$get_folders);
- unset($folders[$inbox]);
+ unset($get_folders[$inbox]);
unset($inbox);
}
- sort($folders);
+ sort($get_folders);
- array_unshift($folders,"{$conn}INBOX");
+ array_unshift($get_folders,"{$host}INBOX");
- reset($folders);
+ reset($get_folders);
echo "\n\n<div class=\"folders\"><table border=\"0\" cellspacing=\"1\" callpadding=\"2\">";
- foreach ($folders as $folder) {
+ foreach ($get_folders as $get_folder) {
- $status = imap_status($mbox, $folder, SA_MESSAGES+SA_UNSEEN);
+ $status = imap_status($mbox, $get_folder, SA_MESSAGES+SA_UNSEEN);
$status_folder = "(" . $status->unseen . "/" . $status->messages . ")";
- $folder = str_replace($conn,"",$folder);
+ $get_folder = str_replace($host,"",$get_folder);
- echo "<tr><form method=\"post\"><td align=\"center\"><input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<tr><form method=\"post\"><td align=\"center\"><input type=\"hidden\" name=\"box\" value=\"$get_folder\">";
- if ((!isset($_POST['box']) and ($folder == "INBOX")) or (isset($_POST['box']) and ($_POST['box'] == $folder))) {
+ if ($folder == $get_folder) {
echo "<input type=\"image\" src=\"images/folder-open.png\"></td></form>";
- echo "<td><nobr><b>$folder</b> $status_folder</nobr></td></tr>";
+ echo "<td><nobr><b>$get_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 "<td><nobr>$get_folder $status_folder</nobr></td></tr>";
}
-
-
}
echo "</table></div>";
@@ -137,15 +131,13 @@ else {
echo "imap_getmailboxes failed: " . imap_last_error() . "\n";
}
-imap_close($mbox);
-
echo "<div style=\"height: 4px;\"></div>";
echo "<div class=\"folders\"><table border=\"0\" cellspacing=\"0\" callpadding=\"0\">";
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"set\" value=\"1\">";
-echo "<tr><td width=\"34\"><input type=\"image\" src=\"images/mail-settings.png\"></td><td>Settings</td></tr>";
+echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-settings.png\"></td><td>Settings</td></tr>";
echo "</form>";
echo "</table></div>";
diff --git a/images/mail-settings.png b/images/mail-settings.png
index 769d539..9737aa2 100644
Binary files a/images/mail-settings.png and b/images/mail-settings.png differ
diff --git a/inbox.php b/inbox.php
index d8402c3..945489a 100644
--- a/inbox.php
+++ b/inbox.php
@@ -1,22 +1,11 @@
<?php
-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']));
+if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
+ exit;
}
-$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']));
@@ -225,6 +214,4 @@ foreach ($mbox_sort as $mbox_num => $mbox_row) {
echo "</table>";
-imap_close($mbox);
-
?>
diff --git a/index.php b/index.php
index 2a65c53..1434ec3 100644
--- a/index.php
+++ b/index.php
@@ -149,38 +149,41 @@ if ($pw_put == $pw_get) {
unset($pw_mbox);
- if ($_SESSION['logged_lvl'] == "subscriber") {
+if ($_SESSION['logged_lvl'] == "subscriber") {
- if (isset($_SESSION['clean_up_i']) and file_exists("attach/i/$fileUsr/{$_SESSION['clean_up_i']}") and (!isset($_POST['filedrop_box']) or empty($_POST['filedrop_box']))) {
+ if (isset($_SESSION['clean_up_i']) and file_exists("attach/i/$fileUsr/{$_SESSION['clean_up_i']}") and (!isset($_POST['filedrop_box']) or empty($_POST['filedrop_box']))) {
- rmdirr("attach/i/$fileUsr/{$_SESSION['clean_up_i']}");
- unset($_SESSION['clean_up_i']);
+ rmdirr("attach/i/$fileUsr/{$_SESSION['clean_up_i']}");
+ unset($_SESSION['clean_up_i']);
- if (count(glob("attach/i/$fileUsr/*")) == 0) {
- rmdirr("attach/i/$fileUsr");
- }
+ if (count(glob("attach/i/$fileUsr/*")) == 0) {
+ rmdirr("attach/i/$fileUsr");
}
+ }
- if (isset($_SESSION['clean_up_o']) and file_exists("attach/o/$fileUsr/{$_SESSION['clean_up_o']}")) {
+ if (isset($_SESSION['clean_up_o']) and file_exists("attach/o/$fileUsr/{$_SESSION['clean_up_o']}")) {
- rmdirr("attach/o/$fileUsr/{$_SESSION['clean_up_o']}");
- unset($_SESSION['clean_up_o']);
+ rmdirr("attach/o/$fileUsr/{$_SESSION['clean_up_o']}");
+ unset($_SESSION['clean_up_o']);
- if (count(glob("attach/o/$fileUsr/*")) == 0) {
- rmdirr("attach/o/$fileUsr");
- }
- }
+ if (count(glob("attach/o/$fileUsr/*")) == 0) {
+ rmdirr("attach/o/$fileUsr");
+ }
}
+}
if (isset($_GET['do']) and ($_GET['do'] == "logout")) {
+
+ if ($mbox) {
+ imap_close($mbox, CL_EXPUNGE);
+ }
+
$_SESSION = array();
session_destroy();
header("Location: .");
exit;
}
-/* 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>";
@@ -222,8 +225,6 @@ if (!isset($_SESSION['logged_uid']) and (($pw_put != $pw_get) or !isset($_POST['
if (isset($_SESSION['logged_uid'])) {
- //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\">";
@@ -238,11 +239,13 @@ if (isset($_SESSION['logged_uid'])) {
$dom_data = mysql_fetch_row($dom_query);
if ($dom_data[0] == 0) {
- nak("{$usr_data[4]} disabled by admin - new settings will take effect once it is re-enabled");
+ nak("{$usr_data[4]} disabled by admin");
+ exit();
}
if ($usr_data[5] == 0) {
- nak("{$_SESSION['logged_uid']} disabled by postmaster - new settings will take effect once it is re-enabled");
+ nak("{$_SESSION['logged_uid']} disabled by postmaster");
+ exit();
}
$usr_name = $usr_data[3];
@@ -311,13 +314,13 @@ if (isset($_SESSION['logged_uid'])) {
nak("{$_SESSION['logged_uid']} disabled by admin - new settings will take effect once it is re-enabled");
}
-$max_get = mysql_query("select max from domains where id='{$_SESSION['logged_uid']}'");
+ $max_get = mysql_query("select max from domains where id='{$_SESSION['logged_uid']}'");
-$pm_max = mysql_fetch_row($max_get);
+ $pm_max = mysql_fetch_row($max_get);
-$pm_get = mysql_query("select * from users where domain='{$_SESSION['logged_uid']}' order by id");
+ $pm_get = mysql_query("select * from users where domain='{$_SESSION['logged_uid']}' order by id");
-$pm_now = mysql_num_rows($pm_get);
+ $pm_now = mysql_num_rows($pm_get);
if (isset($_POST['pm_id']) and isset($_POST['pm_name']) and isset($_POST['pm_pw']) and !empty($_POST['pm_id']) and !empty($_POST['pm_name']) and !empty($_POST['pm_pw'])) {
@@ -816,6 +819,17 @@ $pm_now = mysql_num_rows($pm_get);
$filedrop_box = sha1(microtime(true));
+ $host = "{127.0.0.1:143/imap/notls/norsh}";
+
+ if (!isset($_POST['box']) or empty($_POST['box'])) {
+ $folder = "INBOX";
+ }
+ else {
+ $folder = trim(strip_tags($_POST['box']));
+ }
+
+ $mbox = @imap_open("{$host}$folder", $_SESSION['logged_uid'], $_SESSION['logged_key'], CL_EXPUNGE) or die(imap_last_error());
+
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']) and !empty($_POST['reply_from']) and !empty($_POST['reply_to']) and !empty($_POST['reply_subj']) and !empty($_POST['reply_body'])) {
@@ -878,14 +892,8 @@ $pm_now = mysql_num_rows($pm_get);
}
}
-
-
- $host = "{127.0.0.1:143/imap/notls/norsh}";
-
if ($_POST['redirect'] == 1) {
- $mbox = @imap_open("{$host}{$_POST['box']}", $_SESSION['logged_uid'], $_SESSION['logged_key']) or die("Connection to server failed");
-
$redirect_date = date("D, j M Y H:i:s O (T)");
$reply_headers = "Resent-Date: $redirect_date\r\nResent-To: $reply_to\r\n";
@@ -909,9 +917,6 @@ $pm_now = mysql_num_rows($pm_get);
$reply_body = imap_body($mbox,$_POST['msg']);
}
- else {
- $mbox = @imap_open($host, $_SESSION['logged_uid'], $_SESSION['logged_key']) or die("Connection to server failed");
- }
imap_createmailbox($mbox,"{$host}Sent");
@@ -926,33 +931,21 @@ $pm_now = mysql_num_rows($pm_get);
if ($_POST['ack'] == 1) {
- imap_reopen($mbox, "{$host}{$_POST['box']}");
+ //imap_reopen($mbox, "{$host}$folder");
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);
+ imap_expunge($mbox);
}
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);
+ imap_expunge($mbox);
}
echo "<tr><td valign=\"top\" width=\"700\"><div id=\"main\" class=\"main\">";
diff --git a/post.php b/post.php
index e00b2e4..91d634b 100644
--- a/post.php
+++ b/post.php
@@ -1,11 +1,11 @@
<?php
+require_once("core.php");
+
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']}>";
diff --git a/preload.php b/preload.php
index fe790d2..9f1ae4f 100644
--- a/preload.php
+++ b/preload.php
@@ -14,6 +14,7 @@
<img src="images/mail-reply-all.png">
<img src="images/mail-reply.png">
<img src="images/mail-search.png">
+<img src="images/mail-settings.png">
<img src="images/mail-unread.png">
<img src="images/trashcan_empty.png">
<img src="images/trashcan_full.png">
diff --git a/read.php b/read.php
index bf4ec65..1cb91d2 100644
--- a/read.php
+++ b/read.php
@@ -1,22 +1,11 @@
<?php
-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']));
+if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
+ exit;
}
-$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']));
@@ -475,6 +464,4 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "</td></tr></table>";
}
-imap_close($mbox);
-
?>
diff --git a/search.php b/search.php
index ec0032e..cebc75e 100644
--- a/search.php
+++ b/search.php
@@ -1,23 +1,12 @@
<?php
-session_start();
+require_once("core.php");
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']));
-}
-
-$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());
-
-$search_folders = imap_list($mbox,$conn,"*");
+$search_folders = imap_list($mbox,$host,"*");
if (is_array($search_folders)) {
@@ -33,7 +22,7 @@ if (is_array($search_folders)) {
foreach ($search_folders as $search_folder) {
- $search_folder = str_replace($conn,"",$search_folder);
+ $search_folder = str_replace($host,"",$search_folder);
if ($folder == $search_folder) {
echo "<option selected>$search_folder</option>";
@@ -76,6 +65,4 @@ if (is_array($search_folders)) {
}
-imap_close($mbox);
-
?>
diff --git a/send.php b/send.php
index 87c45ea..2b0ff82 100644
--- a/send.php
+++ b/send.php
@@ -1,22 +1,11 @@
<?php
-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']));
+if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
+ exit;
}
-$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']));
@@ -245,8 +234,6 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "</td></tr>";
echo "</table>";
-
- imap_close($mbox);
}
?>
tree a5b1caa33d57f745a4837206da1e1dca59e8670c
parent de68c2d9438b49c18449bde4a0c7d33919325a97
author Engels Antonio <engels@majcms.org> 1332703262 +0800
committer Engels Antonio <engels@majcms.org> 1332703262 +0800
Consolidate imap_open() calls
diff --git a/folders.php b/folders.php
index ca7f19e..d351752 100644
--- a/folders.php
+++ b/folders.php
@@ -1,15 +1,11 @@
<?php
-session_start();
+require_once("core.php");
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\">";
@@ -59,9 +55,9 @@ if (!isset($_POST['get']) and !isset($_POST['rep'])) {
}
}
-if ($_POST['box'] == "Trash") {
+if ($folder == "Trash") {
- $trash_status = imap_status($mbox, "{$conn}Trash", SA_MESSAGES+SA_UNSEEN);
+ $trash_status = imap_status($mbox, "{$host}Trash", SA_MESSAGES+SA_UNSEEN);
if ($trash_status->messages > 0) {
@@ -89,46 +85,44 @@ echo "</table></div>";
echo "<div style=\"height: 4px;\"></div>";
-$folders = imap_list($mbox, $conn, "*");
+$get_folders = imap_list($mbox, $host, "*");
-if (is_array($folders)) {
+if (is_array($get_folders)) {
- if (in_array("{$conn}INBOX",$folders)) {
+ if (in_array("{$host}INBOX",$get_folders)) {
- $inbox = array_search("{$conn}INBOX",$folders);
+ $inbox = array_search("{$host}INBOX",$get_folders);
- unset($folders[$inbox]);
+ unset($get_folders[$inbox]);
unset($inbox);
}
- sort($folders);
+ sort($get_folders);
- array_unshift($folders,"{$conn}INBOX");
+ array_unshift($get_folders,"{$host}INBOX");
- reset($folders);
+ reset($get_folders);
echo "\n\n<div class=\"folders\"><table border=\"0\" cellspacing=\"1\" callpadding=\"2\">";
- foreach ($folders as $folder) {
+ foreach ($get_folders as $get_folder) {
- $status = imap_status($mbox, $folder, SA_MESSAGES+SA_UNSEEN);
+ $status = imap_status($mbox, $get_folder, SA_MESSAGES+SA_UNSEEN);
$status_folder = "(" . $status->unseen . "/" . $status->messages . ")";
- $folder = str_replace($conn,"",$folder);
+ $get_folder = str_replace($host,"",$get_folder);
- echo "<tr><form method=\"post\"><td align=\"center\"><input type=\"hidden\" name=\"box\" value=\"$folder\">";
+ echo "<tr><form method=\"post\"><td align=\"center\"><input type=\"hidden\" name=\"box\" value=\"$get_folder\">";
- if ((!isset($_POST['box']) and ($folder == "INBOX")) or (isset($_POST['box']) and ($_POST['box'] == $folder))) {
+ if ($folder == $get_folder) {
echo "<input type=\"image\" src=\"images/folder-open.png\"></td></form>";
- echo "<td><nobr><b>$folder</b> $status_folder</nobr></td></tr>";
+ echo "<td><nobr><b>$get_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 "<td><nobr>$get_folder $status_folder</nobr></td></tr>";
}
-
-
}
echo "</table></div>";
@@ -137,15 +131,13 @@ else {
echo "imap_getmailboxes failed: " . imap_last_error() . "\n";
}
-imap_close($mbox);
-
echo "<div style=\"height: 4px;\"></div>";
echo "<div class=\"folders\"><table border=\"0\" cellspacing=\"0\" callpadding=\"0\">";
echo "<form method=\"post\">";
echo "<input type=\"hidden\" name=\"set\" value=\"1\">";
-echo "<tr><td width=\"34\"><input type=\"image\" src=\"images/mail-settings.png\"></td><td>Settings</td></tr>";
+echo "<tr><td width=\"32\"><input type=\"image\" src=\"images/mail-settings.png\"></td><td>Settings</td></tr>";
echo "</form>";
echo "</table></div>";
diff --git a/images/mail-settings.png b/images/mail-settings.png
index 769d539..9737aa2 100644
Binary files a/images/mail-settings.png and b/images/mail-settings.png differ
diff --git a/inbox.php b/inbox.php
index d8402c3..945489a 100644
--- a/inbox.php
+++ b/inbox.php
@@ -1,22 +1,11 @@
<?php
-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']));
+if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
+ exit;
}
-$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']));
@@ -225,6 +214,4 @@ foreach ($mbox_sort as $mbox_num => $mbox_row) {
echo "</table>";
-imap_close($mbox);
-
?>
diff --git a/index.php b/index.php
index 2a65c53..1434ec3 100644
--- a/index.php
+++ b/index.php
@@ -149,38 +149,41 @@ if ($pw_put == $pw_get) {
unset($pw_mbox);
- if ($_SESSION['logged_lvl'] == "subscriber") {
+if ($_SESSION['logged_lvl'] == "subscriber") {
- if (isset($_SESSION['clean_up_i']) and file_exists("attach/i/$fileUsr/{$_SESSION['clean_up_i']}") and (!isset($_POST['filedrop_box']) or empty($_POST['filedrop_box']))) {
+ if (isset($_SESSION['clean_up_i']) and file_exists("attach/i/$fileUsr/{$_SESSION['clean_up_i']}") and (!isset($_POST['filedrop_box']) or empty($_POST['filedrop_box']))) {
- rmdirr("attach/i/$fileUsr/{$_SESSION['clean_up_i']}");
- unset($_SESSION['clean_up_i']);
+ rmdirr("attach/i/$fileUsr/{$_SESSION['clean_up_i']}");
+ unset($_SESSION['clean_up_i']);
- if (count(glob("attach/i/$fileUsr/*")) == 0) {
- rmdirr("attach/i/$fileUsr");
- }
+ if (count(glob("attach/i/$fileUsr/*")) == 0) {
+ rmdirr("attach/i/$fileUsr");
}
+ }
- if (isset($_SESSION['clean_up_o']) and file_exists("attach/o/$fileUsr/{$_SESSION['clean_up_o']}")) {
+ if (isset($_SESSION['clean_up_o']) and file_exists("attach/o/$fileUsr/{$_SESSION['clean_up_o']}")) {
- rmdirr("attach/o/$fileUsr/{$_SESSION['clean_up_o']}");
- unset($_SESSION['clean_up_o']);
+ rmdirr("attach/o/$fileUsr/{$_SESSION['clean_up_o']}");
+ unset($_SESSION['clean_up_o']);
- if (count(glob("attach/o/$fileUsr/*")) == 0) {
- rmdirr("attach/o/$fileUsr");
- }
- }
+ if (count(glob("attach/o/$fileUsr/*")) == 0) {
+ rmdirr("attach/o/$fileUsr");
+ }
}
+}
if (isset($_GET['do']) and ($_GET['do'] == "logout")) {
+
+ if ($mbox) {
+ imap_close($mbox, CL_EXPUNGE);
+ }
+
$_SESSION = array();
session_destroy();
header("Location: .");
exit;
}
-/* 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>";
@@ -222,8 +225,6 @@ if (!isset($_SESSION['logged_uid']) and (($pw_put != $pw_get) or !isset($_POST['
if (isset($_SESSION['logged_uid'])) {
- //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\">";
@@ -238,11 +239,13 @@ if (isset($_SESSION['logged_uid'])) {
$dom_data = mysql_fetch_row($dom_query);
if ($dom_data[0] == 0) {
- nak("{$usr_data[4]} disabled by admin - new settings will take effect once it is re-enabled");
+ nak("{$usr_data[4]} disabled by admin");
+ exit();
}
if ($usr_data[5] == 0) {
- nak("{$_SESSION['logged_uid']} disabled by postmaster - new settings will take effect once it is re-enabled");
+ nak("{$_SESSION['logged_uid']} disabled by postmaster");
+ exit();
}
$usr_name = $usr_data[3];
@@ -311,13 +314,13 @@ if (isset($_SESSION['logged_uid'])) {
nak("{$_SESSION['logged_uid']} disabled by admin - new settings will take effect once it is re-enabled");
}
-$max_get = mysql_query("select max from domains where id='{$_SESSION['logged_uid']}'");
+ $max_get = mysql_query("select max from domains where id='{$_SESSION['logged_uid']}'");
-$pm_max = mysql_fetch_row($max_get);
+ $pm_max = mysql_fetch_row($max_get);
-$pm_get = mysql_query("select * from users where domain='{$_SESSION['logged_uid']}' order by id");
+ $pm_get = mysql_query("select * from users where domain='{$_SESSION['logged_uid']}' order by id");
-$pm_now = mysql_num_rows($pm_get);
+ $pm_now = mysql_num_rows($pm_get);
if (isset($_POST['pm_id']) and isset($_POST['pm_name']) and isset($_POST['pm_pw']) and !empty($_POST['pm_id']) and !empty($_POST['pm_name']) and !empty($_POST['pm_pw'])) {
@@ -816,6 +819,17 @@ $pm_now = mysql_num_rows($pm_get);
$filedrop_box = sha1(microtime(true));
+ $host = "{127.0.0.1:143/imap/notls/norsh}";
+
+ if (!isset($_POST['box']) or empty($_POST['box'])) {
+ $folder = "INBOX";
+ }
+ else {
+ $folder = trim(strip_tags($_POST['box']));
+ }
+
+ $mbox = @imap_open("{$host}$folder", $_SESSION['logged_uid'], $_SESSION['logged_key'], CL_EXPUNGE) or die(imap_last_error());
+
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']) and !empty($_POST['reply_from']) and !empty($_POST['reply_to']) and !empty($_POST['reply_subj']) and !empty($_POST['reply_body'])) {
@@ -878,14 +892,8 @@ $pm_now = mysql_num_rows($pm_get);
}
}
-
-
- $host = "{127.0.0.1:143/imap/notls/norsh}";
-
if ($_POST['redirect'] == 1) {
- $mbox = @imap_open("{$host}{$_POST['box']}", $_SESSION['logged_uid'], $_SESSION['logged_key']) or die("Connection to server failed");
-
$redirect_date = date("D, j M Y H:i:s O (T)");
$reply_headers = "Resent-Date: $redirect_date\r\nResent-To: $reply_to\r\n";
@@ -909,9 +917,6 @@ $pm_now = mysql_num_rows($pm_get);
$reply_body = imap_body($mbox,$_POST['msg']);
}
- else {
- $mbox = @imap_open($host, $_SESSION['logged_uid'], $_SESSION['logged_key']) or die("Connection to server failed");
- }
imap_createmailbox($mbox,"{$host}Sent");
@@ -926,33 +931,21 @@ $pm_now = mysql_num_rows($pm_get);
if ($_POST['ack'] == 1) {
- imap_reopen($mbox, "{$host}{$_POST['box']}");
+ //imap_reopen($mbox, "{$host}$folder");
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);
+ imap_expunge($mbox);
}
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);
+ imap_expunge($mbox);
}
echo "<tr><td valign=\"top\" width=\"700\"><div id=\"main\" class=\"main\">";
diff --git a/post.php b/post.php
index e00b2e4..91d634b 100644
--- a/post.php
+++ b/post.php
@@ -1,11 +1,11 @@
<?php
+require_once("core.php");
+
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']}>";
diff --git a/preload.php b/preload.php
index fe790d2..9f1ae4f 100644
--- a/preload.php
+++ b/preload.php
@@ -14,6 +14,7 @@
<img src="images/mail-reply-all.png">
<img src="images/mail-reply.png">
<img src="images/mail-search.png">
+<img src="images/mail-settings.png">
<img src="images/mail-unread.png">
<img src="images/trashcan_empty.png">
<img src="images/trashcan_full.png">
diff --git a/read.php b/read.php
index bf4ec65..1cb91d2 100644
--- a/read.php
+++ b/read.php
@@ -1,22 +1,11 @@
<?php
-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']));
+if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
+ exit;
}
-$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']));
@@ -475,6 +464,4 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "</td></tr></table>";
}
-imap_close($mbox);
-
?>
diff --git a/search.php b/search.php
index ec0032e..cebc75e 100644
--- a/search.php
+++ b/search.php
@@ -1,23 +1,12 @@
<?php
-session_start();
+require_once("core.php");
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']));
-}
-
-$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());
-
-$search_folders = imap_list($mbox,$conn,"*");
+$search_folders = imap_list($mbox,$host,"*");
if (is_array($search_folders)) {
@@ -33,7 +22,7 @@ if (is_array($search_folders)) {
foreach ($search_folders as $search_folder) {
- $search_folder = str_replace($conn,"",$search_folder);
+ $search_folder = str_replace($host,"",$search_folder);
if ($folder == $search_folder) {
echo "<option selected>$search_folder</option>";
@@ -76,6 +65,4 @@ if (is_array($search_folders)) {
}
-imap_close($mbox);
-
?>
diff --git a/send.php b/send.php
index 87c45ea..2b0ff82 100644
--- a/send.php
+++ b/send.php
@@ -1,22 +1,11 @@
<?php
-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']));
+if (!isset($_SESSION['logged_uid']) or !isset($_SESSION['logged_lvl']) or !isset($_SESSION['logged_key']) or ($_SESSION['logged_lvl'] != "subscriber")) {
+ exit;
}
-$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']));
@@ -245,8 +234,6 @@ if (isset($_POST['msg']) and !empty($_POST['msg']) and is_numeric($_POST['msg'])
echo "</td></tr>";
echo "</table>";
-
- imap_close($mbox);
}
?>