summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-09-08 09:40:39 +0000
committeralecpl <alec@alec.pl>2010-09-08 09:40:39 +0000
commit2aa2b332f6e216ceeabc36ef6b942c40d91bda5a (patch)
tree08a21f5cb3d9f7bc706fa34a73aba37baff9a03c /program
parentec581c106e51a46f4536caec397e2b34821db5de (diff)
- Small performance improvements
Diffstat (limited to 'program')
-rw-r--r--program/include/main.inc2
-rw-r--r--program/include/rcmail.php6
-rw-r--r--program/include/rcube_browser.php32
-rw-r--r--program/include/rcube_imap.php4
-rw-r--r--program/include/rcube_imap_generic.php4
-rwxr-xr-xprogram/include/rcube_template.php5
6 files changed, 28 insertions, 25 deletions
diff --git a/program/include/main.inc b/program/include/main.inc
index fa5534f10..04992fd89 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -700,7 +700,7 @@ function asciiwords($str, $css_id = false, $replace_with = '')
*/
function strip_quotes($str)
{
- return preg_replace('/[\'"]/', '', $str);
+ return str_replace(array("'", '"'), '', $str);
}
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 808f0db06..0a7c15d84 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -810,9 +810,9 @@ class rcmail
if (($attrib['uppercase'] && strtolower($attrib['uppercase']=='first')) || $attrib['ucfirst'])
return ucfirst($text);
else if ($attrib['uppercase'])
- return strtoupper($text);
+ return mb_strtoupper($text);
else if ($attrib['lowercase'])
- return strtolower($text);
+ return mb_strtolower($text);
return $text;
}
@@ -874,7 +874,7 @@ class rcmail
if ($dh = @opendir(INSTALL_PATH . 'program/localization')) {
while (($name = readdir($dh)) !== false) {
- if ($name{0}=='.' || !is_dir(INSTALL_PATH . 'program/localization/' . $name))
+ if ($name[0] == '.' || !is_dir(INSTALL_PATH . 'program/localization/' . $name))
continue;
if ($label = $rcube_languages[$name])
diff --git a/program/include/rcube_browser.php b/program/include/rcube_browser.php
index 23ef61590..361ffb63e 100644
--- a/program/include/rcube_browser.php
+++ b/program/include/rcube_browser.php
@@ -30,25 +30,25 @@ class rcube_browser
{
function __construct()
{
- $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
+ $HTTP_USER_AGENT = strtolower($_SERVER['HTTP_USER_AGENT']);
$this->ver = 0;
- $this->win = stristr($HTTP_USER_AGENT, 'win');
- $this->mac = stristr($HTTP_USER_AGENT, 'mac');
- $this->linux = stristr($HTTP_USER_AGENT, 'linux');
- $this->unix = stristr($HTTP_USER_AGENT, 'unix');
+ $this->win = strstr($HTTP_USER_AGENT, 'win');
+ $this->mac = strstr($HTTP_USER_AGENT, 'mac');
+ $this->linux = strstr($HTTP_USER_AGENT, 'linux');
+ $this->unix = strstr($HTTP_USER_AGENT, 'unix');
- $this->opera = stristr($HTTP_USER_AGENT, 'opera');
- $this->ns4 = stristr($HTTP_USER_AGENT, 'mozilla/4') && !stristr($HTTP_USER_AGENT, 'msie');
- $this->ns = ($this->ns4 || stristr($HTTP_USER_AGENT, 'netscape'));
- $this->ie = stristr($HTTP_USER_AGENT, 'compatible; msie') && !$this->opera;
- $this->mz = stristr($HTTP_USER_AGENT, 'mozilla/5');
- $this->chrome = stristr($HTTP_USER_AGENT, 'chrome');
- $this->khtml = stristr($HTTP_USER_AGENT, 'khtml');
- $this->safari = !$this->chrome && ($this->khtml || stristr($HTTP_USER_AGENT, 'safari'));
+ $this->opera = strstr($HTTP_USER_AGENT, 'opera');
+ $this->ns4 = strstr($HTTP_USER_AGENT, 'mozilla/4') && !strstr($HTTP_USER_AGENT, 'msie');
+ $this->ns = ($this->ns4 || strstr($HTTP_USER_AGENT, 'netscape'));
+ $this->ie = !$this->opera && strstr($HTTP_USER_AGENT, 'compatible; msie');
+ $this->mz = strstr($HTTP_USER_AGENT, 'mozilla/5');
+ $this->chrome = strstr($HTTP_USER_AGENT, 'chrome');
+ $this->khtml = strstr($HTTP_USER_AGENT, 'khtml');
+ $this->safari = !$this->chrome && ($this->khtml || strstr($HTTP_USER_AGENT, 'safari'));
if ($this->ns || $this->chrome) {
- $test = preg_match('/(mozilla|chrome)\/([0-9.]+)/i', $HTTP_USER_AGENT, $regs);
+ $test = preg_match('/(mozilla|chrome)\/([0-9.]+)/', $HTTP_USER_AGENT, $regs);
$this->ver = $test ? (float)$regs[2] : 0;
}
else if ($this->mz) {
@@ -56,11 +56,11 @@ class rcube_browser
$this->ver = $test ? (float)$regs[1] : 0;
}
else if ($this->ie || $this->opera) {
- $test = preg_match('/(msie|opera) ([0-9.]+)/i', $HTTP_USER_AGENT, $regs);
+ $test = preg_match('/(msie|opera) ([0-9.]+)/', $HTTP_USER_AGENT, $regs);
$this->ver = $test ? (float)$regs[2] : 0;
}
- if (preg_match('/ ([a-z]{2})-([a-z]{2})/i', $HTTP_USER_AGENT, $regs))
+ if (preg_match('/ ([a-z]{2})-([a-z]{2})/', $HTTP_USER_AGENT, $regs))
$this->lang = $regs[1];
else
$this->lang = 'en';
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index c5b10e626..043d902bc 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -3426,7 +3426,7 @@ class rcube_imap
$name = trim($val['name']);
if (preg_match('/^[\'"]/', $name) && preg_match('/[\'"]$/', $name))
- $name = preg_replace(array('/^[\'"]/', '/[\'"]$/'), '', $name);
+ $name = trim($name, '\'"');
if ($name && $address && $name != $address)
$string = sprintf('%s <%s>', preg_match("/$special_chars/", $name) ? '"'.addcslashes($name, '"').'"' : $name, $address);
@@ -3458,7 +3458,7 @@ class rcube_imap
function decode_header($input, $remove_quotes=false)
{
$str = rcube_imap::decode_mime_string((string)$input, $this->default_charset);
- if ($str{0}=='"' && $remove_quotes)
+ if ($str[0] == '"' && $remove_quotes)
$str = str_replace('"', '', $str);
return $str;
diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php
index 6cf86fc24..0c69c2320 100644
--- a/program/include/rcube_imap_generic.php
+++ b/program/include/rcube_imap_generic.php
@@ -1258,7 +1258,7 @@ class rcube_imap_generic
}
break;
case 'in-reply-to':
- $result[$id]->in_reply_to = preg_replace('/[\n<>]/', '', $string);
+ $result[$id]->in_reply_to = str_replace(array("\n", '<', '>'), '', $string);
break;
case 'references':
$result[$id]->references = $string;
@@ -2115,7 +2115,7 @@ class rcube_imap_generic
// return false if not found, parse if found
$min_free = PHP_INT_MAX;
foreach ($quota_lines as $key => $quota_line) {
- $quota_line = preg_replace('/[()]/', '', $quota_line);
+ $quota_line = str_replace(array('(', ')'), '', $quota_line);
$parts = explode(' ', $quota_line);
$storage_part = array_search('STORAGE', $parts);
diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php
index 2c9e95100..f301b3618 100755
--- a/program/include/rcube_template.php
+++ b/program/include/rcube_template.php
@@ -444,7 +444,10 @@ class rcube_template extends rcube_html_page
*/
public function abs_url($str)
{
- return preg_replace('/^\//', $this->config['skin_path'].'/', $str);
+ if ($str[0] == '/')
+ return $this->config['skin_path'] . $str;
+ else
+ return $str;
}