<?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__).'/');
@header('Content-type: application/x-javascript; charset=utf-8');
require_once (WM_ROOTPATH.'common/last_modified.php');
require_once (WM_ROOTPATH.'common/inc_constants.php');
require_once (WM_ROOTPATH.'common/class_settings.php');
$type = '';
$files = array();
$v = isset($_GET['v']) ? $_GET['v'] : '';
if (get_type_and_files($type, $files))
{
@ob_start(USE_JS_GZIP ? 'obStartGzip' : 'obStartNoGzip');
echo js_pack($files);
}
/* ---------- functions ------------- */
/**
* @param array $filesArray
* @return string
*/
function js_pack($filesArray)
{
$return = array();
foreach ($filesArray as $file)
{
$return[] = file_load_and_pack(WM_ROOTPATH.$file);
}
return implode('', $return);
}
/**
* @param string $filename
* @return string
*/
function file_load_and_pack($filename)
{
$filename = str_replace('..', '', $filename);
$return = array();
if (@file_exists($filename))
{
$return[] = text_clear(@file_get_contents($filename))."\r\n";
}
return implode('', $return);
}
/**
* @param string $string
* @return string
*/
function text_clear($string)
{
/*$string = preg_replace('/\/\*(.*?)\*\//s', '', $string);*/
/*$string = preg_replace('/\/\/[]*$/', '', $string);*/
/*$string = preg_replace('/[\s]+/', ' ', $string);*/
return $string;
}
/**
* @param string $type
* @param array $files
* @return bool
*/
function get_type_and_files(&$type, &$files)
{
if (isset($_GET['t']))
{
switch ($_GET['t']) {
case 'login':
$type = $_GET['t'];
$files = array('js/class.login.js');
return true;
case 'reg':
$type = $_GET['t'];
$files = array('js/class.reg.js');
return true;
case 'reset':
$type = $_GET['t'];
$files = array('js/class.password-reset.js');
return true;
case 'common':
$type = $_GET['t'];
$files = array('js/class.common.js');
return true;
case 'def':
$type = $_GET['t'];
$files = array(
'js/_defines.js',
'js/class.common.js',
'js/_functions.js');
return true;
case 'wm':
$type = $_GET['t'];
$files = array(
'js/class.webmail.js',
'js/class.html-editor.js',
'js/class.xml-parsers.js',
'js/class.screens-parts.js',
'js/screen.messages-list.js',
'js/screen.view-message.js',
'js/screen.messages-list-view.js',
'js/screen.new-message.js',
'js/class.variable-table.js');
return true;
case 'wmp':
$type = $_GET['t'];
$files = array('js/class.webmail-parts.js');
return true;
case 'cont':
$type = $_GET['t'];
$files = array(
'js/screen.user-settings.js',
'js/screen.common-settings.js',
'js/screen.accounts-settings.js',
'js/screen.account-properties.js',
'js/inc.calendar-settings.js',
'js/screen.contacts.js',
'js/screen.view-contact.js');
return true;
case 'cal':
$type = $_GET['t'];
$files = array('calendar/js/cal_lib.js', 'calendar/js/cal_userforms.js');
return true;
case 'cal_f':
$type = $_GET['t'];
$files = array('calendar/js/cal_functions.js');
return true;
case 'cal_p':
$type = $_GET['t'];
$files = array('calendar/js/pub_lib.js', 'calendar/js/pub_userforms.js');
return true;
}
}
return false;
}