Initial revision
@ -0,0 +1,12 @@
|
|||||||
|
php_flag display_errors On
|
||||||
|
php_value session.gc_maxlifetime 21600
|
||||||
|
php_value session.gc_divisor 500
|
||||||
|
php_value upload_max_filesize 2m
|
||||||
|
|
||||||
|
<FilesMatch "(\.inc|\~)$|^_">
|
||||||
|
Order allow,deny
|
||||||
|
Deny from all
|
||||||
|
</FilesMatch>
|
||||||
|
|
||||||
|
Order deny,allow
|
||||||
|
Allow from all
|
@ -0,0 +1,26 @@
|
|||||||
|
CHANGELOG RoundCube Webmail
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
2005/08/11
|
||||||
|
----------
|
||||||
|
- Write list header to client even if list is empty
|
||||||
|
- Add functions "select all", "select none" to message list
|
||||||
|
- Improved filter for HTML messages to remove potentially malicious tags (script, iframe, object) and event handlers.
|
||||||
|
- Buttons for next/previous message in view mode
|
||||||
|
- Add new created contact to list and show confirmation status
|
||||||
|
- Added folder management (subscribe/create/delete)
|
||||||
|
- Log message sending (SMTP log)
|
||||||
|
- Grant access for Camino browser
|
||||||
|
- Added German translation
|
||||||
|
|
||||||
|
|
||||||
|
2005/08/20
|
||||||
|
----------
|
||||||
|
- Improved cacheing of mailbox messagecount
|
||||||
|
- Fixed javascript bug when creating a new message folder
|
||||||
|
- Fixed javascript bugs #1260990 and #1260992: folder selection
|
||||||
|
- Make Trash folder configurable
|
||||||
|
- Auto create folders Inbox, Sent and Trash (if configured)
|
||||||
|
- Support for IMAP root folder
|
||||||
|
- Added support fot text/enriched messages
|
||||||
|
- Make list of special mailboxes configurable
|
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
INSTALLATION
|
||||||
|
============
|
||||||
|
|
||||||
|
1. Decompress and put this folder somewhere inside your document root
|
||||||
|
2. Make shure that the following directories are writable by the webserver
|
||||||
|
- /temp
|
||||||
|
- /logs
|
||||||
|
3. Modify the files in /config to suit your local environment
|
||||||
|
4. Create database tables using the queries in file 'SQL/initial.sql'
|
||||||
|
Rename tables if you like, but make shure the names are also changed in /config/db.inc
|
||||||
|
5. Done!
|
||||||
|
|
||||||
|
|
||||||
|
REQUIREMENTS
|
||||||
|
============
|
||||||
|
|
||||||
|
* The Apache Webserver
|
||||||
|
* .htaccess support allowing overrides for DirectoryIndex
|
||||||
|
* PHP Version 4.3.1 or greater
|
||||||
|
* php.ini options:
|
||||||
|
- error_reporting E_ALL & ~E_NOTICE (or lower)
|
||||||
|
- file_uploads on (for attachment upload features)
|
||||||
|
* The MySQL database engine
|
||||||
|
* A database with permission to create tables
|
||||||
|
|
||||||
|
|
||||||
|
CONFIGURATION
|
||||||
|
=============
|
||||||
|
|
||||||
|
Change the files in /config/ according your environment and you needs.
|
||||||
|
Details about the config paramaters can be found in the config files.
|
@ -0,0 +1,93 @@
|
|||||||
|
-- RoundCube Webmail initial database structure
|
||||||
|
-- Version 0.1a
|
||||||
|
--
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `cache`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `cache` (
|
||||||
|
`cache_id` int(10) unsigned NOT NULL auto_increment,
|
||||||
|
`user_id` int(10) unsigned NOT NULL default '0',
|
||||||
|
`session_id` varchar(32) default NULL,
|
||||||
|
`cache_key` varchar(128) NOT NULL default '',
|
||||||
|
`created` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
`data` longtext NOT NULL,
|
||||||
|
PRIMARY KEY (`cache_id`),
|
||||||
|
KEY `user_id` (`user_id`),
|
||||||
|
KEY `cache_key` (`cache_key`),
|
||||||
|
KEY `session_id` (`session_id`)
|
||||||
|
) TYPE=MyISAM;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `contacts`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `contacts` (
|
||||||
|
`contact_id` int(10) unsigned NOT NULL auto_increment,
|
||||||
|
`user_id` int(10) unsigned NOT NULL default '0',
|
||||||
|
`del` enum('0','1') NOT NULL default '0',
|
||||||
|
`name` varchar(128) NOT NULL default '',
|
||||||
|
`email` varchar(128) NOT NULL default '',
|
||||||
|
`firstname` varchar(128) NOT NULL default '',
|
||||||
|
`surname` varchar(128) NOT NULL default '',
|
||||||
|
`vcard` text NOT NULL,
|
||||||
|
PRIMARY KEY (`contact_id`),
|
||||||
|
KEY `user_id` (`user_id`)
|
||||||
|
) TYPE=MyISAM;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `identities`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `identities` (
|
||||||
|
`identity_id` int(10) unsigned NOT NULL auto_increment,
|
||||||
|
`user_id` int(10) unsigned NOT NULL default '0',
|
||||||
|
`del` enum('0','1') NOT NULL default '0',
|
||||||
|
`default` enum('0','1') NOT NULL default '0',
|
||||||
|
`name` varchar(128) NOT NULL default '',
|
||||||
|
`organization` varchar(128) NOT NULL default '',
|
||||||
|
`email` varchar(128) NOT NULL default '',
|
||||||
|
`reply-to` varchar(128) NOT NULL default '',
|
||||||
|
`bcc` varchar(128) NOT NULL default '',
|
||||||
|
`signature` text NOT NULL,
|
||||||
|
PRIMARY KEY (`identity_id`),
|
||||||
|
KEY `user_id` (`user_id`)
|
||||||
|
) TYPE=MyISAM;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `session`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `session` (
|
||||||
|
`sess_id` varchar(32) NOT NULL default '',
|
||||||
|
`created` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
`changed` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
`vars` text NOT NULL,
|
||||||
|
PRIMARY KEY (`sess_id`)
|
||||||
|
) TYPE=MyISAM;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `users`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `users` (
|
||||||
|
`user_id` int(10) unsigned NOT NULL auto_increment,
|
||||||
|
`username` varchar(128) NOT NULL default '',
|
||||||
|
`mail_host` varchar(255) NOT NULL default '',
|
||||||
|
`created` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
`last_login` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
`language` varchar(5) NOT NULL default 'en',
|
||||||
|
`preferences` text NOT NULL,
|
||||||
|
PRIMARY KEY (`user_id`)
|
||||||
|
) TYPE=MyISAM;
|
@ -0,0 +1,15 @@
|
|||||||
|
UPDATE instructions
|
||||||
|
===================
|
||||||
|
|
||||||
|
Follow these instructions if upgrading from a previous version
|
||||||
|
of RoundCube Webmail.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
from versions 0.1-alpha and 0.1-20050811
|
||||||
|
----------------------------------------
|
||||||
|
- replace all files in folder /program/
|
||||||
|
- add these line to /config/main.inc.php
|
||||||
|
$rcmail_config['trash_mbox'] = 'Trash';
|
||||||
|
$rcmail_config['default_imap_folders'] = array('INBOX', 'Drafts', 'Sent', 'Junk', 'Trash');
|
||||||
|
$rcmail_config['prefer_html'] = TRUE;
|
@ -0,0 +1,2 @@
|
|||||||
|
Order allow,deny
|
||||||
|
Deny from all
|
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Configuration file for database access |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$rcmail_config = array();
|
||||||
|
|
||||||
|
// database engine (currently supported: mysql)
|
||||||
|
$rcmail_config['db_type'] = 'mysql';
|
||||||
|
|
||||||
|
// database host
|
||||||
|
$rcmail_config['db_host'] = 'localhost';
|
||||||
|
|
||||||
|
// database user
|
||||||
|
$rcmail_config['db_user'] = 'roundcube';
|
||||||
|
|
||||||
|
// pwd
|
||||||
|
$rcmail_config['db_pass'] = 'pass';
|
||||||
|
|
||||||
|
// database name
|
||||||
|
$rcmail_config['db_name'] = 'roundcubemail';
|
||||||
|
|
||||||
|
|
||||||
|
// you can define specific table names used to store webmail data
|
||||||
|
$rcmail_config['db_table_users'] = 'users';
|
||||||
|
|
||||||
|
$rcmail_config['db_table_identities'] = 'identities';
|
||||||
|
|
||||||
|
$rcmail_config['db_table_contacts'] = 'contacts';
|
||||||
|
|
||||||
|
$rcmail_config['db_table_session'] = 'session';
|
||||||
|
|
||||||
|
$rcmail_config['db_table_cache'] = 'cache';
|
||||||
|
|
||||||
|
|
||||||
|
// end db config file
|
||||||
|
?>
|
@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Main configuration file |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$rcmail_config = array();
|
||||||
|
|
||||||
|
|
||||||
|
// system error reporting: 1 = log; 2 = report (not implemented yet), 4 = show
|
||||||
|
$rcmail_config['debug_level'] = 5;
|
||||||
|
|
||||||
|
// automatically create a new user when log-in the first time
|
||||||
|
// set to false if only registered users can use this service
|
||||||
|
$rcmail_config['auto_create_user'] = TRUE;
|
||||||
|
|
||||||
|
// the mail host chosen to perform the log-in
|
||||||
|
// leave blank to show a textbox at login, give a list of hosts
|
||||||
|
// to display a pulldown menu or set one host as string
|
||||||
|
$rcmail_config['default_host'] = '';
|
||||||
|
|
||||||
|
// use this host for sending mails.
|
||||||
|
// if left blank, the PHP mail() function is used
|
||||||
|
$rcmail_config['smtp_server'] = '';
|
||||||
|
|
||||||
|
// SMTP username (if required)
|
||||||
|
$rcmail_config['smtp_user'] = '';
|
||||||
|
|
||||||
|
// SMTP password (if required)
|
||||||
|
$rcmail_config['smtp_pass'] = '';
|
||||||
|
|
||||||
|
// Log sent messages
|
||||||
|
$rcmail_config['smtp_log'] = TRUE;
|
||||||
|
|
||||||
|
// these cols are shown in the message list
|
||||||
|
// available cols are: subject, from, to, cc, replyto, date, size, encoding
|
||||||
|
$rcmail_config['list_cols'] = array('subject', 'from', 'date', 'size');
|
||||||
|
|
||||||
|
// relative path to the skin folder
|
||||||
|
$rcmail_config['skin_path'] = 'skins/default/';
|
||||||
|
|
||||||
|
// use this folder to store temp files (must be writebale for apache user)
|
||||||
|
$rcmail_config['temp_dir'] = 'temp/';
|
||||||
|
|
||||||
|
// check client IP in session athorization
|
||||||
|
$rcmail_config['ip_check'] = TRUE;
|
||||||
|
|
||||||
|
// not shure what this was good for :-)
|
||||||
|
$rcmail_config['locale_string'] = 'de_DE';
|
||||||
|
|
||||||
|
// use this format for short date display
|
||||||
|
$rcmail_config['date_short'] = 'D H:i';
|
||||||
|
|
||||||
|
// use this format for detailed date/time formatting
|
||||||
|
$rcmail_config['date_long'] = 'd.m.Y H:i';
|
||||||
|
|
||||||
|
// add this user-agent to message headers when sending
|
||||||
|
$rcmail_config['useragent'] = 'RoundCube Webmail/0.1a';
|
||||||
|
|
||||||
|
// only list folders within this path
|
||||||
|
$rcmail_config['imap_root'] = '';
|
||||||
|
|
||||||
|
// store sent message is this mailbox
|
||||||
|
// leave blank if sent messages should not be stored
|
||||||
|
$rcmail_config['sent_mbox'] = 'Sent';
|
||||||
|
|
||||||
|
// move messages to this folder when deleting them
|
||||||
|
// leave blank if they should be deleted directly
|
||||||
|
$rcmail_config['trash_mbox'] = 'Trash';
|
||||||
|
|
||||||
|
// display these folders separately in the mailbox list
|
||||||
|
$rcmail_config['default_imap_folders'] = array('INBOX', 'Drafts', 'Sent', 'Junk', 'Trash');
|
||||||
|
|
||||||
|
|
||||||
|
/***** these settings can be overwritten by user's preferences *****/
|
||||||
|
|
||||||
|
// show up to X items in list view
|
||||||
|
$rcmail_config['pagesize'] = 40;
|
||||||
|
|
||||||
|
// use this timezone to display date/time
|
||||||
|
$rcmail_config['timezone'] = 1;
|
||||||
|
|
||||||
|
// prefer displaying HTML messages
|
||||||
|
$rcmail_config['prefer_html'] = TRUE;
|
||||||
|
|
||||||
|
|
||||||
|
// end of config file
|
||||||
|
?>
|
@ -0,0 +1,273 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| RoundCube Webmail IMAP Client |
|
||||||
|
| Version 0.1-20050811 |
|
||||||
|
| |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| Redistribution and use in source and binary forms, with or without |
|
||||||
|
| modification, are permitted provided that the following conditions |
|
||||||
|
| are met: |
|
||||||
|
| |
|
||||||
|
| o Redistributions of source code must retain the above copyright |
|
||||||
|
| notice, this list of conditions and the following disclaimer. |
|
||||||
|
| o Redistributions in binary form must reproduce the above copyright |
|
||||||
|
| notice, this list of conditions and the following disclaimer in the |
|
||||||
|
| documentation and/or other materials provided with the distribution.|
|
||||||
|
| o The names of the authors may not be used to endorse or promote |
|
||||||
|
| products derived from this software without specific prior written |
|
||||||
|
| permission. |
|
||||||
|
| |
|
||||||
|
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
|
| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||||
|
| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
||||||
|
| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
||||||
|
| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
||||||
|
| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
||||||
|
| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
||||||
|
| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
||||||
|
| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
||||||
|
| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
||||||
|
| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// define global vars
|
||||||
|
$INSTALL_PATH = './';
|
||||||
|
$OUTPUT_TYPE = 'html';
|
||||||
|
$JS_OBJECT_NAME = 'rcmail';
|
||||||
|
|
||||||
|
|
||||||
|
// set environment first
|
||||||
|
ini_set('include_path', ini_get('include_path').PATH_SEPARATOR.'program'.PATH_SEPARATOR.'program/lib');
|
||||||
|
ini_set('session.name', 'sessid');
|
||||||
|
ini_set('session.use_cookies', 1);
|
||||||
|
//ini_set('session.save_path', $INSTALL_PATH.'session');
|
||||||
|
|
||||||
|
|
||||||
|
// increase maximum execution time for php scripts
|
||||||
|
set_time_limit('120');
|
||||||
|
|
||||||
|
|
||||||
|
// include base files
|
||||||
|
require_once('include/rcube_shared.inc');
|
||||||
|
require_once('include/rcube_imap.inc');
|
||||||
|
require_once('include/rcube_mysql.inc');
|
||||||
|
require_once('include/bugs.inc');
|
||||||
|
require_once('include/main.inc');
|
||||||
|
require_once('include/cache.inc');
|
||||||
|
|
||||||
|
|
||||||
|
// catch some url/post parameters
|
||||||
|
$_auth = strlen($_POST['_auth']) ? $_POST['_auth'] : $_GET['_auth'];
|
||||||
|
$_task = strlen($_POST['_task']) ? $_POST['_task'] : ($_GET['_task'] ? $_GET['_task'] : 'mail');
|
||||||
|
$_action = strlen($_POST['_action']) ? $_POST['_action'] : $_GET['_action'];
|
||||||
|
$_framed = ($_GET['_framed'] || $_POST['_framed']);
|
||||||
|
|
||||||
|
// start session with requested task
|
||||||
|
rcmail_startup($_task);
|
||||||
|
|
||||||
|
|
||||||
|
// set session related variables
|
||||||
|
$COMM_PATH = sprintf('./?_auth=%s&_task=%s', $sess_auth, $_task);
|
||||||
|
$SESS_HIDDEN_FIELD = sprintf('<input type="hidden" name="_auth" value="%s" />', $sess_auth);
|
||||||
|
|
||||||
|
|
||||||
|
// add framed parameter
|
||||||
|
if ($_GET['_framed'] || $_POST['_framed'])
|
||||||
|
{
|
||||||
|
$COMM_PATH .= '&_framed=1';
|
||||||
|
$SESS_HIDDEN_FIELD = "\n".'<input type="hidden" name="_framed" value="1" />';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// init necessary objects for GUI
|
||||||
|
load_gui();
|
||||||
|
|
||||||
|
|
||||||
|
// error steps
|
||||||
|
if ($_action=='error' && strlen($_GET['_code']))
|
||||||
|
{
|
||||||
|
raise_error(array('code' => hexdec($_GET['_code'])), FALSE, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// try to log in
|
||||||
|
if ($_action=='login' && $_task=='mail')
|
||||||
|
{
|
||||||
|
$host = $_POST['_host'] ? $_POST['_host'] : $CONFIG['default_host'];
|
||||||
|
|
||||||
|
// check if client supports cookies
|
||||||
|
if (!$_COOKIE[session_name()])
|
||||||
|
{
|
||||||
|
show_message("cookiesdisabled", 'warning');
|
||||||
|
}
|
||||||
|
else if ($_POST['_user'] && $_POST['_pass'] && rcmail_login($_POST['_user'], $_POST['_pass'], $host))
|
||||||
|
{
|
||||||
|
// send redirect
|
||||||
|
header("Location: $COMM_PATH");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
show_message("loginfailed", 'warning');
|
||||||
|
$_SESSION['user_id'] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// end session
|
||||||
|
else if ($_action=='logout' && $_SESSION['user_id'])
|
||||||
|
{
|
||||||
|
show_message('loggedout');
|
||||||
|
rcmail_kill_session();
|
||||||
|
}
|
||||||
|
|
||||||
|
// check session cookie and auth string
|
||||||
|
else if ($_action!='login' && $_auth && $sess_auth)
|
||||||
|
{
|
||||||
|
if ($_auth !== $sess_auth || $_auth != rcmail_auth_hash($_SESSION['client_id'], $_SESSION['auth_time']))
|
||||||
|
{
|
||||||
|
show_message('sessionerror', 'error');
|
||||||
|
rcmail_kill_session();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// log in to imap server
|
||||||
|
if ($_SESSION['user_id'] && $_task=='mail')
|
||||||
|
{
|
||||||
|
$conn = $IMAP->connect($_SESSION['imap_host'], $_SESSION['username'], decrypt_passwd($_SESSION['password']));
|
||||||
|
if (!$conn)
|
||||||
|
{
|
||||||
|
show_message('imaperror', 'error');
|
||||||
|
$_SESSION['user_id'] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// not logged in -> set task to 'login
|
||||||
|
if (!$_SESSION['user_id'])
|
||||||
|
$_task = 'login';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// set taask and action to client
|
||||||
|
$script = sprintf("%s.set_env('task', '%s');", $JS_OBJECT_NAME, $_task);
|
||||||
|
if (!empty($_action))
|
||||||
|
$script .= sprintf("\n%s.set_env('action', '%s');", $JS_OBJECT_NAME, $_action);
|
||||||
|
|
||||||
|
$OUTPUT->add_script($script);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// not logged in -> show login page
|
||||||
|
if (!$_SESSION['user_id'])
|
||||||
|
{
|
||||||
|
parse_template('login');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// include task specific files
|
||||||
|
if ($_task=='mail')
|
||||||
|
{
|
||||||
|
include_once('program/steps/mail/func.inc');
|
||||||
|
|
||||||
|
if ($_action=='show' || $_action=='print')
|
||||||
|
include('program/steps/mail/show.inc');
|
||||||
|
|
||||||
|
if ($_action=='get')
|
||||||
|
include('program/steps/mail/get.inc');
|
||||||
|
|
||||||
|
if ($_action=='moveto' || $_action=='delete')
|
||||||
|
include('program/steps/mail/move_del.inc');
|
||||||
|
|
||||||
|
if ($_action=='mark')
|
||||||
|
include('program/steps/mail/mark.inc');
|
||||||
|
|
||||||
|
if ($_action=='viewsource')
|
||||||
|
include('program/steps/mail/viewsource.inc');
|
||||||
|
|
||||||
|
if ($_action=='send')
|
||||||
|
include('program/steps/mail/sendmail.inc');
|
||||||
|
|
||||||
|
if ($_action=='upload')
|
||||||
|
include('program/steps/mail/upload.inc');
|
||||||
|
|
||||||
|
if ($_action=='compose')
|
||||||
|
include('program/steps/mail/compose.inc');
|
||||||
|
|
||||||
|
if ($_action=='addcontact')
|
||||||
|
include('program/steps/mail/addcontact.inc');
|
||||||
|
|
||||||
|
if ($_action=='list' && $_GET['_remote'])
|
||||||
|
include('program/steps/mail/list.inc');
|
||||||
|
|
||||||
|
// kill compose entry from session
|
||||||
|
if (isset($_SESSION['compose']))
|
||||||
|
rcmail_compose_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// include task specific files
|
||||||
|
if ($_task=='addressbook')
|
||||||
|
{
|
||||||
|
include_once('program/steps/addressbook/func.inc');
|
||||||
|
|
||||||
|
if ($_action=='save')
|
||||||
|
include('program/steps/addressbook/save.inc');
|
||||||
|
|
||||||
|
if ($_action=='edit' || $_action=='add')
|
||||||
|
include('program/steps/addressbook/edit.inc');
|
||||||
|
|
||||||
|
if ($_action=='delete')
|
||||||
|
include('program/steps/addressbook/delete.inc');
|
||||||
|
|
||||||
|
if ($_action=='show')
|
||||||
|
include('program/steps/addressbook/show.inc');
|
||||||
|
|
||||||
|
if ($_action=='list' && $_GET['_remote'])
|
||||||
|
include('program/steps/addressbook/list.inc');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// include task specific files
|
||||||
|
if ($_task=='settings')
|
||||||
|
{
|
||||||
|
include_once('program/steps/settings/func.inc');
|
||||||
|
|
||||||
|
if ($_action=='save-identity')
|
||||||
|
include('program/steps/settings/save_identity.inc');
|
||||||
|
|
||||||
|
if ($_action=='add-identity' || $_action=='edit-identity')
|
||||||
|
include('program/steps/settings/edit_identity.inc');
|
||||||
|
|
||||||
|
if ($_action=='delete-identity')
|
||||||
|
include('program/steps/settings/delete_identity.inc');
|
||||||
|
|
||||||
|
if ($_action=='identities')
|
||||||
|
include('program/steps/settings/identities.inc');
|
||||||
|
|
||||||
|
if ($_action=='save-prefs')
|
||||||
|
include('program/steps/settings/save_prefs.inc');
|
||||||
|
|
||||||
|
if ($_action=='folders' || $_action=='subscribe' || $_action=='unsubscribe' || $_action=='create-folder' || $_action=='delete-folder')
|
||||||
|
include('program/steps/settings/manage_folders.inc');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// parse main template
|
||||||
|
parse_template($_task);
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,2 @@
|
|||||||
|
Order allow,deny
|
||||||
|
Deny from all
|
After Width: | Height: | Size: 56 B |
@ -0,0 +1,104 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/include/bugs.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the BQube Webmail client |
|
||||||
|
| Copyright (C) 2005, BQube Dev - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Provide error handling and logging functions |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// throw system error and show error page
|
||||||
|
function raise_error($arg=array(), $log=FALSE, $terminate=FALSE)
|
||||||
|
{
|
||||||
|
global $__page_content, $CONFIG, $OUTPUT, $ERROR_CODE, $ERROR_MESSAGE;
|
||||||
|
|
||||||
|
/* $arg keys:
|
||||||
|
int code
|
||||||
|
string type (php, xpath, db, imap, javascript)
|
||||||
|
string message
|
||||||
|
sring file
|
||||||
|
int line
|
||||||
|
*/
|
||||||
|
|
||||||
|
// report bug (if not incompatible browser)
|
||||||
|
if ($log && $arg['type'] && $arg['message'])
|
||||||
|
log_bug($arg);
|
||||||
|
|
||||||
|
// display error page and terminate script
|
||||||
|
if ($terminate)
|
||||||
|
{
|
||||||
|
$ERROR_CODE = $arg['code'];
|
||||||
|
$ERROR_MESSAGE = $arg['message'];
|
||||||
|
include("program/steps/error.inc");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// report error
|
||||||
|
function log_bug($arg_arr)
|
||||||
|
{
|
||||||
|
global $CONFIG, $INSTALL_PATH;
|
||||||
|
$program = $arg_arr['type']=='xpath' ? 'XPath' : strtoupper($arg_arr['type']);
|
||||||
|
|
||||||
|
// write error to local log file
|
||||||
|
if ($CONFIG['debug_level'] & 1)
|
||||||
|
{
|
||||||
|
$log_entry = sprintf("[%s] %s Error: %s in %s on line %d\n",
|
||||||
|
date("d-M-Y H:i:s O", mktime()),
|
||||||
|
$program,
|
||||||
|
$arg_arr['message'],
|
||||||
|
$arg_arr['file'],
|
||||||
|
$arg_arr['line']);
|
||||||
|
|
||||||
|
if ($fp = fopen($INSTALL_PATH.'logs/errors', 'a'))
|
||||||
|
{
|
||||||
|
fwrite($fp, $log_entry);
|
||||||
|
fclose($fp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// resport the bug to the global bug reporting system
|
||||||
|
if ($CONFIG['debug_level'] & 2)
|
||||||
|
{
|
||||||
|
$delm = '%AC';
|
||||||
|
http_request(sprintf('http://roundcube.net/log/bug.php?_type=%s&_domain=%s&_server_ip=%s&_client_ip=%s&_useragent=%s&_url=%s%%3A//%s&_errors=%s%s%s%s%s',
|
||||||
|
$arg_arr['type'],
|
||||||
|
$GLOBALS['HTTP_HOST'],
|
||||||
|
$GLOBALS['SERVER_ADDR'],
|
||||||
|
$GLOBALS['REMOTE_ADDR'],
|
||||||
|
rawurlencode($GLOBALS['HTTP_USER_AGENT']),
|
||||||
|
$GLOBALS['SERVER_PORT']==43 ? 'https' : 'http',
|
||||||
|
$GLOBALS['HTTP_HOST'].$GLOBALS['REQUEST_URI'],
|
||||||
|
$arg_arr['file'], $delm,
|
||||||
|
$arg_arr['line'], $delm,
|
||||||
|
rawurlencode($arg_arr['message'])));
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// show error if debug_mode is on
|
||||||
|
if ($CONFIG['debug_level'] & 4)
|
||||||
|
{
|
||||||
|
print "<b>$program Error in $arg_arr[file] ($arg_arr[line]):</b> ";
|
||||||
|
print nl2br($arg_arr['message']);
|
||||||
|
print '<br />';
|
||||||
|
flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,112 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/include/cache.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev, - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Provide access to the application cache |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function rcube_read_cache($key)
|
||||||
|
{
|
||||||
|
global $DB, $CACHE_KEYS;
|
||||||
|
|
||||||
|
// query db
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT cache_id, data
|
||||||
|
FROM %s
|
||||||
|
WHERE user_id=%d
|
||||||
|
AND cache_key='%s'",
|
||||||
|
get_table_name('cache'),
|
||||||
|
$_SESSION['user_id'],
|
||||||
|
$key));
|
||||||
|
|
||||||
|
// get cached data
|
||||||
|
if ($sql_arr = $DB->fetch_assoc($sql_result))
|
||||||
|
{
|
||||||
|
$data = $sql_arr['data'];
|
||||||
|
$CACHE_KEYS[$key] = $sql_arr['cache_id'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$data = FALSE;
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function rcube_write_cache($key, $data, $session_cache=FALSE)
|
||||||
|
{
|
||||||
|
global $DB, $CACHE_KEYS, $sess_id;
|
||||||
|
|
||||||
|
// check if we already have a cache entry for this key
|
||||||
|
if (!isset($CACHE_KEYS[$key]))
|
||||||
|
{
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT cache_id
|
||||||
|
FROM %s
|
||||||
|
WHERE user_id=%d
|
||||||
|
AND cache_key='%s'",
|
||||||
|
get_table_name('cache'),
|
||||||
|
$_SESSION['user_id'],
|
||||||
|
$key));
|
||||||
|
|
||||||
|
if ($sql_arr = $DB->fetch_assoc($sql_result))
|
||||||
|
$CACHE_KEYS[$key] = $sql_arr['cache_id'];
|
||||||
|
else
|
||||||
|
$CACHE_KEYS[$key] = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// update existing cache record
|
||||||
|
if ($CACHE_KEYS[$key])
|
||||||
|
{
|
||||||
|
$DB->query(sprintf("UPDATE %s
|
||||||
|
SET created=NOW(),
|
||||||
|
data='%s'
|
||||||
|
WHERE user_id=%d
|
||||||
|
AND cache_key='%s'",
|
||||||
|
get_table_name('cache'),
|
||||||
|
addslashes($data),
|
||||||
|
$_SESSION['user_id'],
|
||||||
|
$key));
|
||||||
|
}
|
||||||
|
// add new cache record
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$DB->query(sprintf("INSERT INTO %s
|
||||||
|
(created, user_id, session_id, cache_key, data)
|
||||||
|
VALUES (NOW(), %d, %s, '%s', '%s')",
|
||||||
|
get_table_name('cache'),
|
||||||
|
$_SESSION['user_id'],
|
||||||
|
$session_cache ? "'$sess_id'" : 'NULL',
|
||||||
|
$key,
|
||||||
|
addslashes($data)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function rcube_clear_cache($key)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
|
||||||
|
$DB->query(sprintf("DELETE FROM %s
|
||||||
|
WHERE user_id=%d
|
||||||
|
AND cache_key='%s'",
|
||||||
|
get_table_name('cache'),
|
||||||
|
$_SESSION['user_id'],
|
||||||
|
$key));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,186 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/include/rcube_mysql.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| MySQL wrapper class that implements PHP MySQL functions |
|
||||||
|
| See http://www.php.net/manual/en/ref.mysql.php |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class rcube_mysql
|
||||||
|
{
|
||||||
|
var $db_link;
|
||||||
|
var $db_host = 'localhost';
|
||||||
|
var $db_name = '';
|
||||||
|
var $db_user = '';
|
||||||
|
var $db_pass = '';
|
||||||
|
var $a_query_results = array('dummy');
|
||||||
|
var $last_res_id = 0;
|
||||||
|
|
||||||
|
|
||||||
|
// PHP 5 constructor
|
||||||
|
function __construct($db_name='', $user='', $pass='', $host='localhost')
|
||||||
|
{
|
||||||
|
$this->db_host = $host;
|
||||||
|
$this->db_name = $db_name;
|
||||||
|
$this->db_user = $user;
|
||||||
|
$this->db_pass = $pass;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PHP 4 compatibility
|
||||||
|
function rcube_mysql($db_name='', $user='', $pass='', $host='localhost')
|
||||||
|
{
|
||||||
|
$this->__construct($db_name, $user, $pass, $host);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function connect()
|
||||||
|
{
|
||||||
|
$this->db_link = mysql_connect($this->db_host, $this->db_user, $this->db_pass);
|
||||||
|
|
||||||
|
if (!$this->db_link)
|
||||||
|
{
|
||||||
|
raise_error(array('code' => 500,
|
||||||
|
'type' => 'mysql',
|
||||||
|
'line' => __LINE__,
|
||||||
|
'file' => __FILE__,
|
||||||
|
'message' => "Can't connect to database"), TRUE, FALSE);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function select_db($name)
|
||||||
|
{
|
||||||
|
$this->db_name = $name;
|
||||||
|
|
||||||
|
if ($this->db_link)
|
||||||
|
mysql_select_db($name, $this->db_link);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function query($query)
|
||||||
|
{
|
||||||
|
// establish a connection
|
||||||
|
if (!$this->db_link)
|
||||||
|
{
|
||||||
|
if (!$this->connect())
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql_result = mysql_db_query($this->db_name, $query, $this->db_link);
|
||||||
|
return $this->_add_result($sql_result, $query);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function num_rows($res_id=NULL)
|
||||||
|
{
|
||||||
|
if (!$this->db_link)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
$sql_result = $this->_get_result($res_id);
|
||||||
|
|
||||||
|
if ($sql_result)
|
||||||
|
return mysql_num_rows($sql_result);
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function affected_rows()
|
||||||
|
{
|
||||||
|
if (!$this->db_link)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return mysql_affected_rows($this->db_link);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function insert_id()
|
||||||
|
{
|
||||||
|
if (!$this->db_link)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return mysql_insert_id($this->db_link);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function fetch_assoc($res_id=NULL)
|
||||||
|
{
|
||||||
|
$sql_result = $this->_get_result($res_id);
|
||||||
|
|
||||||
|
if ($sql_result)
|
||||||
|
return mysql_fetch_assoc($sql_result);
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function seek($res_id=NULL, $row=0)
|
||||||
|
{
|
||||||
|
$sql_result = $this->_get_result($res_id);
|
||||||
|
|
||||||
|
if ($sql_result)
|
||||||
|
return mysql_data_seek($sql_result, $row);
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function _add_result($res, $query)
|
||||||
|
{
|
||||||
|
// sql error occured
|
||||||
|
if ($res===FALSE)
|
||||||
|
{
|
||||||
|
$sql_error = mysql_error($this->db_link);
|
||||||
|
raise_error(array('code' => 500,
|
||||||
|
'type' => 'mysql',
|
||||||
|
'line' => __LINE__,
|
||||||
|
'file' => __FILE__,
|
||||||
|
'message' => $sql_error."; QUERY: ".preg_replace('/[\r\n]+\s*/', ' ', $query)), TRUE, FALSE);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$res_id = sizeof($this->a_query_results);
|
||||||
|
$this->a_query_results[$res_id] = $res;
|
||||||
|
$this->last_res_id = $res_id;
|
||||||
|
|
||||||
|
return $res_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _get_result($res_id)
|
||||||
|
{
|
||||||
|
if ($res_id===NULL)
|
||||||
|
$res_id = $this->last_res_id;
|
||||||
|
|
||||||
|
if ($res_id && isset($this->a_query_results[$res_id]))
|
||||||
|
return $this->a_query_results[$res_id];
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,154 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/include/session.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev, - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Provide database supported session management |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function sess_open($save_path, $session_name)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function sess_close()
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// read session data
|
||||||
|
function sess_read($key)
|
||||||
|
{
|
||||||
|
global $DB, $SESS_CHANGED;
|
||||||
|
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT vars, UNIX_TIMESTAMP(changed) AS changed
|
||||||
|
FROM %s
|
||||||
|
WHERE sess_id='%s'",
|
||||||
|
get_table_name('session'),
|
||||||
|
$key));
|
||||||
|
|
||||||
|
if ($sql_arr = $DB->fetch_assoc($sql_result))
|
||||||
|
{
|
||||||
|
$SESS_CHANGED = $sql_arr['changed'];
|
||||||
|
|
||||||
|
if (strlen($sql_arr['vars']))
|
||||||
|
return $sql_arr['vars'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// save session data
|
||||||
|
function sess_write($key, $vars)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT 1
|
||||||
|
FROM %s
|
||||||
|
WHERE sess_id='%s'",
|
||||||
|
get_table_name('session'),
|
||||||
|
$key));
|
||||||
|
|
||||||
|
if ($DB->num_rows($sql_result))
|
||||||
|
{
|
||||||
|
session_decode($vars);
|
||||||
|
$DB->query(sprintf("UPDATE %s
|
||||||
|
SET vars='%s',
|
||||||
|
changed=NOW()
|
||||||
|
WHERE sess_id='%s'",
|
||||||
|
get_table_name('session'),
|
||||||
|
$vars,
|
||||||
|
$key));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$DB->query(sprintf("INSERT INTO %s
|
||||||
|
(sess_id, vars, created, changed)
|
||||||
|
VALUES ('%s', '%s', NOW(), NOW())",
|
||||||
|
get_table_name('session'),
|
||||||
|
$key,
|
||||||
|
$vars));
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// handler for session_destroy()
|
||||||
|
function sess_destroy($key)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
|
||||||
|
$DB->query(sprintf("DELETE FROM %s
|
||||||
|
WHERE sess_id='%s'",
|
||||||
|
get_table_name('session'),
|
||||||
|
$key));
|
||||||
|
|
||||||
|
// also delete session entries in cache table
|
||||||
|
$DB->query(sprintf("DELETE FROM %s
|
||||||
|
WHERE session_id='%s'",
|
||||||
|
get_table_name('cache'),
|
||||||
|
$key));
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// garbage collecting function
|
||||||
|
function sess_gc($maxlifetime)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
|
||||||
|
// get all expired sessions
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT sess_id
|
||||||
|
FROM %s
|
||||||
|
WHERE UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(created) > %d",
|
||||||
|
get_table_name('session'),
|
||||||
|
$maxlifetime));
|
||||||
|
|
||||||
|
$a_exp_sessions = array();
|
||||||
|
while ($sql_arr = $DB->fetch_assoc($sql_result))
|
||||||
|
$a_exp_sessions[] = $sql_arr['sess_id'];
|
||||||
|
|
||||||
|
|
||||||
|
if (sizeof($a_exp_sessions))
|
||||||
|
{
|
||||||
|
// delete session records
|
||||||
|
$DB->query(sprintf("DELETE FROM %s
|
||||||
|
WHERE sess_id IN ('%s')",
|
||||||
|
get_table_name('session'),
|
||||||
|
join("','", $a_exp_sessions)));
|
||||||
|
|
||||||
|
// also delete session cache records
|
||||||
|
$DB->query(sprintf("DELETE FROM %s
|
||||||
|
WHERE session_id IN ('%s')",
|
||||||
|
get_table_name('cache'),
|
||||||
|
join("','", $a_exp_sessions)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// set custom functions for PHP session management
|
||||||
|
session_set_save_handler('sess_open', 'sess_close', 'sess_read', 'sess_write', 'sess_destroy', 'sess_gc');
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,343 @@
|
|||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| RoundCube common js library |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube web development suite |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev, - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| Modified: 19.08.2005 (tbr) |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// default browsercheck
|
||||||
|
function roundcube_browser()
|
||||||
|
{
|
||||||
|
this.ver = parseFloat(navigator.appVersion);
|
||||||
|
this.appver = navigator.appVersion;
|
||||||
|
this.agent = navigator.userAgent;
|
||||||
|
this.name = navigator.appName;
|
||||||
|
this.vendor = navigator.vendor ? navigator.vendor : '';
|
||||||
|
this.vendver = navigator.vendorSub ? parseFloat(navigator.vendorSub) : 0;
|
||||||
|
this.product = navigator.product ? navigator.product : '';
|
||||||
|
this.platform = String(navigator.platform).toLowerCase();
|
||||||
|
this.lang = (navigator.language) ? navigator.language.substring(0,2) :
|
||||||
|
(navigator.browserLanguage) ? navigator.browserLanguage.substring(0,2) :
|
||||||
|
(navigator.systemLanguage) ? navigator.systemLanguage.substring(0,2) : 'en';
|
||||||
|
|
||||||
|
this.win = (this.platform.indexOf('win')>=0) ? true : false;
|
||||||
|
this.mac = (this.platform.indexOf('mac')>=0) ? true : false;
|
||||||
|
this.linux = (this.platform.indexOf('linux')>=0) ? true : false;
|
||||||
|
this.unix = (this.platform.indexOf('unix')>=0) ? true : false;
|
||||||
|
|
||||||
|
this.dom = document.getElementById ? true : false;
|
||||||
|
this.dom2 = (document.addEventListener && document.removeEventListener);
|
||||||
|
|
||||||
|
this.ie = (document.all) ? true : false;
|
||||||
|
this.ie4 = (this.ie && !this.dom);
|
||||||
|
this.ie5 = (this.dom && this.appver.indexOf('MSIE 5')>0);
|
||||||
|
this.ie6 = (this.dom && this.appver.indexOf('MSIE 6')>0);
|
||||||
|
|
||||||
|
this.mz = (this.dom && this.ver>=5); // (this.dom && this.product=='Gecko')
|
||||||
|
this.ns = ((this.ver<5 && this.name=='Netscape') || (this.ver>=5 && this.vendor.indexOf('Netscape')>=0));
|
||||||
|
this.ns4 = (this.ns && parseInt(this.ver)==4);
|
||||||
|
this.ns6 = (this.ns && parseInt(this.vendver)==6); // (this.mz && this.ns) ? true : false;
|
||||||
|
this.ns7 = (this.ns && parseInt(this.vendver)==7); // this.agent.indexOf('Netscape/7')>0);
|
||||||
|
this.safari = this.agent.toLowerCase().indexOf('safari')>0;
|
||||||
|
this.konq = (this.agent.toLowerCase().indexOf('konqueror')>0);
|
||||||
|
|
||||||
|
this.opera = (window.opera) ? true : false;
|
||||||
|
this.opera5 = (this.opera5 && this.agent.indexOf('Opera 5')>0) ? true : false;
|
||||||
|
this.opera6 = (this.opera && this.agent.indexOf('Opera 6')>0) ? true : false;
|
||||||
|
this.opera7 = (this.opera && this.agent.indexOf('Opera 7')>0) ? true : false;
|
||||||
|
|
||||||
|
if(this.opera && window.RegExp)
|
||||||
|
this.vendver = (/opera(\s|\/)([0-9\.]+)/i.test(navigator.userAgent)) ? parseFloat(RegExp.$2) : -1;
|
||||||
|
else if(!this.vendver && this.safari)
|
||||||
|
this.vendver = (/safari\/([0-9]+)/i.test(this.agent)) ? parseInt(RegExp.$1) : 0;
|
||||||
|
else if((!this.vendver && this.mz) || this.agent.indexOf('Camino')>0)
|
||||||
|
this.vendver = (/rv:([0-9\.]+)/.test(this.agent)) ? parseFloat(RegExp.$1) : 0;
|
||||||
|
else if(this.ie && window.RegExp)
|
||||||
|
this.vendver = (/msie\s+([0-9\.]+)/i.test(this.agent)) ? parseFloat(RegExp.$1) : 0;
|
||||||
|
|
||||||
|
// get real language out of safari's user agent
|
||||||
|
if(this.safari && (/;\s+([a-z]{2})-[a-z]{2}\)/i.test(this.agent)))
|
||||||
|
this.lang = RegExp.$1;
|
||||||
|
|
||||||
|
this.dhtml = ((this.ie4 && this.win) || this.ie5 || this.ie6 || this.ns4 || this.mz);
|
||||||
|
this.layers = this.ns4; // (document.layers);
|
||||||
|
this.div = (this.ie4 || this.dom);
|
||||||
|
this.vml = (this.win && this.ie && this.dom && !this.opera);
|
||||||
|
this.linkborder = (this.ie || this.mz);
|
||||||
|
this.rollover = (this.ver>=4 || (this.ns && this.ver>=3)); // (document.images) ? true : false;
|
||||||
|
this.pngalpha = (this.mz || (this.opera && this.vendver>=6) || (this.ie && this.mac && this.vendver>=5) ||
|
||||||
|
(this.ie && this.win && this.vendver>=5.5) || this.safari);
|
||||||
|
this.opacity = (this.mz || (this.ie && this.vendver>=5.5 && !this.opera) || (this.safari && this.vendver>=100));
|
||||||
|
this.cookies = navigator.cookieEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var rcube_layer_objects = new Array();
|
||||||
|
|
||||||
|
function rcube_layer(id, attributes)
|
||||||
|
{
|
||||||
|
this.name = id;
|
||||||
|
|
||||||
|
// create a new layer in the current document
|
||||||
|
this.create = function(arg)
|
||||||
|
{
|
||||||
|
var l = (arg.x) ? arg.x : 0;
|
||||||
|
var t = (arg.y) ? arg.y : 0;
|
||||||
|
var w = arg.width;
|
||||||
|
var h = arg.height;
|
||||||
|
var z = arg.zindex;
|
||||||
|
var vis = arg.vis;
|
||||||
|
var parent = arg.parent;
|
||||||
|
var obj;
|
||||||
|
|
||||||
|
obj = document.createElement('DIV');
|
||||||
|
with(obj)
|
||||||
|
{
|
||||||
|
id = this.name;
|
||||||
|
with(style)
|
||||||
|
{
|
||||||
|
position = 'absolute';
|
||||||
|
visibility = (vis) ? (vis==2) ? 'inherit' : 'visible' : 'hidden';
|
||||||
|
left = l+'px';
|
||||||
|
top = t+'px';
|
||||||
|
if(w) width = w+'px';
|
||||||
|
if(h) height = h+'px';
|
||||||
|
if(z) zIndex = z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(parent) parent.appendChild(obj);
|
||||||
|
else document.body.appendChild(obj);
|
||||||
|
|
||||||
|
this.elm = obj;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// create new layer
|
||||||
|
if(attributes!=null)
|
||||||
|
{
|
||||||
|
this.create(attributes);
|
||||||
|
this.name = this.elm.id;
|
||||||
|
}
|
||||||
|
else // just refer to the object
|
||||||
|
this.elm = document.getElementById(id);
|
||||||
|
|
||||||
|
|
||||||
|
if(!this.elm)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
// ********* layer object properties *********
|
||||||
|
|
||||||
|
this.css = this.elm.style;
|
||||||
|
this.event = this.elm;
|
||||||
|
this.width = this.elm.offsetWidth;
|
||||||
|
this.height = this.elm.offsetHeight;
|
||||||
|
this.x = parseInt(this.elm.offsetLeft);
|
||||||
|
this.y = parseInt(this.elm.offsetTop);
|
||||||
|
this.visible = (this.css.visibility=='visible' || this.css.visibility=='show' || this.css.visibility=='inherit') ? true : false;
|
||||||
|
|
||||||
|
this.id = rcube_layer_objects.length;
|
||||||
|
this.obj = 'rcube_layer_objects['+this.id+']';
|
||||||
|
rcube_layer_objects[this.id] = this;
|
||||||
|
|
||||||
|
|
||||||
|
// ********* layer object methods *********
|
||||||
|
|
||||||
|
|
||||||
|
// move the layer to a specific position
|
||||||
|
this.move = function(x, y)
|
||||||
|
{
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.css.left = Math.round(this.x)+'px';
|
||||||
|
this.css.top = Math.round(this.y)+'px';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// move the layer for a specific step
|
||||||
|
this.shift = function(x,y)
|
||||||
|
{
|
||||||
|
x = Math.round(x*100)/100;
|
||||||
|
y = Math.round(y*100)/100;
|
||||||
|
this.move(this.x+x, this.y+y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// change the layers width and height
|
||||||
|
this.resize = function(w,h)
|
||||||
|
{
|
||||||
|
this.css.width = w+'px';
|
||||||
|
this.css.height = h+'px';
|
||||||
|
this.width = w;
|
||||||
|
this.height = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// cut the layer (top,width,height,left)
|
||||||
|
this.clip = function(t,w,h,l)
|
||||||
|
{
|
||||||
|
this.css.clip='rect('+t+' '+w+' '+h+' '+l+')';
|
||||||
|
this.clip_height = h;
|
||||||
|
this.clip_width = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// show or hide the layer
|
||||||
|
this.show = function(a)
|
||||||
|
{
|
||||||
|
if(a==1)
|
||||||
|
{
|
||||||
|
this.css.visibility = 'visible';
|
||||||
|
this.visible = true;
|
||||||
|
}
|
||||||
|
else if(a==2)
|
||||||
|
{
|
||||||
|
this.css.visibility = 'inherit';
|
||||||
|
this.visible = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.css.visibility = 'hidden';
|
||||||
|
this.visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// write new content into a Layer
|
||||||
|
this.write = function(cont)
|
||||||
|
{
|
||||||
|
this.elm.innerHTML = cont;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// set the given color to the layer background
|
||||||
|
this.set_bgcolor = function(c)
|
||||||
|
{
|
||||||
|
if(!c || c=='#')
|
||||||
|
c = 'transparent';
|
||||||
|
|
||||||
|
this.css.backgroundColor = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// set the opacity of a layer to the given ammount (in %)
|
||||||
|
this.set_opacity = function(v)
|
||||||
|
{
|
||||||
|
if(!bw.opacity)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var op = v<=1 ? Math.round(v*100) : parseInt(v);
|
||||||
|
|
||||||
|
if(bw.ie)
|
||||||
|
this.css.filter = 'alpha(opacity:'+op+')';
|
||||||
|
else if(bw.safari)
|
||||||
|
{
|
||||||
|
this.css.opacity = op/100;
|
||||||
|
this.css.KhtmlOpacity = op/100;
|
||||||
|
}
|
||||||
|
else if(bw.mz)
|
||||||
|
this.css.MozOpacity = op/100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// find a value in a specific array and returns the index
|
||||||
|
function find_in_array()
|
||||||
|
{
|
||||||
|
var args = find_in_array.arguments;
|
||||||
|
if(!args.length) return -1;
|
||||||
|
|
||||||
|
var haystack = typeof(args[0])=='object' ? args[0] : args.length>1 && typeof(args[1])=='object' ? args[1] : new Array();
|
||||||
|
var needle = typeof(args[0])!='object' ? args[0] : args.length>1 && typeof(args[1])!='object' ? args[1] : '';
|
||||||
|
var nocase = args.length==3 ? args[2] : false;
|
||||||
|
|
||||||
|
if(!haystack.length) return -1;
|
||||||
|
|
||||||
|
for(var i=0; i<haystack.length; i++)
|
||||||
|
if(nocase && haystack[i].toLowerCase()==needle.toLowerCase())
|
||||||
|
return i;
|
||||||
|
else if(haystack[i]==needle)
|
||||||
|
return i;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// get any type of html objects by id/name
|
||||||
|
function rcube_find_object(id, d)
|
||||||
|
{
|
||||||
|
var n, f, obj, e;
|
||||||
|
if(!d) d = document;
|
||||||
|
|
||||||
|
if(d.getElementsByName && (e = d.getElementsByName(id)))
|
||||||
|
obj = e[0];
|
||||||
|
if(!obj && d.getElementById)
|
||||||
|
obj = d.getElementById(id);
|
||||||
|
if(!obj && d.all)
|
||||||
|
obj = d.all[id];
|
||||||
|
|
||||||
|
if(!obj && d.images.length)
|
||||||
|
obj = d.images[id];
|
||||||
|
|
||||||
|
if(!obj && d.forms.length)
|
||||||
|
for(f=0; f<d.forms.length; f++)
|
||||||
|
{
|
||||||
|
if(d.forms[f].name == id)
|
||||||
|
obj = d.forms[f];
|
||||||
|
else if(d.forms[f].elements[id])
|
||||||
|
obj = d.forms[f].elements[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!obj && d.layers)
|
||||||
|
{
|
||||||
|
if(d.layers[id]) obj = d.layers[id];
|
||||||
|
for(n=0; !obj && n<d.layers.length; n++)
|
||||||
|
obj = nex_get_object(id, d.layers[n].document);
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// return the absolute position of an object within the document
|
||||||
|
function rcube_get_object_pos(obj)
|
||||||
|
{
|
||||||
|
if(typeof(obj)=='string')
|
||||||
|
obj = nex_get_object(obj);
|
||||||
|
|
||||||
|
if(!obj) return {x:0, y:0};
|
||||||
|
|
||||||
|
var iX = (bw.layers) ? obj.x : obj.offsetLeft;
|
||||||
|
var iY = (bw.layers) ? obj.y : obj.offsetTop;
|
||||||
|
|
||||||
|
if(bw.ie || bw.mz)
|
||||||
|
{
|
||||||
|
var elm = obj.offsetParent;
|
||||||
|
while(elm && elm!=null)
|
||||||
|
{
|
||||||
|
iX += elm.offsetLeft;
|
||||||
|
iY += elm.offsetTop;
|
||||||
|
elm = elm.offsetParent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(bw.mac && bw.ie5) iX += document.body.leftMargin;
|
||||||
|
if(bw.mac && bw.ie5) iY += document.body.topMargin;
|
||||||
|
|
||||||
|
return {x:iX, y:iY};
|
||||||
|
}
|
||||||
|
|
||||||
|
var bw = new roundcube_browser();
|
@ -0,0 +1,733 @@
|
|||||||
|
<?php
|
||||||
|
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright (c) 2002-2003 Richard Heyes |
|
||||||
|
// | Copyright (c) 2003-2005 The PHP Group |
|
||||||
|
// | All rights reserved. |
|
||||||
|
// | |
|
||||||
|
// | Redistribution and use in source and binary forms, with or without |
|
||||||
|
// | modification, are permitted provided that the following conditions |
|
||||||
|
// | are met: |
|
||||||
|
// | |
|
||||||
|
// | o Redistributions of source code must retain the above copyright |
|
||||||
|
// | notice, this list of conditions and the following disclaimer. |
|
||||||
|
// | o Redistributions in binary form must reproduce the above copyright |
|
||||||
|
// | notice, this list of conditions and the following disclaimer in the |
|
||||||
|
// | documentation and/or other materials provided with the distribution.|
|
||||||
|
// | o The names of the authors may not be used to endorse or promote |
|
||||||
|
// | products derived from this software without specific prior written |
|
||||||
|
// | permission. |
|
||||||
|
// | |
|
||||||
|
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
|
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||||
|
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
||||||
|
// | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
||||||
|
// | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
||||||
|
// | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
||||||
|
// | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
||||||
|
// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
||||||
|
// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
||||||
|
// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
||||||
|
// | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
|
// | |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Author: Richard Heyes <richard@phpguru.org> |
|
||||||
|
// | Tomas V.V.Cox <cox@idecnet.com> (port to PEAR) |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
//
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
require_once('PEAR.php');
|
||||||
|
require_once('Mail/mimePart.php');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mime mail composer class. Can handle: text and html bodies, embedded html
|
||||||
|
* images and attachments.
|
||||||
|
* Documentation and examples of this class are avaible here:
|
||||||
|
* http://pear.php.net/manual/
|
||||||
|
*
|
||||||
|
* @notes This class is based on HTML Mime Mail class from
|
||||||
|
* Richard Heyes <richard@phpguru.org> which was based also
|
||||||
|
* in the mime_mail.class by Tobias Ratschiller <tobias@dnet.it> and
|
||||||
|
* Sascha Schumann <sascha@schumann.cx>
|
||||||
|
*
|
||||||
|
* Function _encodeHeaders() changed by Thomas Bruederli <roundcube@gmail.com>
|
||||||
|
* in order to be read correctly by Google Gmail
|
||||||
|
*
|
||||||
|
* @author Richard Heyes <richard.heyes@heyes-computing.net>
|
||||||
|
* @author Tomas V.V.Cox <cox@idecnet.com>
|
||||||
|
* @package Mail
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
class Mail_mime
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Contains the plain text part of the email
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
var $_txtbody;
|
||||||
|
/**
|
||||||
|
* Contains the html part of the email
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
var $_htmlbody;
|
||||||
|
/**
|
||||||
|
* contains the mime encoded text
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
var $_mime;
|
||||||
|
/**
|
||||||
|
* contains the multipart content
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
var $_multipart;
|
||||||
|
/**
|
||||||
|
* list of the attached images
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
var $_html_images = array();
|
||||||
|
/**
|
||||||
|
* list of the attachements
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
var $_parts = array();
|
||||||
|
/**
|
||||||
|
* Build parameters
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
var $_build_params = array();
|
||||||
|
/**
|
||||||
|
* Headers for the mail
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
var $_headers = array();
|
||||||
|
/**
|
||||||
|
* End Of Line sequence (for serialize)
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
var $_eol;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor function
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function Mail_mime($crlf = "\r\n")
|
||||||
|
{
|
||||||
|
$this->_setEOL($crlf);
|
||||||
|
$this->_build_params = array(
|
||||||
|
'text_encoding' => '7bit',
|
||||||
|
'html_encoding' => 'quoted-printable',
|
||||||
|
'7bit_wrap' => 998,
|
||||||
|
'html_charset' => 'ISO-8859-1',
|
||||||
|
'text_charset' => 'ISO-8859-1',
|
||||||
|
'head_charset' => 'ISO-8859-1'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wakeup (unserialize) - re-sets EOL constant
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function __wakeup()
|
||||||
|
{
|
||||||
|
$this->_setEOL($this->_eol);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accessor function to set the body text. Body text is used if
|
||||||
|
* it's not an html mail being sent or else is used to fill the
|
||||||
|
* text/plain part that emails clients who don't support
|
||||||
|
* html should show.
|
||||||
|
*
|
||||||
|
* @param string $data Either a string or
|
||||||
|
* the file name with the contents
|
||||||
|
* @param bool $isfile If true the first param should be treated
|
||||||
|
* as a file name, else as a string (default)
|
||||||
|
* @param bool $append If true the text or file is appended to
|
||||||
|
* the existing body, else the old body is
|
||||||
|
* overwritten
|
||||||
|
* @return mixed true on success or PEAR_Error object
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function setTXTBody($data, $isfile = false, $append = false)
|
||||||
|
{
|
||||||
|
if (!$isfile) {
|
||||||
|
if (!$append) {
|
||||||
|
$this->_txtbody = $data;
|
||||||
|
} else {
|
||||||
|
$this->_txtbody .= $data;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$cont = $this->_file2str($data);
|
||||||
|
if (PEAR::isError($cont)) {
|
||||||
|
return $cont;
|
||||||
|
}
|
||||||
|
if (!$append) {
|
||||||
|
$this->_txtbody = $cont;
|
||||||
|
} else {
|
||||||
|
$this->_txtbody .= $cont;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a html part to the mail
|
||||||
|
*
|
||||||
|
* @param string $data Either a string or the file name with the
|
||||||
|
* contents
|
||||||
|
* @param bool $isfile If true the first param should be treated
|
||||||
|
* as a file name, else as a string (default)
|
||||||
|
* @return mixed true on success or PEAR_Error object
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function setHTMLBody($data, $isfile = false)
|
||||||
|
{
|
||||||
|
if (!$isfile) {
|
||||||
|
$this->_htmlbody = $data;
|
||||||
|
} else {
|
||||||
|
$cont = $this->_file2str($data);
|
||||||
|
if (PEAR::isError($cont)) {
|
||||||
|
return $cont;
|
||||||
|
}
|
||||||
|
$this->_htmlbody = $cont;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an image to the list of embedded images.
|
||||||
|
*
|
||||||
|
* @param string $file The image file name OR image data itself
|
||||||
|
* @param string $c_type The content type
|
||||||
|
* @param string $name The filename of the image.
|
||||||
|
* Only use if $file is the image data
|
||||||
|
* @param bool $isfilename Whether $file is a filename or not
|
||||||
|
* Defaults to true
|
||||||
|
* @return mixed true on success or PEAR_Error object
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function addHTMLImage($file, $c_type='application/octet-stream',
|
||||||
|
$name = '', $isfilename = true)
|
||||||
|
{
|
||||||
|
$filedata = ($isfilename === true) ? $this->_file2str($file)
|
||||||
|
: $file;
|
||||||
|
if ($isfilename === true) {
|
||||||
|
$filename = ($name == '' ? basename($file) : basename($name));
|
||||||
|
} else {
|
||||||
|
$filename = basename($name);
|
||||||
|
}
|
||||||
|
if (PEAR::isError($filedata)) {
|
||||||
|
return $filedata;
|
||||||
|
}
|
||||||
|
$this->_html_images[] = array(
|
||||||
|
'body' => $filedata,
|
||||||
|
'name' => $filename,
|
||||||
|
'c_type' => $c_type,
|
||||||
|
'cid' => md5(uniqid(time()))
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a file to the list of attachments.
|
||||||
|
*
|
||||||
|
* @param string $file The file name of the file to attach
|
||||||
|
* OR the file data itself
|
||||||
|
* @param string $c_type The content type
|
||||||
|
* @param string $name The filename of the attachment
|
||||||
|
* Only use if $file is the file data
|
||||||
|
* @param bool $isFilename Whether $file is a filename or not
|
||||||
|
* Defaults to true
|
||||||
|
* @return mixed true on success or PEAR_Error object
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function addAttachment($file, $c_type = 'application/octet-stream',
|
||||||
|
$name = '', $isfilename = true,
|
||||||
|
$encoding = 'base64')
|
||||||
|
{
|
||||||
|
$filedata = ($isfilename === true) ? $this->_file2str($file)
|
||||||
|
: $file;
|
||||||
|
if ($isfilename === true) {
|
||||||
|
// Force the name the user supplied, otherwise use $file
|
||||||
|
$filename = (!empty($name)) ? $name : $file;
|
||||||
|
} else {
|
||||||
|
$filename = $name;
|
||||||
|
}
|
||||||
|
if (empty($filename)) {
|
||||||
|
return PEAR::raiseError(
|
||||||
|
'The supplied filename for the attachment can\'t be empty'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$filename = basename($filename);
|
||||||
|
if (PEAR::isError($filedata)) {
|
||||||
|
return $filedata;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_parts[] = array(
|
||||||
|
'body' => $filedata,
|
||||||
|
'name' => $filename,
|
||||||
|
'c_type' => $c_type,
|
||||||
|
'encoding' => $encoding
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the contents of the given file name as string
|
||||||
|
*
|
||||||
|
* @param string $file_name path of file to process
|
||||||
|
* @return string contents of $file_name
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function &_file2str($file_name)
|
||||||
|
{
|
||||||
|
if (!is_readable($file_name)) {
|
||||||
|
return PEAR::raiseError('File is not readable ' . $file_name);
|
||||||
|
}
|
||||||
|
if (!$fd = fopen($file_name, 'rb')) {
|
||||||
|
return PEAR::raiseError('Could not open ' . $file_name);
|
||||||
|
}
|
||||||
|
$cont = fread($fd, filesize($file_name));
|
||||||
|
fclose($fd);
|
||||||
|
return $cont;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a text subpart to the mimePart object and
|
||||||
|
* returns it during the build process.
|
||||||
|
*
|
||||||
|
* @param mixed The object to add the part to, or
|
||||||
|
* null if a new object is to be created.
|
||||||
|
* @param string The text to add.
|
||||||
|
* @return object The text mimePart object
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function &_addTextPart(&$obj, $text)
|
||||||
|
{
|
||||||
|
$params['content_type'] = 'text/plain';
|
||||||
|
$params['encoding'] = $this->_build_params['text_encoding'];
|
||||||
|
$params['charset'] = $this->_build_params['text_charset'];
|
||||||
|
if (is_object($obj)) {
|
||||||
|
return $obj->addSubpart($text, $params);
|
||||||
|
} else {
|
||||||
|
return new Mail_mimePart($text, $params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a html subpart to the mimePart object and
|
||||||
|
* returns it during the build process.
|
||||||
|
*
|
||||||
|
* @param mixed The object to add the part to, or
|
||||||
|
* null if a new object is to be created.
|
||||||
|
* @return object The html mimePart object
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function &_addHtmlPart(&$obj)
|
||||||
|
{
|
||||||
|
$params['content_type'] = 'text/html';
|
||||||
|
$params['encoding'] = $this->_build_params['html_encoding'];
|
||||||
|
$params['charset'] = $this->_build_params['html_charset'];
|
||||||
|
if (is_object($obj)) {
|
||||||
|
return $obj->addSubpart($this->_htmlbody, $params);
|
||||||
|
} else {
|
||||||
|
return new Mail_mimePart($this->_htmlbody, $params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new mimePart object, using multipart/mixed as
|
||||||
|
* the initial content-type and returns it during the
|
||||||
|
* build process.
|
||||||
|
*
|
||||||
|
* @return object The multipart/mixed mimePart object
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function &_addMixedPart()
|
||||||
|
{
|
||||||
|
$params['content_type'] = 'multipart/mixed';
|
||||||
|
return new Mail_mimePart('', $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a multipart/alternative part to a mimePart
|
||||||
|
* object (or creates one), and returns it during
|
||||||
|
* the build process.
|
||||||
|
*
|
||||||
|
* @param mixed The object to add the part to, or
|
||||||
|
* null if a new object is to be created.
|
||||||
|
* @return object The multipart/mixed mimePart object
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function &_addAlternativePart(&$obj)
|
||||||
|
{
|
||||||
|
$params['content_type'] = 'multipart/alternative';
|
||||||
|
if (is_object($obj)) {
|
||||||
|
return $obj->addSubpart('', $params);
|
||||||
|
} else {
|
||||||
|
return new Mail_mimePart('', $params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a multipart/related part to a mimePart
|
||||||
|
* object (or creates one), and returns it during
|
||||||
|
* the build process.
|
||||||
|
*
|
||||||
|
* @param mixed The object to add the part to, or
|
||||||
|
* null if a new object is to be created
|
||||||
|
* @return object The multipart/mixed mimePart object
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function &_addRelatedPart(&$obj)
|
||||||
|
{
|
||||||
|
$params['content_type'] = 'multipart/related';
|
||||||
|
if (is_object($obj)) {
|
||||||
|
return $obj->addSubpart('', $params);
|
||||||
|
} else {
|
||||||
|
return new Mail_mimePart('', $params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an html image subpart to a mimePart object
|
||||||
|
* and returns it during the build process.
|
||||||
|
*
|
||||||
|
* @param object The mimePart to add the image to
|
||||||
|
* @param array The image information
|
||||||
|
* @return object The image mimePart object
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function &_addHtmlImagePart(&$obj, $value)
|
||||||
|
{
|
||||||
|
$params['content_type'] = $value['c_type'];
|
||||||
|
$params['encoding'] = 'base64';
|
||||||
|
$params['disposition'] = 'inline';
|
||||||
|
$params['dfilename'] = $value['name'];
|
||||||
|
$params['cid'] = $value['cid'];
|
||||||
|
$obj->addSubpart($value['body'], $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an attachment subpart to a mimePart object
|
||||||
|
* and returns it during the build process.
|
||||||
|
*
|
||||||
|
* @param object The mimePart to add the image to
|
||||||
|
* @param array The attachment information
|
||||||
|
* @return object The image mimePart object
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function &_addAttachmentPart(&$obj, $value)
|
||||||
|
{
|
||||||
|
$params['content_type'] = $value['c_type'];
|
||||||
|
$params['encoding'] = $value['encoding'];
|
||||||
|
$params['disposition'] = 'attachment';
|
||||||
|
$params['dfilename'] = $value['name'];
|
||||||
|
$obj->addSubpart($value['body'], $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the multipart message from the list ($this->_parts) and
|
||||||
|
* returns the mime content.
|
||||||
|
*
|
||||||
|
* @param array Build parameters that change the way the email
|
||||||
|
* is built. Should be associative. Can contain:
|
||||||
|
* text_encoding - What encoding to use for plain text
|
||||||
|
* Default is 7bit
|
||||||
|
* html_encoding - What encoding to use for html
|
||||||
|
* Default is quoted-printable
|
||||||
|
* 7bit_wrap - Number of characters before text is
|
||||||
|
* wrapped in 7bit encoding
|
||||||
|
* Default is 998
|
||||||
|
* html_charset - The character set to use for html.
|
||||||
|
* Default is iso-8859-1
|
||||||
|
* text_charset - The character set to use for text.
|
||||||
|
* Default is iso-8859-1
|
||||||
|
* head_charset - The character set to use for headers.
|
||||||
|
* Default is iso-8859-1
|
||||||
|
* @return string The mime content
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function &get($build_params = null)
|
||||||
|
{
|
||||||
|
if (isset($build_params)) {
|
||||||
|
while (list($key, $value) = each($build_params)) {
|
||||||
|
$this->_build_params[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($this->_html_images) AND isset($this->_htmlbody)) {
|
||||||
|
foreach ($this->_html_images as $value) {
|
||||||
|
$regex = '#src\s*=\s*(["\']?)' . preg_quote($value['name']) .
|
||||||
|
'(["\'])?#';
|
||||||
|
$rep = 'src=\1cid:' . $value['cid'] .'\2';
|
||||||
|
$this->_htmlbody = preg_replace($regex, $rep,
|
||||||
|
$this->_htmlbody
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$null = null;
|
||||||
|
$attachments = !empty($this->_parts) ? true : false;
|
||||||
|
$html_images = !empty($this->_html_images) ? true : false;
|
||||||
|
$html = !empty($this->_htmlbody) ? true : false;
|
||||||
|
$text = (!$html AND !empty($this->_txtbody)) ? true : false;
|
||||||
|
|
||||||
|
switch (true) {
|
||||||
|
case $text AND !$attachments:
|
||||||
|
$message =& $this->_addTextPart($null, $this->_txtbody);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case !$text AND !$html AND $attachments:
|
||||||
|
$message =& $this->_addMixedPart();
|
||||||
|
for ($i = 0; $i < count($this->_parts); $i++) {
|
||||||
|
$this->_addAttachmentPart($message, $this->_parts[$i]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case $text AND $attachments:
|
||||||
|
$message =& $this->_addMixedPart();
|
||||||
|
$this->_addTextPart($message, $this->_txtbody);
|
||||||
|
for ($i = 0; $i < count($this->_parts); $i++) {
|
||||||
|
$this->_addAttachmentPart($message, $this->_parts[$i]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case $html AND !$attachments AND !$html_images:
|
||||||
|
if (isset($this->_txtbody)) {
|
||||||
|
$message =& $this->_addAlternativePart($null);
|
||||||
|
$this->_addTextPart($message, $this->_txtbody);
|
||||||
|
$this->_addHtmlPart($message);
|
||||||
|
} else {
|
||||||
|
$message =& $this->_addHtmlPart($null);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case $html AND !$attachments AND $html_images:
|
||||||
|
if (isset($this->_txtbody)) {
|
||||||
|
$message =& $this->_addAlternativePart($null);
|
||||||
|
$this->_addTextPart($message, $this->_txtbody);
|
||||||
|
$related =& $this->_addRelatedPart($message);
|
||||||
|
} else {
|
||||||
|
$message =& $this->_addRelatedPart($null);
|
||||||
|
$related =& $message;
|
||||||
|
}
|
||||||
|
$this->_addHtmlPart($related);
|
||||||
|
for ($i = 0; $i < count($this->_html_images); $i++) {
|
||||||
|
$this->_addHtmlImagePart($related, $this->_html_images[$i]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case $html AND $attachments AND !$html_images:
|
||||||
|
$message =& $this->_addMixedPart();
|
||||||
|
if (isset($this->_txtbody)) {
|
||||||
|
$alt =& $this->_addAlternativePart($message);
|
||||||
|
$this->_addTextPart($alt, $this->_txtbody);
|
||||||
|
$this->_addHtmlPart($alt);
|
||||||
|
} else {
|
||||||
|
$this->_addHtmlPart($message);
|
||||||
|
}
|
||||||
|
for ($i = 0; $i < count($this->_parts); $i++) {
|
||||||
|
$this->_addAttachmentPart($message, $this->_parts[$i]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case $html AND $attachments AND $html_images:
|
||||||
|
$message =& $this->_addMixedPart();
|
||||||
|
if (isset($this->_txtbody)) {
|
||||||
|
$alt =& $this->_addAlternativePart($message);
|
||||||
|
$this->_addTextPart($alt, $this->_txtbody);
|
||||||
|
$rel =& $this->_addRelatedPart($alt);
|
||||||
|
} else {
|
||||||
|
$rel =& $this->_addRelatedPart($message);
|
||||||
|
}
|
||||||
|
$this->_addHtmlPart($rel);
|
||||||
|
for ($i = 0; $i < count($this->_html_images); $i++) {
|
||||||
|
$this->_addHtmlImagePart($rel, $this->_html_images[$i]);
|
||||||
|
}
|
||||||
|
for ($i = 0; $i < count($this->_parts); $i++) {
|
||||||
|
$this->_addAttachmentPart($message, $this->_parts[$i]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($message)) {
|
||||||
|
$output = $message->encode();
|
||||||
|
$this->_headers = array_merge($this->_headers,
|
||||||
|
$output['headers']);
|
||||||
|
return $output['body'];
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array with the headers needed to prepend to the email
|
||||||
|
* (MIME-Version and Content-Type). Format of argument is:
|
||||||
|
* $array['header-name'] = 'header-value';
|
||||||
|
*
|
||||||
|
* @param array $xtra_headers Assoc array with any extra headers.
|
||||||
|
* Optional.
|
||||||
|
* @return array Assoc array with the mime headers
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function &headers($xtra_headers = null)
|
||||||
|
{
|
||||||
|
// Content-Type header should already be present,
|
||||||
|
// So just add mime version header
|
||||||
|
$headers['MIME-Version'] = '1.0';
|
||||||
|
if (isset($xtra_headers)) {
|
||||||
|
$headers = array_merge($headers, $xtra_headers);
|
||||||
|
}
|
||||||
|
$this->_headers = array_merge($headers, $this->_headers);
|
||||||
|
|
||||||
|
return $this->_encodeHeaders($this->_headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the text version of the headers
|
||||||
|
* (usefull if you want to use the PHP mail() function)
|
||||||
|
*
|
||||||
|
* @param array $xtra_headers Assoc array with any extra headers.
|
||||||
|
* Optional.
|
||||||
|
* @return string Plain text headers
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function txtHeaders($xtra_headers = null)
|
||||||
|
{
|
||||||
|
$headers = $this->headers($xtra_headers);
|
||||||
|
$ret = '';
|
||||||
|
foreach ($headers as $key => $val) {
|
||||||
|
$ret .= "$key: $val" . MAIL_MIME_CRLF;
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the Subject header
|
||||||
|
*
|
||||||
|
* @param string $subject String to set the subject to
|
||||||
|
* access public
|
||||||
|
*/
|
||||||
|
function setSubject($subject)
|
||||||
|
{
|
||||||
|
$this->_headers['Subject'] = $subject;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set an email to the From (the sender) header
|
||||||
|
*
|
||||||
|
* @param string $email The email direction to add
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function setFrom($email)
|
||||||
|
{
|
||||||
|
$this->_headers['From'] = $email;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an email to the Cc (carbon copy) header
|
||||||
|
* (multiple calls to this method are allowed)
|
||||||
|
*
|
||||||
|
* @param string $email The email direction to add
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function addCc($email)
|
||||||
|
{
|
||||||
|
if (isset($this->_headers['Cc'])) {
|
||||||
|
$this->_headers['Cc'] .= ", $email";
|
||||||
|
} else {
|
||||||
|
$this->_headers['Cc'] = $email;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an email to the Bcc (blank carbon copy) header
|
||||||
|
* (multiple calls to this method are allowed)
|
||||||
|
*
|
||||||
|
* @param string $email The email direction to add
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function addBcc($email)
|
||||||
|
{
|
||||||
|
if (isset($this->_headers['Bcc'])) {
|
||||||
|
$this->_headers['Bcc'] .= ", $email";
|
||||||
|
} else {
|
||||||
|
$this->_headers['Bcc'] = $email;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes a header as per RFC2047
|
||||||
|
*
|
||||||
|
* @param string $input The header data to encode
|
||||||
|
* @return string Encoded data
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _encodeHeaders($input)
|
||||||
|
{
|
||||||
|
$enc_prefix = '=?' . $this->_build_params['head_charset'] . '?Q?';
|
||||||
|
foreach ($input as $hdr_name => $hdr_value) {
|
||||||
|
if (preg_match('/(\w*[\x80-\xFF]+\w*)/', $hdr_value)) {
|
||||||
|
$enc_value = preg_replace('/([\x80-\xFF])/e', '"=".strtoupper(dechex(ord("\1")))', $hdr_value);
|
||||||
|
// check for <email address> in string
|
||||||
|
if (preg_match('/<[a-z0-9\-\.\+\_]+@[a-z0-9]([a-z0-9\-].?)*[a-z0-9]\\.[a-z]{2,5}>/i', $enc_value) && ($p = strrpos($enc_value, '<'))) {
|
||||||
|
$hdr_value = $enc_prefix . substr($enc_value, 0, $p-1) . '?= ' . substr($enc_value, $p, strlen($enc_value)-$p);
|
||||||
|
} else {
|
||||||
|
$hdr_value = $enc_prefix . $enc_value . '?=';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$input[$hdr_name] = $hdr_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $input;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* replaced 2005/07/08 by roundcube@gmail.com
|
||||||
|
|
||||||
|
function _encodeHeaders_old($input)
|
||||||
|
{
|
||||||
|
foreach ($input as $hdr_name => $hdr_value) {
|
||||||
|
preg_match_all('/(\w*[\x80-\xFF]+\w*)/', $hdr_value, $matches);
|
||||||
|
foreach ($matches[1] as $value) {
|
||||||
|
$replacement = preg_replace('/([\x80-\xFF])/e',
|
||||||
|
'"=" .
|
||||||
|
strtoupper(dechex(ord("\1")))',
|
||||||
|
$value);
|
||||||
|
$hdr_value = str_replace($value, '=?' .
|
||||||
|
$this->_build_params['head_charset'] .
|
||||||
|
'?Q?' . $replacement . '?=',
|
||||||
|
$hdr_value);
|
||||||
|
}
|
||||||
|
$input[$hdr_name] = $hdr_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $input;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the object's end-of-line and define the constant if applicable
|
||||||
|
*
|
||||||
|
* @param string $eol End Of Line sequence
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _setEOL($eol)
|
||||||
|
{
|
||||||
|
$this->_eol = $eol;
|
||||||
|
if (!defined('MAIL_MIME_CRLF')) {
|
||||||
|
define('MAIL_MIME_CRLF', $this->_eol, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // End of class
|
||||||
|
?>
|
@ -0,0 +1,351 @@
|
|||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright (c) 2002-2003 Richard Heyes |
|
||||||
|
// | All rights reserved. |
|
||||||
|
// | |
|
||||||
|
// | Redistribution and use in source and binary forms, with or without |
|
||||||
|
// | modification, are permitted provided that the following conditions |
|
||||||
|
// | are met: |
|
||||||
|
// | |
|
||||||
|
// | o Redistributions of source code must retain the above copyright |
|
||||||
|
// | notice, this list of conditions and the following disclaimer. |
|
||||||
|
// | o Redistributions in binary form must reproduce the above copyright |
|
||||||
|
// | notice, this list of conditions and the following disclaimer in the |
|
||||||
|
// | documentation and/or other materials provided with the distribution.|
|
||||||
|
// | o The names of the authors may not be used to endorse or promote |
|
||||||
|
// | products derived from this software without specific prior written |
|
||||||
|
// | permission. |
|
||||||
|
// | |
|
||||||
|
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
|
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||||
|
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
||||||
|
// | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
||||||
|
// | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
||||||
|
// | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
||||||
|
// | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
||||||
|
// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
||||||
|
// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
||||||
|
// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
||||||
|
// | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
|
// | |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Author: Richard Heyes <richard@phpguru.org> |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Raw mime encoding class
|
||||||
|
*
|
||||||
|
* What is it?
|
||||||
|
* This class enables you to manipulate and build
|
||||||
|
* a mime email from the ground up.
|
||||||
|
*
|
||||||
|
* Why use this instead of mime.php?
|
||||||
|
* mime.php is a userfriendly api to this class for
|
||||||
|
* people who aren't interested in the internals of
|
||||||
|
* mime mail. This class however allows full control
|
||||||
|
* over the email.
|
||||||
|
*
|
||||||
|
* Eg.
|
||||||
|
*
|
||||||
|
* // Since multipart/mixed has no real body, (the body is
|
||||||
|
* // the subpart), we set the body argument to blank.
|
||||||
|
*
|
||||||
|
* $params['content_type'] = 'multipart/mixed';
|
||||||
|
* $email = new Mail_mimePart('', $params);
|
||||||
|
*
|
||||||
|
* // Here we add a text part to the multipart we have
|
||||||
|
* // already. Assume $body contains plain text.
|
||||||
|
*
|
||||||
|
* $params['content_type'] = 'text/plain';
|
||||||
|
* $params['encoding'] = '7bit';
|
||||||
|
* $text = $email->addSubPart($body, $params);
|
||||||
|
*
|
||||||
|
* // Now add an attachment. Assume $attach is
|
||||||
|
* the contents of the attachment
|
||||||
|
*
|
||||||
|
* $params['content_type'] = 'application/zip';
|
||||||
|
* $params['encoding'] = 'base64';
|
||||||
|
* $params['disposition'] = 'attachment';
|
||||||
|
* $params['dfilename'] = 'example.zip';
|
||||||
|
* $attach =& $email->addSubPart($body, $params);
|
||||||
|
*
|
||||||
|
* // Now build the email. Note that the encode
|
||||||
|
* // function returns an associative array containing two
|
||||||
|
* // elements, body and headers. You will need to add extra
|
||||||
|
* // headers, (eg. Mime-Version) before sending.
|
||||||
|
*
|
||||||
|
* $email = $message->encode();
|
||||||
|
* $email['headers'][] = 'Mime-Version: 1.0';
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Further examples are available at http://www.phpguru.org
|
||||||
|
*
|
||||||
|
* TODO:
|
||||||
|
* - Set encode() to return the $obj->encoded if encode()
|
||||||
|
* has already been run. Unless a flag is passed to specifically
|
||||||
|
* re-build the message.
|
||||||
|
*
|
||||||
|
* @author Richard Heyes <richard@phpguru.org>
|
||||||
|
* @version $Revision$
|
||||||
|
* @package Mail
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Mail_mimePart {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The encoding type of this part
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
var $_encoding;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An array of subparts
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
var $_subparts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The output of this part after being built
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
var $_encoded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Headers for this part
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
var $_headers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The body of this part (not encoded)
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
var $_body;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* Sets up the object.
|
||||||
|
*
|
||||||
|
* @param $body - The body of the mime part if any.
|
||||||
|
* @param $params - An associative array of parameters:
|
||||||
|
* content_type - The content type for this part eg multipart/mixed
|
||||||
|
* encoding - The encoding to use, 7bit, 8bit, base64, or quoted-printable
|
||||||
|
* cid - Content ID to apply
|
||||||
|
* disposition - Content disposition, inline or attachment
|
||||||
|
* dfilename - Optional filename parameter for content disposition
|
||||||
|
* description - Content description
|
||||||
|
* charset - Character set to use
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function Mail_mimePart($body = '', $params = array())
|
||||||
|
{
|
||||||
|
if (!defined('MAIL_MIMEPART_CRLF')) {
|
||||||
|
define('MAIL_MIMEPART_CRLF', defined('MAIL_MIME_CRLF') ? MAIL_MIME_CRLF : "\r\n", TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($params as $key => $value) {
|
||||||
|
switch ($key) {
|
||||||
|
case 'content_type':
|
||||||
|
$headers['Content-Type'] = $value . (isset($charset) ? '; charset="' . $charset . '"' : '');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'encoding':
|
||||||
|
$this->_encoding = $value;
|
||||||
|
$headers['Content-Transfer-Encoding'] = $value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'cid':
|
||||||
|
$headers['Content-ID'] = '<' . $value . '>';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'disposition':
|
||||||
|
$headers['Content-Disposition'] = $value . (isset($dfilename) ? '; filename="' . $dfilename . '"' : '');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'dfilename':
|
||||||
|
if (isset($headers['Content-Disposition'])) {
|
||||||
|
$headers['Content-Disposition'] .= '; filename="' . $value . '"';
|
||||||
|
} else {
|
||||||
|
$dfilename = $value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'description':
|
||||||
|
$headers['Content-Description'] = $value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'charset':
|
||||||
|
if (isset($headers['Content-Type'])) {
|
||||||
|
$headers['Content-Type'] .= '; charset="' . $value . '"';
|
||||||
|
} else {
|
||||||
|
$charset = $value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default content-type
|
||||||
|
if (!isset($headers['Content-Type'])) {
|
||||||
|
$headers['Content-Type'] = 'text/plain';
|
||||||
|
}
|
||||||
|
|
||||||
|
//Default encoding
|
||||||
|
if (!isset($this->_encoding)) {
|
||||||
|
$this->_encoding = '7bit';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign stuff to member variables
|
||||||
|
$this->_encoded = array();
|
||||||
|
$this->_headers = $headers;
|
||||||
|
$this->_body = $body;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* encode()
|
||||||
|
*
|
||||||
|
* Encodes and returns the email. Also stores
|
||||||
|
* it in the encoded member variable
|
||||||
|
*
|
||||||
|
* @return An associative array containing two elements,
|
||||||
|
* body and headers. The headers element is itself
|
||||||
|
* an indexed array.
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function encode()
|
||||||
|
{
|
||||||
|
$encoded =& $this->_encoded;
|
||||||
|
|
||||||
|
if (!empty($this->_subparts)) {
|
||||||
|
srand((double)microtime()*1000000);
|
||||||
|
$boundary = '=_' . md5(rand() . microtime());
|
||||||
|
$this->_headers['Content-Type'] .= ';' . MAIL_MIMEPART_CRLF . "\t" . 'boundary="' . $boundary . '"';
|
||||||
|
|
||||||
|
// Add body parts to $subparts
|
||||||
|
for ($i = 0; $i < count($this->_subparts); $i++) {
|
||||||
|
$headers = array();
|
||||||
|
$tmp = $this->_subparts[$i]->encode();
|
||||||
|
foreach ($tmp['headers'] as $key => $value) {
|
||||||
|
$headers[] = $key . ': ' . $value;
|
||||||
|
}
|
||||||
|
$subparts[] = implode(MAIL_MIMEPART_CRLF, $headers) . MAIL_MIMEPART_CRLF . MAIL_MIMEPART_CRLF . $tmp['body'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$encoded['body'] = '--' . $boundary . MAIL_MIMEPART_CRLF .
|
||||||
|
implode('--' . $boundary . MAIL_MIMEPART_CRLF, $subparts) .
|
||||||
|
'--' . $boundary.'--' . MAIL_MIMEPART_CRLF;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$encoded['body'] = $this->_getEncodedData($this->_body, $this->_encoding) . MAIL_MIMEPART_CRLF;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add headers to $encoded
|
||||||
|
$encoded['headers'] =& $this->_headers;
|
||||||
|
|
||||||
|
return $encoded;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* &addSubPart()
|
||||||
|
*
|
||||||
|
* Adds a subpart to current mime part and returns
|
||||||
|
* a reference to it
|
||||||
|
*
|
||||||
|
* @param $body The body of the subpart, if any.
|
||||||
|
* @param $params The parameters for the subpart, same
|
||||||
|
* as the $params argument for constructor.
|
||||||
|
* @return A reference to the part you just added. It is
|
||||||
|
* crucial if using multipart/* in your subparts that
|
||||||
|
* you use =& in your script when calling this function,
|
||||||
|
* otherwise you will not be able to add further subparts.
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function &addSubPart($body, $params)
|
||||||
|
{
|
||||||
|
$this->_subparts[] = new Mail_mimePart($body, $params);
|
||||||
|
return $this->_subparts[count($this->_subparts) - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* _getEncodedData()
|
||||||
|
*
|
||||||
|
* Returns encoded data based upon encoding passed to it
|
||||||
|
*
|
||||||
|
* @param $data The data to encode.
|
||||||
|
* @param $encoding The encoding type to use, 7bit, base64,
|
||||||
|
* or quoted-printable.
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _getEncodedData($data, $encoding)
|
||||||
|
{
|
||||||
|
switch ($encoding) {
|
||||||
|
case '8bit':
|
||||||
|
case '7bit':
|
||||||
|
return $data;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'quoted-printable':
|
||||||
|
return $this->_quotedPrintableEncode($data);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'base64':
|
||||||
|
return rtrim(chunk_split(base64_encode($data), 76, MAIL_MIMEPART_CRLF));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* quoteadPrintableEncode()
|
||||||
|
*
|
||||||
|
* Encodes data to quoted-printable standard.
|
||||||
|
*
|
||||||
|
* @param $input The data to encode
|
||||||
|
* @param $line_max Optional max line length. Should
|
||||||
|
* not be more than 76 chars
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _quotedPrintableEncode($input , $line_max = 76)
|
||||||
|
{
|
||||||
|
$lines = preg_split("/\r?\n/", $input);
|
||||||
|
$eol = MAIL_MIMEPART_CRLF;
|
||||||
|
$escape = '=';
|
||||||
|
$output = '';
|
||||||
|
|
||||||
|
while(list(, $line) = each($lines)){
|
||||||
|
|
||||||
|
$linlen = strlen($line);
|
||||||
|
$newline = '';
|
||||||
|
|
||||||
|
for ($i = 0; $i < $linlen; $i++) {
|
||||||
|
$char = substr($line, $i, 1);
|
||||||
|
$dec = ord($char);
|
||||||
|
|
||||||
|
if (($dec == 32) AND ($i == ($linlen - 1))){ // convert space at eol only
|
||||||
|
$char = '=20';
|
||||||
|
|
||||||
|
} elseif(($dec == 9) AND ($i == ($linlen - 1))) { // convert tab at eol only
|
||||||
|
$char = '=09';
|
||||||
|
} elseif($dec == 9) {
|
||||||
|
; // Do nothing if a tab.
|
||||||
|
} elseif(($dec == 61) OR ($dec < 32 ) OR ($dec > 126)) {
|
||||||
|
$char = $escape . strtoupper(sprintf('%02s', dechex($dec)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((strlen($newline) + strlen($char)) >= $line_max) { // MAIL_MIMEPART_CRLF is not counted
|
||||||
|
$output .= $newline . $escape . $eol; // soft line break; " =\r\n" is okay
|
||||||
|
$newline = '';
|
||||||
|
}
|
||||||
|
$newline .= $char;
|
||||||
|
} // end of for
|
||||||
|
$output .= $newline . $eol;
|
||||||
|
}
|
||||||
|
$output = substr($output, 0, -1 * strlen($eol)); // Don't want last crlf
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
} // End of class
|
||||||
|
?>
|
@ -0,0 +1,927 @@
|
|||||||
|
<?php
|
||||||
|
//
|
||||||
|
// +----------------------------------------------------------------------+
|
||||||
|
// | PHP Version 4 |
|
||||||
|
// +----------------------------------------------------------------------+
|
||||||
|
// | Copyright (c) 1997-2002 The PHP Group |
|
||||||
|
// +----------------------------------------------------------------------+
|
||||||
|
// | This source file is subject to version 2.0 of the PHP license, |
|
||||||
|
// | that is bundled with this package in the file LICENSE, and is |
|
||||||
|
// | available at through the world-wide-web at |
|
||||||
|
// | http://www.php.net/license/2_02.txt. |
|
||||||
|
// | If you did not receive a copy of the PHP license and are unable to |
|
||||||
|
// | obtain it through the world-wide-web, please send a note to |
|
||||||
|
// | license@php.net so we can mail you a copy immediately. |
|
||||||
|
// +----------------------------------------------------------------------+
|
||||||
|
// | Authors: Sterling Hughes <sterling@php.net> |
|
||||||
|
// | Stig Bakken <ssb@fast.no> |
|
||||||
|
// | Tomas V.V.Cox <cox@idecnet.com> |
|
||||||
|
// +----------------------------------------------------------------------+
|
||||||
|
//
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
|
||||||
|
define('PEAR_ERROR_RETURN', 1);
|
||||||
|
define('PEAR_ERROR_PRINT', 2);
|
||||||
|
define('PEAR_ERROR_TRIGGER', 4);
|
||||||
|
define('PEAR_ERROR_DIE', 8);
|
||||||
|
define('PEAR_ERROR_CALLBACK', 16);
|
||||||
|
define('PEAR_ZE2', (function_exists('version_compare') &&
|
||||||
|
version_compare(zend_version(), "2-dev", "ge")));
|
||||||
|
|
||||||
|
if (substr(PHP_OS, 0, 3) == 'WIN') {
|
||||||
|
define('OS_WINDOWS', true);
|
||||||
|
define('OS_UNIX', false);
|
||||||
|
define('PEAR_OS', 'Windows');
|
||||||
|
} else {
|
||||||
|
define('OS_WINDOWS', false);
|
||||||
|
define('OS_UNIX', true);
|
||||||
|
define('PEAR_OS', 'Unix'); // blatant assumption
|
||||||
|
}
|
||||||
|
|
||||||
|
$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN;
|
||||||
|
$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE;
|
||||||
|
$GLOBALS['_PEAR_destructor_object_list'] = array();
|
||||||
|
$GLOBALS['_PEAR_shutdown_funcs'] = array();
|
||||||
|
$GLOBALS['_PEAR_error_handler_stack'] = array();
|
||||||
|
|
||||||
|
ini_set('track_errors', true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for other PEAR classes. Provides rudimentary
|
||||||
|
* emulation of destructors.
|
||||||
|
*
|
||||||
|
* If you want a destructor in your class, inherit PEAR and make a
|
||||||
|
* destructor method called _yourclassname (same name as the
|
||||||
|
* constructor, but with a "_" prefix). Also, in your constructor you
|
||||||
|
* have to call the PEAR constructor: $this->PEAR();.
|
||||||
|
* The destructor method will be called without parameters. Note that
|
||||||
|
* at in some SAPI implementations (such as Apache), any output during
|
||||||
|
* the request shutdown (in which destructors are called) seems to be
|
||||||
|
* discarded. If you need to get any debug information from your
|
||||||
|
* destructor, use error_log(), syslog() or something similar.
|
||||||
|
*
|
||||||
|
* IMPORTANT! To use the emulated destructors you need to create the
|
||||||
|
* objects by reference, ej: $obj =& new PEAR_child;
|
||||||
|
*
|
||||||
|
* @since PHP 4.0.2
|
||||||
|
* @author Stig Bakken <ssb@fast.no>
|
||||||
|
* @see http://pear.php.net/manual/
|
||||||
|
*/
|
||||||
|
class PEAR
|
||||||
|
{
|
||||||
|
// {{{ properties
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to enable internal debug messages.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $_debug = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default error mode for this object.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $_default_error_mode = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default error options used for this object when error mode
|
||||||
|
* is PEAR_ERROR_TRIGGER.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $_default_error_options = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default error handler (callback) for this object, if error mode is
|
||||||
|
* PEAR_ERROR_CALLBACK.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $_default_error_handler = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Which class to use for error objects.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $_error_class = 'PEAR_Error';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An array of expected errors.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $_expected_errors = array();
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
// {{{ constructor
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Registers this object in
|
||||||
|
* $_PEAR_destructor_object_list for destructor emulation if a
|
||||||
|
* destructor object exists.
|
||||||
|
*
|
||||||
|
* @param string $error_class (optional) which class to use for
|
||||||
|
* error objects, defaults to PEAR_Error.
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function PEAR($error_class = null)
|
||||||
|
{
|
||||||
|
$classname = get_class($this);
|
||||||
|
if ($this->_debug) {
|
||||||
|
print "PEAR constructor called, class=$classname\n";
|
||||||
|
}
|
||||||
|
if ($error_class !== null) {
|
||||||
|
$this->_error_class = $error_class;
|
||||||
|
}
|
||||||
|
while ($classname) {
|
||||||
|
$destructor = "_$classname";
|
||||||
|
if (method_exists($this, $destructor)) {
|
||||||
|
global $_PEAR_destructor_object_list;
|
||||||
|
$_PEAR_destructor_object_list[] = &$this;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
$classname = get_parent_class($classname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ destructor
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor (the emulated type of...). Does nothing right now,
|
||||||
|
* but is included for forward compatibility, so subclass
|
||||||
|
* destructors should always call it.
|
||||||
|
*
|
||||||
|
* See the note in the class desciption about output from
|
||||||
|
* destructors.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function _PEAR() {
|
||||||
|
if ($this->_debug) {
|
||||||
|
printf("PEAR destructor called, class=%s\n", get_class($this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ getStaticProperty()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If you have a class that's mostly/entirely static, and you need static
|
||||||
|
* properties, you can use this method to simulate them. Eg. in your method(s)
|
||||||
|
* do this: $myVar = &PEAR::getStaticProperty('myVar');
|
||||||
|
* You MUST use a reference, or they will not persist!
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string $class The calling classname, to prevent clashes
|
||||||
|
* @param string $var The variable to retrieve.
|
||||||
|
* @return mixed A reference to the variable. If not set it will be
|
||||||
|
* auto initialised to NULL.
|
||||||
|
*/
|
||||||
|
function &getStaticProperty($class, $var)
|
||||||
|
{
|
||||||
|
static $properties;
|
||||||
|
return $properties[$class][$var];
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ registerShutdownFunc()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this function to register a shutdown method for static
|
||||||
|
* classes.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param mixed $func The function name (or array of class/method) to call
|
||||||
|
* @param mixed $args The arguments to pass to the function
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function registerShutdownFunc($func, $args = array())
|
||||||
|
{
|
||||||
|
$GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ isError()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell whether a value is a PEAR error.
|
||||||
|
*
|
||||||
|
* @param mixed $data the value to test
|
||||||
|
* @access public
|
||||||
|
* @return bool true if parameter is an error
|
||||||
|
*/
|
||||||
|
function isError($data) {
|
||||||
|
return (bool)(is_object($data) &&
|
||||||
|
(get_class($data) == 'pear_error' ||
|
||||||
|
is_subclass_of($data, 'pear_error')));
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ setErrorHandling()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets how errors generated by this DB object should be handled.
|
||||||
|
* Can be invoked both in objects and statically. If called
|
||||||
|
* statically, setErrorHandling sets the default behaviour for all
|
||||||
|
* PEAR objects. If called in an object, setErrorHandling sets
|
||||||
|
* the default behaviour for that object.
|
||||||
|
*
|
||||||
|
* @param int $mode
|
||||||
|
* One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
|
||||||
|
* PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE or
|
||||||
|
* PEAR_ERROR_CALLBACK.
|
||||||
|
*
|
||||||
|
* @param mixed $options
|
||||||
|
* When $mode is PEAR_ERROR_TRIGGER, this is the error level (one
|
||||||
|
* of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
|
||||||
|
*
|
||||||
|
* When $mode is PEAR_ERROR_CALLBACK, this parameter is expected
|
||||||
|
* to be the callback function or method. A callback
|
||||||
|
* function is a string with the name of the function, a
|
||||||
|
* callback method is an array of two elements: the element
|
||||||
|
* at index 0 is the object, and the element at index 1 is
|
||||||
|
* the name of the method to call in the object.
|
||||||
|
*
|
||||||
|
* When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is
|
||||||
|
* a printf format string used when printing the error
|
||||||
|
* message.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
* @see PEAR_ERROR_RETURN
|
||||||
|
* @see PEAR_ERROR_PRINT
|
||||||
|
* @see PEAR_ERROR_TRIGGER
|
||||||
|
* @see PEAR_ERROR_DIE
|
||||||
|
* @see PEAR_ERROR_CALLBACK
|
||||||
|
*
|
||||||
|
* @since PHP 4.0.5
|
||||||
|
*/
|
||||||
|
|
||||||
|
function setErrorHandling($mode = null, $options = null)
|
||||||
|
{
|
||||||
|
if (isset($this)) {
|
||||||
|
$setmode = &$this->_default_error_mode;
|
||||||
|
$setoptions = &$this->_default_error_options;
|
||||||
|
} else {
|
||||||
|
$setmode = &$GLOBALS['_PEAR_default_error_mode'];
|
||||||
|
$setoptions = &$GLOBALS['_PEAR_default_error_options'];
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($mode) {
|
||||||
|
case PEAR_ERROR_RETURN:
|
||||||
|
case PEAR_ERROR_PRINT:
|
||||||
|
case PEAR_ERROR_TRIGGER:
|
||||||
|
case PEAR_ERROR_DIE:
|
||||||
|
case null:
|
||||||
|
$setmode = $mode;
|
||||||
|
$setoptions = $options;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PEAR_ERROR_CALLBACK:
|
||||||
|
$setmode = $mode;
|
||||||
|
if ((is_string($options) && function_exists($options)) ||
|
||||||
|
(is_array($options) && method_exists(@$options[0], @$options[1])))
|
||||||
|
{
|
||||||
|
$setoptions = $options;
|
||||||
|
} else {
|
||||||
|
trigger_error("invalid error callback", E_USER_WARNING);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
trigger_error("invalid error mode", E_USER_WARNING);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ expectError()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to tell which errors you expect to get.
|
||||||
|
* Expected errors are always returned with error mode
|
||||||
|
* PEAR_ERROR_RETURN. Expected error codes are stored in a stack,
|
||||||
|
* and this method pushes a new element onto it. The list of
|
||||||
|
* expected errors are in effect until they are popped off the
|
||||||
|
* stack with the popExpect() method.
|
||||||
|
*
|
||||||
|
* Note that this method can not be called statically
|
||||||
|
*
|
||||||
|
* @param mixed $code a single error code or an array of error codes to expect
|
||||||
|
*
|
||||||
|
* @return int the new depth of the "expected errors" stack
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function expectError($code = '*')
|
||||||
|
{
|
||||||
|
if (is_array($code)) {
|
||||||
|
array_push($this->_expected_errors, $code);
|
||||||
|
} else {
|
||||||
|
array_push($this->_expected_errors, array($code));
|
||||||
|
}
|
||||||
|
return sizeof($this->_expected_errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ popExpect()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method pops one element off the expected error codes
|
||||||
|
* stack.
|
||||||
|
*
|
||||||
|
* @return array the list of error codes that were popped
|
||||||
|
*/
|
||||||
|
function popExpect()
|
||||||
|
{
|
||||||
|
return array_pop($this->_expected_errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ _checkDelExpect()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method checks unsets an error code if available
|
||||||
|
*
|
||||||
|
* @param mixed error code
|
||||||
|
* @return bool true if the error code was unset, false otherwise
|
||||||
|
* @access private
|
||||||
|
* @since PHP 4.3.0
|
||||||
|
*/
|
||||||
|
function _checkDelExpect($error_code)
|
||||||
|
{
|
||||||
|
$deleted = false;
|
||||||
|
|
||||||
|
foreach ($this->_expected_errors AS $key => $error_array) {
|
||||||
|
if (in_array($error_code, $error_array)) {
|
||||||
|
unset($this->_expected_errors[$key][array_search($error_code, $error_array)]);
|
||||||
|
$deleted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// clean up empty arrays
|
||||||
|
if (0 == count($this->_expected_errors[$key])) {
|
||||||
|
unset($this->_expected_errors[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ delExpect()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method deletes all occurences of the specified element from
|
||||||
|
* the expected error codes stack.
|
||||||
|
*
|
||||||
|
* @param mixed $error_code error code that should be deleted
|
||||||
|
* @return mixed list of error codes that were deleted or error
|
||||||
|
* @access public
|
||||||
|
* @since PHP 4.3.0
|
||||||
|
*/
|
||||||
|
function delExpect($error_code)
|
||||||
|
{
|
||||||
|
$deleted = false;
|
||||||
|
|
||||||
|
if ((is_array($error_code) && (0 != count($error_code)))) {
|
||||||
|
// $error_code is a non-empty array here;
|
||||||
|
// we walk through it trying to unset all
|
||||||
|
// values
|
||||||
|
foreach($error_code AS $key => $error) {
|
||||||
|
if ($this->_checkDelExpect($error)) {
|
||||||
|
$deleted = true;
|
||||||
|
} else {
|
||||||
|
$deleted = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
|
||||||
|
} elseif (!empty($error_code)) {
|
||||||
|
// $error_code comes alone, trying to unset it
|
||||||
|
if ($this->_checkDelExpect($error_code)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// $error_code is empty
|
||||||
|
return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ raiseError()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is a wrapper that returns an instance of the
|
||||||
|
* configured error class with this object's default error
|
||||||
|
* handling applied. If the $mode and $options parameters are not
|
||||||
|
* specified, the object's defaults are used.
|
||||||
|
*
|
||||||
|
* @param mixed $message a text error message or a PEAR error object
|
||||||
|
*
|
||||||
|
* @param int $code a numeric error code (it is up to your class
|
||||||
|
* to define these if you want to use codes)
|
||||||
|
*
|
||||||
|
* @param int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
|
||||||
|
* PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE or
|
||||||
|
* PEAR_ERROR_CALLBACK.
|
||||||
|
*
|
||||||
|
* @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter
|
||||||
|
* specifies the PHP-internal error level (one of
|
||||||
|
* E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
|
||||||
|
* If $mode is PEAR_ERROR_CALLBACK, this
|
||||||
|
* parameter specifies the callback function or
|
||||||
|
* method. In other error modes this parameter
|
||||||
|
* is ignored.
|
||||||
|
*
|
||||||
|
* @param string $userinfo If you need to pass along for example debug
|
||||||
|
* information, this parameter is meant for that.
|
||||||
|
*
|
||||||
|
* @param string $error_class The returned error object will be
|
||||||
|
* instantiated from this class, if specified.
|
||||||
|
*
|
||||||
|
* @param bool $skipmsg If true, raiseError will only pass error codes,
|
||||||
|
* the error message parameter will be dropped.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return object a PEAR error object
|
||||||
|
* @see PEAR::setErrorHandling
|
||||||
|
* @since PHP 4.0.5
|
||||||
|
*/
|
||||||
|
function &raiseError($message = null,
|
||||||
|
$code = null,
|
||||||
|
$mode = null,
|
||||||
|
$options = null,
|
||||||
|
$userinfo = null,
|
||||||
|
$error_class = null,
|
||||||
|
$skipmsg = false)
|
||||||
|
{
|
||||||
|
// The error is yet a PEAR error object
|
||||||
|
if (is_object($message)) {
|
||||||
|
$code = $message->getCode();
|
||||||
|
$userinfo = $message->getUserInfo();
|
||||||
|
$error_class = $message->getType();
|
||||||
|
$message = $message->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) {
|
||||||
|
if ($exp[0] == "*" ||
|
||||||
|
(is_int(reset($exp)) && in_array($code, $exp)) ||
|
||||||
|
(is_string(reset($exp)) && in_array($message, $exp))) {
|
||||||
|
$mode = PEAR_ERROR_RETURN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// No mode given, try global ones
|
||||||
|
if ($mode === null) {
|
||||||
|
// Class error handler
|
||||||
|
if (isset($this) && isset($this->_default_error_mode)) {
|
||||||
|
$mode = $this->_default_error_mode;
|
||||||
|
$options = $this->_default_error_options;
|
||||||
|
// Global error handler
|
||||||
|
} elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {
|
||||||
|
$mode = $GLOBALS['_PEAR_default_error_mode'];
|
||||||
|
$options = $GLOBALS['_PEAR_default_error_options'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($error_class !== null) {
|
||||||
|
$ec = $error_class;
|
||||||
|
} elseif (isset($this) && isset($this->_error_class)) {
|
||||||
|
$ec = $this->_error_class;
|
||||||
|
} else {
|
||||||
|
$ec = 'PEAR_Error';
|
||||||
|
}
|
||||||
|
if ($skipmsg) {
|
||||||
|
return new $ec($code, $mode, $options, $userinfo);
|
||||||
|
} else {
|
||||||
|
return new $ec($message, $code, $mode, $options, $userinfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ throwError()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simpler form of raiseError with fewer options. In most cases
|
||||||
|
* message, code and userinfo are enough.
|
||||||
|
*
|
||||||
|
* @param string $message
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function &throwError($message = null,
|
||||||
|
$code = null,
|
||||||
|
$userinfo = null)
|
||||||
|
{
|
||||||
|
if (isset($this)) {
|
||||||
|
return $this->raiseError($message, $code, null, null, $userinfo);
|
||||||
|
} else {
|
||||||
|
return PEAR::raiseError($message, $code, null, null, $userinfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ pushErrorHandling()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Push a new error handler on top of the error handler options stack. With this
|
||||||
|
* you can easily override the actual error handler for some code and restore
|
||||||
|
* it later with popErrorHandling.
|
||||||
|
*
|
||||||
|
* @param mixed $mode (same as setErrorHandling)
|
||||||
|
* @param mixed $options (same as setErrorHandling)
|
||||||
|
*
|
||||||
|
* @return bool Always true
|
||||||
|
*
|
||||||
|
* @see PEAR::setErrorHandling
|
||||||
|
*/
|
||||||
|
function pushErrorHandling($mode, $options = null)
|
||||||
|
{
|
||||||
|
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
|
||||||
|
if (isset($this)) {
|
||||||
|
$def_mode = &$this->_default_error_mode;
|
||||||
|
$def_options = &$this->_default_error_options;
|
||||||
|
} else {
|
||||||
|
$def_mode = &$GLOBALS['_PEAR_default_error_mode'];
|
||||||
|
$def_options = &$GLOBALS['_PEAR_default_error_options'];
|
||||||
|
}
|
||||||
|
$stack[] = array($def_mode, $def_options);
|
||||||
|
|
||||||
|
if (isset($this)) {
|
||||||
|
$this->setErrorHandling($mode, $options);
|
||||||
|
} else {
|
||||||
|
PEAR::setErrorHandling($mode, $options);
|
||||||
|
}
|
||||||
|
$stack[] = array($mode, $options);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ popErrorHandling()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pop the last error handler used
|
||||||
|
*
|
||||||
|
* @return bool Always true
|
||||||
|
*
|
||||||
|
* @see PEAR::pushErrorHandling
|
||||||
|
*/
|
||||||
|
function popErrorHandling()
|
||||||
|
{
|
||||||
|
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
|
||||||
|
array_pop($stack);
|
||||||
|
list($mode, $options) = $stack[sizeof($stack) - 1];
|
||||||
|
array_pop($stack);
|
||||||
|
if (isset($this)) {
|
||||||
|
$this->setErrorHandling($mode, $options);
|
||||||
|
} else {
|
||||||
|
PEAR::setErrorHandling($mode, $options);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ loadExtension()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OS independant PHP extension load. Remember to take care
|
||||||
|
* on the correct extension name for case sensitive OSes.
|
||||||
|
*
|
||||||
|
* @param string $ext The extension name
|
||||||
|
* @return bool Success or not on the dl() call
|
||||||
|
*/
|
||||||
|
function loadExtension($ext)
|
||||||
|
{
|
||||||
|
if (!extension_loaded($ext)) {
|
||||||
|
if (OS_WINDOWS) {
|
||||||
|
$suffix = '.dll';
|
||||||
|
} elseif (PHP_OS == 'HP-UX') {
|
||||||
|
$suffix = '.sl';
|
||||||
|
} elseif (PHP_OS == 'AIX') {
|
||||||
|
$suffix = '.a';
|
||||||
|
} elseif (PHP_OS == 'OSX') {
|
||||||
|
$suffix = '.bundle';
|
||||||
|
} else {
|
||||||
|
$suffix = '.so';
|
||||||
|
}
|
||||||
|
return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
}
|
||||||
|
|
||||||
|
// {{{ _PEAR_call_destructors()
|
||||||
|
|
||||||
|
function _PEAR_call_destructors()
|
||||||
|
{
|
||||||
|
global $_PEAR_destructor_object_list;
|
||||||
|
if (is_array($_PEAR_destructor_object_list) &&
|
||||||
|
sizeof($_PEAR_destructor_object_list))
|
||||||
|
{
|
||||||
|
reset($_PEAR_destructor_object_list);
|
||||||
|
while (list($k, $objref) = each($_PEAR_destructor_object_list)) {
|
||||||
|
$classname = get_class($objref);
|
||||||
|
while ($classname) {
|
||||||
|
$destructor = "_$classname";
|
||||||
|
if (method_exists($objref, $destructor)) {
|
||||||
|
$objref->$destructor();
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
$classname = get_parent_class($classname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Empty the object list to ensure that destructors are
|
||||||
|
// not called more than once.
|
||||||
|
$_PEAR_destructor_object_list = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now call the shutdown functions
|
||||||
|
if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) {
|
||||||
|
foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) {
|
||||||
|
call_user_func_array($value[0], $value[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
class PEAR_Error
|
||||||
|
{
|
||||||
|
// {{{ properties
|
||||||
|
|
||||||
|
var $error_message_prefix = '';
|
||||||
|
var $mode = PEAR_ERROR_RETURN;
|
||||||
|
var $level = E_USER_NOTICE;
|
||||||
|
var $code = -1;
|
||||||
|
var $message = '';
|
||||||
|
var $userinfo = '';
|
||||||
|
|
||||||
|
// Wait until we have a stack-groping function in PHP.
|
||||||
|
//var $file = '';
|
||||||
|
//var $line = 0;
|
||||||
|
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ constructor
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PEAR_Error constructor
|
||||||
|
*
|
||||||
|
* @param string $message message
|
||||||
|
*
|
||||||
|
* @param int $code (optional) error code
|
||||||
|
*
|
||||||
|
* @param int $mode (optional) error mode, one of: PEAR_ERROR_RETURN,
|
||||||
|
* PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER or
|
||||||
|
* PEAR_ERROR_CALLBACK
|
||||||
|
*
|
||||||
|
* @param mixed $options (optional) error level, _OR_ in the case of
|
||||||
|
* PEAR_ERROR_CALLBACK, the callback function or object/method
|
||||||
|
* tuple.
|
||||||
|
*
|
||||||
|
* @param string $userinfo (optional) additional user/debug info
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function PEAR_Error($message = 'unknown error', $code = null,
|
||||||
|
$mode = null, $options = null, $userinfo = null)
|
||||||
|
{
|
||||||
|
if ($mode === null) {
|
||||||
|
$mode = PEAR_ERROR_RETURN;
|
||||||
|
}
|
||||||
|
$this->message = $message;
|
||||||
|
$this->code = $code;
|
||||||
|
$this->mode = $mode;
|
||||||
|
$this->userinfo = $userinfo;
|
||||||
|
if ($mode & PEAR_ERROR_CALLBACK) {
|
||||||
|
$this->level = E_USER_NOTICE;
|
||||||
|
$this->callback = $options;
|
||||||
|
} else {
|
||||||
|
if ($options === null) {
|
||||||
|
$options = E_USER_NOTICE;
|
||||||
|
}
|
||||||
|
$this->level = $options;
|
||||||
|
$this->callback = null;
|
||||||
|
}
|
||||||
|
if ($this->mode & PEAR_ERROR_PRINT) {
|
||||||
|
if (is_null($options) || is_int($options)) {
|
||||||
|
$format = "%s";
|
||||||
|
} else {
|
||||||
|
$format = $options;
|
||||||
|
}
|
||||||
|
printf($format, $this->getMessage());
|
||||||
|
}
|
||||||
|
if ($this->mode & PEAR_ERROR_TRIGGER) {
|
||||||
|
trigger_error($this->getMessage(), $this->level);
|
||||||
|
}
|
||||||
|
if ($this->mode & PEAR_ERROR_DIE) {
|
||||||
|
$msg = $this->getMessage();
|
||||||
|
if (is_null($options) || is_int($options)) {
|
||||||
|
$format = "%s";
|
||||||
|
if (substr($msg, -1) != "\n") {
|
||||||
|
$msg .= "\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$format = $options;
|
||||||
|
}
|
||||||
|
die(sprintf($format, $msg));
|
||||||
|
}
|
||||||
|
if ($this->mode & PEAR_ERROR_CALLBACK) {
|
||||||
|
if (is_string($this->callback) && strlen($this->callback)) {
|
||||||
|
call_user_func($this->callback, $this);
|
||||||
|
} elseif (is_array($this->callback) &&
|
||||||
|
sizeof($this->callback) == 2 &&
|
||||||
|
is_object($this->callback[0]) &&
|
||||||
|
is_string($this->callback[1]) &&
|
||||||
|
strlen($this->callback[1])) {
|
||||||
|
@call_user_func($this->callback, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ getMode()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the error mode from an error object.
|
||||||
|
*
|
||||||
|
* @return int error mode
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function getMode() {
|
||||||
|
return $this->mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ getCallback()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the callback function/method from an error object.
|
||||||
|
*
|
||||||
|
* @return mixed callback function or object/method array
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function getCallback() {
|
||||||
|
return $this->callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ getMessage()
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the error message from an error object.
|
||||||
|
*
|
||||||
|
* @return string full error message
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function getMessage()
|
||||||
|
{
|
||||||
|
return ($this->error_message_prefix . $this->message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ getCode()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get error code from an error object
|
||||||
|
*
|
||||||
|
* @return int error code
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function getCode()
|
||||||
|
{
|
||||||
|
return $this->code;
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ getType()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of this error/exception.
|
||||||
|
*
|
||||||
|
* @return string error/exception name (type)
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function getType()
|
||||||
|
{
|
||||||
|
return get_class($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ getUserInfo()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get additional user-supplied information.
|
||||||
|
*
|
||||||
|
* @return string user-supplied information
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function getUserInfo()
|
||||||
|
{
|
||||||
|
return $this->userinfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ getDebugInfo()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get additional debug information supplied by the application.
|
||||||
|
*
|
||||||
|
* @return string debug information
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function getDebugInfo()
|
||||||
|
{
|
||||||
|
return $this->getUserInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ addUserInfo()
|
||||||
|
|
||||||
|
function addUserInfo($info)
|
||||||
|
{
|
||||||
|
if (empty($this->userinfo)) {
|
||||||
|
$this->userinfo = $info;
|
||||||
|
} else {
|
||||||
|
$this->userinfo .= " ** $info";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ toString()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a string representation of this object.
|
||||||
|
*
|
||||||
|
* @return string a string with an object summary
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function toString() {
|
||||||
|
$modes = array();
|
||||||
|
$levels = array(E_USER_NOTICE => 'notice',
|
||||||
|
E_USER_WARNING => 'warning',
|
||||||
|
E_USER_ERROR => 'error');
|
||||||
|
if ($this->mode & PEAR_ERROR_CALLBACK) {
|
||||||
|
if (is_array($this->callback)) {
|
||||||
|
$callback = get_class($this->callback[0]) . '::' .
|
||||||
|
$this->callback[1];
|
||||||
|
} else {
|
||||||
|
$callback = $this->callback;
|
||||||
|
}
|
||||||
|
return sprintf('[%s: message="%s" code=%d mode=callback '.
|
||||||
|
'callback=%s prefix="%s" info="%s"]',
|
||||||
|
get_class($this), $this->message, $this->code,
|
||||||
|
$callback, $this->error_message_prefix,
|
||||||
|
$this->userinfo);
|
||||||
|
}
|
||||||
|
if ($this->mode & PEAR_ERROR_PRINT) {
|
||||||
|
$modes[] = 'print';
|
||||||
|
}
|
||||||
|
if ($this->mode & PEAR_ERROR_TRIGGER) {
|
||||||
|
$modes[] = 'trigger';
|
||||||
|
}
|
||||||
|
if ($this->mode & PEAR_ERROR_DIE) {
|
||||||
|
$modes[] = 'die';
|
||||||
|
}
|
||||||
|
if ($this->mode & PEAR_ERROR_RETURN) {
|
||||||
|
$modes[] = 'return';
|
||||||
|
}
|
||||||
|
return sprintf('[%s: message="%s" code=%d mode=%s level=%s '.
|
||||||
|
'prefix="%s" info="%s"]',
|
||||||
|
get_class($this), $this->message, $this->code,
|
||||||
|
implode("|", $modes), $levels[$this->level],
|
||||||
|
$this->error_message_prefix,
|
||||||
|
$this->userinfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
}
|
||||||
|
|
||||||
|
register_shutdown_function("_PEAR_call_destructors");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Local Variables:
|
||||||
|
* mode: php
|
||||||
|
* tab-width: 4
|
||||||
|
* c-basic-offset: 4
|
||||||
|
* End:
|
||||||
|
*/
|
||||||
|
?>
|
@ -0,0 +1,218 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
//PHP version
|
||||||
|
//Paul Tero, July 2001
|
||||||
|
//http://www.shopable.co.uk/des.html
|
||||||
|
//
|
||||||
|
//Optimised for performance with large blocks by Michael Hayworth, November 2001
|
||||||
|
//http://www.netdealing.com
|
||||||
|
//
|
||||||
|
//Converted from JavaScript to PHP by Jim Gibbs, June 2004
|
||||||
|
//
|
||||||
|
//THIS SOFTWARE IS PROVIDED "AS IS" AND
|
||||||
|
//ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
//IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
//ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
//FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
//DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
//OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
//OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
//SUCH DAMAGE.
|
||||||
|
|
||||||
|
//des
|
||||||
|
//this takes the key, the message, and whether to encrypt or decrypt
|
||||||
|
function des ($key, $message, $encrypt, $mode, $iv) {
|
||||||
|
//declaring this locally speeds things up a bit
|
||||||
|
$spfunction1 = array (0x1010400,0,0x10000,0x1010404,0x1010004,0x10404,0x4,0x10000,0x400,0x1010400,0x1010404,0x400,0x1000404,0x1010004,0x1000000,0x4,0x404,0x1000400,0x1000400,0x10400,0x10400,0x1010000,0x1010000,0x1000404,0x10004,0x1000004,0x1000004,0x10004,0,0x404,0x10404,0x1000000,0x10000,0x1010404,0x4,0x1010000,0x1010400,0x1000000,0x1000000,0x400,0x1010004,0x10000,0x10400,0x1000004,0x400,0x4,0x1000404,0x10404,0x1010404,0x10004,0x1010000,0x1000404,0x1000004,0x404,0x10404,0x1010400,0x404,0x1000400,0x1000400,0,0x10004,0x10400,0,0x1010004);
|
||||||
|
$spfunction2 = array (-0x7fef7fe0,-0x7fff8000,0x8000,0x108020,0x100000,0x20,-0x7fefffe0,-0x7fff7fe0,-0x7fffffe0,-0x7fef7fe0,-0x7fef8000,-0x80000000,-0x7fff8000,0x100000,0x20,-0x7fefffe0,0x108000,0x100020,-0x7fff7fe0,0,-0x80000000,0x8000,0x108020,-0x7ff00000,0x100020,-0x7fffffe0,0,0x108000,0x8020,-0x7fef8000,-0x7ff00000,0x8020,0,0x108020,-0x7fefffe0,0x100000,-0x7fff7fe0,-0x7ff00000,-0x7fef8000,0x8000,-0x7ff00000,-0x7fff8000,0x20,-0x7fef7fe0,0x108020,0x20,0x8000,-0x80000000,0x8020,-0x7fef8000,0x100000,-0x7fffffe0,0x100020,-0x7fff7fe0,-0x7fffffe0,0x100020,0x108000,0,-0x7fff8000,0x8020,-0x80000000,-0x7fefffe0,-0x7fef7fe0,0x108000);
|
||||||
|
$spfunction3 = array (0x208,0x8020200,0,0x8020008,0x8000200,0,0x20208,0x8000200,0x20008,0x8000008,0x8000008,0x20000,0x8020208,0x20008,0x8020000,0x208,0x8000000,0x8,0x8020200,0x200,0x20200,0x8020000,0x8020008,0x20208,0x8000208,0x20200,0x20000,0x8000208,0x8,0x8020208,0x200,0x8000000,0x8020200,0x8000000,0x20008,0x208,0x20000,0x8020200,0x8000200,0,0x200,0x20008,0x8020208,0x8000200,0x8000008,0x200,0,0x8020008,0x8000208,0x20000,0x8000000,0x8020208,0x8,0x20208,0x20200,0x8000008,0x8020000,0x8000208,0x208,0x8020000,0x20208,0x8,0x8020008,0x20200);
|
||||||
|
$spfunction4 = array (0x802001,0x2081,0x2081,0x80,0x802080,0x800081,0x800001,0x2001,0,0x802000,0x802000,0x802081,0x81,0,0x800080,0x800001,0x1,0x2000,0x800000,0x802001,0x80,0x800000,0x2001,0x2080,0x800081,0x1,0x2080,0x800080,0x2000,0x802080,0x802081,0x81,0x800080,0x800001,0x802000,0x802081,0x81,0,0,0x802000,0x2080,0x800080,0x800081,0x1,0x802001,0x2081,0x2081,0x80,0x802081,0x81,0x1,0x2000,0x800001,0x2001,0x802080,0x800081,0x2001,0x2080,0x800000,0x802001,0x80,0x800000,0x2000,0x802080);
|
||||||
|
$spfunction5 = array (0x100,0x2080100,0x2080000,0x42000100,0x80000,0x100,0x40000000,0x2080000,0x40080100,0x80000,0x2000100,0x40080100,0x42000100,0x42080000,0x80100,0x40000000,0x2000000,0x40080000,0x40080000,0,0x40000100,0x42080100,0x42080100,0x2000100,0x42080000,0x40000100,0,0x42000000,0x2080100,0x2000000,0x42000000,0x80100,0x80000,0x42000100,0x100,0x2000000,0x40000000,0x2080000,0x42000100,0x40080100,0x2000100,0x40000000,0x42080000,0x2080100,0x40080100,0x100,0x2000000,0x42080000,0x42080100,0x80100,0x42000000,0x42080100,0x2080000,0,0x40080000,0x42000000,0x80100,0x2000100,0x40000100,0x80000,0,0x40080000,0x2080100,0x40000100);
|
||||||
|
$spfunction6 = array (0x20000010,0x20400000,0x4000,0x20404010,0x20400000,0x10,0x20404010,0x400000,0x20004000,0x404010,0x400000,0x20000010,0x400010,0x20004000,0x20000000,0x4010,0,0x400010,0x20004010,0x4000,0x404000,0x20004010,0x10,0x20400010,0x20400010,0,0x404010,0x20404000,0x4010,0x404000,0x20404000,0x20000000,0x20004000,0x10,0x20400010,0x404000,0x20404010,0x400000,0x4010,0x20000010,0x400000,0x20004000,0x20000000,0x4010,0x20000010,0x20404010,0x404000,0x20400000,0x404010,0x20404000,0,0x20400010,0x10,0x4000,0x20400000,0x404010,0x4000,0x400010,0x20004010,0,0x20404000,0x20000000,0x400010,0x20004010);
|
||||||
|
$spfunction7 = array (0x200000,0x4200002,0x4000802,0,0x800,0x4000802,0x200802,0x4200800,0x4200802,0x200000,0,0x4000002,0x2,0x4000000,0x4200002,0x802,0x4000800,0x200802,0x200002,0x4000800,0x4000002,0x4200000,0x4200800,0x200002,0x4200000,0x800,0x802,0x4200802,0x200800,0x2,0x4000000,0x200800,0x4000000,0x200800,0x200000,0x4000802,0x4000802,0x4200002,0x4200002,0x2,0x200002,0x4000000,0x4000800,0x200000,0x4200800,0x802,0x200802,0x4200800,0x802,0x4000002,0x4200802,0x4200000,0x200800,0,0x2,0x4200802,0,0x200802,0x4200000,0x800,0x4000002,0x4000800,0x800,0x200002);
|
||||||
|
$spfunction8 = array (0x10001040,0x1000,0x40000,0x10041040,0x10000000,0x10001040,0x40,0x10000000,0x40040,0x10040000,0x10041040,0x41000,0x10041000,0x41040,0x1000,0x40,0x10040000,0x10000040,0x10001000,0x1040,0x41000,0x40040,0x10040040,0x10041000,0x1040,0,0,0x10040040,0x10000040,0x10001000,0x41040,0x40000,0x41040,0x40000,0x10041000,0x1000,0x40,0x10040040,0x1000,0x41040,0x10001000,0x40,0x10000040,0x10040000,0x10040040,0x10000000,0x40000,0x10001040,0,0x10041040,0x40040,0x10000040,0x10040000,0x10001000,0x10001040,0,0x10041040,0x41000,0x41000,0x1040,0x1040,0x40040,0x10000000,0x10041000);
|
||||||
|
$masks = array (4294967295,2147483647,1073741823,536870911,268435455,134217727,67108863,33554431,16777215,8388607,4194303,2097151,1048575,524287,262143,131071,65535,32767,16383,8191,4095,2047,1023,511,255,127,63,31,15,7,3,1,0);
|
||||||
|
|
||||||
|
//create the 16 or 48 subkeys we will need
|
||||||
|
$keys = des_createKeys ($key);
|
||||||
|
$m=0;
|
||||||
|
$len = strlen($message);
|
||||||
|
$chunk = 0;
|
||||||
|
//set up the loops for single and triple des
|
||||||
|
$iterations = ((count($keys) == 32) ? 3 : 9); //single or triple des
|
||||||
|
if ($iterations == 3) {$looping = (($encrypt) ? array (0, 32, 2) : array (30, -2, -2));}
|
||||||
|
else {$looping = (($encrypt) ? array (0, 32, 2, 62, 30, -2, 64, 96, 2) : array (94, 62, -2, 32, 64, 2, 30, -2, -2));}
|
||||||
|
|
||||||
|
$message .= (chr(0) . chr(0) . chr(0) . chr(0) . chr(0) . chr(0) . chr(0) . chr(0)); //pad the message out with null bytes
|
||||||
|
//store the result here
|
||||||
|
$result = "";
|
||||||
|
$tempresult = "";
|
||||||
|
|
||||||
|
if ($mode == 1) { //CBC mode
|
||||||
|
$cbcleft = (ord($iv{$m++}) << 24) | (ord($iv{$m++}) << 16) | (ord($iv{$m++}) << 8) | ord($iv{$m++});
|
||||||
|
$cbcright = (ord($iv{$m++}) << 24) | (ord($iv{$m++}) << 16) | (ord($iv{$m++}) << 8) | ord($iv{$m++});
|
||||||
|
$m=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//loop through each 64 bit chunk of the message
|
||||||
|
while ($m < $len) {
|
||||||
|
$left = (ord($message{$m++}) << 24) | (ord($message{$m++}) << 16) | (ord($message{$m++}) << 8) | ord($message{$m++});
|
||||||
|
$right = (ord($message{$m++}) << 24) | (ord($message{$m++}) << 16) | (ord($message{$m++}) << 8) | ord($message{$m++});
|
||||||
|
|
||||||
|
//for Cipher Block Chaining mode, xor the message with the previous result
|
||||||
|
if ($mode == 1) {if ($encrypt) {$left ^= $cbcleft; $right ^= $cbcright;} else {$cbcleft2 = $cbcleft; $cbcright2 = $cbcright; $cbcleft = $left; $cbcright = $right;}}
|
||||||
|
|
||||||
|
//first each 64 but chunk of the message must be permuted according to IP
|
||||||
|
$temp = (($left >> 4 & $masks[4]) ^ $right) & 0x0f0f0f0f; $right ^= $temp; $left ^= ($temp << 4);
|
||||||
|
$temp = (($left >> 16 & $masks[16]) ^ $right) & 0x0000ffff; $right ^= $temp; $left ^= ($temp << 16);
|
||||||
|
$temp = (($right >> 2 & $masks[2]) ^ $left) & 0x33333333; $left ^= $temp; $right ^= ($temp << 2);
|
||||||
|
$temp = (($right >> 8 & $masks[8]) ^ $left) & 0x00ff00ff; $left ^= $temp; $right ^= ($temp << 8);
|
||||||
|
$temp = (($left >> 1 & $masks[1]) ^ $right) & 0x55555555; $right ^= $temp; $left ^= ($temp << 1);
|
||||||
|
|
||||||
|
$left = (($left << 1) | ($left >> 31 & $masks[31]));
|
||||||
|
$right = (($right << 1) | ($right >> 31 & $masks[31]));
|
||||||
|
|
||||||
|
//do this either 1 or 3 times for each chunk of the message
|
||||||
|
for ($j=0; $j<$iterations; $j+=3) {
|
||||||
|
$endloop = $looping[$j+1];
|
||||||
|
$loopinc = $looping[$j+2];
|
||||||
|
//now go through and perform the encryption or decryption
|
||||||
|
for ($i=$looping[$j]; $i!=$endloop; $i+=$loopinc) { //for efficiency
|
||||||
|
$right1 = $right ^ $keys[$i];
|
||||||
|
$right2 = (($right >> 4 & $masks[4]) | ($right << 28)) ^ $keys[$i+1];
|
||||||
|
//the result is attained by passing these bytes through the S selection functions
|
||||||
|
$temp = $left;
|
||||||
|
$left = $right;
|
||||||
|
$right = $temp ^ ($spfunction2[($right1 >> 24 & $masks[24]) & 0x3f] | $spfunction4[($right1 >> 16 & $masks[16]) & 0x3f]
|
||||||
|
| $spfunction6[($right1 >> 8 & $masks[8]) & 0x3f] | $spfunction8[$right1 & 0x3f]
|
||||||
|
| $spfunction1[($right2 >> 24 & $masks[24]) & 0x3f] | $spfunction3[($right2 >> 16 & $masks[16]) & 0x3f]
|
||||||
|
| $spfunction5[($right2 >> 8 & $masks[8]) & 0x3f] | $spfunction7[$right2 & 0x3f]);
|
||||||
|
}
|
||||||
|
$temp = $left; $left = $right; $right = $temp; //unreverse left and right
|
||||||
|
} //for either 1 or 3 iterations
|
||||||
|
|
||||||
|
//move then each one bit to the right
|
||||||
|
$left = (($left >> 1 & $masks[1]) | ($left << 31));
|
||||||
|
$right = (($right >> 1 & $masks[1]) | ($right << 31));
|
||||||
|
|
||||||
|
//now perform IP-1, which is IP in the opposite direction
|
||||||
|
$temp = (($left >> 1 & $masks[1]) ^ $right) & 0x55555555; $right ^= $temp; $left ^= ($temp << 1);
|
||||||
|
$temp = (($right >> 8 & $masks[8]) ^ $left) & 0x00ff00ff; $left ^= $temp; $right ^= ($temp << 8);
|
||||||
|
$temp = (($right >> 2 & $masks[2]) ^ $left) & 0x33333333; $left ^= $temp; $right ^= ($temp << 2);
|
||||||
|
$temp = (($left >> 16 & $masks[16]) ^ $right) & 0x0000ffff; $right ^= $temp; $left ^= ($temp << 16);
|
||||||
|
$temp = (($left >> 4 & $masks[4]) ^ $right) & 0x0f0f0f0f; $right ^= $temp; $left ^= ($temp << 4);
|
||||||
|
|
||||||
|
//for Cipher Block Chaining mode, xor the message with the previous result
|
||||||
|
if ($mode == 1) {if ($encrypt) {$cbcleft = $left; $cbcright = $right;} else {$left ^= $cbcleft2; $right ^= $cbcright2;}}
|
||||||
|
$tempresult .= (chr($left>>24 & $masks[24]) . chr(($left>>16 & $masks[16]) & 0xff) . chr(($left>>8 & $masks[8]) & 0xff) . chr($left & 0xff) . chr($right>>24 & $masks[24]) . chr(($right>>16 & $masks[16]) & 0xff) . chr(($right>>8 & $masks[8]) & 0xff) . chr($right & 0xff));
|
||||||
|
|
||||||
|
$chunk += 8;
|
||||||
|
if ($chunk == 512) {$result .= $tempresult; $tempresult = ""; $chunk = 0;}
|
||||||
|
} //for every 8 characters, or 64 bits in the message
|
||||||
|
|
||||||
|
//return the result as an array
|
||||||
|
return ($result . $tempresult);
|
||||||
|
} //end of des
|
||||||
|
|
||||||
|
//des_createKeys
|
||||||
|
//this takes as input a 64 bit key (even though only 56 bits are used)
|
||||||
|
//as an array of 2 integers, and returns 16 48 bit keys
|
||||||
|
function des_createKeys ($key) {
|
||||||
|
//declaring this locally speeds things up a bit
|
||||||
|
$pc2bytes0 = array (0,0x4,0x20000000,0x20000004,0x10000,0x10004,0x20010000,0x20010004,0x200,0x204,0x20000200,0x20000204,0x10200,0x10204,0x20010200,0x20010204);
|
||||||
|
$pc2bytes1 = array (0,0x1,0x100000,0x100001,0x4000000,0x4000001,0x4100000,0x4100001,0x100,0x101,0x100100,0x100101,0x4000100,0x4000101,0x4100100,0x4100101);
|
||||||
|
$pc2bytes2 = array (0,0x8,0x800,0x808,0x1000000,0x1000008,0x1000800,0x1000808,0,0x8,0x800,0x808,0x1000000,0x1000008,0x1000800,0x1000808);
|
||||||
|
$pc2bytes3 = array (0,0x200000,0x8000000,0x8200000,0x2000,0x202000,0x8002000,0x8202000,0x20000,0x220000,0x8020000,0x8220000,0x22000,0x222000,0x8022000,0x8222000);
|
||||||
|
$pc2bytes4 = array (0,0x40000,0x10,0x40010,0,0x40000,0x10,0x40010,0x1000,0x41000,0x1010,0x41010,0x1000,0x41000,0x1010,0x41010);
|
||||||
|
$pc2bytes5 = array (0,0x400,0x20,0x420,0,0x400,0x20,0x420,0x2000000,0x2000400,0x2000020,0x2000420,0x2000000,0x2000400,0x2000020,0x2000420);
|
||||||
|
$pc2bytes6 = array (0,0x10000000,0x80000,0x10080000,0x2,0x10000002,0x80002,0x10080002,0,0x10000000,0x80000,0x10080000,0x2,0x10000002,0x80002,0x10080002);
|
||||||
|
$pc2bytes7 = array (0,0x10000,0x800,0x10800,0x20000000,0x20010000,0x20000800,0x20010800,0x20000,0x30000,0x20800,0x30800,0x20020000,0x20030000,0x20020800,0x20030800);
|
||||||
|
$pc2bytes8 = array (0,0x40000,0,0x40000,0x2,0x40002,0x2,0x40002,0x2000000,0x2040000,0x2000000,0x2040000,0x2000002,0x2040002,0x2000002,0x2040002);
|
||||||
|
$pc2bytes9 = array (0,0x10000000,0x8,0x10000008,0,0x10000000,0x8,0x10000008,0x400,0x10000400,0x408,0x10000408,0x400,0x10000400,0x408,0x10000408);
|
||||||
|
$pc2bytes10 = array (0,0x20,0,0x20,0x100000,0x100020,0x100000,0x100020,0x2000,0x2020,0x2000,0x2020,0x102000,0x102020,0x102000,0x102020);
|
||||||
|
$pc2bytes11 = array (0,0x1000000,0x200,0x1000200,0x200000,0x1200000,0x200200,0x1200200,0x4000000,0x5000000,0x4000200,0x5000200,0x4200000,0x5200000,0x4200200,0x5200200);
|
||||||
|
$pc2bytes12 = array (0,0x1000,0x8000000,0x8001000,0x80000,0x81000,0x8080000,0x8081000,0x10,0x1010,0x8000010,0x8001010,0x80010,0x81010,0x8080010,0x8081010);
|
||||||
|
$pc2bytes13 = array (0,0x4,0x100,0x104,0,0x4,0x100,0x104,0x1,0x5,0x101,0x105,0x1,0x5,0x101,0x105);
|
||||||
|
$masks = array (4294967295,2147483647,1073741823,536870911,268435455,134217727,67108863,33554431,16777215,8388607,4194303,2097151,1048575,524287,262143,131071,65535,32767,16383,8191,4095,2047,1023,511,255,127,63,31,15,7,3,1,0);
|
||||||
|
|
||||||
|
//how many iterations (1 for des, 3 for triple des)
|
||||||
|
$iterations = ((strlen($key) >= 24) ? 3 : 1);
|
||||||
|
//stores the return keys
|
||||||
|
$keys = array (); // size = 32 * iterations but you don't specify this in php
|
||||||
|
//now define the left shifts which need to be done
|
||||||
|
$shifts = array (0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0);
|
||||||
|
//other variables
|
||||||
|
$m=0;
|
||||||
|
$n=0;
|
||||||
|
|
||||||
|
for ($j=0; $j<$iterations; $j++) { //either 1 or 3 iterations
|
||||||
|
$left = (ord($key{$m++}) << 24) | (ord($key{$m++}) << 16) | (ord($key{$m++}) << 8) | ord($key{$m++});
|
||||||
|
$right = (ord($key{$m++}) << 24) | (ord($key{$m++}) << 16) | (ord($key{$m++}) << 8) | ord($key{$m++});
|
||||||
|
|
||||||
|
$temp = (($left >> 4 & $masks[4]) ^ $right) & 0x0f0f0f0f; $right ^= $temp; $left ^= ($temp << 4);
|
||||||
|
$temp = (($right >> 16 & $masks[16]) ^ $left) & 0x0000ffff; $left ^= $temp; $right ^= ($temp << -16);
|
||||||
|
$temp = (($left >> 2 & $masks[2]) ^ $right) & 0x33333333; $right ^= $temp; $left ^= ($temp << 2);
|
||||||
|
$temp = (($right >> 16 & $masks[16]) ^ $left) & 0x0000ffff; $left ^= $temp; $right ^= ($temp << -16);
|
||||||
|
$temp = (($left >> 1 & $masks[1]) ^ $right) & 0x55555555; $right ^= $temp; $left ^= ($temp << 1);
|
||||||
|
$temp = (($right >> 8 & $masks[8]) ^ $left) & 0x00ff00ff; $left ^= $temp; $right ^= ($temp << 8);
|
||||||
|
$temp = (($left >> 1 & $masks[1]) ^ $right) & 0x55555555; $right ^= $temp; $left ^= ($temp << 1);
|
||||||
|
|
||||||
|
//the right side needs to be shifted and to get the last four bits of the left side
|
||||||
|
$temp = ($left << 8) | (($right >> 20 & $masks[20]) & 0x000000f0);
|
||||||
|
//left needs to be put upside down
|
||||||
|
$left = ($right << 24) | (($right << 8) & 0xff0000) | (($right >> 8 & $masks[8]) & 0xff00) | (($right >> 24 & $masks[24]) & 0xf0);
|
||||||
|
$right = $temp;
|
||||||
|
|
||||||
|
//now go through and perform these shifts on the left and right keys
|
||||||
|
for ($i=0; $i < count($shifts); $i++) {
|
||||||
|
//shift the keys either one or two bits to the left
|
||||||
|
if ($shifts[$i] > 0) {
|
||||||
|
$left = (($left << 2) | ($left >> 26 & $masks[26]));
|
||||||
|
$right = (($right << 2) | ($right >> 26 & $masks[26]));
|
||||||
|
} else {
|
||||||
|
$left = (($left << 1) | ($left >> 27 & $masks[27]));
|
||||||
|
$right = (($right << 1) | ($right >> 27 & $masks[27]));
|
||||||
|
}
|
||||||
|
$left = $left & -0xf;
|
||||||
|
$right = $right & -0xf;
|
||||||
|
|
||||||
|
//now apply PC-2, in such a way that E is easier when encrypting or decrypting
|
||||||
|
//this conversion will look like PC-2 except only the last 6 bits of each byte are used
|
||||||
|
//rather than 48 consecutive bits and the order of lines will be according to
|
||||||
|
//how the S selection functions will be applied: S2, S4, S6, S8, S1, S3, S5, S7
|
||||||
|
$lefttemp = $pc2bytes0[$left >> 28 & $masks[28]] | $pc2bytes1[($left >> 24 & $masks[24]) & 0xf]
|
||||||
|
| $pc2bytes2[($left >> 20 & $masks[20]) & 0xf] | $pc2bytes3[($left >> 16 & $masks[16]) & 0xf]
|
||||||
|
| $pc2bytes4[($left >> 12 & $masks[12]) & 0xf] | $pc2bytes5[($left >> 8 & $masks[8]) & 0xf]
|
||||||
|
| $pc2bytes6[($left >> 4 & $masks[4]) & 0xf];
|
||||||
|
$righttemp = $pc2bytes7[$right >> 28 & $masks[28]] | $pc2bytes8[($right >> 24 & $masks[24]) & 0xf]
|
||||||
|
| $pc2bytes9[($right >> 20 & $masks[20]) & 0xf] | $pc2bytes10[($right >> 16 & $masks[16]) & 0xf]
|
||||||
|
| $pc2bytes11[($right >> 12 & $masks[12]) & 0xf] | $pc2bytes12[($right >> 8 & $masks[8]) & 0xf]
|
||||||
|
| $pc2bytes13[($right >> 4 & $masks[4]) & 0xf];
|
||||||
|
$temp = (($righttemp >> 16 & $masks[16]) ^ $lefttemp) & 0x0000ffff;
|
||||||
|
$keys[$n++] = $lefttemp ^ $temp; $keys[$n++] = $righttemp ^ ($temp << 16);
|
||||||
|
}
|
||||||
|
} //for each iterations
|
||||||
|
//return the keys we've created
|
||||||
|
return $keys;
|
||||||
|
} //end of des_createKeys
|
||||||
|
|
||||||
|
/*
|
||||||
|
////////////////////////////// TEST //////////////////////////////
|
||||||
|
function stringToHex ($s) {
|
||||||
|
$r = "0x";
|
||||||
|
$hexes = array ("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
|
||||||
|
for ($i=0; $i<strlen($s); $i++) {$r .= ($hexes [(ord($s{$i}) >> 4)] . $hexes [(ord($s{$i}) & 0xf)]);}
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
|
echo "<PRE>";
|
||||||
|
$key = "this is a 24 byte key !!";
|
||||||
|
$message = "This is a test message";
|
||||||
|
$ciphertext = des ($key, $message, 1, 0, null);
|
||||||
|
echo "DES Test Encrypted: " . stringToHex ($ciphertext);
|
||||||
|
$recovered_message = des ($key, $ciphertext, 0, 0, null);
|
||||||
|
echo "\n";
|
||||||
|
echo "DES Test Decrypted: " . $recovered_message;
|
||||||
|
*/
|
||||||
|
?>
|
@ -0,0 +1,114 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
File: read_enriched.inc
|
||||||
|
Author: Ryo Chijiiwa
|
||||||
|
License: GPL (part of IlohaMail)
|
||||||
|
Purpose: functions for handling text/enriched messages
|
||||||
|
Reference: RFC 1523, 1896
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function enriched_convert_newlines($str){
|
||||||
|
//remove single newlines, convert N newlines to N-1
|
||||||
|
|
||||||
|
$str = str_replace("\r\n","\n",$str);
|
||||||
|
$len = strlen($str);
|
||||||
|
|
||||||
|
$nl = 0;
|
||||||
|
$out = '';
|
||||||
|
for($i=0;$i<$len;$i++){
|
||||||
|
$c = $str[$i];
|
||||||
|
if (ord($c)==10) $nl++;
|
||||||
|
if ($nl && ord($c)!=10) $nl = 0;
|
||||||
|
if ($nl!=1) $out.=$c;
|
||||||
|
else $out.=' ';
|
||||||
|
}
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
function enriched_convert_formatting($body){
|
||||||
|
$a=array('<bold>'=>'<b>','</bold>'=>'</b>','<italic>'=>'<i>',
|
||||||
|
'</italic>'=>'</i>','<fixed>'=>'<tt>','</fixed>'=>'</tt>',
|
||||||
|
'<smaller>'=>'<font size=-1>','</smaller>'=>'</font>',
|
||||||
|
'<bigger>'=>'<font size=+1>','</bigger>'=>'</font>',
|
||||||
|
'<underline>'=>'<span style="text-decoration: underline">',
|
||||||
|
'</underline>'=>'</span>',
|
||||||
|
'<flushleft>'=>'<span style="text-align:left">',
|
||||||
|
'</flushleft>'=>'</span>',
|
||||||
|
'<flushright>'=>'<span style="text-align:right">',
|
||||||
|
'</flushright>'=>'</span>',
|
||||||
|
'<flushboth>'=>'<span style="text-align:justified">',
|
||||||
|
'</flushboth>'=>'</span>',
|
||||||
|
'<indent>'=>'<span style="padding-left: 20px">',
|
||||||
|
'</indent>'=>'</span>',
|
||||||
|
'<indentright>'=>'<span style="padding-right: 20px">',
|
||||||
|
'</indentright>'=>'</span>');
|
||||||
|
|
||||||
|
while(list($find,$replace)=each($a)){
|
||||||
|
$body = eregi_replace($find,$replace,$body);
|
||||||
|
}
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
|
||||||
|
function enriched_font($body){
|
||||||
|
$pattern = '/(.*)\<fontfamily\>\<param\>(.*)\<\/param\>(.*)\<\/fontfamily\>(.*)/ims';
|
||||||
|
while(preg_match($pattern,$body,$a)){
|
||||||
|
//print_r($a);
|
||||||
|
if (count($a)!=5) continue;
|
||||||
|
$body=$a[1].'<span style="font-family: '.$a[2].'">'.$a[3].'</span>'.$a[4];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function enriched_color($body){
|
||||||
|
$pattern = '/(.*)\<color\>\<param\>(.*)\<\/param\>(.*)\<\/color\>(.*)/ims';
|
||||||
|
while(preg_match($pattern,$body,$a)){
|
||||||
|
//print_r($a);
|
||||||
|
if (count($a)!=5) continue;
|
||||||
|
|
||||||
|
//extract color (either by name, or ####,####,####)
|
||||||
|
if (strpos($a[2],',')){
|
||||||
|
$rgb = explode(',',$a[2]);
|
||||||
|
$color ='#';
|
||||||
|
for($i=0;$i<3;$i++) $color.=substr($rgb[$i],0,2); //just take first 2 bytes
|
||||||
|
}else{
|
||||||
|
$color = $a[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
//put it all together
|
||||||
|
$body = $a[1].'<span style="color: '.$color.'">'.$a[3].'</span>'.$a[4];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
|
||||||
|
function enriched_excerpt($body){
|
||||||
|
|
||||||
|
$pattern = '/(.*)\<excerpt\>(.*)\<\/excerpt\>(.*)/i';
|
||||||
|
while(preg_match($pattern,$body,$a)){
|
||||||
|
//print_r($a);
|
||||||
|
if (count($a)!=4) continue;
|
||||||
|
$quoted = '';
|
||||||
|
$lines = explode('<br>',$a[2]);
|
||||||
|
foreach($lines as $n=>$line) $quoted.='>'.$line.'<br>';
|
||||||
|
$body=$a[1].'<span class="quotes">'.$quoted.'</span>'.$a[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
|
||||||
|
function enriched_to_html($body){
|
||||||
|
$body = str_replace('<<','<',$body);
|
||||||
|
$body = enriched_convert_newlines($body);
|
||||||
|
$body = str_replace("\n", '<br>', $body);
|
||||||
|
$body = enriched_convert_formatting($body);
|
||||||
|
$body = enriched_color($body);
|
||||||
|
$body = enriched_font($body);
|
||||||
|
$body = enriched_excerpt($body);
|
||||||
|
//$body = nl2br($body);
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,440 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
* *
|
||||||
|
* class.html2text.inc *
|
||||||
|
* *
|
||||||
|
*************************************************************************
|
||||||
|
* *
|
||||||
|
* Converts HTML to formatted plain text *
|
||||||
|
* *
|
||||||
|
* Copyright (c) 2005 Jon Abernathy <jon@chuggnutt.com> *
|
||||||
|
* All rights reserved. *
|
||||||
|
* *
|
||||||
|
* This script is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* The GNU General Public License can be found at *
|
||||||
|
* http://www.gnu.org/copyleft/gpl.html. *
|
||||||
|
* *
|
||||||
|
* This script is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* Author(s): Jon Abernathy <jon@chuggnutt.com> *
|
||||||
|
* *
|
||||||
|
* Last modified: 04/06/05 *
|
||||||
|
* Modified: 2004/05/19 (tbr) *
|
||||||
|
* *
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes HTML and converts it to formatted, plain text.
|
||||||
|
*
|
||||||
|
* Thanks to Alexander Krug (http://www.krugar.de/) to pointing out and
|
||||||
|
* correcting an error in the regexp search array. Fixed 7/30/03.
|
||||||
|
*
|
||||||
|
* Updated set_html() function's file reading mechanism, 9/25/03.
|
||||||
|
*
|
||||||
|
* Thanks to Joss Sanglier (http://www.dancingbear.co.uk/) for adding
|
||||||
|
* several more HTML entity codes to the $search and $replace arrays.
|
||||||
|
* Updated 11/7/03.
|
||||||
|
*
|
||||||
|
* Thanks to Darius Kasperavicius (http://www.dar.dar.lt/) for
|
||||||
|
* suggesting the addition of $allowed_tags and its supporting function
|
||||||
|
* (which I slightly modified). Updated 3/12/04.
|
||||||
|
*
|
||||||
|
* Thanks to Justin Dearing for pointing out that a replacement for the
|
||||||
|
* <TH> tag was missing, and suggesting an appropriate fix.
|
||||||
|
* Updated 8/25/04.
|
||||||
|
*
|
||||||
|
* Thanks to Mathieu Collas (http://www.myefarm.com/) for finding a
|
||||||
|
* display/formatting bug in the _build_link_list() function: email
|
||||||
|
* readers would show the left bracket and number ("[1") as part of the
|
||||||
|
* rendered email address.
|
||||||
|
* Updated 12/16/04.
|
||||||
|
*
|
||||||
|
* Thanks to Wojciech Bajon (http://histeria.pl/) for submitting code
|
||||||
|
* to handle relative links, which I hadn't considered. I modified his
|
||||||
|
* code a bit to handle normal HTTP links and MAILTO links. Also for
|
||||||
|
* suggesting three additional HTML entity codes to search for.
|
||||||
|
* Updated 03/02/05.
|
||||||
|
*
|
||||||
|
* Thanks to Jacob Chandler for pointing out another link condition
|
||||||
|
* for the _build_link_list() function: "https".
|
||||||
|
* Updated 04/06/05.
|
||||||
|
*
|
||||||
|
* @author Jon Abernathy <jon@chuggnutt.com>
|
||||||
|
* @version 0.6.1
|
||||||
|
* @since PHP 4.0.2
|
||||||
|
*/
|
||||||
|
class html2text
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the HTML content to convert.
|
||||||
|
*
|
||||||
|
* @var string $html
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
var $html;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the converted, formatted text.
|
||||||
|
*
|
||||||
|
* @var string $text
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
var $text;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum width of the formatted text, in columns.
|
||||||
|
*
|
||||||
|
* @var integer $width
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
var $width = 70;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of preg* regular expression patterns to search for,
|
||||||
|
* used in conjunction with $replace.
|
||||||
|
*
|
||||||
|
* @var array $search
|
||||||
|
* @access public
|
||||||
|
* @see $replace
|
||||||
|
*/
|
||||||
|
var $search = array(
|
||||||
|
"/\r/", // Non-legal carriage return
|
||||||
|
"/[\n\t]+/", // Newlines and tabs
|
||||||
|
'/<script[^>]*>.*?<\/script>/i', // <script>s -- which strip_tags supposedly has problems with
|
||||||
|
//'/<!-- .* -->/', // Comments -- which strip_tags might have problem a with
|
||||||
|
'/<a href="([^"]+)"[^>]*>(.+?)<\/a>/ie', // <a href="">
|
||||||
|
'/<h[123][^>]*>(.+?)<\/h[123]>/ie', // H1 - H3
|
||||||
|
'/<h[456][^>]*>(.+?)<\/h[456]>/ie', // H4 - H6
|
||||||
|
'/<p[^>]*>/i', // <P>
|
||||||
|
'/<br[^>]*>/i', // <br>
|
||||||
|
'/<b[^>]*>(.+?)<\/b>/ie', // <b>
|
||||||
|
'/<i[^>]*>(.+?)<\/i>/i', // <i>
|
||||||
|
'/(<ul[^>]*>|<\/ul>)/i', // <ul> and </ul>
|
||||||
|
'/(<ol[^>]*>|<\/ol>)/i', // <ol> and </ol>
|
||||||
|
'/<li[^>]*>/i', // <li>
|
||||||
|
'/<hr[^>]*>/i', // <hr>
|
||||||
|
'/(<table[^>]*>|<\/table>)/i', // <table> and </table>
|
||||||
|
'/(<tr[^>]*>|<\/tr>)/i', // <tr> and </tr>
|
||||||
|
'/<td[^>]*>(.+?)<\/td>/i', // <td> and </td>
|
||||||
|
'/<th[^>]*>(.+?)<\/th>/i', // <th> and </th>
|
||||||
|
'/ /i',
|
||||||
|
'/"/i',
|
||||||
|
'/>/i',
|
||||||
|
'/</i',
|
||||||
|
'/&/i',
|
||||||
|
'/©/i',
|
||||||
|
'/™/i',
|
||||||
|
'/“/',
|
||||||
|
'/”/',
|
||||||
|
'/–/',
|
||||||
|
'/’/',
|
||||||
|
'/&/',
|
||||||
|
'/©/',
|
||||||
|
'/™/',
|
||||||
|
'/—/',
|
||||||
|
'/“/',
|
||||||
|
'/”/',
|
||||||
|
'/•/',
|
||||||
|
'/®/i',
|
||||||
|
'/•/i',
|
||||||
|
'/&[&;]+;/i'
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of pattern replacements corresponding to patterns searched.
|
||||||
|
*
|
||||||
|
* @var array $replace
|
||||||
|
* @access public
|
||||||
|
* @see $search
|
||||||
|
*/
|
||||||
|
var $replace = array(
|
||||||
|
'', // Non-legal carriage return
|
||||||
|
' ', // Newlines and tabs
|
||||||
|
'', // <script>s -- which strip_tags supposedly has problems with
|
||||||
|
//'', // Comments -- which strip_tags might have problem a with
|
||||||
|
'$this->_build_link_list("\\1", "\\2")', // <a href="">
|
||||||
|
"strtoupper(\"\n\n\\1\n\n\")", // H1 - H3
|
||||||
|
"ucwords(\"\n\n\\1\n\n\")", // H4 - H6
|
||||||
|
"\n\n\t", // <P>
|
||||||
|
"\n", // <br>
|
||||||
|
'strtoupper("\\1")', // <b>
|
||||||
|
'_\\1_', // <i>
|
||||||
|
"\n\n", // <ul> and </ul>
|
||||||
|
"\n\n", // <ol> and </ol>
|
||||||
|
"\t*", // <li>
|
||||||
|
"\n-------------------------\n", // <hr>
|
||||||
|
"\n\n", // <table> and </table>
|
||||||
|
"\n", // <tr> and </tr>
|
||||||
|
"\t\t\\1\n", // <td> and </td>
|
||||||
|
"strtoupper(\"\t\t\\1\n\")", // <th> and </th>
|
||||||
|
' ',
|
||||||
|
'"',
|
||||||
|
'>',
|
||||||
|
'<',
|
||||||
|
'&',
|
||||||
|
'(c)',
|
||||||
|
'(tm)',
|
||||||
|
'"',
|
||||||
|
'"',
|
||||||
|
'-',
|
||||||
|
"'",
|
||||||
|
'&',
|
||||||
|
'(c)',
|
||||||
|
'(tm)',
|
||||||
|
'--',
|
||||||
|
'"',
|
||||||
|
'"',
|
||||||
|
'*',
|
||||||
|
'(R)',
|
||||||
|
'*',
|
||||||
|
''
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains a list of HTML tags to allow in the resulting text.
|
||||||
|
*
|
||||||
|
* @var string $allowed_tags
|
||||||
|
* @access public
|
||||||
|
* @see set_allowed_tags()
|
||||||
|
*/
|
||||||
|
var $allowed_tags = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the base URL that relative links should resolve to.
|
||||||
|
*
|
||||||
|
* @var string $url
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
var $url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether content in the $html variable has been converted yet.
|
||||||
|
*
|
||||||
|
* @var boolean $converted
|
||||||
|
* @access private
|
||||||
|
* @see $html, $text
|
||||||
|
*/
|
||||||
|
var $_converted = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains URL addresses from links to be rendered in plain text.
|
||||||
|
*
|
||||||
|
* @var string $link_list
|
||||||
|
* @access private
|
||||||
|
* @see _build_link_list()
|
||||||
|
*/
|
||||||
|
var $_link_list = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* If the HTML source string (or file) is supplied, the class
|
||||||
|
* will instantiate with that source propagated, all that has
|
||||||
|
* to be done it to call get_text().
|
||||||
|
*
|
||||||
|
* @param string $source HTML content
|
||||||
|
* @param boolean $from_file Indicates $source is a file to pull content from
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function html2text( $source = '', $from_file = false )
|
||||||
|
{
|
||||||
|
if ( !empty($source) ) {
|
||||||
|
$this->set_html($source, $from_file);
|
||||||
|
}
|
||||||
|
$this->set_base_url();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads source HTML into memory, either from $source string or a file.
|
||||||
|
*
|
||||||
|
* @param string $source HTML content
|
||||||
|
* @param boolean $from_file Indicates $source is a file to pull content from
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function set_html( $source, $from_file = false )
|
||||||
|
{
|
||||||
|
$this->html = $source;
|
||||||
|
|
||||||
|
if ( $from_file && file_exists($source) ) {
|
||||||
|
$fp = fopen($source, 'r');
|
||||||
|
$this->html = fread($fp, filesize($source));
|
||||||
|
fclose($fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_converted = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the text, converted from HTML.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function get_text()
|
||||||
|
{
|
||||||
|
if ( !$this->_converted ) {
|
||||||
|
$this->_convert();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->text;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints the text, converted from HTML.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function print_text()
|
||||||
|
{
|
||||||
|
print $this->get_text();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias to print_text(), operates identically.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
* @see print_text()
|
||||||
|
*/
|
||||||
|
function p()
|
||||||
|
{
|
||||||
|
print $this->get_text();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the allowed HTML tags to pass through to the resulting text.
|
||||||
|
*
|
||||||
|
* Tags should be in the form "<p>", with no corresponding closing tag.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function set_allowed_tags( $allowed_tags = '' )
|
||||||
|
{
|
||||||
|
if ( !empty($allowed_tags) ) {
|
||||||
|
$this->allowed_tags = $allowed_tags;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a base URL to handle relative links.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function set_base_url( $url = '' )
|
||||||
|
{
|
||||||
|
if ( empty($url) ) {
|
||||||
|
$this->url = 'http://' . $_SERVER['HTTP_HOST'];
|
||||||
|
} else {
|
||||||
|
// Strip any trailing slashes for consistency (relative
|
||||||
|
// URLs may already start with a slash like "/file.html")
|
||||||
|
if ( substr($url, -1) == '/' ) {
|
||||||
|
$url = substr($url, 0, -1);
|
||||||
|
}
|
||||||
|
$this->url = $url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Workhorse function that does actual conversion.
|
||||||
|
*
|
||||||
|
* First performs custom tag replacement specified by $search and
|
||||||
|
* $replace arrays. Then strips any remaining HTML tags, reduces whitespace
|
||||||
|
* and newlines to a readable format, and word wraps the text to
|
||||||
|
* $width characters.
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function _convert()
|
||||||
|
{
|
||||||
|
// Variables used for building the link list
|
||||||
|
//$link_count = 1;
|
||||||
|
//$this->_link_list = '';
|
||||||
|
|
||||||
|
$text = trim(stripslashes($this->html));
|
||||||
|
|
||||||
|
// Run our defined search-and-replace
|
||||||
|
$text = preg_replace($this->search, $this->replace, $text);
|
||||||
|
|
||||||
|
// Strip any other HTML tags
|
||||||
|
$text = strip_tags($text, $this->allowed_tags);
|
||||||
|
|
||||||
|
// Bring down number of empty lines to 2 max
|
||||||
|
$text = preg_replace("/\n\s+\n/", "\n", $text);
|
||||||
|
$text = preg_replace("/[\n]{3,}/", "\n\n", $text);
|
||||||
|
|
||||||
|
// Add link list
|
||||||
|
if ( sizeof($this->_link_list) ) {
|
||||||
|
$text .= "\n\nLinks:\n------\n";
|
||||||
|
foreach ($this->_link_list as $id => $link) {
|
||||||
|
$text .= '[' . ($id+1) . '] ' . $link . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wrap the text to a readable format
|
||||||
|
// for PHP versions >= 4.0.2. Default width is 75
|
||||||
|
$text = wordwrap($text, $this->width);
|
||||||
|
|
||||||
|
$this->text = $text;
|
||||||
|
|
||||||
|
$this->_converted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function called by preg_replace() on link replacement.
|
||||||
|
*
|
||||||
|
* Maintains an internal list of links to be displayed at the end of the
|
||||||
|
* text, with numeric indices to the original point in the text they
|
||||||
|
* appeared. Also makes an effort at identifying and handling absolute
|
||||||
|
* and relative links.
|
||||||
|
*
|
||||||
|
* @param integer $link_count Counter tracking current link number
|
||||||
|
* @param string $link URL of the link
|
||||||
|
* @param string $display Part of the text to associate number with
|
||||||
|
* @access private
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _build_link_list($link, $display)
|
||||||
|
{
|
||||||
|
$link_lc = strtolower($link);
|
||||||
|
|
||||||
|
if (substr($link_lc, 0, 7) == 'http://' || substr($link_lc, 0, 8) == 'https://' || substr($link_lc, 0, 7) == 'mailto:')
|
||||||
|
{
|
||||||
|
$url = $link;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$url = $this->url;
|
||||||
|
if ($link{0} != '/') {
|
||||||
|
$url .= '/';
|
||||||
|
}
|
||||||
|
$url .= $link;
|
||||||
|
}
|
||||||
|
|
||||||
|
$index = array_search($url, $this->_link_list);
|
||||||
|
if ($index===FALSE)
|
||||||
|
{
|
||||||
|
$index = sizeof($this->_link_list);
|
||||||
|
$this->_link_list[$index] = $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $display . ' [' . ($index+1) . ']';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
function mod_b64_decode($data){
|
||||||
|
return base64_decode(str_replace(",","/",$data));
|
||||||
|
}
|
||||||
|
|
||||||
|
function mod_b64_encode($data){
|
||||||
|
return str_replace("/",",",str_replace("=","",base64_encode($data)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function utf8_to_html($str){
|
||||||
|
$len = strlen($str);
|
||||||
|
$out = "";
|
||||||
|
for($i=0;$i<$len;$i+=2){
|
||||||
|
$val = ord($str[$i]);
|
||||||
|
$next_val = ord($str[$i+1]);
|
||||||
|
if ($val<255){
|
||||||
|
$out.="&#".($val*256+$next_val).";";
|
||||||
|
}else{
|
||||||
|
$out.=$str[$i].$str[$i+1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
function iil_utf7_decode($str, $raw=false){
|
||||||
|
if (strpos($str, '&')===false) return $str;
|
||||||
|
|
||||||
|
$len = strlen($str);
|
||||||
|
$in_b64 = false;
|
||||||
|
$b64_data = "";
|
||||||
|
$out = "";
|
||||||
|
for ($i=0;$i<$len;$i++){
|
||||||
|
$char = $str[$i];
|
||||||
|
if ($char=='&') $in_b64 = true;
|
||||||
|
else if ($in_b64 && $char=='-'){
|
||||||
|
$in_b64 = false;
|
||||||
|
if ($b64_data=="") $out.="&";
|
||||||
|
else{
|
||||||
|
$dec=mod_b64_decode($b64_data);
|
||||||
|
$out.=($raw?$dec:utf8_to_html($dec));
|
||||||
|
$b64_data = "";
|
||||||
|
}
|
||||||
|
}else if ($in_b64) $b64_data.=$char;
|
||||||
|
else $out.=$char;
|
||||||
|
}
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
function iil_utf7_encode($str){
|
||||||
|
if (!ereg("[\200-\237]",$str) && !ereg("[\241-\377]",$str))
|
||||||
|
return $str;
|
||||||
|
|
||||||
|
$len = strlen($str);
|
||||||
|
|
||||||
|
for ($i=0;$i<$len;$i++){
|
||||||
|
$val = ord($str[$i]);
|
||||||
|
if ($val>=224 && $val<=239){
|
||||||
|
$unicode = ($val-224) * 4096 + (ord($str[$i+1])-128) * 64 + (ord($str[$i+2])-128);
|
||||||
|
$i+=2;
|
||||||
|
$utf_code.=chr((int)($unicode/256)).chr($unicode%256);
|
||||||
|
}else if ($val>=192 && $val<=223){
|
||||||
|
$unicode = ($val-192) * 64 + (ord($str[$i+1])-128);
|
||||||
|
$i++;
|
||||||
|
$utf_code.=chr((int)($unicode/256)).chr($unicode%256);
|
||||||
|
}else{
|
||||||
|
if ($utf_code){
|
||||||
|
$out.='&'.mod_b64_encode($utf_code).'-';
|
||||||
|
$utf_code="";
|
||||||
|
}
|
||||||
|
if ($str[$i]=="-") $out.="&";
|
||||||
|
$out.=$str[$i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($utf_code)
|
||||||
|
$out.='&'.mod_b64_encode($utf_code).'-';
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,322 @@
|
|||||||
|
<?php
|
||||||
|
/////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Iloha MIME Library (IML)
|
||||||
|
//
|
||||||
|
// (C)Copyright 2002 Ryo Chijiiwa <Ryo@IlohaMail.org>
|
||||||
|
//
|
||||||
|
// This file is part of IlohaMail. IlohaMail is free software released
|
||||||
|
// under the GPL license. See enclosed file COPYING for details, or
|
||||||
|
// see http://www.fsf.org/copyleft/gpl.html
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/********************************************************
|
||||||
|
|
||||||
|
FILE: include/mime.inc
|
||||||
|
PURPOSE:
|
||||||
|
Provide functions for handling mime messages.
|
||||||
|
USAGE:
|
||||||
|
Use iil_C_FetchStructureString to get IMAP structure stirng, then pass that through
|
||||||
|
iml_GetRawStructureArray() to get root node to a nested data structure.
|
||||||
|
Pass root node to the iml_GetPart*() functions to retreive individual bits of info.
|
||||||
|
|
||||||
|
********************************************************/
|
||||||
|
$MIME_INVALID = -1;
|
||||||
|
$MIME_TEXT = 0;
|
||||||
|
$MIME_MULTIPART = 1;
|
||||||
|
$MIME_MESSAGE = 2;
|
||||||
|
$MIME_APPLICATION = 3;
|
||||||
|
$MIME_AUDIO = 4;
|
||||||
|
$MIME_IMAGE = 5;
|
||||||
|
$MIME_VIDEO = 6;
|
||||||
|
$MIME_OTHER = 7;
|
||||||
|
|
||||||
|
function iml_ClosingParenPos($str, $start){
|
||||||
|
$level=0;
|
||||||
|
$len = strlen($str);
|
||||||
|
$in_quote = 0;
|
||||||
|
for ($i=$start;$i<$len;$i++){
|
||||||
|
if ($str[$i]=="\"") $in_quote = ($in_quote + 1) % 2;
|
||||||
|
if (!$in_quote){
|
||||||
|
if ($str[$i]=="(") $level++;
|
||||||
|
else if (($level > 0) && ($str[$i]==")")) $level--;
|
||||||
|
else if (($level == 0) && ($str[$i]==")")) return $i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function iml_ParseBSString($str){
|
||||||
|
|
||||||
|
$id = 0;
|
||||||
|
$a = array();
|
||||||
|
$len = strlen($str);
|
||||||
|
|
||||||
|
$in_quote = 0;
|
||||||
|
for ($i=0; $i<$len; $i++){
|
||||||
|
if ($str[$i] == "\"") $in_quote = ($in_quote + 1) % 2;
|
||||||
|
else if (!$in_quote){
|
||||||
|
if ($str[$i] == " ") $id++; //space means new element
|
||||||
|
else if ($str[$i]=="("){ //new part
|
||||||
|
$i++;
|
||||||
|
$endPos = iml_ClosingParenPos($str, $i);
|
||||||
|
$partLen = $endPos - $i;
|
||||||
|
$part = substr($str, $i, $partLen);
|
||||||
|
$a[$id] = iml_ParseBSString($part); //send part string
|
||||||
|
if ($verbose){
|
||||||
|
echo "{>".$endPos."}";
|
||||||
|
flush();
|
||||||
|
}
|
||||||
|
$i = $endPos;
|
||||||
|
}else $a[$id].=$str[$i]; //add to current element in array
|
||||||
|
}else if ($in_quote){
|
||||||
|
if ($str[$i]=="\\") $i++; //escape backslashes
|
||||||
|
else $a[$id].=$str[$i]; //add to current element in array
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reset($a);
|
||||||
|
return $a;
|
||||||
|
}
|
||||||
|
|
||||||
|
function iml_GetRawStructureArray($str){
|
||||||
|
$line=substr($str, 1, strlen($str) - 2);
|
||||||
|
$line = str_replace(")(", ") (", $line);
|
||||||
|
|
||||||
|
$struct = iml_ParseBSString($line);
|
||||||
|
if ((strcasecmp($struct[0], "message")==0) && (strcasecmp($struct[1], "rfc822")==0)){
|
||||||
|
$struct = array($struct);
|
||||||
|
}
|
||||||
|
return $struct;
|
||||||
|
}
|
||||||
|
|
||||||
|
function iml_GetPartArray($a, $part){
|
||||||
|
if (!is_array($a)) return false;
|
||||||
|
if (strpos($part, ".") > 0){
|
||||||
|
$original_part = $part;
|
||||||
|
$pos = strpos($part, ".");
|
||||||
|
$rest = substr($original_part, $pos+1);
|
||||||
|
$part = substr($original_part, 0, $pos);
|
||||||
|
if ((strcasecmp($a[0], "message")==0) && (strcasecmp($a[1], "rfc822")==0)){
|
||||||
|
$a = $a[8];
|
||||||
|
}
|
||||||
|
//echo "m - part: $original_part current: $part rest: $rest array: ".implode(" ", $a)."<br>\n";
|
||||||
|
return iml_GetPartArray($a[$part-1], $rest);
|
||||||
|
}else if ($part>0){
|
||||||
|
if ((strcasecmp($a[0], "message")==0) && (strcasecmp($a[1], "rfc822")==0)){
|
||||||
|
$a = $a[8];
|
||||||
|
}
|
||||||
|
//echo "s - part: $part rest: $rest array: ".implode(" ", $a)."<br>\n";
|
||||||
|
if (is_array($a[$part-1])) return $a[$part-1];
|
||||||
|
else return false;
|
||||||
|
}else if (($part==0) || (empty($part))){
|
||||||
|
return $a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function iml_GetNumParts($a, $part){
|
||||||
|
if (is_array($a)){
|
||||||
|
$parent=iml_GetPartArray($a, $part);
|
||||||
|
|
||||||
|
if ((strcasecmp($parent[0], "message")==0) && (strcasecmp($parent[1], "rfc822")==0)){
|
||||||
|
$parent = $parent[8];
|
||||||
|
}
|
||||||
|
|
||||||
|
$is_array=true;
|
||||||
|
$c=0;
|
||||||
|
while (( list ($key, $val) = each ($parent) )&&($is_array)){
|
||||||
|
$is_array=is_array($parent[$key]);
|
||||||
|
if ($is_array) $c++;
|
||||||
|
}
|
||||||
|
return $c;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function iml_GetPartTypeString($a, $part){
|
||||||
|
$part_a=iml_GetPartArray($a, $part);
|
||||||
|
if ($part_a){
|
||||||
|
if (is_array($part_a[0])){
|
||||||
|
$type_str = "MULTIPART/";
|
||||||
|
reset($part_a);
|
||||||
|
while(list($n,$element)=each($part_a)){
|
||||||
|
if (!is_array($part_a[$n])){
|
||||||
|
$type_str.=$part_a[$n];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $type_str;
|
||||||
|
}else return $part_a[0]."/".$part_a[1];
|
||||||
|
}else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function iml_GetFirstTextPart($structure,$part){
|
||||||
|
if ($part==0) $part="";
|
||||||
|
$typeCode = -1;
|
||||||
|
while ($typeCode!=0){
|
||||||
|
$typeCode = iml_GetPartTypeCode($structure, $part);
|
||||||
|
if ($typeCode == 1){
|
||||||
|
$part .= (empty($part)?"":".")."1";
|
||||||
|
}else if ($typeCode > 0){
|
||||||
|
$parts_a = explode(".", $part);
|
||||||
|
$lastPart = count($parts_a) - 1;
|
||||||
|
$parts_a[$lastPart] = (int)$parts_a[$lastPart] + 1;
|
||||||
|
$part = implode(".", $parts_a);
|
||||||
|
}else if ($typeCode == -1){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $part;
|
||||||
|
}
|
||||||
|
|
||||||
|
function iml_GetPartTypeCode($a, $part){
|
||||||
|
$types=array(0=>"text",1=>"multipart",2=>"message",3=>"application",4=>"audio",5=>"image",6=>"video",7=>"other");
|
||||||
|
|
||||||
|
$part_a=iml_GetPartArray($a, $part);
|
||||||
|
if ($part_a){
|
||||||
|
if (is_array($part_a[0])) $str="multipart";
|
||||||
|
else $str=$part_a[0];
|
||||||
|
|
||||||
|
$code=7;
|
||||||
|
while ( list($key, $val) = each($types)) if (strcasecmp($val, $str)==0) $code=$key;
|
||||||
|
return $code;
|
||||||
|
}else return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function iml_GetPartEncodingCode($a, $part){
|
||||||
|
$encodings=array("7BIT", "8BIT", "BINARY", "BASE64", "QUOTED-PRINTABLE", "OTHER");
|
||||||
|
|
||||||
|
$part_a=iml_GetPartArray($a, $part);
|
||||||
|
if ($part_a){
|
||||||
|
if (is_array($part_a[0])) return -1;
|
||||||
|
else $str=$part_a[5];
|
||||||
|
|
||||||
|
$code=5;
|
||||||
|
while ( list($key, $val) = each($encodings)) if (strcasecmp($val, $str)==0) $code=$key;
|
||||||
|
|
||||||
|
return $code;
|
||||||
|
|
||||||
|
}else return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function iml_GetPartEncodingString($a, $part){
|
||||||
|
$part_a=iml_GetPartArray($a, $part);
|
||||||
|
if ($part_a){
|
||||||
|
if (is_array($part_a[0])) return -1;
|
||||||
|
else return $part_a[5];
|
||||||
|
}else return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function iml_GetPartSize($a, $part){
|
||||||
|
$part_a=iml_GetPartArray($a, $part);
|
||||||
|
if ($part_a){
|
||||||
|
if (is_array($part_a[0])) return -1;
|
||||||
|
else return $part_a[6];
|
||||||
|
}else return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function iml_GetPartID($a, $part){
|
||||||
|
$part_a=iml_GetPartArray($a, $part);
|
||||||
|
if ($part_a){
|
||||||
|
if (is_array($part_a[0])) return -1;
|
||||||
|
else return $part_a[3];
|
||||||
|
}else return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function iml_GetPartDisposition($a, $part){
|
||||||
|
$part_a=iml_GetPartArray($a, $part);
|
||||||
|
if ($part_a){
|
||||||
|
if (is_array($part_a[0])) return -1;
|
||||||
|
else{
|
||||||
|
$id = count($part_a) - 2;
|
||||||
|
if (is_array($part_a[$id])) return $part_a[$id][0];
|
||||||
|
else return "";
|
||||||
|
}
|
||||||
|
}else return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function iml_GetPartName($a, $part){
|
||||||
|
$part_a=iml_GetPartArray($a, $part);
|
||||||
|
if ($part_a){
|
||||||
|
if (is_array($part_a[0])) return -1;
|
||||||
|
else{
|
||||||
|
$name = "";
|
||||||
|
if (is_array($part_a[2])){
|
||||||
|
//first look in content type
|
||||||
|
$name="";
|
||||||
|
while ( list($key, $val) = each ($part_a[2])){
|
||||||
|
if ((strcasecmp($val, "NAME")==0)||(strcasecmp($val, "FILENAME")==0))
|
||||||
|
$name=$part_a[2][$key+1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($name)){
|
||||||
|
//check in content disposition
|
||||||
|
$id = count($part_a) - 2;
|
||||||
|
if ((is_array($part_a[$id])) && (is_array($part_a[$id][1]))){
|
||||||
|
$array = $part_a[$id][1];
|
||||||
|
while ( list($key, $val) = each($array)){
|
||||||
|
if ((strcasecmp($val, "NAME")==0)||(strcasecmp($val, "FILENAME")==0))
|
||||||
|
$name=$array[$key+1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
}else return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function iml_GetPartCharset($a, $part){
|
||||||
|
$part_a=iml_GetPartArray($a, $part);
|
||||||
|
if ($part_a){
|
||||||
|
if (is_array($part_a[0])) return -1;
|
||||||
|
else{
|
||||||
|
if (is_array($part_a[2])){
|
||||||
|
$name="";
|
||||||
|
while ( list($key, $val) = each ($part_a[2])) if (strcasecmp($val, "charset")==0) $name=$part_a[2][$key+1];
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
else return "";
|
||||||
|
}
|
||||||
|
}else return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function iml_GetPartList($a, $part){
|
||||||
|
//echo "MOO?"; flush();
|
||||||
|
$data = array();
|
||||||
|
$num_parts = iml_GetNumParts($a, $part);
|
||||||
|
//echo "($num_parts)"; flush();
|
||||||
|
if ($num_parts !== false){
|
||||||
|
//echo "<!-- ($num_parts parts)//-->\n";
|
||||||
|
for ($i = 0; $i<$num_parts; $i++){
|
||||||
|
$part_code = $part.(empty($part)?"":".").($i+1);
|
||||||
|
$part_type = iml_GetPartTypeCode($a, $part_code);
|
||||||
|
$part_disposition = iml_GetPartDisposition($a, $part_code);
|
||||||
|
//echo "<!-- part: $part_code type: $part_type //-->\n";
|
||||||
|
if (strcasecmp($part_disposition, "attachment")!=0 &&
|
||||||
|
(($part_type == 1) || ($part_type==2))){
|
||||||
|
$data = array_merge($data, iml_GetPartList($a, $part_code));
|
||||||
|
}else{
|
||||||
|
$data[$part_code]["typestring"] = iml_GetPartTypeString($a, $part_code);
|
||||||
|
$data[$part_code]["disposition"] = $part_disposition;
|
||||||
|
$data[$part_code]["size"] = iml_GetPartSize($a, $part_code);
|
||||||
|
$data[$part_code]["name"] = iml_GetPartName($a, $part_code);
|
||||||
|
$data[$part_code]["id"] = iml_GetPartID($a, $part_code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function iml_GetNextPart($part){
|
||||||
|
if (strpos($part, ".")===false) return $part++;
|
||||||
|
else{
|
||||||
|
$parts_a = explode(".", $part);
|
||||||
|
$num_levels = count($parts_a);
|
||||||
|
$parts_a[$num_levels-1]++;
|
||||||
|
return implode(".", $parts_a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -0,0 +1,351 @@
|
|||||||
|
<?php
|
||||||
|
/////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// include/smtp.inc
|
||||||
|
//
|
||||||
|
// (C)Copyright 2002 Ryo Chijiiwa <Ryo@IlohaMail.org>
|
||||||
|
//
|
||||||
|
// This file is part of IlohaMail.
|
||||||
|
// IlohaMail is free software released under the GPL
|
||||||
|
// license. See enclosed file COPYING for details,
|
||||||
|
// or see http://www.fsf.org/copyleft/gpl.html
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/********************************************************
|
||||||
|
|
||||||
|
AUTHOR: Ryo Chijiiwa <ryo@ilohamail.org>
|
||||||
|
FILE: include/smtp.php
|
||||||
|
PURPOSE:
|
||||||
|
Provide SMTP functionality using pure PHP.
|
||||||
|
PRE-CONDITIONS:
|
||||||
|
The functions here require a SMTP server configured to allow relaying.
|
||||||
|
POST-CONDITIONS:
|
||||||
|
The following global variables are returned:
|
||||||
|
$smtp_errornum - error number, 0 if successful
|
||||||
|
$smtp_error - error message(s)
|
||||||
|
$SMTP_TYPE - Optional
|
||||||
|
COMMENTS:
|
||||||
|
The optional $smtp_message_file can be used for sending extremely large
|
||||||
|
messages. Storing large messages in a variable will consume whatever
|
||||||
|
amount of memory required, which may be more than is available if dealing
|
||||||
|
with messages with large attachments. By storing them in a file, it becomes
|
||||||
|
possible to read/send bits at a time, drastically reducing memory useage.
|
||||||
|
|
||||||
|
This library only provides bare-bones SMTP functionality. It is up to the
|
||||||
|
parent code to form valid RFC822 (MIME) messages.
|
||||||
|
|
||||||
|
********************************************************/
|
||||||
|
|
||||||
|
//set some global constants
|
||||||
|
if (strcasecmp($SMTP_TYPE, "courier")==0){
|
||||||
|
$SMTP_REPLY_DELIM = "-";
|
||||||
|
$SMTP_DATA_REPLY = 250;
|
||||||
|
}else{
|
||||||
|
$SMTP_REPLY_DELIM = " ";
|
||||||
|
$SMTP_DATA_REPLY = 354;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* fgets replacement that's multi-line aware */
|
||||||
|
function smtp_get_response($fp, $len){
|
||||||
|
$end = false;
|
||||||
|
do{
|
||||||
|
$line = chop(fgets($fp, 5120));
|
||||||
|
// echo "SMTP:".$line."<br>\n"; flush();
|
||||||
|
if ((strlen($line)==3) || ($line[3]==' ')) $end = true;
|
||||||
|
}while(!$end);
|
||||||
|
|
||||||
|
return $line;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function smtp_check_reply($reply){
|
||||||
|
global $smtp_error;
|
||||||
|
global $SMTP_REPLY_DELIM;
|
||||||
|
|
||||||
|
$a = explode($SMTP_REPLY_DELIM, chop($reply));
|
||||||
|
|
||||||
|
if (count($a) >= 1){
|
||||||
|
|
||||||
|
if ($a[0]==250||$a[0]==354) return true;
|
||||||
|
else{
|
||||||
|
$smtp_error .= $reply."\n";
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$smtp_error .= "Invalid SMTP response line: $reply\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function smtp_split($str){
|
||||||
|
$result = array();
|
||||||
|
$pos = strpos($str, " ");
|
||||||
|
if ($pos===false){
|
||||||
|
$result[0] = $str;
|
||||||
|
}else{
|
||||||
|
$result[0] = substr($str, 0, $pos);
|
||||||
|
$result[1] = substr($str, $pos+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function smtp_ehlo(&$conn, $host){
|
||||||
|
$result = "";
|
||||||
|
fputs($conn, "EHLO $host\r\n");
|
||||||
|
//echo "Sent: EHLO $host\n"; flush();
|
||||||
|
do{
|
||||||
|
$line = fgets($conn, 2048);
|
||||||
|
//echo "Got: $line"; flush();
|
||||||
|
$a = explode(" ", $line);
|
||||||
|
if ($a[0]=="250-AUTH") $result .= substr($line, 9);
|
||||||
|
}while(!is_numeric($a[0]));
|
||||||
|
|
||||||
|
if ($a[0]==250) return $result;
|
||||||
|
else return $a[0];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function smtp_auth_login(&$conn, $user, $pass){
|
||||||
|
$auth["username"] = base64_encode($user);
|
||||||
|
$auth["password"] = base64_encode($pass);
|
||||||
|
|
||||||
|
fputs($conn, "AUTH LOGIN\r\n");
|
||||||
|
|
||||||
|
//echo "Sent: AUTH LOGIN\n"; flush();
|
||||||
|
|
||||||
|
//get first line
|
||||||
|
$line = smtp_get_response($conn, 1024);
|
||||||
|
//echo "AUTH_LOGIN << $line"; flush();
|
||||||
|
$parts = smtp_split($line);
|
||||||
|
//valid reply?
|
||||||
|
if (($parts[0]!=334) || (empty($parts[1]))) return false;
|
||||||
|
//send data
|
||||||
|
$prompt = eregi_replace("[^a-z]", "", strtolower(base64_decode($parts[1])));
|
||||||
|
fputs($conn, $auth[$prompt]."\r\n");
|
||||||
|
//echo "AUT_LOGIN >> ".$auth[$prompt]."\n"; flush();
|
||||||
|
|
||||||
|
//get second line
|
||||||
|
$line = smtp_get_response($conn, 1024);
|
||||||
|
//echo "AUTH_LOGIN << $line"; flush();
|
||||||
|
$parts = smtp_split($line);
|
||||||
|
//valid reply?
|
||||||
|
if (($parts[0]!=334) || (empty($parts[1]))) return false;
|
||||||
|
$prompt = eregi_replace("[^a-z]", "", strtolower(base64_decode($parts[1])));
|
||||||
|
fputs($conn, $auth[$prompt]."\r\n");
|
||||||
|
//echo "AUT_LOGIN >> ".$auth[$prompt]."\n"; flush();
|
||||||
|
|
||||||
|
$line = smtp_get_response($conn, 1024);
|
||||||
|
//echo "AUTH_LOGIN << $line"; flush();
|
||||||
|
$parts = smtp_split($line);
|
||||||
|
return ($parts[0]==235);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function smtp_connect($host, $port, $user, $pass){
|
||||||
|
global $smtp_errornum;
|
||||||
|
global $smtp_error;
|
||||||
|
|
||||||
|
//auth user?
|
||||||
|
global $SMTP_USER, $SMTP_PASSWORD;
|
||||||
|
if ((!empty($SMTP_USER)) && (!empty($SMTP_PASSWORD))){
|
||||||
|
$user = $SMTP_USER;
|
||||||
|
$pass = $SMTP_PASSWORD;
|
||||||
|
}
|
||||||
|
|
||||||
|
// echo "User: $user<br>\n";
|
||||||
|
|
||||||
|
//figure out auth mode
|
||||||
|
global $AUTH_MODE;
|
||||||
|
$auth_mode = $AUTH_MODE["smtp"];
|
||||||
|
if (empty($auth_mode)) $auth_mode = "none";
|
||||||
|
if (empty($user) || empty($pass)) $auth_mode = "none";
|
||||||
|
|
||||||
|
// echo "authmode: $auth_mode<br>\n"; flush();
|
||||||
|
|
||||||
|
//initialize defaults
|
||||||
|
if (empty($host)) $host = "localhost";
|
||||||
|
if (empty($port)) $port = 25;
|
||||||
|
|
||||||
|
// echo "Connecting to $host:$port<br>\n"; flush();
|
||||||
|
|
||||||
|
//connect to SMTP server
|
||||||
|
$conn = fsockopen($host, $port);
|
||||||
|
|
||||||
|
if (!$conn){
|
||||||
|
//echo "fsockopen failed\n";
|
||||||
|
$smtp_error = "Couldn't connect to $host:$port<br>\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//read greeting
|
||||||
|
$greeting = smtp_get_response($conn, 1024);
|
||||||
|
|
||||||
|
// echo "Connected: $greeting<br>\n"; flush();
|
||||||
|
|
||||||
|
if (($auth_mode=="check") || ($auth_mode=="auth")){
|
||||||
|
// echo "Trying EHLO<br>\n"; flush();
|
||||||
|
$auth_modes = smtp_ehlo($conn, $_SERVER["SERVER_NAME"]);
|
||||||
|
// echo "smtp_ehlo returned: $auth_modes<br>\n"; flush();
|
||||||
|
if ($auth_modes===false){
|
||||||
|
$smtp_error = "EHLO failed\n";
|
||||||
|
$conn = false;
|
||||||
|
}else if (stristr($auth_modes, "LOGIN")!==false){
|
||||||
|
echo "trying AUTH LOGIN\n"; flush();
|
||||||
|
if (!smtp_auth_login($conn, $user, $pass)){
|
||||||
|
//echo "CONN: AUTH_LOGIN failed\n"; flush();
|
||||||
|
$conn = false;
|
||||||
|
}
|
||||||
|
//echo "Conn after LOGIN: $conn<br>\n"; flush();
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
fputs($conn, "HELO ".$_SERVER["SERVER_NAME"]."\r\n");
|
||||||
|
$line = smtp_get_response($conn, 1024);
|
||||||
|
if (!smtp_check_reply($line)){
|
||||||
|
$conn = false;
|
||||||
|
$smtp_error .= $line."\n";
|
||||||
|
}
|
||||||
|
// echo "after HELO: $conn<br>\n"; flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $conn;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function smtp_close($conn){
|
||||||
|
fclose($conn);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function smtp_mail($conn, $from, $recipients, $message, $is_file){
|
||||||
|
global $smtp_errornum;
|
||||||
|
global $smtp_error;
|
||||||
|
global $SMTP_DATA_REPLY;
|
||||||
|
|
||||||
|
//check recipients and sender addresses
|
||||||
|
if ((count($recipients)==0) || (!is_array($recipients))){
|
||||||
|
$smtp_errornum = -1;
|
||||||
|
$smtp_error .= "Recipients list is empty\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (empty($from)){
|
||||||
|
$smtp_errornum = -2;
|
||||||
|
$smtp_error .= "From address unspecified\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$conn){
|
||||||
|
$smtp_errornum = -3;
|
||||||
|
$smtp_error .= "Invalid connection\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ereg("^<", $from)) $from = "<".$from;
|
||||||
|
if (!ereg(">$", $from)) $from = $from.">";
|
||||||
|
|
||||||
|
//send MAIL FROM command
|
||||||
|
$command = "MAIL FROM: $from\r\n";
|
||||||
|
// echo nl2br(htmlspecialchars($command));
|
||||||
|
fputs($conn, $command);
|
||||||
|
|
||||||
|
if (smtp_check_reply(smtp_get_response($conn, 1024))){
|
||||||
|
//send RCPT TO commands, count valid recipients
|
||||||
|
$num_recipients = 0;
|
||||||
|
while ( list($k, $recipient) = each($recipients) ){
|
||||||
|
$command = "RCPT TO: $recipient\r\n";
|
||||||
|
fputs($conn, $command);
|
||||||
|
$reply = smtp_check_reply(smtp_get_response($conn, 1024));
|
||||||
|
if ($reply) $num_recipients++;
|
||||||
|
else $smtp_error .= $reply."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
//error out if no valid recipiets
|
||||||
|
if ($num_recipients == 0){
|
||||||
|
$smtp_errornum = -1;
|
||||||
|
$smtp_error .= "No valid recipients\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//send DATA command
|
||||||
|
fputs($conn, "DATA\r\n");
|
||||||
|
$reply = chop(smtp_get_response($conn, 1024));
|
||||||
|
$a = explode(" ", $reply);
|
||||||
|
|
||||||
|
//error out if DATA command ill received
|
||||||
|
if ($a[0]!=$SMTP_DATA_REPLY){
|
||||||
|
$smtp_errornum = -4;
|
||||||
|
$smtp_error .= $reply;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//send data
|
||||||
|
if ($is_file){
|
||||||
|
//if message file, open file
|
||||||
|
$fp = false;
|
||||||
|
if (file_exists(realpath($message))) $fp = fopen($message, "rb");
|
||||||
|
if (!$fp)
|
||||||
|
{
|
||||||
|
$smtp_errornum = -4;
|
||||||
|
$smtp_error .= "Invlid message file\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//send file
|
||||||
|
while(!feof($fp)){
|
||||||
|
$buffer = chop(fgets($fp, 4096), "\r\n");
|
||||||
|
fputs($conn, $buffer."\r\n");
|
||||||
|
}
|
||||||
|
fclose($fp);
|
||||||
|
fputs($conn, "\r\n.\r\n");
|
||||||
|
|
||||||
|
return smtp_check_reply(smtp_get_response($conn, 1024));
|
||||||
|
}else{
|
||||||
|
//else, send message
|
||||||
|
$message = str_replace("\r\n", "\n", $message);
|
||||||
|
$message = str_replace("\n", "\r\n", $message);
|
||||||
|
$message = str_replace("\r\n.\r\n", "\r\n..\r\n", $message);
|
||||||
|
fputs($conn, $message);
|
||||||
|
fputs($conn, "\r\n.\r\n");
|
||||||
|
|
||||||
|
return smtp_check_reply(smtp_get_response($conn, 1024));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function smtp_ExplodeQuotedString($delimiter, $string){
|
||||||
|
$quotes=explode("\"", $string);
|
||||||
|
while ( list($key, $val) = each($quotes))
|
||||||
|
if (($key % 2) == 1)
|
||||||
|
$quotes[$key] = str_replace($delimiter, "_!@!_", $quotes[$key]);
|
||||||
|
$string=implode("\"", $quotes);
|
||||||
|
|
||||||
|
$result=explode($delimiter, $string);
|
||||||
|
while ( list($key, $val) = each($result) )
|
||||||
|
$result[$key] = str_replace("_!@!_", $delimiter, $result[$key]);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function smtp_expand($str){
|
||||||
|
$addresses = array();
|
||||||
|
$recipients = smtp_ExplodeQuotedString(",", $str);
|
||||||
|
reset($recipients);
|
||||||
|
while ( list($k, $recipient) = each($recipients) ){
|
||||||
|
$a = explode(" ", $recipient);
|
||||||
|
while ( list($k2, $word) = each($a) ){
|
||||||
|
if ((strpos($word, "@") > 0) && (strpos($word, "\"")===false)){
|
||||||
|
if (!ereg("^<", $word)) $word = "<".$word;
|
||||||
|
if (!ereg(">$", $word)) $word = $word.">";
|
||||||
|
if (in_array($word, $addresses)===false) array_push($addresses, $word);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $addresses;
|
||||||
|
}
|
||||||
|
?>
|
@ -0,0 +1,384 @@
|
|||||||
|
<?php
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// utf7.inc - Routines to encode bytes to UTF7 and decode UTF7 strings
|
||||||
|
//
|
||||||
|
// Copyright (C) 1999, 2002 Ziberex and Torben Rybner
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Version 1.01 2002-06-08 19:00
|
||||||
|
//
|
||||||
|
// - Adapted for use in IlohaMail (modified UTF-7 decoding)
|
||||||
|
// - Converted from C to PHP4
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Version 1.00 1999-09-03 19:00
|
||||||
|
//
|
||||||
|
// - Encodes bytes to UTF7 strings
|
||||||
|
// *OutString = '\0';
|
||||||
|
// StartBase64Encode();
|
||||||
|
// for (CP = InString; *CP; CP++)
|
||||||
|
// strcat(OutString, Base64Encode(*CP));
|
||||||
|
// strcat(OutString, StopBase64Encode());
|
||||||
|
// - Decodes Base64 strings to bytes
|
||||||
|
// StartBase64Decode();
|
||||||
|
// for (CP1 = InString, CP2 = OutString; *CP1 && (*CP1 != '='); CP1++)
|
||||||
|
// CP2 += Base64Decode(*CP1, CP2);
|
||||||
|
// StopBase64Decode();
|
||||||
|
//
|
||||||
|
|
||||||
|
$BASE64LENGTH = 60;
|
||||||
|
|
||||||
|
$BASE64DECODE_NO_DATA = -1;
|
||||||
|
$BASE64DECODE_EMPTY_DATA = -2;
|
||||||
|
$BASE64DECODE_INVALID_DATA = -3;
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Used for conversion to UTF7
|
||||||
|
//
|
||||||
|
$_ToUTF7 = array
|
||||||
|
(
|
||||||
|
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||||
|
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
|
||||||
|
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||||
|
'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', ','
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Used for conversion from UTF7
|
||||||
|
// (0x80 => Illegal, 0x40 => CR/LF)
|
||||||
|
//
|
||||||
|
$_FromUTF7 = array
|
||||||
|
(
|
||||||
|
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 00 - 07 - Ctrl -
|
||||||
|
0x80, 0x80, 0x40, 0x80, 0x80, 0x40, 0x80, 0x80, // 08 - 0F - Ctrl -
|
||||||
|
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 10 - 17 - Ctrl -
|
||||||
|
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 18 - 1F - Ctrl -
|
||||||
|
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 20 - 27 !"#$%&'
|
||||||
|
0x80, 0x80, 0x80, 0x3E, 0x3F, 0x80, 0x80, 0x3F, // 28 - 2F ()*+,-./
|
||||||
|
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, // 30 - 37 01234567
|
||||||
|
0x3C, 0x3D, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, // 38 - 3F 89:;<=>?
|
||||||
|
0x80, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // 40 - 47 @ABCDEFG
|
||||||
|
0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, // 48 - 4F HIJKLMNO
|
||||||
|
0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, // 50 - 57 PQRSTUVW
|
||||||
|
0x17, 0x18, 0x19, 0x80, 0x80, 0x80, 0x80, 0x80, // 58 - 5F XYZ[\]^_
|
||||||
|
0x80, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, // 60 - 67 `abcdefg
|
||||||
|
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, // 68 - 6F hijklmno
|
||||||
|
0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, // 70 - 77 pqrstuvw
|
||||||
|
0x31, 0x32, 0x33, 0x80, 0x80, 0x80, 0x80, 0x80, // 78 - 7F xyz{|}~
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// UTF7EncodeInit:
|
||||||
|
//
|
||||||
|
// Start the encoding of bytes
|
||||||
|
//
|
||||||
|
function UTF7EncodeInit(&$Context)
|
||||||
|
{
|
||||||
|
$Context[ "Data" ] = "";
|
||||||
|
$Context[ "Count" ] = 0;
|
||||||
|
$Context[ "Pos" ] = 0;
|
||||||
|
$Context[ "State" ] = 0;
|
||||||
|
} // UTF7EncodeInit
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// UTF7EncodeByte:
|
||||||
|
//
|
||||||
|
// Encodes one byte to UTF7
|
||||||
|
//
|
||||||
|
function UTF7EncodeByte(&$Context, $Byte)
|
||||||
|
{
|
||||||
|
global $_ToUTF7;
|
||||||
|
|
||||||
|
$Byte = ord($Byte);
|
||||||
|
switch ($Context[ "State" ])
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
// Convert into a byte
|
||||||
|
$Context[ "Data" ] = $_ToUTF7[ $Byte >> 2 ];
|
||||||
|
$Context[ "Pos" ]++;
|
||||||
|
// Save residue for next converted byte
|
||||||
|
$Context[ "Residue" ] = ($Byte & 0x03) << 4;
|
||||||
|
// This is the first byte in this line
|
||||||
|
$Context[ "Count" ] = 1;
|
||||||
|
// Next state is 1
|
||||||
|
$Context[ "State" ] = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
// Convert into a byte
|
||||||
|
$Context[ "Data" ] .= $_ToUTF7[ $Context[ "Residue" ] | ($Byte >> 4) ];
|
||||||
|
$Context[ "Pos" ]++;
|
||||||
|
// Save residue for next converted byte
|
||||||
|
$Context[ "Residue" ] = ($Byte & 0x0F) << 2;
|
||||||
|
// Bumb byte counter
|
||||||
|
$Context[ "Count" ]++;
|
||||||
|
// Next state is 2
|
||||||
|
$Context[ "State" ] = 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
// Convert into a byte
|
||||||
|
$Context[ "Data" ] .= $_ToUTF7[ $Context[ "Residue" ] | ($Byte >> 6) ];
|
||||||
|
$Context[ "Pos" ]++;
|
||||||
|
// Residue fits precisely into the next byte
|
||||||
|
$Context[ "Data" ] .= $_ToUTF7[ $Byte & 0x3F ];
|
||||||
|
$Context[ "Pos" ]++;
|
||||||
|
// Bumb byte counter
|
||||||
|
$Context[ "Count" ]++;
|
||||||
|
// Next state is 3
|
||||||
|
$Context[ "State" ] = 3;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
// Convert into a byte
|
||||||
|
$Context[ "Data" ] .= $_ToUTF7[ $Byte >> 2 ];
|
||||||
|
$Context[ "Pos" ]++;
|
||||||
|
// Save residue for next converted byte
|
||||||
|
$Context[ "Residue" ] = ($Byte & 0x03) << 4;
|
||||||
|
// Bumb byte counter
|
||||||
|
$Context[ "Count" ]++;
|
||||||
|
// Next state is 1
|
||||||
|
$Context[ "State" ] = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// printf("Internal error in UTF7Encode: State is %d\n", $Context[ "State" ]);
|
||||||
|
// exit(1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} // UTF7EncodeByte
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// UTF7EncodeFinal:
|
||||||
|
//
|
||||||
|
// Terminates the encoding of bytes
|
||||||
|
//
|
||||||
|
function UTF7EncodeFinal(&$Context)
|
||||||
|
{
|
||||||
|
if ($Context[ "State" ] == 0)
|
||||||
|
return "";
|
||||||
|
if ($Context[ "State" ] != 3)
|
||||||
|
UTF7EncodeByte($Context, "\0");
|
||||||
|
return $Context[ "Data" ];
|
||||||
|
} // UTF7EncodeFinal
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// UTF7EncodeString
|
||||||
|
//
|
||||||
|
// Encodes a string to modified UTF-7 format
|
||||||
|
//
|
||||||
|
function UTF7EncodeString($String)
|
||||||
|
{
|
||||||
|
// Not during encoding, yet
|
||||||
|
$Encoding = false;
|
||||||
|
// Go through the string
|
||||||
|
for ($I = 0; $I < strlen($String); $I++)
|
||||||
|
{
|
||||||
|
$Ch = substr($String, $I, 1);
|
||||||
|
if (ord($Ch) > 0x7F)
|
||||||
|
{
|
||||||
|
if (! $Encoding)
|
||||||
|
{
|
||||||
|
$RetVal .= "&";
|
||||||
|
$Encoding = true;
|
||||||
|
// Initialise UTF7 context
|
||||||
|
UTF7EncodeInit($Context);
|
||||||
|
}
|
||||||
|
UTF7EncodeByte($Context, "\0");
|
||||||
|
UTF7EncodeByte($Context, $Ch);
|
||||||
|
}
|
||||||
|
elseif ($Ch == "&")
|
||||||
|
{
|
||||||
|
if (! $Encoding)
|
||||||
|
{
|
||||||
|
$RetVal .= "&";
|
||||||
|
$Encoding = true;
|
||||||
|
// Initialise UTF7 context
|
||||||
|
UTF7EncodeInit($Context);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UTF7EncodeByte($Context, "\0");
|
||||||
|
UTF7EncodeByte($Context, $Ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($Encoding)
|
||||||
|
{
|
||||||
|
$RetVal .= UTF7EncodeFinal($Context) . "-$Ch";
|
||||||
|
$Encoding = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$RetVal .= $Ch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($Encoding)
|
||||||
|
$RetVal .= UTF7EncodeFinal($Context) . "-";
|
||||||
|
return $RetVal;
|
||||||
|
} // UTF7EncodeString
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// UTF7DecodeInit:
|
||||||
|
//
|
||||||
|
// Start the decoding of bytes
|
||||||
|
//
|
||||||
|
function UTF7DecodeInit(&$Context)
|
||||||
|
{
|
||||||
|
$Context[ "Data" ] = "";
|
||||||
|
$Context[ "State" ] = 0;
|
||||||
|
$Context[ "Pos" ] = 0;
|
||||||
|
} // UTF7DecodeInit
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// UTF7DecodeByte:
|
||||||
|
//
|
||||||
|
// Decodes one character from UTF7
|
||||||
|
//
|
||||||
|
function UTF7DecodeByte(&$Context, $Byte)
|
||||||
|
{
|
||||||
|
global $BASE64DECODE_INVALID_DATA;
|
||||||
|
global $_FromUTF7;
|
||||||
|
|
||||||
|
// Restore bits
|
||||||
|
$Byte = $_FromUTF7[ ord($Byte) ];
|
||||||
|
// Ignore carriage returns and linefeeds
|
||||||
|
if ($Byte == 0x40)
|
||||||
|
return "";
|
||||||
|
// Invalid byte - Tell caller!
|
||||||
|
if ($Byte == 0x80)
|
||||||
|
$Context[ "Count" ] = $BASE64DECODE_INVALID_DATA;
|
||||||
|
switch ($Context[ "State" ])
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
// Save residue
|
||||||
|
$Context[ "Residue" ] = $Byte;
|
||||||
|
// Initialise count
|
||||||
|
$Context[ "Count" ] = 0;
|
||||||
|
// Next state
|
||||||
|
$Context[ "State" ] = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
// Store byte
|
||||||
|
$Context[ "Data" ] .= chr(($Context[ "Residue" ] << 2) | ($Byte >> 4));
|
||||||
|
$Context[ "Pos" ]++;
|
||||||
|
// Update count
|
||||||
|
$Context[ "Count" ]++;
|
||||||
|
// Save residue
|
||||||
|
$Context[ "Residue" ] = $Byte;
|
||||||
|
// Next state
|
||||||
|
$Context[ "State" ] = 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
// Store byte
|
||||||
|
$Context[ "Data" ] .= chr(($Context[ "Residue" ] << 4) | ($Byte >> 2));
|
||||||
|
$Context[ "Pos" ]++;
|
||||||
|
// Update count
|
||||||
|
$Context[ "Count" ]++;
|
||||||
|
// Save residue
|
||||||
|
$Context[ "Residue" ] = $Byte;
|
||||||
|
// Next state
|
||||||
|
$Context[ "State" ] = 3;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
// Store byte
|
||||||
|
$Context[ "Data" ] .= chr(($Context[ "Residue" ] << 6) | $Byte);
|
||||||
|
$Context[ "Pos" ]++;
|
||||||
|
// Update count
|
||||||
|
$Context[ "Count" ]++;
|
||||||
|
// Next state
|
||||||
|
$Context[ "State" ] = 4;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
// Save residue
|
||||||
|
$Context[ "Residue" ] = $Byte;
|
||||||
|
// Next state
|
||||||
|
$Context[ "State" ] = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} // UTF7DecodeByte
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// UTF7DecodeFinal:
|
||||||
|
//
|
||||||
|
// Decodes one character from UTF7
|
||||||
|
//
|
||||||
|
function UTF7DecodeFinal(&$Context)
|
||||||
|
{
|
||||||
|
// Buffer not empty - Return remainder!
|
||||||
|
if ($Context[ "Count" ])
|
||||||
|
{
|
||||||
|
$Context[ "Pos" ] = 0;
|
||||||
|
$Context[ "State" ] = 0;
|
||||||
|
return $Context[ "Data" ];
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
} // UTF7DecodeFinal
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// UTF7DecodeString
|
||||||
|
//
|
||||||
|
// Converts a string encoded in modified UTF-7 encoding
|
||||||
|
// to ISO 8859-1.
|
||||||
|
// OBS: Works only for valid ISO 8859-1 characters in the
|
||||||
|
// encoded data
|
||||||
|
//
|
||||||
|
function UTF7DecodeString($String)
|
||||||
|
{
|
||||||
|
$Decoding = false;
|
||||||
|
for ($I = 0; $I < strlen($String); $I++)
|
||||||
|
{
|
||||||
|
$Ch = substr($String, $I, 1);
|
||||||
|
if ($Decoding)
|
||||||
|
{
|
||||||
|
if ($Ch == "-")
|
||||||
|
{
|
||||||
|
$RetVal .= UTF7DecodeFinal($Context);
|
||||||
|
$Decoding = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
UTF7DecodeByte($Context, $Ch);
|
||||||
|
}
|
||||||
|
elseif ($Ch == "&")
|
||||||
|
{
|
||||||
|
if (($I < strlen($String) - 1) && (substr($String, $I + 1, 1) == "-"))
|
||||||
|
{
|
||||||
|
$RetVal .= $Ch;
|
||||||
|
$I++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UTF7DecodeInit($Context);
|
||||||
|
$Decoding = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$RetVal .= $Ch;
|
||||||
|
}
|
||||||
|
return str_replace("\0", "", $RetVal);
|
||||||
|
} // UTF7DecodeString
|
||||||
|
?>
|
@ -0,0 +1,102 @@
|
|||||||
|
<?php
|
||||||
|
/////////////////////////////
|
||||||
|
// utf8.inc
|
||||||
|
// (C)2002 Ryo Chijiiwa <Ryo@IlohaMail.org>
|
||||||
|
//
|
||||||
|
// Description:
|
||||||
|
// UTF-8 handling functions
|
||||||
|
//
|
||||||
|
// This file is part of IlohaMail. IlohaMail is free software released
|
||||||
|
// under the GPL license. See enclosed file COPYING for details, or
|
||||||
|
// see http://www.fsf.org/copyleft/gpl.html
|
||||||
|
////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* takes a string of utf-8 encoded characters and converts it to a string of unicode entities
|
||||||
|
* each unicode entitiy has the form &#nnnnn; n={0..9} and can be displayed by utf-8 supporting
|
||||||
|
* browsers
|
||||||
|
* @param $source string encoded using utf-8 [STRING]
|
||||||
|
* @return string of unicode entities [STRING]
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Author: ronen at greyzone dot com
|
||||||
|
* Taken from php.net comment:
|
||||||
|
* http://www.php.net/manual/en/function.utf8-decode.php
|
||||||
|
**/
|
||||||
|
function utf8ToUnicodeEntities ($source) {
|
||||||
|
// array used to figure what number to decrement from character order value
|
||||||
|
// according to number of characters used to map unicode to ascii by utf-8
|
||||||
|
$decrement[4] = 240;
|
||||||
|
$decrement[3] = 224;
|
||||||
|
$decrement[2] = 192;
|
||||||
|
$decrement[1] = 0;
|
||||||
|
|
||||||
|
// the number of bits to shift each charNum by
|
||||||
|
$shift[1][0] = 0;
|
||||||
|
$shift[2][0] = 6;
|
||||||
|
$shift[2][1] = 0;
|
||||||
|
$shift[3][0] = 12;
|
||||||
|
$shift[3][1] = 6;
|
||||||
|
$shift[3][2] = 0;
|
||||||
|
$shift[4][0] = 18;
|
||||||
|
$shift[4][1] = 12;
|
||||||
|
$shift[4][2] = 6;
|
||||||
|
$shift[4][3] = 0;
|
||||||
|
|
||||||
|
$pos = 0;
|
||||||
|
$len = strlen ($source);
|
||||||
|
$encodedString = '';
|
||||||
|
while ($pos < $len) {
|
||||||
|
$asciiPos = ord (substr ($source, $pos, 1));
|
||||||
|
if (($asciiPos >= 240) && ($asciiPos <= 255)) {
|
||||||
|
// 4 chars representing one unicode character
|
||||||
|
$thisLetter = substr ($source, $pos, 4);
|
||||||
|
$pos += 4;
|
||||||
|
}
|
||||||
|
else if (($asciiPos >= 224) && ($asciiPos <= 239)) {
|
||||||
|
// 3 chars representing one unicode character
|
||||||
|
$thisLetter = substr ($source, $pos, 3);
|
||||||
|
$pos += 3;
|
||||||
|
}
|
||||||
|
else if (($asciiPos >= 192) && ($asciiPos <= 223)) {
|
||||||
|
// 2 chars representing one unicode character
|
||||||
|
$thisLetter = substr ($source, $pos, 2);
|
||||||
|
$pos += 2;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// 1 char (lower ascii)
|
||||||
|
$thisLetter = substr ($source, $pos, 1);
|
||||||
|
$pos += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// process the string representing the letter to a unicode entity
|
||||||
|
$thisLen = strlen ($thisLetter);
|
||||||
|
$thisPos = 0;
|
||||||
|
$decimalCode = 0;
|
||||||
|
while ($thisPos < $thisLen) {
|
||||||
|
$thisCharOrd = ord (substr ($thisLetter, $thisPos, 1));
|
||||||
|
if ($thisPos == 0) {
|
||||||
|
$charNum = intval ($thisCharOrd - $decrement[$thisLen]);
|
||||||
|
$decimalCode += ($charNum << $shift[$thisLen][$thisPos]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$charNum = intval ($thisCharOrd - 128);
|
||||||
|
$decimalCode += ($charNum << $shift[$thisLen][$thisPos]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$thisPos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($thisLen == 1)
|
||||||
|
$encodedLetter = "&#". str_pad($decimalCode, 3, "0", STR_PAD_LEFT) . ';';
|
||||||
|
else
|
||||||
|
$encodedLetter = "&#". str_pad($decimalCode, 5, "0", STR_PAD_LEFT) . ';';
|
||||||
|
|
||||||
|
$encodedString .= $encodedLetter;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $encodedString;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,171 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| language/de/labels.inc |
|
||||||
|
| |
|
||||||
|
| Language file of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundQube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$labels = array();
|
||||||
|
|
||||||
|
// login page
|
||||||
|
$labels['username'] = 'Benutzername';
|
||||||
|
$labels['password'] = 'Passwort';
|
||||||
|
$labels['server'] = 'Server';
|
||||||
|
$labels['login'] = 'Login';
|
||||||
|
|
||||||
|
// taskbar
|
||||||
|
$labels['logout'] = 'Logout';
|
||||||
|
$labels['mail'] = 'E-Mail';
|
||||||
|
$labels['settings'] = 'Einstellungen';
|
||||||
|
$labels['addressbook'] = 'Adressbuch';
|
||||||
|
|
||||||
|
// mailbox names
|
||||||
|
$labels['inbox'] = 'Posteingang';
|
||||||
|
$labels['sent'] = 'Gesendet';
|
||||||
|
$labels['trash'] = 'Gelöscht';
|
||||||
|
$labels['drafts'] = 'Vorlagen';
|
||||||
|
$labels['junk'] = 'Junk';
|
||||||
|
|
||||||
|
// message listing
|
||||||
|
$labels['subject'] = 'Betreff';
|
||||||
|
$labels['from'] = 'Absender';
|
||||||
|
$labels['to'] = 'Empfänger';
|
||||||
|
$labels['cc'] = 'Kopie';
|
||||||
|
$labels['bcc'] = 'Bcc';
|
||||||
|
$labels['replyto'] = 'Antwort an';
|
||||||
|
$labels['date'] = 'Datum';
|
||||||
|
$labels['size'] = 'Grösse';
|
||||||
|
$labels['priority'] = 'Priorität';
|
||||||
|
$labels['organization'] = 'Organisation';
|
||||||
|
|
||||||
|
// aliases
|
||||||
|
$labels['reply-to'] = $labels['replyto'];
|
||||||
|
|
||||||
|
$labels['mailboxlist'] = 'Ordner';
|
||||||
|
$labels['messagesfromto'] = 'Nachrichten $from bis $to von $count';
|
||||||
|
$labels['messagenrof'] = 'Nachrichten $nr von $count';
|
||||||
|
|
||||||
|
$labels['moveto'] = 'verschieben nach...';
|
||||||
|
$labels['download'] = 'download';
|
||||||
|
|
||||||
|
$labels['filename'] = 'Dateiname';
|
||||||
|
$labels['filesize'] = 'Dateigrösse';
|
||||||
|
|
||||||
|
$labels['preferhtml'] = 'HTML bevorzugen';
|
||||||
|
$labels['htmlmessage'] = 'HTML Nachricht';
|
||||||
|
|
||||||
|
$labels['addtoaddressbook'] = 'Ins Adressbuch übernehmen';
|
||||||
|
|
||||||
|
// weekdays short
|
||||||
|
$labels['sun'] = 'So';
|
||||||
|
$labels['mon'] = 'Mo';
|
||||||
|
$labels['tue'] = 'Di';
|
||||||
|
$labels['wed'] = 'Mi';
|
||||||
|
$labels['thu'] = 'Do';
|
||||||
|
$labels['fri'] = 'Fr';
|
||||||
|
$labels['sat'] = 'Sa';
|
||||||
|
|
||||||
|
// weekdays long
|
||||||
|
$labels['sunday'] = 'Sonntag';
|
||||||
|
$labels['monday'] = 'Montag';
|
||||||
|
$labels['tuesday'] = 'Dienstag';
|
||||||
|
$labels['wednesday'] = 'Mittwoch';
|
||||||
|
$labels['thursday'] = 'Donnerstag';
|
||||||
|
$labels['friday'] = 'Freitag';
|
||||||
|
$labels['saturday'] = 'Samstag';
|
||||||
|
|
||||||
|
$labels['today'] = 'Heute';
|
||||||
|
|
||||||
|
// toolbar buttons
|
||||||
|
$labels['writenewmessage'] = 'Neue Nachricht schreiben';
|
||||||
|
$labels['replytomessage'] = 'Antwort verfassen';
|
||||||
|
$labels['forwardmessage'] = 'Nachricht weiterleiten';
|
||||||
|
$labels['deletemessage'] = 'In den Papierkorb verschieben';
|
||||||
|
$labels['printmessage'] = 'Diese Nachricht drucken';
|
||||||
|
$labels['previousmessages'] = 'Vorherige Nachrichten anzeigen';
|
||||||
|
$labels['nextmessages'] = 'Weitere Nachrichten anzeigen';
|
||||||
|
$labels['backtolist'] = 'Zurück zur Liste';
|
||||||
|
|
||||||
|
$labels['select'] = 'Auswählen';
|
||||||
|
$labels['all'] = 'Alle';
|
||||||
|
$labels['none'] = 'Keine';
|
||||||
|
$labels['unread'] = 'Ungelesene';
|
||||||
|
|
||||||
|
// message compose
|
||||||
|
$labels['compose'] = 'Neue Nachricht verfassen';
|
||||||
|
$labels['sendmessage'] = 'Nachricht jetzt senden';
|
||||||
|
$labels['addattachment'] = 'Datei anfügen';
|
||||||
|
|
||||||
|
$labels['upload'] = 'Hochladen';
|
||||||
|
$labels['close'] = 'Schliessen';
|
||||||
|
|
||||||
|
$labels['low'] = 'Tief';
|
||||||
|
$labels['lowest'] = 'Tiefste';
|
||||||
|
$labels['normal'] = 'Normal';
|
||||||
|
$labels['high'] = 'Hoch';
|
||||||
|
$labels['highest'] = 'Höchste';
|
||||||
|
|
||||||
|
$labels['showimages'] = 'Bilder anzeigen';
|
||||||
|
|
||||||
|
|
||||||
|
// address boook
|
||||||
|
$labels['name'] = 'Anzeigename';
|
||||||
|
$labels['firstname'] = 'Vorname';
|
||||||
|
$labels['surname'] = 'Nachname';
|
||||||
|
$labels['email'] = 'E-Mail';
|
||||||
|
|
||||||
|
$labels['addcontact'] = 'Kontakt hinzufügen';
|
||||||
|
$labels['editcontact'] = 'Kontakt bearbeiten';
|
||||||
|
|
||||||
|
$labels['edit'] = 'Bearbeiten';
|
||||||
|
$labels['cancel'] = 'Abbrechen';
|
||||||
|
$labels['save'] = 'Speichern';
|
||||||
|
$labels['delete'] = 'Löschen';
|
||||||
|
|
||||||
|
$labels['newcontact'] = 'Neuen Kontakt erfassen';
|
||||||
|
$labels['deletecontact'] = 'Gewählte Kontakte löschen';
|
||||||
|
$labels['composeto'] = 'Nachricht verfassen';
|
||||||
|
$labels['contactsfromto'] = 'Kontakte $from bis $to von $count';
|
||||||
|
|
||||||
|
|
||||||
|
// settings
|
||||||
|
$labels['settingsfor'] = 'Einstellungen für';
|
||||||
|
|
||||||
|
$labels['preferences'] = 'Einstellungen';
|
||||||
|
$labels['userpreferences'] = 'Benutzereinstellungen';
|
||||||
|
$labels['editpreferences'] = 'Ereinstellungen bearbeiten';
|
||||||
|
|
||||||
|
$labels['identities'] = 'Absender';
|
||||||
|
$labels['manageidentities'] = 'Absender für dieses Konto verwalten';
|
||||||
|
$labels['newidentity'] = 'Neuer Absender';
|
||||||
|
|
||||||
|
$labels['newitem'] = 'Neuer Eintrag';
|
||||||
|
$labels['edititem'] = 'Eintrag bearbeiten';
|
||||||
|
|
||||||
|
$labels['setdefault'] = 'Als Standard';
|
||||||
|
$labels['language'] = 'Sprache';
|
||||||
|
$labels['timezone'] = 'Zeitzone';
|
||||||
|
$labels['pagesize'] = 'Einträge pro Seite';
|
||||||
|
|
||||||
|
|
||||||
|
$labels['folders'] = 'Ordner';
|
||||||
|
$labels['foldername'] = 'Ordnername';
|
||||||
|
$labels['subscribed'] = 'Abonniert';
|
||||||
|
$labels['create'] = 'Erstellen';
|
||||||
|
$labels['createfolder'] = 'Neuen Ordner erstellen';
|
||||||
|
$labels['deletefolder'] = 'Ordner löschen';
|
||||||
|
$labels['managefolders'] = 'Ordner verwalten';
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| language/de/messages.inc |
|
||||||
|
| |
|
||||||
|
| Language file of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$messages = array();
|
||||||
|
|
||||||
|
$messages['loginfailed'] = 'Login fehlgeschlagen';
|
||||||
|
|
||||||
|
$messages['cookiesdisabled'] = 'Ihr Browser akzeptiert keine Cookies';
|
||||||
|
|
||||||
|
$messages['sessionerror'] = 'Ihre Session ist ungültig oder abgelaufen';
|
||||||
|
|
||||||
|
$messages['imaperror'] = 'Keine Verbindung zum IMAP server';
|
||||||
|
|
||||||
|
$messages['nomessagesfound'] = 'Keine Nachrichten in diesem Order';
|
||||||
|
|
||||||
|
$messages['loggedout'] = 'Sie haben Ihre Session erfolgreich beendeet. Auf Wiedersehen!';
|
||||||
|
|
||||||
|
$messages['mailboxempty'] = 'Ordner ist leer';
|
||||||
|
|
||||||
|
$messages['loadingdata'] = 'Daten werden geladen...';
|
||||||
|
|
||||||
|
$messages['messagesent'] = 'Nachricht erfolgreich gesendet';
|
||||||
|
|
||||||
|
$messages['successfullysaved'] = 'Erfolgreich gespeichert';
|
||||||
|
|
||||||
|
$messages['addedsuccessfully'] = 'Kontakt zum Adressbuch hinzugefügt';
|
||||||
|
|
||||||
|
$messages['contactexists'] = 'Es existiert bereits ein Eintrag mit dieser E-Mail-Adresse';
|
||||||
|
|
||||||
|
$messages['blockedimages'] = 'Um Ihre Privatsphäre zur schützen, wurden externe Bilder blockiert.';
|
||||||
|
|
||||||
|
$messages['encryptedmessage'] = 'Dies ist eine verschlüsselte Nachricht und kann leider nicht angezeigt werden.';
|
||||||
|
|
||||||
|
$messages['nocontactsfound'] = 'Keine Kontakte gefunden';
|
||||||
|
|
||||||
|
$messages['sendingfailed'] = 'Versand der Nachricht fehlgeschlagen';
|
||||||
|
|
||||||
|
$messages['errorsaving'] = 'Beim Speichern ist ein Fehler aufgetreten';
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,171 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| language/en/labels.inc |
|
||||||
|
| |
|
||||||
|
| Language file of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundQube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$labels = array();
|
||||||
|
|
||||||
|
// login page
|
||||||
|
$labels['username'] = 'Username';
|
||||||
|
$labels['password'] = 'Password';
|
||||||
|
$labels['server'] = 'Server';
|
||||||
|
$labels['login'] = 'Login';
|
||||||
|
|
||||||
|
// taskbar
|
||||||
|
$labels['logout'] = 'Logout';
|
||||||
|
$labels['mail'] = 'E-Mail';
|
||||||
|
$labels['settings'] = 'Personal Settings';
|
||||||
|
$labels['addressbook'] = 'Address Book';
|
||||||
|
|
||||||
|
// mailbox names
|
||||||
|
$labels['inbox'] = 'Inbox';
|
||||||
|
$labels['sent'] = 'Sent';
|
||||||
|
$labels['trash'] = 'Trash';
|
||||||
|
$labels['drafts'] = 'Drafts';
|
||||||
|
$labels['junk'] = 'Junk';
|
||||||
|
|
||||||
|
// message listing
|
||||||
|
$labels['subject'] = 'Subject';
|
||||||
|
$labels['from'] = 'Sender';
|
||||||
|
$labels['to'] = 'Recipient';
|
||||||
|
$labels['cc'] = 'Copy';
|
||||||
|
$labels['bcc'] = 'Bcc';
|
||||||
|
$labels['replyto'] = 'Reply-To';
|
||||||
|
$labels['date'] = 'Date';
|
||||||
|
$labels['size'] = 'Size';
|
||||||
|
$labels['priority'] = 'Priority';
|
||||||
|
$labels['organization'] = 'Organization';
|
||||||
|
|
||||||
|
// aliases
|
||||||
|
$labels['reply-to'] = $labels['replyto'];
|
||||||
|
|
||||||
|
$labels['mailboxlist'] = 'Folders';
|
||||||
|
$labels['messagesfromto'] = 'Messages $from to $to of $count';
|
||||||
|
$labels['messagenrof'] = 'Message $nr of $count';
|
||||||
|
|
||||||
|
$labels['moveto'] = 'move to...';
|
||||||
|
$labels['download'] = 'download';
|
||||||
|
|
||||||
|
$labels['filename'] = 'File name';
|
||||||
|
$labels['filesize'] = 'File size';
|
||||||
|
|
||||||
|
$labels['preferhtml'] = 'Prefer HTML';
|
||||||
|
$labels['htmlmessage'] = 'HTML Message';
|
||||||
|
|
||||||
|
$labels['addtoaddressbook'] = 'Add to address book';
|
||||||
|
|
||||||
|
// weekdays short
|
||||||
|
$labels['sun'] = 'Sun';
|
||||||
|
$labels['mon'] = 'Mon';
|
||||||
|
$labels['tue'] = 'Tue';
|
||||||
|
$labels['wed'] = 'Wed';
|
||||||
|
$labels['thu'] = 'Thu';
|
||||||
|
$labels['fri'] = 'Fri';
|
||||||
|
$labels['sat'] = 'Sat';
|
||||||
|
|
||||||
|
// weekdays long
|
||||||
|
$labels['sunday'] = 'Sunday';
|
||||||
|
$labels['monday'] = 'Monday';
|
||||||
|
$labels['tuesday'] = 'Tuesday';
|
||||||
|
$labels['wednesday'] = 'Wednesday';
|
||||||
|
$labels['thursday'] = 'Thursday';
|
||||||
|
$labels['friday'] = 'Friday';
|
||||||
|
$labels['saturday'] = 'Saturday';
|
||||||
|
|
||||||
|
$labels['today'] = 'Today';
|
||||||
|
|
||||||
|
// toolbar buttons
|
||||||
|
$labels['writenewmessage'] = 'Create a new message';
|
||||||
|
$labels['replytomessage'] = 'Reply to the message';
|
||||||
|
$labels['forwardmessage'] = 'Forwad the message';
|
||||||
|
$labels['deletemessage'] = 'Move message to trash';
|
||||||
|
$labels['printmessage'] = 'Print this message';
|
||||||
|
$labels['previousmessages'] = 'Show previous set of messages';
|
||||||
|
$labels['nextmessages'] = 'Show next set of messages';
|
||||||
|
$labels['backtolist'] = 'Back to message list';
|
||||||
|
|
||||||
|
$labels['select'] = 'Select';
|
||||||
|
$labels['all'] = 'All';
|
||||||
|
$labels['none'] = 'None';
|
||||||
|
$labels['unread'] = 'Unread';
|
||||||
|
|
||||||
|
// message compose
|
||||||
|
$labels['compose'] = 'Compose a message';
|
||||||
|
$labels['sendmessage'] = 'Send the message now';
|
||||||
|
$labels['addattachment'] = 'Attach a file';
|
||||||
|
|
||||||
|
$labels['upload'] = 'Upload';
|
||||||
|
$labels['close'] = 'Close';
|
||||||
|
|
||||||
|
$labels['low'] = 'Low';
|
||||||
|
$labels['lowest'] = 'Lowest';
|
||||||
|
$labels['normal'] = 'Normal';
|
||||||
|
$labels['high'] = 'High';
|
||||||
|
$labels['highest'] = 'Highest';
|
||||||
|
|
||||||
|
$labels['showimages'] = 'Display images';
|
||||||
|
|
||||||
|
|
||||||
|
// address boook
|
||||||
|
$labels['name'] = 'Display name';
|
||||||
|
$labels['firstname'] = 'First name';
|
||||||
|
$labels['surname'] = 'Last name';
|
||||||
|
$labels['email'] = 'E-Mail';
|
||||||
|
|
||||||
|
$labels['addcontact'] = 'Add new contact';
|
||||||
|
$labels['editcontact'] = 'Edit contact';
|
||||||
|
|
||||||
|
$labels['edit'] = 'Edit';
|
||||||
|
$labels['cancel'] = 'Cancel';
|
||||||
|
$labels['save'] = 'Save';
|
||||||
|
$labels['delete'] = 'Delete';
|
||||||
|
|
||||||
|
$labels['newcontact'] = 'Create new contact card';
|
||||||
|
$labels['deletecontact'] = 'Delete selected contacts';
|
||||||
|
$labels['composeto'] = 'Compose mail to';
|
||||||
|
$labels['contactsfromto'] = 'Contacts $from to $to of $count';
|
||||||
|
|
||||||
|
|
||||||
|
// settings
|
||||||
|
$labels['settingsfor'] = 'Settings for';
|
||||||
|
|
||||||
|
$labels['preferences'] = 'Preferences';
|
||||||
|
$labels['userpreferences'] = 'User preferences';
|
||||||
|
$labels['editpreferences'] = 'Edit user preferences';
|
||||||
|
|
||||||
|
$labels['identities'] = 'Identities';
|
||||||
|
$labels['manageidentities'] = 'Manage identities for this account';
|
||||||
|
$labels['newidentity'] = 'New identity';
|
||||||
|
|
||||||
|
$labels['newitem'] = 'New item';
|
||||||
|
$labels['edititem'] = 'Edit item';
|
||||||
|
|
||||||
|
$labels['setdefault'] = 'Set default';
|
||||||
|
$labels['language'] = 'Language';
|
||||||
|
$labels['timezone'] = 'Time zone';
|
||||||
|
$labels['pagesize'] = 'Rows per page';
|
||||||
|
|
||||||
|
|
||||||
|
$labels['folders'] = 'Folders';
|
||||||
|
$labels['foldername'] = 'Folder name';
|
||||||
|
$labels['subscribed'] = 'Subscribed';
|
||||||
|
$labels['create'] = 'Create';
|
||||||
|
$labels['createfolder'] = 'Create new folder';
|
||||||
|
$labels['deletefolder'] = 'Delete folder';
|
||||||
|
$labels['managefolders'] = 'Manage folders';
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| language/en/messages.inc |
|
||||||
|
| |
|
||||||
|
| Language file of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$messages = array();
|
||||||
|
|
||||||
|
$messages['loginfailed'] = 'Login failed';
|
||||||
|
|
||||||
|
$messages['cookiesdisabled'] = 'Your browser does not accept cookies';
|
||||||
|
|
||||||
|
$messages['sessionerror'] = 'Your session is invalid or expired';
|
||||||
|
|
||||||
|
$messages['imaperror'] = 'Connection to IMAP server failed';
|
||||||
|
|
||||||
|
$messages['nomessagesfound'] = 'No messages found in this mailbox';
|
||||||
|
|
||||||
|
$messages['loggedout'] = 'You have successfully terminated the session. Goody bye!';
|
||||||
|
|
||||||
|
$messages['mailboxempty'] = 'Mailbox is empty';
|
||||||
|
|
||||||
|
$messages['loadingdata'] = 'Loading data...';
|
||||||
|
|
||||||
|
$messages['messagesent'] = 'Message sent successfully';
|
||||||
|
|
||||||
|
$messages['successfullysaved'] = 'Successfully saved';
|
||||||
|
|
||||||
|
$messages['addedsuccessfully'] = 'Contact added successfully to address book';
|
||||||
|
|
||||||
|
$messages['contactexists'] = 'A contact with this e-mail address already exists';
|
||||||
|
|
||||||
|
$messages['blockedimages'] = 'To protect your privacy, remote images are blocked in this message.';
|
||||||
|
|
||||||
|
$messages['encryptedmessage'] = 'This is an encrypted message and can not be displayed. Sorry!';
|
||||||
|
|
||||||
|
$messages['nocontactsfound'] = 'No contacts found';
|
||||||
|
|
||||||
|
$messages['sendingfailed'] = 'Failed to send message';
|
||||||
|
|
||||||
|
$messages['errorsaving'] = 'An error occured while saving';
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,104 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/addressbook/delete.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Delete the submitted contacts (CIDs) from the users address book |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$REMOTE_REQUEST = TRUE;
|
||||||
|
|
||||||
|
if ($_GET['_cid'])
|
||||||
|
{
|
||||||
|
$DB->query(sprintf("UPDATE %s
|
||||||
|
SET del='1'
|
||||||
|
WHERE user_id=%d
|
||||||
|
AND contact_id IN (%s)",
|
||||||
|
get_table_name('contacts'),
|
||||||
|
$_SESSION['user_id'],
|
||||||
|
$_GET['_cid']));
|
||||||
|
|
||||||
|
$count = $DB->affected_rows();
|
||||||
|
if (!$count)
|
||||||
|
{
|
||||||
|
// send error message
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// count contacts for this user
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT COUNT(contact_id) AS rows
|
||||||
|
FROM %s
|
||||||
|
WHERE del!='1'
|
||||||
|
AND user_id=%d",
|
||||||
|
get_table_name('contacts'),
|
||||||
|
$_SESSION['user_id']));
|
||||||
|
|
||||||
|
$sql_arr = $DB->fetch_assoc($sql_result);
|
||||||
|
$rowcount = $sql_arr['rows'];
|
||||||
|
|
||||||
|
// update message count display
|
||||||
|
$pages = ceil($rowcount/$CONFIG['pagesize']);
|
||||||
|
$commands = sprintf("this.set_rowcount('%s');\n", rcmail_get_rowcount_text($rowcount));
|
||||||
|
$commands .= sprintf("this.set_env('pagecount', %d);\n", $pages);
|
||||||
|
|
||||||
|
|
||||||
|
// add new rows from next page (if any)
|
||||||
|
if ($_GET['_from']!='show' && $pages>1 && $_SESSION['page'] < $pages)
|
||||||
|
{
|
||||||
|
$start_row = ($_SESSION['page'] * $CONFIG['pagesize']) - $count;
|
||||||
|
|
||||||
|
// get contacts from DB
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT * FROM %s
|
||||||
|
WHERE del!='1'
|
||||||
|
AND user_id=%d
|
||||||
|
ORDER BY name
|
||||||
|
LIMIT %d, %d",
|
||||||
|
get_table_name('contacts'),
|
||||||
|
$_SESSION['user_id'],
|
||||||
|
$start_row,
|
||||||
|
$count));
|
||||||
|
|
||||||
|
$commands .= rcmail_js_contacts_list($sql_result);
|
||||||
|
|
||||||
|
/*
|
||||||
|
// define list of cols to be displayed
|
||||||
|
$a_show_cols = array('name', 'email');
|
||||||
|
|
||||||
|
while ($sql_arr = $DB->fetch_assoc($sql_result))
|
||||||
|
{
|
||||||
|
$a_row_cols = array();
|
||||||
|
|
||||||
|
// format each col
|
||||||
|
foreach ($a_show_cols as $col)
|
||||||
|
{
|
||||||
|
$cont = rep_specialchars_output($sql_arr[$col]);
|
||||||
|
$a_row_cols[$col] = $cont;
|
||||||
|
}
|
||||||
|
|
||||||
|
$commands .= sprintf("this.add_contact_row(%s, %s);\n",
|
||||||
|
$sql_arr['contact_id'],
|
||||||
|
array2js($a_row_cols));
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
// send response
|
||||||
|
rcube_remote_response($commands);
|
||||||
|
}
|
||||||
|
|
||||||
|
exit;
|
||||||
|
?>
|
@ -0,0 +1,123 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/addressbook/edit.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Show edit form for a contact entry or to add a new one |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
if (($_GET['_cid'] || $_POST['_cid']) && $_action=='edit')
|
||||||
|
{
|
||||||
|
$cid = $_POST['_cid'] ? $_POST['_cid'] : $_GET['_cid'];
|
||||||
|
$DB->query(sprintf("SELECT * FROM %s
|
||||||
|
WHERE contact_id=%d
|
||||||
|
AND user_id=%d
|
||||||
|
AND del!='1'",
|
||||||
|
get_table_name('contacts'),
|
||||||
|
$cid,
|
||||||
|
$_SESSION['user_id']));
|
||||||
|
|
||||||
|
$CONTACT_RECORD = $DB->fetch_assoc();
|
||||||
|
|
||||||
|
if (is_array($CONTACT_RECORD))
|
||||||
|
$OUTPUT->add_script(sprintf("%s.set_env('cid', '%s');", $JS_OBJECT_NAME, $CONTACT_RECORD['contact_id']));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function rcmail_contact_editform($attrib)
|
||||||
|
{
|
||||||
|
global $CONTACT_RECORD, $JS_OBJECT_NAME;
|
||||||
|
|
||||||
|
if (!$CONTACT_RECORD && $GLOBALS['_action']!='add')
|
||||||
|
return rcube_label('contactnotfound');
|
||||||
|
|
||||||
|
list($form_start, $form_end) = get_form_tags($attrib);
|
||||||
|
unset($attrib['form']);
|
||||||
|
|
||||||
|
|
||||||
|
// a specific part is requested
|
||||||
|
if ($attrib['part'])
|
||||||
|
{
|
||||||
|
$out = $form_start;
|
||||||
|
$out .= rcmail_get_edit_field($attrib['part'], $CONTACT_RECORD[$attrib['part']], $attrib);
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// return the complete address edit form as table
|
||||||
|
$out = "$form_start<table>\n\n";
|
||||||
|
|
||||||
|
$a_show_cols = array('name', 'firstname', 'surname', 'email');
|
||||||
|
foreach ($a_show_cols as $col)
|
||||||
|
{
|
||||||
|
$attrib['id'] = 'rcmfd_'.$col;
|
||||||
|
$title = rcube_label($col);
|
||||||
|
$value = rcmail_get_edit_field($col, $CONTACT_RECORD[$col], $attrib);
|
||||||
|
$out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
|
||||||
|
$attrib['id'],
|
||||||
|
$title,
|
||||||
|
$value);
|
||||||
|
}
|
||||||
|
|
||||||
|
$out .= "\n</table>$form_end";
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// similar function as in /steps/settings/edit_identity.inc
|
||||||
|
function get_form_tags($attrib)
|
||||||
|
{
|
||||||
|
global $CONTACT_RECORD, $OUTPUT, $JS_OBJECT_NAME, $EDIT_FORM, $SESS_HIDDEN_FIELD;
|
||||||
|
|
||||||
|
$form_start = '';
|
||||||
|
if (!strlen($EDIT_FORM))
|
||||||
|
{
|
||||||
|
$hiddenfields = new hiddenfield(array('name' => '_task', 'value' => $GLOBALS['_task']));
|
||||||
|
$hiddenfields->add(array('name' => '_action', 'value' => 'save'));
|
||||||
|
|
||||||
|
if ($_GET['_framed'] || $_POST['_framed'])
|
||||||
|
$hiddenfields->add(array('name' => '_framed', 'value' => 1));
|
||||||
|
|
||||||
|
if ($CONTACT_RECORD['contact_id'])
|
||||||
|
$hiddenfields->add(array('name' => '_cid', 'value' => $CONTACT_RECORD['contact_id']));
|
||||||
|
|
||||||
|
$form_start = !strlen($attrib['form']) ? '<form name="form" action="./" method="post">' : '';
|
||||||
|
$form_start .= "\n$SESS_HIDDEN_FIELD\n";
|
||||||
|
$form_start .= $hiddenfields->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
$form_end = (strlen($EDIT_FORM) && !strlen($attrib['form'])) ? '</form>' : '';
|
||||||
|
$form_name = strlen($attrib['form']) ? $attrib['form'] : 'form';
|
||||||
|
|
||||||
|
if (!strlen($EDIT_FORM))
|
||||||
|
$OUTPUT->add_script("$JS_OBJECT_NAME.gui_object('editform', '$form_name');");
|
||||||
|
|
||||||
|
$EDIT_FORM = $form_name;
|
||||||
|
|
||||||
|
return array($form_start, $form_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!$CONTACT_RECORD && template_exists('addcontact'))
|
||||||
|
parse_template('addcontact');
|
||||||
|
|
||||||
|
// this will be executed if no template for addcontact exists
|
||||||
|
parse_template('editcontact');
|
||||||
|
?>
|
@ -0,0 +1,198 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/addressbook/func.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Provide addressbook functionality and GUI objects |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$CONTACTS_LIST = array();
|
||||||
|
|
||||||
|
// set list properties and session vars
|
||||||
|
if (strlen($_GET['_page']))
|
||||||
|
{
|
||||||
|
$CONTACTS_LIST['page'] = $_GET['_page'];
|
||||||
|
$_SESSION['page'] = $_GET['_page'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$CONTACTS_LIST['page'] = $_SESSION['page'] ? $_SESSION['page'] : 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// return the message list as HTML table
|
||||||
|
function rcmail_contacts_list($attrib)
|
||||||
|
{
|
||||||
|
global $DB, $CONFIG, $OUTPUT, $CONTACTS_LIST, $JS_OBJECT_NAME;
|
||||||
|
|
||||||
|
//$skin_path = $CONFIG['skin_path'];
|
||||||
|
//$image_tag = '<img src="%s%s" alt="%s" border="0" />';
|
||||||
|
|
||||||
|
// count contacts for this user
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT COUNT(contact_id) AS rows
|
||||||
|
FROM %s
|
||||||
|
WHERE del!='1'
|
||||||
|
AND user_id=%d",
|
||||||
|
get_table_name('contacts'),
|
||||||
|
$_SESSION['user_id']));
|
||||||
|
|
||||||
|
$sql_arr = $DB->fetch_assoc($sql_result);
|
||||||
|
$rowcount = $sql_arr['rows'];
|
||||||
|
|
||||||
|
if ($rowcount)
|
||||||
|
{
|
||||||
|
$start_row = ($CONTACTS_LIST['page']-1) * $CONFIG['pagesize'];
|
||||||
|
|
||||||
|
// get contacts from DB
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT * FROM %s
|
||||||
|
WHERE del!='1'
|
||||||
|
AND user_id=%d
|
||||||
|
ORDER BY name
|
||||||
|
LIMIT %d, %d",
|
||||||
|
get_table_name('contacts'),
|
||||||
|
$_SESSION['user_id'],
|
||||||
|
$start_row,
|
||||||
|
$CONFIG['pagesize']));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$sql_result = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
// add id to message list table if not specified
|
||||||
|
if (!strlen($attrib['id']))
|
||||||
|
$attrib['id'] = 'rcmAddressList';
|
||||||
|
|
||||||
|
// define list of cols to be displayed
|
||||||
|
$a_show_cols = array('name', 'email');
|
||||||
|
|
||||||
|
// create XHTML table
|
||||||
|
$out = rcube_table_output($attrib, $sql_result, $a_show_cols, 'contact_id');
|
||||||
|
|
||||||
|
// set client env
|
||||||
|
$javascript = sprintf("%s.gui_object('contactslist', '%s');\n", $JS_OBJECT_NAME, $attrib['id']);
|
||||||
|
$javascript .= sprintf("%s.set_env('current_page', %d);\n", $JS_OBJECT_NAME, $CONTACTS_LIST['page']);
|
||||||
|
$javascript .= sprintf("%s.set_env('pagecount', %d);\n", $JS_OBJECT_NAME, ceil($rowcount/$CONFIG['pagesize']));
|
||||||
|
//$javascript .= sprintf("%s.set_env('contacts', %s);", $JS_OBJECT_NAME, array2js($a_js_message_arr));
|
||||||
|
|
||||||
|
$OUTPUT->add_script($javascript);
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function rcmail_js_contacts_list($sql_result, $obj_name='this')
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
|
||||||
|
$commands = '';
|
||||||
|
|
||||||
|
if (!$sql_result)
|
||||||
|
return '';
|
||||||
|
|
||||||
|
// define list of cols to be displayed
|
||||||
|
$a_show_cols = array('name', 'email');
|
||||||
|
|
||||||
|
while ($sql_arr = $DB->fetch_assoc($sql_result))
|
||||||
|
{
|
||||||
|
$a_row_cols = array();
|
||||||
|
|
||||||
|
// format each col
|
||||||
|
foreach ($a_show_cols as $col)
|
||||||
|
{
|
||||||
|
$cont = rep_specialchars_output($sql_arr[$col]);
|
||||||
|
$a_row_cols[$col] = $cont;
|
||||||
|
}
|
||||||
|
|
||||||
|
$commands .= sprintf("%s.add_contact_row(%s, %s);\n",
|
||||||
|
$obj_name,
|
||||||
|
$sql_arr['contact_id'],
|
||||||
|
array2js($a_row_cols));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// similar function as /steps/settings/identities.inc::rcmail_identity_frame()
|
||||||
|
function rcmail_contact_frame($attrib)
|
||||||
|
{
|
||||||
|
global $OUTPUT, $JS_OBJECT_NAME;
|
||||||
|
|
||||||
|
if (!$attrib['id'])
|
||||||
|
$attrib['id'] = 'rcmcontactframe';
|
||||||
|
|
||||||
|
$attrib['name'] = $attrib['id'];
|
||||||
|
|
||||||
|
$OUTPUT->add_script(sprintf("%s.set_env('contentframe', '%s');", $JS_OBJECT_NAME, $attrib['name']));
|
||||||
|
|
||||||
|
$attrib_str = create_attrib_string($attrib, array('name', 'id', 'class', 'style', 'src', 'width', 'height', 'frameborder'));
|
||||||
|
$out = '<iframe'. $attrib_str . '></iframe>';
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function rcmail_rowcount_display($attrib)
|
||||||
|
{
|
||||||
|
global $OUTPUT, $JS_OBJECT_NAME;
|
||||||
|
|
||||||
|
if (!$attrib['id'])
|
||||||
|
$attrib['id'] = 'rcmcountdisplay';
|
||||||
|
|
||||||
|
$OUTPUT->add_script(sprintf("%s.gui_object('countdisplay', '%s');", $JS_OBJECT_NAME, $attrib['id']));
|
||||||
|
|
||||||
|
// allow the following attributes to be added to the <span> tag
|
||||||
|
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id'));
|
||||||
|
|
||||||
|
|
||||||
|
$out = '<span' . $attrib_str . '>';
|
||||||
|
$out .= rcmail_get_rowcount_text();
|
||||||
|
$out .= '</span>';
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function rcmail_get_rowcount_text($max=NULL)
|
||||||
|
{
|
||||||
|
global $CONTACTS_LIST, $CONFIG, $DB;
|
||||||
|
|
||||||
|
$start_row = ($CONTACTS_LIST['page']-1) * $CONFIG['pagesize'] + 1;
|
||||||
|
|
||||||
|
// get nr of contacts
|
||||||
|
if ($max===NULL)
|
||||||
|
{
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT 1 FROM %s
|
||||||
|
WHERE del!='1'
|
||||||
|
AND user_id=%d",
|
||||||
|
get_table_name('contacts'),
|
||||||
|
$_SESSION['user_id']));
|
||||||
|
|
||||||
|
$max = $DB->num_rows($sql_result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($max==0)
|
||||||
|
$out = rcube_label('nocontactsfound');
|
||||||
|
else
|
||||||
|
$out = rcube_label(array('name' => 'contactsfromto',
|
||||||
|
'vars' => array('from' => $start_row,
|
||||||
|
'to' => min($max, $start_row + $CONFIG['pagesize'] - 1),
|
||||||
|
'count' => $max)));
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/addressbook/list.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Send contacts list to client (as remote response) |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$REMOTE_REQUEST = TRUE;
|
||||||
|
|
||||||
|
// count contacts for this user
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT COUNT(contact_id) AS rows
|
||||||
|
FROM %s
|
||||||
|
WHERE del!='1'
|
||||||
|
AND user_id=%d",
|
||||||
|
get_table_name('contacts'),
|
||||||
|
$_SESSION['user_id']));
|
||||||
|
|
||||||
|
$sql_arr = $DB->fetch_assoc($sql_result);
|
||||||
|
$rowcount = $sql_arr['rows'];
|
||||||
|
|
||||||
|
// update message count display
|
||||||
|
$pages = ceil($rowcount/$CONFIG['pagesize']);
|
||||||
|
$commands = sprintf("this.set_rowcount('%s');\n", rcmail_get_rowcount_text($rowcount));
|
||||||
|
$commands .= sprintf("this.set_env('pagecount', %d);\n", $pages);
|
||||||
|
|
||||||
|
$start_row = ($CONTACTS_LIST['page']-1) * $CONFIG['pagesize'];
|
||||||
|
|
||||||
|
// get contacts from DB
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT * FROM %s
|
||||||
|
WHERE del!='1'
|
||||||
|
AND user_id=%d
|
||||||
|
ORDER BY name
|
||||||
|
LIMIT %d, %d",
|
||||||
|
get_table_name('contacts'),
|
||||||
|
$_SESSION['user_id'],
|
||||||
|
$start_row,
|
||||||
|
$CONFIG['pagesize']));
|
||||||
|
|
||||||
|
$commands .= rcmail_js_contacts_list($sql_result);
|
||||||
|
|
||||||
|
// send response
|
||||||
|
rcube_remote_response($commands);
|
||||||
|
|
||||||
|
exit;
|
||||||
|
?>
|
@ -0,0 +1,168 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/addressbook/save.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Save a contact entry or to add a new one |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
$a_save_cols = array('name', 'firstname', 'surname', 'email');
|
||||||
|
|
||||||
|
|
||||||
|
// update an existing contact
|
||||||
|
if ($_POST['_cid'])
|
||||||
|
{
|
||||||
|
$a_write_sql = array();
|
||||||
|
|
||||||
|
foreach ($a_save_cols as $col)
|
||||||
|
{
|
||||||
|
$fname = '_'.$col;
|
||||||
|
if (!isset($_POST[$fname]))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$a_write_sql[] = sprintf("%s='%s'", $col, addslashes($_POST[$fname]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sizeof($a_write_sql))
|
||||||
|
{
|
||||||
|
$DB->query(sprintf("UPDATE %s
|
||||||
|
SET %s
|
||||||
|
WHERE contact_id=%d
|
||||||
|
AND user_id=%d
|
||||||
|
AND del!='1'",
|
||||||
|
get_table_name('contacts'),
|
||||||
|
join(', ', $a_write_sql),
|
||||||
|
$_POST['_cid'],
|
||||||
|
$_SESSION['user_id']));
|
||||||
|
|
||||||
|
$updated = $DB->affected_rows();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($updated)
|
||||||
|
{
|
||||||
|
$_action = 'show';
|
||||||
|
show_message('successfullysaved', 'confirmation');
|
||||||
|
|
||||||
|
if ($_POST['_framed'])
|
||||||
|
{
|
||||||
|
// define list of cols to be displayed
|
||||||
|
$a_show_cols = array('name', 'email');
|
||||||
|
$a_js_cols = array();
|
||||||
|
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT * FROM %s
|
||||||
|
WHERE contact_id=%d
|
||||||
|
AND user_id=%d
|
||||||
|
AND del!='1'",
|
||||||
|
get_table_name('contacts'),
|
||||||
|
$_POST['_cid'],
|
||||||
|
$_SESSION['user_id']));
|
||||||
|
|
||||||
|
$sql_arr = $DB->fetch_assoc($sql_result);
|
||||||
|
foreach ($a_show_cols as $col)
|
||||||
|
$a_js_cols[] = (string)$sql_arr[$col];
|
||||||
|
|
||||||
|
// update the changed col in list
|
||||||
|
$OUTPUT->add_script(sprintf("if(parent.%s)parent.%s.update_contact_row('%d', %s);",
|
||||||
|
$JS_OBJECT_NAME,
|
||||||
|
$JS_OBJECT_NAME,
|
||||||
|
$_POST['_cid'],
|
||||||
|
array2js($a_js_cols)));
|
||||||
|
|
||||||
|
// show confirmation
|
||||||
|
show_message('successfullysaved', 'confirmation');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// show error message
|
||||||
|
show_message('errorsaving', 'error');
|
||||||
|
$_action = 'show';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert a new contact
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$a_insert_cols = $a_insert_values = array();
|
||||||
|
|
||||||
|
foreach ($a_save_cols as $col)
|
||||||
|
{
|
||||||
|
$fname = '_'.$col;
|
||||||
|
if (!isset($_POST[$fname]))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$a_insert_cols[] = $col;
|
||||||
|
$a_insert_values[] = sprintf("'%s'", addslashes($_POST[$fname]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sizeof($a_insert_cols))
|
||||||
|
{
|
||||||
|
$DB->query(sprintf("INSERT INTO %s
|
||||||
|
(user_id, %s)
|
||||||
|
VALUES (%d, %s)",
|
||||||
|
get_table_name('contacts'),
|
||||||
|
join(', ', $a_insert_cols),
|
||||||
|
$_SESSION['user_id'],
|
||||||
|
join(', ', $a_insert_values)));
|
||||||
|
|
||||||
|
$insert_id = $DB->insert_id();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($insert_id)
|
||||||
|
{
|
||||||
|
$_action = 'show';
|
||||||
|
$_GET['_cid'] = $insert_id;
|
||||||
|
|
||||||
|
if ($_POST['_framed'])
|
||||||
|
{
|
||||||
|
// add contact row or jump to the page where it should appear
|
||||||
|
$commands = sprintf("if(parent.%s)parent.", $JS_OBJECT_NAME);
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT * FROM %s
|
||||||
|
WHERE contact_id=%d
|
||||||
|
AND user_id=%d",
|
||||||
|
get_table_name('contacts'),
|
||||||
|
$insert_id,
|
||||||
|
$_SESSION['user_id']));
|
||||||
|
$commands .= rcmail_js_contacts_list($sql_result, $JS_OBJECT_NAME);
|
||||||
|
|
||||||
|
$commands .= sprintf("if(parent.%s)parent.%s.select('%d');\n",
|
||||||
|
$JS_OBJECT_NAME,
|
||||||
|
$JS_OBJECT_NAME,
|
||||||
|
$insert_id);
|
||||||
|
|
||||||
|
// update record count display
|
||||||
|
$commands .= sprintf("if(parent.%s)parent.%s.set_rowcount('%s');\n",
|
||||||
|
$JS_OBJECT_NAME,
|
||||||
|
$JS_OBJECT_NAME,
|
||||||
|
rcmail_get_rowcount_text());
|
||||||
|
|
||||||
|
$OUTPUT->add_script($commands);
|
||||||
|
|
||||||
|
// show confirmation
|
||||||
|
show_message('successfullysaved', 'confirmation');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// show error message
|
||||||
|
show_message('errorsaving', 'error');
|
||||||
|
$_action = 'add';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/addressbook/show.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Show contact details |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
if ($_GET['_cid'] || $_POST['_cid'])
|
||||||
|
{
|
||||||
|
$cid = $_POST['_cid'] ? $_POST['_cid'] : $_GET['_cid'];
|
||||||
|
$DB->query(sprintf("SELECT * FROM %s
|
||||||
|
WHERE contact_id=%d
|
||||||
|
AND user_id=%d
|
||||||
|
AND del!='1'",
|
||||||
|
get_table_name('contacts'),
|
||||||
|
$cid,
|
||||||
|
$_SESSION['user_id']));
|
||||||
|
|
||||||
|
$CONTACT_RECORD = $DB->fetch_assoc();
|
||||||
|
|
||||||
|
if (is_array($CONTACT_RECORD))
|
||||||
|
$OUTPUT->add_script(sprintf("%s.set_env('cid', '%s');", $JS_OBJECT_NAME, $CONTACT_RECORD['contact_id']));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function rcmail_contact_details($attrib)
|
||||||
|
{
|
||||||
|
global $CONTACT_RECORD, $JS_OBJECT_NAME;
|
||||||
|
|
||||||
|
if (!$CONTACT_RECORD)
|
||||||
|
return show_message('contactnotfound');
|
||||||
|
|
||||||
|
// a specific part is requested
|
||||||
|
if ($attrib['part'])
|
||||||
|
return rep_specialchars_output($CONTACT_RECORD[$attrib['part']]);
|
||||||
|
|
||||||
|
|
||||||
|
// return the complete address record as table
|
||||||
|
$out = "<table>\n\n";
|
||||||
|
|
||||||
|
$a_show_cols = array('name', 'firstname', 'surname', 'email');
|
||||||
|
foreach ($a_show_cols as $col)
|
||||||
|
{
|
||||||
|
if ($col=='email' && $CONTACT_RECORD[$col])
|
||||||
|
$value = sprintf('<a href="#compose" onclick="%s.command(\'compose\', %d)" title="%s">%s</a>',
|
||||||
|
$JS_OBJECT_NAME,
|
||||||
|
$CONTACT_RECORD['contact_id'],
|
||||||
|
rcube_label('composeto'),
|
||||||
|
$CONTACT_RECORD[$col]);
|
||||||
|
else
|
||||||
|
$value = rep_specialchars_output($CONTACT_RECORD[$col]);
|
||||||
|
|
||||||
|
$title = rcube_label($col);
|
||||||
|
$out .= sprintf("<tr><td class=\"title\">%s</td><td>%s</td></tr>\n", $title, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$out .= "\n</table>";
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
parse_template('showcontact');
|
||||||
|
?>
|
@ -0,0 +1,117 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/error.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Display error message page |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// browser is not compatible with this application
|
||||||
|
if ($ERROR_CODE==409)
|
||||||
|
{
|
||||||
|
$user_agent = $GLOBALS['HTTP_SERVER_VARS']['HTTP_USER_AGENT'];
|
||||||
|
$__error_title = 'Your browser does not suit the requirements for this application';
|
||||||
|
$__error_text = <<<EOF
|
||||||
|
<i>Supported browsers:</i><br />
|
||||||
|
» Netscape 7+<br />
|
||||||
|
» Microsoft Internet Explorer 6+<br />
|
||||||
|
» Mozilla Firefox 1.0+<br />
|
||||||
|
» Opera 8.0+<br />
|
||||||
|
» Safari 1.2+<br />
|
||||||
|
<br />
|
||||||
|
» JavaScript enabled<br />
|
||||||
|
|
||||||
|
<p><i>Your configuration:</i><br />
|
||||||
|
$user_agent</p>
|
||||||
|
EOF;
|
||||||
|
}
|
||||||
|
|
||||||
|
// authorization error
|
||||||
|
else if ($ERROR_CODE==401)
|
||||||
|
{
|
||||||
|
$__error_title = "AUTHORIZATION FAILED";
|
||||||
|
$__error_text = "Could not verify that you are authorized to access this service!<br />\n".
|
||||||
|
"Please contact your server-administrator.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// failed request (wrong step in URL)
|
||||||
|
else if ($ERROR_CODE==404)
|
||||||
|
{
|
||||||
|
$__error_title = "REQUEST FAILED/FILE NOT FOUND";
|
||||||
|
$request_url = $GLOBALS['HTTP_HOST'].$GLOBALS['REQUEST_URI'];
|
||||||
|
$__error_text = <<<EOF
|
||||||
|
The requested page was not found!<br />
|
||||||
|
Please contact your server-administrator.
|
||||||
|
|
||||||
|
<p><i>Failed request:</i><br />
|
||||||
|
http://$request_url</p>
|
||||||
|
EOF;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// system error
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$__error_title = "SERVICE CURRENTLY NOT AVAILABLE!";
|
||||||
|
$__error_text = "Please contact your server-administrator.";
|
||||||
|
|
||||||
|
if (($CONFIG['debug_level'] & 4) && $ERROR_MESSAGE)
|
||||||
|
$__error_text = $ERROR_MESSAGE;
|
||||||
|
else
|
||||||
|
$__error_text = 'Error No. '.dechex($ERROR_CODE).')';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// compose page content
|
||||||
|
|
||||||
|
$__page_content = <<<EOF
|
||||||
|
<div>
|
||||||
|
<h3 class="error-title">$__error_title</h3>
|
||||||
|
<p class="error-text">$__error_text</p>
|
||||||
|
</div>
|
||||||
|
EOF;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (template_exists('error'))
|
||||||
|
{
|
||||||
|
$OUTPUT->scripts = array();
|
||||||
|
$OUTPUT->script_files = array();
|
||||||
|
parse_template('error');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// print system error page
|
||||||
|
print <<<EOF
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"><head>
|
||||||
|
<title>RoundCube|Mail : ERROR $ERROR_CODE</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="program/style.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<table border="0" cellsapcing="0" cellpadding="0" width="100%" height="80%"><tr><td align="center">
|
||||||
|
|
||||||
|
$__page_content
|
||||||
|
|
||||||
|
</td></tr></table>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
EOF;
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/mail/addcontact.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Add the submitted contact to the users address book |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$REMOTE_REQUEST = TRUE;
|
||||||
|
|
||||||
|
if ($_GET['_address'])
|
||||||
|
{
|
||||||
|
$contact_arr = $IMAP->decode_address_list($_GET['_address']);
|
||||||
|
if (sizeof($contact_arr))
|
||||||
|
{
|
||||||
|
$contact = $contact_arr[1];
|
||||||
|
|
||||||
|
if ($contact['mailto'])
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT 1 FROM %s
|
||||||
|
WHERE user_id=%d
|
||||||
|
AND email='%s'
|
||||||
|
AND del!='1'",
|
||||||
|
get_table_name('contacts'),
|
||||||
|
$_SESSION['user_id'],
|
||||||
|
$contact['mailto']));
|
||||||
|
|
||||||
|
// contact entry with this mail address exists
|
||||||
|
if ($sql_result && $DB->num_rows($sql_result))
|
||||||
|
$existing_contact = TRUE;
|
||||||
|
|
||||||
|
else if ($contact['mailto'])
|
||||||
|
{
|
||||||
|
$DB->query(sprintf("INSERT INTO %s
|
||||||
|
(user_id, name, email)
|
||||||
|
VALUES (%d, '%s', '%s')",
|
||||||
|
get_table_name('contacts'),
|
||||||
|
$_SESSION['user_id'],
|
||||||
|
$contact['name'],
|
||||||
|
$contact['mailto']));
|
||||||
|
|
||||||
|
$added = $DB->insert_id();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($added)
|
||||||
|
$commands = show_message('addedsuccessfully', 'confirmation');
|
||||||
|
else if ($existing_contact)
|
||||||
|
$commands = show_message('contactexists', 'warning');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!$commands)
|
||||||
|
$commands = show_message('errorsavingcontact', 'warning');
|
||||||
|
|
||||||
|
rcube_remote_response($commands);
|
||||||
|
exit;
|
||||||
|
?>
|
@ -0,0 +1,545 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/mail/compose.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Compose a new mail message with all headers and attachments |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
require_once('Mail/mimeDecode.php');
|
||||||
|
|
||||||
|
|
||||||
|
$MESSAGE_FORM = NULL;
|
||||||
|
$REPLY_MESSAGE = NULL;
|
||||||
|
$FORWARD_MESSAGE = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
if (!is_array($_SESSION['compose']))
|
||||||
|
$_SESSION['compose'] = array('id' => uniqid(rand()));
|
||||||
|
|
||||||
|
|
||||||
|
if ($_GET['_reply_uid'] || $_GET['_forward_uid'])
|
||||||
|
{
|
||||||
|
$msg_uid = $_GET['_reply_uid'] ? $_GET['_reply_uid'] : $_GET['_forward_uid'];
|
||||||
|
|
||||||
|
// similar as in program/steps/mail/show.inc
|
||||||
|
$MESSAGE = array();
|
||||||
|
$MESSAGE['headers'] = $IMAP->get_headers($msg_uid);
|
||||||
|
|
||||||
|
$MESSAGE['source'] = rcmail_message_source($msg_uid);
|
||||||
|
|
||||||
|
$mmd = new Mail_mimeDecode($MESSAGE['source']);
|
||||||
|
$MESSAGE['structure'] = $mmd->decode(array('include_bodies' => TRUE,
|
||||||
|
'decode_headers' => TRUE,
|
||||||
|
'decode_bodies' => FALSE));
|
||||||
|
|
||||||
|
$MESSAGE['subject'] = $IMAP->decode_header($MESSAGE['headers']->subject);
|
||||||
|
$MESSAGE['parts'] = $mmd->getMimeNumbers($MESSAGE['structure']);
|
||||||
|
|
||||||
|
if ($_GET['_reply_uid'])
|
||||||
|
{
|
||||||
|
$REPLY_MESSAGE = $MESSAGE;
|
||||||
|
$_SESSION['compose']['reply_uid'] = $_GET['_reply_uid'];
|
||||||
|
$_SESSION['compose']['reply_msgid'] = $REPLY_MESSAGE['headers']->messageID;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$FORWARD_MESSAGE = $MESSAGE;
|
||||||
|
$_SESSION['compose']['forward_uid'] = $_GET['_forward_uid'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/****** compose mode functions ********/
|
||||||
|
|
||||||
|
|
||||||
|
function rcmail_compose_headers($attrib)
|
||||||
|
{
|
||||||
|
global $IMAP, $REPLY_MESSAGE, $DB;
|
||||||
|
|
||||||
|
list($form_start, $form_end) = get_form_tags($attrib);
|
||||||
|
|
||||||
|
$out = '';
|
||||||
|
$part = strtolower($attrib['part']);
|
||||||
|
|
||||||
|
switch ($part)
|
||||||
|
{
|
||||||
|
case 'from':
|
||||||
|
// pass the following attributes to the form class
|
||||||
|
$field_attrib = array('name' => '_from');
|
||||||
|
foreach ($attrib as $attr => $value)
|
||||||
|
if (in_array($attr, array('id', 'class', 'style', 'size')))
|
||||||
|
$field_attrib[$attr] = $value;
|
||||||
|
|
||||||
|
// get this user's identities
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT identity_id, name, email
|
||||||
|
FROM %s
|
||||||
|
WHERE user_id=%d
|
||||||
|
AND del!='1'
|
||||||
|
ORDER BY `default` DESC, name ASC",
|
||||||
|
get_table_name('identities'),
|
||||||
|
$_SESSION['user_id']));
|
||||||
|
|
||||||
|
if ($DB->num_rows($sql_result))
|
||||||
|
{
|
||||||
|
$select_from = new select($field_attrib);
|
||||||
|
while ($sql_arr = $DB->fetch_assoc($sql_result))
|
||||||
|
$select_from->add(format_email_recipient($sql_arr['email'], $sql_arr['name']), $sql_arr['identity_id']);
|
||||||
|
|
||||||
|
$out = $select_from->show($_POST['_from']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$input_from = new textfield($field_attrib);
|
||||||
|
$out = $input_from->show($_POST['_from']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($form_start)
|
||||||
|
$out = $form_start.$out;
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
|
||||||
|
|
||||||
|
case 'to':
|
||||||
|
$fname = '_to';
|
||||||
|
$header = 'to';
|
||||||
|
|
||||||
|
// we have contact id's as get parameters
|
||||||
|
if (strlen($_GET['_to']) && preg_match('/[0-9]+,?/', $_GET['_to']))
|
||||||
|
{
|
||||||
|
$a_recipients = array();
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT name, email
|
||||||
|
FROM %s
|
||||||
|
WHERE user_id=%d
|
||||||
|
AND del!='1'
|
||||||
|
AND contact_id IN (%s)",
|
||||||
|
get_table_name('contacts'),
|
||||||
|
$_SESSION['user_id'],
|
||||||
|
$_GET['_to']));
|
||||||
|
|
||||||
|
while ($sql_arr = $DB->fetch_assoc($sql_result))
|
||||||
|
$a_recipients[] = format_email_recipient($sql_arr['email'], $sql_arr['name']);
|
||||||
|
|
||||||
|
if (sizeof($a_recipients))
|
||||||
|
$fvalue = join(', ', $a_recipients);
|
||||||
|
}
|
||||||
|
else if (strlen($_GET['_to']))
|
||||||
|
$fvalue = $_GET['_to'];
|
||||||
|
|
||||||
|
case 'cc':
|
||||||
|
if (!$fname)
|
||||||
|
{
|
||||||
|
$fname = '_cc';
|
||||||
|
//$header = 'cc';
|
||||||
|
}
|
||||||
|
case 'bcc':
|
||||||
|
if (!$fname)
|
||||||
|
$fname = '_bcc';
|
||||||
|
|
||||||
|
$allow_attrib = array('id', 'class', 'style', 'cols', 'rows', 'wrap');
|
||||||
|
$field_type = 'textarea';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'replyto':
|
||||||
|
case 'reply-to':
|
||||||
|
$fname = '_replyto';
|
||||||
|
$allow_attrib = array('id', 'class', 'style', 'size');
|
||||||
|
$field_type = 'textfield';
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($fname && $_POST[$fname])
|
||||||
|
$fvalue = $_POST[$fname];
|
||||||
|
else if ($header && is_object($REPLY_MESSAGE['headers']))
|
||||||
|
{
|
||||||
|
// get recipent address(es) out of the message headers
|
||||||
|
if ($header=='to' && $REPLY_MESSAGE['headers']->replyto)
|
||||||
|
$fvalue = $IMAP->decode_header($REPLY_MESSAGE['headers']->replyto);
|
||||||
|
else if ($header=='to' && $REPLY_MESSAGE['headers']->from)
|
||||||
|
$fvalue = $IMAP->decode_header($REPLY_MESSAGE['headers']->from);
|
||||||
|
|
||||||
|
// split recipients and put them back together in a unique way
|
||||||
|
$to_addresses = $IMAP->decode_address_list($fvalue);
|
||||||
|
$fvalue = '';
|
||||||
|
foreach ($to_addresses as $addr_part)
|
||||||
|
$fvalue .= (strlen($fvalue) ? ', ':'').$addr_part['string'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($fname && $field_type)
|
||||||
|
{
|
||||||
|
// pass the following attributes to the form class
|
||||||
|
$field_attrib = array('name' => $fname);
|
||||||
|
foreach ($attrib as $attr => $value)
|
||||||
|
if (in_array($attr, $allow_attrib))
|
||||||
|
$field_attrib[$attr] = $value;
|
||||||
|
|
||||||
|
// create teaxtarea object
|
||||||
|
$input = new $field_type($field_attrib);
|
||||||
|
$out = $input->show($fvalue);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($form_start)
|
||||||
|
$out = $form_start.$out;
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*function rcube_compose_headers($attrib)
|
||||||
|
{
|
||||||
|
global $CONFIG, $OUTPUT;
|
||||||
|
|
||||||
|
list($form_start, $form_end) = get_form_tags($attrib);
|
||||||
|
|
||||||
|
// allow the following attributes to be added to the headers table
|
||||||
|
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border'));
|
||||||
|
|
||||||
|
$labels = array();
|
||||||
|
$labels['from'] = rcube_label('from');
|
||||||
|
$labels['to'] = rcube_label('to');
|
||||||
|
$labels['cc'] = rcube_label('cc');
|
||||||
|
$labels['bcc'] = rcube_label('bcc');
|
||||||
|
$labels['replyto'] = rcube_label('replyto');
|
||||||
|
|
||||||
|
$input_from = new textfield(array('name' => '_from', 'size' => 30));
|
||||||
|
$input_to = new textfield(array('name' => '_to', 'size' => 30));
|
||||||
|
$input_cc = new textfield(array('name' => '_cc', 'size' => 30));
|
||||||
|
$input_bcc = new textfield(array('name' => '_bcc', 'size' => 30));
|
||||||
|
$input_replyto = new textfield(array('name' => '_replyto', 'size' => 30));
|
||||||
|
|
||||||
|
$fields = array();
|
||||||
|
$fields['from'] = $input_from->show($_POST['_from']);
|
||||||
|
$fields['to'] = $input_to->show($_POST['_to']);
|
||||||
|
$fields['cc'] = $input_cc->show($_POST['_cc']);
|
||||||
|
$fields['bcc'] = $input_bcc->show($_POST['_bcc']);
|
||||||
|
$fields['replyto'] = $input_replyto->show($_POST['_replyto']);
|
||||||
|
|
||||||
|
|
||||||
|
$out = <<<EOF
|
||||||
|
$form_start
|
||||||
|
<table$attrib_str><tr>
|
||||||
|
|
||||||
|
<td class="title">$labels[from]</td>
|
||||||
|
<td>$fields[from]</td>
|
||||||
|
|
||||||
|
</tr><tr>
|
||||||
|
|
||||||
|
<td class="title">$labels[to]</td>
|
||||||
|
<td>$fields[to]</td>
|
||||||
|
|
||||||
|
</tr><tr>
|
||||||
|
|
||||||
|
<td class="title">$labels[cc]</td>
|
||||||
|
<td>$fields[cc]</td>
|
||||||
|
|
||||||
|
</tr><tr>
|
||||||
|
|
||||||
|
<td class="title">$labels[bcc]</td>
|
||||||
|
<td>$fields[bcc]</td>
|
||||||
|
|
||||||
|
</tr><tr>
|
||||||
|
|
||||||
|
<td class="title">$labels[replyto]</td>
|
||||||
|
<td>$fields[replyto]</td>
|
||||||
|
|
||||||
|
</tr></table>
|
||||||
|
$form_end
|
||||||
|
EOF;
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function rcmail_compose_body($attrib)
|
||||||
|
{
|
||||||
|
global $CONFIG, $REPLY_MESSAGE, $FORWARD_MESSAGE;
|
||||||
|
|
||||||
|
list($form_start, $form_end) = get_form_tags($attrib);
|
||||||
|
unset($attrib['form']);
|
||||||
|
|
||||||
|
$attrib['name'] = '_message';
|
||||||
|
$textarea = new textarea($attrib);
|
||||||
|
|
||||||
|
$body = '';
|
||||||
|
|
||||||
|
// use posted message body
|
||||||
|
if ($_POST['_message'])
|
||||||
|
$body = $_POST['_message'];
|
||||||
|
|
||||||
|
// compose reply-body
|
||||||
|
else if (is_array($REPLY_MESSAGE['parts']))
|
||||||
|
{
|
||||||
|
$body = rcmail_first_text_part($REPLY_MESSAGE['parts']);
|
||||||
|
if (strlen($body))
|
||||||
|
$body = rcmail_create_reply_body($body);
|
||||||
|
}
|
||||||
|
|
||||||
|
// forward message body inline
|
||||||
|
else if (is_array($FORWARD_MESSAGE['parts']))
|
||||||
|
{
|
||||||
|
$body = rcmail_first_text_part($FORWARD_MESSAGE['parts']);
|
||||||
|
if (strlen($body))
|
||||||
|
$body = rcmail_create_forward_body($body);
|
||||||
|
}
|
||||||
|
|
||||||
|
$out = $form_start ? "$form_start\n" : '';
|
||||||
|
$out .= $textarea->show($body);
|
||||||
|
$out .= $form_end ? "\n$form_end" : '';
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function rcmail_create_reply_body($body)
|
||||||
|
{
|
||||||
|
global $IMAP, $REPLY_MESSAGE;
|
||||||
|
|
||||||
|
// soft-wrap message first
|
||||||
|
$body = wordwrap($body, 75);
|
||||||
|
|
||||||
|
// split body into single lines
|
||||||
|
$a_lines = preg_split('/\r?\n/', $body);
|
||||||
|
|
||||||
|
// add > to each line
|
||||||
|
for($n=0; $n<sizeof($a_lines); $n++)
|
||||||
|
{
|
||||||
|
if (strpos($a_lines[$n], '>')===0)
|
||||||
|
$a_lines[$n] = '>'.$a_lines[$n];
|
||||||
|
else
|
||||||
|
$a_lines[$n] = '> '.$a_lines[$n];
|
||||||
|
}
|
||||||
|
|
||||||
|
$body = join("\n", $a_lines);
|
||||||
|
|
||||||
|
// add title line
|
||||||
|
$pefix = sprintf("\n\n\nOn %s, %s wrote:\n",
|
||||||
|
$REPLY_MESSAGE['headers']->date,
|
||||||
|
$IMAP->decode_header($REPLY_MESSAGE['headers']->from));
|
||||||
|
|
||||||
|
return $pefix.$body;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function rcmail_create_forward_body($body)
|
||||||
|
{
|
||||||
|
global $IMAP, $FORWARD_MESSAGE;
|
||||||
|
|
||||||
|
// soft-wrap message first
|
||||||
|
$body = wordwrap($body, 80);
|
||||||
|
|
||||||
|
$prefix = sprintf("\n\n\n-------- Original Message --------\nSubject: %s\nDate: %s\nFrom: %s\nTo: %s\n\n",
|
||||||
|
$FORWARD_MESSAGE['subject'],
|
||||||
|
$FORWARD_MESSAGE['headers']->date,
|
||||||
|
$IMAP->decode_header($FORWARD_MESSAGE['headers']->from),
|
||||||
|
$IMAP->decode_header($FORWARD_MESSAGE['headers']->to));
|
||||||
|
|
||||||
|
return $prefix.$body;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function rcmail_compose_subject($attrib)
|
||||||
|
{
|
||||||
|
global $CONFIG, $REPLY_MESSAGE, $FORWARD_MESSAGE;
|
||||||
|
|
||||||
|
list($form_start, $form_end) = get_form_tags($attrib);
|
||||||
|
unset($attrib['form']);
|
||||||
|
|
||||||
|
$attrib['name'] = '_subject';
|
||||||
|
$textfield = new textfield($attrib);
|
||||||
|
|
||||||
|
$subject = '';
|
||||||
|
|
||||||
|
// use subject from post
|
||||||
|
if ($_POST['_subject'])
|
||||||
|
$subject = $_POST['_subject'];
|
||||||
|
|
||||||
|
// create a reply-subject
|
||||||
|
else if (isset($REPLY_MESSAGE['subject']))
|
||||||
|
$subject = 'Re: '.$REPLY_MESSAGE['subject'];
|
||||||
|
|
||||||
|
// create a forward-subject
|
||||||
|
else if (isset($FORWARD_MESSAGE['subject']))
|
||||||
|
$subject = 'Fwd: '.$FORWARD_MESSAGE['subject'];
|
||||||
|
|
||||||
|
|
||||||
|
$out = $form_start ? "$form_start\n" : '';
|
||||||
|
$out .= $textfield->show($subject);
|
||||||
|
$out .= $form_end ? "\n$form_end" : '';
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function rcmail_compose_attachment_list($attrib)
|
||||||
|
{
|
||||||
|
global $OUTPUT, $JS_OBJECT_NAME;
|
||||||
|
|
||||||
|
// add ID if not given
|
||||||
|
if (!$attrib['id'])
|
||||||
|
$attrib['id'] = 'rcmAttachmentList';
|
||||||
|
|
||||||
|
// allow the following attributes to be added to the <ul> tag
|
||||||
|
$attrib_str = create_attrib_string($attrib, array('id', 'class', 'style'));
|
||||||
|
|
||||||
|
$out = '<ul'. $attrib_str . ">\n";
|
||||||
|
|
||||||
|
if (is_array($_SESSION['compose']['attachments']))
|
||||||
|
{
|
||||||
|
foreach ($_SESSION['compose']['attachments'] as $i => $a_prop)
|
||||||
|
$out .= sprintf("<li>%s</li>\n", $a_prop['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$OUTPUT->add_script(sprintf("%s.gui_object('attachmentlist', '%s');", $JS_OBJECT_NAME, $attrib['id']));
|
||||||
|
|
||||||
|
$out .= '</ul>';
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function rcmail_compose_attachment_form($attrib)
|
||||||
|
{
|
||||||
|
global $OUTPUT, $JS_OBJECT_NAME, $SESS_HIDDEN_FIELD;
|
||||||
|
|
||||||
|
// add ID if not given
|
||||||
|
if (!$attrib['id'])
|
||||||
|
$attrib['id'] = 'rcmUploadbox';
|
||||||
|
|
||||||
|
// allow the following attributes to be added to the <div> tag
|
||||||
|
$attrib_str = create_attrib_string($attrib, array('id', 'class', 'style'));
|
||||||
|
$input_field = rcmail_compose_attachment_field(array());
|
||||||
|
$label_send = rcube_label('upload');
|
||||||
|
$label_close = rcube_label('close');
|
||||||
|
|
||||||
|
$out = <<<EOF
|
||||||
|
<div$attrib_str>
|
||||||
|
<form action="./" method="post" enctype="multipart/form-data">
|
||||||
|
$SESS_HIDDEN_FIELD
|
||||||
|
$input_field<br />
|
||||||
|
<input type="button" value="$label_close" class="button" onclick="document.getElementById('$attrib[id]').style.visibility='hidden'" />
|
||||||
|
<input type="button" value="$label_send" class="button" onclick="$JS_OBJECT_NAME.command('send-attachment', this.form)" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
EOF;
|
||||||
|
|
||||||
|
|
||||||
|
$OUTPUT->add_script(sprintf("%s.gui_object('uploadbox', '%s');", $JS_OBJECT_NAME, $attrib['id']));
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function rcmail_compose_attachment_field($attrib)
|
||||||
|
{
|
||||||
|
// allow the following attributes to be added to the <input> tag
|
||||||
|
$attrib_str = create_attrib_string($attrib, array('id', 'class', 'style', 'size'));
|
||||||
|
|
||||||
|
$out = '<input type="file" name="_attachments[]"'. $attrib_str . " />";
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function rcmail_priority_selector($attrib)
|
||||||
|
{
|
||||||
|
list($form_start, $form_end) = get_form_tags($attrib);
|
||||||
|
unset($attrib['form']);
|
||||||
|
|
||||||
|
$attrib['name'] = '_priority';
|
||||||
|
$selector = new select($attrib);
|
||||||
|
|
||||||
|
$selector->add(array(rcube_label('lowest'),
|
||||||
|
rcube_label('low'),
|
||||||
|
rcube_label('normal'),
|
||||||
|
rcube_label('high'),
|
||||||
|
rcube_label('highest')),
|
||||||
|
array(1, 2, 0, 4, 5));
|
||||||
|
|
||||||
|
$sel = $_POST['_priority'] ? $_POST['_priority'] : 0;
|
||||||
|
|
||||||
|
$out = $form_start ? "$form_start\n" : '';
|
||||||
|
$out .= $selector->show($sel);
|
||||||
|
$out .= $form_end ? "\n$form_end" : '';
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function get_form_tags($attrib)
|
||||||
|
{
|
||||||
|
global $CONFIG, $OUTPUT, $JS_OBJECT_NAME, $MESSAGE_FORM, $SESS_HIDDEN_FIELD;
|
||||||
|
|
||||||
|
$form_start = '';
|
||||||
|
if (!strlen($MESSAGE_FORM))
|
||||||
|
{
|
||||||
|
$hiddenfields = new hiddenfield(array('name' => '_task', 'value' => $GLOBALS['_task']));
|
||||||
|
$hiddenfields->add(array('name' => '_action', 'value' => 'send'));
|
||||||
|
|
||||||
|
$form_start = !strlen($attrib['form']) ? '<form name="form" action="./" method="post">' : '';
|
||||||
|
$form_start .= "\n$SESS_HIDDEN_FIELD\n";
|
||||||
|
$form_start .= $hiddenfields->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
$form_end = (strlen($MESSAGE_FORM) && !strlen($attrib['form'])) ? '</form>' : '';
|
||||||
|
$form_name = strlen($attrib['form']) ? $attrib['form'] : 'form';
|
||||||
|
|
||||||
|
if (!strlen($MESSAGE_FORM))
|
||||||
|
$OUTPUT->add_script("$JS_OBJECT_NAME.gui_object('messageform', '$form_name');");
|
||||||
|
|
||||||
|
$MESSAGE_FORM = $form_name;
|
||||||
|
|
||||||
|
return array($form_start, $form_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function format_email_recipient($email, $name='')
|
||||||
|
{
|
||||||
|
if ($name && $name != $email)
|
||||||
|
return sprintf('%s <%s>', strpos($name, ",") ? '"'.$name.'"' : $name, $email);
|
||||||
|
else
|
||||||
|
return $email;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****** get contacts for this user and add them to client scripts ********/
|
||||||
|
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT name, email
|
||||||
|
FROM %s
|
||||||
|
WHERE user_id=%d
|
||||||
|
AND del!='1'",
|
||||||
|
get_table_name('contacts'),
|
||||||
|
$_SESSION['user_id']));
|
||||||
|
|
||||||
|
if ($DB->num_rows($sql_result))
|
||||||
|
{
|
||||||
|
$a_contacts = array();
|
||||||
|
while ($sql_arr = $DB->fetch_assoc($sql_result))
|
||||||
|
if ($sql_arr['email'])
|
||||||
|
$a_contacts[] = format_email_recipient($sql_arr['email'], rep_specialchars_output($sql_arr['name'], 'js'));
|
||||||
|
|
||||||
|
$OUTPUT->add_script(sprintf("$JS_OBJECT_NAME.set_env('contacts', %s);", array2js($a_contacts)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
parse_template('compose');
|
||||||
|
?>
|
@ -0,0 +1,159 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/mail/get.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Delivering a specific part of a mail message |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once('Mail/mimeDecode.php');
|
||||||
|
|
||||||
|
|
||||||
|
// show loading page
|
||||||
|
if ($_GET['_preload'])
|
||||||
|
{
|
||||||
|
$url = str_replace('&_preload=1', '', $_SERVER['REQUEST_URI']);
|
||||||
|
$message = rcube_label('loadingdata');
|
||||||
|
|
||||||
|
print "<html>\n<head>\n" .
|
||||||
|
'<meta http-equiv="refresh" content="0; url='.$url.'">' .
|
||||||
|
"\n</head>\n<body>" .
|
||||||
|
$message .
|
||||||
|
"\n</body>\n</html>";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// similar code as in program/steps/mail/show.inc
|
||||||
|
if ($_GET['_uid'])
|
||||||
|
{
|
||||||
|
$MESSAGE = array();
|
||||||
|
$MESSAGE['source'] = rcmail_message_source($_GET['_uid']);
|
||||||
|
|
||||||
|
$mmd = new Mail_mimeDecode($MESSAGE['source']);
|
||||||
|
$MESSAGE['structure'] = $mmd->decode(array('include_bodies' => TRUE,
|
||||||
|
'decode_headers' => FALSE,
|
||||||
|
'decode_bodies' => FALSE));
|
||||||
|
|
||||||
|
$MESSAGE['parts'] = $mmd->getMimeNumbers($MESSAGE['structure']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// show part page
|
||||||
|
if ($_GET['_frame'])
|
||||||
|
{
|
||||||
|
parse_template('messagepart');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if ($_GET['_part'])
|
||||||
|
{
|
||||||
|
if ($part = $MESSAGE['parts'][$_GET['_part']]);
|
||||||
|
{
|
||||||
|
$ctype_primary = strtolower($part->ctype_primary);
|
||||||
|
$ctype_secondary = strtolower($part->ctype_secondary);
|
||||||
|
|
||||||
|
$mimetype = sprintf('%s/%s', $ctype_primary, $ctype_secondary);
|
||||||
|
$filename = $part->d_parameters['filename'] ? $part->d_parameters['filename'] : $part->ctype_parameters['name'];
|
||||||
|
|
||||||
|
if ($ctype_primary=='text')
|
||||||
|
{
|
||||||
|
list($MESSAGE['parts']) = rcmail_parse_message($MESSAGE['structure'],
|
||||||
|
array('safe' => (bool)$_GET['_safe'],
|
||||||
|
'prefer_html' => TRUE,
|
||||||
|
'get_url' => $GET_URL.'&_part=%s'));
|
||||||
|
|
||||||
|
$cont = rcmail_print_body($MESSAGE['parts'][0], (bool)$_GET['_safe']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$cont = $IMAP->mime_decode($part->body, $part->headers['content-transfer-encoding']);
|
||||||
|
|
||||||
|
// send correct headers for content type and length
|
||||||
|
if ($_GET['_download'])
|
||||||
|
{
|
||||||
|
// send download headers
|
||||||
|
header("Content-Type: application/octet-stream");
|
||||||
|
header(sprintf('Content-Disposition: attachment; filename="%s"',
|
||||||
|
$filename ? $filename : "roundcube.$ctype_secondary"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
header("Content-Type: $mimetype");
|
||||||
|
header(sprintf('Content-Disposition: inline; filename="%s"', $filename));
|
||||||
|
}
|
||||||
|
|
||||||
|
header(sprintf('Content-Length: %d', strlen($cont)));
|
||||||
|
|
||||||
|
// deliver part content
|
||||||
|
echo $cont;
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// print message
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$ctype_primary = strtolower($MESSAGE['structure']->ctype_primary);
|
||||||
|
$ctype_secondary = strtolower($MESSAGE['structure']->ctype_secondary);
|
||||||
|
$mimetype = sprintf('%s/%s', $ctype_primary, $ctype_secondary);
|
||||||
|
|
||||||
|
// send correct headers for content type
|
||||||
|
header("Content-Type: text/html");
|
||||||
|
|
||||||
|
$cont = '';
|
||||||
|
list($MESSAGE['parts']) = rcmail_parse_message($MESSAGE['structure'],
|
||||||
|
array('safe' => (bool)$_GET['_safe'],
|
||||||
|
'get_url' => $GET_URL.'&_part=%s'));
|
||||||
|
|
||||||
|
if ($MESSAGE['parts'] && $ctype_primary=='multipart')
|
||||||
|
{
|
||||||
|
// reset output page
|
||||||
|
$OUTPUT = new rcube_html_page();
|
||||||
|
parse_template('messagepart');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else if ($MESSAGE['parts'][0])
|
||||||
|
{
|
||||||
|
$part = $MESSAGE['parts'][0];
|
||||||
|
$cont = rcmail_print_body($part, (bool)$_GET['_safe']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$cont = $IMAP->get_body($_GET['_uid']);
|
||||||
|
|
||||||
|
$OUTPUT = new rcube_html_page();
|
||||||
|
$OUTPUT->write($cont);
|
||||||
|
|
||||||
|
/*
|
||||||
|
if ($mimetype=='text/html')
|
||||||
|
print $cont;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "<html>\n<body>\n";
|
||||||
|
print $cont;
|
||||||
|
print "\n</body>\n</html>";
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// if we arrive here, the requested part was not found
|
||||||
|
header('HTTP/1.1 404 Not Found');
|
||||||
|
exit;
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/mail/list.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Send message list to client (as remote response) |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$REMOTE_REQUEST = TRUE;
|
||||||
|
|
||||||
|
$count = $IMAP->messagecount();
|
||||||
|
|
||||||
|
// update message count display
|
||||||
|
$pages = ceil($count/$IMAP->page_size);
|
||||||
|
$commands = sprintf("this.set_env('messagecount', %d);\n", $count);
|
||||||
|
$commands .= sprintf("this.set_env('pagecount', %d);\n", $pages);
|
||||||
|
$commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text());
|
||||||
|
|
||||||
|
// update mailboxlist
|
||||||
|
$mbox = $IMAP->get_mailbox_name();
|
||||||
|
$commands .= sprintf("this.set_unread_count('%s', %d);\n", $mbox, $IMAP->messagecount($mbox, 'UNSEEN'));
|
||||||
|
|
||||||
|
|
||||||
|
// add message rows
|
||||||
|
if ($count)
|
||||||
|
{
|
||||||
|
$a_headers = $IMAP->list_headers($mbox);
|
||||||
|
$commands .= rcmail_js_message_list($a_headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// send response
|
||||||
|
rcube_remote_response($commands);
|
||||||
|
|
||||||
|
exit;
|
||||||
|
?>
|
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/mail/mark.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Mark the submitted messages with the specified flag |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$REMOTE_REQUEST = TRUE;
|
||||||
|
|
||||||
|
$a_flags_map = array('read' => 'SEEN',
|
||||||
|
'unread' => 'UNSEEN');
|
||||||
|
|
||||||
|
if ($_GET['_uid'] && $_GET['_flag'])
|
||||||
|
{
|
||||||
|
$flag = $a_flags_map[$_GET['_flag']] ? $a_flags_map[$_GET['_flag']] : strtoupper($_GET['_flag']);
|
||||||
|
$marked = $IMAP->set_flag($_GET['_uid'], $flag);
|
||||||
|
|
||||||
|
if ($marked)
|
||||||
|
{
|
||||||
|
$mbox = $IMAP->get_mailbox_name();
|
||||||
|
$commands = sprintf("this.set_unread_count('%s', %d);\n", $mbox, $IMAP->messagecount($mbox, 'UNSEEN'));
|
||||||
|
rcube_remote_response($commands);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exit;
|
||||||
|
?>
|
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/mail/move_del.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Move the submitted messages to a specific mailbox or delete them |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$REMOTE_REQUEST = TRUE;
|
||||||
|
|
||||||
|
// move messages
|
||||||
|
if ($_action=='moveto' && $_GET['_uid'] && $_GET['_target_mbox'])
|
||||||
|
{
|
||||||
|
$count = sizeof(explode(',', $_GET['_uid']));
|
||||||
|
$moved = $IMAP->move_message($_GET['_uid'], $_GET['_target_mbox'], $_GET['_mbox']);
|
||||||
|
|
||||||
|
if (!$moved)
|
||||||
|
{
|
||||||
|
// send error message
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete messages
|
||||||
|
else if ($_action=='delete' && $_GET['_uid'])
|
||||||
|
{
|
||||||
|
$count = sizeof(explode(',', $_GET['_uid']));
|
||||||
|
$del = $IMAP->delete_message($_GET['_uid'], $_GET['_mbox']);
|
||||||
|
|
||||||
|
if (!$del)
|
||||||
|
{
|
||||||
|
// send error message
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// unknown action or missing query param
|
||||||
|
else
|
||||||
|
{
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// update message count display
|
||||||
|
$pages = ceil($IMAP->messagecount()/$IMAP->page_size);
|
||||||
|
$commands = sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text());
|
||||||
|
$commands .= sprintf("this.set_env('pagecount', %d);\n", $pages);
|
||||||
|
|
||||||
|
|
||||||
|
// update mailboxlist
|
||||||
|
$mbox = $IMAP->get_mailbox_name();
|
||||||
|
$commands .= sprintf("this.set_unread_count('%s', %d);\n", $mbox, $IMAP->messagecount($mbox, 'UNSEEN'));
|
||||||
|
$commands .= sprintf("this.set_unread_count('%s', %d);\n", $_GET['_target_mbox'], $IMAP->messagecount($_GET['_target_mbox'], 'UNSEEN'));
|
||||||
|
|
||||||
|
|
||||||
|
// add new rows from next page (if any)
|
||||||
|
if ($_GET['_from']!='show' && $pages>1 && $IMAP->list_page < $pages)
|
||||||
|
{
|
||||||
|
$a_headers = $IMAP->list_headers($mbox);
|
||||||
|
$a_headers = array_slice($a_headers, -$count, $count);
|
||||||
|
$commands .= rcmail_js_message_list($a_headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// send response
|
||||||
|
rcube_remote_response($commands);
|
||||||
|
|
||||||
|
exit;
|
||||||
|
?>
|
@ -0,0 +1,251 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/mail/sendmail.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Compose a new mail message with all headers and attachments |
|
||||||
|
| and send it using IlohaMail's SMTP methods or with PHP mail() |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
require_once('lib/smtp.inc');
|
||||||
|
require_once('Mail/mime.php');
|
||||||
|
|
||||||
|
|
||||||
|
if (!isset($_SESSION['compose']['id']))
|
||||||
|
{
|
||||||
|
$_action = 'list';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****** message sending functions ********/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function rcmail_get_identity($id)
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
|
||||||
|
// get identity record
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT *, email AS mailto
|
||||||
|
FROM %s
|
||||||
|
WHERE identity_id=%d
|
||||||
|
AND user_id=%d
|
||||||
|
AND del!='1'",
|
||||||
|
get_table_name('identities'),
|
||||||
|
$id,
|
||||||
|
$_SESSION['user_id']));
|
||||||
|
|
||||||
|
if ($DB->num_rows($sql_result))
|
||||||
|
{
|
||||||
|
$sql_arr = $DB->fetch_assoc($sql_result);
|
||||||
|
$out = $sql_arr;
|
||||||
|
$out['string'] = sprintf('%s <%s>', $sql_arr['name'], $sql_arr['mailto']);
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/****** check submission and compose message ********/
|
||||||
|
|
||||||
|
|
||||||
|
$mailto_regexp = '/,\s*$/';
|
||||||
|
|
||||||
|
// trip ending ', ' from
|
||||||
|
$mailto = preg_replace($mailto_regexp, '', $_POST['_to']);
|
||||||
|
|
||||||
|
// decode address strings
|
||||||
|
$to_address_arr = $IMAP->decode_address_list($mailto);
|
||||||
|
$identity_arr = rcmail_get_identity($_POST['_from']);
|
||||||
|
|
||||||
|
|
||||||
|
$from = $identity_arr['mailto'];
|
||||||
|
$first_to = is_array($to_address_arr[0]) ? $to_address_arr[0]['mailto'] : $mailto;
|
||||||
|
|
||||||
|
|
||||||
|
// create unique message-id
|
||||||
|
$message_id = sprintf('<%s@%s>', md5(uniqid('rcmail')), $_SESSION['imap_host']);
|
||||||
|
|
||||||
|
|
||||||
|
// compose headers array
|
||||||
|
$headers = array('Date' => date('D, j M Y G:i:s O'),
|
||||||
|
'From' => $identity_arr['string'],
|
||||||
|
'To' => $mailto);
|
||||||
|
|
||||||
|
// additional recipients
|
||||||
|
if ($_POST['_cc'])
|
||||||
|
$headers['Cc'] = preg_replace($mailto_regexp, '', $_POST['_cc']);
|
||||||
|
|
||||||
|
if ($_POST['_bcc'])
|
||||||
|
$headers['Bcc'] = preg_replace($mailto_regexp, '', $_POST['_bcc']);
|
||||||
|
|
||||||
|
if (strlen($identity_arr['bcc']))
|
||||||
|
$headers['Bcc'] = ($headers['Bcc'] ? $headers['Bcc'].', ' : '') . $identity_arr['bcc'];
|
||||||
|
|
||||||
|
// add subject
|
||||||
|
$headers['Subject'] = trim(stripslashes($_POST['_subject']));
|
||||||
|
|
||||||
|
if (strlen($identity_arr['organization']))
|
||||||
|
$headers['Organization'] = $identity_arr['organization'];
|
||||||
|
|
||||||
|
if (strlen($identity_arr['reply-to']))
|
||||||
|
$headers['Reply-To'] = $identity_arr['reply-to'];
|
||||||
|
|
||||||
|
if ($_SESSION['compose']['reply_msgid'])
|
||||||
|
$headers['In-Reply-To'] = $_SESSION['compose']['reply_msgid'];
|
||||||
|
|
||||||
|
|
||||||
|
if ($_POST['_priority'])
|
||||||
|
{
|
||||||
|
$priority = (int)$_POST['_priority'];
|
||||||
|
$a_priorities = array(1=>'lowest', 2=>'low', 4=>'high', 5=>'highest');
|
||||||
|
if ($str_priority = $a_priorities[$priority])
|
||||||
|
$headers['X-Priority'] = sprintf("%d (%s)", $priority, ucfirst($str_priority));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// additional headers
|
||||||
|
$headers['Message-ID'] = $message_id;
|
||||||
|
$headers['X-Sender'] = $from;
|
||||||
|
|
||||||
|
if ($CONFIG['useragent'])
|
||||||
|
$headers['User-Agent'] = $CONFIG['useragent'];
|
||||||
|
|
||||||
|
|
||||||
|
// create PEAR::Mail_mime instance
|
||||||
|
$MAIL_MIME = new Mail_mime();
|
||||||
|
$MAIL_MIME->setTXTBody(stripslashes($_POST['_message']), FALSE, TRUE);
|
||||||
|
//$MAIL_MIME->setTXTBody(wordwrap(stripslashes($_POST['_message'])), FALSE, TRUE);
|
||||||
|
|
||||||
|
|
||||||
|
// add stored attachments, if any
|
||||||
|
if (is_array($_SESSION['compose']['attachments']))
|
||||||
|
foreach ($_SESSION['compose']['attachments'] as $attachment)
|
||||||
|
$MAIL_MIME->addAttachment($attachment['path'], $attachment['mimetype'], $attachment['name'], TRUE);
|
||||||
|
|
||||||
|
|
||||||
|
// add submitted attachments
|
||||||
|
if (is_array($_FILES['_attachments']['tmp_name']))
|
||||||
|
foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath)
|
||||||
|
$MAIL_MIME->addAttachment($filepath, $files['type'][$i], $files['name'][$i], TRUE);
|
||||||
|
|
||||||
|
|
||||||
|
// compose message body and get headers
|
||||||
|
$msg_body = $MAIL_MIME->get();
|
||||||
|
$msg_subject = $headers['Subject'];
|
||||||
|
|
||||||
|
|
||||||
|
// send thru SMTP server using cusotm SMTP library
|
||||||
|
if ($CONFIG['smtp_server'])
|
||||||
|
{
|
||||||
|
// connect to SMTP server
|
||||||
|
$smtp_conn = smtp_connect($CONFIG['smtp_server'], '25', $CONFIG['smtp_user'], $CONFIG['smtp_pass']);
|
||||||
|
|
||||||
|
if ($smtp_conn)
|
||||||
|
{
|
||||||
|
// generate list of recipients
|
||||||
|
$recipients = $mailto.', '.$headers['Cc'].', '.$headers['Bcc'];
|
||||||
|
$a_recipients = smtp_expand($recipients);
|
||||||
|
|
||||||
|
// generate message headers
|
||||||
|
$header_str = $MAIL_MIME->txtHeaders($headers);
|
||||||
|
|
||||||
|
// send message
|
||||||
|
$sent = smtp_mail($smtp_conn, $from, $a_recipients, $header_str."\r\n".$msg_body, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// log error
|
||||||
|
if (!$smtp_conn || !$sent)
|
||||||
|
{
|
||||||
|
raise_error(array('code' => 800,
|
||||||
|
'type' => 'smtp',
|
||||||
|
'line' => __LINE__,
|
||||||
|
'file' => __FILE__,
|
||||||
|
'message' => "Connection failed: $smtp_error"), TRUE, FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// send mail using PHP's mail() function
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// unset some headers because they will be added by the mail() function
|
||||||
|
$headers_php = $headers;
|
||||||
|
unset($headers_php['To'], $headers_php['Subject']);
|
||||||
|
|
||||||
|
$header_str = $MAIL_MIME->txtHeaders($headers_php);
|
||||||
|
$sent = mail($mailto, $msg_subject, $msg_body, $header_str, "-f$from");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// return to compose page if sending failed
|
||||||
|
if (!$sent)
|
||||||
|
{
|
||||||
|
$_action = 'compose';
|
||||||
|
$OUTPUT->add_script(sprintf("\n%s.set_env('action', '%s');", $JS_OBJECT_NAME, $_action));
|
||||||
|
show_message("sendingfailed", 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// set repliead flag
|
||||||
|
if ($_SESSION['compose']['reply_uid'])
|
||||||
|
$IMAP->set_flag($_SESSION['compose']['reply_uid'], 'ANSWERED');
|
||||||
|
|
||||||
|
|
||||||
|
// copy message to sent folder
|
||||||
|
if ($CONFIG['sent_mbox'])
|
||||||
|
{
|
||||||
|
// create string of complete message headers
|
||||||
|
$header_str = $MAIL_MIME->txtHeaders($headers);
|
||||||
|
|
||||||
|
// check if mailbox exists
|
||||||
|
if (!in_array_nocase($CONFIG['sent_mbox'], $IMAP->list_mailboxes()))
|
||||||
|
$IMAP->create_mailbox($CONFIG['sent_mbox'], TRUE);
|
||||||
|
|
||||||
|
// append message to sent box
|
||||||
|
$saved = $IMAP->save_message($CONFIG['sent_mbox'], $header_str."\r\n".$msg_body);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// log mail sending
|
||||||
|
if ($CONFIG['smtp_log'])
|
||||||
|
{
|
||||||
|
$log_entry = sprintf("[%s] User: %d; Message for %s; Subject: %s\n",
|
||||||
|
date("d-M-Y H:i:s O", mktime()),
|
||||||
|
$_SESSION['user_id'],
|
||||||
|
$mailto,
|
||||||
|
$msg_subject);
|
||||||
|
|
||||||
|
if ($fp = fopen($INSTALL_PATH.'logs/sendmail', 'a'))
|
||||||
|
{
|
||||||
|
fwrite($fp, $log_entry);
|
||||||
|
fclose($fp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// show confirmation
|
||||||
|
show_message('messagesent', 'confirmation');
|
||||||
|
|
||||||
|
|
||||||
|
// kill compose entry from session
|
||||||
|
rcmail_compose_cleanup();
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,169 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/mail/show.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Display a mail message similar as a usual mail application does |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once('Mail/mimeDecode.php');
|
||||||
|
|
||||||
|
$PRINT_MODE = $_action=='print' ? TRUE : FALSE;
|
||||||
|
|
||||||
|
|
||||||
|
// similar code as in program/steps/mail/get.inc
|
||||||
|
if ($_GET['_uid'])
|
||||||
|
{
|
||||||
|
$MESSAGE = array();
|
||||||
|
$MESSAGE['headers'] = $IMAP->get_headers($_GET['_uid']);
|
||||||
|
$MESSAGE['source'] = rcmail_message_source($_GET['_uid']);
|
||||||
|
|
||||||
|
// go back to list if message not found (wrong UID)
|
||||||
|
if (!$MESSAGE['headers'] || !$MESSAGE['source'])
|
||||||
|
{
|
||||||
|
$_action = 'list';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$mmd = new Mail_mimeDecode($MESSAGE['source']);
|
||||||
|
$MESSAGE['structure'] = $mmd->decode(array('include_bodies' => TRUE,
|
||||||
|
'decode_headers' => FALSE,
|
||||||
|
'decode_bodies' => FALSE));
|
||||||
|
|
||||||
|
$mmd->getMimeNumbers($MESSAGE['structure']);
|
||||||
|
|
||||||
|
$MESSAGE['subject'] = $IMAP->decode_header($MESSAGE['structure']->headers['subject']);
|
||||||
|
|
||||||
|
if ($MESSAGE['structure'])
|
||||||
|
list($MESSAGE['parts'], $MESSAGE['attachments']) = rcmail_parse_message($MESSAGE['structure'],
|
||||||
|
array('safe' => (bool)$_GET['_safe'],
|
||||||
|
'prefer_html' => $CONFIG['prefer_html'],
|
||||||
|
'get_url' => $GET_URL.'&_part=%s'));
|
||||||
|
else
|
||||||
|
$MESSAGE['body'] = $IMAP->get_body($_GET['_uid']);
|
||||||
|
|
||||||
|
|
||||||
|
// mark message as read
|
||||||
|
if (!$MESSAGE['headers']->seen)
|
||||||
|
$IMAP->set_flag($_GET['_uid'], 'SEEN');
|
||||||
|
|
||||||
|
// give message uid to the client
|
||||||
|
$javascript = sprintf("%s.set_env('uid', '%s');\n", $JS_OBJECT_NAME, $_GET['_uid']);
|
||||||
|
$javascript .= sprintf("%s.set_env('safemode', '%b');", $JS_OBJECT_NAME, $_GET['_safe']);
|
||||||
|
|
||||||
|
// get previous and next message UID
|
||||||
|
$a_msg_index = $IMAP->message_index();
|
||||||
|
$MESSAGE['index'] = array_search((string)$_GET['_uid'], $a_msg_index, TRUE);
|
||||||
|
|
||||||
|
if (isset($a_msg_index[$MESSAGE['index']-1]))
|
||||||
|
$javascript .= sprintf("\n%s.set_env('prev_uid', '%s');", $JS_OBJECT_NAME, $a_msg_index[$MESSAGE['index']-1]);
|
||||||
|
if (isset($a_msg_index[$MESSAGE['index']+1]))
|
||||||
|
$javascript .= sprintf("\n%s.set_env('next_uid', '%s');", $JS_OBJECT_NAME, $a_msg_index[$MESSAGE['index']+1]);
|
||||||
|
|
||||||
|
$OUTPUT->add_script($javascript);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function rcmail_message_attachments($attrib)
|
||||||
|
{
|
||||||
|
global $CONFIG, $OUTPUT, $PRINT_MODE, $MESSAGE, $GET_URL, $JS_OBJECT_NAME;
|
||||||
|
|
||||||
|
if (sizeof($MESSAGE['attachments']))
|
||||||
|
{
|
||||||
|
// allow the following attributes to be added to the <ul> tag
|
||||||
|
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id'));
|
||||||
|
$out = '<ul' . $attrib_str . ">\n";
|
||||||
|
|
||||||
|
foreach ($MESSAGE['attachments'] as $attach_prop)
|
||||||
|
{
|
||||||
|
if ($PRINT_MODE)
|
||||||
|
$out .= sprintf('<li>%s (%s)</li>'."\n",
|
||||||
|
$attach_prop['filename'],
|
||||||
|
show_bytes($attach_prop['size']));
|
||||||
|
else
|
||||||
|
$out .= sprintf('<li><a href="#attachment" onclick="return %s.command(\'load-attachment\',{part:\'%s\', mimetype:\'%s\'},this)">%s</a></li>'."\n",
|
||||||
|
$JS_OBJECT_NAME,
|
||||||
|
$attach_prop['part_id'],
|
||||||
|
$attach_prop['mimetype'],
|
||||||
|
$attach_prop['filename']);
|
||||||
|
/* direct link
|
||||||
|
else
|
||||||
|
$out .= sprintf('<li><a href="%s&_part=%s&_frame=1" target="rcubemailattachment">%s</a></li>'."\n",
|
||||||
|
$GET_URL,
|
||||||
|
$attach_prop['part_id'],
|
||||||
|
$attach_prop['filename']);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
$out .= "</ul>";
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// return an HTML iframe for loading mail content
|
||||||
|
function rcmail_messagecontent_frame($attrib)
|
||||||
|
{
|
||||||
|
global $COMM_PATH, $OUTPUT, $GET_URL, $JS_OBJECT_NAME;
|
||||||
|
|
||||||
|
// allow the following attributes to be added to the <iframe> tag
|
||||||
|
$attrib_str = create_attrib_string($attrib);
|
||||||
|
$framename = 'rcmailcontentwindow';
|
||||||
|
|
||||||
|
$out = sprintf('<iframe src="%s" name="%s"%s>%s</iframe>'."\n",
|
||||||
|
$GET_URL,
|
||||||
|
$framename,
|
||||||
|
$attrib_str,
|
||||||
|
rcube_label('loading'));
|
||||||
|
|
||||||
|
|
||||||
|
$OUTPUT->add_script("$JS_OBJECT_NAME.set_env('contentframe', '$framename');");
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function rcmail_remote_objects_msg($attrib)
|
||||||
|
{
|
||||||
|
global $CONFIG, $OUTPUT, $JS_OBJECT_NAME;
|
||||||
|
|
||||||
|
if (!$attrib['id'])
|
||||||
|
$attrib['id'] = 'rcmremoteobjmsg';
|
||||||
|
|
||||||
|
// allow the following attributes to be added to the <div> tag
|
||||||
|
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id'));
|
||||||
|
$out = '<div' . $attrib_str . ">";
|
||||||
|
|
||||||
|
$out .= rep_specialchars_output(sprintf('%s <a href="#loadimages" onclick="%s.command(\'load-images\')" title="%s">%s</a>',
|
||||||
|
rcube_label('blockedimages'),
|
||||||
|
$JS_OBJECT_NAME,
|
||||||
|
rcube_label('showimages'),
|
||||||
|
rcube_label('showimages')));
|
||||||
|
|
||||||
|
$out .= '</div>';
|
||||||
|
|
||||||
|
$OUTPUT->add_script(sprintf("%s.gui_object('remoteobjectsmsg', '%s');", $JS_OBJECT_NAME, $attrib['id']));
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($_action=='print')
|
||||||
|
parse_template('printmessage');
|
||||||
|
else
|
||||||
|
parse_template('message');
|
||||||
|
?>
|
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/mail/upload.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Handle file-upload and make them available as attachments |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
if (!$_SESSION['compose'])
|
||||||
|
{
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (strlen($CONFIG['temp_dir']))
|
||||||
|
$temp_dir = $CONFIG['temp_dir'].(!eregi('\/$', $CONFIG['temp_dir']) ? '/' : '').$_SESSION['compose']['id'];
|
||||||
|
|
||||||
|
if (!is_array($_SESSION['compose']['attachments']))
|
||||||
|
{
|
||||||
|
$_SESSION['compose']['attachments'] = array();
|
||||||
|
|
||||||
|
// create temp-dir for uploaded attachments
|
||||||
|
if ($CONFIG['temp_dir'] && is_writeable($CONFIG['temp_dir']))
|
||||||
|
{
|
||||||
|
mkdir($temp_dir);
|
||||||
|
$_SESSION['compose']['temp_dir'] = $temp_dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$response = '';
|
||||||
|
|
||||||
|
foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath)
|
||||||
|
{
|
||||||
|
$tmpfname = tempnam($temp_dir, 'rcmAttmnt');
|
||||||
|
if (copy($filepath, $tmpfname))
|
||||||
|
{
|
||||||
|
$_SESSION['compose']['attachments'][] = array('name' => $_FILES['_attachments']['name'][$i],
|
||||||
|
'mimetype' => $_FILES['_attachments']['type'][$i],
|
||||||
|
'path' => $tmpfname);
|
||||||
|
|
||||||
|
$response .= sprintf("parent.%s.add2attachment_list('%s');\n", $JS_OBJECT_NAME, $_FILES['_attachments']['name'][$i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// send html page with JS calls as response
|
||||||
|
print <<<EOF
|
||||||
|
<html>
|
||||||
|
<script type="text/javascript">
|
||||||
|
if (parent.$JS_OBJECT_NAME)
|
||||||
|
{
|
||||||
|
$response
|
||||||
|
parent.$JS_OBJECT_NAME.show_attachment_form(false);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</html>
|
||||||
|
EOF;
|
||||||
|
exit;
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/mail/viewsource.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Display a mail message similar as a usual mail application does |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// similar code as in program/steps/mail/get.inc
|
||||||
|
if ($_GET['_uid'])
|
||||||
|
{
|
||||||
|
header('Content-Type: text/plain');
|
||||||
|
print rcmail_message_source($_GET['_uid']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
raise_error(array('code' => 500,
|
||||||
|
'type' => 'php',
|
||||||
|
'message' => 'Message UID '.$_GET['_uid'].' not found'),
|
||||||
|
TRUE,
|
||||||
|
TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
exit;
|
||||||
|
?>
|
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/settings/delete_identity.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Delete the submitted identities (IIDs) from the database |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$REMOTE_REQUEST = $_GET['_remote'] ? TRUE : FALSE;
|
||||||
|
|
||||||
|
if ($_GET['_iid'])
|
||||||
|
{
|
||||||
|
$DB->query(sprintf("UPDATE %s
|
||||||
|
SET del='1'
|
||||||
|
WHERE user_id=%d
|
||||||
|
AND identity_id IN (%s)",
|
||||||
|
get_table_name('identities'),
|
||||||
|
$_SESSION['user_id'],
|
||||||
|
$_GET['_iid']));
|
||||||
|
|
||||||
|
$count = $DB->affected_rows();
|
||||||
|
if ($count)
|
||||||
|
{
|
||||||
|
$commands = show_message('deletedsuccessfully', 'confirmation');
|
||||||
|
}
|
||||||
|
|
||||||
|
// send response
|
||||||
|
if ($REMOTE_REQUEST)
|
||||||
|
rcube_remote_response($commands);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($REMOTE_REQUEST)
|
||||||
|
exit;
|
||||||
|
|
||||||
|
|
||||||
|
// go to identities page
|
||||||
|
$_action = 'identities';
|
||||||
|
|
||||||
|
// overwrite action variable
|
||||||
|
$OUTPUT->add_script(sprintf("\n%s.set_env('action', '%s');", $JS_OBJECT_NAME, $_action));
|
||||||
|
?>
|
@ -0,0 +1,106 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/settings/edit_identity.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Show edit form for a identity record or to add a new one |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (($_GET['_iid'] || $_POST['_iid']) && $_action=='edit-identity')
|
||||||
|
{
|
||||||
|
$id = $_POST['_iid'] ? $_POST['_iid'] : $_GET['_iid'];
|
||||||
|
$DB->query(sprintf("SELECT * FROM %s
|
||||||
|
WHERE identity_id=%d
|
||||||
|
AND user_id=%d
|
||||||
|
AND del!='1'",
|
||||||
|
get_table_name('identities'),
|
||||||
|
$id,
|
||||||
|
$_SESSION['user_id']));
|
||||||
|
|
||||||
|
$IDENTITY_RECORD = $DB->fetch_assoc();
|
||||||
|
|
||||||
|
if (is_array($IDENTITY_RECORD))
|
||||||
|
$OUTPUT->add_script(sprintf("%s.set_env('iid', '%s');", $JS_OBJECT_NAME, $IDENTITY_RECORD['identity_id']));
|
||||||
|
|
||||||
|
$PAGE_TITLE = rcube_label('edititem');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$PAGE_TITLE = rcube_label('newitem');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function rcube_identity_form($attrib)
|
||||||
|
{
|
||||||
|
global $IDENTITY_RECORD, $JS_OBJECT_NAME;
|
||||||
|
|
||||||
|
if (!$IDENTITY_RECORD && $GLOBALS['_action']!='add-identity')
|
||||||
|
return rcube_label('notfound');
|
||||||
|
|
||||||
|
list($form_start, $form_end) = get_form_tags($attrib, 'save-identity', array('name' => '_iid', 'value' => $IDENTITY_RECORD['identity_id']));
|
||||||
|
unset($attrib['form']);
|
||||||
|
|
||||||
|
|
||||||
|
// list of available cols
|
||||||
|
$a_show_cols = array('name' => array('type' => 'text'),
|
||||||
|
'email' => array('type' => 'text'),
|
||||||
|
'organization' => array('type' => 'text'),
|
||||||
|
'reply-to' => array('type' => 'text', 'label' => 'replyto'),
|
||||||
|
'bcc' => array('type' => 'text'),
|
||||||
|
'default' => array('type' => 'checkbox', 'label' => 'setdefault'));
|
||||||
|
|
||||||
|
|
||||||
|
// a specific part is requested
|
||||||
|
if ($attrib['part'])
|
||||||
|
{
|
||||||
|
$colprop = $a_show_cols[$attrib['part']];
|
||||||
|
if (is_array($colprop))
|
||||||
|
{
|
||||||
|
$out = $form_start;
|
||||||
|
$out .= rcmail_get_edit_field($attrib['part'], $IDENTITY_RECORD[$attrib['part']], $attrib, $colprop['type']);
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// return the complete edit form as table
|
||||||
|
$out = "$form_start<table>\n\n";
|
||||||
|
|
||||||
|
foreach ($a_show_cols as $col => $colprop)
|
||||||
|
{
|
||||||
|
$attrib['id'] = 'rcmfd_'.$col;
|
||||||
|
$label = strlen($colprop['label']) ? $colprop['label'] : $col;
|
||||||
|
$value = rcmail_get_edit_field($col, $IDENTITY_RECORD[$col], $attrib, $colprop['type']);
|
||||||
|
|
||||||
|
$out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
|
||||||
|
$attrib['id'],
|
||||||
|
rcube_label($label),
|
||||||
|
$value);
|
||||||
|
}
|
||||||
|
|
||||||
|
$out .= "\n</table>$form_end";
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ($_action=='add-identity' && template_exists('addidentity'))
|
||||||
|
parse_template('addidentity');
|
||||||
|
|
||||||
|
parse_template('editidentity');
|
||||||
|
?>
|
@ -0,0 +1,194 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/settings/func.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Provide functionality for user's settings & preferences |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// get user record
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT username, mail_host FROM %s
|
||||||
|
WHERE user_id=%d",
|
||||||
|
get_table_name('users'),
|
||||||
|
$_SESSION['user_id']));
|
||||||
|
|
||||||
|
if ($USER_DATA = $DB->fetch_assoc($sql_result))
|
||||||
|
$PAGE_TITLE = sprintf('%s %s@%s', rcube_label('settingsfor'), $USER_DATA['username'], $USER_DATA['mail_host']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function rcmail_user_prefs_form($attrib)
|
||||||
|
{
|
||||||
|
global $DB, $CONFIG, $sess_user_lang;
|
||||||
|
|
||||||
|
list($form_start, $form_end) = get_form_tags($attrib, 'save-prefs');
|
||||||
|
unset($attrib['form']);
|
||||||
|
|
||||||
|
// allow the following attributes to be added to the <table> tag
|
||||||
|
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary'));
|
||||||
|
|
||||||
|
// return the complete edit form as table
|
||||||
|
$out = "$form_start<table" . $attrib_str . ">\n\n";
|
||||||
|
|
||||||
|
$a_show_cols = array('language' => array('type' => 'text'),
|
||||||
|
'pagesize' => array('type' => 'text'),
|
||||||
|
'timezone' => array('type' => 'text'));
|
||||||
|
|
||||||
|
// show language selection
|
||||||
|
$field_id = 'rcmfd_lang';
|
||||||
|
$select_lang = new select(array('name' => '_language', 'id' => $field_id));
|
||||||
|
$select_lang->add('English', 'en');
|
||||||
|
$select_lang->add('Deutsch', 'de');
|
||||||
|
|
||||||
|
$out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
|
||||||
|
$field_id,
|
||||||
|
rcube_label('language'),
|
||||||
|
$select_lang->show($sess_user_lang));
|
||||||
|
|
||||||
|
|
||||||
|
// show page size selection
|
||||||
|
$field_id = 'rcmfd_timezone';
|
||||||
|
$select_timezone = new select(array('name' => '_timezone', 'id' => $field_id));
|
||||||
|
$select_timezone->add('(GMT -11:00) Midway Island, Samoa', '-11');
|
||||||
|
$select_timezone->add('(GMT -10:00) Hawaii', '-10');
|
||||||
|
$select_timezone->add('(GMT -9:00) Alaska', '-9');
|
||||||
|
$select_timezone->add('(GMT -8:00) Pacific Time (US/Canada)', '-8');
|
||||||
|
$select_timezone->add('(GMT -7:00) Mountain Time (US/Canada)', '-7');
|
||||||
|
$select_timezone->add('(GMT -6:00) Central Time (US/Canada), Mexico City', '-6');
|
||||||
|
$select_timezone->add('(GMT -5:00) Eastern Time (US/Canada), Bogota, Lima', '-5');
|
||||||
|
$select_timezone->add('(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz', '-4');
|
||||||
|
$select_timezone->add('(GMT -3:00) Brazil, Buenos Aires, Georgetown', '-3');
|
||||||
|
$select_timezone->add('(GMT -2:00) Mid-Atlantic', '-2');
|
||||||
|
$select_timezone->add('(GMT -1:00) Azores, Cape Verde Islands', '-1');
|
||||||
|
$select_timezone->add('(GMT) Western Europe, London, Lisbon, Casablanca', '0');
|
||||||
|
$select_timezone->add('(GMT +1:00) Central European Time', '1');
|
||||||
|
$select_timezone->add('(GMT +2:00) EET: Kaliningrad, South Africa', '2');
|
||||||
|
$select_timezone->add('(GMT +3:00) Baghdad, Kuwait, Riyadh, Moscow, Nairobi', '3');
|
||||||
|
$select_timezone->add('(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi', '4');
|
||||||
|
$select_timezone->add('(GMT +5:00) Ekaterinburg, Islamabad, Karachi', '5');
|
||||||
|
$select_timezone->add('(GMT +6:00) Almaty, Dhaka, Colombo', '6');
|
||||||
|
$select_timezone->add('(GMT +7:00) Bangkok, Hanoi, Jakarta', '7');
|
||||||
|
$select_timezone->add('(GMT +8:00) Beijing, Perth, Singapore, Taipei', '8');
|
||||||
|
$select_timezone->add('(GMT +9:00) Tokyo, Seoul, Yakutsk', '9');
|
||||||
|
$select_timezone->add('(GMT +10:00) EAST/AEST: Guam, Vladivostok', '10');
|
||||||
|
$select_timezone->add('(GMT +11:00) Magadan, Solomon Islands', '11');
|
||||||
|
$select_timezone->add('(GMT +12:00) Auckland, Wellington, Kamchatka', '12');
|
||||||
|
$select_timezone->add('(GMT +13:00) Tonga, Pheonix Islands', '13');
|
||||||
|
$select_timezone->add('(GMT +14:00) Kiribati', '14');
|
||||||
|
|
||||||
|
|
||||||
|
$out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
|
||||||
|
$field_id,
|
||||||
|
rcube_label('timezone'),
|
||||||
|
$select_timezone->show($CONFIG['timezone']));
|
||||||
|
|
||||||
|
|
||||||
|
// show page size selection
|
||||||
|
$field_id = 'rcmfd_pgsize';
|
||||||
|
$input_pagesize = new textfield(array('name' => '_pagesize', 'id' => $field_id, 'size' => 5));
|
||||||
|
|
||||||
|
$out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
|
||||||
|
$field_id,
|
||||||
|
rcube_label('pagesize'),
|
||||||
|
$input_pagesize->show($CONFIG['pagesize']));
|
||||||
|
|
||||||
|
// show checkbox for HTML/plaintext messages
|
||||||
|
$field_id = 'rcmfd_htmlmsg';
|
||||||
|
$input_pagesize = new checkbox(array('name' => '_prefer_html', 'id' => $field_id, 'value' => 1));
|
||||||
|
|
||||||
|
$out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
|
||||||
|
$field_id,
|
||||||
|
rcube_label('preferhtml'),
|
||||||
|
$input_pagesize->show($CONFIG['prefer_html']?1:0));
|
||||||
|
|
||||||
|
|
||||||
|
$out .= "\n</table>$form_end";
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function rcmail_identities_list($attrib)
|
||||||
|
{
|
||||||
|
global $DB, $CONFIG, $OUTPUT, $JS_OBJECT_NAME;
|
||||||
|
|
||||||
|
|
||||||
|
// get contacts from DB
|
||||||
|
$sql_result = $DB->query(sprintf("SELECT * FROM %s
|
||||||
|
WHERE del!='1'
|
||||||
|
AND user_id=%d
|
||||||
|
ORDER BY `default` DESC, name ASC",
|
||||||
|
get_table_name('identities'),
|
||||||
|
$_SESSION['user_id']));
|
||||||
|
|
||||||
|
|
||||||
|
// add id to message list table if not specified
|
||||||
|
if (!strlen($attrib['id']))
|
||||||
|
$attrib['id'] = 'rcmIdentitiesList';
|
||||||
|
|
||||||
|
// define list of cols to be displayed
|
||||||
|
$a_show_cols = array('name', 'email', 'organization', 'reply-to');
|
||||||
|
|
||||||
|
// create XHTML table
|
||||||
|
$out = rcube_table_output($attrib, $sql_result, $a_show_cols, 'identity_id');
|
||||||
|
|
||||||
|
// set client env
|
||||||
|
$javascript = sprintf("%s.gui_object('identitieslist', '%s');\n", $JS_OBJECT_NAME, $attrib['id']);
|
||||||
|
$OUTPUT->add_script($javascript);
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// similar function as in /steps/addressbook/edit.inc
|
||||||
|
function get_form_tags($attrib, $action, $add_hidden=array())
|
||||||
|
{
|
||||||
|
global $OUTPUT, $JS_OBJECT_NAME, $EDIT_FORM, $SESS_HIDDEN_FIELD;
|
||||||
|
|
||||||
|
$form_start = '';
|
||||||
|
if (!strlen($EDIT_FORM))
|
||||||
|
{
|
||||||
|
$hiddenfields = new hiddenfield(array('name' => '_task', 'value' => $GLOBALS['_task']));
|
||||||
|
$hiddenfields->add(array('name' => '_action', 'value' => $action));
|
||||||
|
|
||||||
|
if ($add_hidden)
|
||||||
|
$hiddenfields->add($add_hidden);
|
||||||
|
|
||||||
|
if ($_GET['_framed'] || $_POST['_framed'])
|
||||||
|
$hiddenfields->add(array('name' => '_framed', 'value' => 1));
|
||||||
|
|
||||||
|
$form_start = !strlen($attrib['form']) ? '<form name="form" action="./" method="post">' : '';
|
||||||
|
$form_start .= "\n$SESS_HIDDEN_FIELD\n";
|
||||||
|
$form_start .= $hiddenfields->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
$form_end = (!strlen($EDIT_FORM) && !strlen($attrib['form'])) ? '</form>' : '';
|
||||||
|
$form_name = strlen($attrib['form']) ? $attrib['form'] : 'form';
|
||||||
|
|
||||||
|
if (!strlen($EDIT_FORM))
|
||||||
|
$OUTPUT->add_script("$JS_OBJECT_NAME.gui_object('editform', '$form_name');");
|
||||||
|
|
||||||
|
$EDIT_FORM = $form_name;
|
||||||
|
|
||||||
|
return array($form_start, $form_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/settings/identities.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Manage identities of a user account |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ($USER_DATA = $DB->fetch_assoc($sql_result))
|
||||||
|
$PAGE_TITLE = sprintf('%s (%s@%s)', rcube_label('identities'), $USER_DATA['username'], $USER_DATA['mail_host']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// similar function as /steps/addressbook/func.inc::rcmail_contact_frame()
|
||||||
|
function rcmail_identity_frame($attrib)
|
||||||
|
{
|
||||||
|
global $OUTPUT, $JS_OBJECT_NAME;
|
||||||
|
|
||||||
|
if (!$attrib['id'])
|
||||||
|
$attrib['id'] = 'rcmIdentityFrame';
|
||||||
|
|
||||||
|
$attrib['name'] = $attrib['id'];
|
||||||
|
|
||||||
|
$OUTPUT->add_script(sprintf("%s.set_env('contentframe', '%s');", $JS_OBJECT_NAME, $attrib['name']));
|
||||||
|
|
||||||
|
$attrib_str = create_attrib_string($attrib, array('name', 'id', 'class', 'style', 'src', 'width', 'height', 'frameborder'));
|
||||||
|
$out = '<iframe'. $attrib_str . '></iframe>';
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
parse_template('identities');
|
||||||
|
?>
|
@ -0,0 +1,176 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/settings/manage_folders.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Provide functionality to create/delete/rename folders |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// init IAMP connection
|
||||||
|
rcmail_imap_init(TRUE);
|
||||||
|
|
||||||
|
|
||||||
|
// subscribe to one or more mailboxes
|
||||||
|
if ($_action=='subscribe')
|
||||||
|
{
|
||||||
|
if (strlen($_GET['_mboxes']))
|
||||||
|
$IMAP->subscribe(explode(',', $_GET['_mboxes']));
|
||||||
|
|
||||||
|
if ($_GET['_remote'])
|
||||||
|
rcube_remote_response('// subscribed');
|
||||||
|
}
|
||||||
|
|
||||||
|
// unsubscribe one or more mailboxes
|
||||||
|
else if ($_action=='unsubscribe')
|
||||||
|
{
|
||||||
|
if (strlen($_GET['_mboxes']))
|
||||||
|
$IMAP->unsubscribe(explode(',', $_GET['_mboxes']));
|
||||||
|
|
||||||
|
if ($_GET['_remote'])
|
||||||
|
rcube_remote_response('// unsubscribed');
|
||||||
|
}
|
||||||
|
|
||||||
|
// create a new mailbox
|
||||||
|
else if ($_action=='create-folder')
|
||||||
|
{
|
||||||
|
if (strlen($_GET['_name']))
|
||||||
|
$create = $IMAP->create_mailbox(trim($_GET['_name']), TRUE);
|
||||||
|
|
||||||
|
if ($create && $_GET['_remote'])
|
||||||
|
{
|
||||||
|
$commands = sprintf("this.add_folder_row('%s')", rep_specialchars_output($_GET['_name'], 'js'));
|
||||||
|
rcube_remote_response($commands);
|
||||||
|
}
|
||||||
|
else if (!$create && $_GET['_remote'])
|
||||||
|
{
|
||||||
|
$commands = show_message('errorsaving', 'error');
|
||||||
|
rcube_remote_response($commands);
|
||||||
|
}
|
||||||
|
else if (!$create)
|
||||||
|
show_message('errorsaving', 'error');
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete an existing IMAP mailbox
|
||||||
|
else if ($_action=='delete-folder')
|
||||||
|
{
|
||||||
|
if (strlen($_GET['_mboxes']))
|
||||||
|
$IMAP->delete_mailbox(explode(',', $_GET['_mboxes']));
|
||||||
|
|
||||||
|
if ($_GET['_remote'])
|
||||||
|
rcube_remote_response('// deleted');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// build table with all folders listed by server
|
||||||
|
function rcube_subscription_form($attrib)
|
||||||
|
{
|
||||||
|
global $IMAP, $CONFIG, $OUTPUT, $JS_OBJECT_NAME;
|
||||||
|
|
||||||
|
list($form_start, $form_end) = get_form_tags($attrib, 'folders');
|
||||||
|
unset($attrib['form']);
|
||||||
|
|
||||||
|
|
||||||
|
if (!$attrib['id'])
|
||||||
|
$attrib['id'] = 'rcmSubscriptionlist';
|
||||||
|
|
||||||
|
// allow the following attributes to be added to the <table> tag
|
||||||
|
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary'));
|
||||||
|
|
||||||
|
$out = "$form_start\n<table" . $attrib_str . ">\n";
|
||||||
|
|
||||||
|
|
||||||
|
// add table header
|
||||||
|
$out .= "<thead><tr>\n";
|
||||||
|
$out .= sprintf('<td>%s</td><td>%s</td><td></td>', rcube_label('foldername'), rcube_label('subscribed'));
|
||||||
|
$out .= "\n</tr></thead>\n<tbody>\n";
|
||||||
|
|
||||||
|
|
||||||
|
// get folders from server
|
||||||
|
$a_unsubscribed = $IMAP->list_unsubscribed();
|
||||||
|
$a_subscribed = $IMAP->list_mailboxes();
|
||||||
|
$a_js_folders = array();
|
||||||
|
|
||||||
|
$checkbox_subscribe = new checkbox(array('name' => '_subscribed[]', 'onclick' => "$JS_OBJECT_NAME.command(this.checked?'subscribe':'unsubscribe',this.value)"));
|
||||||
|
|
||||||
|
if ($attrib['deleteicon'])
|
||||||
|
$button = sprintf('<img src="%s%s" alt="%s" border="0" />', $CONFIG['skin_path'], $attrib['deleteicon'], rcube_label('delete'));
|
||||||
|
else
|
||||||
|
$button = rcube_label('delete');
|
||||||
|
|
||||||
|
|
||||||
|
// create list of available folders
|
||||||
|
foreach ($a_unsubscribed as $i => $folder)
|
||||||
|
{
|
||||||
|
$zebra_class = $i%2 ? 'even' : 'odd';
|
||||||
|
$folder_js = rep_specialchars_output($folder, 'js');
|
||||||
|
$a_js_folders['rcmrow'.($i+1)] = $folder_js;
|
||||||
|
|
||||||
|
$out .= sprintf('<tr id="rcmrow%d" class="%s"><td>%s</td><td>%s</td><td><a href="#delete" onclick="%s.command(\'delete-folder\',\'%s\')" title="%s">%s</a></td>',
|
||||||
|
$i+1,
|
||||||
|
$zebra_class,
|
||||||
|
rep_specialchars_output($folder, 'html'),
|
||||||
|
$checkbox_subscribe->show(in_array($folder, $a_subscribed)?$folder:'', array('value' => $folder)),
|
||||||
|
$JS_OBJECT_NAME,
|
||||||
|
$folder_js,
|
||||||
|
rcube_label('deletefolder'),
|
||||||
|
$button);
|
||||||
|
|
||||||
|
$out .= "</tr>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$out .= "</tbody>\n</table>";
|
||||||
|
$out .= "\n$form_end";
|
||||||
|
|
||||||
|
|
||||||
|
$javascript = sprintf("%s.gui_object('subscriptionlist', '%s');\n", $JS_OBJECT_NAME, $attrib['id']);
|
||||||
|
$javascript .= sprintf("%s.set_env('subscriptionrows', %s);", $JS_OBJECT_NAME, array2js($a_js_folders));
|
||||||
|
$OUTPUT->add_script($javascript);
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function rcube_create_folder_form($attrib)
|
||||||
|
{
|
||||||
|
global $JS_OBJECT_NAME;
|
||||||
|
|
||||||
|
list($form_start, $form_end) = get_form_tags($attrib, 'create-folder');
|
||||||
|
unset($attrib['form']);
|
||||||
|
|
||||||
|
|
||||||
|
// return the complete edit form as table
|
||||||
|
$out = "$form_start\n";
|
||||||
|
|
||||||
|
$input = new textfield(array('name' => '_folder_name'));
|
||||||
|
$out .= $input->show();
|
||||||
|
|
||||||
|
if (get_boolean($attrib['button']))
|
||||||
|
{
|
||||||
|
$button = new input_field(array('type' => 'button',
|
||||||
|
'value' => rcube_label('create'),
|
||||||
|
'onclick' => "$JS_OBJECT_NAME.command('create-folder',this.form)"));
|
||||||
|
$out .= $button->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
$out .= "\n$form_end";
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
parse_template('managefolders');
|
||||||
|
?>
|
@ -0,0 +1,136 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/settings/save_identity.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Save an identity record or to add a new one |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$a_save_cols = array('name', 'email', 'organization', 'reply-to', 'bcc', 'default');
|
||||||
|
|
||||||
|
|
||||||
|
// update an existing contact
|
||||||
|
if ($_POST['_iid'])
|
||||||
|
{
|
||||||
|
$a_write_sql = array();
|
||||||
|
|
||||||
|
foreach ($a_save_cols as $col)
|
||||||
|
{
|
||||||
|
$fname = '_'.$col;
|
||||||
|
if (!isset($_POST[$fname]))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$a_write_sql[] = sprintf("`%s`='%s'", $col, addslashes($_POST[$fname]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sizeof($a_write_sql))
|
||||||
|
{
|
||||||
|
$DB->query(sprintf("UPDATE %s
|
||||||
|
SET %s
|
||||||
|
WHERE identity_id=%d
|
||||||
|
AND user_id=%d
|
||||||
|
AND del!='1'",
|
||||||
|
get_table_name('identities'),
|
||||||
|
join(', ', $a_write_sql),
|
||||||
|
$_POST['_iid'],
|
||||||
|
$_SESSION['user_id']));
|
||||||
|
|
||||||
|
$updated = $DB->affected_rows();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($updated)
|
||||||
|
{
|
||||||
|
show_message('successfullysaved', 'confirmation');
|
||||||
|
|
||||||
|
// mark all other identities as 'not-default'
|
||||||
|
$DB->query(sprintf("UPDATE %s
|
||||||
|
SET `default`='0'
|
||||||
|
WHERE identity_id!=%d
|
||||||
|
AND user_id=%d
|
||||||
|
AND del!='1'",
|
||||||
|
get_table_name('identities'),
|
||||||
|
$_POST['_iid'],
|
||||||
|
$_SESSION['user_id']));
|
||||||
|
|
||||||
|
if ($_POST['_framed'])
|
||||||
|
{
|
||||||
|
// update the changed col in list
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// show error message
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert a new contact
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$a_insert_cols = $a_insert_values = array();
|
||||||
|
|
||||||
|
foreach ($a_save_cols as $col)
|
||||||
|
{
|
||||||
|
$fname = '_'.$col;
|
||||||
|
if (!isset($_POST[$fname]))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$a_insert_cols[] = "`$col`";
|
||||||
|
$a_insert_values[] = sprintf("'%s'", addslashes($_POST[$fname]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sizeof($a_insert_cols))
|
||||||
|
{
|
||||||
|
$DB->query(sprintf("INSERT INTO %s
|
||||||
|
(user_id, %s)
|
||||||
|
VALUES (%d, %s)",
|
||||||
|
get_table_name('identities'),
|
||||||
|
join(', ', $a_insert_cols),
|
||||||
|
$_SESSION['user_id'],
|
||||||
|
join(', ', $a_insert_values)));
|
||||||
|
|
||||||
|
$insert_id = $DB->insert_id();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($insert_id)
|
||||||
|
{
|
||||||
|
$_GET['_iid'] = $insert_id;
|
||||||
|
|
||||||
|
if ($_POST['_framed'])
|
||||||
|
{
|
||||||
|
// add contact row or jump to the page where it should appear
|
||||||
|
// ....
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// show error message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// go to next step
|
||||||
|
if ($_POST['_framed'])
|
||||||
|
$_action = 'edit-identitiy';
|
||||||
|
else
|
||||||
|
$_action = 'identities';
|
||||||
|
|
||||||
|
|
||||||
|
// overwrite action variable
|
||||||
|
$OUTPUT->add_script(sprintf("\n%s.set_env('action', '%s');", $JS_OBJECT_NAME, $_action));
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| program/steps/settings/save_prefs.inc |
|
||||||
|
| |
|
||||||
|
| This file is part of the RoundCube Webmail client |
|
||||||
|
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
|
||||||
|
| All rights reserved. |
|
||||||
|
| |
|
||||||
|
| PURPOSE: |
|
||||||
|
| Save user preferences to DB and to the current session |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$a_user_prefs = $_SESSION['user_prefs'];
|
||||||
|
if (!is_array($a_user_prefs))
|
||||||
|
$a_user_prefs = array();
|
||||||
|
|
||||||
|
|
||||||
|
$a_user_prefs['timezone'] = isset($_POST['_timezone']) ? (int)$_POST['_timezone'] : $CONFIG['timezone'];
|
||||||
|
$a_user_prefs['pagesize'] = is_numeric($_POST['_pagesize']) ? (int)$_POST['_pagesize'] : $CONFIG['pagesize'];
|
||||||
|
$a_user_prefs['prefer_html'] = isset($_POST['_prefer_html']) ? TRUE : FALSE;
|
||||||
|
|
||||||
|
if (isset($_POST['_language']))
|
||||||
|
$sess_user_lang = $_SESSION['user_lang'] = $_POST['_language'];
|
||||||
|
|
||||||
|
|
||||||
|
$DB->query(sprintf("UPDATE %s
|
||||||
|
SET preferences='%s',
|
||||||
|
language='%s'
|
||||||
|
WHERE user_id=%d",
|
||||||
|
get_table_name('users'),
|
||||||
|
addslashes(serialize($a_user_prefs)),
|
||||||
|
$sess_user_lang,
|
||||||
|
$_SESSION['user_id']));
|
||||||
|
|
||||||
|
if ($DB->affected_rows())
|
||||||
|
{
|
||||||
|
show_message('successfullysaved', 'confirmation');
|
||||||
|
|
||||||
|
$_SESSION['user_prefs'] = $a_user_prefs;
|
||||||
|
$CONFIG = array_merge($CONFIG, $a_user_prefs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// go to next step
|
||||||
|
$_action = 'preferences';
|
||||||
|
|
||||||
|
// overwrite action variable
|
||||||
|
$OUTPUT->add_script(sprintf("\n%s.set_env('action', '%s');", $JS_OBJECT_NAME, $_action));
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,119 @@
|
|||||||
|
/***** RoundCube|Mail address book task styles *****/
|
||||||
|
|
||||||
|
|
||||||
|
#abooktoolbar
|
||||||
|
{
|
||||||
|
position: absolute;
|
||||||
|
top: 32px;
|
||||||
|
left: 200px;
|
||||||
|
height: 35px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#abooktoolbar a
|
||||||
|
{
|
||||||
|
padding-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#abookcountbar
|
||||||
|
{
|
||||||
|
position: absolute;
|
||||||
|
top: 50px;
|
||||||
|
left: 490px;
|
||||||
|
width: 200px;
|
||||||
|
height: 20px;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
#abookcountbar span
|
||||||
|
{
|
||||||
|
font-size: 11px;
|
||||||
|
color: #333333;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#addresslist
|
||||||
|
{
|
||||||
|
position: absolute;
|
||||||
|
top: 75px;
|
||||||
|
left: 20px;
|
||||||
|
width: 450px;
|
||||||
|
bottom: 60px;
|
||||||
|
border: 1px solid #999999;
|
||||||
|
background-color: #F9F9F9;
|
||||||
|
overflow: auto;
|
||||||
|
/* css hack for IE */
|
||||||
|
height: expression((parseInt(document.documentElement.clientHeight)-135)+'px');
|
||||||
|
}
|
||||||
|
|
||||||
|
#contacts-table
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
table-layout: fixed;
|
||||||
|
/* css hack for IE */
|
||||||
|
width: expression(document.getElementById('addresslist').clientWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#contacts-table tbody td
|
||||||
|
{
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#contacts-box
|
||||||
|
{
|
||||||
|
position: absolute;
|
||||||
|
top: 75px;
|
||||||
|
left: 490px;
|
||||||
|
right: 40px;
|
||||||
|
bottom: 60px;
|
||||||
|
border: 1px solid #999999;
|
||||||
|
overflow: hidden;
|
||||||
|
/* css hack for IE */
|
||||||
|
width: expression((parseInt(document.documentElement.clientWidth)-530)+'px');
|
||||||
|
height: expression((parseInt(document.documentElement.clientHeight)-135)+'px');
|
||||||
|
}
|
||||||
|
|
||||||
|
body.iframe,
|
||||||
|
#contact-frame
|
||||||
|
{
|
||||||
|
background-color: #F9F9F9;
|
||||||
|
}
|
||||||
|
|
||||||
|
#contact-frame
|
||||||
|
{
|
||||||
|
border: none;
|
||||||
|
/* visibility: hidden; */
|
||||||
|
}
|
||||||
|
|
||||||
|
#contact-title
|
||||||
|
{
|
||||||
|
height: 12px !important;
|
||||||
|
/* height: 20px; */
|
||||||
|
padding: 4px 20px 3px 20px;
|
||||||
|
border-bottom: 1px solid #999999;
|
||||||
|
color: #333333;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: bold;
|
||||||
|
background-color: #EBEBEB;
|
||||||
|
background-image: url(images/listheader_aqua.gif);
|
||||||
|
}
|
||||||
|
|
||||||
|
#contact-details
|
||||||
|
{
|
||||||
|
padding: 15px 20px 10px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#contact-details table td.title
|
||||||
|
{
|
||||||
|
color: #666666;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: right;
|
||||||
|
padding-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,277 @@
|
|||||||
|
/***** RoundCube|Mail basic styles *****/
|
||||||
|
|
||||||
|
body
|
||||||
|
{
|
||||||
|
margin: 8px;
|
||||||
|
background-color: #F2F2F2; /* #EBEBEB; */
|
||||||
|
color: #000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.iframe
|
||||||
|
{
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.extwin
|
||||||
|
{
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
body, td, th, span, div, p, h3
|
||||||
|
{
|
||||||
|
font-family: "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
th
|
||||||
|
{
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3
|
||||||
|
{
|
||||||
|
font-family: "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
|
||||||
|
font-size: 18px;
|
||||||
|
color: #000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
a, a:active, a:visited
|
||||||
|
{
|
||||||
|
color: #000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.button, a.button:visited, a.tab, a.tab:visited, a.axislist
|
||||||
|
{
|
||||||
|
color: #000000;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.tab
|
||||||
|
{
|
||||||
|
width: 80px;
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr
|
||||||
|
{
|
||||||
|
height: 1px;
|
||||||
|
background-color: #666666;
|
||||||
|
border-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
input, textarea
|
||||||
|
{
|
||||||
|
font-size: 9pt;
|
||||||
|
font-family: "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
|
||||||
|
padding: 1px;
|
||||||
|
padding-left: 3px;
|
||||||
|
padding-right: 3px;
|
||||||
|
background-color: #ffffff;
|
||||||
|
border: 1px solid #666666;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.button
|
||||||
|
{
|
||||||
|
height: 20px;
|
||||||
|
color: #333333;
|
||||||
|
font-size: 12px;
|
||||||
|
padding-left: 8px;
|
||||||
|
padding-right: 8px;
|
||||||
|
background: url(images/buttons/bg.gif) repeat-x #f0f0f0;
|
||||||
|
border: 1px solid #a4a4a4;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.button:hover
|
||||||
|
{
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
img
|
||||||
|
{
|
||||||
|
behavior: url('skins/default/pngbehavior.htc');
|
||||||
|
}
|
||||||
|
|
||||||
|
.alttext
|
||||||
|
{
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** common user interface objects */
|
||||||
|
|
||||||
|
#header
|
||||||
|
{
|
||||||
|
/* margin: 10px auto; */
|
||||||
|
width: 170px;
|
||||||
|
height: 40px;
|
||||||
|
margin-top: 0px;
|
||||||
|
margin-left: 10px;
|
||||||
|
/* border: 1px solid #cccccc; */
|
||||||
|
}
|
||||||
|
|
||||||
|
#footer
|
||||||
|
{
|
||||||
|
position: fixed !important;
|
||||||
|
left: 0px;
|
||||||
|
right: 0px;
|
||||||
|
bottom: 0px !important;
|
||||||
|
height: 40px;
|
||||||
|
background-color: #f2f2f2;
|
||||||
|
|
||||||
|
/* css hack for IE */
|
||||||
|
position: absolute;
|
||||||
|
bottom: auto;
|
||||||
|
top: expression((parseInt(document.documentElement.clientHeight)+parseInt(document.documentElement.scrollTop)-42)+'px');
|
||||||
|
width: expression(parseInt(document.documentElement.clientWidth)+'px');
|
||||||
|
}
|
||||||
|
|
||||||
|
#taskbar
|
||||||
|
{
|
||||||
|
margin: 0px auto;
|
||||||
|
width: 400px;
|
||||||
|
height: 34px;
|
||||||
|
padding: 3px;
|
||||||
|
text-align: center;
|
||||||
|
border: 1px solid #cccccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
#taskbar a
|
||||||
|
{
|
||||||
|
padding-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#message
|
||||||
|
{
|
||||||
|
position: absolute;
|
||||||
|
display: none;
|
||||||
|
top: 0px;
|
||||||
|
left: 200px;
|
||||||
|
right: 200px;
|
||||||
|
z-index: 5000;
|
||||||
|
}
|
||||||
|
|
||||||
|
#message div
|
||||||
|
{
|
||||||
|
width: 400px;
|
||||||
|
margin: 0px auto;
|
||||||
|
height: 22px;
|
||||||
|
min-height: 22px;
|
||||||
|
padding: 8px 10px 8px 46px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#message div.notice,
|
||||||
|
#remote-objects-message
|
||||||
|
{
|
||||||
|
background: url(images/display/info.png) 6px 3px no-repeat;
|
||||||
|
background-color: #F7FDCB;
|
||||||
|
border: 1px solid #C2D071;
|
||||||
|
}
|
||||||
|
|
||||||
|
#message div.error,
|
||||||
|
#message div.warning
|
||||||
|
{
|
||||||
|
background: url(images/display/warning.png) 6px 3px no-repeat;
|
||||||
|
background-color: #EF9398;
|
||||||
|
border: 1px solid #DC5757;
|
||||||
|
}
|
||||||
|
|
||||||
|
#message div.confirmation
|
||||||
|
{
|
||||||
|
background: url(images/display/confirm.png) 6px 3px no-repeat;
|
||||||
|
background-color: #A6EF7B;
|
||||||
|
border: 1px solid #76C83F;
|
||||||
|
}
|
||||||
|
|
||||||
|
#message div.loading
|
||||||
|
{
|
||||||
|
background: url(images/display/loading.gif) 6px 3px no-repeat;
|
||||||
|
background-color: #EFEFEF;
|
||||||
|
border: 1px solid #CCCCCC;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***** common table settings ******/
|
||||||
|
|
||||||
|
table.records-table thead tr td
|
||||||
|
{
|
||||||
|
height: 20px;
|
||||||
|
padding: 0px 4px 0px 4px;
|
||||||
|
vertical-align: middle;
|
||||||
|
border-bottom: 1px solid #999999;
|
||||||
|
color: #333333;
|
||||||
|
background-color: #EBEBEB;
|
||||||
|
background-image: url(images/listheader_aqua.gif);
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.records-table tbody tr td
|
||||||
|
{
|
||||||
|
height: 16px;
|
||||||
|
padding: 2px 4px 2px 4px;
|
||||||
|
font-size: 11px;
|
||||||
|
white-space: nowrap;
|
||||||
|
border-bottom: 1px solid #EBEBEB;
|
||||||
|
overflow: hidden;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.records-table tr
|
||||||
|
{
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.records-table tr.selected td
|
||||||
|
{
|
||||||
|
font-weight: bold;
|
||||||
|
color: #FFFFFF;
|
||||||
|
background-color: #CC3333;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/***** roundcube webmail pre-defined classes *****/
|
||||||
|
|
||||||
|
a.rcmContactAddress
|
||||||
|
{
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.rcmContactAddress:hover
|
||||||
|
{
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
#rcmKSearchpane
|
||||||
|
{
|
||||||
|
background-color: #F9F9F9;
|
||||||
|
border: 1px solid #CCCCCC;
|
||||||
|
}
|
||||||
|
|
||||||
|
#rcmKSearchpane ul
|
||||||
|
{
|
||||||
|
margin: 0px;
|
||||||
|
padding: 2px;
|
||||||
|
list-style-image: none;
|
||||||
|
list-style-type: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#rcmKSearchpane ul li
|
||||||
|
{
|
||||||
|
height: 16px;
|
||||||
|
font-size: 11px;
|
||||||
|
padding-left: 8px;
|
||||||
|
padding-top: 2px;
|
||||||
|
padding-right: 8px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
#rcmKSearchpane ul li.selected
|
||||||
|
{
|
||||||
|
color: #ffffff;
|
||||||
|
background-color: #CC3333;
|
||||||
|
}
|
||||||
|
|
After Width: | Height: | Size: 56 B |
After Width: | Height: | Size: 295 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 301 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 211 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 454 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 267 B |
After Width: | Height: | Size: 260 B |
After Width: | Height: | Size: 262 B |
After Width: | Height: | Size: 277 B |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.4 KiB |