<?
// $Header: /cvsroot/jwapmail/Jwapmail/html/wml.lib.php,v 1.9 2004/01/23 05:04:16 nasir Exp $
/**********************************************************************
*
* a libray used for IMAP client
*
* Copyright (C) 2002 3WSI <http://3wsi.com)
*
* Author : Nasir Simbolon <hide@address.com>
*
* This program is open source; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License <http://www.opensource.org/licenses/gpl-license.html>
* for a complete version of the license
*
**********************************************************************/
function wmlLoginform ($iscard = 0, $cardid = '', $cardtitle = '') {
global $wmlout;
if ($iscard)
$wmlout .= "<card id=\"$cardid\" title=\"$cardtitle\">";
$wmlout .=
'<p>
Server
<input name="host" size="15" maxlength="256" value="' .
DEFAULT_SERVER_HOST . ':' . DEFAULT_SERVER_PORT . '"/>
Username
<input name="username" size="15" maxlength="32" />
Password
<input type="password" name="password" size="15"
maxlength="32" />
</p>
<p>
<do type="accept" label="Login">
<go method="get" href="' . $_SERVER['PHP_SELF'] . '">
<postfield name="host" value="$(host)" />
<postfield name="username" value="$(username)" />
<postfield name="password" value="$(password)" />
</go>
</do>
</p>';
if ($iscard)
$wmlout .= "</card>";
}
function wmlLoginfailed () {
global $wmlout;
$wmlout .= '<card id="login" title="Login failed">
<p>Login failed</p>
<p>try again</p>';
$wmlout .= wmlLoginform ();
$wmlout .= "</card>";
jExit ();
}
function wmlMessage ($msg) {
global $wmlout;
$wmlout .= '<p>' . wmlentities ($msg) . '</p>';
}
function wmlBegin () {
global $wmlout;
$wmlout = "<wml>";
}
function wmlEnd () {
global $wmlout;
$wmlout .= "</wml>";
}
function wmlNewcard ($cardid = '', $cardtitle = '', $timer = '') {
global $wmlout;
if ($timer == '') {
$wmlout .= '<card id="' . $cardid . '" title="' . $cardtitle . '">';
}
else {
$wmlout .= '<card id="' . $cardid . '" title="' . $cardtitle .
'" ontimer="' . $_SERVER['PHP_SELF'] . '">';
$wmlout .= '<timer value="' . $timer . '"/>';
}
}
function wmlEndcard () {
global $wmlout;
$wmlout .= '</card>';
}
function jExit ($wmlclosedtag = 1, $echo = 1) {
global $wmlout;
if ($wmlclosedtag)
wmlEnd ();
if ($echo)
echo $wmlout;
exit;
}
function jIsloggedin () {
global $wmlout;
if (! is_set_and_not_empty($_GET['username']) &&
! is_set_and_not_empty($_SESSION['username'])) {
wmlLoginform (1, 'login', 'Log in Wapmail');
jExit ();
}
}
function wmlListmbox ($mailbox, $totmsg, $newmsg) {
global $wmlout;
$totmbox = count($mailbox);
$wmlout .= "<p>";
for ($i = $totmbox - 1; $i > 0; $i--) {
if ($newmsg[$mailbox[$i]] != 0) {
$wmlout .= '<b>';
}
$wmlout .= '<anchor>' . wmlentities ($mailbox[$i]) . ' (' .
(int)$newmsg[$mailbox[$i]] . '/' . (int)$totmsg[$mailbox[$i]] .
")<go href=\"" . $_SERVER['PHP_SELF'] . '?page=headers&mbox=' .
urlencode ($mailbox[$i]) . '&msgnum=' . (int)$totmsg[$mailbox[$i]] .
'&' . session_name () . '=' . session_id() . "\" /></anchor>";
if ($newmsg[$mailbox[$i]] != 0) {
$wmlout .= '</b>';
}
$wmlout .= "<br/>\n";
}
$wmlout .= '</p>';
}
function wmlCompose ($to = '', $cc = '',$subject = '', $body = '',
$bcc = '') {
global $wmlout;
$wmlout .= '
<p>To: <input name="to" value="' . wmlentities ($to) . '"/></p>
<p>Cc: <input name="cc" value="' . wmlentities ($cc) . '"/></p>
<p>Bcc: <input name="bcc" /></p>
<p>Subject: <input name="subject" value="' . wmlentities ($subject) .
'"/></p>
<p>Message: <input name="body" type="text" /></p>
<p>
<do type="accept" label="Send">
<go method="get" href="' . $_SERVER['PHP_SELF'] . '">
<postfield name="to" value="$(to)" />
<postfield name="cc" value="$(cc)" />
<postfield name="bcc" value="$(bcc)" />
<postfield name="subject" value="$(subject)" />
<postfield name="body" value="$(body)" />
<postfield name="send" value="1" />
<postfield name="' . session_name () . '" value="' .
session_id () . '" />
</go>
</do>
</p>';
}
function wmlMenu1 () {
global $wmlout;
$wmlout .=
'<p>
<anchor>Compose
<go href="' . WEB_SERVER_BASE_PATH . 'index.php?' . session_name () . '='
. session_id() . '&page=compose" />
</anchor>
</p>
<p>
<anchor>Folders
<go href="' . WEB_SERVER_BASE_PATH . 'index.php?' . session_name () . '='
. session_id() . '&page=folders" />
</anchor>
</p>
<p>
<anchor>Logout
<go href="' . WEB_SERVER_BASE_PATH . 'index.php?' . session_name () . '='
. session_id() . '&page=logout" />
</anchor>
</p>';
}
function wmlListmsg ($header, $offset = 0, $flag = 0) {
global $wmlout, $nummsglist;
$total = count ($header);
if ($total == 0) {
$wmlout .= '<p>No messages in the mailbox</p>';
return;
}
$wmlout .= '<p>List of message in ' . urldecode ($_GET['mbox']) . '</p>';
$content = '';
$t = $nummsglist + $offset;
for($i = $offset; $i < $total && $i < $t; $i++) {
$content .=
'<p>' . date ('d.m. H:i', strtotime ($header[$i]['Date'])) .
'. From: ' . wmlentities ($header[$i]['From']) . '<br />' .
' Subject: <anchor>' . wmlentities ($header[$i]['Subject']) .
' <go href="' . $_SERVER['PHP_SELF'] . '?page=body&mbox=' .
urlencode ($_GET['mbox']) . '&msgno=' . $header[$i]['msgno'] .
'&' . session_name () . '=' . session_id () .
'" /></anchor></p>';
}
$wmlout .= $content;
$wmlout .= '';
}
function wmlPaging ($nummsglist, $total, $url, $offset) {
$out= '';
$i = $offset + $nummsglist;
$j = $offset - $nummsglist;
if ($i < $total && $j >= 0)
$out .=
'<p>
<anchor>Less
<go href="' . $url . '&offset=' . $j .
'&' . session_name () . '=' . session_id() . '" />
</anchor>
<anchor>More
<go href="' . $url. '&offset=' . $i .
'&' . session_name () . '=' . session_id() . '" />
</anchor>
</p>';
elseif ($i < $total)
$out .=
'<p>
<anchor>More
<go href="' . $url . '&offset=' . $i .
'&' . session_name () . '=' . session_id() . '" />
</anchor>
</p>';
elseif ($j >= 0)
$out .=
'<p>
<anchor>Less
<go href="' . $url . '&offset=' . $j .
'&' . session_name () . '=' . session_id() . '" />
</anchor>
</p>';
return $out;
}
function wmlSwitchcard ($nextcardid, $option = "Options") {
global $wmlout;
$wmlout .=
'<p>
<anchor>' . $option .
'<go href="' . $_SERVER['PHP_SELF'] . '?' .
wmlentities (getenv ('QUERY_STRING')) . '#' . $nextcardid . '" />
</anchor>
</p>';
}
function wmlPrevcard () {
global $wmlout;
$wmlout .=
'<p>
<anchor>Back
<prev/>
</anchor>
</p>';
}
function wmlIndexCard () {
global $wmlout;
$wmlout .=
'<p>
<anchor>Index
<go href="' . WEB_SERVER_BASE_PATH . 'index.php?' . session_name () .
'=' . session_id () .'&page=" />
</anchor>
</p>';
}
function wmlMsgmenu ($mbox, $msgno) {
global $wmlout;
$wmlout .=
'<p>
<anchor>Reply
<go href="' . WEB_SERVER_BASE_PATH .'index.php?page=compose&' .
'action=reply&mbox=' . $mbox . '&msgno=' . $msgno . '&'
. session_name () . '=' . session_id() . '" />
</anchor>
</p>
<p>
<anchor>Reply to All
<go href="' . WEB_SERVER_BASE_PATH . 'index.php?page=compose&' .
'action=replyall&mbox=' . $mbox . '&msgno=' . $msgno .
'&' . session_name () . '=' . session_id() . '" />
</anchor>
</p>
<p>
<anchor>Forward
<go href="' . WEB_SERVER_BASE_PATH . 'index.php?page=compose&' .
'action=forward&mbox=' . $mbox . '&msgno=' . $msgno .
'&' . session_name () . '=' . session_id() . '" />
</anchor>
</p>
<p>
<anchor>Delete
<go href="' . WEB_SERVER_BASE_PATH . 'index.php?page=manage&' .
'action=delete&mbox=' . $mbox . '&msgno=' . $msgno .
'&' . session_name () . '=' . session_id() . '" />
</anchor>
</p>
<p>
<anchor>Move to Folder
<go href="' . WEB_SERVER_BASE_PATH . 'index.php?page=manage&' .
'action=move&mbox=' . $mbox . '&msgno=' . $msgno . '&'
. session_name () . '=' . session_id () . '" />
</anchor>
</p>';
}
function wmlHeadermsg ($from, $date, $subject) {
$out =
'<p>From: ' . wmlentities ($from) . '</p>
<p>Date: ' . date ('d.m.Y H:i:s', strtotime ($date)) . '</p>
<p>Subject: ' . wmlentities ($subject) . '</p>';
return $out;
}
function wmlLogout () {
global $wmlout;
$wmlout .= '<p>You have been successfully logged out</p>';
}
?>