From 59478e06c25303a790a0840ab2ac30662c4ef781 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Tue, 5 Aug 2014 16:46:22 +0200 Subject: c'est la merde.. --- program/lib/Roundcube/rcube_utils.php | 84 +++++------------------------------ 1 file changed, 11 insertions(+), 73 deletions(-) (limited to 'program/lib/Roundcube/rcube_utils.php') diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php index 1d76ae508..4dadbb8bd 100644 --- a/program/lib/Roundcube/rcube_utils.php +++ b/program/lib/Roundcube/rcube_utils.php @@ -400,7 +400,7 @@ class rcube_utils $out = array(); $src = $mode == self::INPUT_GET ? $_GET : ($mode == self::INPUT_POST ? $_POST : $_REQUEST); - foreach (array_keys($src) as $key) { + foreach ($src as $key => $value) { $fname = $key[0] == '_' ? substr($key, 1) : $key; if ($ignore && !preg_match('/^(' . $ignore . ')$/', $fname)) { $out[$fname] = self::get_input_value($key, $mode); @@ -476,9 +476,9 @@ class rcube_utils // remove html comments and add #container to each tag selector. // also replace body definition because we also stripped off the tag - $styles = preg_replace( + $source = preg_replace( array( - '/(^\s*\s*$)/', + '/(^\s*<\!--)|(-->\s*$)/m', '/(^\s*|,\s*|\}\s*)([a-z0-9\._#\*][a-z0-9\.\-_]*)/im', '/'.preg_quote($container_id, '/').'\s+body/i', ), @@ -490,9 +490,9 @@ class rcube_utils $source); // put block contents back in - $styles = $replacements->resolve($styles); + $source = $replacements->resolve($source); - return $styles; + return $source; } @@ -506,24 +506,17 @@ class rcube_utils */ public static function file2class($mimetype, $filename) { - $mimetype = strtolower($mimetype); - $filename = strtolower($filename); - list($primary, $secondary) = explode('/', $mimetype); $classes = array($primary ? $primary : 'unknown'); - if ($secondary) { $classes[] = $secondary; } - - if (preg_match('/\.([a-z0-9]+)$/', $filename, $m)) { - if (!in_array($m[1], $classes)) { - $classes[] = $m[1]; - } + if (preg_match('/\.([a-z0-9]+)$/i', $filename, $m)) { + $classes[] = $m[1]; } - return join(" ", $classes); + return strtolower(join(" ", $classes)); } @@ -665,21 +658,6 @@ class rcube_utils } - /** - * Returns the real remote IP address - * - * @return string Remote IP address - */ - public static function remote_addr() - { - foreach (array('HTTP_X_FORWARDED_FOR','HTTP_X_REAL_IP','REMOTE_ADDR') as $prop) { - if (!empty($_SERVER[$prop])) - return $_SERVER[$prop]; - } - - return ''; - } - /** * Read a specific HTTP request header. * @@ -761,9 +739,9 @@ class rcube_utils // Clean malformed data $date = preg_replace( array( - '/GMT\s*([+-][0-9]+)/', // support non-standard "GMTXXXX" literal - '/[^a-z0-9\x20\x09:+-]/i', // remove any invalid characters - '/\s*(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s*/i', // remove weekday names + '/GMT\s*([+-][0-9]+)/', // support non-standard "GMTXXXX" literal + '/[^a-z0-9\x20\x09:+-]/i', // remove any invalid characters + '/\s*(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s*/i', // remove weekday names ), array( '\\1', @@ -771,8 +749,6 @@ class rcube_utils '', ), $date); - $date = trim($date); - // if date parsing fails, we have a date in non-rfc format. // remove token from the end and try again while ((($ts = @strtotime($date)) === false) || ($ts < 0)) { @@ -787,44 +763,6 @@ class rcube_utils return (int) $ts; } - /** - * Date parsing function that turns the given value into a DateTime object - * - * @param string $date Date string - * - * @return object DateTime instance or false on failure - */ - public static function anytodatetime($date) - { - if (is_object($date) && is_a($date, 'DateTime')) { - return $date; - } - - $dt = false; - $date = trim($date); - - // try to parse string with DateTime first - if (!empty($date)) { - try { - $dt = new DateTime($date); - } - catch (Exception $e) { - // ignore - } - } - - // try our advanced strtotime() method - if (!$dt && ($timestamp = self::strtotime($date))) { - try { - $dt = new DateTime("@".$timestamp); - } - catch (Exception $e) { - // ignore - } - } - - return $dt; - } /* * Idn_to_ascii wrapper. -- cgit v1.2.3