Viewing file: ajax.js.php (9.53 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/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']);
//header ("Content-type: text/javascript");
?>
<!--
var response;
var responsetext;
var ie;
var newemail;
var success;
var sound;
var objXMLDOM;
var strFlagIm;
var strTemplate;
// -------------------------------------------
// AJAX message flagger
function markmessage(messageid, strFlagMode, strFolder, strSession, strCurrentTemplate) {
if (window.XMLHttpRequest || window.ActiveXObject) {
strFlagIm = 'flag' + messageid;
strTemplate = strCurrentTemplate;
ajaxMessageFlag('markmessage.php?xml=1&m=' + strFlagMode + '&f=' + strFolder + '&selection=' + messageid + '&' + strSession);
}
else {
window.location = 'markmessage.php?xml=1&m=' + strFlagMode + '&f=' + strFolder + '&selection=' + messageid + '&' + strSession;
}
}
function ajaxMessageFlag(url) {
// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
try {
req = new XMLHttpRequest();
}
catch(e) {
req = false;
}
// branch for IE/Windows ActiveX version
}
else if (window.ActiveXObject) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
req = false;
}
}
}
if(req) {
req.onreadystatechange = ajaxMessageFlagChange;
req.open("GET", url, true);
req.send("");
}
}
function ajaxMessageFlagChange() {
if (req.readyState == 4) {
if (req.status == 200) {
responsetext = req.responseText;
response = req.responseXML.documentElement;
success = response.getElementsByTagName('success')[0].firstChild.data;
if (success == 1) {
var strIm = document[strFlagIm].src;
if (strIm.search(/flag_on/) != -1) {
document[strFlagIm].src = 'templates/' + strTemplate + '/images/mailbox/flag_off.gif';
}
else {
document[strFlagIm].src = 'templates/' + strTemplate + '/images/mailbox/flag_on.gif';
}
}
}
else {
alert ('Error flagging message');
}
}
}
// -------------------------------------------
// New mail AJAX checker
function ajaxCheckNew(url) {
// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
try {
req = new XMLHttpRequest();
}
catch(e) {
req = false;
}
// branch for IE/Windows ActiveX version
}
else if (window.ActiveXObject) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
req = false;
}
}
}
if(req) {
req.onreadystatechange = ajaxCheckNewChange;
req.open("GET", url, true);
req.send("");
}
}
function ajaxCheckNewChange() {
if (req.readyState == 4) {
if (req.status == 200) {
responsetext = req.responseText;
response = req.responseXML.documentElement;
// Deal with new email
newemail = response.getElementsByTagName('new')[0].firstChild.data;
ie = response.getElementsByTagName('ie')[0].firstChild.data;
sound = response.getElementsByTagName('sound')[0].firstChild.data;
if (newemail >= 1) {
if (ie == 1) {
IEPopup();
}
else {
GenericPopup();
}
}
// Deal with folders
objNodeList = response.getElementsByTagName("folder");
for (var i = 0; i < objNodeList.length; i++) {
var dataNodes = objNodeList.item(i);
var oname = dataNodes.getElementsByTagName("name")[0].firstChild.data;
var ototal = dataNodes.getElementsByTagName("total")[0].firstChild.data;
var onew = dataNodes.getElementsByTagName("new")[0].firstChild.data;
var nummess = '';
if (onew > 0) {
nummess = ototal + " <span class=\"messagecountnew\">(" + onew + ")</span>";
}
else {
nummess = ototal;
}
var onamea = 'f' + oname;
var olinka = 'l' + oname;
document.getElementById(onamea).innerHTML = nummess;
if (onew > 0) {
document.getElementById(olinka).className = 'folderpanenew';
}
else {
document.getElementById(olinka).className = 'folderpane';
}
nummess = '';
}
}
else {
top.window.status='Error checking for new email';
}
}
}
// -------------------------------------------
// New mail pop-up
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)') {
window.clearInterval(DoPopUp);
DoPopUp = -1;
window.setTimeout('closeNewMailNotify()', 15000);
}
}
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>";
if (sound == 1) {
szHTML = szHTML + "<object classid='clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95' style='display:none'><param name='ShowDisplay' value='none' /><param name='ShowControls' value='none' /><param name='uiMode' value='none' /><param name='loop' value='false' /><param name='autoplay' value='true' /><param name='FileName' value='./templates/<?php echo $_SESSION['tpl']; ?>/notify.wav' /></object>";
}
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();
}
// -----------------------------------
// Create an IE windowless pop-up
function IEPopup() {
w_nmn = window.createPopup();
DoPopUp = -1;
FadeNewMailNotify.opacity = 0;
FadeNewMailNotify.dimY = 0;
FadeNewMailNotify.dimX = 0;
DisplayNewMailNotify();
}
// Create a cross-browser pop-up
function GenericPopup() {
if (confirm('<?php echo str_replace("'", "\'", $lang['NewEmailAlert'] ); ?>') == true) {
<?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();\r\n");
}
}
else {
echo ("parent.location = './mailbox.php?f=INBOX&" . strip_tags(SID) . "';\r\n");
}
?>
}
}
//-->
|