- Merge devel-framework branch, resolved conflicts
parent
ce64332e7a
commit
0c259682f6
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+-----------------------------------------------------------------------+
|
||||
| program/include/rcube_base_replacer.php |
|
||||
| |
|
||||
| This file is part of the Roundcube Webmail client |
|
||||
| Copyright (C) 2005-2012, The Roundcube Dev Team |
|
||||
| |
|
||||
| Licensed under the GNU General Public License version 3 or |
|
||||
| any later version with exceptions for skins & plugins. |
|
||||
| See the README file for a full license statement. |
|
||||
| |
|
||||
| PURPOSE: |
|
||||
| Provide basic functions for base URL replacement |
|
||||
| |
|
||||
+-----------------------------------------------------------------------+
|
||||
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||
+-----------------------------------------------------------------------+
|
||||
|
||||
$Id$
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* Helper class to turn relative urls into absolute ones
|
||||
* using a predefined base
|
||||
*
|
||||
* @package Core
|
||||
* @author Thomas Bruederli <roundcube@gmail.com>
|
||||
*/
|
||||
class rcube_base_replacer
|
||||
{
|
||||
private $base_url;
|
||||
|
||||
|
||||
public function __construct($base)
|
||||
{
|
||||
$this->base_url = $base;
|
||||
}
|
||||
|
||||
|
||||
public function callback($matches)
|
||||
{
|
||||
return $matches[1] . '="' . self::absolute_url($matches[3], $this->base_url) . '"';
|
||||
}
|
||||
|
||||
|
||||
public function replace($body)
|
||||
{
|
||||
return preg_replace_callback(array(
|
||||
'/(src|background|href)=(["\']?)([^"\'\s]+)(\2|\s|>)/Ui',
|
||||
'/(url\s*\()(["\']?)([^"\'\)\s]+)(\2)\)/Ui',
|
||||
),
|
||||
array($this, 'callback'), $body);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert paths like ../xxx to an absolute path using a base url
|
||||
*
|
||||
* @param string $path Relative path
|
||||
* @param string $base_url Base URL
|
||||
*
|
||||
* @return string Absolute URL
|
||||
*/
|
||||
public static function absolute_url($path, $base_url)
|
||||
{
|
||||
$host_url = $base_url;
|
||||
$abs_path = $path;
|
||||
|
||||
// check if path is an absolute URL
|
||||
if (preg_match('/^[fhtps]+:\/\//', $path)) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
// check if path is a content-id scheme
|
||||
if (strpos($path, 'cid:') === 0) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
// cut base_url to the last directory
|
||||
if (strrpos($base_url, '/') > 7) {
|
||||
$host_url = substr($base_url, 0, strpos($base_url, '/', 7));
|
||||
$base_url = substr($base_url, 0, strrpos($base_url, '/'));
|
||||
}
|
||||
|
||||
// $path is absolute
|
||||
if ($path[0] == '/') {
|
||||
$abs_path = $host_url.$path;
|
||||
}
|
||||
else {
|
||||
// strip './' because its the same as ''
|
||||
$path = preg_replace('/^\.\//', '', $path);
|
||||
|
||||
if (preg_match_all('/\.\.\//', $path, $matches, PREG_SET_ORDER)) {
|
||||
foreach ($matches as $a_match) {
|
||||
if (strrpos($base_url, '/')) {
|
||||
$base_url = substr($base_url, 0, strrpos($base_url, '/'));
|
||||
}
|
||||
$path = substr($path, 3);
|
||||
}
|
||||
}
|
||||
|
||||
$abs_path = $base_url.'/'.$path;
|
||||
}
|
||||
|
||||
return $abs_path;
|
||||
}
|
||||
}
|
@ -1,323 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+-----------------------------------------------------------------------+
|
||||
| program/include/rcube_html_page.php |
|
||||
| |
|
||||
| This file is part of the Roundcube PHP suite |
|
||||
| Copyright (C) 2005-2011 The Roundcube Dev Team |
|
||||
| |
|
||||
| Licensed under the GNU General Public License version 3 or |
|
||||
| any later version with exceptions for skins & plugins. |
|
||||
| See the README file for a full license statement. |
|
||||
| |
|
||||
| CONTENTS: |
|
||||
| Class to build XHTML page output |
|
||||
| |
|
||||
+-----------------------------------------------------------------------+
|
||||
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||
+-----------------------------------------------------------------------+
|
||||
|
||||
$Id$
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class for HTML page creation
|
||||
*
|
||||
* @package HTML
|
||||
*/
|
||||
class rcube_html_page
|
||||
{
|
||||
protected $scripts_path = '';
|
||||
protected $script_files = array();
|
||||
protected $css_files = array();
|
||||
protected $scripts = array();
|
||||
protected $charset = RCMAIL_CHARSET;
|
||||
protected $default_template = "<html>\n<head><title></title></head>\n<body></body>\n</html>";
|
||||
|
||||
protected $title = '';
|
||||
protected $header = '';
|
||||
protected $footer = '';
|
||||
protected $body = '';
|
||||
protected $base_path = '';
|
||||
|
||||
|
||||
/** Constructor */
|
||||
public function __construct() {}
|
||||
|
||||
/**
|
||||
* Link an external script file
|
||||
*
|
||||
* @param string File URL
|
||||
* @param string Target position [head|foot]
|
||||
*/
|
||||
public function include_script($file, $position='head')
|
||||
{
|
||||
static $sa_files = array();
|
||||
|
||||
if (!preg_match('|^https?://|i', $file) && $file[0] != '/') {
|
||||
$file = $this->scripts_path . $file;
|
||||
if ($fs = @filemtime($file)) {
|
||||
$file .= '?s=' . $fs;
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($file, $sa_files)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sa_files[] = $file;
|
||||
|
||||
if (!is_array($this->script_files[$position])) {
|
||||
$this->script_files[$position] = array();
|
||||
}
|
||||
|
||||
$this->script_files[$position][] = $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add inline javascript code
|
||||
*
|
||||
* @param string JS code snippet
|
||||
* @param string Target position [head|head_top|foot]
|
||||
*/
|
||||
public function add_script($script, $position='head')
|
||||
{
|
||||
if (!isset($this->scripts[$position])) {
|
||||
$this->scripts[$position] = "\n" . rtrim($script);
|
||||
}
|
||||
else {
|
||||
$this->scripts[$position] .= "\n" . rtrim($script);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Link an external css file
|
||||
*
|
||||
* @param string File URL
|
||||
*/
|
||||
public function include_css($file)
|
||||
{
|
||||
$this->css_files[] = $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add HTML code to the page header
|
||||
*
|
||||
* @param string $str HTML code
|
||||
*/
|
||||
public function add_header($str)
|
||||
{
|
||||
$this->header .= "\n" . $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add HTML code to the page footer
|
||||
* To be added right befor </body>
|
||||
*
|
||||
* @param string $str HTML code
|
||||
*/
|
||||
public function add_footer($str)
|
||||
{
|
||||
$this->footer .= "\n" . $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for page title
|
||||
*
|
||||
* @param string $t Page title
|
||||
*/
|
||||
public function set_title($t)
|
||||
{
|
||||
$this->title = $t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for output charset.
|
||||
* To be specified in a meta tag and sent as http-header
|
||||
*
|
||||
* @param string $charset Charset
|
||||
*/
|
||||
public function set_charset($charset)
|
||||
{
|
||||
$this->charset = $charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for output charset
|
||||
*
|
||||
* @return string Output charset
|
||||
*/
|
||||
public function get_charset()
|
||||
{
|
||||
return $this->charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset all saved properties
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->script_files = array();
|
||||
$this->scripts = array();
|
||||
$this->title = '';
|
||||
$this->header = '';
|
||||
$this->footer = '';
|
||||
$this->body = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Process template and write to stdOut
|
||||
*
|
||||
* @param string HTML template
|
||||
* @param string Base for absolute paths
|
||||
*/
|
||||
public function write($templ='', $base_path='')
|
||||
{
|
||||
$output = empty($templ) ? $this->default_template : trim($templ);
|
||||
|
||||
// set default page title
|
||||
if (empty($this->title)) {
|
||||
$this->title = 'Roundcube Mail';
|
||||
}
|
||||
|
||||
// replace specialchars in content
|
||||
$page_title = Q($this->title, 'show', FALSE);
|
||||
$page_header = '';
|
||||
$page_footer = '';
|
||||
|
||||
// include meta tag with charset
|
||||
if (!empty($this->charset)) {
|
||||
if (!headers_sent()) {
|
||||
header('Content-Type: text/html; charset=' . $this->charset);
|
||||
}
|
||||
$page_header = '<meta http-equiv="content-type"';
|
||||
$page_header.= ' content="text/html; charset=';
|
||||
$page_header.= $this->charset . '" />'."\n";
|
||||
}
|
||||
|
||||
// definition of the code to be placed in the document header and footer
|
||||
if (is_array($this->script_files['head'])) {
|
||||
foreach ($this->script_files['head'] as $file) {
|
||||
$page_header .= html::script($file);
|
||||
}
|
||||
}
|
||||
|
||||
$head_script = $this->scripts['head_top'] . $this->scripts['head'];
|
||||
if (!empty($head_script)) {
|
||||
$page_header .= html::script(array(), $head_script);
|
||||
}
|
||||
|
||||
if (!empty($this->header)) {
|
||||
$page_header .= $this->header;
|
||||
}
|
||||
|
||||
// put docready commands into page footer
|
||||
if (!empty($this->scripts['docready'])) {
|
||||
$this->add_script('$(document).ready(function(){ ' . $this->scripts['docready'] . "\n});", 'foot');
|
||||
}
|
||||
|
||||
if (is_array($this->script_files['foot'])) {
|
||||
foreach ($this->script_files['foot'] as $file) {
|
||||
$page_footer .= html::script($file);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->footer)) {
|
||||
$page_footer .= $this->footer . "\n";
|
||||
}
|
||||
|
||||
if (!empty($this->scripts['foot'])) {
|
||||
$page_footer .= html::script(array(), $this->scripts['foot']);
|
||||
}
|
||||
|
||||
// find page header
|
||||
if ($hpos = stripos($output, '</head>')) {
|
||||
$page_header .= "\n";
|
||||
}
|
||||
else {
|
||||
if (!is_numeric($hpos)) {
|
||||
$hpos = stripos($output, '<body');
|
||||
}
|
||||
if (!is_numeric($hpos) && ($hpos = stripos($output, '<html'))) {
|
||||
while ($output[$hpos] != '>') {
|
||||
$hpos++;
|
||||
}
|
||||
$hpos++;
|
||||
}
|
||||
$page_header = "<head>\n<title>$page_title</title>\n$page_header\n</head>\n";
|
||||
}
|
||||
|
||||
// add page hader
|
||||
if ($hpos) {
|
||||
$output = substr_replace($output, $page_header, $hpos, 0);
|
||||
}
|
||||
else {
|
||||
$output = $page_header . $output;
|
||||
}
|
||||
|
||||
// add page footer
|
||||
if (($fpos = strripos($output, '</body>')) || ($fpos = strripos($output, '</html>'))) {
|
||||
$output = substr_replace($output, $page_footer."\n", $fpos, 0);
|
||||
}
|
||||
else {
|
||||
$output .= "\n".$page_footer;
|
||||
}
|
||||
|
||||
// add css files in head, before scripts, for speed up with parallel downloads
|
||||
if (!empty($this->css_files) &&
|
||||
(($pos = stripos($output, '<script ')) || ($pos = stripos($output, '</head>')))
|
||||
) {
|
||||
$css = '';
|
||||
foreach ($this->css_files as $file) {
|
||||
$css .= html::tag('link', array('rel' => 'stylesheet',
|
||||
'type' => 'text/css', 'href' => $file, 'nl' => true));
|
||||
}
|
||||
$output = substr_replace($output, $css, $pos, 0);
|
||||
}
|
||||
|
||||
$this->base_path = $base_path;
|
||||
|
||||
// correct absolute paths in images and other tags
|
||||
// add timestamp to .js and .css filename
|
||||
$output = preg_replace_callback(
|
||||
'!(src|href|background)=(["\']?)([a-z0-9/_.-]+)(["\'\s>])!i',
|
||||
array($this, 'file_callback'), $output);
|
||||
|
||||
// trigger hook with final HTML content to be sent
|
||||
$hook = rcmail::get_instance()->plugins->exec_hook("send_page", array('content' => $output));
|
||||
if (!$hook['abort']) {
|
||||
if ($this->charset != RCMAIL_CHARSET) {
|
||||
echo rcube_charset_convert($hook['content'], RCMAIL_CHARSET, $this->charset);
|
||||
}
|
||||
else {
|
||||
echo $hook['content'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function for preg_replace_callback in write()
|
||||
*
|
||||
* @return string Parsed string
|
||||
*/
|
||||
private function file_callback($matches)
|
||||
{
|
||||
$file = $matches[3];
|
||||
|
||||
// correct absolute paths
|
||||
if ($file[0] == '/') {
|
||||
$file = $this->base_path . $file;
|
||||
}
|
||||
|
||||
// add file modification timestamp
|
||||
if (preg_match('/\.(js|css)$/', $file)) {
|
||||
if ($fs = @filemtime($file)) {
|
||||
$file .= '?s=' . $fs;
|
||||
}
|
||||
}
|
||||
|
||||
return $matches[1] . '=' . $matches[2] . $file . $matches[4];
|
||||
}
|
||||
}
|
@ -0,0 +1,238 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
+-----------------------------------------------------------------------+
|
||||
| program/include/rcube_message_header.php |
|
||||
| |
|
||||
| This file is part of the Roundcube Webmail client |
|
||||
| Copyright (C) 2005-2012, The Roundcube Dev Team |
|
||||
| Copyright (C) 2011-2012, Kolab Systems AG |
|
||||
| |
|
||||
| Licensed under the GNU General Public License version 3 or |
|
||||
| any later version with exceptions for skins & plugins. |
|
||||
| See the README file for a full license statement. |
|
||||
| |
|
||||
| PURPOSE: |
|
||||
| E-mail message headers representation |
|
||||
| |
|
||||
+-----------------------------------------------------------------------+
|
||||
| Author: Aleksander Machniak <alec@alec.pl> |
|
||||
+-----------------------------------------------------------------------+
|
||||
|
||||
$Id$
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* Struct representing an e-mail message header
|
||||
*
|
||||
* @package Mail
|
||||
* @author Aleksander Machniak <alec@alec.pl>
|
||||
*/
|
||||
class rcube_message_header
|
||||
{
|
||||
/**
|
||||
* Message sequence number
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* Message unique identifier
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $uid;
|
||||
|
||||
/**
|
||||
* Message subject
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $subject;
|
||||
|
||||
/**
|
||||
* Message sender (From)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $from;
|
||||
|
||||
/**
|
||||
* Message recipient (To)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $to;
|
||||
|
||||
/**
|
||||
* Message additional recipients (Cc)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $cc;
|
||||
|
||||
/**
|
||||
* Message Reply-To header
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $replyto;
|
||||
|
||||
/**
|
||||
* Message In-Reply-To header
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $in_reply_to;
|
||||
|
||||
/**
|
||||
* Message date (Date)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $date;
|
||||
|
||||
/**
|
||||
* Message identifier (Message-ID)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $messageID;
|
||||
|
||||
/**
|
||||
* Message size
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $size;
|
||||
|
||||
/**
|
||||
* Message encoding
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $encoding;
|
||||
|
||||
/**
|
||||
* Message charset
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $charset;
|
||||
|
||||
/**
|
||||
* Message Content-type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $ctype;
|
||||
|
||||
/**
|
||||
* Message timestamp (based on message date)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timestamp;
|
||||
|
||||
/**
|
||||
* IMAP bodystructure string
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $bodystructure;
|
||||
|
||||
/**
|
||||
* IMAP internal date
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $internaldate;
|
||||
|
||||
/**
|
||||
* Message References header
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $references;
|
||||
|
||||
/**
|
||||
* Message priority (X-Priority)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $priority;
|
||||
|
||||
/**
|
||||
* Message receipt recipient
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $mdn_to;
|
||||
|
||||
/**
|
||||
* Other message headers
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $others = array();
|
||||
|
||||
/**
|
||||
* Message flags
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $flags = array();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class for sorting an array of rcube_message_header objects in a predetermined order.
|
||||
*
|
||||
* @package Mail
|
||||
* @author Aleksander Machniak <alec@alec.pl>
|
||||
*/
|
||||
class rcube_message_header_sorter
|
||||
{
|
||||
private $uids = array();
|
||||
|
||||
|
||||
/**
|
||||
* Set the predetermined sort order.
|
||||
*
|
||||
* @param array $index Numerically indexed array of IMAP UIDs
|
||||
*/
|
||||
function set_index($index)
|
||||
{
|
||||
$index = array_flip($index);
|
||||
|
||||
$this->uids = $index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the array of header objects
|
||||
*
|
||||
* @param array $headers Array of rcube_message_header objects indexed by UID
|
||||
*/
|
||||
function sort_headers(&$headers)
|
||||
{
|
||||
uksort($headers, array($this, "compare_uids"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort method called by uksort()
|
||||
*
|
||||
* @param int $a Array key (UID)
|
||||
* @param int $b Array key (UID)
|
||||
*/
|
||||
function compare_uids($a, $b)
|
||||
{
|
||||
// then find each sequence number in my ordered list
|
||||
$posa = isset($this->uids[$a]) ? intval($this->uids[$a]) : -1;
|
||||
$posb = isset($this->uids[$b]) ? intval($this->uids[$b]) : -1;
|
||||
|
||||
// return the relative position as the comparison value
|
||||
return $posa - $posb;
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+-----------------------------------------------------------------------+
|
||||
| program/include/rcube_message_part.php |
|
||||
| |
|
||||
| This file is part of the Roundcube Webmail client |
|
||||
| Copyright (C) 2005-2012, The Roundcube Dev Team |
|
||||
| Copyright (C) 2011-2012, Kolab Systems AG |
|
||||
| |
|
||||
| Licensed under the GNU General Public License version 3 or |
|
||||
| any later version with exceptions for skins & plugins. |
|
||||
| See the README file for a full license statement. |
|
||||
| |
|
||||
| PURPOSE: |
|
||||
| Class representing a message part |
|
||||
| |
|
||||
+-----------------------------------------------------------------------+
|
||||
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||
| Author: Aleksander Machniak <alec@alec.pl> |
|
||||
+-----------------------------------------------------------------------+
|
||||
|
||||
$Id$
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class representing a message part
|
||||
*
|
||||
* @package Mail
|
||||
* @author Thomas Bruederli <roundcube@gmail.com>
|
||||
* @author Aleksander Machniak <alec@alec.pl>
|
||||
* @version 2.0
|
||||
*/
|
||||
class rcube_message_part
|
||||
{
|
||||
/**
|
||||
* Part MIME identifier
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $mime_id = '';
|
||||
|
||||
/**
|
||||
* Content main type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $ctype_primary = 'text';
|
||||
|
||||
/**
|
||||
* Content subtype
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $ctype_secondary = 'plain';
|
||||
|
||||
/**
|
||||
* Complete content type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $mimetype = 'text/plain';
|
||||
|
||||
public $disposition = '';
|
||||
public $filename = '';
|
||||
public $encoding = '8bit';
|
||||
public $charset = '';
|
||||
|
||||
/**
|
||||
* Part size in bytes
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $size = 0;
|
||||
|
||||
/**
|
||||
* Part headers
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $headers = array();
|
||||
|
||||
public $d_parameters = array();
|
||||
public $ctype_parameters = array();
|
||||
|
||||
|
||||
/**
|
||||
* Clone handler.
|
||||
*/
|
||||
function __clone()
|
||||
{
|
||||
if (isset($this->parts)) {
|
||||
foreach ($this->parts as $idx => $part) {
|
||||
if (is_object($part)) {
|
||||
$this->parts[$idx] = clone $part;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,259 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+-----------------------------------------------------------------------+
|
||||
| program/include/rcube_output.php |
|
||||
| |
|
||||
| This file is part of the Roundcube PHP suite |
|
||||
| Copyright (C) 2005-2012 The Roundcube Dev Team |
|
||||
| |
|
||||
| Licensed under the GNU General Public License version 3 or |
|
||||
| any later version with exceptions for skins & plugins. |
|
||||
| See the README file for a full license statement. |
|
||||
| CONTENTS: |
|
||||
| Abstract class for output generation |
|
||||
| |
|
||||
+-----------------------------------------------------------------------+
|
||||
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||
| Author: Aleksander Machniak <alec@alec.pl> |
|
||||
+-----------------------------------------------------------------------+
|
||||
|
||||
$Id$
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class for output generation
|
||||
*
|
||||
* @package HTML
|
||||
*/
|
||||
abstract class rcube_output
|
||||
{
|
||||
public $browser;
|
||||
public $type = 'html';
|
||||
public $ajax_call = false;
|
||||
public $framed = false;
|
||||
|
||||
protected $app;
|
||||
protected $config;
|
||||
protected $charset = RCMAIL_CHARSET;
|
||||
protected $env = array();
|
||||
protected $pagetitle = '';
|
||||
protected $object_handlers = array();
|
||||
|
||||
|
||||
/**
|
||||
* Object constructor
|
||||
*/
|
||||
public function __construct($task = null, $framed = false)
|
||||
{
|
||||
$this->app = rcmail::get_instance();
|
||||
$this->config = $this->app->config;
|
||||
$this->browser = new rcube_browser();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setter for page title
|
||||
*
|
||||
* @param string $title Page title
|
||||
*/
|
||||
public function set_pagetitle($title)
|
||||
{
|
||||
$this->pagetitle = $title;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setter for output charset.
|
||||
* To be specified in a meta tag and sent as http-header
|
||||
*
|
||||
* @param string $charset Charset name
|
||||
*/
|
||||
public function set_charset($charset)
|
||||
{
|
||||
$this->charset = $charset;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Getter for output charset
|
||||
*
|
||||
* @return string Output charset name
|
||||
*/
|
||||
public function get_charset()
|
||||
{
|
||||
return $this->charset;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Getter for the current skin path property
|
||||
*/
|
||||
public function get_skin_path()
|
||||
{
|
||||
return $this->config->get('skin_path');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set environment variable
|
||||
*
|
||||
* @param string $name Property name
|
||||
* @param mixed $value Property value
|
||||
*/
|
||||
public function set_env($name, $value)
|
||||
{
|
||||
$this->env[$name] = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Environment variable getter.
|
||||
*
|
||||
* @param string $name Property name
|
||||
*
|
||||
* @return mixed Property value
|
||||
*/
|
||||
public function get_env($name)
|
||||
{
|
||||
return $this->env[$name];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete all stored env variables and commands
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->env = array();
|
||||
$this->object_handlers = array();
|
||||
$this->pagetitle = '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call a client method
|
||||
*
|
||||
* @param string Method to call
|
||||
* @param ... Additional arguments
|
||||
*/
|
||||
abstract function command();
|
||||
|
||||
|
||||
/**
|
||||
* Add a localized label to the client environment
|
||||
*/
|
||||
abstract function add_label();
|
||||
|
||||
|
||||
/**
|
||||
* Invoke display_message command
|
||||
*
|
||||
* @param string $message Message to display
|
||||
* @param string $type Message type [notice|confirm|error]
|
||||
* @param array $vars Key-value pairs to be replaced in localized text
|
||||
* @param boolean $override Override last set message
|
||||
* @param int $timeout Message displaying time in seconds
|
||||
*/
|
||||
abstract function show_message($message, $type = 'notice', $vars = null, $override = true, $timeout = 0);
|
||||
|
||||
|
||||
/**
|
||||
* Redirect to a certain url.
|
||||
*
|
||||
* @param mixed $p Either a string with the action or url parameters as key-value pairs
|
||||
* @param int $delay Delay in seconds
|
||||
*/
|
||||
abstract function redirect($p = array(), $delay = 1);
|
||||
|
||||
|
||||
/**
|
||||
* Send output to the client.
|
||||
*/
|
||||
abstract function send();
|
||||
|
||||
|
||||
/**
|
||||
* Register a template object handler
|
||||
*
|
||||
* @param string Object name
|
||||
* @param string Function name to call
|
||||
* @return void
|
||||
*/
|
||||
public function add_handler($obj, $func)
|
||||
{
|
||||
$this->object_handlers[$obj] = $func;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register a list of template object handlers
|
||||
*
|
||||
* @param array Hash array with object=>handler pairs
|
||||
* @return void
|
||||
*/
|
||||
public function add_handlers($arr)
|
||||
{
|
||||
$this->object_handlers = array_merge($this->object_handlers, $arr);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send HTTP headers to prevent caching a page
|
||||
*/
|
||||
public function nocacheing_headers()
|
||||
{
|
||||
if (headers_sent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
header("Expires: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
// Request browser to disable DNS prefetching (CVE-2010-0464)
|
||||
header("X-DNS-Prefetch-Control: off");
|
||||
|
||||
// We need to set the following headers to make downloads work using IE in HTTPS mode.
|
||||
if ($this->browser->ie && rcube_ui::https_check()) {
|
||||
header('Pragma: private');
|
||||
header("Cache-Control: private, must-revalidate");
|
||||
}
|
||||
else {
|
||||
header("Cache-Control: private, no-cache, must-revalidate, post-check=0, pre-check=0");
|
||||
header("Pragma: no-cache");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show error page and terminate script execution
|
||||
*
|
||||
* @param int $code Error code
|
||||
* @param string $message Error message
|
||||
*/
|
||||
public function raise_error($code, $message)
|
||||
{
|
||||
// STUB: to be overloaded by specific output classes
|
||||
fputs(STDERR, "Error $code: $message\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a variable into a javascript object notation
|
||||
*
|
||||
* @param mixed Input value
|
||||
*
|
||||
* @return string Serialized JSON string
|
||||
*/
|
||||
public static function json_serialize($input)
|
||||
{
|
||||
$input = rcube_charset::clean($input);
|
||||
|
||||
// sometimes even using rcube_charset::clean() the input contains invalid UTF-8 sequences
|
||||
// that's why we have @ here
|
||||
return @json_encode($input);
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,79 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
+-----------------------------------------------------------------------+
|
||||
| program/include/rcube_sqlite.inc |
|
||||
| |
|
||||
| This file is part of the Roundcube Webmail client |
|
||||
| Copyright (C) 2005-2010, The Roundcube Dev Team |
|
||||
| |
|
||||
| Licensed under the GNU General Public License version 3 or |
|
||||
| any later version with exceptions for skins & plugins. |
|
||||
| See the README file for a full license statement. |
|
||||
| |
|
||||
| PURPOSE: |
|
||||
| Provide callback functions for sqlite that will emulate |
|
||||
| sone MySQL functions |
|
||||
| |
|
||||
+-----------------------------------------------------------------------+
|
||||
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||
+-----------------------------------------------------------------------+
|
||||
|
||||
$Id$
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* Callback functions for sqlite database interface
|
||||
*
|
||||
* @package Database
|
||||
*/
|
||||
|
||||
|
||||
function rcube_sqlite_from_unixtime($timestamp)
|
||||
{
|
||||
$timestamp = trim($timestamp);
|
||||
if (!preg_match('/^[0-9]+$/is', $timestamp))
|
||||
$ret = strtotime($timestamp);
|
||||
else
|
||||
$ret = $timestamp;
|
||||
|
||||
$ret = date('Y-m-d H:i:s', $ret);
|
||||
rcube_sqlite_debug("FROM_UNIXTIME ($timestamp) = $ret");
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
function rcube_sqlite_unix_timestamp($timestamp='')
|
||||
{
|
||||
$timestamp = trim($timestamp);
|
||||
if (!$timestamp)
|
||||
$ret = time();
|
||||
else if (!preg_match('/^[0-9]+$/is', $timestamp))
|
||||
$ret = strtotime($timestamp);
|
||||
else
|
||||
$ret = $timestamp;
|
||||
|
||||
rcube_sqlite_debug("UNIX_TIMESTAMP ($timestamp) = $ret");
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
function rcube_sqlite_now()
|
||||
{
|
||||
rcube_sqlite_debug("NOW() = ".date("Y-m-d H:i:s"));
|
||||
return date("Y-m-d H:i:s");
|
||||
}
|
||||
|
||||
|
||||
function rcube_sqlite_md5($str)
|
||||
{
|
||||
return md5($str);
|
||||
}
|
||||
|
||||
|
||||
function rcube_sqlite_debug($str)
|
||||
{
|
||||
//console($str);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue