diff options
Diffstat (limited to 'program/steps')
-rw-r--r-- | program/steps/mail/compose.inc | 3 | ||||
-rw-r--r-- | program/steps/mail/func.inc | 5 | ||||
-rw-r--r-- | program/steps/utils/html2text.inc | 28 | ||||
-rw-r--r-- | program/steps/utils/killcache.inc | 52 | ||||
-rw-r--r-- | program/steps/utils/modcss.inc | 98 | ||||
-rw-r--r-- | program/steps/utils/spell.inc (renamed from program/steps/mail/spell.inc) | 2 | ||||
-rw-r--r-- | program/steps/utils/spell_googie.inc (renamed from program/steps/mail/spell_googie.inc) | 4 | ||||
-rw-r--r-- | program/steps/utils/spell_pspell.inc (renamed from program/steps/mail/spell_pspell.inc) | 4 |
8 files changed, 187 insertions, 9 deletions
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index bc7cd8960..97541da91 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -555,7 +555,7 @@ function rcmail_compose_body($attrib) $OUTPUT->include_script('googiespell.js'); $OUTPUT->add_script(sprintf( - "var googie = new GoogieSpell('\$__skin_path/images/googiespell/','%s&_action=spell&lang=');\n". + "var googie = new GoogieSpell('\$__skin_path/images/googiespell/','?_task=utils&_action=spell&lang=');\n". "googie.lang_chck_spell = \"%s\";\n". "googie.lang_rsm_edt = \"%s\";\n". "googie.lang_close = \"%s\";\n". @@ -566,7 +566,6 @@ function rcmail_compose_body($attrib) "googie.setSpellContainer('spellcheck-control');\n". "googie.decorateTextarea('%s');\n". "%s.set_env('spellcheck', googie);", - $RCMAIL->comm_path, JQ(Q(rcube_label('checkspelling'))), JQ(Q(rcube_label('resumeediting'))), JQ(Q(rcube_label('close'))), diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 00a8edf95..951e777b1 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -27,7 +27,7 @@ $SEARCH_MODS_DEFAULT = array('*' => array('subject'=>1, 'from'=>1), $SENT_MBOX = $EMAIL_ADDRESS_PATTERN = '([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9][a-z0-9\-\.]*\\.[a-z]{2,5})'; // actions that do not require imap connection -$NOIMAP_ACTIONS = array('spell', 'addcontact', 'autocomplete', 'upload', 'display-attachment', 'remove-attachment'); +$NOIMAP_ACTIONS = array('addcontact', 'autocomplete', 'upload', 'display-attachment', 'remove-attachment'); // always instantiate imap object (but not yet connect to server) $RCMAIL->imap_init(); @@ -1068,7 +1068,8 @@ function rcmail_alter_html_link($matches) $end = '>'; if ($tag == 'link' && preg_match('/^https?:\/\//i', $attrib['href'])) { - $attrib['href'] = "./bin/modcss.php?u=" . urlencode($attrib['href']) . "&c=" . urlencode($GLOBALS['rcmail_html_container_id']); + $attrib['href'] = "?_task=utils&_action=modcss&u=" . urlencode($attrib['href']) + . "&c=" . urlencode($GLOBALS['rcmail_html_container_id']); $end = ' />'; } else if (preg_match('/^mailto:'.$EMAIL_ADDRESS_PATTERN.'(\?[^"\'>]+)?/i', $attrib['href'], $mailto)) { diff --git a/program/steps/utils/html2text.inc b/program/steps/utils/html2text.inc new file mode 100644 index 000000000..ff2b40e6b --- /dev/null +++ b/program/steps/utils/html2text.inc @@ -0,0 +1,28 @@ +<?php +/* + + +-----------------------------------------------------------------------+ + | program/steps/utils/html2text.inc | + | | + | This file is part of the RoundCube Webmail client | + | Copyright (C) 2005-2010, RoundCube Dev. - Switzerland | + | Licensed under the GNU GPL | + | | + | PURPOSE: | + | Convert HTML message to plain text | + | | + +-----------------------------------------------------------------------+ + | Author: Thomas Bruederli <roundcube@gmail.com> | + +-----------------------------------------------------------------------+ + + $Id$ + +*/ + +$converter = new html2text($HTTP_RAW_POST_DATA); + +header('Content-Type: text/plain; charset=UTF-8'); +print trim($converter->get_text()); +exit; + +?> diff --git a/program/steps/utils/killcache.inc b/program/steps/utils/killcache.inc new file mode 100644 index 000000000..a2e7b3e25 --- /dev/null +++ b/program/steps/utils/killcache.inc @@ -0,0 +1,52 @@ +<?php +/* + + +-----------------------------------------------------------------------+ + | program/steps/utils/killcache.inc | + | | + | This file is part of the RoundCube Webmail client | + | Copyright (C) 2005-2010, RoundCube Dev. - Switzerland | + | Licensed under the GNU GPL | + | | + | PURPOSE: | + | Delete rows from cache and messages tables | + | | + +-----------------------------------------------------------------------+ + | Author: Dennis P. Nikolaenko <dennis@nikolaenko.ru> | + +-----------------------------------------------------------------------+ + + $Id$ + +*/ + +// don't allow public access if not in devel_mode +if (!$RCMAIL->config->get('devel_mode')) { + header("HTTP/1.0 401 Access denied"); + die("Access denied!"); +} + +$options = array( + 'use_transactions' => false, + 'log_line_break' => "\n", + 'idxname_format' => '%s', + 'debug' => false, + 'quote_identifier' => true, + 'force_defaults' => false, + 'portability' => true +); + +// @TODO: transaction here (if supported by DB) would be a good thing +$res = $RCMAIL->db->query("DELETE FROM cache"); +if (PEAR::isError($res)) { + exit($res->getMessage()); +} + +$res = $RCMAIL->db->query("DELETE FROM messages"); +if (PEAR::isError($res)) { + exit($res->getMessage()); +} + +echo "Cache cleared\n"; +exit; + +?> diff --git a/program/steps/utils/modcss.inc b/program/steps/utils/modcss.inc new file mode 100644 index 000000000..2224901ac --- /dev/null +++ b/program/steps/utils/modcss.inc @@ -0,0 +1,98 @@ +<?php + +/* + +-----------------------------------------------------------------------+ + | program/steps/utils/modcss.inc | + | | + | This file is part of the RoundCube Webmail client | + | Copyright (C) 2007-2010, RoundCube Dev. - Switzerland | + | Licensed under the GNU GPL | + | | + | PURPOSE: | + | Modify CSS source from a URL | + | | + +-----------------------------------------------------------------------+ + | Author: Thomas Bruederli <roundcube@gmail.com> | + +-----------------------------------------------------------------------+ + + $Id$ + +*/ + +$source = ''; + +$url = preg_replace('![^a-z0-9:./\-_?$&=%]!i', '', $_GET['u']); +if ($url === null) { + header('HTTP/1.1 403 Forbidden'); + echo $error; + exit; +} + +$a_uri = parse_url($url); +$port = $a_uri['port'] ? $a_uri['port'] : 80; +$host = $a_uri['host']; +$path = $a_uri['path'] . ($a_uri['query'] ? '?'.$a_uri['query'] : ''); + +// don't allow any other connections than http(s) +if (strtolower(substr($a_uri['scheme'], 0, 4)) != 'http') { + header('HTTP/1.1 403 Forbidden'); + echo "Invalid URL"; + exit; +} + +// try to open socket connection +if (!($fp = fsockopen($host, $port, $errno, $error, 15))) { + header('HTTP/1.1 500 Internal Server Error'); + echo $error; + exit; +} + +// set timeout for socket +stream_set_timeout($fp, 30); + +// send request +$out = "GET $path HTTP/1.0\r\n"; +$out .= "Host: $host\r\n"; +$out .= "Connection: Close\r\n\r\n"; +fwrite($fp, $out); + +// read response +$header = true; +$headers = array(); +while (!feof($fp)) { + $line = trim(fgets($fp, 4048)); + + if ($header) { + if (preg_match('/^HTTP\/1\..\s+(\d+)/', $line, $regs) + && intval($regs[1]) != 200) { + break; + } + else if (empty($line)) { + $header = false; + } + else { + list($key, $value) = explode(': ', $line); + $headers[strtolower($key)] = $value; + } + } + else { + $source .= "$line\n"; + } +} +fclose($fp); + +// check content-type header and mod styles +$mimetype = strtolower($headers['content-type']); +if (!empty($source) && in_array($mimetype, array('text/css','text/plain'))) { + header('Content-Type: text/css'); + echo rcmail_mod_css_styles($source, preg_replace('/[^a-z0-9]/i', '', $_GET['c'])); + exit; +} +else + $error = "Invalid response returned by server"; + +header('HTTP/1.0 404 Not Found'); +echo $error; +exit; + +?> diff --git a/program/steps/mail/spell.inc b/program/steps/utils/spell.inc index a567c7bf6..dab56956b 100644 --- a/program/steps/mail/spell.inc +++ b/program/steps/utils/spell.inc @@ -2,7 +2,7 @@ /* +-----------------------------------------------------------------------+ - | program/steps/mail/spell.inc | + | program/steps/utils/spell.inc | | | | This file is part of the RoundCube Webmail client | | Licensed under the GNU GPL | diff --git a/program/steps/mail/spell_googie.inc b/program/steps/utils/spell_googie.inc index f3b1c684d..ec60f48f0 100644 --- a/program/steps/mail/spell_googie.inc +++ b/program/steps/utils/spell_googie.inc @@ -2,7 +2,7 @@ /* +-----------------------------------------------------------------------+ - | program/steps/mail/spell.inc | + | program/steps/utils/spell.inc | | | | This file is part of the RoundCube Webmail client | | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland | @@ -67,7 +67,7 @@ header("Content-Length: " . strlen($store)); // Don't use server's default Content-Type charset (#1486406) header("Content-Type: text/xml; charset=".RCMAIL_CHARSET); -print $store; +print $store; exit; ?> diff --git a/program/steps/mail/spell_pspell.inc b/program/steps/utils/spell_pspell.inc index b443ed525..f892f8963 100644 --- a/program/steps/mail/spell_pspell.inc +++ b/program/steps/utils/spell_pspell.inc @@ -2,7 +2,7 @@ /* +-----------------------------------------------------------------------+ - | program/steps/mail/spell_pspell.inc | + | program/steps/utils/spell_pspell.inc | | | | This file is part of the RoundCube Webmail client | | Licensed under the GNU GPL | @@ -25,7 +25,7 @@ if (!extension_loaded('pspell')) { 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Pspell extension not available"), true, false); - + header('HTTP/1.1 404 Not Found'); exit; } |