View file mail/mail/index-slow.php

File size: 3.48Kb
<?
#####################################################################
#  Copyright (c) 2002 Pau Oliva Fora <[email protected]>               #
#  Licensed under the GNU GPL. For full terms see the file COPYING. #
##################################################################### 
require("config.php");
wmlheader();
wmlmeta();
if ( isset ($P) && isset($F) ) {

		  $mbox = imap_open ("\{$IMAPSERVER:143}$F", "$U", "$P") or die ("can't connect: " .  imap_last_error());

		  echo "<card id=\"intro\">\n";

		  $check = imap_mailboxmsginfo($mbox);
		  if($check) $showlist = $check->Nmsgs; 
		  else echo "imap_check() failed: ".imap_last_error(). "<br/>\n";
		  
		  echo "<p align=\"center\">\n";

		  if ($showlist != 0) echo "<anchor title=\"$S_SUBMIT\">$S_VIEWMAIL
<go href=\"maillist.php?page=1\" method=\"post\">
<postfield name=\"F\" value=\"$F\"/>
<postfield name=\"U\" value=\"$U\"/>
<postfield name=\"P\" value=\"$P\"/>
</go></anchor><br/>";

		  $check = imap_mailboxmsginfo ($mbox);
		  if ($check) {
		 		echo "<anchor title=\"$S_SUBMIT\">$S_COMPOSE
<go href=\"compose.php\" method=\"post\">
<postfield name=\"F\" value=\"$F\"/>
<postfield name=\"U\" value=\"$U\"/>
<postfield name=\"P\" value=\"$P\"/>
</go></anchor><br/>";
		 		echo "<anchor title=\"$S_SUBMIT\">$S_INFO
<go href=\"mailinfo.php\" method=\"post\">
<postfield name=\"F\" value=\"$F\"/>
<postfield name=\"U\" value=\"$U\"/>
<postfield name=\"P\" value=\"$P\"/>
</go></anchor><br/>";
				echo "$S_FOLDER $F <br/>\n";
				echo "$S_MESSAGES". $check->Nmsgs   ."<br/>\n" ;
				echo "$S_UNREAD". $check->Unread  ."<br/>\n" ;
		  } else echo "imap_check() failed: ".imap_last_error(). "<br/>\n";
		  
		  imap_close($mbox);
		  echo "</p>\n";


} elseif ( isset ($P) ) {

		  echo "<card id=\"mailbox\" title=\"$S_FOLDER\">\n";
		  echo "<p align=\"center\">\n";
		  
		  $mbox = imap_open ("\{$IMAPSERVER:143}", "$U", "$P",OP_HALFOPEN) or die ("can't connect: " .  imap_last_error());

		  //$list = imap_getmailboxes($mbox,"\{$IMAPSERVER:143}","$BASEFOLDER/*");
		  $list = imap_getsubscribed($mbox,"\{$IMAPSERVER:143}","$BASEFOLDER/*");
		  if(is_array($list)) {
			  reset($list);
			  echo "<select name=\"F\">\n";
			  while (list($key, $val) = each($list)) {
					$name = ereg_replace("/$","",ereg_replace("\{.*.\}","",imap_utf7_decode($val->name)));
			  		print "<option value=\"$name\">$name";
					# get Nmsgs/Unread for each mailbox (this is so slow if you have a lot of folders!!)
		  			$mbox2 = imap_open ("\{$IMAPSERVER:143}$name", "$U", "$P") or die ("can't connect: " .  imap_last_error());
					$check = imap_mailboxmsginfo ($mbox2);
					if($check) print " (". $check->Nmsgs ."/". $check->Unread .")";
					echo "</option>\n";
					imap_close($mbox2);
				}
			  echo "</select>\n";
		  } else die ("imap_getmailboxes failed: ".imap_last_error());
   
		  imap_close($mbox);

		  echo "<do type=\"accept\" label=\"$S_SUBMIT\">";
		  ?>
<go href="index.php" method="post">
<postfield name="F" value="$F"/>
<postfield name="U" value="$U"/>
<postfield name="P" value="$P"/>
</go></do></p>

<?

} else {

		  echo "<card id=\"input\" title=\"pofHQ wapMAIL $VERSION\">\n";
		  echo "<p>\n";
		  echo "$S_LOGIN<input type=\"text\" name=\"U\"/>\n";
		  echo "$S_P<input type=\"password\" name=\"P\"/>\n";
		  #echo "$S_FOLDER<input type=\"text\" name=\"F\" value=\"INBOX\"/>\n";
		  echo "<do type=\"accept\" label=\"$S_SUBMIT\">";
		  ?>
<go href="index.php" method="post">
<postfield name="U" value="$U"/>
<postfield name="P" value="$P"/>
</go></do></p>

<?
}
wmlfooter();
?>