Index: /trunk/lib/CSS.inc.php
===================================================================
--- /trunk/lib/CSS.inc.php	(revision 695)
+++ /trunk/lib/CSS.inc.php	(revision 696)
@@ -182,5 +182,5 @@
                 // Strip whitespace and print file.
                 echo preg_replace(
-                    array('!/\*.*?\*/!s', '/[\n\r]+/', '/([;:])\s+/m', '/\s*}[ \t]*/', '/\s*{\s*/', '/[ \t\n\r]*,[ \t\n\r]*/', '/^\s+/'),
+                    array('!/\*.*?\*/!su', '/[\n\r]+/u', '/([;:])\s+/mu', '/\s*}[ \t]*/u', '/\s*{\s*/u', '/[ \t\n\r]*,[ \t\n\r]*/u', '/^\s+/u'),
                     array('', "\n", '$1', '}', '{', ',', ''), file_get_contents($file, true)
                 );
Index: /trunk/lib/Email.inc.php
===================================================================
--- /trunk/lib/Email.inc.php	(revision 695)
+++ /trunk/lib/Email.inc.php	(revision 696)
@@ -118,5 +118,5 @@
         . '(?:\s*>\s*|>\s+\([^,@]+\)\s*)'                               // TRUE, ensure ending >
         . '|'
-        . '(?:|\s*|\s+\([^,@]+\)\s*))$/i'));                            // FALSE ensure there is no ending >
+        . '(?:|\s*|\s+\([^,@]+\)\s*))$/iu'));                            // FALSE ensure there is no ending >
 
         if (isset($params)) {
@@ -260,5 +260,7 @@
         // Apply regex pattern to search elements.
         $search = array_keys($replacements);
-        array_walk($search, create_function('&$v', '$v = "{" . mb_strtoupper($v) . "}";'));
+        array_walk($search, function (&$v) {
+            $v = '{' . mb_strtoupper($v) . '}';
+        });
 
         // Replacement values.
@@ -274,5 +276,5 @@
     * You can also use this function to do post-processing on the email body before sending it,
     * like removing extraneous lines:
-    * $email->setString(preg_replace('/(?:(?:\r\n|\r|\n)\s*){2}/s', "\n\n", $email->getBody()));
+    * $email->setString(preg_replace('/(?:(?:\r\n|\r|\n)\s*){2}/su', "\n\n", $email->getBody()));
     *
     * @access   public
@@ -367,9 +369,9 @@
         foreach ($headers as $key => $val) {
             // Validate key and values.
-            if (empty($val)) {
+            if (!strlen($val)) {
                 $app->logMsg(sprintf('Empty email header provided: %s', $key), LOG_NOTICE, __FILE__, __LINE__);
                 continue;
             }
-            if (empty($key) || !is_string($key) || !is_string($val) || preg_match("/[\n\r]/", $key . $val) || preg_match('/[^\w-]/', $key)) {
+            if (!strlen($key) || preg_match("/[\n\r]/", $key . $val) || preg_match('/[^\w-]/', $key)) {
                 $app->logMsg(sprintf('Broken email header provided: %s=%s', $key, $val), LOG_WARNING, __FILE__, __LINE__);
                 continue;
@@ -394,5 +396,5 @@
             $envelope_sender_address = sprintf('<%s>', trim($this->_params['envelope_sender_address'], '<>'));
         } else {
-            $envelope_sender_address = preg_replace('/^.*<?([^\s@\[\]<>()]+\@[A-Za-z0-9.-]{1,}\.[A-Za-z]{2,5})>?$/iU', '$1', $this->_params['from']);
+            $envelope_sender_address = preg_replace('/^.*<?([^\s@\[\]<>()]+\@[A-Za-z0-9.-]{1,}\.[A-Za-z]{2,5})>?$/iUu', '$1', $this->_params['from']);
         }
         if ('' != $envelope_sender_address && $this->validEmail($envelope_sender_address)) {
Index: /trunk/lib/JS.inc.php
===================================================================
--- /trunk/lib/JS.inc.php	(revision 695)
+++ /trunk/lib/JS.inc.php	(revision 696)
@@ -182,5 +182,5 @@
                 // Strip whitespace and print file.
                 echo preg_replace(
-                    array('/(?<=^|;|{)\s*\/\/.*$/m', '/(?<=^|;|{)\s*\/\*.*?\*\//ms', '/[\n\r]+/', '/[ \t]+}[ \t]+/', '/[ \t]+{[ \t]+/', '/\s+=\s+/', '/^[ \t]+/m', '/[ \t]+$/m'),
+                    array('/(?<=^|;|{)\s*\/\/.*$/mu', '/(?<=^|;|{)\s*\/\*.*?\*\//msu', '/[\n\r]+/u', '/[ \t]+}[ \t]+/u', '/[ \t]+{[ \t]+/u', '/\s+=\s+/u', '/^[ \t]+/mu', '/[ \t]+$/mu'),
                     array('', '', "\n", '}', '{', '=', '', ''), file_get_contents($file, true)
                 );
Index: /trunk/lib/Utilities.inc.php
===================================================================
--- /trunk/lib/Utilities.inc.php	(revision 695)
+++ /trunk/lib/Utilities.inc.php	(revision 696)
@@ -122,5 +122,5 @@
     $d = ob_get_contents();
     ob_end_clean();
-    return $serialize ? preg_replace('/\s+/m', ' ', $d) : $d;
+    return $serialize ? preg_replace('/\s+/mu', ' ', $d) : $d;
 }
 
@@ -154,5 +154,5 @@
         $output .= sprintf("%s%s\n", $indent_str, $var);
     }
-    return preg_replace(['/^[ \t]+$/', '/\n\n+/', '/^(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(\S )/m'], ['', "\n", '$1$1$2$2$3$3$4$4$5$5$6$6$7$7$8$8$9'], $output);
+    return preg_replace(['/^[ \t]+$/u', '/\n\n+/u', '/^(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(?:\S( ))?(\S )/mu'], ['', "\n", '$1$1$2$2$3$3$4$4$5$5$6$6$7$7$8$8$9'], $output);
 }
 
@@ -189,19 +189,19 @@
 
     // Make converted ampersand entities into normal ampersands (they will be done manually later) to retain HTML entities.
-    $search['retain_ampersand']     = '/&amp;/';
+    $search['retain_ampersand']     = '/&amp;/u';
     $replace['retain_ampersand']    = '&';
 
     if ($preserve_html) {
         // Convert characters that must remain non-entities for displaying HTML.
-        $search['retain_left_angle']       = '/&lt;/';
+        $search['retain_left_angle']       = '/&lt;/u';
         $replace['retain_left_angle']      = '<';
 
-        $search['retain_right_angle']      = '/&gt;/';
+        $search['retain_right_angle']      = '/&gt;/u';
         $replace['retain_right_angle']     = '>';
 
-        $search['retain_single_quote']     = '/&#039;/';
+        $search['retain_single_quote']     = '/&#039;/u';
         $replace['retain_single_quote']    = "'";
 
-        $search['retain_double_quote']     = '/&quot;/';
+        $search['retain_double_quote']     = '/&quot;/u';
         $replace['retain_double_quote']    = '"';
     }
@@ -309,10 +309,10 @@
             // If not truncating, or URL was not truncated.
             // Remove http schemas, and any single trailing / to make the display URL.
-            $display_url = preg_replace(['!^https?://!', '!^([^/]+)/$!'], ['', '$1'], $url);
+            $display_url = preg_replace(['!^https?://!u', '!^([^/]+)/$!u'], ['', '$1'], $url);
             return sprintf('<a href="%s">%s</a>', oTxt($absolute_url), $display_url);
         } else {
             // Truncated URL.
             // Remove http schemas, and any single trailing / to make the display URL.
-            $display_url = preg_replace(['!^https?://!', '!^([^/]+)/$!'], ['', '$1'], trim($truncated_url));
+            $display_url = preg_replace(['!^https?://!u', '!^([^/]+)/$!u'], ['', '$1'], trim($truncated_url));
             return sprintf('<a href="%s">%s%s</a>', oTxt($absolute_url), $display_url, $delim);
         }
@@ -337,5 +337,5 @@
     foreach ($words as $w) {
         if ('' != trim($w)) {
-            $search[] = '/\b(' . preg_quote($w) . ')\b/i';
+            $search[] = '/\b(' . preg_quote($w) . ')\b/iu';
             $replace[] = '<span class="' . $class . '">$1</span>';
         }
@@ -368,6 +368,9 @@
     default :
         // Reduce all hex values slightly to avoid all white.
-        array_walk($rgb, create_function('&$v', "\$v = dechex(round(hexdec(\$v) * $n));"));
+        array_walk($rgb, function (&$v) use ($n) {
+            $v = dechex(round(hexdec($v) * $n));
+        });
         break;
+
     case 2 :
         foreach ($rgb as $i => $v) {
@@ -411,5 +414,5 @@
 function encodeEmail($email, $at=' at ', $dot=' dot ')
 {
-    $search = array('/@/', '/\./');
+    $search = array('/@/u', '/\./u');
     $replace = array($at, $dot);
     return preg_replace($search, $replace, $email);
@@ -529,5 +532,5 @@
 function URLSlug($str)
 {
-    $slug = preg_replace(array('/\W+/u', '/^-+|-+$/'), array('-', ''), $str);
+    $slug = preg_replace(array('/\W+/u', '/^-+|-+$/u'), array('-', ''), $str);
     $slug = strtolower($slug);
     return $slug;
@@ -1138,5 +1141,5 @@
 function hash64($string, $length=18)
 {
-    return mb_substr(preg_replace('/[^\w]/', '', base64_encode(hash('sha512', $string, true))), 0, $length);
+    return mb_substr(preg_replace('/[^\w]/u', '', base64_encode(hash('sha512', $string, true))), 0, $length);
 }
 
@@ -1168,5 +1171,5 @@
     switch ($app->getParam('signing_method')) {
     case 'sha512+base64':
-        return $val . '-' . mb_substr(preg_replace('/[^\w]/', '', base64_encode(hash('sha512', $val . $salt, true))), 0, $length);
+        return $val . '-' . mb_substr(preg_replace('/[^\w]/u', '', base64_encode(hash('sha512', $val . $salt, true))), 0, $length);
 
     case 'md5':
@@ -1395,5 +1398,5 @@
 function stripQuery($url)
 {
-    return preg_replace('/[?#].*$/', '', $url);
+    return preg_replace('/[?#].*$/u', '', $url);
 }
 
@@ -1405,5 +1408,5 @@
 function absoluteMe()
 {
-    $safe_http_host = preg_replace('/[^a-z\d.:-]/', '', getenv('HTTP_HOST'));
+    $safe_http_host = preg_replace('/[^a-z\d.:-]/u', '', getenv('HTTP_HOST'));
     return sprintf('%s://%s%s', (getenv('HTTPS') ? 'https' : 'http'), $safe_http_host, getenv('REQUEST_URI'));
 }
@@ -1422,6 +1425,6 @@
     // If one of the hostnames is an IP address, compare only the path of both.
     if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', parse_url($current_url, PHP_URL_HOST)) || preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', parse_url($referrer_url, PHP_URL_HOST))) {
-        $current_url = preg_replace('@^https?://[^/]+@', '', $current_url);
-        $referrer_url = preg_replace('@^https?://[^/]+@', '', $referrer_url);
+        $current_url = preg_replace('@^https?://[^/]+@u', '', $current_url);
+        $referrer_url = preg_replace('@^https?://[^/]+@u', '', $referrer_url);
     }
 
Index: /trunk/lib/Validator.inc.php
===================================================================
--- /trunk/lib/Validator.inc.php	(revision 695)
+++ /trunk/lib/Validator.inc.php	(revision 696)
@@ -453,5 +453,5 @@
         $app =& App::getInstance();
         // Get rid of any non-digits
-        $cc_num = preg_replace('/[^\d]/', '', $val);
+        $cc_num = preg_replace('/[^\d]/u', '', $val);
 
         // Perform card-specific checks, if applicable
