View file pofhq-wapmail/maillist.php

File size: 3.93Kb
<?
/*
$Header: /home/cvsroot/pofhq-wapmail/maillist.php,v 1.3 2002/12/12 20:49:57 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();

$mbox = imap_open ("\{$IMAPSERVER:$IMAPPORT}$F", "$U", "$P") or wmldie ("can't connect: " . imap_last_error());
$mailnr = imap_num_msg ($mbox);
$mail_page = $page - 1;
$pages = ceil($mailnr / $MAILSBYPAGE);

if ($CYRUS) {
	$FOLDER = preg_replace("/^$BASEFOLDER\./", "", $F);
	print "<card id=\"maillist\" title=\"$U's $FOLDER\">\n";
} else print "<card id=\"maillist\" title=\"$U's $F\">\n";

if ($page == 0 or $page > $pages) echo "<p>$S_NOMORE</p>\n";

elseif ($pages == 1) {
	for ($count = $mailnr - $mail_page * $MAILSBYPAGE, $countstop = 0; $count > $countstop; $count--){
		$header = imap_header ($mbox, $count, 100, 100, 0);
		$msgsubject = getsubject($header->fetchsubject);
		echo "<p mode=\"nowrap\">\n";
		echo "<small>\n";
		if ( $header->Unseen == "U" || $header->Recent =="N" ) echo "<b>";
		waplink($S_SUBMIT,$msgsubject,"mailview.php",array("page"=>$page,"msgid"=>$count,"F"=>$F,"U"=>$U,"P"=>$P));
		if ( $header->Unseen == "U" || $header->Recent =="N" ) echo "</b>";
		echo "</small>\n";
		echo "</p>\n";
	}
	echo "<p>$S_NOMORE</p>\n";
}

elseif ($page == 1) {

	for ($count = $mailnr - $mail_page * $MAILSBYPAGE, $countstop = $mailnr - $page * $MAILSBYPAGE; $count > $countstop; $count--){
		$header = imap_header ($mbox, $count, 100, 100, 0);
		$msgsubject = getsubject($header->fetchsubject);
		echo "<p mode=\"nowrap\">\n";
		echo "<small>\n";
		if ( $header->Unseen == "U" || $header->Recent =="N" ) echo "<b>";
		waplink($S_SUBMIT,$msgsubject,"mailview.php",array("page"=>$page,"msgid"=>$count,"F"=>$F,"U"=>$U,"P"=>$P));
		if ( $header->Unseen == "U" || $header->Recent =="N" ) echo "</b>";
		echo "</small>\n";
		echo "</p>\n";
	}

	/* previous */
	echo "<p align=\"center\">\n";
	waplink($S_SUBMIT,$S_PREVIOUS,"maillist.php",array("page"=>"2","F"=>$F,"U"=>$U,"P"=>$P));
	echo "</p>\n";
}

elseif ($page < $pages and $page != 1) {

	/* next */
	echo "<p align=\"center\">\n";
	$next_page = $page - 1;
	waplink($S_SUBMIT,$S_NEXT,"maillist.php",array("page"=>$next_page,"F"=>$F,"U"=>$U,"P"=>$P));
	echo "</p>\n";

	for ($count = $mailnr - $mail_page * $MAILSBYPAGE, $countstop = $mailnr - $page * $MAILSBYPAGE; $count > $countstop; $count--){
		$header = imap_header ($mbox, $count, 100, 100, 0);
		$msgsubject = getsubject($header->fetchsubject);
		echo "<p mode=\"nowrap\">\n";
		echo "<small>\n";
		if ( $header->Unseen == "U" || $header->Recent =="N" ) echo "<b>";
		waplink($S_SUBMIT,$msgsubject,"mailview.php",array("page"=>$page,"msgid"=>$count,"F"=>$F,"U"=>$U,"P"=>$P));
		if ( $header->Unseen == "U" || $header->Recent =="N" ) echo "</b>";
		echo "</small>\n";
		echo "</p>\n";
	}

	/* previous */
	echo "<p align=\"center\">\n";
	$prev_page = $page + 1;
	waplink($S_SUBMIT,$S_PREVIOUS,"maillist.php",array("page"=>$prev_page,"F"=>$F,"U"=>$U,"P"=>$P));
	echo "</p>\n";
}

elseif($page = $pages and $pages != 1 ) {

	/* next */
	echo "<p align=\"center\">\n";
	$next_page = $page - 1;
	waplink($S_SUBMIT,$S_NEXT,"maillist.php",array("page"=>$next_page,"F"=>$F,"U"=>$U,"P"=>$P));
	echo "</p>\n";

	for ($count = $mailnr - $mail_page * $MAILSBYPAGE, $countstop = 0; $count > $countstop; $count--){
		$header = imap_header ($mbox, $count, 100, 100, 0);
		$msgsubject = getsubject($header->fetchsubject);
		echo "<p mode=\"nowrap\">\n";
		echo "<small>\n";
		if ( $header->Unseen == "U" || $header->Recent =="N" ) echo "<b>";
		waplink($S_SUBMIT,$msgsubject,"mailview.php",array("page"=>$page,"msgid"=>$count,"F"=>$F,"U"=>$U,"P"=>$P));
		if ( $header->Unseen == "U" || $header->Recent =="N" ) echo "</b>";
		echo "</small>\n";
		echo "</p>\n";
	}
}

/* always add a button to return to index */
echo "<p>\n";
wapbutton(0,$S_INDEX,"index.php",array("F"=>$F,"U"=>$U,"P"=>$P));
echo "</p>\n";

imap_close($mbox);

wmlfooter();
?>