Viewing file: checknew.php (9.76 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/*
############################################################################
# DWmail
# - version 4.0
# - Copyright (c) 2003-2006 Dominion Web Design
# - http://www.dominion-web.com/products/dwmail/
############################################################################
#
# The contents of this file are subject to the DWmail License version
# 2.2 ('License'). You may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.dominion-web.com/products/dwmail/license.php
# Software distributed under the License is distributed on an "AS IS" basis,
# without warranty of any kind, either express or implied.
#
# This code is Copyright (c) 2003-2006 Dominion Web Design.
# All rights reserved.
#
# This software may not be redistributed outside the terms of the
# license agreement.
#
############################################################################
*/
require ("./includes/init.inc.php");
require ("./includes/global.inc.php");
require ("./includes/imap.inc.php");
require ("./includes/functions.inc.php");
require ("./includes/browser.inc.php");
require ("./includes/config.inc.php");
$MainSettings = new GlobalInit();
$TransIDEnabled = $MainSettings->INIGet('session.use_trans_sid');
session_cache_limiter($DefaultSessionCache);
session_start();
if (!$_SESSION['DefaultLang']) {
$_SESSION['DefaultLang'] = $DefaultLang;
}
require ("./lang/" . strip_tags(trim($_SESSION['DefaultLang'])) . "/global.inc.php");
@setlocale(LC_TIME, $AvailLangs[$_SESSION['DefaultLang']]['locale']);
require ("./includes/options.inc.php");
if ($newmailmode == 2) {
header ("Content-Type: text/xml; charset=UTF-8");
}
else {
header ("Content-Type: text/html; charset=" . $_SESSION['DefaultCharSet']);
}
if (($_SESSION['sess_u'] == "") && ($_SESSION['sess_p'] == "")) {
echo ("<p>" . $lang['SErrors']['Session'] . "</p>");
exit;
}
$IMAPConnection = new WM_IMAPConnection($_SESSION);
$securitycheck = $IMAPConnection->WM_IMAPCheckSecurity();
if ($securitycheck == 0) {
echo ("<p>" . $lang['SErrors']['IP'] . "</p>");
exit;
}
$mailbox = $IMAPConnection->WM_IMAPConnect();
if ($_GET['check'] == 1) {
$imapstatus = $IMAPConnection->WM_IMAPStatus('INBOX');
if ($_SESSION['servertype'] == "imap" || $_SESSION['servertype'] == "imapssl") {
$numberofmessages = $imapstatus->unseen;
}
else {
$numberofmessages = $imapstatus->messages;
}
}
$messagealert = 0;
if ($_SESSION['IT'] < $numberofmessages && $_GET['check'] == 1) {
$messagealert = 1;
$_SESSION['IT'] = $numberofmessages;
}
$isIE = 0;
if (($bd['browser'] == "MSIE") && ($bd['version'] >= 6.0)) {
$isIE = 1;
}
elseif (($bd['browser'] == "MSIE") && ($bd['version'] == 5.5)) {
$isIE = 1;
}
$PlaySoundfile = 0;
if (file_exists('./templates/' . $_SESSION['tpl'] . '/notify.wav') && $PlaySound == 1) {
$PlaySoundfile = 1;
}
if ($newmailmode == 2) {
if ($_SERVER['HTTPS'] == "on") {
$currenturl = 'https://';
}
else {
$currenturl = 'http://';
}
$currenturl .= $_SERVER["HTTP_HOST"];
$directory = str_replace("checknew.php", "", $_SERVER["PHP_SELF"]);
$currenturl .= $directory;
echo ('<?xml version="1.0" encoding="UTF-8" ?>' . "\n");
echo ('<!DOCTYPE DWmail SYSTEM "' . $currenturl . 'scripts/checknew.dtd">');
?>
<DWmail>
<new><?php echo $messagealert; ?></new>
<ie><?php echo $isIE; ?></ie>
<sound><?php echo $PlaySoundfile; ?></sound>
<folders>
<?php
if ($_SESSION['servertype'] == "imap" || $_SESSION['servertype'] == "imapssl") {
// Update folder totals here too
$folderget = $IMAPConnection->WM_IMAPFolders($IMAPSubscriptions);
$folders = $IMAPConnection->_folders;
$newfolder = $IMAPConnection->WM_IMAPReOpen('', 1);
for($i=0; $i<count($folders); $i++) {
$foldertemp = $PageFolderLinks;
$imapstatus = $IMAPConnection->WM_IMAPStatus($folders[$i]['id']);
$numberofmessages = $imapstatus->messages;
$numberofnewmessages = $imapstatus->unseen;
echo ("<folder id=\"" . urlencode($folders[$i]['id']) . "\"><name>" . urlencode($folders[$i]['id']) . "</name><total>$numberofmessages</total><new>$numberofnewmessages</new></folder>\n");
}
}
?>
</folders>
</DWmail>
<?php
}
else {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php echo $_SESSION['DefaultLang']; ?>" dir="<?php echo $AvailLangs[$_SESSION['DefaultLang']]['dir']; ?>">
<head>
<title>DWmail</title>
<meta http-equiv="expires" content="now" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="refresh" content="<?php echo $newmail; ?>;URL=checknew.php?check=1&<?php echo strip_tags(SID); ?>" />
<bgsound id="notifysound" loop="1" />
<script language="javascript" type="text/javascript">
<?php
if ($_SESSION['servertype'] == "imap" || $_SESSION['servertype'] == "imapssl") {
// Update folder totals here too
$folderget = $IMAPConnection->WM_IMAPFolders($IMAPSubscriptions);
$folders = $IMAPConnection->_folders;
$newfolder = $IMAPConnection->WM_IMAPReOpen('', 1);
for($i=0; $i<count($folders); $i++) {
$foldertemp = $PageFolderLinks;
$imapstatus = $IMAPConnection->WM_IMAPStatus($folders[$i]['id']);
$numberofmessages = $imapstatus->messages;
$numberofnewmessages = $imapstatus->unseen;
if ($numberofnewmessages > 0) {
$numberofmessages .= " <span class=\"messagecountnew\">($numberofnewmessages)</span>";
echo ("parent.document.getElementById('l" . urlencode($folders[$i]['id']) . "').className = 'folderpanenew'");
}
else {
echo ("parent.document.getElementById('l" . urlencode($folders[$i]['id']) . "').className = 'folderpane'");
}
echo ("parent.document.getElementById('f" . urlencode($folders[$i]['id']) . "').innerHTML = '<font size=\"1\">$numberofmessages</font>';\n");
}
}
?>
</script>
<?php
if ($messagealert == 1 && $isIE == 0) {
echo ("
<script language=\"javascript\" type=\"text/javascript\">
if (confirm('" . str_replace("'", "\'", $lang['NewEmailAlert']) . "') == true) {
");
if ($_SESSION['fs'] == 1) {
echo ("parent.parent.document.getElementById('mailbox').src = './mailbox.php?f=INBOX&" . strip_tags(SID) . "';\r\n");
if ($PreviewPane == 1) {
echo ("parent.RestorePreview();\r\n");
}
}
else {
echo ("parent.location = './mailbox.php?f=INBOX&" . strip_tags(SID) . "';\r\n");
}
echo ("}
</script>");
}
if ($messagealert == 1 && $isIE == 1) {
?>
<script language="javascript" type="text/javascript">
w_nmn = window.createPopup();
function playSound() {
notifysound.src = './templates/<?php echo $_SESSION['tpl']; ?>/notify.wav';
}
function closeNewMailNotify() {
if(null != w_nmn) {
DoPopUp = window.setInterval(UnloadNewMailNotify,25);
}
}
function UnloadNewMailNotify() {
FadeNewMailNotify.opacity -= 1;
if(null != w_nmn) {
var nmnBody = w_nmn.document.body;
nmnBody.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + FadeNewMailNotify.opacity + ')';
if (nmnBody.style.filter == 'progid:DXImageTransform.Microsoft.Alpha(opacity=0)') {
w_nmn.hide();
}
}
}
function CalcScreenSize() {
FadeNewMailNotify.dimY = window.screen.height;
FadeNewMailNotify.dimX = window.screen.width;
}
function FadeNewMailNotify() {
FadeNewMailNotify.opacity += 1;
w_nmn.show(FadeNewMailNotify.dimX, FadeNewMailNotify.dimY-95, 200, 65);
var nmnBody = w_nmn.document.body;
nmnBody.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + FadeNewMailNotify.opacity + ')';
if (nmnBody.style.filter == 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)') {
<?php
if ($PlaySoundfile == 1) {
echo (" playSound();");
}
?>
window.clearInterval(DoPopUp);
DoPopUp = -1;
window.setTimeout('closeNewMailNotify()', 15000);
}
}
DoPopUp = -1;
FadeNewMailNotify.opacity = 0;
FadeNewMailNotify.dimY = 0;
FadeNewMailNotify.dimX = 0;
function DisplayNewMailNotify() {
if (null == w_nmn) {
return;
}
var nmnBody = w_nmn.document.body;
var szHTML = "<table height='100%' align='right' width='100%' cellpadding='1' cellspacing='1'><tr><td width='61'> </td><td align='middle' align='center'>"+
"<a href=\"#\" style='color:#000066; font-size:11px;'><?php echo str_replace("'", "\'", $lang['NewEmailAlert']); ?></a><br /><div></div>"+
"</td></tr></table>";
nmnBody.innerHTML = szHTML;
nmnBody.style.fontSize = '11px';
nmnBody.style.backgroundColor='#FFFFFF';
nmnBody.style.cursor="hand";
nmnBody.style.color = "#000000";
nmnBody.style.fontFamily = "Tahoma, Arial, Hevetica";
nmnBody.style.backgroundImage='url(<?php echo ("templates/" . $_SESSION['tpl'] . "/images/"); ?>newmailnotify.gif)';
nmnBody.style.borderStyle='none';
nmnBody.style.backgroundColor='transparent';
nmnBody.onclick = ShowInbox;
CalcScreenSize();
DoPopUp = window.setInterval(FadeNewMailNotify,25);
}
function ShowInbox() {
window.top.focus();
<?php
if ($_SESSION['fs'] == 1) {
echo ("parent.parent.document.getElementById('mailbox').src = './mailbox.php?f=INBOX&" . strip_tags(SID) . "';\r\n");
if ($PreviewPane == 1) {
echo ("parent.RestorePreview();");
}
}
else {
echo ("parent.location = './mailbox.php?f=INBOX&" . strip_tags(SID) . "';\r\n");
}
?>
if(-1 != DoPopUp) {
window.clearInterval(DoPopUp);
DoPopUp = -1;
}
closeNewMailNotify();
}
DisplayNewMailNotify();
</script>
<?php
}
?>
</head>
<body>
<?php
if ($messagealert == 1 && $isIE == 0 && $PlaySoundfile == 1) {
echo ("<embed src=\"templates/" . $_SESSION['tpl'] . "/notify.wav\" hidden=\"true\" border=\"0\" width=\"1\" height=\"1\" autostart=\"true\" autoplay=\"true\" />");
}
?>
</body>
</html>
<?php
}
$IMAPConnection->WM_IMAPClose();
?>
|