Location: PHPKode > scripts > AfterLogic WebMail Lite PHP > afterlogic-webmail-lite-php/webmail/webmail.php
<?php

/*
 * AfterLogic WebMail Pro PHP by AfterLogic Corp. <hide@address.com>
 *
 * Copyright (C) 2002-2010  AfterLogic Corp. (www.afterlogic.com)
 * Distributed under the terms of the license described in COPYING
 * 
 */

	defined('WM_ROOTPATH') || define('WM_ROOTPATH', (dirname(__FILE__).'/'));
	
	require_once(WM_ROOTPATH.'common/inc_constants.php');
	
	@ob_start(USE_INDEX_GZIP ? 'obStartGzip' : 'obStartNoGzip');

	require WM_ROOTPATH.'common/class_session.php';

	require_once(WM_ROOTPATH.'common/class_account.php');
	
	if (!isset($_SESSION[ACCOUNT_ID]))
	{
		if (USE_DB && isset($_COOKIE['awm_autologin_data']) && isset($_COOKIE['awm_autologin_id']))
		{
			$account = &Account::LoadFromDb($_COOKIE['awm_autologin_id'], false, false);
			if ($account != null && $_COOKIE['awm_autologin_data'] == 
					md5(ConvertUtils::EncodePassword($account->MailIncPassword, $account)))
			{
				$_SESSION[ACCOUNT_ID] = $account->Id; 
				$_SESSION[USER_ID] = $account->IdUser;
				$_SESSION[SESSION_LANG] = $account->DefaultLanguage;
			}
		}
	}
	
	if (!isset($_SESSION[ACCOUNT_ID]))
	{
		header('Location: index.php?error=1');
		exit;
	}

	$check = isset($_GET['check']) ? $_GET['check'] : 0;
	$start = isset($_GET['start']) ? $_GET['start'] : 0;
	$to = isset($_GET['to']) ? $_GET['to'] : '';
	$null = null;

	$params = array();
	if ($start > 0)
	{
		$params[] = 'start='.$start;
	}
	if (strlen($to) > 0)
	{
		$params[] = 'to='.$to;
	}
	
	$paramsLine = implode('&', $params);
	
	if ($check)
	{
		$account =& Account::LoadFromDb($_SESSION[ACCOUNT_ID], false, false);
		if (!$account)
		{
			header('Location: index.php?error=2');
			exit();
		}
		
		$_SESSION[SESSION_LANG] = $account->DefaultLanguage;


		$paramsLine = strlen($paramsLine) > 0 ? '?'.$paramsLine : '';
		
		define('G_WEBMAILURL', 'webmail.php'.$paramsLine);
		require_once(WM_ROOTPATH.'check-mail-at-login.php');
	}
	else
	{
		$paramsLine = strlen($paramsLine) > 0 ? '?'.$paramsLine : '';
		
		if (!isset($_GET['iframe']) && defined('USE_IFRAME_WEBMAIL') && strlen(USE_IFRAME_WEBMAIL) > 0)
		{
			header('Location: '.USE_IFRAME_WEBMAIL.$paramsLine);
			exit();
		}

		require_once(WM_ROOTPATH.'common/class_settings.php');
		require_once(WM_ROOTPATH.'common/class_filesystem.php');
		
		$settings =& Settings::CreateInstance();
		if (!$settings || !$settings->isLoad)
		{
			header('Location: index.php?error=3');
			exit();		
		}
		elseif (!$settings->IncludeLang())
		{
			header('Location: index.php?error=6');
			exit();			
		}
		
		$nAcct = isset($_GET['nacct']) ? (int) $_GET['nacct'] : null;
	
		if ($nAcct !== null  && USE_DB)
		{
			$dbStorage =& DbStorageCreator::CreateDatabaseStorage($null);
			if ($dbStorage->Connect() && $dbStorage->IsAccountInRing($_SESSION[ACCOUNT_ID], $nAcct))
			{
				$_SESSION[ACCOUNT_ID] = $nAcct;
			}
			else 
			{
				header('Location: index.php?error=2');
				exit();	
			}
		}
		
		$account =& Account::LoadFromDb($_SESSION[ACCOUNT_ID]);
		if (!$account)
		{
			header('Location: index.php?error=2');
			exit();
		}
		
		define('defaultTitle', $settings->WindowTitle);
		$skins =& FileSystem::GetSkinsList();
	
		$hasDefSettingsSkin = false;
		foreach ($skins as $skinName)
		{
			if ($skinName == $settings->DefaultSkin)
			{
				$hasDefSettingsSkin = true;
			}
			
			if ($skinName == $account->DefaultSkin)
			{
				define('defaultSkin', $account->DefaultSkin);
				break;
			}
		}
		
		if (!defined('defaultSkin'))
		{
			if ($hasDefSettingsSkin)
			{
				define('defaultSkin', $settings->DefaultSkin);
			}
			else
			{
				define('defaultSkin', $skins[0]);
			}
		}
		
		$_rtl = in_array($account->DefaultLanguage, explode('|', RTL_ARRAY));
		$_style = ($_rtl) ? '<link rel="stylesheet" href="skins/'.$account->DefaultSkin.'/styles-rtl.css" type="text/css" id="skin-rtl">' : '';
		$_js_rtl = ($_rtl) ? 'var RTL = true;' : '';
		
		define('JS_VERS', ConvertUtils::GetJsVersion());
	
		header('Content-type: text/html; charset=utf-8');
		header('Content-script-type: text/javascript');
		header('Pragma: cache');
		header('Cache-control: public');
		
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
<html id="html">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="Content-Script-Type" content="text/javascript" />
	<meta http-equiv="Pragma" content="cache" />
	<meta http-equiv="Cache-Control" content="public" />
	<link rel="shortcut icon" href="favicon.ico" />
	<title><?php echo defaultTitle; ?></title>
	<link rel="stylesheet" href="skins/<?php echo ConvertUtils::AttributeQuote(defaultSkin); ?>/styles.css" type="text/css" id="skin" />
	<?php echo $_style; ?>
	<script type="text/javascript">
		function ResizeBodyHandler() {}
		var JSLoadedCount = 1;
		var TotalJSFilesCount = 19;
		function JSFileLoaded()
		{
			JSLoadedCount++;
			var percent = Math.ceil((JSLoadedCount)*100/(TotalJSFilesCount + 1));
			if (percent >= 0)
			{
				var jsProgressLoaded = document.getElementById('jsProgressLoaded');
				if (jsProgressLoaded)
				{
					percent = (percent > 100) ? 100 : percent;
					jsProgressLoaded.style.width = percent + 'px';
				}
			}
		}
	</script>
</head>

<body onresize="ResizeBodyHandler();" onload="Init();" onclick="EventBodyHandler();" onkeyup="EventBodyHandler();">
	<table class="wm_information wm_connection_information" cellpadding="0" cellspacing="0" style="right: auto; width: auto; top: 0px; left: 604px;" id="info_cont">
		<tr style="position:relative;z-index:20">
			<td class="wm_shadow" style="width:2px;font-size:1px;"></td>
			<td>
				<div class="wm_info_message" id="info_message">
					<span><?php echo JS_LANG_InfoWebMailLoading;?></span>
					<div class="wm_progressbar">
						<div id="jsProgressLoaded" class="wm_progressbar_used" style="width: 95px;"></div>
					</div>
				</div>
				<div class="a">&nbsp;</div>
				<div class="b">&nbsp;</div>
			</td>
			<td class="wm_shadow" style="width:2px;font-size:1px;"></td>
		</tr>
		<tr>
			<td colspan="3" class="wm_shadow" style="height:2px;background:none;">
				<div class="a">&nbsp;</div>
				<div class="b">&nbsp;</div>
			</td>
		</tr>
		<tr style="position:relative;z-index:19">
			<td colspan="3" style="height:2px;">
				<div class="a wm_shadow" style="margin:0px 2px;height:2px; top:-4px; position:relative; border:0px;background:#555;">&nbsp;</div>
			</td>
		</tr>
	</table>
	<div align="center" id="content" class="wm_hide">
		<div class="wm_logo" id="logo" tabindex="-1" onfocus="this.blur();"></div>
	</div>
	<div id="spell_popup_menu" class="wm_hide"><?php echo SpellWait; ?></div>
	<div class="wm_hide" id="copyright">
		<?php require('inc.footer.php'); ?>
	</div>
</body>
<script type="text/javascript">
	var LoginUrl = 'index.php';
	var WebMailUrl = 'webmail.php<?php echo (isset($_GET['iframe'])) ? '?iframe' : ''; ?>';
	var ActionUrl = 'processing.php';
	var EditAreaUrl = 'edit-area.php';
	var EmptyHtmlUrl = 'empty.html';
	var UploadUrl = 'upload.php';
	var ImportUrl = 'import.php';
	var HistoryStorageUrl = 'history-storage.php';
	var CheckMailUrl = 'check-mail.php';
	var LanguageUrl = 'langs.js.php';
	var SpellcheckerUrl = 'spellcheck.php';
	var CalendarUrl = 'calendar.php';
	var CalendarProcessingUrl = 'calendar/processing.php';
	var ImageUploaderUrl = 'image-uploader.php';
	
	var Title = "<?php echo ConvertUtils::ClearJavaScriptString(defaultTitle, '"'); ?>";
	var SkinName = "<?php echo ConvertUtils::ClearJavaScriptString(defaultSkin, '"'); ?>";
	var Start = <?php echo $start; ?>;
	var ToAddr = "<?php echo ConvertUtils::ClearJavaScriptString($to, '"'); ?>";
	var XType = "<?php echo (int) XTYPE; ?>";
	var WmVersion = "<?php echo JS_VERS; ?>";
	var Seporated = <?php echo (isset($_SESSION[SEPARATED]) && $_SESSION[SEPARATED]) ? 'true' : 'false'; ?>;
	var CSType = <?php echo (@file_exists('CS')) ? 'true' : 'false'; ?>;
	<?php echo $_js_rtl; ?>
	var UseDb = true;
	var Browser;
	var WebMail, HistoryStorage;
	
	function GetWidth() {
		var w = 1024;
		if (document.documentElement && document.documentElement.clientWidth) {
			w = document.documentElement.clientWidth;
		} else if (document.body.clientWidth) {
			w = document.body.clientWidth;
		} else if (self.innerWidth) {
			w = self.innerWidth;
		}
		return w;
	}
	var infoCont = document.getElementById('info_cont');
	if (infoCont) {
		infoCont.style.right = 'auto';
		infoCont.style.left = Math.round((GetWidth() - infoCont.offsetWidth)/2) + 'px';
	}
</script>
<script type="text/javascript" src="langs.js.php?v=<?php echo JS_VERS; ?>&lang=<?php echo ConvertUtils::AttributeQuote($account->DefaultLanguage); ?>"></script>
<?php if (USE_JS_GZIP && IS_SUPPORT_GZIP) { ?>
<script type="text/javascript" src="cache-loader.php?v=<?php echo JS_VERS; ?>&t=def"></script>
<script type="text/javascript" src="cache-loader.php?v=<?php echo JS_VERS; ?>&t=wm"></script>
<script type="text/javascript" src="cache-loader.php?v=<?php echo JS_VERS; ?>&t=wmp"></script>
<script type="text/javascript" src="cache-loader.php?v=<?php echo JS_VERS; ?>&t=cont"></script>
<?php } else { ?>
<script type="text/javascript" src="js/_defines.js"></script>
<script type="text/javascript" src="js/class.common.js"></script>
<script type="text/javascript" src="js/_functions.js"></script>
<script type="text/javascript" src="js/class.webmail.js"></script>
<script type="text/javascript" src="js/class.webmail-parts.js"></script>
<script type="text/javascript" src="js/class.html-editor.js"></script>
<script type="text/javascript" src="js/class.xml-parsers.js"></script>
<script type="text/javascript" src="js/class.screens-parts.js"></script>
<script type="text/javascript" src="js/screen.messages-list.js"></script>
<script type="text/javascript" src="js/screen.view-message.js"></script>
<script type="text/javascript" src="js/screen.messages-list-view.js"></script>
<script type="text/javascript" src="js/screen.new-message.js"></script>
<script type="text/javascript" src="js/class.variable-table.js"></script>
<!-- scripts for settings-->
<script type="text/javascript" src="js/screen.user-settings.js"></script>
<script type="text/javascript" src="js/screen.common-settings.js"></script>
<script type="text/javascript" src="js/screen.accounts-settings.js"></script>
<script type="text/javascript" src="js/screen.account-properties.js"></script>
<script type="text/javascript" src="js/inc.calendar-settings.js"></script>
<!-- scripts for contacts-->
<script type="text/javascript" src="js/screen.contacts.js"></script>
<script type="text/javascript" src="js/screen.view-contact.js"></script>
<?php } ?>
<script type="text/javascript">
	function Init() {
		Browser = new CBrowser();
		if (Browser.IE && Browser.Version < 7) {
			try {
				document.execCommand('BackgroundImageCache', false, true);
			} catch(e) {}
		}
		HtmlEditorField.Build(<?php echo USE_DB ? 'false' : 'true'; ?>);
		var DataTypes = [
			new CDataType(TYPE_BASE, false, 0, false, { }, 'base' ),
			new CDataType(TYPE_ACCOUNT_BASE, false, 0, false, { IdAcct: 'id_acct', ChangeAcct: 'change_acct' }, 'account_base' ),
			new CDataType(TYPE_MESSAGES_BODIES, false, 0, false, { }, 'messages_bodies' ),
			new CDataType(TYPE_FOLDERS_BASE, false, 0, false, { }, 'folders_base' ),
			new CDataType(TYPE_SETTINGS_LIST, false, 0, false, { }, 'settings_list' ),
			new CDataType(TYPE_ACCOUNTS_LIST, false, 0, false, { }, 'accounts' ),
			new CDataType(TYPE_FOLDERS_LIST, true, 10, false, { IdAcct: 'id_acct', Sync: 'sync' }, 'folders_list' ),
			new CDataType(TYPE_MESSAGES_LIST, true, 20, false, { IdAcct: 'id_acct', Page: 'page', SortField: 'sort_field', SortOrder: 'sort_order' }, 'messages' ),
			new CDataType(TYPE_MESSAGES_OPERATION, false, 0, false, { }, '' ),
			new CDataType(TYPE_MESSAGE, true, 100, true, { Id: 'id', Charset: 'charset' }, 'message' ),
			new CDataType(TYPE_USER_SETTINGS, false, 0, false, { }, 'settings' ),
			new CDataType(TYPE_ACCOUNT_PROPERTIES, false, 0, false, { IdAcct: 'id_acct' }, 'account' ),
			new CDataType(TYPE_FILTERS, false, 0, false, { IdAcct: 'id_acct' }, 'filters' ),
			new CDataType(TYPE_FILTER_PROPERTIES, false, 0, false, { IdFilter: 'id_filter', IdAcct: 'id_acct' }, 'filter' ),
			new CDataType(TYPE_CONTACTS_SETTINGS, false, 0, false, { }, 'contacts_settings' ),
			new CDataType(TYPE_SIGNATURE, false, 0, false, { IdAcct: 'id_acct' }, 'signature' ),
			new CDataType(TYPE_AUTORESPONDER, false, 0, false, { IdAcct: 'id_acct' }, 'autoresponder' ),
			new CDataType(TYPE_CONTACTS, true, 5, false, { Page: 'page', SortField: 'sort_field', SortOrder: 'sort_order' }, 'contacts_groups' ),
			new CDataType(TYPE_CONTACT, true, 20, false, { IdAddr: 'id_addr' }, 'contact' ),
			new CDataType(TYPE_GROUPS, false, 0, false, { }, 'groups' ),
			new CDataType(TYPE_GROUP, true, 10, false, { IdGroup: 'id_group' }, 'group' ),
			new CDataType(TYPE_SPELLCHECK, false, 0, false, { Word: 'word' }, 'spellcheck')
		];
		WebMail = new CWebMail(Title, SkinName);
		WebMail.DataSource = new CDataSource( DataTypes, ActionUrl, ErrorHandler, InfoHandler, LoadHandler, TakeDataHandler, ShowLoadingInfoHandler );
		HistoryStorage = new CHistoryStorage(
			{
				Document: document,
				HistoryStorageObjectName: "HistoryStorage",
				PathToPageInIframe: HistoryStorageUrl,
				MaxLimitSteps: 50,
				Browser: Browser
			}
		);

		if (Start) {
			WebMail.SetStartScreen(Start);
		}
		
		WebMail.DataSource.Get(TYPE_BASE, { }, [], '');
		setTimeout(CreateSessionSaver, 20000);
		
<?php

	if (isset($_GET['prefetch_off']))
	{
		$_SESSION['awm_prefetch_off'] = true;
	} 
	else if (isset($_GET['prefetch_on']) && isset($_SESSION['awm_prefetch_off']))
	{
		unset($_SESSION['awm_prefetch_off']);
	}
	
	if (isset($_SESSION['awm_prefetch_off']))
	{
		echo "\t\t".'UsePrefetch = false;';
	}
	
	if (!USE_DB)
	{
		echo "\t\t".'UseDb = false;';
	}

?>

	}
</script>
</html><?php
	
		echo '<!-- '.WMVERSION.' -->';
	}
Return current item: AfterLogic WebMail Lite PHP