/** Needs the DB functions */
if (!include_once('DB.php')) {
// same error also in db_prefs.php
- require_once(SM_PATH . 'functions/display_messages.php');
$error = _("Could not include PEAR database functions required for the database backend.") . "<br />\n";
$error .= sprintf(_("Is PEAR installed, and is the include path set correctly to find %s?"),
'<tt>DB.php</tt>') . "<br />\n";
* @subpackage addressbook
*/
-/**
- * If SM_PATH isn't defined, define it. Required to include files.
- * @ignore
- */
-if (!defined('SM_PATH')) {
- define('SM_PATH','../');
-}
/* required includes */
-include_once(SM_PATH . 'functions/display_messages.php');
+// FIXME, NO display code in functions files
include_once(SM_PATH . 'templates/util_global.php');
-global $addrbook_dsn, $addrbook_global_dsn;
-
/**
* Create and initialize an addressbook object.
* @param boolean $showerr display any address book init errors. html page header
var $localbackendname = '';
/**
* Controls use of 'extra' field
- *
- * Extra field can be used to add link to form, which allows
- * to modify all fields supported by backend. This is the only field
+ *
+ * Extra field can be used to add link to form, which allows
+ * to modify all fields supported by backend. This is the only field
* that is not sanitized with htmlspecialchars. Backends MUST make
* sure that field data is sanitized and displayed correctly inside
* table cell. Use of html formating in other address book fields is
- * not allowed. Backends that don't return 'extra' row in address book
+ * not allowed. Backends that don't return 'extra' row in address book
* data should not modify this object property.
* @var boolean
* @since 1.5.1
* @return integer number of backends
*/
function add_backend($backend, $param = '') {
+ static $backend_classes;
+ if (!isset($backend_classes)) {
+ $backend_classes = array();
+ }
+ if (!isset($backend_classes[$backend])) {
+ /**
+ * Support backend provided by plugins. Plugin function must
+ * return an associative array with as key the backend name ($backend)
+ * and as value the file including the path containing the backend class.
+ * i.e.: $aBackend = array('backend_template' => SM_PATH . 'plugins/abook_backend_template/functions.php')
+ *
+ * NB: Because the backend files are included from within this function they DO NOT have access to
+ * vars in the global scope. This function is the global scope for the included backend !!!
+ */
+ $aBackend = do_hook('abook_add_class');
+ if (isset($aBackend) && is_array($aBackend) && isset($aBackend[$backend])) {
+ require_once($aBackend[$backend]);
+ } else {
+ require_once(SM_PATH . 'functions/abook_'.$backend.'.php');
+ }
+ $backend_classes[$backend] = true;
+ }
$backend_name = 'abook_' . $backend;
- eval('$newback = new ' . $backend_name . '($param);');
+ $newback = new $backend_name($param);
+ //eval('$newback = new ' . $backend_name . '($param);');
if(!empty($newback->error)) {
$this->error = $newback->error;
return false;
/**
* Search for entries in backend
*
- * Working backend should support use of wildcards. * symbol
+ * Working backend should support use of wildcards. * symbol
* should match one or more symbols. ? symbol should match any
- * single symbol.
+ * single symbol.
* @param string $expression
* @return bool
*/
return false;
}
}
-
-/*
- PHP 5 requires that the class be made first, which seems rather
- logical, and should have been the way it was generated the first time.
-*/
-
-require_once(SM_PATH . 'functions/abook_local_file.php');
-require_once(SM_PATH . 'functions/abook_ldap_server.php');
-
-/* Only load database backend if database is configured */
-if((isset($addrbook_dsn) && !empty($addrbook_dsn)) ||
- (isset($addrbook_global_dsn) && !empty($addrbook_global_dsn))) {
- include_once(SM_PATH . 'functions/abook_database.php');
-}
-
-/*
- * hook allows adding different address book classes.
- * class must follow address book class coding standards.
- *
- * see addressbook_backend class and functions/abook_*.php files.
- * @since 1.5.1 and 1.4.5
- */
-do_hook('abook_add_class');
-
?>
* @todo document attachment $type hook arguments
*/
-/** @ignore */
-if (! defined('SM_PATH')) define('SM_PATH','../');
-/** sqgetGlobalVar() */
-include_once(SM_PATH . 'functions/global.php');
-/** sqm_baseuri() */
-include_once(SM_PATH . 'functions/display_messages.php');
-
-global $attachment_common_show_images_list;
-$attachment_common_show_images_list = array();
-
-global $FileExtensionToMimeType, $attachment_common_types;
/**
* Mapping of file extensions to mime types
*
register_attachment_common('image/x-xbitmap', 'link_image');
elseif ($val == '*/*' || $val == 'image/*') {
/**
- * browser (Firefox) declared that anything is acceptable.
+ * browser (Firefox) declared that anything is acceptable.
* Lets register some common image types.
*/
if (! isset($jpeg_done)) {
* @since 1.2.0
*/
function attachment_common_link_text(&$Args) {
+ global $base_uri;
/* If there is a text attachment, we would like to create a "View" button
that links to the text attachment viewer.
sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
// if htmlspecialchars() breaks something - find other way to encode & in url.
- $Args[1]['attachment_common']['href'] = sqm_baseuri() . 'src/view_text.php?'. htmlspecialchars($QUERY_STRING);
+ $Args[1]['attachment_common']['href'] = $base_uri . 'src/view_text.php?'. htmlspecialchars($QUERY_STRING);
$Args[1]['attachment_common']['href'] =
set_url_var($Args[1]['attachment_common']['href'],
'ent_id',$Args[5]);
* @since 1.2.6
*/
function attachment_common_link_message(&$Args) {
- $Args[1]['attachment_common']['href'] = sqm_baseuri() . 'src/read_body.php?startMessage=' .
+ global $base_uri;
+ $Args[1]['attachment_common']['href'] = $base_uri . 'src/read_body.php?startMessage=' .
$Args[2] . '&passed_id=' . $Args[3] . '&mailbox=' . $Args[4] .
'&passed_ent_id=' . $Args[5] . '&override_type0=message&override_type1=rfc822';
* @since 1.2.0
*/
function attachment_common_link_html(&$Args) {
+ global $base_uri;
sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
- $Args[1]['attachment_common']['href'] = sqm_baseuri() . 'src/view_text.php?'. htmlspecialchars($QUERY_STRING).
+ $Args[1]['attachment_common']['href'] = $base_uri . 'src/view_text.php?'. htmlspecialchars($QUERY_STRING).
/* why use the overridetype? can this be removed */
/* override_type might be needed only when we want view other type of messages as html */
'&override_type0=text&override_type1=html';
* @since 1.2.0
*/
function attachment_common_link_image(&$Args) {
- global $attachment_common_show_images_list;
+ global $attachment_common_show_images_list, $base_uri ;
sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
$attachment_common_show_images_list[] = $info;
- $Args[1]['attachment_common']['href'] = sqm_baseuri() . 'src/image.php?'. htmlspecialchars($QUERY_STRING);
+ $Args[1]['attachment_common']['href'] = $base_uri . 'src/image.php?'. htmlspecialchars($QUERY_STRING);
$Args[1]['attachment_common']['href'] =
set_url_var($Args[1]['attachment_common']['href'],
'ent_id',$Args[5]);
* @since 1.2.0
*/
function attachment_common_link_vcard(&$Args) {
+ global $base_uri;
sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
- $Args[1]['attachment_common']['href'] = sqm_baseuri() . 'src/vcard.php?'. htmlspecialchars($QUERY_STRING);
+ $Args[1]['attachment_common']['href'] = $base_uri . 'src/vcard.php?'. htmlspecialchars($QUERY_STRING);
$Args[1]['attachment_common']['href'] =
set_url_var($Args[1]['attachment_common']['href'],
'ent_id',$Args[5]);
/**
* auth.php
*
- * Contains functions used to do authentication. Library depends on
- * functions from functions/global.php, functions/i18n.php and
+ * Contains functions used to do authentication. Library depends on
+ * functions from functions/global.php, functions/i18n.php and
* functions/strings.php.
*
* @copyright © 1999-2006 The SquirrelMail Project Team
* @package squirrelmail
*/
-/** Put in a safety net here, in case a naughty admin didn't run conf.pl when they upgraded */
-
-if (! isset($smtp_auth_mech)) {
- $smtp_auth_mech = 'none';
-}
-
-if (! isset($imap_auth_mech)) {
- $imap_auth_mech = 'login';
-}
-
-if (! isset($use_imap_tls)) {
- $use_imap_tls = false;
-}
-
-if (! isset($use_smtp_tls)) {
- $use_smtp_tls = false;
-}
-
-/**
- * Check if user has previously logged in to the SquirrelMail session. If user
- * has not logged in, execution will stop inside this function.
- *
- * @return int A positive value is returned if user has previously logged in
- * successfully.
- * @since 1.0
- */
-function is_logged_in() {
-
- if ( sqsession_is_registered('user_is_logged_in') ) {
- return;
- } else {
- global $PHP_SELF, $session_expired_post,
- $session_expired_location, $squirrelmail_language;
-
- // First we store some information in the new session to prevent
- // information-loss.
- //
- $session_expired_post = $_POST;
- $session_expired_location = $PHP_SELF;
- if (!sqsession_is_registered('session_expired_post')) {
- sqsession_register($session_expired_post,'session_expired_post');
- }
- if (!sqsession_is_registered('session_expired_location')) {
- sqsession_register($session_expired_location,'session_expired_location');
- }
-
- // signout page will deal with users who aren't logged
- // in on its own; don't show error here
- //
- if (strpos($PHP_SELF, 'signout.php') !== FALSE) {
- return;
- }
-
- include_once( SM_PATH . 'functions/display_messages.php' );
- set_up_language($squirrelmail_language, true);
- logout_error( _("You must be logged in to access this page.") );
- exit;
- }
-}
/**
* Detect logged user
- *
- * Function is similar to is_logged_in() function. If user is logged in, function
+ *
+ * Function is similar to is_logged_in() function. If user is logged in, function
* returns true. If user is not logged in or session is expired, function saves $_POST
- * and $PHP_SELF in session and returns false. POST information is saved in
+ * and $PHP_SELF in session and returns false. POST information is saved in
* 'session_expired_post' variable, PHP_SELF is saved in 'session_expired_location'.
*
- * Script that uses this function instead of is_logged_in() function, must handle user
+ * Script that uses this function instead of is_logged_in() function, must handle user
* level messages.
* @return boolean
* @since 1.5.1
/**
* Saves or updates user password information
- *
+ *
* This function is used to update password information that SquirrelMail
- * stores during existing web session. It does not modify password stored
+ * stores during existing web session. It does not modify password stored
* in authentication system used by IMAP server.
*
- * Function must be called before any html output started. Direct access
- * to password information is deprecated. Saved password information is
+ * Function must be called before any html output started. Direct access
+ * to password information is deprecated. Saved password information is
* available only to next executed SquirrelMail script. If your script needs
- * access to saved password after sqauth_save_password() call, use returned
+ * access to saved password after sqauth_save_password() call, use returned
* OTP encrypted key.
* @param string $pass password
- * @return string password encrypted with OTP. In case script wants to access
+ * @return string password encrypted with OTP. In case script wants to access
* password information before reloading page.
* @since 1.5.1
*/
* @subpackage date
*/
-/** Load up some useful constants */
-require_once(SM_PATH . 'functions/constants.php');
+/**
+ * dependency information
+ * - none
+ */
/**
* Corrects a time stamp to be the local time.
return getGMTSeconds($stamp, $dateParts[0]);
}
}
-
-/* I use this function for profiling. Should never be called in
- actual versions of SquirrelMail released to public. */
-/*
- function getmicrotime() {
- $mtime = microtime();
- $mtime = explode(' ',$mtime);
- $mtime = $mtime[1] + $mtime[0];
- return ($mtime);
- }
-*/
-?>
\ No newline at end of file
/** PostgreSQL */
define('SMDB_PGSQL', 2);
-require_once(SM_PATH . 'config/config.php');
+
if (!include_once('DB.php')) {
// same error also in abook_database.php
- require_once(SM_PATH . 'functions/display_messages.php');
$error = _("Could not include PEAR database functions required for the database backend.") . "<br />\n";
$error .= sprintf(_("Is PEAR installed, and is the include path set correctly to find %s?"),
'<tt>DB.php</tt>') . "<br />\n";
/**
* Function used to handle database connection errors
- * @param object PEAR Error object
+ * @param object PEAR Error object
*/
function failQuery($res = NULL) {
if($res == NULL) {
/**
* Delete user's prefs setting
- * @param string $user user name
+ * @param string $user user name
* @param string $key preference name
* @return boolean
*/
." See doc/db-backend.txt or contact your system administrator.";
/**
- * Debugging function. Can be used to log all issues that trigger
- * oversized field errors. Function should be enabled in all three
+ * Debugging function. Can be used to log all issues that trigger
+ * oversized field errors. Function should be enabled in all three
* strlen checks. See http://www.php.net/error-log
*/
// error_log($user.'|'.$key.'|'.$value."\n",3,'/tmp/oversized_log');
* @package squirrelmail
*/
-/** @ignore */
-if (! defined('SM_PATH')) define('SM_PATH','../');
-
-/**
- * including plugin functions
- */
-include_once(SM_PATH . 'functions/plugin.php');
/**
* Displays error message and URL to message listing
/**
* Displays error when user is logged out
- *
+ *
* Error strings can be overriden by logout_error hook
* @param string $errString error message
* @param string $errTitle title of page with error message
*/
function logout_error( $errString, $errTitle = '' ) {
global $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height,
- $hide_sm_attributions, $version, $squirrelmail_language,
+ $hide_sm_attributions, $version, $squirrelmail_language,
$color, $theme, $theme_default;
$base_uri = sqm_baseuri();
- include_once( SM_PATH . 'functions/page_header.php' );
- if ( !isset( $org_logo ) ) {
- // Don't know yet why, but in some accesses $org_logo is not set.
- include( SM_PATH . 'config/config.php' );
- }
/* Display width and height like good little people */
$width_and_height = '';
if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) {
/**
* Displays error message
- *
+ *
* Since 1.4.1 function checks if page header is already displayed.
* Since 1.4.3 and 1.5.1 function contains error_box hook.
* Use plain_error_message() and make sure that page header is created,
/* check if the page header has been sent; if not, send it! */
if(!isset($pageheader_sent) && !$pageheader_sent) {
- /* include this just to be sure */
- include_once( SM_PATH . 'functions/page_header.php' );
displayHtmlHeader('SquirrelMail: '.$err);
$pageheader_sent = TRUE;
echo "<body>\n\n";
$optpage_save_error=array();
$optpage_save_error=array_merge($optpage_save_error,array($message));
-}
-?>
+}
\ No newline at end of file
* @since 1.2.5
*/
-/** @ignore */
-if (! defined('SM_PATH')) define('SM_PATH','../');
-
-/** include this for error messages */
-include_once(SM_PATH . 'functions/display_messages.php');
/**
* Check the preferences into the session cache.
sqgetGlobalVar('prefs_are_cached', $prefs_are_cached, SQ_SESSION );
if ( isset($prefs_are_cached) && $prefs_are_cached) {
sqgetGlobalVar('prefs_cache', $prefs_cache, SQ_SESSION );
+// sm_print_r($prefs_cache);
+// exit;
return;
}
*/
function folders_delete_do ($imapConnection, $delimiter, $folder_name)
{
- require_once(SM_PATH . 'functions/tree.php');
+ include(SM_PATH . 'functions/tree.php');
$boxes = sqimap_mailbox_list ($imapConnection);
* @subpackage i18n
*/
-/** Almost everything requires global.php... */
-require_once(SM_PATH . 'functions/global.php');
/** Load classes and other functions */
include_once(SM_PATH . 'class/l10n.class.php');
global $l10n, $gettext_domain;
if (! isset($l10n[$gettext_domain]) ||
! is_object($l10n[$gettext_domain]) ||
- $l10n[$gettext_domain]->error==1)
+ $l10n[$gettext_domain]->error==1)
return $str;
return $l10n[$gettext_domain]->translate($str);
}
global $l10n;
if (! isset($l10n[$domain]) ||
! is_object($l10n[$domain]) ||
- $l10n[$domain]->error==1)
+ $l10n[$domain]->error==1)
return $str;
return $l10n[$domain]->translate($str);
}
define('SQ_SERVER',5);
define('SQ_FORM',6);
+
/**
* returns true if current php version is at mimimum a.b.c
*
* @param int search constant defining where to look
* @return bool whether variable is found.
*/
-function sqgetGlobalVar($name, &$value, $search = SQ_INORDER) {
+function sqgetGlobalVar($name, &$value, $search = SQ_INORDER, $default = NULL, $typecast = false) {
+
+ $result = false;
- /* NOTE: DO NOT enclose the constants in the switch
- statement with quotes. They are constant values,
- enclosing them in quotes will cause them to evaluate
- as strings. */
switch ($search) {
/* we want the default case to be first here,
so that if a valid value isn't specified,
case SQ_SESSION:
if( isset($_SESSION[$name]) ) {
$value = $_SESSION[$name];
- return TRUE;
+ $result = TRUE;
+ break;
} elseif ( $search == SQ_SESSION ) {
break;
}
case SQ_POST:
if( isset($_POST[$name]) ) {
$value = $_POST[$name];
- return TRUE;
+ $result = TRUE;
+ break;
} elseif ( $search == SQ_POST ) {
break;
}
case SQ_GET:
if ( isset($_GET[$name]) ) {
$value = $_GET[$name];
- return TRUE;
+ $result = TRUE;
+ break;
}
/* NO IF HERE. FOR SQ_INORDER CASE, EXIT after GET */
break;
case SQ_COOKIE:
if ( isset($_COOKIE[$name]) ) {
$value = $_COOKIE[$name];
- return TRUE;
+ $result = TRUE;
+ break;
}
break;
case SQ_SERVER:
if ( isset($_SERVER[$name]) ) {
$value = $_SERVER[$name];
- return TRUE;
+ $result = TRUE;
+ break;
}
break;
}
- /* Nothing found, return FALSE */
- return FALSE;
+ if ($result && $typecast) {
+ switch ($typecast) {
+ case 'int': $value = (int) $value; break;
+ case 'bool': $value = (bool) $value; break;
+ default: break;
+ }
+ } else if (!is_null($default)) {
+ $value = $default;
+ }
+ return $result;
}
/**
$_SESSION = array();
@session_destroy();
}
-
}
/**
* (IE6 only)
*/
function sqsession_start() {
- global $PHP_SELF;
-
- $dirs = array('|src/.*|', '|plugins/.*|', '|functions/.*|');
- $repl = array('', '', '');
- $base_uri = preg_replace($dirs, $repl, $PHP_SELF);
-
+ global $base_uri;
session_start();
- $sessid = session_id();
+ $session_id = session_id();
+
// session_starts sets the sessionid cookie buth without the httponly var
// setting the cookie again sets the httponly cookie attribute
- sqsetcookie(session_name(),$sessid,false,$base_uri);
+ sqsetcookie(session_name(),session_id(),false,$base_uri);
}
* @param boolean $bHttpOnly Disallow JS to access the cookie (IE6 only)
* @return void
*/
-function sqsetcookie($sName,$sValue,$iExpire=false,$sPath="",$sDomain="",$bSecure=false,$bHttpOnly=true) {
+function sqsetcookie($sName,$sValue,$iExpire=false,$sPath="",$sDomain="",$bSecure=false,$bHttpOnly=true,$bFlush=false) {
+ static $sCookieCache;
+ if (!isset($sCache)) {
+ $sCache = '';
+ }
+ /**
+ * We have to send all cookies with one header call otherwise we loose cookies.
+ * In order to achieve that the sqsetcookieflush function calls this function with $bFlush = true.
+ * If that happens we send the cookie header.
+ */
+ if ($bFlush) {
+ header($sCookieCache);
+ return;
+ }
+
$sHeader = "Set-Cookie: $sName=$sValue";
if ($sPath) {
$sHeader .= "; path=$sPath";
$sHeader .= "; HttpOnly";
}
// $sHeader .= "; Version=1";
+ $sCookieCache .= $sHeader ."\r\n";
+ if ($bFlush) {
+ header($sCookieCache);
+ }
+}
+
+/**
+ * Send the cookie header
+ *
+ * Cookies set with sqsetcookie will bet set after a sqsetcookieflush call.
+ * @return void
+ */
+function sqsetcookieflush() {
+ sqsetcookie('','','','','','','',true);
+}
+
+/**
+ * session_regenerate_id replacement for PHP < 4.3.2
+ *
+ * This code is borrowed from Gallery, session.php version 1.53.2.1
+ */
+if (!function_exists('session_regenerate_id')) {
+ function make_seed() {
+ list($usec, $sec) = explode(' ', microtime());
+ return (float)$sec + ((float)$usec * 100000);
+ }
+
+ function php_combined_lcg() {
+ mt_srand(make_seed());
+ $tv = gettimeofday();
+ $lcg['s1'] = $tv['sec'] ^ (~$tv['usec']);
+ $lcg['s2'] = mt_rand();
+ $q = (int) ($lcg['s1'] / 53668);
+ $lcg['s1'] = (int) (40014 * ($lcg['s1'] - 53668 * $q) - 12211 * $q);
+ if ($lcg['s1'] < 0) {
+ $lcg['s1'] += 2147483563;
+ }
+ $q = (int) ($lcg['s2'] / 52774);
+ $lcg['s2'] = (int) (40692 * ($lcg['s2'] - 52774 * $q) - 3791 * $q);
+ if ($lcg['s2'] < 0) {
+ $lcg['s2'] += 2147483399;
+ }
+ $z = (int) ($lcg['s1'] - $lcg['s2']);
+ if ($z < 1) {
+ $z += 2147483562;
+ }
+ return $z * 4.656613e-10;
+ }
- header($sHeader);
+ function session_regenerate_id() {
+ global $base_uri;
+ $tv = gettimeofday();
+ sqgetGlobalVar('REMOTE_ADDR',$remote_addr,SQ_SERVER);
+ $buf = sprintf("%.15s%ld%ld%0.8f", $remote_addr, $tv['sec'], $tv['usec'], php_combined_lcg() * 10);
+ session_id(md5($buf));
+ if (ini_get('session.use_cookies')) {
+ // at a later stage we use sqsetcookie. At this point just do
+ // what session_regenerate_id would do
+ setcookie(session_name(), session_id(), NULL, $base_uri);
+ }
+ return TRUE;
+ }
}
+
/**
* php_self
*
return '';
}
-/** set the name of the session cookie */
-if(isset($session_name) && $session_name) {
- ini_set('session.name' , $session_name);
-} else {
- ini_set('session.name' , 'SQMSESSID');
-}
-
-/**
- * If magic_quotes_runtime is on, SquirrelMail breaks in new and creative ways.
- * Force magic_quotes_runtime off.
- * tassium@squirrelmail.org - I put it here in the hopes that all SM code includes this.
- * If there's a better place, please let me know.
- */
-ini_set('magic_quotes_runtime','0');
-
-/* Since we decided all IMAP servers must implement the UID command as defined in
- * the IMAP RFC, we force $uid_support to be on.
- */
-
-global $uid_support;
-$uid_support = true;
-
-/* if running with magic_quotes_gpc then strip the slashes
- from POST and GET global arrays */
-if (get_magic_quotes_gpc()) {
- sqstripslashes($_GET);
- sqstripslashes($_POST);
-}
-
-/**
- * If register_globals are on, unregister globals.
- * Code requires PHP 4.1.0 or newer.
- */
-if ((bool) @ini_get('register_globals')) {
- /**
- * Remove all globals from $_GET, $_POST, and $_COOKIE.
- */
- foreach ($_REQUEST as $key => $value) {
- unset($GLOBALS[$key]);
- }
- /**
- * Remove globalized $_FILES variables
- * Before 4.3.0 $_FILES are included in $_REQUEST.
- * Unglobalize them in separate call in order to remove dependency
- * on PHP version.
- */
- foreach ($_FILES as $key => $value) {
- unset($GLOBALS[$key]);
- // there are three undocumented $_FILES globals.
- unset($GLOBALS[$key.'_type']);
- unset($GLOBALS[$key.'_name']);
- unset($GLOBALS[$key.'_size']);
- }
- /**
- * Remove globalized environment variables.
- */
- foreach ($_ENV as $key => $value) {
- unset($GLOBALS[$key]);
- }
- /**
- * Remove globalized server variables.
- */
- foreach ($_SERVER as $key => $value) {
- unset($GLOBALS[$key]);
- }
-}
-
-/* strip any tags added to the url from PHP_SELF.
- This fixes hand crafted url XXS expoits for any
- page that uses PHP_SELF as the FORM action */
-$_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
-
-$PHP_SELF = php_self();
-
-sqsession_is_active();
-
-/**
- * Remove globalized session data in rg=on setups
- */
-if ((bool) @ini_get('register_globals')) {
- foreach ($_SESSION as $key => $value) {
- unset($GLOBALS[$key]);
- }
-}
-?>
}
return $url;
}
-
-/**
- * Temporary test function to process template vars with formatting.
- * I use it for viewing the message_header (view_header.php) with
- * a sort of template.
- * @param mixed $var
- * @param mixed $format_ar
- * @since 1.3.0
- * @todo if function is temporary, then why it is used.
- * @deprecated
- */
-function echo_template_var($var, $format_ar = array() ) {
- $frm_last = count($format_ar) -1;
-
- if (isset($format_ar[0])) echo $format_ar[0];
- $i = 1;
-
- switch (true) {
- case (is_string($var)):
- echo $var;
- break;
- case (is_array($var)):
- $frm_a = array_slice($format_ar,1,$frm_last-1);
- foreach ($var as $a_el) {
- if (is_array($a_el)) {
- echo_template_var($a_el,$frm_a);
- } else {
- echo $a_el;
- if (isset($format_ar[$i])) {
- echo $format_ar[$i];
- }
- $i++;
- }
- }
- break;
- default:
- break;
- }
- if (isset($format_ar[$frm_last]) && $frm_last>$i ) {
- echo $format_ar[$frm_last];
- }
-}
?>
\ No newline at end of file
* @since 1.4.2
*/
-/** Used to simplify includes
- * @ignore
- */
-if (!defined('SM_PATH')) {
- define('SM_PATH','../');
-}
-
-/** preference and signature functions */
-include_once(SM_PATH . 'include/load_prefs.php');
/**
* Returns an array of all the identities.
$num_cur = getPref($data_dir, $username, 'identities');
-
+
$cnt = count($identities);
// Remove any additional identities in prefs //
// Process actions from plugins and save/update action //
default:
/**
- * send action and id information. number of hook arguments
- * differs from 1.4.4 or older and 1.5.0. count($args) can
- * be used to detect modified hook. Older hook does not
+ * send action and id information. number of hook arguments
+ * differs from 1.4.4 or older and 1.5.0. count($args) can
+ * be used to detect modified hook. Older hook does not
* provide information that can be useful for plugins.
*/
do_hook('options_identities_process', $action, $id);
*/
/** Includes */
-require_once(SM_PATH . 'functions/imap_mailbox.php');
-require_once(SM_PATH . 'functions/imap_messages.php');
-require_once(SM_PATH . 'functions/imap_general.php');
-
-/** This is here for bc */
-require_once(SM_PATH . 'functions/date.php');
-require_once(SM_PATH . 'functions/mailbox_display.php');
-require_once(SM_PATH . 'functions/mime.php');
+include_once(SM_PATH . 'functions/imap_messages.php');
+include_once(SM_PATH . 'functions/imap_general.php');
?>
\ No newline at end of file
/** This functionality requires the IMAP and date functions
*/
-require_once(SM_PATH . 'functions/imap_general.php');
-require_once(SM_PATH . 'functions/date.php');
+//require_once(SM_PATH . 'functions/imap_general.php');
+//require_once(SM_PATH . 'functions/date.php');
/** Set to TRUE to dump the IMAP dialogue
* @global bool $imap_asearch_debug_dump
*/
/** Includes.. */
-require_once(SM_PATH . 'functions/page_header.php');
-require_once(SM_PATH . 'functions/auth.php');
-include_once(SM_PATH . 'functions/rfc822address.php');
+
+require_once(SM_PATH . 'functions/rfc822address.php');
/**
} else {
global $squirrelmail_language, $color;
set_up_language($squirrelmail_language);
- require_once(SM_PATH . 'functions/display_messages.php');
$string = "<b><font color=\"$color[2]\">\n" .
_("ERROR: No available IMAP stream.") .
"</b></font>\n";
} else {
global $squirrelmail_language, $color;
set_up_language($squirrelmail_language);
- require_once(SM_PATH . 'functions/display_messages.php');
$string = "<b><font color=\"$color[2]\">\n" .
_("ERROR: No available IMAP stream.") .
"</b></font>\n";
&$response, &$message, $query = '') {
global $color, $squirrelmail_language;
set_up_language($squirrelmail_language);
- require_once(SM_PATH . 'functions/display_messages.php');
$string = "<b><font color=\"$color[2]\">\n" .
_("ERROR: Bad function call.") .
"</b><br />\n" .
global $color, $squirrelmail_language;
set_up_language($squirrelmail_language);
- require_once(SM_PATH . 'functions/display_messages.php');
$string = "<font color=\"$color[2]\"><b>\n" . $title . "</b><br />\n";
$cmd = explode(' ',$query);
$cmd= strtolower($cmd[0]);
case '*':
{
- if (($sCommand == "FETCH" || $sCommand == "STORE") && preg_match('/^\*\s\d+\sFETCH/',$read)) {
+ if (($sCommand == "FETCH" || $sCommand == "STORE") && preg_match('/^\*\s\d+\sFETCH/',$read)) {
/* check for literal */
$s = substr($read,-3);
$fetch_data = array();
/* "BAD" and anything else gets reported here. */
$message = htmlspecialchars($message);
set_up_language($squirrelmail_language, true);
- require_once(SM_PATH . 'functions/display_messages.php');
if ($response == 'BAD') {
$string = sprintf (_("Bad request: %s")."<br />\r\n", $message);
} else {
*/
set_up_language($squirrelmail_language, true);
- include_once(SM_PATH . 'functions/display_messages.php' );
sqsession_destroy();
+ sqsetcookieflush();
/* terminate the session nicely */
sqimap_logout($imap_stream);
logout_error( _("Unknown user or password incorrect.") );
if ( stristr($message, 'REFERRAL imap') === TRUE ) {
sqimap_logout($imap_stream);
set_up_language($squirrelmail_language, true);
- include_once(SM_PATH . 'functions/display_messages.php' );
sqsession_destroy();
logout_error( _("Your mailbox is not located at this server. Try a different server or consult your system administrator") );
exit;
if (!$bUseCache || ! sqgetGlobalVar('sqimap_capabilities', $sqimap_capabilities, SQ_SESSION)) {
$read = sqimap_run_command($imap_stream, 'CAPABILITY', true, $a, $b);
-
$c = explode(' ', $read[0]);
for ($i=2; $i < count($c); $i++) {
$cap_list = explode('=', $c[$i]);
return chop(substr($yp, strlen($username)+1));
}
-?>
+?>
\ No newline at end of file
* @subpackage imap
*/
-/** @ignore */
-if (! defined('SM_PATH')) define('SM_PATH','../');
-
/** UTF7 support */
require_once(SM_PATH . 'functions/imap_utf7_local.php');
-global $boxesnew;
/**
* Mailboxes class
if ($show_only_subscribed) { $show_only_subscribed=$show_only_subscribed_folders; }
- require_once(SM_PATH . 'include/load_prefs.php');
+ //require_once(SM_PATH . 'include/load_prefs.php');
/**
* There are three main listing commands we can use in IMAP:
// get subscribed mailbox list from cache (session)
// if not there, then get it from the imap server and store in cache
- sqsession_is_active();
if (!$force) {
sqgetGlobalVar($sub_cache_name,$lsub_cache,SQ_SESSION);
* @package squirrelmail
*/
-/** The standard includes.. */
-require_once(SM_PATH . 'functions/strings.php');
-require_once(SM_PATH . 'functions/html.php');
-require_once(SM_PATH . 'functions/imap_mailbox.php');
-require_once(SM_PATH . 'functions/imap_messages.php');
-require_once(SM_PATH . 'functions/imap_asearch.php');
-require_once(SM_PATH . 'functions/mime.php');
-require_once(SM_PATH . 'functions/forms.php');
-
/**
* Selects a mailbox for header retrieval.
$link = $sTargetModule.'.php?' . implode('&',$aQuery);
// see top of this function for which attributes are available
- // in the global scope for plugin use (like $link, $target,
+ // in the global scope for plugin use (like $link, $target,
// $onclick, $link_extra, $title, and so forth)
- // plugins are responsible for sharing nicely (such as for
+ // plugins are responsible for sharing nicely (such as for
// setting the target, etc)
do_hook('subject_link', array($iPageOffset, $sSearch, $aSearch));
}
* @package squirrelmail
*/
-/** The typical includes... */
-require_once(SM_PATH . 'functions/imap.php');
-require_once(SM_PATH . 'functions/attachment_common.php');
-/** add sqm_baseuri()*/
-include_once(SM_PATH . 'functions/display_messages.php');
+/**
+ * dependency information
+ functions dependency
+ mime_structure
+ class/mime/Message.class.php
+ Message::parseStructure
+ functions/page_header.php
+ displayPageHeader
+ functions/display_messages.php
+ plain_error_message
+ mime_fetch_body
+ functions/imap_general.php
+ sqimap_run_command
+ mime_print_body_lines
+
+
+
+functions/imap.php
+functions/attachment_common.php
+functions/display_messages.php
+
+magicHtml => url_parser
+translateText => url_parser
+
+*/
+
/* -------------------------------------------------------------------------- */
/* MIME DECODING */
$i = 0;
$msg = Message::parseStructure($read,$i);
if (!is_object($msg)) {
- include_once(SM_PATH . 'functions/display_messages.php');
global $color, $mailbox;
/* removed urldecode because $_GET is auto urldecoded ??? */
displayPageHeader( $color, $mailbox );
global $where, $what; /* from searching */
global $color; /* color theme */
- require_once(SM_PATH . 'functions/url_parser.php');
+ // require_once(SM_PATH . 'functions/url_parser.php');
$body_ary = explode("\n", $body);
for ($i=0; $i < count($body_ary); $i++) {
* @return string html formated attachment information.
*/
function formatAttachments($message, $exclude_id, $mailbox, $id) {
- global $where, $what, $startMessage, $color, $passed_ent_id;
+ global $where, $what, $startMessage, $color, $passed_ent_id, $base_uri;
$att_ar = $message->getAttachments($exclude_id);
$type1 = strtolower($header->type1);
$name = '';
$links['download link']['text'] = _("Download");
- $links['download link']['href'] = sqm_baseuri() .
+ $links['download link']['href'] = $base_uri .
"src/download.php?absolute_dl=true&passed_id=$id&mailbox=$urlMailbox&ent_id=$ent";
if ($type0 =='message' && $type1 == 'rfc822') {
- $default_page = sqm_baseuri() . 'src/read_body.php';
+ $default_page = $base_uri . 'src/read_body.php';
$rfc822_header = $att->rfc822_header;
$filename = $rfc822_header->subject;
if (trim( $filename ) == '') {
}
$description = $from_name;
} else {
- $default_page = sqm_baseuri() . 'src/download.php';
+ $default_page = $base_uri . 'src/download.php';
$filename = $att->getFilename();
if ($header->description) {
$description = decodeHeader($header->description);
*/
function magicHTML($body, $id, $message, $mailbox = 'INBOX', $take_mailto_links =true) {
- require_once(SM_PATH . 'functions/url_parser.php'); // for $MailTo_PReg_Match
+ // require_once(SM_PATH . 'functions/url_parser.php'); // for $MailTo_PReg_Match
global $attachment_common_show_images, $view_unsafe_images,
$has_unsafe_images;
if ($take_mailto_links) {
// parseUrl($trusted); // this even parses URLs inside of tags... too aggressive
global $MailTo_PReg_Match;
- $MailTo_PReg_Match = '/mailto:' . substr($MailTo_PReg_Match, 1);
+ $MailTo_PReg_Match = '/mailto:' . substr($MailTo_PReg_Match, 1) ;
if ((preg_match_all($MailTo_PReg_Match, $trusted, $regs)) && ($regs[0][0] != '')) {
foreach ($regs[0] as $i => $mailto_before) {
$mailto_params = $regs[10][$i];
} // end fn SendDownloadHeaders
-?>
+?>
\ No newline at end of file
* @package squirrelmail
*/
-/** @ignore */
-if (! defined('SM_PATH')) define('SM_PATH','../');
-
/** Include required files from SM */
-require_once(SM_PATH . 'functions/strings.php');
-require_once(SM_PATH . 'functions/html.php');
-require_once(SM_PATH . 'functions/imap_mailbox.php');
-require_once(SM_PATH . 'functions/global.php');
-include_once(SM_PATH . 'class/template/template.class.php');
+include_once(SM_PATH . 'functions/imap_mailbox.php');
/**
* Output a SquirrelMail page header, from <!doctype> to </head>
.(!empty($used_fontsize) ? '&fontsize='.$used_fontsize : '')
.(!empty($text_direction) ? '&dir='.$text_direction : '')."\">\n";
+
// load custom style sheet (deprecated)
if ( ! empty($theme_css) ) {
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\">\n";
* @param string target the target frame for this link
*/
function makeInternalLink($path, $text, $target='') {
- sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
+ global $base_uri;
+// sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
if ($target != '') {
$target = " target=\"$target\"";
}
displayHtmlHeader ('SquirrelMail');
$sBodyTagJs = '';
}
-
+ /*
+ * this explains the imap_mailbox.php dependency. We should instead store
+ * the selected mailbox in the session and fallback to the session var.
+ */
$shortBoxName = htmlspecialchars(imap_utf7_decode_local(
readShortMailboxName($mailbox, $delimiter)));
if ( $shortBoxName == 'INBOX' ) {
}
echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $sBodyTagJs>\n\n";
}
-?>
\ No newline at end of file
* @package squirrelmail
*/
-/** Everything needs global.. */
-require_once(SM_PATH . 'functions/global.php');
-require_once(SM_PATH . 'config/config.php');
-require_once(SM_PATH . 'functions/prefs.php');
-
-global $squirrelmail_plugin_hooks;
-$squirrelmail_plugin_hooks = array();
-
/**
* This function adds a plugin.
* @param string $name Internal plugin name (ie. delete_move_next)
global $plugins;
/**
- * check if variable is empty. if var is not set, php empty
+ * check if variable is empty. if var is not set, php empty
* returns true without error notice.
*
* then check if it is an array
return false;
}
}
-
-/*************************************/
-/*** MAIN PLUGIN LOADING CODE HERE ***/
-/*************************************/
-
-/* On startup, register all plugins configured for use. */
-if (isset($plugins) && is_array($plugins)) {
- // turn on output buffering in order to prevent output of new lines
- ob_start();
- foreach ($plugins as $name) {
- use_plugin($name);
- }
- // get output and remove whitespace
- $output = trim(ob_get_contents());
- ob_end_clean();
- // if plugins output more than newlines and spacing, stop script execution.
- if (!empty($output)) {
- die($output);
- }
-}
-
?>
/**
* prefs.php
*
- * This contains functions for manipulating user preferences
+ * This contains functions for filebased user prefs locations
*
* @copyright © 1999-2006 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @subpackage prefs
*/
-/** @ignore */
-if (!defined('SM_PATH')) define('SM_PATH','../');
-/** Include global.php */
-require_once(SM_PATH . 'functions/global.php');
-require_once(SM_PATH . 'functions/plugin.php');
-
-sqgetGlobalVar('prefs_cache', $prefs_cache, SQ_SESSION );
-sqgetGlobalVar('prefs_are_cached', $prefs_are_cached, SQ_SESSION );
-
-if ( !sqsession_is_registered('prefs_are_cached') ||
- !isset( $prefs_cache) ||
- !is_array( $prefs_cache)
- ) {
- $prefs_are_cached = false;
- $prefs_cache = array();
-}
-
-$prefs_backend = do_hook_function('prefs_backend');
-if (isset($prefs_backend) && !empty($prefs_backend) && file_exists(SM_PATH . $prefs_backend)) {
- require_once(SM_PATH . $prefs_backend);
-} elseif (isset($prefs_dsn) && !empty($prefs_dsn)) {
- require_once(SM_PATH . 'functions/db_prefs.php');
-} else {
- require_once(SM_PATH . 'functions/file_prefs.php');
-}
/* Hashing functions */
/* Return our array of hash directories. */
return ($hash_dirs);
}
-
-/**
- * Javascript support detection function
- * @param boolean $reset recheck javascript support if set to true.
- * @return integer SMPREF_JS_ON or SMPREF_JS_OFF ({@see functions/constants.php})
- * @since 1.5.1
- */
-function checkForJavascript($reset = FALSE) {
- global $data_dir, $username, $javascript_on, $javascript_setting;
-
- if ( !$reset && sqGetGlobalVar('javascript_on', $javascript_on, SQ_SESSION) )
- return $javascript_on;
-
- if ( $reset || !isset($javascript_setting) )
- $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT);
-
- if ( !sqGetGlobalVar('new_js_autodetect_results', $js_autodetect_results) &&
- !sqGetGlobalVar('js_autodetect_results', $js_autodetect_results) )
- $js_autodetect_results = SMPREF_JS_OFF;
-
- if ( $javascript_setting == SMPREF_JS_AUTODETECT )
- $javascript_on = $js_autodetect_results;
- else
- $javascript_on = $javascript_setting;
-
- sqsession_register($javascript_on, 'javascript_on');
- return $javascript_on;
-}
-
?>
\ No newline at end of file
* @package squirrelmail
*/
-/** @ignore */
-if (!defined('SM_PATH')) define('SM_PATH','../');
-
-/**
- * SquirrelMail version number -- DO NOT CHANGE
- */
-global $version;
-$version = '1.5.2 [CVS]';
-
-/**
- * SquirrelMail internal version number -- DO NOT CHANGE
- * $sm_internal_version = array (release, major, minor)
- */
-global $SQM_INTERNAL_VERSION;
-$SQM_INTERNAL_VERSION = array(1,5,2);
-
-/**
- * There can be a circular issue with includes, where the $version string is
- * referenced by the include of global.php, etc. before it's defined.
- * For that reason, bring in global.php AFTER we define the version strings.
- */
-include_once(SM_PATH . 'functions/global.php');
-
-/**
- * Include Compatibility plugin if available.
- */
-if (file_exists(SM_PATH . 'plugins/compatibility/functions.php'))
- include_once(SM_PATH . 'plugins/compatibility/functions.php');
-
/**
* Appends citation markers to the string.
* Also appends a trailing space.
return( $elem );
}
-/**
- * Find out where SquirrelMail lives and try to be smart about it.
- * The only problem would be when SquirrelMail lives in directories
- * called "src", "functions", or "plugins", but people who do that need
- * to be beaten with a steel pipe anyway.
- *
- * @return string the base uri of SquirrelMail installation.
- * @since 1.2.6
- */
-function sqm_baseuri(){
- global $base_uri, $PHP_SELF;
- /**
- * If it is in the session, just return it.
- */
- if (sqgetGlobalVar('base_uri',$base_uri,SQ_SESSION)){
- return $base_uri;
- }
- $dirs = array('|src/.*|', '|plugins/.*|', '|functions/.*|');
- $repl = array('', '', '');
- $base_uri = preg_replace($dirs, $repl, $PHP_SELF);
- return $base_uri;
-}
/**
* get_location
* @package squirrelmail
*/
-/** @ignore */
-if (! defined('SM_PATH')) define('SM_PATH','../');
-
-/** Clearly, this needs the IMAP functions.. */
-require_once(SM_PATH . 'functions/imap.php');
/**
* Recursive function to find the correct parent for a new node.
--- /dev/null
+<?php
+
+/**
+ * constants.php
+ *
+ * Loads constants used by the rest of the SquirrelMail source.
+ * This file is include by src/login.php, src/redirect.php and
+ * src/load_prefs.php.
+ *
+ * @copyright © 1999-2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ * @since 1.2.0
+ */
+
+/** @ignore */
+
+/**************************************************************/
+/* Set values for constants used by SquirrelMail preferences. */
+/**************************************************************/
+
+/**
+ * Define basic, general purpose preference constants.
+ * @since 1.2.0
+ */
+define('SMPREF_NO', 0);
+define('SMPREF_OFF', 0);
+define('SMPREF_YES', 1);
+define('SMPREF_ON', 1);
+define('SMPREF_NONE', 'none');
+
+/**
+ * Define constants for location based preferences.
+ * @since 1.2.0
+ */
+define('SMPREF_LOC_TOP', 'top');
+define('SMPREF_LOC_BETWEEN', 'between');
+define('SMPREF_LOC_BOTTOM', 'bottom');
+define('SMPREF_LOC_LEFT', '');
+define('SMPREF_LOC_RIGHT', 'right');
+
+/**
+ * Define preferences for folder settings.
+ * @since 1.2.0
+ */
+define('SMPREF_UNSEEN_NONE', 1);
+define('SMPREF_UNSEEN_INBOX', 2);
+define('SMPREF_UNSEEN_ALL', 3);
+define('SMPREF_UNSEEN_SPECIAL', 4); // Only special folders (since 1.2.5)
+define('SMPREF_UNSEEN_NORMAL', 5); // Only normal folders (since 1.2.5)
+define('SMPREF_UNSEEN_ONLY', 1);
+define('SMPREF_UNSEEN_TOTAL', 2);
+
+/**
+ * Define constants for time/date display preferences.
+ * @since 1.2.0
+ */
+define('SMPREF_TIME_24HR', 1);
+define('SMPREF_TIME_12HR', 2);
+
+/**
+ * Define constants for javascript preferences.
+ * @since 1.2.0
+ */
+define('SMPREF_JS_OFF', 0);
+define('SMPREF_JS_ON', 1);
+define('SMPREF_JS_AUTODETECT', 2);
+
+/**
+ * default value for page_selector_max
+ * @since 1.5.1
+ */
+define('PG_SEL_MAX', 10);
+
+
+/**
+ * The number of pages to cache msg headers
+ * @since 1.5.1
+ */
+define('SQM_MAX_PAGES_IN_CACHE',5);
+
+/**
+ * The number of mailboxes to cache msg headers
+ * @since 1.5.1
+ */
+define('SQM_MAX_MBX_IN_CACHE',3);
+
+/**
+ * Sort constants used for sorting of messages
+ * @since 1.5.1
+ */
+define('SQSORT_NONE',0);
+define('SQSORT_DATE_ASC',1);
+define('SQSORT_DATE_DESC',2);
+define('SQSORT_FROM_ASC',3);
+define('SQSORT_FROM_DESC',4);
+define('SQSORT_SUBJ_ASC',5);
+define('SQSORT_SUBJ_DESC',6);
+define('SQSORT_SIZE_ASC',7);
+define('SQSORT_SIZE_DESC',8);
+define('SQSORT_TO_ASC',9);
+define('SQSORT_TO_DESC',10);
+define('SQSORT_CC_ASC',11);
+define('SQSORT_CC_DESC',12);
+define('SQSORT_INT_DATE_ASC',13);
+define('SQSORT_INT_DATE_DESC',14);
+
+/**
+ * Special sort constant thread which is added to above sort mode.
+ * By doing a bitwise check ($sort & SQSORT_THREAD) we know if the mailbox
+ * is sorted by thread.
+ * @since 1.5.1
+ */
+define('SQSORT_THREAD',32);
+
+/**
+ * Mailbox preference array keys
+ * @since 1.5.1
+ */
+define('MBX_PREF_SORT',0);
+define('MBX_PREF_LIMIT',1);
+define('MBX_PREF_AUTO_EXPUNGE',2);
+define('MBX_PREF_INTERNALDATE',3);
+define('MBX_PREF_COLUMNS',4);
+// define('MBX_PREF_FUTURE',unique integer key);
+
+/**
+ * Email address array keys
+ * @since 1.5.1
+ */
+define('SQM_ADDR_PERSONAL', 0);
+define('SQM_ADDR_ADL', 1);
+define('SQM_ADDR_MAILBOX', 2);
+define('SQM_ADDR_HOST', 3);
+
+/**
+ * Supported columns to show in a messages list
+ * The MBX_PREF_COLUMNS contains an ordered array with these columns
+ * @since 1.5.1
+ */
+define('SQM_COL_CHECK',0);
+define('SQM_COL_FROM',1);
+define('SQM_COL_DATE', 2);
+define('SQM_COL_SUBJ', 3);
+define('SQM_COL_FLAGS', 4);
+define('SQM_COL_SIZE', 5);
+define('SQM_COL_PRIO', 6);
+define('SQM_COL_ATTACHMENT', 7);
+define('SQM_COL_INT_DATE', 8);
+define('SQM_COL_TO', 9);
+define('SQM_COL_CC', 10);
+define('SQM_COL_BCC', 11);
+
+/** @since 1.2.0 */
+do_hook('loading_constants');
+
+?>
\ No newline at end of file
'category' => SQM_ERROR_IMAP,
'message' => _( "Out of quota error."),
'link' => '',
- 'tip' => _("Remove unneccessary messages from your folders. Start with your Trash folder.")
+ 'tip' => _("Remove unneccessary messages from your folder. Start with your Trash folder.")
);
$aErrors['SQM_IMAP_APPEND_ERROR'] = array(
--- /dev/null
+<?php
+
+/**
+ * init.php -- initialisation file
+ *
+ * File should be loaded in every file in src/ or plugins that occupate an entire frame
+ *
+ * @copyright © 2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ */
+
+/**
+ * SquirrelMail version number -- DO NOT CHANGE
+ */
+
+$version = '1.5.2 [CVS]';
+
+/**
+ * SquirrelMail internal version number -- DO NOT CHANGE
+ * $sm_internal_version = array (release, major, minor)
+ */
+
+$SQM_INTERNAL_VERSION = array(1,5,2);
+
+/**
+ * This is a development version so in order to track programmer mistakes we
+ * set the error reporting to E_ALL
+ */
+
+error_reporting(E_ALL);
+
+
+/**
+ * calculate SM_PATH and calculate the base_uri
+ * assumptions made: init.php is only called from plugins or from the src dir.
+ * files in the plugin directory may not be part of a subdirectory called "src"
+ *
+ */
+if (isset($_SERVER['SCRIPT_NAME'])) {
+ $a = explode('/',$_SERVER['SCRIPT_NAME']);
+} elseif (isset($HTTP_SERVER_VARS['SCRIPT_NAME'])) {
+ $a = explode('/',$_SERVER['SCRIPT_NAME']);
+}
+$sSM_PATH = '';
+for($i = count($a) -2;$i > -1; --$i) {
+ $sSM_PATH .= '../';
+ if ($a[$i] === 'src' || $a[$i] === 'plugins') {
+ break;
+ }
+}
+
+$base_uri = implode('/',array_slice($a,0,$i)). '/';
+
+
+
+define('SM_PATH',$sSM_PATH);
+
+/**
+ * global var $bInit is used to check if initialisation took place.
+ * At this moment it's a workarounf for the include of addrbook_search_html
+ * inside compose.php. If we found a better way then remove this. Do only use
+ * this var if you know for sure a page can be called stand alone and be included
+ * in another file.
+ */
+$bInit = true;
+
+require(SM_PATH . 'functions/global.php');
+require(SM_PATH . 'config/config.php');
+require(SM_PATH . 'functions/plugin.php');
+require(SM_PATH . 'include/constants.php');
+require(SM_PATH . 'include/languages.php');
+
+/**
+ * If magic_quotes_runtime is on, SquirrelMail breaks in new and creative ways.
+ * Force magic_quotes_runtime off.
+ * tassium@squirrelmail.org - I put it here in the hopes that all SM code includes this.
+ * If there's a better place, please let me know.
+ */
+ini_set('magic_quotes_runtime','0');
+
+
+/* if running with magic_quotes_gpc then strip the slashes
+ from POST and GET global arrays */
+if (get_magic_quotes_gpc()) {
+ sqstripslashes($_GET);
+ sqstripslashes($_POST);
+}
+
+/**
+ * If register_globals are on, unregister globals.
+ * Code requires PHP 4.1.0 or newer.
+ */
+if ((bool) @ini_get('register_globals')) {
+ /**
+ * Remove all globals from $_GET, $_POST, and $_COOKIE.
+ */
+ foreach ($_REQUEST as $key => $value) {
+ unset($GLOBALS[$key]);
+ }
+ /**
+ * Remove globalized $_FILES variables
+ * Before 4.3.0 $_FILES are included in $_REQUEST.
+ * Unglobalize them in separate call in order to remove dependency
+ * on PHP version.
+ */
+ foreach ($_FILES as $key => $value) {
+ unset($GLOBALS[$key]);
+ // there are three undocumented $_FILES globals.
+ unset($GLOBALS[$key.'_type']);
+ unset($GLOBALS[$key.'_name']);
+ unset($GLOBALS[$key.'_size']);
+ }
+ /**
+ * Remove globalized environment variables.
+ */
+ foreach ($_ENV as $key => $value) {
+ unset($GLOBALS[$key]);
+ }
+ /**
+ * Remove globalized server variables.
+ */
+ foreach ($_SERVER as $key => $value) {
+ unset($GLOBALS[$key]);
+ }
+}
+
+/* strip any tags added to the url from PHP_SELF.
+This fixes hand crafted url XXS expoits for any
+ page that uses PHP_SELF as the FORM action */
+$_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
+
+$PHP_SELF = php_self();
+
+/**
+ * Initialize the session
+ */
+
+/**
+ * includes from classes stored in the session
+ */
+require(SM_PATH . 'class/mime.class.php');
+
+/** set the name of the session cookie */
+if (!isset($session_name) || !$session_name) {
+ $session_name = 'SQMSESSID';
+}
+ini_set('session.name' , $session_name);
+session_set_cookie_params (0, $base_uri);
+sqsession_is_active();
+
+sqsession_register($base_uri, 'base_uri');
+
+/**
+ * Remove globalized session data in rg=on setups
+ */
+if ((bool) @ini_get('register_globals')) {
+ foreach ($_SESSION as $key => $value) {
+ unset($GLOBALS[$key]);
+ }
+}
+/**
+ * Retrieve the language cookie
+ */
+if (! sqgetGlobalVar('squirrelmail_language',$squirrelmail_language,SQ_COOKIE)) {
+ $squirrelmail_language = '';
+}
+
+
+/**
+ * @var $sInitlocation From where do we include.
+ */
+if (!isset($sInitLocation)) {
+ $sInitLocation=NULL;
+}
+
+/**
+ * MAIN PLUGIN LOADING CODE HERE
+ */
+
+/**
+ * Include Compatibility plugin if available.
+ */
+if (file_exists(SM_PATH . 'plugins/compatibility/functions.php'))
+ include_once(SM_PATH . 'plugins/compatibility/functions.php');
+$squirrelmail_plugin_hooks = array();
+
+/* On init, register all plugins configured for use. */
+if (isset($plugins) && is_array($plugins)) {
+ // turn on output buffering in order to prevent output of new lines
+ ob_start();
+ foreach ($plugins as $name) {
+ use_plugin($name);
+ }
+ // get output and remove whitespace
+ $output = trim(ob_get_contents());
+ ob_end_clean();
+ // if plugins output more than newlines and spacing, stop script execution.
+ if (!empty($output)) {
+ die($output);
+ }
+}
+
+
+switch ($sInitLocation) {
+ case 'style': session_write_close(); sqsetcookieflush(); break;
+ case 'redirect':
+ $prefs_backend = do_hook_function('prefs_backend');
+ if (isset($prefs_backend) && !empty($prefs_backend) && file_exists(SM_PATH . $prefs_backend)) {
+ require(SM_PATH . $prefs_backend);
+ } elseif (isset($prefs_dsn) && !empty($prefs_dsn)) {
+ require(SM_PATH . 'functions/db_prefs.php');
+ } else {
+ require(SM_PATH . 'functions/prefs.php');
+ require(SM_PATH . 'functions/file_prefs.php');
+ }
+ //nobreak;
+ case 'login':
+ require(SM_PATH . 'functions/display_messages.php' );
+ require(SM_PATH . 'functions/page_header.php');
+ require(SM_PATH . 'functions/html.php');
+ break;
+ default:
+ require(SM_PATH . 'functions/display_messages.php' );
+ require(SM_PATH . 'functions/page_header.php');
+ require(SM_PATH . 'functions/html.php');
+ require(SM_PATH . 'functions/strings.php');
+
+
+ /**
+ * Check if we are logged in
+ */
+ require(SM_PATH . 'functions/auth.php');
+
+ if ( !sqsession_is_registered('user_is_logged_in') ) {
+ // First we store some information in the new session to prevent
+ // information-loss.
+ //
+ $session_expired_post = $_POST;
+ $session_expired_location = $PHP_SELF;
+ if (!sqsession_is_registered('session_expired_post')) {
+ sqsession_register($session_expired_post,'session_expired_post');
+ }
+ if (!sqsession_is_registered('session_expired_location')) {
+ sqsession_register($session_expired_location,'session_expired_location');
+ }
+ // signout page will deal with users who aren't logged
+ // in on its own; don't show error here
+ //
+ if (strpos($PHP_SELF, 'signout.php') !== FALSE) {
+ return;
+ }
+
+ set_up_language($squirrelmail_language, true);
+ logout_error( _("You must be logged in to access this page.") );
+ exit;
+ }
+
+ sqgetGlobalVar('username',$username,SQ_SESSION);
+
+ /**
+ * Setting the prefs backend
+ */
+ sqgetGlobalVar('prefs_cache', $prefs_cache, SQ_SESSION );
+ sqgetGlobalVar('prefs_are_cached', $prefs_are_cached, SQ_SESSION );
+
+ if ( !sqsession_is_registered('prefs_are_cached') ||
+ !isset( $prefs_cache) ||
+ !is_array( $prefs_cache)) {
+ $prefs_are_cached = false;
+ $prefs_cache = false; //array();
+ }
+
+ $prefs_backend = do_hook_function('prefs_backend');
+ if (isset($prefs_backend) && !empty($prefs_backend) && file_exists(SM_PATH . $prefs_backend)) {
+ require(SM_PATH . $prefs_backend);
+ } elseif (isset($prefs_dsn) && !empty($prefs_dsn)) {
+ require(SM_PATH . 'functions/db_prefs.php');
+ } else {
+ require(SM_PATH . 'functions/prefs.php');
+ require(SM_PATH . 'functions/file_prefs.php');
+ }
+
+ /**
+ * initializing user settings
+ */
+ require(SM_PATH . 'include/load_prefs.php');
+
+
+// i do not understand the frames language cookie story
+ /**
+ * We'll need this to later have a noframes version
+ *
+ * Check if the user has a language preference, but no cookie.
+ * Send him a cookie with his language preference, if there is
+ * such discrepancy.
+ */
+ $my_language = getPref($data_dir, $username, 'language');
+ if ($my_language != $squirrelmail_language) {
+ sqsetcookie('squirrelmail_language', $my_language, time()+2592000, $base_uri);
+ }
+// /dont understand
+
+ /**
+ * Set up the language.
+ */
+ $err=set_up_language(getPref($data_dir, $username, 'language'));
+ /* this is the last cookie we set so flush it. */
+ sqsetcookieflush();
+
+ // Japanese translation used without mbstring support
+ if ($err==2) {
+ $sError =
+ "<p>You need to have PHP installed with the multibyte string function \n".
+ "enabled (using configure option --enable-mbstring).</p>\n".
+ "<p>System assumed that you accidently switched to Japanese translation \n".
+ "and reverted your language preference to English.</p>\n".
+ "<p>Please refresh this page in order to use webmail.</p>\n";
+ error_box($sError);
+ }
+
+ $timeZone = getPref($data_dir, $username, 'timezone');
+
+ /* Check to see if we are allowed to set the TZ environment variable.
+ * We are able to do this if ...
+ * safe_mode is disabled OR
+ * safe_mode_allowed_env_vars is empty (you are allowed to set any) OR
+ * safe_mode_allowed_env_vars contains TZ
+ */
+ $tzChangeAllowed = (!ini_get('safe_mode')) ||
+ !strcmp(ini_get('safe_mode_allowed_env_vars'),'') ||
+ preg_match('/^([\w_]+,)*TZ/', ini_get('safe_mode_allowed_env_vars'));
+
+ if ( $timeZone != SMPREF_NONE && ($timeZone != "")
+ && $tzChangeAllowed ) {
+
+ // get time zone key, if strict or custom strict timezones are used
+ if (isset($time_zone_type) &&
+ ($time_zone_type == 1 || $time_zone_type == 3)) {
+ /* load time zone functions */
+ require(SM_PATH . 'include/timezones.php');
+ $realTimeZone = sq_get_tz_key($timeZone);
+ } else {
+ $realTimeZone = $timeZone;
+ }
+
+ // set time zone
+ if ($realTimeZone) {
+ putenv("TZ=".$realTimeZone);
+ }
+ }
+ break;
+}
+
+/**
+ * Initialize the template object
+ */
+require(SM_PATH . 'class/template/template.class.php');
+/*
+ * $sTplDir is not initialized when a user is not logged in, so we will use
+ * the config file defaults here. If the neccesary variables are net set,
+ * force a default value.
+ */
+$aTemplateSet = ( !isset($aTemplateSet) ? array() : $aTemplateSet );
+$templateset_default = ( !isset($templateset_default) ? 0 : $templateset_default );
+
+$sTplDir = ( !isset($aTemplateSet[$templateset_default]['PATH']) ?
+ SM_PATH . 'templates/default/' :
+ $aTemplateSet[$templateset_default]['PATH'] );
+$oTemplate = new Template($sTplDir);
+
+/**
+ * Initialize our custom error handler object
+ */
+require(SM_PATH . 'class/error.class.php');
+$oErrorHandler = new ErrorHandler($oTemplate,'error_message.tpl');
+
+/**
+ * Activate custom error handling
+ */
+if (version_compare(PHP_VERSION, "4.3.0", ">=")) {
+ $oldErrorHandler = set_error_handler(array($oErrorHandler, 'SquirrelMailErrorhandler'));
+} else {
+ $oldErrorHandler = set_error_handler('SquirrelMailErrorhandler');
+}
+
+/**
+ * Javascript support detection function
+ * @param boolean $reset recheck javascript support if set to true.
+ * @return integer SMPREF_JS_ON or SMPREF_JS_OFF ({@see functions/constants.php})
+ * @since 1.5.1
+ */
+
+function checkForJavascript($reset = FALSE) {
+ global $data_dir, $username, $javascript_on, $javascript_setting;
+
+ if ( !$reset && sqGetGlobalVar('javascript_on', $javascript_on, SQ_SESSION) )
+ return $javascript_on;
+
+ if ( $reset || !isset($javascript_setting) )
+ $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT);
+
+ if ( !sqGetGlobalVar('new_js_autodetect_results', $js_autodetect_results) &&
+ !sqGetGlobalVar('js_autodetect_results', $js_autodetect_results) )
+ $js_autodetect_results = SMPREF_JS_OFF;
+
+ if ( $javascript_setting == SMPREF_JS_AUTODETECT )
+ $javascript_on = $js_autodetect_results;
+ else
+ $javascript_on = $javascript_setting;
+
+ sqsession_register($javascript_on, 'javascript_on');
+ return $javascript_on;
+}
+
+function sqm_baseuri() {
+ global $base_uri;
+ return $base_uri;
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/**
+ * SquirrelMail internationalization functions
+ *
+ * This file contains variuos functions that are needed to do
+ * internationalization of SquirrelMail.
+ *
+ * Internally the output character set is used. Other characters are
+ * encoded using Unicode entities according to HTML 4.0.
+ *
+ * @copyright © 1999-2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ * @subpackage i18n
+ */
+
+
+/**
+ * Gettext bindtextdomain wrapper.
+ *
+ * Wrapper solves differences between php versions in order to provide
+ * ngettext support. Should be used if translation uses ngettext
+ * functions.
+ * @since 1.5.1
+ * @param string $domain gettext domain name
+ * @param string $dir directory that contains all translations
+ * @return string path to translation directory
+ */
+function sq_bindtextdomain($domain,$dir) {
+ global $l10n, $gettext_flags, $sm_notAlias;
+
+ if ($gettext_flags==7) {
+ // gettext extension without ngettext
+ if (substr($dir, -1) != '/') $dir .= '/';
+ $mofile=$dir . $sm_notAlias . '/LC_MESSAGES/' . $domain . '.mo';
+ $input = new FileReader($mofile);
+ $l10n[$domain] = new gettext_reader($input);
+ }
+
+ $dir=bindtextdomain($domain,$dir);
+
+ return $dir;
+}
+
+/**
+ * Gettext textdomain wrapper.
+ * Makes sure that gettext_domain global is modified.
+ * @since 1.5.1
+ * @param string $name gettext domain name
+ * @return string gettext domain name
+ */
+function sq_textdomain($domain) {
+ global $gettext_domain;
+ $gettext_domain=textdomain($domain);
+ return $gettext_domain;
+}
+
+/**
+ * php setlocale function wrapper
+ *
+ * From php 4.3.0 it is possible to use arrays in order to set locale.
+ * php gettext extension works only when locale is set. This wrapper
+ * function allows to use more than one locale name.
+ *
+ * @param int $category locale category name. Use php named constants
+ * (LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME)
+ * @param mixed $locale option contains array with possible locales or string with one locale
+ * @return string name of set locale or false, if all locales fail.
+ * @since 1.5.1 and 1.4.5
+ * @see http://www.php.net/setlocale
+ */
+function sq_setlocale($category,$locale) {
+ // string with only one locale
+ if (is_string($locale))
+ return setlocale($category,$locale);
+
+ if (! check_php_version(4,3)) {
+ $ret=false;
+ $index=0;
+ while ( ! $ret && $index<count($locale)) {
+ $ret=setlocale($category,$locale[$index]);
+ $index++;
+ }
+ } else {
+ // php 4.3.0 or better, use entire array
+ $ret=setlocale($category,$locale);
+ }
+ return $ret;
+}
+
+/**
+ * Converts string from given charset to charset, that can be displayed by user translation.
+ *
+ * Function by default returns html encoded strings, if translation uses different encoding.
+ * If Japanese translation is used - function returns string converted to euc-jp
+ * If iconv or recode functions are enabled and translation uses utf-8 - function returns utf-8 encoded string.
+ * If $charset is not supported - function returns unconverted string.
+ *
+ * sanitizing of html tags is also done by this function.
+ *
+ * @param string $charset
+ * @param string $string Text to be decoded
+ * @param boolean $force_decode converts string to html without $charset!=$default_charset check.
+ * Argument is available since 1.5.1 and 1.4.5.
+ * @param boolean $save_html disables htmlspecialchars() in order to preserve
+ * html formating. Use with care. Available since 1.5.1
+ * @return string decoded string
+ */
+function charset_decode ($charset, $string, $force_decode=false, $save_html=false) {
+ global $languages, $squirrelmail_language, $default_charset;
+ global $use_php_recode, $use_php_iconv, $aggressive_decoding;
+
+ if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
+ function_exists($languages[$squirrelmail_language]['XTRA_CODE'] . '_decode')) {
+ $string = call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_decode', $string);
+ }
+
+ $charset = strtolower($charset);
+
+ set_my_charset();
+
+ // Variables that allow to use functions without function_exist() calls
+ if (! isset($use_php_recode) || $use_php_recode=="" ) {
+ $use_php_recode=false; }
+ if (! isset($use_php_iconv) || $use_php_iconv=="" ) {
+ $use_php_iconv=false; }
+
+ // Don't do conversion if charset is the same.
+ if ( ! $force_decode && $charset == strtolower($default_charset) )
+ return ($save_html ? $string : htmlspecialchars($string));
+
+ // catch iso-8859-8-i thing
+ if ( $charset == "iso-8859-8-i" )
+ $charset = "iso-8859-8";
+
+ /*
+ * Recode converts html special characters automatically if you use
+ * 'charset..html' decoding. There is no documented way to put -d option
+ * into php recode function call.
+ */
+ if ( $use_php_recode ) {
+ if ( $default_charset == "utf-8" ) {
+ // other charsets can be converted to utf-8 without loss.
+ // and output string is smaller
+ $string = recode_string($charset . "..utf-8",$string);
+ return ($save_html ? $string : htmlspecialchars($string));
+ } else {
+ $string = recode_string($charset . "..html",$string);
+ // recode does not convert single quote, htmlspecialchars does.
+ $string = str_replace("'", ''', $string);
+ // undo html specialchars
+ if ($save_html)
+ $string=str_replace(array('&','"','<','>'),
+ array('&','"','<','>'),$string);
+ return $string;
+ }
+ }
+
+ // iconv functions does not have html target and can be used only with utf-8
+ if ( $use_php_iconv && $default_charset=='utf-8') {
+ $string = iconv($charset,$default_charset,$string);
+ return ($save_html ? $string : htmlspecialchars($string));
+ }
+
+ // If we don't use recode and iconv, we'll do it old way.
+
+ /* All HTML special characters are 7 bit and can be replaced first */
+ if (! $save_html) $string = htmlspecialchars ($string);
+
+ /* controls cpu and memory intensive decoding cycles */
+ if (! isset($aggressive_decoding) || $aggressive_decoding=="" ) {
+ $aggressive_decoding=false; }
+
+ $decode=fixcharset($charset);
+ $decodefile=SM_PATH . 'functions/decode/' . $decode . '.php';
+ if (file_exists($decodefile)) {
+ include_once($decodefile);
+ // send $save_html argument to decoding function. needed for iso-2022-xx decoding.
+ $ret = call_user_func('charset_decode_'.$decode, $string, $save_html);
+ } else {
+ $ret = $string;
+ }
+ return( $ret );
+}
+
+/**
+ * Converts html string to given charset
+ * @since 1.5.1 and 1.4.4
+ * @param string $string
+ * @param string $charset
+ * @param boolean $htmlencode keep htmlspecialchars encoding
+ * @param string
+ */
+function charset_encode($string,$charset,$htmlencode=true) {
+ global $default_charset;
+
+ $encode=fixcharset($charset);
+ $encodefile=SM_PATH . 'functions/encode/' . $encode . '.php';
+ if (file_exists($encodefile)) {
+ include_once($encodefile);
+ $ret = call_user_func('charset_encode_'.$encode, $string);
+ } elseif(file_exists(SM_PATH . 'functions/encode/us_ascii.php')) {
+ // function replaces all 8bit html entities with question marks.
+ // it is used when other encoding functions are unavailable
+ include_once(SM_PATH . 'functions/encode/us_ascii.php');
+ $ret = charset_encode_us_ascii($string);
+ } else {
+ /**
+ * fix for yahoo users that remove all us-ascii related things
+ */
+ $ret = $string;
+ }
+
+ /**
+ * Undo html special chars, some places (like compose form) have
+ * own sanitizing functions and don't need html symbols.
+ * Undo chars only after encoding in order to prevent conversion of
+ * html entities in plain text emails.
+ */
+ if (! $htmlencode ) {
+ $ret = str_replace(array('&','>','<','"'),array('&','>','<','"'),$ret);
+ }
+ return( $ret );
+}
+
+/**
+ * Combined decoding and encoding functions
+ *
+ * If conversion is done to charset different that utf-8, unsupported symbols
+ * will be replaced with question marks.
+ * @since 1.5.1 and 1.4.4
+ * @param string $in_charset initial charset
+ * @param string $string string that has to be converted
+ * @param string $out_charset final charset
+ * @param boolean $htmlencode keep htmlspecialchars encoding
+ * @return string converted string
+ */
+function charset_convert($in_charset,$string,$out_charset,$htmlencode=true) {
+ $string=charset_decode($in_charset,$string,true);
+ $string=sqi18n_convert_entities($string);
+ $string=charset_encode($string,$out_charset,$htmlencode);
+ return $string;
+}
+
+/**
+ * Makes charset name suitable for decoding cycles
+ *
+ * @since 1.5.0 and 1.4.4
+ * @param string $charset Name of charset
+ * @return string $charset Adjusted name of charset
+ */
+function fixcharset($charset) {
+ /* remove minus and characters that might be used in paths from charset
+ * name in order to be able to use it in function names and include calls.
+ */
+ $charset=preg_replace("/[-:.\/\\\]/",'_',$charset);
+
+ // OE ks_c_5601_1987 > cp949
+ $charset=str_replace('ks_c_5601_1987','cp949',$charset);
+ // Moz x-euc-tw > euc-tw
+ $charset=str_replace('x_euc','euc',$charset);
+ // Moz x-windows-949 > cp949
+ $charset=str_replace('x_windows_','cp',$charset);
+
+ // windows-125x and cp125x charsets
+ $charset=str_replace('windows_','cp',$charset);
+
+ // ibm > cp
+ $charset=str_replace('ibm','cp',$charset);
+
+ // iso-8859-8-i -> iso-8859-8
+ // use same cycle until I'll find differences
+ $charset=str_replace('iso_8859_8_i','iso_8859_8',$charset);
+
+ return $charset;
+}
+
+/**
+ * Set up the language to be output
+ * if $do_search is true, then scan the browser information
+ * for a possible language that we know
+ *
+ * Function sets system locale environment (LC_ALL, LANG, LANGUAGE),
+ * gettext translation bindings and html header information.
+ *
+ * Function returns error codes, if there is some fatal error.
+ * 0 = no error,
+ * 1 = mbstring support is not present,
+ * 2 = mbstring support is not present, user's translation reverted to en_US.
+ *
+ * @param string $sm_language translation used by user's interface
+ * @param bool $do_search use browser's preferred language detection functions. Defaults to false.
+ * @param bool $default set $sm_language to $squirrelmail_default_language if language detection fails or language is not set. Defaults to false.
+ * @return int function execution error codes.
+ */
+function set_up_language($sm_language, $do_search = false, $default = false) {
+
+ static $SetupAlready = 0;
+ global $use_gettext, $languages,
+ $squirrelmail_language, $squirrelmail_default_language, $default_charset,
+ $sm_notAlias, $username, $data_dir;
+
+ if ($SetupAlready) {
+ return;
+ }
+
+ $SetupAlready = TRUE;
+ sqgetGlobalVar('HTTP_ACCEPT_LANGUAGE', $accept_lang, SQ_SERVER);
+
+ /**
+ * If function is asked to detect preferred language
+ * OR squirrelmail default language is set to empty string
+ * AND
+ * squirrelmail language ($sm_language) is empty string
+ * (not set in user's prefs and no cookie with language info)
+ * AND
+ * browser provides list of preferred languages
+ * THEN
+ * get preferred language from HTTP_ACCEPT_LANGUAGE header
+ */
+ if (($do_search || empty($squirrelmail_default_language)) &&
+ ! $sm_language &&
+ isset($accept_lang)) {
+ // TODO: use more than one language, if first language is not available
+ // FIXME: function assumes that string contains two or more characters.
+ // FIXME: some languages use 5 chars
+ $sm_language = substr($accept_lang, 0, 2);
+ }
+
+ /**
+ * If language preference is not set OR script asks to use default language
+ * AND
+ * default squirrelmail language is not set to empty string
+ * THEN
+ * use default squirrelmail language value from configuration.
+ */
+ if ((!$sm_language||$default) &&
+ ! empty($squirrelmail_default_language)) {
+ $squirrelmail_language = $squirrelmail_default_language;
+ $sm_language = $squirrelmail_default_language;
+ }
+
+ /** provide failsafe language when detection fails */
+ if (! $sm_language) $sm_language='en_US';
+
+ $sm_notAlias = $sm_language;
+
+ // Catching removed translation
+ // System reverts to English translation if user prefs contain translation
+ // that is not available in $languages array
+ if (!isset($languages[$sm_notAlias])) {
+ $sm_notAlias="en_US";
+ }
+
+ while (isset($languages[$sm_notAlias]['ALIAS'])) {
+ $sm_notAlias = $languages[$sm_notAlias]['ALIAS'];
+ }
+
+ if ( isset($sm_language) &&
+ $use_gettext &&
+ $sm_language != '' &&
+ isset($languages[$sm_notAlias]['CHARSET']) ) {
+ sq_bindtextdomain( 'squirrelmail', SM_PATH . 'locale/' );
+ sq_textdomain( 'squirrelmail' );
+
+ // set codeset in order to avoid gettext charset conversions
+ if (function_exists('bind_textdomain_codeset')) {
+ // Japanese translation uses different internal charset
+ if ($sm_notAlias == 'ja_JP') {
+ bind_textdomain_codeset ('squirrelmail', 'EUC-JP');
+ } else {
+ bind_textdomain_codeset ('squirrelmail', $languages[$sm_notAlias]['CHARSET'] );
+ }
+ }
+
+ // Use LOCALE key, if it is set.
+ if (isset($languages[$sm_notAlias]['LOCALE'])){
+ $longlocale=$languages[$sm_notAlias]['LOCALE'];
+ } else {
+ $longlocale=$sm_notAlias;
+ }
+
+ // try setting locale
+ $retlocale=sq_setlocale(LC_ALL, $longlocale);
+
+ // check if locale is set and assign that locale to $longlocale
+ // in order to use it in putenv calls.
+ if (! is_bool($retlocale)) {
+ $longlocale=$retlocale;
+ } elseif (is_array($longlocale)) {
+ // setting of all locales failed.
+ // we need string instead of array used in LOCALE key.
+ $longlocale=$sm_notAlias;
+ }
+
+ if ( !((bool)ini_get('safe_mode')) &&
+ getenv( 'LC_ALL' ) != $longlocale ) {
+ putenv( "LC_ALL=$longlocale" );
+ putenv( "LANG=$longlocale" );
+ putenv( "LANGUAGE=$longlocale" );
+ putenv( "LC_NUMERIC=C" );
+ if ($sm_notAlias=='tr_TR') putenv( "LC_CTYPE=C" );
+ }
+ // Workaround for plugins that use numbers with floating point
+ // It might be removed if plugins use correct decimal delimiters
+ // according to locale settings.
+ setlocale(LC_NUMERIC, 'C');
+ // Workaround for specific Turkish strtolower/strtoupper rules.
+ // Many functions expect English conversion rules.
+ if ($sm_notAlias=='tr_TR') setlocale(LC_CTYPE,'C');
+
+ /**
+ * Set text direction/alignment variables
+ * When language environment is setup, scripts can use these globals
+ * without accessing $languages directly and making checks for optional
+ * array key.
+ */
+ global $text_direction, $left_align, $right_align;
+ if (isset($languages[$sm_notAlias]['DIR']) &&
+ $languages[$sm_notAlias]['DIR'] == 'rtl') {
+ /**
+ * Text direction
+ * @global string $text_direction
+ */
+ $text_direction='rtl';
+ /**
+ * Left alignment
+ * @global string $left_align
+ */
+ $left_align='right';
+ /**
+ * Right alignment
+ * @global string $right_align
+ */
+ $right_align='left';
+ } else {
+ $text_direction='ltr';
+ $left_align='left';
+ $right_align='right';
+ }
+
+ $squirrelmail_language = $sm_notAlias;
+ if ($squirrelmail_language == 'ja_JP') {
+ header ('Content-Type: text/html; charset=EUC-JP');
+ if (!function_exists('mb_internal_encoding')) {
+ // Error messages can't be displayed here
+ $error = 1;
+ // Revert to English if possible.
+ if (function_exists('setPref') && $username!='' && $data_dir!="") {
+ setPref($data_dir, $username, 'language', "en_US");
+ $error = 2;
+ }
+ // stop further execution in order not to get php errors on mb_internal_encoding().
+ return $error;
+ }
+ if (function_exists('mb_language')) {
+ mb_language('Japanese');
+ }
+ mb_internal_encoding('EUC-JP');
+ mb_http_output('pass');
+ } elseif ($squirrelmail_language == 'en_US') {
+ header( 'Content-Type: text/html; charset=' . $default_charset );
+ } else {
+ header( 'Content-Type: text/html; charset=' . $languages[$sm_notAlias]['CHARSET'] );
+ }
+ /**
+ * mbstring.func_overload fix (#929644).
+ *
+ * php mbstring extension can replace standard string functions with their multibyte
+ * equivalents. See http://www.php.net/ref.mbstring#mbstring.overload. This feature
+ * was added in php v.4.2.0
+ *
+ * Some SquirrelMail functions work with 8bit strings in bytes. If interface is forced
+ * to use mbstring functions and mbstring internal encoding is set to multibyte charset,
+ * interface can't trust regular string functions. Due to mbstring overloading design
+ * limits php scripts can't control this setting.
+ *
+ * This hack should fix some issues related to 8bit strings in passwords. Correct fix is
+ * to disable mbstring overloading. Japanese translation uses different internal encoding.
+ */
+ if ($squirrelmail_language != 'ja_JP' &&
+ function_exists('mb_internal_encoding') &&
+ check_php_version(4,2,0) &&
+ (int)ini_get('mbstring.func_overload')!=0) {
+ mb_internal_encoding('pass');
+ }
+ }
+ return 0;
+}
+
+/**
+ * Sets default_charset variable according to the one that is used by user's translations.
+ *
+ * Function changes global $default_charset variable in order to be sure, that it
+ * contains charset used by user's translation. Sanity of $squirrelmail_language
+ * and $default_charset combination is also tested.
+ *
+ * There can be a $default_charset setting in the
+ * config.php file, but the user may have a different language
+ * selected for a user interface. This function checks the
+ * language selected by the user and tags the outgoing messages
+ * with the appropriate charset corresponding to the language
+ * selection. This is "more right" (tm), than just stamping the
+ * message blindly with the system-wide $default_charset.
+ */
+function set_my_charset(){
+ global $data_dir, $username, $default_charset, $languages, $squirrelmail_language;
+
+ $my_language = getPref($data_dir, $username, 'language');
+ if (!$my_language) {
+ $my_language = $squirrelmail_language ;
+ }
+ // Catch removed translation
+ if (!isset($languages[$my_language])) {
+ $my_language="en_US";
+ }
+ while (isset($languages[$my_language]['ALIAS'])) {
+ $my_language = $languages[$my_language]['ALIAS'];
+ }
+ $my_charset = $languages[$my_language]['CHARSET'];
+ if ($my_language!='en_US') {
+ $default_charset = $my_charset;
+ }
+}
+
+/**
+ * Replaces non-braking spaces inserted by some browsers with regular space
+ *
+ * This function can be used to replace non-braking space symbols
+ * that are inserted in forms by some browsers instead of normal
+ * space symbol.
+ *
+ * @param string $string Text that needs to be cleaned
+ * @param string $charset Charset used in text
+ * @return string Cleaned text
+ */
+function cleanup_nbsp($string,$charset) {
+
+ // reduce number of case statements
+ if (stristr('iso-8859-',substr($charset,0,9))){
+ $output_charset="iso-8859-x";
+ }
+ if (stristr('windows-125',substr($charset,0,11))){
+ $output_charset="cp125x";
+ }
+ if (stristr('koi8',substr($charset,0,4))){
+ $output_charset="koi8-x";
+ }
+ if (! isset($output_charset)){
+ $output_charset=strtolower($charset);
+ }
+
+// where is non-braking space symbol
+switch($output_charset):
+ case "iso-8859-x":
+ case "cp125x":
+ case "iso-2022-jp":
+ $nbsp="\xA0";
+ break;
+ case "koi8-x":
+ $nbsp="\x9A";
+ break;
+ case "utf-8":
+ $nbsp="\xC2\xA0";
+ break;
+ default:
+ // don't change string if charset is unmatched
+ return $string;
+endswitch;
+
+// return space instead of non-braking space.
+ return str_replace($nbsp,' ',$string);
+}
+
+/**
+ * Function informs if it is safe to convert given charset to the one that is used by user.
+ *
+ * It is safe to use conversion only if user uses utf-8 encoding and when
+ * converted charset is similar to the one that is used by user.
+ *
+ * @param string $input_charset Charset of text that needs to be converted
+ * @return bool is it possible to convert to user's charset
+ */
+function is_conversion_safe($input_charset) {
+ global $languages, $sm_notAlias, $default_charset, $lossy_encoding;
+
+ if (isset($lossy_encoding) && $lossy_encoding )
+ return true;
+
+ // convert to lower case
+ $input_charset = strtolower($input_charset);
+
+ // Is user's locale Unicode based ?
+ if ( $default_charset == "utf-8" ) {
+ return true;
+ }
+
+ // Charsets that are similar
+ switch ($default_charset) {
+ case "windows-1251":
+ if ( $input_charset == "iso-8859-5" ||
+ $input_charset == "koi8-r" ||
+ $input_charset == "koi8-u" ) {
+ return true;
+ } else {
+ return false;
+ }
+ case "windows-1257":
+ if ( $input_charset == "iso-8859-13" ||
+ $input_charset == "iso-8859-4" ) {
+ return true;
+ } else {
+ return false;
+ }
+ case "iso-8859-4":
+ if ( $input_charset == "iso-8859-13" ||
+ $input_charset == "windows-1257" ) {
+ return true;
+ } else {
+ return false;
+ }
+ case "iso-8859-5":
+ if ( $input_charset == "windows-1251" ||
+ $input_charset == "koi8-r" ||
+ $input_charset == "koi8-u" ) {
+ return true;
+ } else {
+ return false;
+ }
+ case "iso-8859-13":
+ if ( $input_charset == "iso-8859-4" ||
+ $input_charset == "windows-1257" ) {
+ return true;
+ } else {
+ return false;
+ }
+ case "koi8-r":
+ if ( $input_charset == "windows-1251" ||
+ $input_charset == "iso-8859-5" ||
+ $input_charset == "koi8-u" ) {
+ return true;
+ } else {
+ return false;
+ }
+ case "koi8-u":
+ if ( $input_charset == "windows-1251" ||
+ $input_charset == "iso-8859-5" ||
+ $input_charset == "koi8-r" ) {
+ return true;
+ } else {
+ return false;
+ }
+ default:
+ return false;
+ }
+}
+
+/**
+ * Converts html character entities to numeric entities
+ *
+ * SquirrelMail encoding functions work only with numeric entities.
+ * This function fixes issues with decoding functions that might convert
+ * some symbols to character entities. Issue is specific to PHP recode
+ * extension decoding. Function is used internally in charset_convert()
+ * function.
+ * @param string $str string that might contain html character entities
+ * @return string string with character entities converted to decimals.
+ * @since 1.5.2
+ */
+function sqi18n_convert_entities($str) {
+
+ $entities = array(
+ // Latin 1
+ ' ' => ' ',
+ '¡' => '¡',
+ '¢' => '¢',
+ '£' => '£',
+ '¤' => '¤',
+ '¥' => '¥',
+ '¦' => '¦',
+ '§' => '§',
+ '¨' => '¨',
+ '©' => '©',
+ 'ª' => 'ª',
+ '«' => '«',
+ '¬' => '¬',
+ '­' => '­',
+ '®' => '®',
+ '¯' => '¯',
+ '°' => '°',
+ '±' => '±',
+ '²' => '²',
+ '³' => '³',
+ '´' => '´',
+ 'µ' => 'µ',
+ '¶' => '¶',
+ '·' => '·',
+ '¸' => '¸',
+ '¹' => '¹',
+ 'º' => 'º',
+ '»' => '»',
+ '¼' => '¼',
+ '½' => '½',
+ '¾' => '¾',
+ '¿' => '¿',
+ 'À' => 'À',
+ 'Á' => 'Á',
+ 'Â' => 'Â',
+ 'Ã' => 'Ã',
+ 'Ä' => 'Ä',
+ 'Å' => 'Å',
+ 'Æ' => 'Æ',
+ 'Ç' => 'Ç',
+ 'È' => 'È',
+ 'É' => 'É',
+ 'Ê' => 'Ê',
+ 'Ë' => 'Ë',
+ 'Ì' => 'Ì',
+ 'Í' => 'Í',
+ 'Î' => 'Î',
+ 'Ï' => 'Ï',
+ 'Ð' => 'Ð',
+ 'Ñ' => 'Ñ',
+ 'Ò' => 'Ò',
+ 'Ó' => 'Ó',
+ 'Ô' => 'Ô',
+ 'Õ' => 'Õ',
+ 'Ö' => 'Ö',
+ '×' => '×',
+ 'Ø' => 'Ø',
+ 'Ù' => 'Ù',
+ 'Ú' => 'Ú',
+ 'Û' => 'Û',
+ 'Ü' => 'Ü',
+ 'Ý' => 'Ý',
+ 'Þ' => 'Þ',
+ 'ß' => 'ß',
+ 'à' => 'à',
+ 'á' => 'á',
+ 'â' => 'â',
+ 'ã' => 'ã',
+ 'ä' => 'ä',
+ 'å' => 'å',
+ 'æ' => 'æ',
+ 'ç' => 'ç',
+ 'è' => 'è',
+ 'é' => 'é',
+ 'ê' => 'ê',
+ 'ë' => 'ë',
+ 'ì' => 'ì',
+ 'í' => 'í',
+ 'î' => 'î',
+ 'ï' => 'ï',
+ 'ð' => 'ð',
+ 'ñ' => 'ñ',
+ 'ò' => 'ò',
+ 'ó' => 'ó',
+ 'ô' => 'ô',
+ 'õ' => 'õ',
+ 'ö' => 'ö',
+ '÷' => '÷',
+ 'ø' => 'ø',
+ 'ù' => 'ù',
+ 'ú' => 'ú',
+ 'û' => 'û',
+ 'ü' => 'ü',
+ 'ý' => 'ý',
+ 'þ' => 'þ',
+ 'ÿ' => 'ÿ',
+ // Latin Extended-A
+ 'Œ' => 'Œ',
+ 'œ' => 'œ',
+ 'Š' => 'Š',
+ 'š' => 'š',
+ 'Ÿ' => 'Ÿ',
+ // Spacing Modifier Letters
+ 'ˆ' => 'ˆ',
+ '˜' => '˜',
+ // General Punctuation
+ ' ' => ' ',
+ ' ' => ' ',
+ ' ' => ' ',
+ '‌' => '‌',
+ '‍' => '‍',
+ '‎' => '‎',
+ '‏' => '‏',
+ '–' => '–',
+ '—' => '—',
+ '‘' => '‘',
+ '’' => '’',
+ '‚' => '‚',
+ '“' => '“',
+ '”' => '”',
+ '„' => '„',
+ '†' => '†',
+ '‡' => '‡',
+ '‰' => '‰',
+ '‹' => '‹',
+ '›' => '›',
+ '€' => '€',
+ // Latin Extended-B
+ 'ƒ' => 'ƒ',
+ // Greek
+ 'Α' => 'Α',
+ 'Β' => 'Β',
+ 'Γ' => 'Γ',
+ 'Δ' => 'Δ',
+ 'Ε' => 'Ε',
+ 'Ζ' => 'Ζ',
+ 'Η' => 'Η',
+ 'Θ' => 'Θ',
+ 'Ι' => 'Ι',
+ 'Κ' => 'Κ',
+ 'Λ' => 'Λ',
+ 'Μ' => 'Μ',
+ 'Ν' => 'Ν',
+ 'Ξ' => 'Ξ',
+ 'Ο' => 'Ο',
+ 'Π' => 'Π',
+ 'Ρ' => 'Ρ',
+ 'Σ' => 'Σ',
+ 'Τ' => 'Τ',
+ 'Υ' => 'Υ',
+ 'Φ' => 'Φ',
+ 'Χ' => 'Χ',
+ 'Ψ' => 'Ψ',
+ 'Ω' => 'Ω',
+ 'α' => 'α',
+ 'β' => 'β',
+ 'γ' => 'γ',
+ 'δ' => 'δ',
+ 'ε' => 'ε',
+ 'ζ' => 'ζ',
+ 'η' => 'η',
+ 'θ' => 'θ',
+ 'ι' => 'ι',
+ 'κ' => 'κ',
+ 'λ' => 'λ',
+ 'μ' => 'μ',
+ 'ν' => 'ν',
+ 'ξ' => 'ξ',
+ 'ο' => 'ο',
+ 'π' => 'π',
+ 'ρ' => 'ρ',
+ 'ς' => 'ς',
+ 'σ' => 'σ',
+ 'τ' => 'τ',
+ 'υ' => 'υ',
+ 'φ' => 'φ',
+ 'χ' => 'χ',
+ 'ψ' => 'ψ',
+ 'ω' => 'ω',
+ 'ϑ' => 'ϑ',
+ 'ϒ' => 'ϒ',
+ 'ϖ' => 'ϖ',
+ // General Punctuation
+ '•' => '•',
+ '…' => '…',
+ '′' => '′',
+ '″' => '″',
+ '‾' => '‾',
+ '⁄' => '⁄',
+ // Letterlike Symbols
+ '℘' => '℘',
+ 'ℑ' => 'ℑ',
+ 'ℜ' => 'ℜ',
+ '™' => '™',
+ 'ℵ' => 'ℵ',
+ // Arrows
+ '←' => '←',
+ '↑' => '↑',
+ '→' => '→',
+ '↓' => '↓',
+ '↔' => '↔',
+ '↵' => '↵',
+ '⇐' => '⇐',
+ '⇑' => '⇑',
+ '⇒' => '⇒',
+ '⇓' => '⇓',
+ '⇔' => '⇔',
+ // Mathematical Operators
+ '∀' => '∀',
+ '∂' => '∂',
+ '∃' => '∃',
+ '∅' => '∅',
+ '∇' => '∇',
+ '∈' => '∈',
+ '∉' => '∉',
+ '∋' => '∋',
+ '∏' => '∏',
+ '∑' => '∑',
+ '−' => '−',
+ '∗' => '∗',
+ '√' => '√',
+ '∝' => '∝',
+ '∞' => '∞',
+ '∠' => '∠',
+ '∧' => '∧',
+ '∨' => '∨',
+ '∩' => '∩',
+ '∪' => '∪',
+ '∫' => '∫',
+ '∴' => '∴',
+ '∼' => '∼',
+ '≅' => '≅',
+ '≈' => '≈',
+ '≠' => '≠',
+ '≡' => '≡',
+ '≤' => '≤',
+ '≥' => '≥',
+ '⊂' => '⊂',
+ '⊃' => '⊃',
+ '⊄' => '⊄',
+ '⊆' => '⊆',
+ '⊇' => '⊇',
+ '⊕' => '⊕',
+ '⊗' => '⊗',
+ '⊥' => '⊥',
+ '⋅' => '⋅',
+ // Miscellaneous Technical
+ '⌈' => '⌈',
+ '⌉' => '⌉',
+ '⌊' => '⌊',
+ '⌋' => '⌋',
+ '⟨' => '〈',
+ '⟩' => '〉',
+ // Geometric Shapes
+ '◊' => '◊',
+ // Miscellaneous Symbols
+ '♠' => '♠',
+ '♣' => '♣',
+ '♥' => '♥',
+ '♦' => '♦');
+
+ $str = str_replace(array_keys($entities), array_values($entities), $str);
+
+ return $str;
+}
+
+/* ------------------------------ main --------------------------- */
+
+global $squirrelmail_language, $languages, $use_gettext;
+
+if (! sqgetGlobalVar('squirrelmail_language',$squirrelmail_language,SQ_COOKIE)) {
+ $squirrelmail_language = '';
+}
+
+/**
+ * Array specifies the available translations.
+ *
+ * Structure of array:
+ * $languages['language']['variable'] = 'value'
+ *
+ * Possible 'variable' names:
+ * NAME - Translation name in English
+ * CHARSET - Encoding used by translation
+ * ALIAS - used when 'language' is only short name and 'value' should provide long language name
+ * ALTNAME - Native translation name. Any 8bit symbols must be html encoded.
+ * LOCALE - Full locale name (in xx_XX.charset format). It can use array with more than one locale name since 1.4.5 and 1.5.1
+ * DIR - Text direction. Used to define Right-to-Left languages. Possible values 'rtl' or 'ltr'. If undefined - defaults to 'ltr'
+ * XTRA_CODE - translation uses special functions. See doc/i18n.txt
+ *
+ * Each 'language' definition requires NAME+CHARSET or ALIAS variables.
+ *
+ * @name $languages
+ * @global array $languages
+ */
+$languages['en_US']['NAME'] = 'English';
+$languages['en_US']['CHARSET'] = 'iso-8859-1';
+$languages['en_US']['LOCALE'] = 'en_US.ISO8859-1';
+$languages['en']['ALIAS'] = 'en_US';
+
+/**
+ * Automatic translation loading from setup.php files.
+ * Solution for bug. 1240889.
+ * setup.php file can contain $languages array entries and XTRA_CODE functions.
+ */
+if (is_dir(SM_PATH . 'locale') &&
+ is_readable(SM_PATH . 'locale')) {
+ $localedir = dir(SM_PATH . 'locale');
+ while($lang_dir=$localedir->read()) {
+ // remove trailing slash, if present
+ if (substr($lang_dir,-1)=='/') {
+ $lang_dir = substr($lang_dir,0,-1);
+ }
+ if ($lang_dir != '..' && $lang_dir != '.' && $lang_dir != 'CVS' &&
+ is_dir(SM_PATH.'locale/'.$lang_dir) &&
+ file_exists(SM_PATH.'locale/'.$lang_dir.'/setup.php')) {
+ include_once(SM_PATH.'locale/'.$lang_dir.'/setup.php');
+ }
+ }
+ $localedir->close();
+}
+
+/* Detect whether gettext is installed. */
+$gettext_flags = 0;
+if (function_exists('_')) {
+ $gettext_flags += 1;
+}
+if (function_exists('bindtextdomain')) {
+ $gettext_flags += 2;
+}
+if (function_exists('textdomain')) {
+ $gettext_flags += 4;
+}
+if (function_exists('ngettext')) {
+ $gettext_flags += 8;
+}
+
+/* If gettext is fully loaded, cool */
+if ($gettext_flags == 15) {
+ $use_gettext = true;
+}
+
+/* If ngettext support is missing, load it */
+elseif ($gettext_flags == 7) {
+ $use_gettext = true;
+ // load internal ngettext functions
+ include_once(SM_PATH . 'class/l10n.class.php');
+ include_once(SM_PATH . 'functions/ngettext.php');
+}
+
+/* If we can fake gettext, try that */
+elseif ($gettext_flags == 0) {
+ $use_gettext = true;
+ include_once(SM_PATH . 'functions/gettext.php');
+} else {
+ /* Uh-ho. A weird install */
+ if (! $gettext_flags & 1) {
+ /**
+ * Function is used as replacement in broken installs
+ * @ignore
+ */
+ function _($str) {
+ return $str;
+ }
+ }
+ if (! $gettext_flags & 2) {
+ /**
+ * Function is used as replacement in broken installs
+ * @ignore
+ */
+ function bindtextdomain() {
+ return;
+ }
+ }
+ if (! $gettext_flags & 4) {
+ /**
+ * Function is used as replacemet in broken installs
+ * @ignore
+ */
+ function textdomain() {
+ return;
+ }
+ }
+ if (! $gettext_flags & 8) {
+ /**
+ * Function is used as replacemet in broken installs
+ * @ignore
+ */
+ function ngettext($str,$str2,$number) {
+ if ($number>1) {
+ return $str2;
+ } else {
+ return $str;
+ }
+ }
+ }
+ if (! function_exists('dgettext')) {
+ /**
+ * Replacement for broken setups.
+ * @ignore
+ */
+ function dgettext($domain,$str) {
+ return $str;
+ }
+ }
+ if (! function_exists('dngettext')) {
+ /**
+ * Replacement for broken setups
+ * @ignore
+ */
+ function dngettext($domain,$str1,$strn,$number) {
+ return ($number==1 ? $str1 : $strn);
+ }
+ }
+}
+?>
\ No newline at end of file
* @package squirrelmail
*/
-/** SquirrelMail required files. */
-include_once(SM_PATH . 'functions/constants.php');
-include_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/plugin.php');
+/**
+ * do not allow to call this file directly
+ */
+if ((isset($_SERVER) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) ||
+ (isset($HTTP_SERVER_SERVER) && $HTTP_SERVER_SERVER['SCRIPT_FILENAME'] == __FILE__) ) {
+ header("Location: ../src/login.php");
+ die();
+}
if( ! sqgetGlobalVar('username', $username, SQ_SESSION) ) {
$username = '';
}
-
+// TODO Get rid of "none" strings when NULL or false should be used, i hate them i hate them i hate them!!!.
$custom_css = getPref($data_dir, $username, 'custom_css', 'none' );
$theme = ( !isset($theme) ? array() : $theme );
if ($icon_theme == 'template') {
$icon_theme = $sTplDir . 'images/';
}
-
/*
- * NOTE: The $icon_theme_path var should contain the path to the icon
+ * NOTE: The $icon_theme_path var should contain the path to the icon
* theme to use. If the admin has disabled icons, or the user has
* set the icon theme to "None," no icons will be used.
*/
setPref($data_dir, $username, 'index_order', serialize($index_order));
}
-
-
if (!isset($default_mailbox_pref)) {
$show_num = (isset($show_num)) ? $show_num : 15;
if (! isset($default_fontsize)) $default_fontsize=SMPREF_NONE;
$chosen_fontsize = getPref($data_dir, $username, 'chosen_fontsize', $default_fontsize);
+
+
+/** Put in a safety net for authentication here, in case a naughty admin didn't run conf.pl when they upgraded */
+
+// TODO Get rid of "none" strings when NULL should be used, i hate them i hate them i hate them!!!.
+if (! isset($smtp_auth_mech)) {
+ $smtp_auth_mech = 'none';
+}
+
+if (! isset($imap_auth_mech)) {
+ $imap_auth_mech = 'login';
+}
+
+if (! isset($use_imap_tls)) {
+ $use_imap_tls = false;
+}
+
+if (! isset($use_smtp_tls)) {
+ $use_smtp_tls = false;
+}
+
do_hook('loading_prefs');
?>
/* Icon theme selection */
if ($use_icons) {
global $icon_themes, $icon_theme;
-
+
$temp = array();
for ($count = 0; $count < sizeof($icon_themes); $count++) {
$temp[$count] = $icon_themes[$count]['NAME'];
}
}
+
/*** Load the General Options into the array ***/
$optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options");
$optvals[SMOPT_GRP_MAILBOX] = array();
*/
/** SquirrelMail required files. */
-require_once(SM_PATH . 'functions/imap.php');
-require_once(SM_PATH . 'functions/imap_general.php');
+include(SM_PATH . 'functions/imap_general.php');
/* Define the group constants for the folder options page. */
define('SMOPT_GRP_SPCFOLDER', 0);
* @package squirrelmail
*/
-/** include the mime class before the session start ! otherwise we can't store
- * messages with a session_register.
- *
- * From http://www.php.net/manual/en/language.oop.serialization.php:
- * In case this isn't clear:
- * In 4.2 and below:
- * session.auto_start and session objects are mutually exclusive.
- *
- * We need to load the classes before the session is started,
- * except that the session could be started automatically
- * via session.auto_start. So, we'll close the session,
- * then load the classes, and reopen the session which should
- * make everything happy.
- *
- * ** Note this means that for the 1.3.2 release, we should probably
- * recommend that people set session.auto_start=0 to avoid this altogether.
- */
-
-session_write_close();
-
-/**
- * Reset the $theme() array in case a value was passed via a cookie.
- * This is until theming is rewritten.
- */
-global $theme;
-unset($theme);
-$theme=array();
-
-/* SquirrelMail required files. */
-include_once(SM_PATH . 'class/mime.class.php');
-include_once(SM_PATH . 'functions/global.php');
-include_once(SM_PATH . 'functions/strings.php');
-
-/* set the name of the session cookie */
-if(isset($session_name) && $session_name) {
- ini_set('session.name' , $session_name);
-} else {
- ini_set('session.name' , 'SQMSESSID');
-}
-
-sqsession_is_active();
-
-include_once(SM_PATH . 'functions/i18n.php');
-include_once(SM_PATH . 'functions/auth.php');
-
-is_logged_in();
-
-/**
- * Auto-detection
- *
- * if $send (the form button's name) contains "\n" as the first char
- * and the script is compose.php, then trim everything. Otherwise, we
- * don't have to worry.
- *
- * This is for a RedHat package bug and a Konqueror (pre 2.1.1?) bug
- */
-global $send, $PHP_SELF;
-if (isset($send)
- && (substr($send, 0, 1) == "\n")
- && (substr($PHP_SELF, -12) == '/compose.php')) {
- if ($REQUEST_METHOD == 'POST') {
- global $HTTP_POST_VARS;
- TrimArray($HTTP_POST_VARS);
- } else {
- global $HTTP_GET_VARS;
- TrimArray($HTTP_GET_VARS);
- }
-}
-
-include_once(SM_PATH . 'functions/page_header.php');
-include_once(SM_PATH . 'functions/prefs.php');
-include_once(SM_PATH . 'config/config.php');
-include_once(SM_PATH . 'include/load_prefs.php');
-
-/* Set up the language (i18n.php was included by auth.php). */
-global $username, $data_dir;
-set_up_language(getPref($data_dir, $username, 'language'));
-
-$timeZone = getPref($data_dir, $username, 'timezone');
-
-/* Check to see if we are allowed to set the TZ environment variable.
- * We are able to do this if ...
- * safe_mode is disabled OR
- * safe_mode_allowed_env_vars is empty (you are allowed to set any) OR
- * safe_mode_allowed_env_vars contains TZ
- */
-$tzChangeAllowed = (!ini_get('safe_mode')) ||
- !strcmp(ini_get('safe_mode_allowed_env_vars'),'') ||
- preg_match('/^([\w_]+,)*TZ/', ini_get('safe_mode_allowed_env_vars'));
-
-if ( $timeZone != SMPREF_NONE && ($timeZone != "")
- && $tzChangeAllowed ) {
-
- // get time zone key, if strict or custom strict timezones are used
- if (isset($time_zone_type) &&
- ($time_zone_type == 1 || $time_zone_type == 3)) {
- /* load time zone functions */
- require_once(SM_PATH . 'include/timezones.php');
- $realTimeZone = sq_get_tz_key($timeZone);
- } else {
- $realTimeZone = $timeZone;
- }
-
- // set time zone
- if ($realTimeZone) {
- putenv("TZ=".$realTimeZone);
- }
-}
-
-/* temporary sm_init section */
-
-include_once(SM_PATH . 'class/template/template.class.php');
-include_once(SM_PATH . 'class/error.class.php');
-/*
- * Initialize the template object
- */
-global $sTplDir;
-$oTemplate = new Template($sTplDir);
-
-/*
- * Initialize our custom error handler object
- */
-$oErrorHandler = new ErrorHandler($oTemplate,'error_message.tpl');
-
-/*
- * Activate custom error handling
- */
-if (version_compare(PHP_VERSION, "4.3.0", ">=")) {
- $oldErrorHandler = set_error_handler(array($oErrorHandler, 'SquirrelMailErrorhandler'));
-} else {
- $oldErrorHandler = set_error_handler('SquirrelMailErrorhandler');
-}
-
+echo "Rewrite your code, we now use init.php";
+die();
?>
\ No newline at end of file
* @subpackage abook_take
*/
-/** SquirrelMail required files. */
-require_once(SM_PATH . 'functions/url_parser.php');
-require_once(SM_PATH . 'functions/forms.php');
-
function valid_email ($email, $verify)
{
global $Email_RegExp_Match;
* @subpackage abook_take
*/
-/**
- * If SM_PATH isn't defined, define it. Required to include files.
- * @ignore
- */
-if (!defined('SM_PATH')) {
- define('SM_PATH','../../');
-}
/**
* Initialize the plugin
*/
/**
- * Path for SquirrelMail required files.
- * @ignore */
-define('SM_PATH','../../');
+ * Include the SquirrelMail initialization file.
+ */
+require('../../include/init.php');
/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/addressbook.php');
+require(SM_PATH . 'functions/forms.php');
+require(SM_PATH . 'functions/addressbook.php');
displayPageHeader($color, 'None');
*/
function adm_check_user() {
global $PHP_SELF, $plugins;
- require_once(SM_PATH . 'functions/global.php');
/* fail if the plugin is not enabled */
if ( !in_array('administrator', $plugins) ) {
* @subpackage administrator
*/
-/** @ignore */
-if (!defined('SM_PATH')) define('SM_PATH','../../');
-
-/**
- * Load SquirrelMail SMPREF constants for default_unseen_notify and
- * default_unseen_type variables.
- */
-require_once( SM_PATH . 'functions/constants.php' );
-
/* Define constants for the various option types. */
define('SMOPT_TYPE_UNDEFINED', -1);
define('SMOPT_TYPE_STRING', 0);
* @subpackage bug_report
*/
+
/**
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../../');
-/** load system functions */
-require_once(SM_PATH . 'include/validate.php');
+require('../../include/init.php');
/** load form functions */
-include_once(SM_PATH . 'functions/forms.php');
-/** load error_box() function */
-include_once(SM_PATH . 'functions/display_messages.php');
+require_once(SM_PATH . 'functions/forms.php');
/** load plugin functions */
-include_once(SM_PATH . 'plugins/bug_report/functions.php');
+require_once(SM_PATH . 'plugins/bug_report/functions.php');
displayPageHeader($color, 'None');
}
/** get system specs */
-include_once(SM_PATH . 'plugins/bug_report/system_specs.php');
+require_once(SM_PATH . 'plugins/bug_report/system_specs.php');
global $body;
$body_top = "I am subscribed to the this mailing list.\n" .
<?php echo _("This bug involves:")
.' <select name="send_to">';
if (! empty($bug_report_admin_email)) {
- // if admin's email is set - add 'report to admin' option and make it default one
+ // if admin's email is set - add 'report to admin' option and make it default one
echo '<option value="' . htmlspecialchars($bug_report_admin_email) .'" selected="selected">'
._("my email account") .'</option>';
}
* @subpackage bug_report
*/
-/** @ignore */
-if (! defined('SM_PATH')) define('SM_PATH','../../');
+
+/**
+ * do not allow to call this file directly
+ */
+if ((isset($_SERVER) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) ||
+ (isset($HTTP_SERVER_SERVER) && $HTTP_SERVER_SERVER['SCRIPT_FILENAME'] == __FILE__) ) {
+ header("Location: ../../src/login.php");
+ die();
+}
/** Declare plugin configuration vars */
global $bug_report_admin_email, $bug_report_allow_users;
*/
/**
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../../');
-/** load system functions */
-include_once(SM_PATH . 'include/validate.php');
-/** load error_box() function */
-include_once(SM_PATH . 'functions/display_messages.php');
+require('../../include/init.php');
+
/** load plugin functions */
include_once(SM_PATH.'plugins/bug_report/functions.php');
* @subpackage bug_report
*/
-/** @ignore */
-if (!defined('SM_PATH')) define('SM_PATH','../../');
+/**
+ * do not allow to call this file directly
+ */
+if ((isset($_SERVER) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) ||
+ (isset($HTTP_SERVER_SERVER) && $HTTP_SERVER_SERVER['SCRIPT_FILENAME'] == __FILE__) ) {
+ header("Location: ../../src/login.php");
+ die();
+}
/**
* load required libraries
*/
-include_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/imap.php');
-global $body, $username;
+include_once(SM_PATH . 'functions/imap_general.php');
+
/**
* @subpackage calendar
*/
-/** @ignore */
-define('SM_PATH','../../');
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../../include/init.php');
-/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
/* load date_intl() */
include_once(SM_PATH . 'functions/date.php');
* @subpackage calendar
*/
-/** @ignore */
-define('SM_PATH','../../');
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../../include/init.php');
-/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
/* date_intl() */
include_once(SM_PATH . 'functions/date.php');
echo html_tag( 'tr', '', '', $color[$eo] ) .
html_tag( 'td', date_intl(_("H:i"),mktime($ehour,$eminute,0,1,1,0)) . $elength, 'left' ) .
html_tag( 'td', '', 'left' ) . '[';
- echo ($calbar['priority']==1) ?
- "<font color=\"$color[1]\">".htmlspecialchars($calbar['title']).'</font>' :
+ echo ($calbar['priority']==1) ?
+ "<font color=\"$color[1]\">".htmlspecialchars($calbar['title']).'</font>' :
htmlspecialchars($calbar['title']);
echo'] <div style="margin-left:10px">'.nl2br(htmlspecialchars($calbar['message'])).'</div>' .
html_tag( 'td',
* @package plugins
* @subpackage calendar
*/
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../../include/init.php');
-/** @ignore */
-define('SM_PATH','../../');
-
-/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
/* date_intl() */
include_once(SM_PATH . 'functions/date.php');
* @subpackage calendar
*/
-/** @ignore */
-define('SM_PATH','../../');
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../../include/init.php');
-/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
/* date_intl() */
include_once(SM_PATH . 'functions/date.php');
* @subpackage calendar
*/
-/** @ignore */
-define('SM_PATH','../../');
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../../include/init.php');
/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
+
/* date_intl() */
include_once(SM_PATH . 'functions/date.php');
/* form functions */
*/
function confirm_update() {
global $calself, $year, $month, $day, $hour, $minute, $calendardata,
- $color, $event_year, $event_month, $event_day, $event_hour,
+ $color, $event_year, $event_month, $event_day, $event_hour,
$event_minute, $event_length, $event_priority, $event_title, $event_text;
$tmparray = $calendardata["$month$day$year"]["$hour$minute"];
*/
/**
- * If SM_PATH isn't defined, define it. Required to include files.
- * @ignore
+ * do not allow to call this file directly
*/
-if (!defined('SM_PATH')) define('SM_PATH','../../../');
+if ((isset($_SERVER) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) ||
+ (isset($HTTP_SERVER_SERVER) && $HTTP_SERVER_SERVER['SCRIPT_FILENAME'] == __FILE__) ) {
+ header("Location: ../../../src/login.php");
+ die();
+}
/** load required functions */
-/** error_box() function */
-include_once(SM_PATH . 'functions/display_messages.php');
/** sqimap_get_user_server() function */
-include_once(SM_PATH . 'functions/imap_general.php');
+include_once(SM_PATH . '../functions/imap_general.php');
/** get imap server and username globals */
global $imapServerAddress, $username;
function cpw_merak_init() {
global $color;
- /**
- * If SM_PATH isn't defined, define it. Required to include files.
- * @ignore
- */
- if (!defined('SM_PATH')) {
- define('SM_PATH','../../../');
- }
-
- // load error_box() function
- include_once(SM_PATH . 'functions/display_messages.php');
-
if (!function_exists('curl_init')) {
// user_error('Curl module NOT available!', E_USER_ERROR);
error_box(_("PHP Curl extension is NOT available! Unable to change password!"),$color);
* @subpackage change_password
*/
-/** load Pear DB.
- * Global is needed because library must be loaded before configuration
+/** load Pear DB.
+ * Global is needed because library must be loaded before configuration
* in order to use DB constants.
*/
global $cpw_peardb_detect;
$cpw_peardb_detect=@include_once('DB.php');
/** declare configuration globals */
-global $cpw_peardb_dsn, $cpw_peardb_connect_opts, $cpw_peardb_table,
+global $cpw_peardb_dsn, $cpw_peardb_connect_opts, $cpw_peardb_table,
$cpw_peardb_uid_field, $cpw_peardb_domain_field, $cpw_peardb_passwd_field,
$cpw_peardb_crypted_passwd, $cpw_peardb_debug;
function cpw_peardb_init() {
global $color, $cpw_peardb_detect, $cpw_peardb_dsn, $cpw_peardb_table;
- /**
- * If SM_PATH isn't defined, define it. Required to include files.
- * @ignore
- */
- if (!defined('SM_PATH')) {
- define('SM_PATH','../../../');
- }
-
- // load error_box() function
- include_once(SM_PATH . 'functions/display_messages.php');
-
if (! $cpw_peardb_detect) {
error_box(_("Plugin is unable to use PHP Pear DB libraries. PHP Pear includes must be available in your PHP include_path setting."),$color);
echo "</body></html>\n";
}
// Test required settings
- if ((is_string($cpw_peardb_dsn) && trim($cpw_peardb_dsn)=='')
+ if ((is_string($cpw_peardb_dsn) && trim($cpw_peardb_dsn)=='')
|| trim($cpw_peardb_table)=='' ) {
error_box(_("Required change password backend configuration options are missing."),$color);
echo "</body></html>\n";
*/
function cpw_peardb_dochange($data) {
global $cpw_peardb_dsn, $cpw_peardb_table, $cpw_peardb_connect_opts, $cpw_peardb_debug,
- $cpw_peardb_uid_field, $cpw_peardb_passwd_field, $cpw_peardb_domain_field,
+ $cpw_peardb_uid_field, $cpw_peardb_passwd_field, $cpw_peardb_domain_field,
$cpw_peardb_crypted_passwd, $domain;
$username = $data['username'];
$user=$username;
$user_domain=$domain;
}
-
+
// connect to database and make sure that table exists
$cpw_db = DB::connect($cpw_peardb_dsn, $cpw_peardb_connect_opts);
if (PEAR::isError($cpw_db)) {
$cpw_peardb_passwd_check=false;
$cpw_peardb_domain_check=(($cpw_peardb_domain_field=='')? true : false);
foreach($table_info as $key => $field_data) {
- if ($field_data['name']==$cpw_peardb_uid_field)
+ if ($field_data['name']==$cpw_peardb_uid_field)
$cpw_peardb_uid_check=true;
- if ($field_data['name']==$cpw_peardb_passwd_field)
+ if ($field_data['name']==$cpw_peardb_passwd_field)
$cpw_peardb_passwd_check=true;
if ($cpw_peardb_domain_field!='' && $field_data['name']==$cpw_peardb_domain_field)
$cpw_peardb_domain_check=true;
.' FROM '.$cpw_db->quoteIdentifier($cpw_peardb_table)
.' WHERE '
.$cpw_db->quoteIdentifier($cpw_peardb_uid_field).'='.$cpw_db->quoteSmart($user)
- .(($cpw_peardb_domain_field!='') ?
+ .(($cpw_peardb_domain_field!='') ?
' AND '.$cpw_db->quoteIdentifier($cpw_peardb_domain_field).'='.$cpw_db->quoteSmart($user_domain):
'');
$cpw_res=$cpw_db->query($query);
.'='.$cpw_db->quoteSmart($hashed_passwd)
.' WHERE '.$cpw_db->quoteIdentifier($cpw_peardb_uid_field)
.'='.$cpw_db->quoteSmart($user)
- .(($cpw_peardb_domain_field!='') ?
+ .(($cpw_peardb_domain_field!='') ?
' AND '.$cpw_db->quoteIdentifier($cpw_peardb_domain_field).'='.$cpw_db->quoteSmart($user_domain) :
'');
global $poppassd_server;
global $imapServerAddress;
- /** @ignore */
- if (!defined('SM_PATH')) define('SM_PATH','../../../');
/** sqimap_get_user_server() function */
- include_once(SM_PATH . 'functions/imap_general.php');
+ include_once(SM_PATH . '../functions/imap_general.php');
if($poppassd_server == '') {
// if poppassd address is not set, use imap server's address
{
global $color;
- /**
- * If SM_PATH isn't defined, define it. Required to include files.
- * @ignore
- */
- if (!defined('SM_PATH')) {
- define('SM_PATH','../../../');
- }
-
- // load error_box() function
- include_once(SM_PATH . 'functions/display_messages.php');
-
// plugin is not configured. Handle error gracefully.
error_box(_("No valid backend defined."),$color);
// close html and stop script execution
function cpw_vmailmgrd_init(){
global $vmail_inc_path, $color, $username;
- /**
- * If SM_PATH isn't defined, define it. Required to include files.
- * @ignore
- */
- if (!defined('SM_PATH')) {
- define('SM_PATH','../../../');
- }
-
- // load error_box() function
- include_once(SM_PATH . 'functions/display_messages.php');
-
if ($vmail_inc_path=='' || ! file_exists($vmail_inc_path)) {
// $vmail_inc_path is not set or file does not exist
error_box(_("Incorrent path to vmail.inc file."),$color);
* @subpackage change_password
*/
-/** @ignore */
-define('SM_PATH','../../');
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../../include/init.php');
-include_once (SM_PATH . 'include/validate.php');
include_once (SM_PATH . 'plugins/change_password/functions.php');
include_once (SM_PATH . 'functions/forms.php');
* @subpackage filters
*/
-/** @ignore */
-if (! defined('SM_PATH')) define('SM_PATH','../../');
+/**
+ * do not allow to call this file directly
+ */
+if ((isset($_SERVER) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) ||
+ (isset($HTTP_SERVER_SERVER) && $HTTP_SERVER_SERVER['SCRIPT_FILENAME'] == __FILE__) ) {
+ header("Location: ../../src/login.php");
+ die();
+}
/** load globals */
global $UseSeparateImapConnection,
include_once (SM_PATH . 'plugins/filters/config.php');
}
+/**
+ * Init Hooks
+ * @access private
+ */
+function filters_init_hooks () {
+ global $squirrelmail_plugin_hooks;
+
+ if (! sqgetGlobalVar('mailbox',$mailbox,SQ_FORM)) {
+ $mailbox = 'INBOX';
+ }
+
+ $squirrelmail_plugin_hooks['left_main_before']['filters'] = 'start_filters_hook';
+ if (isset($mailbox) && $mailbox == 'INBOX') {
+ $squirrelmail_plugin_hooks['right_main_after_header']['filters'] = 'start_filters_hook';
+ }
+ $squirrelmail_plugin_hooks['optpage_register_block']['filters'] = 'filters_optpage_register_block_hook';
+ $squirrelmail_plugin_hooks['special_mailbox']['filters'] = 'filters_special_mailbox';
+ $squirrelmail_plugin_hooks['rename_or_delete_folder']['filters'] = 'update_for_folder_hook';
+ $squirrelmail_plugin_hooks['webmail_bottom']['filters'] = 'start_filters_hook';
+ $squirrelmail_plugin_hooks['folder_status']['filters'] = 'filters_folder_status';
+}
+
/**
* Register option blocks
* @access private
global $filter_inbox_count;
if (empty($filter_inbox_count)) $filter_inbox_count=0;
+ //echo "GOT HOOK<br><pre>";
+ //var_dump($statusarr);
+ //echo "</pre><br>\n";
+
if ($statusarr['MAILBOX'] == 'INBOX')
{
if (!empty($statusarr['MESSAGES'])) $filter_inbox_count=$statusarr['MESSAGES'];
/**
* Starts the filtering process
- * @param array $hook_args (since 1.5.2) do hook arguments. Is used to check
- * hook name, array key = 0.
* @access private
*/
-function start_filters($hook_args) {
+function start_filters() {
global $imapServerAddress, $imapPort, $imap_stream, $imapConnection,
$UseSeparateImapConnection, $AllowSpamFilters, $filter_inbox_count;
sqgetGlobalVar('username', $username, SQ_SESSION);
sqgetGlobalVar('key', $key, SQ_COOKIE);
- /**
- * check hook that calls filtering. If filters are called by right_main_after_header,
- * do filtering only when we are in INBOX folder.
- */
- if ($hook_args[0]=='right_main_after_header' &&
- (sqgetGlobalVar('mailbox',$mailbox,SQ_FORM) && $mailbox!='INBOX')) {
- return;
- }
-
$filters = load_filters();
// No point running spam filters if there aren't any to run //
/* read data back from IMAP */
$read = sqimap_run_command($imap_stream, $search_str, true, $response, $message, TRUE);
} else {
+ // TODO BADCHARSET
$search_str .= ' ' . $where . ' {' . strlen($what) . "}";
$sid = sqimap_session_id(true);
fputs ($imap_stream, $sid . ' ' . $search_str . "\r\n");
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../../');
-
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/imap.php');
+require('../../include/init.php');
+include_once(SM_PATH . 'functions/imap_general.php');
include_once(SM_PATH . 'plugins/filters/filters.php');
displayPageHeader($color, 'None');
* @access private
*/
function squirrelmail_plugin_init_filters() {
- global $squirrelmail_plugin_hooks;
-
- $squirrelmail_plugin_hooks['left_main_before']['filters'] = 'start_filters_hook';
- $squirrelmail_plugin_hooks['right_main_after_header']['filters'] = 'start_filters_hook';
- $squirrelmail_plugin_hooks['optpage_register_block']['filters'] = 'filters_optpage_register_block_hook';
- $squirrelmail_plugin_hooks['special_mailbox']['filters'] = 'filters_special_mailbox';
- $squirrelmail_plugin_hooks['rename_or_delete_folder']['filters'] = 'update_for_folder_hook';
- $squirrelmail_plugin_hooks['webmail_bottom']['filters'] = 'start_filters_hook';
- $squirrelmail_plugin_hooks['folder_status']['filters'] = 'filters_folder_status';
+ include_once(SM_PATH . 'plugins/filters/filters.php');
+ filters_init_hooks ();
}
/**
*/
function start_filters_hook($args) {
include_once(SM_PATH . 'plugins/filters/filters.php');
- start_filters ($args);
+ start_filters ();
}
/**
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../../');
+require('../../include/init.php');
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/imap.php');
+include_once(SM_PATH . 'functions/imap_general.php');
+include_once(SM_PATH . 'functions/imap_messages.php');
include_once(SM_PATH . 'plugins/filters/filters.php');
/* get globals */
* @subpackage fortune
*/
-/**
- * If SM_PATH isn't defined, define it.
- * @ignore
- */
-if (!defined('SM_PATH')) {
- define('SM_PATH','../../');
-}
-
/**
* Init plugin
* @access private
* @subpackage info
*/
-/** @ignore */
-define('SM_PATH','../../');
+/**
+ * Path for SquirrelMail required files.
+ * @ignore
+ */
+require('../../include/init.php');
/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/page_header.php');
-require_once(SM_PATH . 'functions/imap.php');
+require_once(SM_PATH . 'functions/imap_general.php');
require_once(SM_PATH . 'functions/forms.php');
require_once(SM_PATH . 'plugins/info/functions.php');
* @package plugins
* @subpackage listcommands
*/
-
-/** @ignore */
-define('SM_PATH','../../');
+/**
+ * Path for SquirrelMail required files.
+ * @ignore
+ */
+require('../../include/init.php');
/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/page_header.php');
-include_once(SM_PATH . 'include/load_prefs.php');
-include_once(SM_PATH . 'functions/html.php');
-require_once(SM_PATH . 'functions/identity.php');
-require_once(SM_PATH . 'functions/forms.php');
-include_once(SM_PATH . 'plugins/listcommands/functions.php');
+require(SM_PATH . 'functions/identity.php');
+require(SM_PATH . 'functions/forms.php');
+require(SM_PATH . 'plugins/listcommands/functions.php');
/* get globals */
sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
Some plugin settings can be adjusted in config/mail_fetch_config.php or
plugins/mail_fetch/config.php files.
-See plugins/mail_fetch/config_default.php
+See plugins/mail_fetch/config_sample.php
Note for mod_gzip users
* @subpackage mail_fetch
*/
-/** @ignore */
-define('SM_PATH','../../');
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../../include/init.php');
-require_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/imap.php');
+include_once(SM_PATH . 'functions/imap_general.php');
include_once(SM_PATH . 'plugins/mail_fetch/class.POP3.php');
include_once(SM_PATH . 'plugins/mail_fetch/functions.php' );
* @subpackage mail_fetch
*/
-/** @ignore */
-if (! defined('SM_PATH')) define('SM_PATH','../../');
/** pop3 class */
include_once (SM_PATH . 'plugins/mail_fetch/class.POP3.php');
* @private
*/
function mail_fetch_login_function() {
- include_once (SM_PATH . 'include/validate.php');
- include_once (SM_PATH . 'functions/imap.php');
-
+ //include_once (SM_PATH . 'include/validate.php');
+ include_once (SM_PATH . 'functions/imap_general.php');
+
global $data_dir, $imapServerAddress, $imapPort;
sqgetGlobalVar('username', $username, SQ_SESSION);
function mail_fetch_setnew_function() {
global $data_dir;
- // FIXME: check if function is already loaded in login_verified hook
- include_once(SM_PATH . 'functions/prefs.php');
-
sqgetGlobalVar('username', $username, SQ_SESSION);
setPref( $data_dir, $username, 'mailfetch_newlog', 'on' );
}
}
/**
- * Internal function used to update mail_fetch settings
+ * Internal function used to update mail_fetch settings
* when folders are renamed or deleted.
* @since 1.5.1
* @private
* @subpackage mail_fetch
*/
-/** @ignore */
-define('SM_PATH','../../');
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../../include/init.php');
-require_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/imap.php');
+include_once(SM_PATH . 'functions/imap_general.php');
/* globals */
sqgetGlobalVar('username', $username, SQ_SESSION);
* @subpackage mail_fetch
*/
-/** @ignore */
-if (! defined('SM_PATH')) define('SM_PATH','../../');
-
/**
* Initialize the plugin
*/
* @subpackage message_details
*/
-/** @ignore */
-if (!defined('SM_PATH'))
- define('SM_PATH','../../');
-
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/imap.php');
-require_once(SM_PATH . 'functions/mime.php');
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../../include/init.php');
+require(SM_PATH . 'functions/imap_general.php');
+require(SM_PATH . 'functions/imap_messages.php');
+require(SM_PATH . 'functions/mime.php');
sqgetGlobalVar('get_message_details', $md_action, SQ_GET);
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../../');
-
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
+require('../../include/init.php');
displayHtmlHeader( _("Message Details"), '', FALSE );
* @subpackage message_details
*/
-/** @ignore */
-define('SM_PATH','../../');
-
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/forms.php');
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../../include/init.php');
+require(SM_PATH . 'functions/forms.php');
displayHtmlHeader( _("Message Details"),
"<script type=\"text/javascript\">\n".
* @todo add midi support
*/
-/** @ignore */
-if (! defined('SM_PATH')) define('SM_PATH','../../');
-
-/**
- * SMPREF_UNSEEN_* constants
- */
-include_once(SM_PATH . 'functions/constants.php');
/** file type defines */
define('SM_NEWMAIL_FILETYPE_WAV',2);
$newmail_popup == 'on' ||
$newmail_changetitle == 'on') &&
/**
- * make sure that $newmail_unseen_notify is set to supported value,
- * currently (1.5.2cvs) SMPREF_UNSEEN_NORMAL has highest integer value
+ * make sure that $newmail_unseen_notify is set to supported value,
+ * currently (1.5.2cvs) SMPREF_UNSEEN_NORMAL has highest integer value
* in SMPREF_UNSEEN constants
*/
($newmail_unseen_notify > SMPREF_UNSEEN_NONE && $newmail_unseen_notify <= SMPREF_UNSEEN_NORMAL)) {
*/
/**
- * define SM_PATH
+ * Path for SquirrelMail required files.
* @ignore
*/
-define('SM_PATH','../../');
-
-/** Load squirrelmail functions */
-include_once(SM_PATH . 'include/validate.php');
+require('../../include/init.php');
/** Load plugin functions */
include_once(SM_PATH . 'plugins/newmail/functions.php');
* @subpackage newmail
*/
-/** @ignore */
-define('SM_PATH','../../');
-
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
+/**
+ * Path for SquirrelMail required files.
+ * @ignore
+ */
+require('../../include/init.php');
sqGetGlobalVar('numnew', $numnew, SQ_GET);
$numnew = (int)$numnew;
'<div style="text-align: center;">'. "\n" .
html_tag( 'table', "\n" .
html_tag( 'tr', "\n" .
- // i18n: %s inserts the organisation name (typically SquirrelMail)
- html_tag( 'td', '<b>' . sprintf(_("%s notice:"), $org_name) . '</b>', 'center', $color[0] )
+ html_tag( 'td', '<b>' . _("SquirrelMail Notice:") . '</b>', 'center', $color[0] )
) .
html_tag( 'tr', "\n" .
html_tag( 'td',
* @subpackage newmail
*/
-/** @ignore */
-define('SM_PATH','../../');
+/**
+ * Path for SquirrelMail required files.
+ * @ignore
+ */
+require('../../include/init.php');
-/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-/* form functions */
-include_once(SM_PATH . 'functions/forms.php');
/** Plugin functions (also loads plugin's config) */
include_once(SM_PATH . 'plugins/newmail/functions.php');
-displayPageHeader($color, 'None');
+include_once(SM_PATH . 'functions/forms.php');
-// plugin uses squirrelmail loading_pref hook.
-// vars are already loaded in include/validate.php
+displayPageHeader($color, 'None');
echo html_tag( 'table', '', 'center', $color[0], 'width="95%" cellpadding="1" cellspacing="0" border="0"' ) . "\n" .
html_tag( 'tr' ) . "\n" .
'left' )
) . "\n";
?>
-</table></form></td></tr></table></td></tr></table></body></html>
\ No newline at end of file
+</table></form></td></tr></table></td></tr></table></body></html>
+
* @subpackage newmail
*/
-/** @ignore */
-if (! defined('SM_PATH')) define('SM_PATH','../../');
/**
* Init newmail plugin
* @subpackage newmail
*/
-/** @ignore */
-define('SM_PATH','../../');
-
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
+/**
+ * Path for SquirrelMail required files.
+ * @ignore
+ */
+require('../../include/init.php');
displayHtmlHeader( _("Test Sound"), '', FALSE );
* @subpackage spamcop
*/
-/** @ignore */
-define('SM_PATH','../../');
-/* SquirrelMail functions */
-require_once(SM_PATH . 'include/validate.php');
+
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../../include/init.php');
/* plugin functions */
include_once(SM_PATH . 'plugins/spamcop/functions.php');
* @subpackage spamcop
*/
-/** @ignore */
-define('SM_PATH','../../');
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../../include/init.php');
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/display_messages.php');
-include_once(SM_PATH . 'functions/imap.php');
+include_once(SM_PATH . 'functions/imap_general.php');
+include_once(SM_PATH . 'functions/imap_messages.php');
/* plugin functions */
include_once(SM_PATH . 'plugins/spamcop/functions.php');
* @todo remove sqspell_ prefix from main php scripts.
*/
-/** @ignore */
-if (! defined('SM_PATH')) define('SM_PATH','../../');
/**
* Standard SquirrelMail plugin initialization API.
* @subpackage squirrelspell
*/
-/** @ignore */
-if (! defined('SM_PATH')) define('SM_PATH','../../');
-
-/** getHashedFile() function for SQSPELL_WORDS_FILE and sqgetGlobalVar() from global.php */
-include_once(SM_PATH . 'functions/prefs.php');
-
/** vars needed for getHashedFile() */
global $data_dir;
sqgetGlobalVar('username', $username, SQ_SESSION);
* $SQSPELL_APP = array('English' => '/usr/local/bin/aspell -a');
*</pre>
* Sometimes you have to specify full path for PHP to find it.
- *
+ *
* You can use Aspell or Ispell spellcheckers, the command line is the
* same. Aspell might provide better spellchecking for Western languages.
*
* <li>Whatever your setting is, don't omit the "-a" flag.</li>
* <li>Remember to keep same array keys during upgrades. Don't rename them.
* Users' dictionary settings use it.</li>
- * <li>Interface might translate array key, if used key is present in
+ * <li>Interface might translate array key, if used key is present in
* SquirrelMail translations.</li>
* </ul>
* <pre>
*
* $SQSPELL_WORDS_FILE is a location and mask of a user dictionary file.
* The default setting should be OK for most everyone.
- *
+ *
* This setting is used only when SquirrelSpell is upgraded from
* older setup. Since SquirrelMail 1.5.1 SquirrelSpell stores all settings in
* same place that stores other SquirrelMail user preferences.
* @subpackage squirrelspell
*/
-/** @ignore */
-if (! defined('SM_PATH')) define('SM_PATH','../../');
-
/** globalize configuration vars **/
global $SQSPELL_APP, $SQSPELL_APP_DEFAULT, $SQSPELL_WORDS_FILE, $SQSPELL_CRYPTO;
-/**
+/**
* load plugin configuration
* @todo allow storing configuration file in config/ directory
*/
/**
* gets list of available dictionaries from user's prefs.
- * Function was modified in 1.5.1 (sqspell 0.5).
+ * Function was modified in 1.5.1 (sqspell 0.5).
* Older function is suffixed with '_old'
* @return array list of dictionaries used by end user.
*/
*/
sqgetGlobalVar('key', $key, SQ_COOKIE);
sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
-
+
$clear_key=OneTimePadDecrypt($key, $onetimepad);
/**
* Try encrypting it. If fails, scream bloody hell.
/**
* Deletes user's dictionary
- * Function was modified in 1.5.1 (sqspell 0.5). Older function is suffixed
+ * Function was modified in 1.5.1 (sqspell 0.5). Older function is suffixed
* with '_old'
* @param string $lang dictionary
*/
. _("SquirrelSpell was unable to decrypt your personal dictionary. This is most likely due to the fact that you have changed your mailbox password. In order to proceed, you will have to supply your old password so that SquirrelSpell can decrypt your personal dictionary. It will be re-encrypted with your new password after this. If you haven't encrypted your dictionary, then it got mangled and is no longer valid. You will have to delete it and start anew. This is also true if you don't remember your old password -- without it, the encrypted data is no longer accessible.") ,
'left' ) . "\n"
. (($lang) ? html_tag('p',sprintf(_("Your %s dictionary is encrypted with password that differs from your current password."),
- htmlspecialchars($lang)),'left') : '')
+ htmlspecialchars($lang)),'left') : '')
. '<blockquote>' . "\n"
. '<form method="post" onsubmit="return AYS()">' . "\n"
. '<input type="hidden" name="MOD" value="crypto_badkey" />' . "\n"
- . (($lang) ?
- '<input type="hidden" name="dict_lang" value="'.htmlspecialchars($lang).'" />' :
+ . (($lang) ?
+ '<input type="hidden" name="dict_lang" value="'.htmlspecialchars($lang).'" />' :
'<input type="hidden" name="old_setup" value="yes" />')
. html_tag( 'p', "\n" .
'<input type="checkbox" name="delete_words" value="ON" />'
$SQSPELL_DIR='plugins/squirrelspell/';
$SQSPELL_CRYPTO=FALSE;
+
/**
- * Load the stuff needed from SquirrelMail
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../../');
+require('../../include/init.php');
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/display_messages.php');
include_once(SM_PATH . $SQSPELL_DIR . 'sqspell_functions.php');
/**
$SQSPELL_DIR='plugins/squirrelspell/';
$SQSPELL_CRYPTO=FALSE;
+
/**
- * Load some necessary stuff from SquirrelMail.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../../');
+require('../../include/init.php');
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/display_messages.php');
include_once(SM_PATH . $SQSPELL_DIR . 'sqspell_functions.php');
/**
*/
/**
- * Define for wrecked souls accessing functions script directly
- * @ignore
+ * do not allow to call this file directly
*/
-if (!defined('SM_PATH')) {
- define('SM_PATH','../../');
+if ((isset($_SERVER) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) ||
+ (isset($HTTP_SERVER_SERVER) && $HTTP_SERVER_SERVER['SCRIPT_FILENAME'] == __FILE__) ) {
+ header("Location: ../../src/login.php");
+ die();
}
-
/** Load default config */
if (file_exists(SM_PATH . 'plugins/translate/config_default.php')) {
include_once(SM_PATH . 'plugins/translate/config_default.php');
$body = decodeBody($body, $body_message->header->encoding);
/*
- * if message part is html formated - convert spaces, html line feeds,
+ * if message part is html formated - convert spaces, html line feeds,
* less than and greater than html entities and remove tags
*/
if ($body_message->header->type1 == 'html') {
* Starts translation box
*
* @param string $action url that has to recieve message for translation
- * @param string $charset (since sm 1.5.1) character set, that should be used
+ * @param string $charset (since sm 1.5.1) character set, that should be used
* to submit 8bit information.
* @access private
*/
if (!$translate_same_window) {
echo ' target="_blank"';
}
-
+
if (! is_null($charset))
echo ' accept-charset="'.htmlspecialchars($charset).'"';
translate_table_end();
}
-?>
+?>
\ No newline at end of file
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../../');
+require('../../include/init.php');
-/** SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
/** Plugin functions */
include_once(SM_PATH . 'plugins/translate/functions.php');
* @subpackage translate
*/
-/**
- * If SM_PATH isn't defined, define it.
- * @ignore
- */
-if (!defined('SM_PATH')) {
- define('SM_PATH','../../');
-}
/**
* Initialize the translation plugin
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
-
-/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
+require('../include/init.php');
displayPageHeader($color, 'None' );
echo "<br />\n";
echo _("The administrator installed the following plugins:");
echo "<br />\n";
-if ( count ($plugins) > 0 ) {
+if ( isset($plugins) && count ($plugins) > 0 ) {
sort($plugins);
echo "<ul>\n";
foreach($plugins as $plugin) {
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
-
-/** SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/addressbook.php');
+include('../include/init.php');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
+require('../include/init.php');
-/** SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/strings.php');
-include_once(SM_PATH . 'functions/global.php');
-include_once(SM_PATH . 'functions/html.php');
include_once(SM_PATH . 'functions/forms.php');
include_once(SM_PATH . 'functions/addressbook.php');
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
+ * Because this file can also be included within compose we check for the $bInit
+ * var which is set inside ini.php. It's needed because compose already includes
+ * init.php.
*/
-if (! defined('SM_PATH') ) {
- define('SM_PATH','../');
+if (!isset($bInit)) {
+ include('../include/init.php');
}
/** SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/global.php');
include_once(SM_PATH . 'functions/date.php');
-include_once(SM_PATH . 'functions/display_messages.php');
include_once(SM_PATH . 'functions/addressbook.php');
-include_once(SM_PATH . 'functions/plugin.php');
-include_once(SM_PATH . 'functions/strings.php');
-include_once(SM_PATH . 'functions/html.php');
sqgetGlobalVar('session', $session, SQ_POST);
sqgetGlobalVar('mailbox', $mailbox, SQ_POST);
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
+include('../include/init.php');
/** SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-/* plain_error_message() */
-include_once(SM_PATH . 'functions/display_messages.php');
/* address book functions */
-include_once(SM_PATH . 'functions/addressbook.php');
+require_once(SM_PATH . 'functions/addressbook.php');
/* form functions */
-include_once(SM_PATH . 'functions/forms.php');
+require_once(SM_PATH . 'functions/forms.php');
/** lets get the global vars we may need */
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
+require('../include/init.php');
/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/global.php');
-require_once(SM_PATH . 'functions/imap.php');
+require_once(SM_PATH . 'functions/imap_general.php');
+require_once(SM_PATH . 'functions/imap_messages.php');
require_once(SM_PATH . 'functions/date.php');
require_once(SM_PATH . 'functions/mime.php');
-require_once(SM_PATH . 'functions/plugin.php');
-require_once(SM_PATH . 'functions/display_messages.php');
require_once(SM_PATH . 'class/deliver/Deliver.class.php');
require_once(SM_PATH . 'functions/addressbook.php');
require_once(SM_PATH . 'functions/forms.php');
if(count($sizes) > 0) {
$maxsize = '(max. ' . show_readable_size( min( $sizes ) ) . ')'
- . addHidden('MAX_FILE_SIZE', min( $sizes ));
+ . addHidden('MAX_FILE_SIZE', min( $sizes ));
} else {
$maxsize = '';
}
$composeMessage->purgeAttachments();
if ($action == 'reply' || $action == 'reply_all') {
+ require(SM_PATH . 'functions/mailbox_display.php');
$aMailbox = sqm_api_mailbox_select($imap_stream, $iAccount, $mailbox,array('setindex' => $what, 'offset' => $startMessage),array());
// check if we are allowed to set the \\Answered flag
if (in_array('\\answered',$aMailbox['PERMANENTFLAGS'], true)) {
return $success;
}
-?>
+?>
\ No newline at end of file
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
-
-/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/display_messages.php');
-
-global $color;
+include('../include/init.php');
error_box('delete_message.php script is obsolete since 1.5.1.',$color);
$oTemplate->display('footer.tpl');
?>
\ No newline at end of file
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
+require('../include/init.php');
/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/imap.php');
-require_once(SM_PATH . 'functions/mime.php');
+require(SM_PATH . 'functions/imap_general.php');
+require(SM_PATH . 'functions/mailbox_display.php');
+require(SM_PATH . 'functions/mime.php');
header('Pragma: ');
header('Cache-Control: cache');
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
+require('../include/init.php');
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/display_messages.php');
-require_once(SM_PATH . 'functions/imap.php');
-require_once(SM_PATH . 'functions/tree.php');
+require(SM_PATH . 'functions/imap_general.php');
+require(SM_PATH . 'functions/imap_messages.php');
+require(SM_PATH . 'functions/tree.php');
/* get those globals */
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
+require('../include/init.php');
/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/imap.php');
+require_once(SM_PATH . 'functions/imap_general.php');
require_once(SM_PATH . 'functions/folder_manip.php');
-require_once(SM_PATH . 'functions/plugin.php');
-require_once(SM_PATH . 'functions/html.php');
require_once(SM_PATH . 'functions/forms.php');
displayPageHeader($color, 'None');
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
-
-/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/global.php');
-require_once(SM_PATH . 'functions/display_messages.php');
+require('../include/init.php');
displayPageHeader($color, 'None' );
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
-
-/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/global.php');
-require_once(SM_PATH . 'functions/date.php');
-require_once(SM_PATH . 'functions/page_header.php');
-require_once(SM_PATH . 'functions/html.php');
-require_once(SM_PATH . 'include/load_prefs.php');
+require('../include/init.php');
displayPageHeader($color, 'None');
</td></tr></table>
<?php
$oTemplate->display('footer.tpl');
-?>
\ No newline at end of file
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
+require('../include/init.php');
/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/imap.php');
-require_once(SM_PATH . 'functions/plugin.php');
-require_once(SM_PATH . 'functions/page_header.php');
-require_once(SM_PATH . 'functions/html.php');
+require_once(SM_PATH . 'functions/imap_general.php');
require_once(SM_PATH . 'functions/date.php');
-
-/** add required includes */
-include_once(SM_PATH . 'templates/util_global.php');
-include_once(SM_PATH . 'templates/util_left_main.php');
+require_once(SM_PATH . 'templates/util_global.php');
+require_once(SM_PATH . 'templates/util_left_main.php');
/* These constants are used for folder stuff. */
define('SM_BOX_UNCOLLAPSED', 0);
foreach ($js_includes as $js_file) {
$xtra .= '<script src="'.$js_file.'" type="text/javascript"></script>' ."\n";
}
-
+
// get mailbox list and cache it
$mailboxes=sqimap_get_mailboxes($imapConnection,false,$show_only_subscribed_folders);
* @package squirrelmail
*/
+// reduces the files included in init.php
+$sInitLocation = 'login';
+
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
+require('../include/init.php');
+
/* SquirrelMail required files. */
-require_once(SM_PATH . 'functions/global.php');
-require_once(SM_PATH . 'functions/strings.php');
-require_once(SM_PATH . 'config/config.php');
-require_once(SM_PATH . 'functions/i18n.php');
-require_once(SM_PATH . 'functions/plugin.php');
-require_once(SM_PATH . 'functions/constants.php');
-require_once(SM_PATH . 'functions/page_header.php');
-require_once(SM_PATH . 'functions/html.php');
require_once(SM_PATH . 'functions/imap_general.php');
require_once(SM_PATH . 'functions/forms.php');
*/
set_up_language($squirrelmail_language, TRUE, TRUE);
-/**
- * Find out the base URI to set cookies.
- */
-$base_uri = sqm_baseuri();
-
/*
* In case the last session was not terminated properly, make sure
* we get a new one.
*/
-
sqsession_destroy();
+sqsession_is_active();
+$_SESSION=array();
+
+
/**
* PHP bug. http://bugs.php.net/11643 (warning, spammed bug tracker) and
* http://bugs.php.net/13834
- * SID constant is not destroyed in PHP 4.1.2, 4.2.3 and maybe other
+ * SID constant is not destroyed in PHP 4.1.2, 4.2.3 and maybe other
* versions. Produces warning on login page. Bug should be fixed only in 4.3.0
*/
-@sqsession_start();
-header('Pragma: no-cache');
+//exit;
/**
* This detects if the IMAP server has logins disabled, and if so,
* squelches the display of the login form and puts up a message
}
}
-/*
- * Initialize the template object and custom error handler object
- */
-include_once(SM_PATH . 'class/template/template.class.php');
-include_once(SM_PATH . 'class/error.class.php');
-
-/*
- * $sTplDir is not initialized when a user is not logged in, so we will use
- * the config file defaults here. If the neccesary variables are net set,
- * force a default value.
- */
-$aTemplateSet = ( !isset($aTemplateSet) ? array() : $aTemplateSet );
-$templateset_default = ( !isset($templateset_default) ? 0 : $templateset_default );
-$sTplDir = ( !isset($aTemplateSet[$templateset_default]['PATH']) ?
- SM_PATH . 'templates/default/' :
- $aTemplateSet[$templateset_default]['PATH'] );
-
-$oTemplate = new Template($sTplDir);
-$oErrorHandler = new ErrorHandler($oTemplate,'error_message.tpl');
-
do_hook('login_cookie');
$loginname_value = (sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : '');
$org_logo_height>0) {
$width_and_height .= " height=\"$org_logo_height\"";
}
-
+
$logo_str = '<img src="'.$org_logo.'" ' .
'alt="'. sprintf(_("%s Logo"), $org_name).'" ' .
$width_and_height .
$rcptaddress .
addHidden('just_logged_in', '1');
+session_write_close();
+
$oTemplate->assign('color', $color);
$oTemplate->assign('logo_str', $logo_str);
$oTemplate->assign('sm_attribute_str', $sm_attribute_str);
* @package squirrelmail
*/
+// reduce the included files in int.php
+$bLogin = true;
+
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
-
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'config/config.php');
-require_once(SM_PATH . 'functions/global.php');
-require_once(SM_PATH . 'functions/strings.php');
+require('../include/init.php');
/* Force users to login each time? */
$force_login = true;
}
$url = substr($url, 0, -1);
}
-sqsession_is_active();
if($force_login == false && sqsession_is_registered('user_is_logged_in')) {
if($compose_only == true) {
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
+require('../include/init.php');
/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/global.php');
-include_once(SM_PATH . 'functions/display_messages.php');
-include_once(SM_PATH . 'functions/imap.php');
-include_once(SM_PATH . 'functions/options.php');
-include_once(SM_PATH . 'functions/strings.php');
-include_once(SM_PATH . 'functions/html.php');
-include_once(SM_PATH . 'functions/forms.php');
+
+//include(SM_PATH . 'functions/imap_general.php');
+require_once(SM_PATH . 'functions/options.php');
+require_once(SM_PATH . 'functions/forms.php');
/*********************************/
/*** Build the resultant page. ***/
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
-
-/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/display_messages.php');
-include_once(SM_PATH . 'functions/imap.php');
-include_once(SM_PATH . 'functions/plugin.php');
-include_once(SM_PATH . 'functions/strings.php');
-include_once(SM_PATH . 'functions/html.php');
-include_once(SM_PATH . 'functions/forms.php');
+require('../include/init.php');
+
+// include_once(SM_PATH . 'functions/imap.php');
+require_once(SM_PATH . 'functions/forms.php');
/* get globals */
sqGetGlobalVar('action', $action);
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
+require('../include/init.php');
/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/global.php');
-include_once(SM_PATH . 'functions/display_messages.php');
-include_once(SM_PATH . 'functions/html.php');
-include_once(SM_PATH . 'functions/identity.php');
+require_once(SM_PATH . 'functions/identity.php');
if (!sqgetGlobalVar('identities', $identities, SQ_SESSION)) {
$identities = get_identities();
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
+require('../include/init.php');
/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/global.php');
-include_once(SM_PATH . 'functions/display_messages.php');
-include_once(SM_PATH . 'functions/imap.php');
-include_once(SM_PATH . 'functions/plugin.php');
-include_once(SM_PATH . 'functions/html.php');
-include_once(SM_PATH . 'functions/forms.php');
-include_once(SM_PATH . 'functions/arrays.php');
-//require_once(SM_PATH . 'functions/options.php');
+require_once(SM_PATH . 'functions/forms.php');
+require_once(SM_PATH . 'functions/arrays.php');
/* get globals */
if (sqgetGlobalVar('num', $num, SQ_GET)) {
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
+require('../include/init.php');
/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/imap.php');
+require_once(SM_PATH . 'functions/imap_general.php');
+require_once(SM_PATH . 'functions/imap_messages.php');
+require_once(SM_PATH . 'functions/date.php');
+require_once(SM_PATH . 'functions/mime.php');
+require_once(SM_PATH . 'functions/url_parser.php');
/* get some of these globals */
sqgetGlobalVar('username', $username, SQ_SESSION);
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
-
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
+include('../include/init.php');
/* get those globals into gear */
global $color;
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
+include('../include/init.php');
-/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
displayHtmlHeader( _("Printer Friendly"),
"<script type=\"text/javascript\">\n".
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
+require('../include/init.php');
/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-//require_once(SM_PATH . 'functions/global.php');
+
+
require_once(SM_PATH . 'functions/imap.php');
+require_once(SM_PATH . 'functions/imap_asearch.php'); // => move to mailbox_display
require_once(SM_PATH . 'functions/mime.php');
require_once(SM_PATH . 'functions/date.php');
require_once(SM_PATH . 'functions/url_parser.php');
-require_once(SM_PATH . 'functions/html.php');
-//require_once(SM_PATH . 'functions/global.php');
require_once(SM_PATH . 'functions/identity.php');
-include_once(SM_PATH . 'functions/arrays.php');
-include_once(SM_PATH . 'functions/mailbox_display.php');
+require_once(SM_PATH . 'functions/arrays.php');
+require_once(SM_PATH . 'functions/mailbox_display.php');
+require_once(SM_PATH . 'functions/forms.php');
+require_once(SM_PATH . 'functions/attachment_common.php');
/**
* Given an IMAP message id number, this will look it up in the cached
}
}
if($has_html == true) {
- $vars = array('passed_ent_id', 'show_more', 'show_more_cc', 'override_type0', 'override_type1', 'startMessage', 'where', 'what');
+ $vars = array('passed_ent_id', 'show_more', 'show_more_cc', 'override_type0', 'override_type1', 'startMessage','where', 'what');
$new_link = $base_uri . 'src/read_body.php?passed_id=' . urlencode($passed_id) .
'&passed_ent_id=' . urlencode($passed_ent_id) .
_("Server replied:") . ' ' . $deliver->dlv_ret_nr . ' ' .
nl2br(htmlspecialchars($deliver->dlv_server_msg));
}
- require_once(SM_PATH . 'functions/display_messages.php');
plain_error_message($msg, $color);
} else {
unset ($deliver);
}
}
+/**
+ * Write mailbox with updated seen flag information back to cache.
+ */
+$mailbox_cache[$iAccount.'_'.$aMailbox['NAME']] = $aMailbox;
+sqsession_register($mailbox_cache,'mailbox_cache');
+$_SESSION['mailbox_cache'] = $mailbox_cache;
+$oTemplate->display('footer.tpl');
+
displayPageHeader($color, $mailbox,'','');
formatMenuBar($aMailbox, $passed_id, $passed_ent_id, $message,false);
formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee);
do_hook('read_body_bottom');
sqimap_logout($imapConnection);
-/**
- * Write mailbox with updated seen flag information back to cache.
- */
-$mailbox_cache[$iAccount.'_'.$aMailbox['NAME']] = $aMailbox;
-sqsession_register($mailbox_cache,'mailbox_cache');
-$oTemplate->display('footer.tpl');
?>
* @version $Id$
* @package squirrelmail
*/
+$sInitLocation = 'redirect';
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
+require('../include/init.php');
/* SquirrelMail required files. */
-require_once(SM_PATH . 'functions/global.php');
-require_once(SM_PATH . 'functions/i18n.php');
+require_once(SM_PATH . 'functions/imap_general.php');
require_once(SM_PATH . 'functions/strings.php');
-require_once(SM_PATH . 'config/config.php');
-require_once(SM_PATH . 'functions/prefs.php');
-require_once(SM_PATH . 'functions/imap.php');
-require_once(SM_PATH . 'functions/plugin.php');
-require_once(SM_PATH . 'functions/constants.php');
-require_once(SM_PATH . 'functions/page_header.php');
-
-/* Before starting the session, the base URI must be known. Assuming */
-/* that this file is in the src/ subdirectory (or something). */
-$base_uri = sqm_baseuri();
header('Pragma: no-cache');
$location = get_location();
-session_set_cookie_params (0, $base_uri);
-sqsession_is_active();
+// session_set_cookie_params (0, $base_uri);
sqsession_unregister ('user_is_logged_in');
sqsession_register ($base_uri, 'base_uri');
$base_uri);
if (!isset($login_username)) {
- include_once(SM_PATH . 'functions/display_messages.php' );
logout_error( _("You must be logged in to access this page.") );
exit;
}
$onetimepad = OneTimePadCreate(strlen($secretkey));
$key = OneTimePadEncrypt($secretkey, $onetimepad);
- sqsession_register($onetimepad, 'onetimepad');
/* remove redundant spaces */
$login_username = trim($login_username);
}
$imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0);
+ /* From now on we are logged it. If the login failed then sqimap_login handles it */
+
+ /* regenerate the session id to avoid session hyijacking */
+ sqsession_destroy();
+ sqsession_is_active();
+ session_regenerate_id();
+ /**
+ * The cookie part. session_start and session_regenerate_session normally set
+ * their own cookie. SquirrelMail sets another cookie which overwites the
+ * php cookies. The sqsetcookie function sets the cookie by using the header
+ * function which gives us full control how the cookie is set. We do that
+ * to add the HttpOnly cookie attribute which blocks javascript access on
+ * IE6 SP1.
+ * sqsetcookieflush is needed to send out the headers. sqsetcookie caches
+ * the cookies to be send. If we don't do that we only can send 1 single cookie
+ * which is not sufficient.
+ */
+ sqsetcookie(session_name(),session_id(),false,$base_uri);
+ sqsetcookie('key', $key, false, $base_uri);
+ sqsetcookieflush();
+
+ sqsession_register($onetimepad, 'onetimepad');
$sqimap_capabilities = sqimap_capability($imapConnection);
$username = $login_username;
sqsession_register ($username, 'username');
- sqsetcookie('key', $key, false, $base_uri);
do_hook ('login_verified');
-
}
/* Set the login variables. */
}
unset($session_expired_location);
}
+
if($mailto != '') {
$redirect_url = $location . '/webmail.php?right_frame=compose.php&mailto=';
$redirect_url .= urlencode($mailto);
/* Write session data and send them off to the appropriate page. */
session_write_close();
header("Location: $redirect_url");
+exit;
/* --------------------- end main ----------------------- */
}
sqsession_register($attachment_common_types, 'attachment_common_types');
}
-
-?>
\ No newline at end of file
* @package squirrelmail
*/
+//xdebug_start_profiling("/var/spool/xdebug/right_main.txt");
+
+
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
+include('../include/init.php');
/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-//include_once(SM_PATH . 'functions/global.php');
-require_once(SM_PATH . 'functions/imap.php');
+require_once(SM_PATH . 'functions/imap_asearch.php');
+require_once(SM_PATH . 'functions/imap_general.php');
+require_once(SM_PATH . 'functions/imap_messages.php');
require_once(SM_PATH . 'functions/date.php');
require_once(SM_PATH . 'functions/mime.php');
require_once(SM_PATH . 'functions/mailbox_display.php');
-require_once(SM_PATH . 'functions/display_messages.php');
-require_once(SM_PATH . 'functions/html.php');
-//require_once(SM_PATH . 'functions/plugin.php');
-
-// Trigger Developers to look at CSS ;)
-// trigger_error("This layout sucks. Adapt squirrelmail.css!!!",E_USER_WARNING);
-//sqm_trigger_imap_error('SQM_IMAP_NO_THREAD',"BLA1",'BAD', 'BLA2', array('test1'=>'test1'));
/* lets get the global vars we may need */
sqgetGlobalVar('key', $key, SQ_COOKIE);
/* add the mailbox to the cache */
$mailbox_cache[$account.'_'.$aMailbox['NAME']] = $aMailbox;
sqsession_register($mailbox_cache,'mailbox_cache');
-?>
\ No newline at end of file
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
+require('../include/init.php');
/** SquirrelMail required files.
*/
-include_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/strings.php');
-include_once(SM_PATH . 'functions/imap_asearch.php');
-include_once(SM_PATH . 'functions/imap_mailbox.php');
-include_once(SM_PATH . 'functions/imap_messages.php');
-include_once(SM_PATH . 'functions/mime.php');
-include_once(SM_PATH . 'functions/mailbox_display.php'); //getButton()...
-include_once(SM_PATH . 'class/template/template.class.php');
+require_once(SM_PATH . 'functions/imap_asearch.php');
+require_once(SM_PATH . 'functions/imap_messages.php');
+require_once(SM_PATH . 'functions/imap_general.php');
+require_once(SM_PATH . 'functions/mime.php');
+require_once(SM_PATH . 'functions/mailbox_display.php'); //getButton()
+require_once(SM_PATH . 'functions/forms.php');
+require_once(SM_PATH . 'functions/date.php');
/** Prefs array ordinals. Must match $recent_prefkeys and $saved_prefkeys
*/
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
-
-include_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/prefs.php');
-require_once(SM_PATH . 'functions/plugin.php');
-require_once(SM_PATH . 'functions/strings.php');
-require_once(SM_PATH . 'functions/html.php');
+require('../include/init.php');
/* Erase any lingering attachments */
sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION);
/* If a user hits reload on the last page, $base_uri isn't set
* because it was deleted with the session. */
if (! sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION) ) {
- require_once(SM_PATH . 'functions/display_messages.php');
$base_uri = sqm_baseuri();
}
* @package squirrelmail
*/
-/** @ignore */
-define('SM_PATH','../');
+/**
+ * Set the location in order to skip unneeded validation and other includes
+ * in the SquirrelMail initialisation file.
+ */
+$sInitLocation = 'style';
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'functions/global.php');
-require_once(SM_PATH . 'functions/strings.php');
-require_once(SM_PATH . 'config/config.php');
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../include/init.php');
/* safety check for older config.php */
if (!isset($fontsets) || !is_array($fontsets)) {
$fontsets=array();
}
-
-/* template init */
-/** start block copy from right_main.php */
-include_once(SM_PATH . 'class/template/template.class.php');
-
/**
* get template name and set used template directory
- *
+ *
* Existing file check has been moved into the template object, so it is
- * not neccesary to do file_exists() here.
+ * not neccesary to do file_exists() here.
* */
if (sqgetGlobalVar('templateid',$templateid,SQ_GET)) {
$sTplDir = SM_PATH.'templates/'.basename($templateid).'/';
foreach ($template_css as $stylesheet) {
$oTemplate->display($stylesheet);
}
-
-?>
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-Define('SM_PATH','../');
+require('../include/init.php');
/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
require_once(SM_PATH . 'functions/mime.php');
require_once(SM_PATH . 'functions/url_parser.php');
+require_once(SM_PATH . 'functions/imap_general.php');
+require_once(SM_PATH . 'functions/imap_messages.php');
/* globals */
sqgetGlobalVar('username', $username, SQ_SESSION);
</td></tr></table>
<?php
$oTemplate->display('footer.tpl');
-?>
+?>
\ No newline at end of file
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
+require('../include/init.php');
/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/global.php');
require_once(SM_PATH . 'functions/imap.php');
-require_once(SM_PATH . 'functions/html.php');
require_once(SM_PATH . 'functions/url_parser.php');
function parse_viewheader($imapConnection,$id, $passed_ent_id) {
return $header_output;
}
+/**
+ * Temporary test function to process template vars with formatting.
+ * I use it for viewing the message_header (view_header.php) with
+ * a sort of template.
+ * @param mixed $var
+ * @param mixed $format_ar
+ * @since 1.3.0
+ * @todo if function is temporary, then why it is used.
+ * @deprecated
+ */
+function echo_template_var($var, $format_ar = array() ) {
+ $frm_last = count($format_ar) -1;
+
+ if (isset($format_ar[0])) echo $format_ar[0];
+ $i = 1;
+
+ switch (true) {
+ case (is_string($var)):
+ echo $var;
+ break;
+ case (is_array($var)):
+ $frm_a = array_slice($format_ar,1,$frm_last-1);
+ foreach ($var as $a_el) {
+ if (is_array($a_el)) {
+ echo_template_var($a_el,$frm_a);
+ } else {
+ echo $a_el;
+ if (isset($format_ar[$i])) {
+ echo $format_ar[$i];
+ }
+ $i++;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ if (isset($format_ar[$frm_last]) && $frm_last>$i ) {
+ echo $format_ar[$frm_last];
+ }
+}
+
function view_header($header, $mailbox, $color) {
sqgetGlobalVar('QUERY_STRING', $queryStr, SQ_SERVER);
$ret_addr = SM_PATH . 'src/read_body.php?'.$queryStr;
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
+require('../include/init.php');
/** SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-include_once(SM_PATH . 'functions/imap.php');
+require_once(SM_PATH . 'functions/imap.php');
+require_once(SM_PATH . 'functions/mime.php');
+require_once(SM_PATH . 'functions/date.php');
/** Get globals */
sqgetGlobalVar('key', $key, SQ_COOKIE);
/** TODO: charset might be part of html code. */
header('Content-Type: text/html; charset=' . $charset);
echo $body;
-
?>
\ No newline at end of file
* @package squirrelmail
*/
-/**
- * Path for SquirrelMail required files.
- * @ignore
- */
-define('SM_PATH','../');
/* SquirrelMail required files. */
-include_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/global.php');
-require_once(SM_PATH . 'functions/imap.php');
-require_once(SM_PATH . 'functions/mime.php');
-require_once(SM_PATH . 'functions/html.php');
+include('../include/init.php');
+include(SM_PATH . 'functions/imap_general.php');
+include(SM_PATH . 'functions/imap_messages.php');
+include(SM_PATH . 'functions/mime.php');
+include(SM_PATH . 'functions/date.php');
+include(SM_PATH . 'functions/url_parser.php');
sqgetGlobalVar('key', $key, SQ_COOKIE);
sqgetGlobalVar('username', $username, SQ_SESSION);
*/
/**
- * Path for SquirrelMail required files.
- * @ignore
+ * Include the SquirrelMail initialization file.
*/
-define('SM_PATH','../');
-
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'functions/global.php');
-require_once(SM_PATH . 'functions/strings.php');
-require_once(SM_PATH . 'config/config.php');
-require_once(SM_PATH . 'functions/prefs.php');
-require_once(SM_PATH . 'functions/imap.php');
-require_once(SM_PATH . 'functions/plugin.php');
-require_once(SM_PATH . 'functions/i18n.php');
-require_once(SM_PATH . 'functions/auth.php');
-
-$base_uri = sqm_baseuri();
-
-sqsession_is_active();
+require('../include/init.php');
sqgetGlobalVar('username', $username, SQ_SESSION);
sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
$mailto = '';
}
-is_logged_in();
-
do_hook('webmail_top');
-/**
- * We'll need this to later have a noframes version
- *
- * Check if the user has a language preference, but no cookie.
- * Send him a cookie with his language preference, if there is
- * such discrepancy.
- */
-$my_language = getPref($data_dir, $username, 'language');
-if ($my_language != $squirrelmail_language) {
- sqsetcookie('squirrelmail_language', $my_language, time()+2592000, $base_uri);
-}
-
-$err=set_up_language(getPref($data_dir, $username, 'language'));
-
$output = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"\n".
" \"http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd\">\n".
"<html><head>\n" .
"<title>$org_title</title>\n".
"</head>";
-// Japanese translation used without mbstring support
-if ($err==2) {
- echo $output.
- "<body>\n".
- "<p>You need to have PHP installed with the multibyte string function \n".
- "enabled (using configure option --enable-mbstring).</p>\n".
- "<p>System assumed that you accidently switched to Japanese translation \n".
- "and reverted your language preference to English.</p>\n".
- "<p>Please refresh this page in order to use webmail.</p>\n".
- "</body></html>";
- return;
-}
-
$left_size = getPref($data_dir, $username, 'left_size');
$location_of_bar = getPref($data_dir, $username, 'location_of_bar');
default:
$right_frame_url = urlencode($right_frame);
break;
-}
+}
$left_frame = '<frame src="left_main.php" name="left" frameborder="1" title="'.
_("Folder List") ."\" />\n";
if($ret != '') {
$output = $ret;
}
-echo $output;
-?>
-</frameset>
-</html>
+echo $output . '</frameset>';
+
+$oTemplate->display('footer.tpl');