<?
/*
$Header: /home/cvsroot/pofhq-wapmail/index.php,v 1.5 2002/12/13 20:19:58 pau Exp $
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) ) {
echo "<card id=\"intro\" title=\"pofHQ wapMAIL $VERSION\">\n";
echo "<p align=\"center\">\n";
if (empty($F)) $F = "$BASEFOLDER";
if ($CYRUS) $FOLDER = preg_replace("/$BASEFOLDER\./", "", $F);
$mbox = imap_open ("\{$IMAPSERVER:$IMAPPORT}$F", "$U", "$P") or wmldie ("can't connect: " . imap_last_error());
$check = imap_mailboxmsginfo($mbox);
if($check) $showlist = $check->Nmsgs;
else echo "imap_check() failed: ".imap_last_error(). "<br/>\n";
$check = imap_mailboxmsginfo ($mbox);
if ($check) {
if ($CYRUS) echo "$S_FOLDER $FOLDER <br/>\n";
else 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";
if ($showlist != 0) waplink($S_SUBMIT,$S_VIEWMAIL,"maillist.php",array("page"=>"1","F"=>$F,"U"=>$U,"P"=>$P));
waplink($S_SUBMIT,$S_COMPOSE,"compose.php",array("F"=>$F,"U"=>$U,"P"=>$P));
waplink($S_SUBMIT,$S_CHANGEFOLDER,"index.php",array("U"=>$U,"P"=>$P));
waplink($S_SUBMIT,$S_INFO,"mailinfo.php",array("F"=>$F,"U"=>$U,"P"=>$P));
waplink($S_SUBMIT,$S_LOGOUT,"logout.php",array("F"=>$F,"U"=>$U,"P"=>$P));
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:$IMAPPORT}", "$U", "$P",OP_HALFOPEN) or wmldie ("can't connect: " . imap_last_error());
# s/imap_getmailboxes/imap_getsubscribed/g if you want to get only subscribed folders
if ($CYRUS) $list = imap_getmailboxes($mbox,"\{$IMAPSERVER:$IMAPPORT}","$BASEFOLDER*");
elseif ($COURIER) $list = imap_getmailboxes($mbox,"\{$IMAPSERVER:$IMAPPORT}","$BASEFOLDER.*");
else $list = imap_getmailboxes($mbox,"\{$IMAPSERVER:$IMAPPORT}","$BASEFOLDER/*");
if(is_array($list)) {
reset($list);
echo "<select name=\"F\">\n";
while (list($key, $val) = each($list)) {
if ($CYRUS) {
if (preg_match("/^{.*}($BASEFOLDER(\.(.*))?)$/", imap_utf7_decode($val->name), $match)) {
$F = $match[1];
$FOLDER = empty($match[3])? $F : $match[3];
echo "<option value=\"$F\">$FOLDER</option>\n";
}
} else print "<option value=\"".ereg_replace("/$","",ereg_replace("\{.*.\}","",imap_utf7_decode($val->name)))."\">".ereg_replace("^\.","",ereg_replace("$BASEFOLDER","",ereg_replace("\{.*.\}","",imap_utf7_decode($val->name))))."</option>\n";
}
echo "</select>\n";
} else wmldie ("imap_getmailboxes failed: ".imap_last_error());
imap_close($mbox);
wapbutton(1,$S_SUBMIT,"index.php",array("F"=>"F","U"=>"U","P"=>"P"));
echo "</p>\n";
} 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";
wapbutton(1,$S_SUBMIT,"index.php",array("F"=>"F","U"=>"U","P"=>"P"));
echo "</p>\n";
}
wmlfooter();
?>