<?php
/*
Copyright (c) 2005-2006 Colorado State Univeristy
All rights reserved.
Please contact Kyle Haefner hide@address.com
for changes, bug notices or feature requests
This program is free software; 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 for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
session_start();
if ($_SESSION[mailbox] =="")
{
header("Location: ./logoff.php");
}
//get timeout information
//This will be passed to a javascript varaible used to set a
//countdown timer
$tmp = session_get_cookie_params();
$countdown = $tmp[lifetime];
//What page are we on if varibale blank we are on first page
$page = $_GET[page];
if($page =="")
$page=1;
//Set the maximum displayed per page this should be remembered in a database
$PAGE_MAX =6;
//Include class files
include ("mailbox.class.php");
include ("message.class.php");
include ("folder.class.php");
//include config file
include_once ("config/vmail_conf.php");
//$active varaibles used to set which list itme in the
//folder navigation is active
$aInbox="";
$aOld="";
$aWork="";
$aFamily="";
$aFriends="";
$aResearch="";
$aSchool="";
//make the folders
$Inbox = new Folder($_SESSION[mailbox],INBOX);
$Old = new Folder($_SESSION[mailbox],Old);
$Work = new Folder($_SESSION[mailbox],Work);
$Family = new Folder($_SESSION[mailbox],Family);
$Friends = new Folder($_SESSION[mailbox],Friends);
$Research = new Folder($_SESSION[mailbox],Research);
$School = new Folder($_SESSION[mailbox],School);
//Array of folder objects
$Folders = array($Inbox,$Old,$Work,$Family,$Friends,$Research,$School);
$Mbox = new Mailbox("$_SESSION[mailbox]");
//Set the current folder
switch ($_GET[folder])
{
case "INBOX":
$Mbox->currentFolder = $Inbox;
$aInbox="active";
break;
case "Old":
$Mbox->currentFolder = $Old;
$aOld="active";
break;
case "Work":
$Mbox->currentFolder = $Work;
$aWork="active";
break;
case "Family":
$Mbox->currentFolder = $Family;
$aFamily="active";
break;
case "Friends":
$Mbox->currentFolder = $Friends;
$aFriends="active";
break;
case "Research":
$Mbox->currentFolder = $Research;
$aResearch="active";
break;
case "School":
$Mbox->currentFolder = $School;
$aSchool="active";
break;
default:
$Mbox->currentFolder = $Inbox;
$aInbox="active";
break;
}
?>
<html>
<head>
<title><?php print $page_title;?></title>
<link rel='stylesheet' type='text/css' href='vmail2.css' />
<script src="vmail.js">
</script>
</head>
<?php print "<body onLoad=\"countDown(".$countdown.")\">"; ?>
<div id="container">
<div id="logo">
<?php print "<a href=\"$logo_url\"><img src=\"$logo\" border=0></a>";?>
</div>
<div class="top">
<?php
print "<h1 id='welcome'>Welcome $_SESSION[name]</h1>";
?>
</div>
<div id="toolbar">
<?php
include("toptools.php");
?>
</div>
<div id="alert">
<?php
if ($_GET[info]=="")
{
if($Mbox->currentFolder->name == "Old")
{
$foldername = "Saved";
}
else
{
$foldername = $Mbox->currentFolder->name;
}
//people with more than one mailbox
if($_SESSION[manyboxes] !="")
print "<h2 class='info'>Mailbox: $_SESSION[mailbox] Current Folder: ".$foldername."</h2>";
else
print "<h2 class='info'>Current Folder: ".$foldername."</h2>";
}
else
{
print "<h2 class='info'>$_GET[info]</h2>";
}
?>
</div>
<div id="leftnav">
<h3 class="label">Folders</h3>
<ul id="navlist">
<?php
print "
<li id='$aInbox'><a href='vmail.php?folder=Inbox'>INBOX ($Inbox->numMsgs)</a></li>
<li id='$aOld'><a href='vmail.php?folder=Old'>Saved ($Old->numMsgs)</a></li>
<li id='$aWork'><a href='vmail.php?folder=Work'>Work ($Work->numMsgs)</a></li>
<li id='$aFamily'><a href='vmail.php?folder=Family'>Family ($Family->numMsgs)</a></li>
<li id='$aFriends'><a href='vmail.php?folder=Friends'>Friends ($Friends->numMsgs)</a></li>
<li id='$aResearch'><a href='vmail.php?folder=Research'>Research ($Research->numMsgs)</a></li>
<li id='$aSchool'><a href='vmail.php?folder=School'>School ($School->numMsgs)</a></li>
</ul>
</div>";
$pages = floor($Mbox->currentFolder->numMsgs/$PAGE_MAX)+1; //add one human readable page =1, not 0
If($Mbox->currentFolder->numMsgs%$PAGE_MAX >0)
$pages++;
print "<div id='pager'>";
if($page > 1)
print "<a href=vmail.php?folder=".$Mbox->currentFolder->name."&page=".($page-1)." ><img src='images/leftarrow.gif' border =0></a>";
for($i=1;$i<$pages;$i++)
{
if($i != $page)
print "<a href=vmail.php?folder=".$Mbox->currentFolder->name."&page=".$i." > ".$i." </a> ";
else
print "<em>".$i."</em> ";
}
if(($page != ($pages-1))&&($pages>1))
print "<a href=vmail.php?folder=".$Mbox->currentFolder->name."&page=".($page+1)." ><img src='images/rightarrow.gif' border =0></a>";
print "</div>";
print "<form name='myMsgs' method='POST' action=''>";
?>
<div id="content">
<div class ="msghead">
<table>
<tr>
<th width="5%"><input type="checkbox" alt="Check All" title="Check All" id="checkall" onchange="checker(<?php print"".$Mbox->currentFolder->numMsgs; ?>)"></th>
<th width="10%">#</th>
<th width ="35%">From</th>
<th width ="30%">Date</th>
<th width ="10%">Duration</th>
<th width="10%">Listen</th></tr>
<?php
if ($Mbox->currentFolder->numMsgs == 0)
{
print "<tr><td colspan='6' width='90%' align='center'>No messages</td></tr>";
}
else
{
$fullArray = $Mbox->currentFolder->msgs;
arsort($fullArray);
$numMsgs=$Mbox->currentFolder->numMsgs;
$start=$page*$PAGE_MAX-$PAGE_MAX;
$msgArray = array_splice($fullArray,$start,$PAGE_MAX);
$msgCount =$start;
foreach($msgArray as $msg=>$origtime)
{
$message = new Message($Mbox->number,$Mbox->currentFolder->name,$msg);
$duration = floor(($message->length)/60).":".sprintf("%02d",(($message->length)%60));
$sender = $message->sender;
$date = $message->datesent;
$folder = $Mbox->currentFolder->name;
/*if the current folder is INDOX then move to old else just play*/
if($folder == "INBOX")
{
$url = "move.php?currentFolder=$folder&destFolder=Old&msg=$msg&action=play";
}
else
{
$url = "play.php?folder=$folder&message=$msg";
}
print "
<tr>
<td width='5%' align='center'><input type='checkbox' name='messages[]' id='checkbox$msgCount' value='$msg'></td>
<td width='5%' align='center'>".($msgCount+1)."</td>
<td width ='35%'>$sender </td>
<td width ='35%' align='center'>$date</td>
<td width ='10%' align='center'>$duration</td>
<td width='10%'>
<a href='$url'><img src='images/play.gif' border=0></a></td></tr>
";
$msgCount++;
}
}
?>
</table>
</div>
<div class='play_placekeeper'></div>
</div>
<input id="msgaction" name="msgaction" type="hidden">
</form>
<div id="placeholder"></div>
<div id="leftbottom"> </div>
<div id="rightbottom"> </div>
<div id="bottom"></div>
</div>
<div class="footer"><?php include("footer.php")?></div>
</body>
</html>