diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index efd3196fa..54dc0a2d0 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -31,7 +31,25 @@ return (new PhpCsFixer\Config()) 'equal' => false, 'identical' => false, ], - 'native_constant_invocation' => true, + 'native_constant_invocation' => [ + 'include' => [ + // https://github.com/php/php-src/commit/2475337bd8a0fad0dac03db3f5e7e9d331d53653 + 'LOG_LOCAL0', + 'LOG_LOCAL1', + 'LOG_LOCAL2', + 'LOG_LOCAL3', + 'LOG_LOCAL4', + 'LOG_LOCAL5', + 'LOG_LOCAL6', + 'LOG_LOCAL7', + // https://github.com/php/php-src/blob/php-8.3.0/ext/ldap/ldap.stub.php#L104 + 'LDAP_OPT_PROTOCOL_VERSION', + // https://github.com/php/pecl-text-pspell/blob/1.0.1/pspell.stub.php#L24 + 'PSPELL_FAST', + // https://github.com/websupport-sk/pecl-memcache/blob/8.2/src/memcache.c#L755 + 'MEMCACHE_COMPRESSED', + ], + ], 'native_function_invocation' => false, 'void_return' => false, 'blank_line_before_statement' => [ @@ -78,7 +96,6 @@ return (new PhpCsFixer\Config()) 'increment_style' => false, 'method_argument_space' => false, 'modernize_types_casting' => false, - 'native_constant_invocation' => false, 'new_with_parentheses' => false, 'no_blank_lines_after_phpdoc' => false, 'no_break_comment' => false, @@ -94,10 +111,8 @@ return (new PhpCsFixer\Config()) // TODO - risky 'no_unset_on_property' => false, 'php_unit_data_provider_name' => false, - 'php_unit_strict' => false, 'php_unit_test_case_static_method_calls' => false, 'random_api_migration' => false, - 'self_accessor' => false, 'strict_param' => false, ]) ->setFinder($finder) diff --git a/bin/deluser.sh b/bin/deluser.sh index c05885f6a..1516de92a 100755 --- a/bin/deluser.sh +++ b/bin/deluser.sh @@ -33,7 +33,7 @@ function print_usage() function _die($msg, $usage = false) { - fwrite(STDERR, $msg . "\n"); + fwrite(\STDERR, $msg . "\n"); if ($usage) { print_usage(); } diff --git a/bin/identity.sh b/bin/identity.sh index 14e4daafe..2d3b8d534 100755 --- a/bin/identity.sh +++ b/bin/identity.sh @@ -175,7 +175,7 @@ function add_identity($options) } if (isset($options['is_default'])) { validate_boolean($options['is_default'], 'is default identity (S)'); - $setAsDefault = filter_var($options['is_default'], FILTER_VALIDATE_BOOLEAN); + $setAsDefault = filter_var($options['is_default'], \FILTER_VALIDATE_BOOLEAN); } $new_identity['email'] = get_option_value($options, 'email', '', false, true, "Enter the email e.g. -e somemail@example.com"); @@ -241,7 +241,7 @@ function update_identity($options) $setAsDefault = false; if (isset($options['is_default'])) { validate_boolean($options['is_default'], 'is default identity (S)'); - $setAsDefault = filter_var($options['is_default'], FILTER_VALIDATE_BOOLEAN); + $setAsDefault = filter_var($options['is_default'], \FILTER_VALIDATE_BOOLEAN); } $email = get_option_value($options, 'email', null, false, false); @@ -324,7 +324,7 @@ function get_option_value($options, $key, $fallback, $isBoolean, $isMandatory, $ function validate_email($email, $fieldName) { - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { + if (!filter_var($email, \FILTER_VALIDATE_EMAIL)) { rcube::raise_error("invalid {$fieldName} format", false, true); } } diff --git a/bin/initdb.sh b/bin/initdb.sh index 4b934121f..2b9c5c37a 100755 --- a/bin/initdb.sh +++ b/bin/initdb.sh @@ -41,7 +41,7 @@ if (!file_exists($opts['dir'])) { $db = rcmail_utils::db(); if (!empty($opts['update']) && in_array($db->table_name('system'), (array) $db->list_tables())) { - echo "Checking for database schema updates..." . PHP_EOL; + echo "Checking for database schema updates..." . \PHP_EOL; rcmail_utils::db_update($opts['dir'], 'roundcube', null, ['errors' => true]); } else { rcmail_utils::db_init($opts['dir']); diff --git a/bin/install-jsdeps.sh b/bin/install-jsdeps.sh index a73d5f4eb..3e132d14a 100755 --- a/bin/install-jsdeps.sh +++ b/bin/install-jsdeps.sh @@ -159,7 +159,7 @@ function extract_filetype($package, &$filetype = null) { global $CACHEDIR; - $filetype = pathinfo(preg_replace('/[?&].*$/', '', $package['url']), PATHINFO_EXTENSION) ?: 'tmp'; + $filetype = pathinfo(preg_replace('/[?&].*$/', '', $package['url']), \PATHINFO_EXTENSION) ?: 'tmp'; $cache_file = $CACHEDIR . '/' . $package['lib'] . '-' . $package['version'] . '.' . $filetype; // Make sure it is a zip file @@ -241,7 +241,7 @@ function extract_zipfile($package, $srcfile) // map source to dest files/directories if (!empty($package['map'])) { // get the root folder of the extracted package - $extract_tree = glob("$extract/*", GLOB_ONLYDIR); + $extract_tree = glob("$extract/*", \GLOB_ONLYDIR); $sourcedir = count($extract_tree) ? $extract_tree[0] : $extract; foreach ($package['map'] as $src => $dest) { @@ -308,7 +308,7 @@ function delete_destfile($package) $destdir = INSTALL_PATH . (!empty($package['rm']) ? $package['rm'] : $package['dest']); if (file_exists($destdir)) { - if (PHP_OS === 'Windows') { + if (\PHP_OS === 'Windows') { exec(sprintf("rd /s /q %s", escapeshellarg($destdir))); } else { diff --git a/bin/installto.sh b/bin/installto.sh index 298c42304..74a34a76b 100755 --- a/bin/installto.sh +++ b/bin/installto.sh @@ -53,7 +53,7 @@ else { echo "Upgrading from $oldversion. Do you want to continue? (y/N)\n"; } -$input = $accept ?: trim(fgets(STDIN)); +$input = $accept ?: trim(fgets(\STDIN)); if (strtolower($input) == 'y') { echo "Copying files to target location..."; diff --git a/bin/msgexport.sh b/bin/msgexport.sh index 89ade637e..26960b2bb 100755 --- a/bin/msgexport.sh +++ b/bin/msgexport.sh @@ -31,7 +31,7 @@ function print_usage() function vputs($str) { - $out = !empty($GLOBALS['args']['file']) ? STDOUT : STDERR; + $out = !empty($GLOBALS['args']['file']) ? \STDOUT : \STDERR; fwrite($out, $str); } @@ -63,7 +63,7 @@ function export_mailbox($mbox, $filename) vputs("Writing to $filename\n"); } else { - $out = STDOUT; + $out = \STDOUT; } for ($i = 0; $i < $count; $i++) { @@ -100,7 +100,7 @@ elseif (!$args['host']) { // prompt for username if not set if (empty($args['user'])) { vputs("IMAP user: "); - $args['user'] = trim(fgets(STDIN)); + $args['user'] = trim(fgets(\STDIN)); } // prompt for password diff --git a/bin/msgimport.sh b/bin/msgimport.sh index 343f5b416..277bd06e6 100755 --- a/bin/msgimport.sh +++ b/bin/msgimport.sh @@ -50,7 +50,7 @@ elseif (!is_file($args['file'])) { if (empty($args['user'])) { //fwrite(STDOUT, "Please enter your name\n"); echo "IMAP user: "; - $args['user'] = trim(fgets(STDIN)); + $args['user'] = trim(fgets(\STDIN)); } // prompt for password diff --git a/bin/update.sh b/bin/update.sh index d7dda06a0..6eb2d8104 100755 --- a/bin/update.sh +++ b/bin/update.sh @@ -30,7 +30,7 @@ $opts = rcube_utils::get_opt(['v' => 'version', 'y' => 'accept:bool']); if (empty($opts['version'])) { echo "What version are you upgrading from? Type '?' if you don't know.\n"; - if (($input = trim(fgets(STDIN))) && preg_match('/^[0-9.]+[a-z0-9-]*$/', $input)) { + if (($input = trim(fgets(\STDIN))) && preg_match('/^[0-9.]+[a-z0-9-]*$/', $input)) { $opts['version'] = $input; } else { @@ -82,7 +82,7 @@ if ($RCI->configured) { if ($err) { if (empty($opts['accept'])) { echo "Do you want me to fix your local configuration? (y/N)\n"; - $input = trim(fgets(STDIN)); + $input = trim(fgets(\STDIN)); } // positive: merge the local config with the defaults @@ -248,7 +248,7 @@ if ($RCI->configured) { $composer_data['repositories'] = array_values($composer_data['repositories']); } - $composer_json = json_encode($composer_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); + $composer_json = json_encode($composer_data, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES); // write updated composer.json back to disk if ($composer_json && is_writable(INSTALL_PATH . 'composer.json')) { diff --git a/bin/updatecss.sh b/bin/updatecss.sh index 930ac2ba9..635fc9b5b 100755 --- a/bin/updatecss.sh +++ b/bin/updatecss.sh @@ -30,8 +30,8 @@ if (empty($opts['dir'])) { $dir = INSTALL_PATH . 'skins'; $dir_p = INSTALL_PATH . 'plugins'; - $skins = glob("$dir/*", GLOB_ONLYDIR); - $skins_p = glob("$dir_p/*/skins/*", GLOB_ONLYDIR); + $skins = glob("$dir/*", \GLOB_ONLYDIR); + $skins_p = glob("$dir_p/*/skins/*", \GLOB_ONLYDIR); $dirs = array_merge($skins, $skins_p); } diff --git a/config/defaults.inc.php b/config/defaults.inc.php index 29e75e2a0..44aee97ec 100644 --- a/config/defaults.inc.php +++ b/config/defaults.inc.php @@ -90,7 +90,7 @@ $config['syslog_id'] = 'roundcube'; // Syslog facility to use, if using the 'syslog' log driver. // For possible values see installer or http://php.net/manual/en/function.openlog.php -$config['syslog_facility'] = LOG_USER; +$config['syslog_facility'] = \LOG_USER; // Activate this option if logs should be written to per-user directories. // Data will only be logged if a directory // exists and is writable. diff --git a/installer/check.php b/installer/check.php index ae1bfc958..bfce76fe1 100644 --- a/installer/check.php +++ b/installer/check.php @@ -107,11 +107,11 @@ echo 'errors)) { // Find position of the new script on the list $list[] = $name; - asort($list, SORT_LOCALE_STRING); + asort($list, \SORT_LOCALE_STRING); $list = array_values($list); $index = array_search($name, $list); @@ -1341,7 +1341,7 @@ class rcube_sieve_engine $list = $this->list_scripts(); if ($list) { - asort($list, SORT_LOCALE_STRING); + asort($list, \SORT_LOCALE_STRING); } if (!empty($attrib['type']) && $attrib['type'] == 'list') { @@ -1482,7 +1482,7 @@ class rcube_sieve_engine $select = new html_select(['name' => '_copy', 'id' => '_copy', 'class' => 'custom-select']); if (is_array($list)) { - asort($list, SORT_LOCALE_STRING); + asort($list, \SORT_LOCALE_STRING); if (!$copy && isset($_SESSION['managesieve_current'])) { $copy = $_SESSION['managesieve_current']; @@ -3101,7 +3101,7 @@ class rcube_sieve_engine $list[] = $name; // Sort and find current script position - asort($list, SORT_LOCALE_STRING); + asort($list, \SORT_LOCALE_STRING); $list = array_values($list); $index = array_search($name, $list); diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php index b4b576f77..ab7f36866 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php @@ -1278,7 +1278,7 @@ class rcube_sieve_script */ static function escape_multiline_string($str) { - $str = preg_split('/(\r?\n)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE); + $str = preg_split('/(\r?\n)/', $str, -1, \PREG_SPLIT_DELIM_CAPTURE); foreach ($str as $idx => $line) { // dot-stuffing @@ -1397,7 +1397,7 @@ class rcube_sieve_script } // tag/identifier/number - if (preg_match('/[a-zA-Z0-9:_]+/', $str, $m, PREG_OFFSET_CAPTURE, $position) + if (preg_match('/[a-zA-Z0-9:_]+/', $str, $m, \PREG_OFFSET_CAPTURE, $position) && $m[0][1] == $position ) { $atom = $m[0][0]; diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php index bcbb49ed0..0a9da4836 100644 --- a/plugins/managesieve/managesieve.php +++ b/plugins/managesieve/managesieve.php @@ -284,7 +284,7 @@ class managesieve extends rcube_plugin { if (!$this->engine) { // Add include path for internal classes - $include_path = $this->home . '/lib' . PATH_SEPARATOR; + $include_path = $this->home . '/lib' . \PATH_SEPARATOR; $include_path .= ini_get('include_path'); set_include_path($include_path); diff --git a/plugins/markasjunk/drivers/cmd_learn.php b/plugins/markasjunk/drivers/cmd_learn.php index c3ebf9f79..aa10b562e 100644 --- a/plugins/markasjunk/drivers/cmd_learn.php +++ b/plugins/markasjunk/drivers/cmd_learn.php @@ -50,7 +50,7 @@ class markasjunk_cmd_learn } if (strpos($command, '%h') !== false) { - preg_match_all('/%h:([\w_-]+)/', $command, $header_names, PREG_SET_ORDER); + preg_match_all('/%h:([\w_-]+)/', $command, $header_names, \PREG_SET_ORDER); $header_names = array_column($header_names, 1); } diff --git a/plugins/password/drivers/cpanel.php b/plugins/password/drivers/cpanel.php index 637fad2a0..4faed250d 100644 --- a/plugins/password/drivers/cpanel.php +++ b/plugins/password/drivers/cpanel.php @@ -124,14 +124,14 @@ class rcube_cpanel_password $postfields = http_build_query($postdata, '', '&'); // see http://php.net/manual/en/function.curl-setopt.php - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_BUFFERSIZE, 131072); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); - curl_setopt($ch, CURLOPT_USERPWD, $userpwd); + curl_setopt($ch, \CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($ch, \CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, \CURLOPT_BUFFERSIZE, 131072); + curl_setopt($ch, \CURLOPT_URL, $url); + curl_setopt($ch, \CURLOPT_POST, 1); + curl_setopt($ch, \CURLOPT_POSTFIELDS, $postfields); + curl_setopt($ch, \CURLOPT_USERPWD, $userpwd); $result = curl_exec($ch); $error = curl_error($ch); diff --git a/plugins/password/drivers/directadmin.php b/plugins/password/drivers/directadmin.php index 1948d2d01..d33b0744b 100644 --- a/plugins/password/drivers/directadmin.php +++ b/plugins/password/drivers/directadmin.php @@ -245,30 +245,30 @@ class HTTPSocket $ch = curl_init($this->remote_host . ':' . $this->remote_port . $request); if ($is_ssl) { - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //1 - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //2 + curl_setopt($ch, \CURLOPT_SSL_VERIFYPEER, false); //1 + curl_setopt($ch, \CURLOPT_SSL_VERIFYHOST, false); //2 //curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); } - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); - curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); - curl_setopt($ch, CURLOPT_USERAGENT, "HTTPSocket/$this->version"); - curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); - curl_setopt($ch, CURLOPT_TIMEOUT, 100); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); - curl_setopt($ch, CURLOPT_HEADER, 1); + curl_setopt($ch, \CURLOPT_HTTP_VERSION, \CURL_HTTP_VERSION_1_1); + curl_setopt($ch, \CURLOPT_RETURNTRANSFER,1); + curl_setopt($ch, \CURLOPT_USERAGENT, "HTTPSocket/$this->version"); + curl_setopt($ch, \CURLOPT_FORBID_REUSE, 1); + curl_setopt($ch, \CURLOPT_TIMEOUT, 100); + curl_setopt($ch, \CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($ch, \CURLOPT_HEADER, 1); - curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 512); - curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, 120); + curl_setopt($ch, \CURLOPT_LOW_SPEED_LIMIT, 512); + curl_setopt($ch, \CURLOPT_LOW_SPEED_TIME, 120); // instance connection if ($this->bind_host) { - curl_setopt($ch, CURLOPT_INTERFACE, $this->bind_host); + curl_setopt($ch, \CURLOPT_INTERFACE, $this->bind_host); } // if we have a username and password, add the header if (isset($this->remote_uname) && isset($this->remote_passwd)) { - curl_setopt($ch, CURLOPT_USERPWD, $this->remote_uname . ':' . $this->remote_passwd); + curl_setopt($ch, \CURLOPT_USERPWD, $this->remote_uname . ':' . $this->remote_passwd); } // for DA skins: if $this->remote_passwd is NULL, try to use the login key system @@ -278,25 +278,25 @@ class HTTPSocket // if method is POST, add content length & type headers if ($this->method == 'POST') { - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, $content); + curl_setopt($ch, \CURLOPT_POST, 1); + curl_setopt($ch, \CURLOPT_POSTFIELDS, $content); //$array_headers['Content-type'] = 'application/x-www-form-urlencoded'; $array_headers['Content-length'] = strlen($content); } - curl_setopt($ch, CURLOPT_HTTPHEADER, $array_headers); + curl_setopt($ch, \CURLOPT_HTTPHEADER, $array_headers); if (!($this->result = curl_exec($ch))) { $this->error[] = curl_error($ch); $OK = false; } - $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); + $header_size = curl_getinfo($ch, \CURLINFO_HEADER_SIZE); $this->result_header = substr($this->result, 0, $header_size); $this->result_body = substr($this->result, $header_size); - $this->result_status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); - $this->lastTransferSpeed = curl_getinfo($ch, CURLINFO_SPEED_DOWNLOAD) / 1024; + $this->result_status_code = curl_getinfo($ch, \CURLINFO_HTTP_CODE); + $this->lastTransferSpeed = curl_getinfo($ch, \CURLINFO_SPEED_DOWNLOAD) / 1024; curl_close($ch); diff --git a/plugins/password/drivers/domainfactory.php b/plugins/password/drivers/domainfactory.php index f9f6df740..03b71aa38 100644 --- a/plugins/password/drivers/domainfactory.php +++ b/plugins/password/drivers/domainfactory.php @@ -35,10 +35,10 @@ class rcube_domainfactory_password if ($ch = curl_init()) { // initial login curl_setopt_array($ch, [ - CURLOPT_RETURNTRANSFER => true, - CURLOPT_URL => 'https://ssl.df.eu/chmail.php', - CURLOPT_POST => true, - CURLOPT_POSTFIELDS => http_build_query([ + \CURLOPT_RETURNTRANSFER => true, + \CURLOPT_URL => 'https://ssl.df.eu/chmail.php', + \CURLOPT_POST => true, + \CURLOPT_POSTFIELDS => http_build_query([ 'login' => $username, 'pwd' => $curpass, 'action' => 'change', @@ -60,7 +60,7 @@ class rcube_domainfactory_password // change password $ch = curl_copy_handle($ch); - curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields)); + curl_setopt($ch, \CURLOPT_POSTFIELDS, http_build_query($postfields)); if ($result = curl_exec($ch)) { // has the password been changed? if (strpos($result, 'Einstellungen erfolgreich') !== false) { diff --git a/plugins/password/drivers/dovecot_passwdfile.php b/plugins/password/drivers/dovecot_passwdfile.php index 06d336f50..91e4c1621 100644 --- a/plugins/password/drivers/dovecot_passwdfile.php +++ b/plugins/password/drivers/dovecot_passwdfile.php @@ -61,7 +61,7 @@ class rcube_dovecot_passwdfile_password return PASSWORD_CONNECT_ERROR; } - if (flock($fp, LOCK_EX)) { + if (flock($fp, \LOCK_EX)) { // Read the file and replace the user password while (($line = fgets($fp, 40960)) !== false) { if (strpos($line, "$username:") === 0) { @@ -75,7 +75,7 @@ class rcube_dovecot_passwdfile_password // Write back the entire file if (file_put_contents($mailuserfile, $content)) { - flock($fp, LOCK_UN); + flock($fp, \LOCK_UN); fclose($fp); return PASSWORD_SUCCESS; diff --git a/plugins/password/drivers/ldap_simple.php b/plugins/password/drivers/ldap_simple.php index e37b40d86..457385b6b 100644 --- a/plugins/password/drivers/ldap_simple.php +++ b/plugins/password/drivers/ldap_simple.php @@ -142,7 +142,7 @@ class rcube_ldap_simple_password $this->_debug("S: OK"); // Set protocol version - ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, + ldap_set_option($ds, \LDAP_OPT_PROTOCOL_VERSION, $rcmail->config->get('password_ldap_version', '3')); // Start TLS diff --git a/plugins/password/drivers/modoboa.php b/plugins/password/drivers/modoboa.php index c95a65773..d78bbc2b7 100644 --- a/plugins/password/drivers/modoboa.php +++ b/plugins/password/drivers/modoboa.php @@ -48,14 +48,14 @@ class rcube_modoboa_password $curl = curl_init(); curl_setopt_array($curl, [ - CURLOPT_URL => "https://" . $IMAPhost . "/api/v1/accounts/?search=" . urlencode($RoudCubeUsername), - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => "", - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 30, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => "GET", - CURLOPT_HTTPHEADER => [ + \CURLOPT_URL => "https://" . $IMAPhost . "/api/v1/accounts/?search=" . urlencode($RoudCubeUsername), + \CURLOPT_RETURNTRANSFER => true, + \CURLOPT_ENCODING => "", + \CURLOPT_MAXREDIRS => 10, + \CURLOPT_TIMEOUT => 30, + \CURLOPT_HTTP_VERSION => \CURL_HTTP_VERSION_1_1, + \CURLOPT_CUSTOMREQUEST => "GET", + \CURLOPT_HTTPHEADER => [ "Authorization: Token " . $ModoboaToken, "Cache-Control: no-cache", "Content-Type: application/json", @@ -92,15 +92,15 @@ class rcube_modoboa_password $curl = curl_init(); curl_setopt_array($curl, [ - CURLOPT_URL => "https://" . $IMAPhost . "/api/v1/accounts/" . $userid . "/", - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => "", - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 30, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => "PUT", - CURLOPT_POSTFIELDS => "" . $encoded . "", - CURLOPT_HTTPHEADER => [ + \CURLOPT_URL => "https://" . $IMAPhost . "/api/v1/accounts/" . $userid . "/", + \CURLOPT_RETURNTRANSFER => true, + \CURLOPT_ENCODING => "", + \CURLOPT_MAXREDIRS => 10, + \CURLOPT_TIMEOUT => 30, + \CURLOPT_HTTP_VERSION => \CURL_HTTP_VERSION_1_1, + \CURLOPT_CUSTOMREQUEST => "PUT", + \CURLOPT_POSTFIELDS => "" . $encoded . "", + \CURLOPT_HTTPHEADER => [ "Authorization: Token " . $ModoboaToken, "Cache-Control: no-cache", "Content-Type: application/json", diff --git a/plugins/password/drivers/plesk.php b/plugins/password/drivers/plesk.php index 784e59c8e..4e2d1bf4f 100644 --- a/plugins/password/drivers/plesk.php +++ b/plugins/password/drivers/plesk.php @@ -117,11 +117,11 @@ class plesk_rpc $url = sprintf("https://%s:%s/%s", $host, $port, $path); $this->curl = curl_init(); - curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT , 5); - curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST , 0); - curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER , false); - curl_setopt($this->curl, CURLOPT_HTTPHEADER , $headers); - curl_setopt($this->curl, CURLOPT_URL , $url); + curl_setopt($this->curl, \CURLOPT_CONNECTTIMEOUT , 5); + curl_setopt($this->curl, \CURLOPT_SSL_VERIFYHOST , 0); + curl_setopt($this->curl, \CURLOPT_SSL_VERIFYPEER , false); + curl_setopt($this->curl, \CURLOPT_HTTPHEADER , $headers); + curl_setopt($this->curl, \CURLOPT_URL , $url); } /** @@ -133,8 +133,8 @@ class plesk_rpc */ function send_request($packet) { - curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($this->curl, CURLOPT_POSTFIELDS, $packet); + curl_setopt($this->curl, \CURLOPT_RETURNTRANSFER, true); + curl_setopt($this->curl, \CURLOPT_POSTFIELDS, $packet); $result = curl_exec($this->curl); return $result && strpos($result, 'socket,$msg); - if (substr(socket_read($this->socket, 512, PHP_BINARY_READ),0,1) != "+") { + if (substr(socket_read($this->socket, 512, \PHP_BINARY_READ),0,1) != "+") { return false; } return true; @@ -96,7 +96,7 @@ class XMail function connect() { - $this->socket = socket_create(AF_INET, SOCK_STREAM, 0); + $this->socket = socket_create(\AF_INET, \SOCK_STREAM, 0); if ($this->socket < 0) { return false; } @@ -107,7 +107,7 @@ class XMail return false; } - if (substr(socket_read($this->socket, 512, PHP_BINARY_READ),0,1) != "+") { + if (substr(socket_read($this->socket, 512, \PHP_BINARY_READ),0,1) != "+") { socket_close($this->socket); return false; } diff --git a/plugins/password/password.php b/plugins/password/password.php index f08d47183..04a0bf998 100644 --- a/plugins/password/password.php +++ b/plugins/password/password.php @@ -764,17 +764,17 @@ class password extends rcube_plugin break; case 'hash-bcrypt': - $crypted = password_hash($password, PASSWORD_BCRYPT, $options); + $crypted = password_hash($password, \PASSWORD_BCRYPT, $options); $prefix = '{BLF-CRYPT}'; break; case 'hash-argon2i': - $crypted = password_hash($password, PASSWORD_ARGON2I, $options); + $crypted = password_hash($password, \PASSWORD_ARGON2I, $options); $prefix = '{ARGON2I}'; break; case 'hash-argon2id': - $crypted = password_hash($password, PASSWORD_ARGON2ID, $options); + $crypted = password_hash($password, \PASSWORD_ARGON2ID, $options); $prefix = '{ARGON2ID}'; break; diff --git a/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php b/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php index c418cbfa3..84a71f5e0 100644 --- a/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php +++ b/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php @@ -108,7 +108,7 @@ class squirrelmail_usercopy extends rcube_plugin foreach ($this->abook as $rec) { // #1487096: handle multi-address and/or too long items // #1487858: convert multi-address contacts into groups - $emails = preg_split('/[;,]/', $rec['email'], -1, PREG_SPLIT_NO_EMPTY); + $emails = preg_split('/[;,]/', $rec['email'], -1, \PREG_SPLIT_NO_EMPTY); $group_id = null; // create group for addresses diff --git a/plugins/zipdownload/zipdownload.php b/plugins/zipdownload/zipdownload.php index f835e3119..7616cfd69 100644 --- a/plugins/zipdownload/zipdownload.php +++ b/plugins/zipdownload/zipdownload.php @@ -408,6 +408,6 @@ class zipdownload_mbox_filter extends php_user_filter stream_bucket_append($out, $bucket); } - return PSFS_PASS_ON; + return \PSFS_PASS_ON; } } diff --git a/program/actions/contacts/delete.php b/program/actions/contacts/delete.php index 916d87a09..5269349a7 100644 --- a/program/actions/contacts/delete.php +++ b/program/actions/contacts/delete.php @@ -119,7 +119,7 @@ class rcmail_action_contacts_delete extends rcmail_action_contacts_index // get records from the next page to add to the list elseif ($pages > 1 && $page < $pages) { // sort the records - ksort($records, SORT_LOCALE_STRING); + ksort($records, \SORT_LOCALE_STRING); $first += $page_size; // create resultset object diff --git a/program/actions/contacts/edit.php b/program/actions/contacts/edit.php index 284a0cb83..f0a964139 100644 --- a/program/actions/contacts/edit.php +++ b/program/actions/contacts/edit.php @@ -139,7 +139,7 @@ class rcmail_action_contacts_edit extends rcmail_action_contacts_index $addr_tpl = $rcmail->config->get('address_template', ''); // copy (parsed) address template to client - if (preg_match_all('/\{([a-z0-9]+)\}([^{]*)/i', $addr_tpl, $templ, PREG_SET_ORDER)) { + if (preg_match_all('/\{([a-z0-9]+)\}([^{]*)/i', $addr_tpl, $templ, \PREG_SET_ORDER)) { $rcmail->output->set_env('address_template', $templ); } diff --git a/program/actions/contacts/export.php b/program/actions/contacts/export.php index f67ab53c6..3367f2327 100644 --- a/program/actions/contacts/export.php +++ b/program/actions/contacts/export.php @@ -64,7 +64,7 @@ class rcmail_action_contacts_export extends rcmail_action_contacts_index } // sort the records - ksort($records, SORT_LOCALE_STRING); + ksort($records, \SORT_LOCALE_STRING); // create resultset object $count = count($records); @@ -97,7 +97,7 @@ class rcmail_action_contacts_export extends rcmail_action_contacts_index } } - ksort($records, SORT_LOCALE_STRING); + ksort($records, \SORT_LOCALE_STRING); // create resultset object $count = count($records); diff --git a/program/actions/contacts/import.php b/program/actions/contacts/import.php index f1c1a9665..5d05efab8 100644 --- a/program/actions/contacts/import.php +++ b/program/actions/contacts/import.php @@ -126,7 +126,7 @@ class rcmail_action_contacts_import extends rcmail_action_contacts_index $csvs[] = $temp_csv; } else { - $upload_error = UPLOAD_ERR_CANT_WRITE; + $upload_error = \UPLOAD_ERR_CANT_WRITE; } continue; diff --git a/program/actions/contacts/index.php b/program/actions/contacts/index.php index 6d420d1ca..0d91b9db2 100644 --- a/program/actions/contacts/index.php +++ b/program/actions/contacts/index.php @@ -427,7 +427,7 @@ class rcmail_action_contacts_index extends rcmail_action $name = $rcmail->gettext('personaladrbook'); } - $rcmail->output->set_env('sourcename', html_entity_decode($name, ENT_COMPAT, 'UTF-8')); + $rcmail->output->set_env('sourcename', html_entity_decode($name, \ENT_COMPAT, 'UTF-8')); } } diff --git a/program/actions/contacts/list.php b/program/actions/contacts/list.php index 225e36479..8bcb3b956 100644 --- a/program/actions/contacts/list.php +++ b/program/actions/contacts/list.php @@ -46,7 +46,7 @@ class rcmail_action_contacts_list extends rcmail_action_contacts_index // Use search result if (($records = self::search_update(true)) !== false) { // sort the records - ksort($records, SORT_LOCALE_STRING); + ksort($records, \SORT_LOCALE_STRING); // create resultset object $count = count($records); diff --git a/program/actions/contacts/move.php b/program/actions/contacts/move.php index a61399c08..40698ba9a 100644 --- a/program/actions/contacts/move.php +++ b/program/actions/contacts/move.php @@ -182,7 +182,7 @@ class rcmail_action_contacts_move extends rcmail_action_contacts_index // get records from the next page to add to the list elseif ($pages > 1 && $page < $pages) { // sort the records - ksort($records, SORT_LOCALE_STRING); + ksort($records, \SORT_LOCALE_STRING); $first += $page_size; // create resultset object diff --git a/program/actions/contacts/photo.php b/program/actions/contacts/photo.php index 4a46bb16b..18c6c5db6 100644 --- a/program/actions/contacts/photo.php +++ b/program/actions/contacts/photo.php @@ -95,7 +95,7 @@ class rcmail_action_contacts_photo extends rcmail_action_contacts_index $data = $plugin['data']; // detect if photo data is a URL - if ($data && strlen($data) < 1024 && filter_var($data, FILTER_VALIDATE_URL)) { + if ($data && strlen($data) < 1024 && filter_var($data, \FILTER_VALIDATE_URL)) { $rcmail->output->redirect($data); } diff --git a/program/actions/contacts/search.php b/program/actions/contacts/search.php index 32324d2b6..b4d80fc68 100644 --- a/program/actions/contacts/search.php +++ b/program/actions/contacts/search.php @@ -148,7 +148,7 @@ class rcmail_action_contacts_search extends rcmail_action_contacts_index } // sort the records - ksort($records, SORT_LOCALE_STRING); + ksort($records, \SORT_LOCALE_STRING); // create resultset object $count = count($records); diff --git a/program/actions/mail/attachment_upload.php b/program/actions/mail/attachment_upload.php index 4434405b7..a744afd1b 100644 --- a/program/actions/mail/attachment_upload.php +++ b/program/actions/mail/attachment_upload.php @@ -133,7 +133,7 @@ class rcmail_action_mail_attachment_upload extends rcmail_action_mail_index self::attachment_success($attachment, $uploadid); } else { // upload failed - if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) { + if ($err == \UPLOAD_ERR_INI_SIZE || $err == \UPLOAD_ERR_FORM_SIZE) { $size = self::show_bytes(rcube_utils::max_upload_size()); $msg = $rcmail->gettext(['name' => 'filesizeerror', 'vars' => ['size' => $size]]); } @@ -144,7 +144,7 @@ class rcmail_action_mail_attachment_upload extends rcmail_action_mail_index $msg = $rcmail->gettext('fileuploaderror'); } - if (!empty($attachment['error']) || $err != UPLOAD_ERR_NO_FILE) { + if (!empty($attachment['error']) || $err != \UPLOAD_ERR_NO_FILE) { if (!in_array($msg, $errors)) { $rcmail->output->command('display_message', $msg, 'error'); $rcmail->output->command('remove_from_attachment_list', $uploadid); diff --git a/program/actions/mail/autocomplete.php b/program/actions/mail/autocomplete.php index a1862ba5a..c008209aa 100644 --- a/program/actions/mail/autocomplete.php +++ b/program/actions/mail/autocomplete.php @@ -161,7 +161,7 @@ class rcmail_action_mail_autocomplete extends rcmail_action if (count($contacts)) { // sort contacts index - asort($sort_keys, SORT_LOCALE_STRING); + asort($sort_keys, \SORT_LOCALE_STRING); // re-sort contacts according to index foreach ($sort_keys as $idx => $val) { $sort_keys[$idx] = $contacts[$idx]; diff --git a/program/actions/mail/compose.php b/program/actions/mail/compose.php index 4f8575d27..ce694c0f9 100644 --- a/program/actions/mail/compose.php +++ b/program/actions/mail/compose.php @@ -1348,7 +1348,7 @@ class rcmail_action_mail_compose extends rcmail_action_mail_index public static function basename($filename) { // basename() is not unicode safe and locale dependent - if (stristr(PHP_OS, 'win') || stristr(PHP_OS, 'netware')) { + if (stristr(\PHP_OS, 'win') || stristr(\PHP_OS, 'netware')) { return preg_replace('/^.*[\\\\\\/]/', '', $filename); } else { diff --git a/program/actions/mail/get.php b/program/actions/mail/get.php index 77ad74014..43c60dc96 100644 --- a/program/actions/mail/get.php +++ b/program/actions/mail/get.php @@ -132,7 +132,7 @@ class rcmail_action_mail_get extends rcmail_action_mail_index // compare file mimetype with the stated content-type headers and file extension to avoid malicious operations if (!empty($_REQUEST['_embed']) && empty($_REQUEST['_nocheck'])) { - $file_extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); + $file_extension = strtolower(pathinfo($filename, \PATHINFO_EXTENSION)); // 1. compare filename suffix with expected suffix derived from mimetype $valid = $file_extension && in_array($file_extension, (array) $extensions) @@ -267,7 +267,7 @@ class rcmail_action_mail_get extends rcmail_action_mail_index } // add filename extension if missing - if (!pathinfo($filename, PATHINFO_EXTENSION) && ($extensions = rcube_mime::get_mime_extensions($mimetype))) { + if (!pathinfo($filename, \PATHINFO_EXTENSION) && ($extensions = rcube_mime::get_mime_extensions($mimetype))) { $filename .= '.' . $extensions[0]; } diff --git a/program/actions/mail/headers.php b/program/actions/mail/headers.php index 004f37abd..8dae71847 100644 --- a/program/actions/mail/headers.php +++ b/program/actions/mail/headers.php @@ -47,7 +47,7 @@ class rcmail_action_mail_headers extends rcmail_action_mail_index if ($source !== false) { $source = trim(rcube_charset::clean($source)); - $source = htmlspecialchars($source, ENT_COMPAT | ENT_HTML401, RCUBE_CHARSET); + $source = htmlspecialchars($source, \ENT_COMPAT | \ENT_HTML401, RCUBE_CHARSET); $source = preg_replace( [ '/\n[\t\s]+/', diff --git a/program/actions/mail/index.php b/program/actions/mail/index.php index 2dc73487b..26b9e481c 100644 --- a/program/actions/mail/index.php +++ b/program/actions/mail/index.php @@ -1264,7 +1264,7 @@ class rcmail_action_mail_index extends rcmail_action if (preg_match('/#' . preg_quote($cont_id, '/') . '\s+\{([^}]+)}/i', $body, $m)) { // get background related style $regexp = '/(background-position|background-repeat)\s*:\s*([^;]+);/i'; - if (preg_match_all($regexp, $m[1], $matches, PREG_SET_ORDER)) { + if (preg_match_all($regexp, $m[1], $matches, \PREG_SET_ORDER)) { foreach ($matches as $m) { $style[$m[1]] = $m[2]; } @@ -1327,7 +1327,7 @@ class rcmail_action_mail_index extends rcmail_action $content = null; } elseif (preg_match('/^mailto:(.+)/i', $attrib['href'], $mailto)) { - $url_parts = explode('?', html_entity_decode($mailto[1], ENT_QUOTES, 'UTF-8'), 2); + $url_parts = explode('?', html_entity_decode($mailto[1], \ENT_QUOTES, 'UTF-8'), 2); $mailto = $url_parts[0]; $url = $url_parts[1] ?? ''; diff --git a/program/actions/mail/list_contacts.php b/program/actions/mail/list_contacts.php index 1e67800c1..f2db49165 100644 --- a/program/actions/mail/list_contacts.php +++ b/program/actions/mail/list_contacts.php @@ -69,7 +69,7 @@ class rcmail_action_mail_list_contacts extends rcmail_action_mail_index } // sort the records - ksort($records, SORT_LOCALE_STRING); + ksort($records, \SORT_LOCALE_STRING); // create resultset object $count = count($records); diff --git a/program/actions/mail/search_contacts.php b/program/actions/mail/search_contacts.php index fd10344ef..c8bc25926 100644 --- a/program/actions/mail/search_contacts.php +++ b/program/actions/mail/search_contacts.php @@ -70,7 +70,7 @@ class rcmail_action_mail_search_contacts extends rcmail_action_mail_list_contact $group_count = count($jsresult); // sort the records - ksort($records, SORT_LOCALE_STRING); + ksort($records, \SORT_LOCALE_STRING); // create resultset object $count = count($records); diff --git a/program/actions/settings/about.php b/program/actions/settings/about.php index 808e054d9..85e137df8 100644 --- a/program/actions/settings/about.php +++ b/program/actions/settings/about.php @@ -96,7 +96,7 @@ class rcmail_action_settings_about extends rcmail_action return ''; } - ksort($plugin_info, SORT_LOCALE_STRING); + ksort($plugin_info, \SORT_LOCALE_STRING); $table = new html_table($attrib); diff --git a/program/actions/settings/identity_edit.php b/program/actions/settings/identity_edit.php index e79819087..da5846cae 100644 --- a/program/actions/settings/identity_edit.php +++ b/program/actions/settings/identity_edit.php @@ -136,7 +136,7 @@ class rcmail_action_settings_identity_edit extends rcmail_action $form['signature']['content']['signature']['is_escaped'] = true; // Correctly handle HTML entities in HTML editor (#1488483) - self::$record['signature'] = htmlspecialchars(self::$record['signature'], ENT_NOQUOTES, RCUBE_CHARSET); + self::$record['signature'] = htmlspecialchars(self::$record['signature'], \ENT_NOQUOTES, RCUBE_CHARSET); } // hide "default" checkbox if only one identity is allowed diff --git a/program/actions/settings/index.php b/program/actions/settings/index.php index edfc6cab5..d96582a7e 100644 --- a/program/actions/settings/index.php +++ b/program/actions/settings/index.php @@ -1089,7 +1089,7 @@ class rcmail_action_settings_index extends rcmail_action if (!empty($books)) { foreach ($books as $book) { - $select->add(html_entity_decode($book['name'], ENT_COMPAT, 'UTF-8'), $book['id']); + $select->add(html_entity_decode($book['name'], \ENT_COMPAT, 'UTF-8'), $book['id']); } } @@ -1223,7 +1223,7 @@ class rcmail_action_settings_index extends rcmail_action $select->add($rcmail->gettext('collectedrecipients'), (string) rcube_addressbook::TYPE_RECIPIENT); foreach ($books as $book) { - $select->add(html_entity_decode($book['name'], ENT_COMPAT, 'UTF-8'), $book['id']); + $select->add(html_entity_decode($book['name'], \ENT_COMPAT, 'UTF-8'), $book['id']); } $selected = $config['collected_recipients']; @@ -1256,7 +1256,7 @@ class rcmail_action_settings_index extends rcmail_action $select->add($rcmail->gettext('trustedsenders'), (string) rcube_addressbook::TYPE_TRUSTED_SENDER); foreach ($books as $book) { - $select->add(html_entity_decode($book['name'], ENT_COMPAT, 'UTF-8'), $book['id']); + $select->add(html_entity_decode($book['name'], \ENT_COMPAT, 'UTF-8'), $book['id']); } $selected = $config['collected_senders']; diff --git a/program/actions/settings/response_edit.php b/program/actions/settings/response_edit.php index d3b598ccd..ed86bcc14 100644 --- a/program/actions/settings/response_edit.php +++ b/program/actions/settings/response_edit.php @@ -104,7 +104,7 @@ class rcmail_action_settings_response_edit extends rcmail_action_settings_respon $text_attr['is_escaped'] = true; // Correctly handle HTML entities in HTML editor (#1488483) - self::$response['data'] = htmlspecialchars(self::$response['data'], ENT_NOQUOTES, RCUBE_CHARSET); + self::$response['data'] = htmlspecialchars(self::$response['data'], \ENT_NOQUOTES, RCUBE_CHARSET); } $table = new html_table(['cols' => 2]); diff --git a/program/actions/utils/spell.php b/program/actions/utils/spell.php index accae41ff..4f44647f4 100644 --- a/program/actions/utils/spell.php +++ b/program/actions/utils/spell.php @@ -39,7 +39,7 @@ class rcmail_action_utils_spell extends rcmail_action $left = strpos($data, ''); $right = strrpos($data, ''); $data = substr($data, $left + 6, $right - ($left + 6)); - $data = html_entity_decode($data, ENT_QUOTES, RCUBE_CHARSET); + $data = html_entity_decode($data, \ENT_QUOTES, RCUBE_CHARSET); $spellchecker = new rcube_spellchecker($lang); diff --git a/program/actions/utils/spell_html.php b/program/actions/utils/spell_html.php index 559df1e38..42452cbd4 100644 --- a/program/actions/utils/spell_html.php +++ b/program/actions/utils/spell_html.php @@ -44,7 +44,7 @@ class rcmail_action_utils_spell_html extends rcmail_action } else { $data = rcube_utils::get_input_string('text', rcube_utils::INPUT_POST, true); - $data = html_entity_decode($data, ENT_QUOTES, RCUBE_CHARSET); + $data = html_entity_decode($data, \ENT_QUOTES, RCUBE_CHARSET); if ($data && !$spellchecker->check($data)) { $result['words'] = $spellchecker->get(); diff --git a/program/include/clisetup.php b/program/include/clisetup.php index edae98e21..9224af8c1 100644 --- a/program/include/clisetup.php +++ b/program/include/clisetup.php @@ -18,7 +18,7 @@ +-----------------------------------------------------------------------+ */ -if (PHP_SAPI != 'cli') { +if (\PHP_SAPI != 'cli') { exit('Not on the "shell" (php-cli).'); } diff --git a/program/include/iniset.php b/program/include/iniset.php index b57f38742..456196375 100644 --- a/program/include/iniset.php +++ b/program/include/iniset.php @@ -19,7 +19,7 @@ +-----------------------------------------------------------------------+ */ -if (PHP_VERSION_ID < 70300) { +if (\PHP_VERSION_ID < 70300) { exit("Unsupported PHP version. Required PHP >= 7.3."); } @@ -48,7 +48,7 @@ register_shutdown_function('rcmail_error_handler'); // RC include folders MUST be included FIRST to avoid other // possible not compatible libraries (i.e PEAR) to be included // instead the ones provided by RC -$include_path = INSTALL_PATH . 'program/lib' . PATH_SEPARATOR; +$include_path = INSTALL_PATH . 'program/lib' . \PATH_SEPARATOR; $include_path .= ini_get('include_path'); if (set_include_path($include_path) === false) { @@ -109,7 +109,7 @@ function rcmail_error_handler() { $error = error_get_last(); - if ($error && ($error['type'] === E_ERROR || $error['type'] === E_PARSE)) { + if ($error && ($error['type'] === \E_ERROR || $error['type'] === \E_PARSE)) { rcmail_fatal_error(); } } @@ -119,7 +119,7 @@ function rcmail_error_handler() */ function rcmail_fatal_error() { - if (PHP_SAPI === 'cli') { + if (\PHP_SAPI === 'cli') { echo "Fatal error: Please check the Roundcube error log and/or server error logs for more information.\n"; } elseif (!empty($_REQUEST['_remote'])) { diff --git a/program/include/rcmail.php b/program/include/rcmail.php index 907ee4da9..798401102 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -84,7 +84,7 @@ class rcmail extends rcube { if (!self::$instance || !is_a(self::$instance, 'rcmail')) { // In cli-server mode env=test - if ($env === null && PHP_SAPI == 'cli-server') { + if ($env === null && \PHP_SAPI == 'cli-server') { $env = 'test'; } @@ -143,7 +143,7 @@ class rcmail extends rcube } // init output class - if (PHP_SAPI == 'cli') { + if (\PHP_SAPI == 'cli') { $this->output = new rcmail_output_cli(); } elseif (!empty($_REQUEST['_remote'])) { @@ -167,7 +167,7 @@ class rcmail extends rcube */ public function set_task($task) { - if (PHP_SAPI == 'cli') { + if (\PHP_SAPI == 'cli') { $task = 'cli'; } elseif (!$this->user || !$this->user->ID) { @@ -209,14 +209,14 @@ class rcmail extends rcube $_SESSION['language'] = $this->user->language = $lang; // set localization - setlocale(LC_ALL, $lang . '.utf8', $lang . '.UTF-8', 'en_US.utf8', 'en_US.UTF-8'); + setlocale(\LC_ALL, $lang . '.utf8', $lang . '.UTF-8', 'en_US.utf8', 'en_US.UTF-8'); ini_set('intl.default_locale', $lang); // Workaround for http://bugs.php.net/bug.php?id=18556 // Also strtoupper/strtolower and other methods are locale-aware // for these locales it is problematic (#1490519) if (in_array($lang, ['tr_TR', 'ku', 'az_AZ'])) { - setlocale(LC_CTYPE, 'en_US.utf8', 'en_US.UTF-8', 'C'); + setlocale(\LC_CTYPE, 'en_US.utf8', 'en_US.UTF-8', 'C'); } } @@ -530,7 +530,7 @@ class rcmail extends rcube } if (!empty($additional)) { - ksort($additional, SORT_LOCALE_STRING); + ksort($additional, \SORT_LOCALE_STRING); $responses = array_merge(array_values($additional), $responses); } } @@ -1207,7 +1207,7 @@ class rcmail extends rcube // In CLI stop here, prevent from errors when the console.log might exist, // but be not accessible - if (PHP_SAPI == 'cli') { + if (\PHP_SAPI == 'cli') { return; } @@ -1217,7 +1217,7 @@ class rcmail extends rcube $this->config->set('per_user_logging', false); // make sure logged numbers use unified format - setlocale(LC_NUMERIC, 'en_US.utf8', 'en_US.UTF-8', 'en_US', 'C'); + setlocale(\LC_NUMERIC, 'en_US.utf8', 'en_US.UTF-8', 'en_US', 'C'); if (function_exists('memory_get_usage')) { $mem = round(memory_get_usage() / 1024 / 1024, 1); diff --git a/program/include/rcmail_action.php b/program/include/rcmail_action.php index 34b94585e..672d14ac7 100644 --- a/program/include/rcmail_action.php +++ b/program/include/rcmail_action.php @@ -590,7 +590,7 @@ abstract class rcmail_action elseif ($attachment && !empty($attachment['error'])) { $msg = $attachment['error']; } - elseif ($php_error == UPLOAD_ERR_INI_SIZE || $php_error == UPLOAD_ERR_FORM_SIZE) { + elseif ($php_error == \UPLOAD_ERR_INI_SIZE || $php_error == \UPLOAD_ERR_FORM_SIZE) { $post_size = self::show_bytes(rcube_utils::max_upload_size()); $msg = $rcmail->gettext(['name' => 'filesizeerror', 'vars' => ['size' => $post_size]]); } diff --git a/program/include/rcmail_install.php b/program/include/rcmail_install.php index 2049b8be7..548d13dd6 100644 --- a/program/include/rcmail_install.php +++ b/program/include/rcmail_install.php @@ -160,16 +160,16 @@ class rcmail_install for ($i = 0; $i < count($tokens); $i++) { $token = $tokens[$i]; - if ($token[0] == T_VARIABLE && ($token[1] == '$config' || $token[1] == '$rcmail_config')) { + if ($token[0] == \T_VARIABLE && ($token[1] == '$config' || $token[1] == '$rcmail_config')) { $in_config = true; - if ($buffer && $tokens[$i + 1] == '[' && $tokens[$i + 2][0] == T_CONSTANT_ENCAPSED_STRING) { + if ($buffer && $tokens[$i + 1] == '[' && $tokens[$i + 2][0] == \T_CONSTANT_ENCAPSED_STRING) { $propname = trim($tokens[$i + 2][1], "'\""); $this->comments[$propname] = preg_replace('/\n\n/', "\n", $buffer); $buffer = ''; $i += 3; } } - elseif ($in_config && $token[0] == T_COMMENT) { + elseif ($in_config && $token[0] == \T_COMMENT) { $buffer .= strtr($token[1], ['\n' => "\n"]) . "\n"; } } @@ -926,7 +926,7 @@ class rcmail_install for ($i = 0; $i < $zip->numFiles; $i++) { $filename = $zip->getNameIndex($i); if (substr($filename, -1, 1) != '/') { - copy("zip://" . $zipfile . "#" . $filename, $destdir . '/' . pathinfo($filename, PATHINFO_BASENAME)); + copy("zip://" . $zipfile . "#" . $filename, $destdir . '/' . pathinfo($filename, \PATHINFO_BASENAME)); } } } @@ -972,7 +972,7 @@ class rcmail_install if ($flat) { // In flat mode remove all directories - $extract_tree = glob("$destdir/*", GLOB_ONLYDIR); + $extract_tree = glob("$destdir/*", \GLOB_ONLYDIR); foreach ($extract_tree as $dir) { rmdir($dir); } diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php index 4776081ed..8c7daa5f3 100644 --- a/program/include/rcmail_output_html.php +++ b/program/include/rcmail_output_html.php @@ -89,7 +89,7 @@ class rcmail_output_html extends rcmail_output // add cookie info $this->set_env('cookie_domain', ini_get('session.cookie_domain')); $this->set_env('cookie_path', ini_get('session.cookie_path')); - $this->set_env('cookie_secure', filter_var(ini_get('session.cookie_secure'), FILTER_VALIDATE_BOOLEAN)); + $this->set_env('cookie_secure', filter_var(ini_get('session.cookie_secure'), \FILTER_VALIDATE_BOOLEAN)); // Easy way to change skin via GET argument, for developers if ($this->devel_mode && !empty($_GET['skin']) && preg_match('/^[a-z0-9-_]+$/i', $_GET['skin'])) { @@ -1105,7 +1105,7 @@ class rcmail_output_html extends rcmail_output $pos = 0; // Find IF tags and process them - while ($pos < strlen($input) && preg_match($regexp1, $input, $conditions, PREG_OFFSET_CAPTURE, $pos)) { + while ($pos < strlen($input) && preg_match($regexp1, $input, $conditions, \PREG_OFFSET_CAPTURE, $pos)) { $pos = $start = $conditions[0][1]; // Process the 'condition' attribute @@ -1121,7 +1121,7 @@ class rcmail_output_html extends rcmail_output $n = $pos + 1; // Process the code until the closing tag (for the processed IF tag) - while (preg_match($regexp2, $input, $matches, PREG_OFFSET_CAPTURE, $n)) { + while (preg_match($regexp2, $input, $matches, \PREG_OFFSET_CAPTURE, $n)) { $tag_start = $matches[0][1]; $tag_end = $tag_start + strlen($matches[0][0]); $tag_name = strtolower($matches[1][0]); @@ -1295,7 +1295,7 @@ class rcmail_output_html extends rcmail_output $value = $_SESSION[$name] ?? ''; break; case 'cookie': - $value = htmlspecialchars($_COOKIE[$name], ENT_COMPAT | ENT_HTML401, RCUBE_CHARSET); + $value = htmlspecialchars($_COOKIE[$name], \ENT_COMPAT | \ENT_HTML401, RCUBE_CHARSET); break; case 'browser': $value = $this->browser->{$name} ?? ''; @@ -2463,7 +2463,7 @@ class rcmail_output_html extends rcmail_output */ protected function preloader($attrib) { - $images = preg_split('/[\s\t\n,]+/', $attrib['images'], -1, PREG_SPLIT_NO_EMPTY); + $images = preg_split('/[\s\t\n,]+/', $attrib['images'], -1, \PREG_SPLIT_NO_EMPTY); $images = array_map([$this, 'abs_url'], $images); $images = array_map([$this, 'asset_url'], $images); @@ -2742,7 +2742,7 @@ class rcmail_output_html extends rcmail_output if (empty($type)) { // If no type provided then remove those options from the list - $template_names = preg_grep("/\]$/", $template_names, PREG_GREP_INVERT); + $template_names = preg_grep("/\]$/", $template_names, \PREG_GREP_INVERT); } elseif ($match === null) { // Type specified with no special matching requirements so remove all none type specific options from the list @@ -2751,7 +2751,7 @@ class rcmail_output_html extends rcmail_output if ($match == 'template') { // Match only specific type or template name - $template_names = preg_grep("/\*$/", $template_names, PREG_GREP_INVERT); + $template_names = preg_grep("/\*$/", $template_names, \PREG_GREP_INVERT); } foreach ($template_names as $key) { diff --git a/program/include/rcmail_resend_mail.php b/program/include/rcmail_resend_mail.php index 36d3da9ef..179e4756b 100644 --- a/program/include/rcmail_resend_mail.php +++ b/program/include/rcmail_resend_mail.php @@ -187,6 +187,6 @@ class rcmail_bounce_stream_filter extends php_user_filter stream_bucket_append($out, $bucket); } - return PSFS_PASS_ON; + return \PSFS_PASS_ON; } } diff --git a/program/include/rcmail_sendmail.php b/program/include/rcmail_sendmail.php index d4c6031be..4b134bb9c 100644 --- a/program/include/rcmail_sendmail.php +++ b/program/include/rcmail_sendmail.php @@ -684,7 +684,7 @@ class rcmail_sendmail $domain = 'localhost'; $regexp = '#img[^>]+src=[\'"](data:([^;]*);base64,([a-z0-9+/=\r\n]+))([\'"])#i'; - if (preg_match_all($regexp, $body, $matches, PREG_OFFSET_CAPTURE)) { + if (preg_match_all($regexp, $body, $matches, \PREG_OFFSET_CAPTURE)) { // get domain for the Content-ID, must be the same as in Mail_mime::get() if (preg_match('#@([0-9a-zA-Z\-\.]+)#', $from, $m)) { $domain = $m[1]; diff --git a/program/include/rcmail_utils.php b/program/include/rcmail_utils.php index 2c024a2fe..048c9d711 100644 --- a/program/include/rcmail_utils.php +++ b/program/include/rcmail_utils.php @@ -181,7 +181,7 @@ class rcmail_utils $result[] = $m[1]; } } - sort($result, SORT_NUMERIC); + sort($result, \SORT_NUMERIC); foreach ($result as $v) { if (empty($opts['quiet'])) { @@ -317,7 +317,7 @@ class rcmail_utils } // host can be a URL like tls://192.168.12.44 - $host_url = parse_url($args['host'], PHP_URL_HOST); + $host_url = parse_url($args['host'], \PHP_URL_HOST); if ($host_url) { $args['host'] = $host_url; } diff --git a/program/lib/Roundcube/bootstrap.php b/program/lib/Roundcube/bootstrap.php index 8cd5f977c..60a580f91 100644 --- a/program/lib/Roundcube/bootstrap.php +++ b/program/lib/Roundcube/bootstrap.php @@ -30,14 +30,14 @@ $config = [ // Some users are not using Installer, so we'll check some // critical PHP settings here. Only these, which doesn't provide // an error/warning in the logs later. See (#1486307). -if (PHP_MAJOR_VERSION < 8) { +if (\PHP_MAJOR_VERSION < 8) { $config += [ 'mbstring.func_overload' => 0, ]; } // check these additional ini settings if not called via CLI -if (PHP_SAPI != 'cli') { +if (\PHP_SAPI != 'cli') { $config += [ 'suhosin.session.encrypt' => false, 'file_uploads' => true, @@ -47,14 +47,14 @@ if (PHP_SAPI != 'cli') { } foreach ($config as $optname => $optval) { - $ini_optval = filter_var(ini_get($optname), is_bool($optval) ? FILTER_VALIDATE_BOOLEAN : FILTER_VALIDATE_INT); + $ini_optval = filter_var(ini_get($optname), is_bool($optval) ? \FILTER_VALIDATE_BOOLEAN : \FILTER_VALIDATE_INT); if ($optval != $ini_optval && @ini_set($optname, $optval) === false) { $optval = !is_bool($optval) ? $optval : ($optval ? 'On' : 'Off'); $error = "ERROR: Wrong '$optname' option value and it wasn't possible to set it to required value ($optval).\n" . "Check your PHP configuration (including php_admin_flag)."; if (defined('STDERR')) { - fwrite(STDERR, $error); + fwrite(\STDERR, $error); } else { echo $error; } @@ -93,12 +93,12 @@ mb_regex_encoding(RCUBE_CHARSET); // make sure the Roundcube lib directory is in the include_path $rcube_path = realpath(RCUBE_LIB_DIR . '..'); -$sep = PATH_SEPARATOR; +$sep = \PATH_SEPARATOR; $regexp = "!(^|$sep)" . preg_quote($rcube_path, '!') . "($sep|\$)!"; $path = ini_get('include_path'); if (!preg_match($regexp, $path)) { - set_include_path($path . PATH_SEPARATOR . $rcube_path); + set_include_path($path . \PATH_SEPARATOR . $rcube_path); } // Register autoloader diff --git a/program/lib/Roundcube/cache/db.php b/program/lib/Roundcube/cache/db.php index 0263ae975..acfe754d7 100644 --- a/program/lib/Roundcube/cache/db.php +++ b/program/lib/Roundcube/cache/db.php @@ -126,7 +126,7 @@ class rcube_cache_db extends rcube_cache // don't attempt to write too big data sets if ($size > $this->max_packet_size()) { - trigger_error("rcube_cache: max_packet_size ($this->max_packet) exceeded for key $key. Tried to write $size bytes", E_USER_WARNING); + trigger_error("rcube_cache: max_packet_size ($this->max_packet) exceeded for key $key. Tried to write $size bytes", \E_USER_WARNING); return false; } diff --git a/program/lib/Roundcube/cache/memcache.php b/program/lib/Roundcube/cache/memcache.php index 7306a9471..1c353d78e 100644 --- a/program/lib/Roundcube/cache/memcache.php +++ b/program/lib/Roundcube/cache/memcache.php @@ -167,10 +167,10 @@ class rcube_cache_memcache extends rcube_cache return false; } - $result = self::$memcache->replace($key, $data, MEMCACHE_COMPRESSED, $this->ttl); + $result = self::$memcache->replace($key, $data, \MEMCACHE_COMPRESSED, $this->ttl); if (!$result) { - $result = self::$memcache->set($key, $data, MEMCACHE_COMPRESSED, $this->ttl); + $result = self::$memcache->set($key, $data, \MEMCACHE_COMPRESSED, $this->ttl); } if ($this->debug) { diff --git a/program/lib/Roundcube/html.php b/program/lib/Roundcube/html.php index b1563b576..2eec7e566 100644 --- a/program/lib/Roundcube/html.php +++ b/program/lib/Roundcube/html.php @@ -396,7 +396,7 @@ class html return (string) $str; } - return @htmlspecialchars($str, ENT_COMPAT | ENT_SUBSTITUTE, RCUBE_CHARSET); + return @htmlspecialchars($str, \ENT_COMPAT | \ENT_SUBSTITUTE, RCUBE_CHARSET); } } diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php index 559ef85a4..bff14bcf3 100644 --- a/program/lib/Roundcube/rcube.php +++ b/program/lib/Roundcube/rcube.php @@ -127,8 +127,8 @@ class rcube // initialize syslog if ($this->config->get('log_driver') == 'syslog') { $syslog_id = $this->config->get('syslog_id', 'roundcube'); - $syslog_facility = $this->config->get('syslog_facility', LOG_USER); - openlog($syslog_id, LOG_ODELAY, $syslog_facility); + $syslog_facility = $this->config->get('syslog_facility', \LOG_USER); + openlog($syslog_id, \LOG_ODELAY, $syslog_facility); } // connect to database @@ -619,13 +619,13 @@ class rcube // case folding if ((!empty($attrib['uppercase']) && strtolower($attrib['uppercase']) == 'first') || !empty($attrib['ucfirst'])) { - $case_mode = MB_CASE_TITLE; + $case_mode = \MB_CASE_TITLE; } elseif (!empty($attrib['uppercase'])) { - $case_mode = MB_CASE_UPPER; + $case_mode = \MB_CASE_UPPER; } elseif (!empty($attrib['lowercase'])) { - $case_mode = MB_CASE_LOWER; + $case_mode = \MB_CASE_LOWER; } if (isset($case_mode)) { @@ -910,10 +910,10 @@ class rcube // This distinction is for PHP 7.3 which throws a warning when // we use $tag argument with non-AEAD cipher method here if (!preg_match('/-(gcm|ccm|poly1305)$/i', $method)) { - $cipher = openssl_encrypt($clear, $method, $ckey, OPENSSL_RAW_DATA, $iv); + $cipher = openssl_encrypt($clear, $method, $ckey, \OPENSSL_RAW_DATA, $iv); } else { - $cipher = openssl_encrypt($clear, $method, $ckey, OPENSSL_RAW_DATA, $iv, $tag); + $cipher = openssl_encrypt($clear, $method, $ckey, \OPENSSL_RAW_DATA, $iv, $tag); } if ($cipher === false) { @@ -975,7 +975,7 @@ class rcube } $cipher = substr($cipher, $iv_size); - $clear = openssl_decrypt($cipher, $method, $ckey, OPENSSL_RAW_DATA, $iv, $tag); + $clear = openssl_decrypt($cipher, $method, $ckey, \OPENSSL_RAW_DATA, $iv, $tag); return $clear; } @@ -1233,7 +1233,7 @@ class rcube $values += (array) $arg; } - preg_match_all('/({(-?)([a-z]\w*)})/', $cmd, $matches, PREG_SET_ORDER); + preg_match_all('/({(-?)([a-z]\w*)})/', $cmd, $matches, \PREG_SET_ORDER); foreach ($matches as $tags) { [, $tag, $option, $key] = $tags; $parts = []; @@ -1335,7 +1335,7 @@ class rcube } if ($log_driver == 'syslog') { - $prio = $name == 'errors' ? LOG_ERR : LOG_INFO; + $prio = $name == 'errors' ? \LOG_ERR : \LOG_INFO; return syslog($prio, $line); } @@ -1343,7 +1343,7 @@ class rcube if ($log_driver == 'stdout') { $stdout = "php://stdout"; $line = "$name: $line\n"; - return file_put_contents($stdout, $line, FILE_APPEND) !== false; + return file_put_contents($stdout, $line, \FILE_APPEND) !== false; } // log_driver == 'file' is assumed here @@ -1380,7 +1380,7 @@ class rcube $name .= '.log'; } - return file_put_contents("$log_dir/$name", $line, FILE_APPEND) !== false; + return file_put_contents("$log_dir/$name", $line, \FILE_APPEND) !== false; } /** @@ -1421,7 +1421,7 @@ class rcube $arg['code'] = 500; } - $cli = PHP_SAPI == 'cli'; + $cli = \PHP_SAPI == 'cli'; $arg['cli'] = $cli; $arg['log'] = $log; @@ -1449,7 +1449,7 @@ class rcube } if ($cli) { - fwrite(STDERR, 'ERROR: ' . trim($arg['message']) . "\n"); + fwrite(\STDERR, 'ERROR: ' . trim($arg['message']) . "\n"); } elseif ($terminate && is_object(self::$instance->output)) { self::$instance->output->raise_error($arg['code'], $arg['message']); @@ -1504,7 +1504,7 @@ class rcube if (!self::write_log('errors', $log_entry)) { // send error to PHPs error handler if write_log didn't succeed - trigger_error($arg_arr['message'], E_USER_WARNING); + trigger_error($arg_arr['message'], \E_USER_WARNING); } } diff --git a/program/lib/Roundcube/rcube_base_replacer.php b/program/lib/Roundcube/rcube_base_replacer.php index a00988d6b..c3f6c842e 100644 --- a/program/lib/Roundcube/rcube_base_replacer.php +++ b/program/lib/Roundcube/rcube_base_replacer.php @@ -102,7 +102,7 @@ class rcube_base_replacer // strip './' because its the same as '' $path = preg_replace('/^\.\//', '', $path); - if (preg_match_all('/\.\.\//', $path, $matches, PREG_SET_ORDER)) { + if (preg_match_all('/\.\.\//', $path, $matches, \PREG_SET_ORDER)) { $cnt = count($matches); while ($cnt--) { if ($pos = strrpos($base_url, '/')) { diff --git a/program/lib/Roundcube/rcube_cache.php b/program/lib/Roundcube/rcube_cache.php index b04d31d03..8b6ae7843 100644 --- a/program/lib/Roundcube/rcube_cache.php +++ b/program/lib/Roundcube/rcube_cache.php @@ -479,7 +479,7 @@ class rcube_cache // don't attempt to write too big data sets if ($size > $this->max_packet_size()) { - trigger_error("rcube_cache: max_packet_size ($this->max_packet) exceeded for key $key. Tried to write $size bytes", E_USER_WARNING); + trigger_error("rcube_cache: max_packet_size ($this->max_packet) exceeded for key $key. Tried to write $size bytes", \E_USER_WARNING); return false; } diff --git a/program/lib/Roundcube/rcube_charset.php b/program/lib/Roundcube/rcube_charset.php index 19a79f7e7..a7c7f4ee4 100644 --- a/program/lib/Roundcube/rcube_charset.php +++ b/program/lib/Roundcube/rcube_charset.php @@ -301,7 +301,7 @@ class rcube_charset // FIXME: Is this really true with substitute character 'none'? // A warning is thrown in PHP<8 also on unsupported encoding, in PHP>=8 ValueError // is thrown instead (therefore we catch Throwable below) - set_error_handler($error_handler, E_WARNING); + set_error_handler($error_handler, \E_WARNING); try { $out = mb_convert_encoding($str, $to, $from); @@ -338,7 +338,7 @@ class rcube_charset // If iconv reports an illegal character in input it means that input string // has been truncated. It's reported as E_NOTICE. // PHP8 will also throw E_WARNING on unsupported encoding. - set_error_handler($error_handler, E_NOTICE | E_WARNING); + set_error_handler($error_handler, \E_NOTICE | \E_WARNING); try { $out = iconv($from, $to . $iconv_options, $str); diff --git a/program/lib/Roundcube/rcube_config.php b/program/lib/Roundcube/rcube_config.php index e682c18b9..9808275ee 100644 --- a/program/lib/Roundcube/rcube_config.php +++ b/program/lib/Roundcube/rcube_config.php @@ -66,7 +66,7 @@ class rcube_config $this->env = $env; if ($paths = getenv('RCUBE_CONFIG_PATH')) { - $this->paths = explode(PATH_SEPARATOR, $paths); + $this->paths = explode(\PATH_SEPARATOR, $paths); // make all paths absolute foreach ($this->paths as $i => $path) { if (!rcube_utils::is_absolute_path($path)) { @@ -202,7 +202,7 @@ class rcube_config $this->errors[] = 'config.inc.php was not found.'; } elseif (rand(1,100) == 10) { // log warning on every 100th request (average) - trigger_error("config.inc.php was not found. Please migrate your config by running bin/update.sh", E_USER_WARNING); + trigger_error("config.inc.php was not found. Please migrate your config by running bin/update.sh", \E_USER_WARNING); } } @@ -603,7 +603,7 @@ class rcube_config } } - $php_os = strtolower(substr(PHP_OS, 0, 3)); + $php_os = strtolower(substr(\PHP_OS, 0, 3)); if ($php_os == 'win') { return "\r\n"; diff --git a/program/lib/Roundcube/rcube_content_filter.php b/program/lib/Roundcube/rcube_content_filter.php index f97dbf30e..d970bff1a 100644 --- a/program/lib/Roundcube/rcube_content_filter.php +++ b/program/lib/Roundcube/rcube_content_filter.php @@ -39,7 +39,7 @@ class rcube_content_filter extends php_user_filter // check for evil content and abort if (preg_match('/<(script|iframe|object)/i', $this->buffer)) { - return PSFS_ERR_FATAL; + return \PSFS_ERR_FATAL; } // keep buffer small enough @@ -51,6 +51,6 @@ class rcube_content_filter extends php_user_filter stream_bucket_append($out, $bucket); } - return PSFS_PASS_ON; + return \PSFS_PASS_ON; } } diff --git a/program/lib/Roundcube/rcube_db.php b/program/lib/Roundcube/rcube_db.php index 14d113c47..64f0fdd2c 100644 --- a/program/lib/Roundcube/rcube_db.php +++ b/program/lib/Roundcube/rcube_db.php @@ -273,7 +273,7 @@ class rcube_db $regex = '/(?:^|\s)(from|update|into|join)\s+' . $start . '?([a-z0-9._]+)' . $end . '?\s+/i'; // find tables involved in this query - if (preg_match_all($regex, $query, $matches, PREG_SET_ORDER)) { + if (preg_match_all($regex, $query, $matches, \PREG_SET_ORDER)) { foreach ($matches as $m) { $table = $m[2]; diff --git a/program/lib/Roundcube/rcube_html2text.php b/program/lib/Roundcube/rcube_html2text.php index 6cfafa495..32ecfcc3d 100644 --- a/program/lib/Roundcube/rcube_html2text.php +++ b/program/lib/Roundcube/rcube_html2text.php @@ -526,7 +526,7 @@ class rcube_html2text $text = preg_replace($this->ent_search, $this->ent_replace, $text); // Replace known html entities - $text = html_entity_decode($text, ENT_QUOTES, $this->charset); + $text = html_entity_decode($text, \ENT_QUOTES, $this->charset); // Replace unicode nbsp to regular spaces $text = preg_replace('/\xC2\xA0/', ' ', $text); @@ -722,7 +722,7 @@ class rcube_html2text // Add citation markers and create
 block
                     $body = preg_replace_callback('/((?:^|\n)>*)([^\n]*)/', [$this, 'blockquote_citation_callback'], trim($body));
-                    $body = '
' . htmlspecialchars($body, ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE, $this->charset) . '
'; + $body = '
' . htmlspecialchars($body, \ENT_COMPAT | \ENT_HTML401 | \ENT_SUBSTITUTE, $this->charset) . '
'; $text = substr_replace($text, $body . "\n", $start, $end + 13 - $start); $offset = 0; @@ -792,7 +792,7 @@ class rcube_html2text private function _toupper($str) { // string can containing HTML tags - $chunks = preg_split('/(<[^>]*>)/', $str, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); + $chunks = preg_split('/(<[^>]*>)/', $str, -1, \PREG_SPLIT_NO_EMPTY | \PREG_SPLIT_DELIM_CAPTURE); // convert toupper only the text between HTML tags foreach ($chunks as $idx => $chunk) { @@ -813,9 +813,9 @@ class rcube_html2text */ private function _strtoupper($str) { - $str = html_entity_decode($str, ENT_COMPAT, $this->charset); + $str = html_entity_decode($str, \ENT_COMPAT, $this->charset); $str = mb_strtoupper($str); - $str = htmlspecialchars($str, ENT_COMPAT, $this->charset); + $str = htmlspecialchars($str, \ENT_COMPAT, $this->charset); return $str; } diff --git a/program/lib/Roundcube/rcube_image.php b/program/lib/Roundcube/rcube_image.php index 11482d23f..9f2933364 100644 --- a/program/lib/Roundcube/rcube_image.php +++ b/program/lib/Roundcube/rcube_image.php @@ -206,21 +206,21 @@ class rcube_image } // do we have enough memory? (#1489937) - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' && !$this->mem_check($props)) { + if (strtoupper(substr(\PHP_OS, 0, 3)) == 'WIN' && !$this->mem_check($props)) { return false; } // use GD extension if ($props['gd_type'] && $props['width'] > 0 && $props['height'] > 0) { - if ($props['gd_type'] == IMAGETYPE_JPEG && function_exists('imagecreatefromjpeg')) { + if ($props['gd_type'] == \IMAGETYPE_JPEG && function_exists('imagecreatefromjpeg')) { $image = @imagecreatefromjpeg($this->image_file); $type = 'jpg'; } - elseif ($props['gd_type'] == IMAGETYPE_GIF && function_exists('imagecreatefromgif')) { + elseif ($props['gd_type'] == \IMAGETYPE_GIF && function_exists('imagecreatefromgif')) { $image = @imagecreatefromgif($this->image_file); $type = 'gif'; } - elseif ($props['gd_type'] == IMAGETYPE_PNG && function_exists('imagecreatefrompng')) { + elseif ($props['gd_type'] == \IMAGETYPE_PNG && function_exists('imagecreatefrompng')) { $image = @imagecreatefrompng($this->image_file); $type = 'png'; } @@ -251,7 +251,7 @@ class rcube_image } // Fix transparency of gif/png image - if ($props['gd_type'] != IMAGETYPE_JPEG) { + if ($props['gd_type'] != \IMAGETYPE_JPEG) { imagealphablending($new_image, false); imagesavealpha($new_image, true); $transparent = imagecolorallocatealpha($new_image, 255, 255, 255, 127); @@ -279,14 +279,14 @@ class rcube_image } } - if ($props['gd_type'] == IMAGETYPE_JPEG) { + if ($props['gd_type'] == \IMAGETYPE_JPEG) { $result = imagejpeg($image, $filename, 75); } - elseif ($props['gd_type'] == IMAGETYPE_GIF) { + elseif ($props['gd_type'] == \IMAGETYPE_GIF) { $result = imagegif($image, $filename); } - elseif ($props['gd_type'] == IMAGETYPE_PNG) { - $result = imagepng($image, $filename, 6, PNG_ALL_FILTERS); + elseif ($props['gd_type'] == \IMAGETYPE_PNG) { + $result = imagepng($image, $filename, 6, \PNG_ALL_FILTERS); } } @@ -361,21 +361,21 @@ class rcube_image $props = $this->props(); // do we have enough memory? (#1489937) - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' && !$this->mem_check($props)) { + if (strtoupper(substr(\PHP_OS, 0, 3)) == 'WIN' && !$this->mem_check($props)) { return false; } if ($props['gd_type']) { - if ($props['gd_type'] == IMAGETYPE_JPEG && function_exists('imagecreatefromjpeg')) { + if ($props['gd_type'] == \IMAGETYPE_JPEG && function_exists('imagecreatefromjpeg')) { $image = imagecreatefromjpeg($this->image_file); } - elseif ($props['gd_type'] == IMAGETYPE_GIF && function_exists('imagecreatefromgif')) { + elseif ($props['gd_type'] == \IMAGETYPE_GIF && function_exists('imagecreatefromgif')) { $image = imagecreatefromgif($this->image_file); } - elseif ($props['gd_type'] == IMAGETYPE_PNG && function_exists('imagecreatefrompng')) { + elseif ($props['gd_type'] == \IMAGETYPE_PNG && function_exists('imagecreatefrompng')) { $image = imagecreatefrompng($this->image_file); } - elseif ($props['gd_type'] == IMAGETYPE_WEBP && function_exists('imagecreatefromwebp')) { + elseif ($props['gd_type'] == \IMAGETYPE_WEBP && function_exists('imagecreatefromwebp')) { $image = imagecreatefromwebp($this->image_file); } else { @@ -390,7 +390,7 @@ class rcube_image $result = imagegif($image, $filename); } elseif ($type == self::TYPE_PNG) { - $result = imagepng($image, $filename, 6, PNG_ALL_FILTERS); + $result = imagepng($image, $filename, 6, \PNG_ALL_FILTERS); } if (!empty($result)) { diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php index d398acc6d..979941a88 100644 --- a/program/lib/Roundcube/rcube_imap.php +++ b/program/lib/Roundcube/rcube_imap.php @@ -136,8 +136,8 @@ class rcube_imap extends rcube_storage $this->options['ident'] = [ 'name' => 'Roundcube', 'version' => RCUBE_VERSION, - 'php' => PHP_VERSION, - 'os' => PHP_OS, + 'php' => \PHP_VERSION, + 'os' => \PHP_OS, 'command' => $_SERVER['REQUEST_URI'] ?? '', ]; } @@ -650,8 +650,8 @@ class rcube_imap extends rcube_storage $ident = $this->conn->id([ 'name' => 'Roundcube', 'version' => RCUBE_VERSION, - 'php' => PHP_VERSION, - 'os' => PHP_OS, + 'php' => \PHP_VERSION, + 'os' => \PHP_OS, ]); } else { @@ -1809,7 +1809,7 @@ class rcube_imap extends rcube_storage public static function convert_criteria($str, $charset, $dest_charset = 'US-ASCII') { // convert strings to US_ASCII - if (preg_match_all('/\{([0-9]+)\}\r\n/', $str, $matches, PREG_OFFSET_CAPTURE)) { + if (preg_match_all('/\{([0-9]+)\}\r\n/', $str, $matches, \PREG_OFFSET_CAPTURE)) { $last = 0; $res = ''; @@ -4530,7 +4530,7 @@ class rcube_imap extends rcube_storage // strcoll() does not work with UTF8 locale on Windows, // use Collator from the intl extension - if (stripos(PHP_OS, 'win') === 0 && function_exists('collator_compare')) { + if (stripos(\PHP_OS, 'win') === 0 && function_exists('collator_compare')) { $locale = ($this->options['language'] ?? null) ?: 'en_US'; $this->sort_folder_collator = collator_create($locale) ?: false; } diff --git a/program/lib/Roundcube/rcube_imap_cache.php b/program/lib/Roundcube/rcube_imap_cache.php index 7419ec410..eb3347323 100644 --- a/program/lib/Roundcube/rcube_imap_cache.php +++ b/program/lib/Roundcube/rcube_imap_cache.php @@ -924,8 +924,8 @@ class rcube_imap_cache return false; } - sort($uids_new, SORT_NUMERIC); - sort($uids_old, SORT_NUMERIC); + sort($uids_new, \SORT_NUMERIC); + sort($uids_old, \SORT_NUMERIC); if ($uids_old != $uids_new) { return false; diff --git a/program/lib/Roundcube/rcube_imap_generic.php b/program/lib/Roundcube/rcube_imap_generic.php index 3a149e2b3..5af9b4651 100644 --- a/program/lib/Roundcube/rcube_imap_generic.php +++ b/program/lib/Roundcube/rcube_imap_generic.php @@ -141,7 +141,7 @@ class rcube_imap_generic } $res = 0; - if ($parts = preg_split('/(\{[0-9]+\}\r\n)/m', $string, -1, PREG_SPLIT_DELIM_CAPTURE)) { + if ($parts = preg_split('/(\{[0-9]+\}\r\n)/m', $string, -1, \PREG_SPLIT_DELIM_CAPTURE)) { for ($i = 0, $cnt = count($parts); $i < $cnt; $i++) { if ($i + 1 < $cnt && preg_match('/^\{([0-9]+)\}\r\n$/', $parts[$i + 1], $matches)) { // LITERAL+/LITERAL- support @@ -677,7 +677,7 @@ class rcube_imap_generic $token = base64_encode($token); } catch (Exception $e) { - trigger_error($e->getMessage(), E_USER_WARNING); + trigger_error($e->getMessage(), \E_USER_WARNING); return $this->setError(self::ERROR_BYE, "GSSAPI authentication failed"); } @@ -715,7 +715,7 @@ class rcube_imap_generic } } catch (Exception $e) { - trigger_error($e->getMessage(), E_USER_WARNING); + trigger_error($e->getMessage(), \E_USER_WARNING); return $this->setError(self::ERROR_BYE, "GSSAPI authentication failed"); } @@ -1057,7 +1057,7 @@ class rcube_imap_generic $options = array_intersect_key($this->prefs['socket_options'], ['ssl' => 1]); $context = stream_context_create($options); $this->fp = stream_socket_client($host . ':' . $port, $errno, $errstr, - $this->prefs['timeout'], STREAM_CLIENT_CONNECT, $context); + $this->prefs['timeout'], \STREAM_CLIENT_CONNECT, $context); } else { $this->fp = @fsockopen($host, $port, $errno, $errstr, $this->prefs['timeout']); @@ -1124,9 +1124,9 @@ class rcube_imap_generic else { // There is no flag to enable all TLS methods. Net_SMTP // handles enabling TLS similarly. - $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT - | @STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT - | @STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; + $crypto_method = \STREAM_CRYPTO_METHOD_TLS_CLIENT + | @\STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT + | @\STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; } if (!stream_socket_enable_crypto($this->fp, true, $crypto_method)) { @@ -2792,11 +2792,11 @@ class rcube_imap_generic $index[$key] = $value; } - $sort_order = $order == 'ASC' ? SORT_ASC : SORT_DESC; - $sort_flags = SORT_STRING | SORT_FLAG_CASE; + $sort_order = $order == 'ASC' ? \SORT_ASC : \SORT_DESC; + $sort_flags = \SORT_STRING | \SORT_FLAG_CASE; if (in_array($field, ['arrival', 'date', 'internaldate', 'timestamp', 'size', 'uid', 'id'])) { - $sort_flags = SORT_NUMERIC; + $sort_flags = \SORT_NUMERIC; } array_multisort($index, $sort_order, $sort_flags, $messages); @@ -3309,7 +3309,7 @@ class rcube_imap_generic return false; } - $min_free = PHP_INT_MAX; + $min_free = \PHP_INT_MAX; $result = []; $all = []; @@ -3602,7 +3602,7 @@ class rcube_imap_generic // create options string if (is_array($options)) { - $options = array_change_key_case($options, CASE_UPPER); + $options = array_change_key_case($options, \CASE_UPPER); $opts = []; if (!empty($options['MAXSIZE'])) { diff --git a/program/lib/Roundcube/rcube_imap_search.php b/program/lib/Roundcube/rcube_imap_search.php index ff2b4d1e9..901ec268f 100644 --- a/program/lib/Roundcube/rcube_imap_search.php +++ b/program/lib/Roundcube/rcube_imap_search.php @@ -193,7 +193,7 @@ class rcube_imap_search_job // extends Stackable $imap = $this->worker->get_imap(); if (!$imap->connected()) { - trigger_error("No IMAP connection for $this->folder", E_USER_WARNING); + trigger_error("No IMAP connection for $this->folder", \E_USER_WARNING); if ($this->threading) { return new rcube_result_thread($this->folder); diff --git a/program/lib/Roundcube/rcube_ldap.php b/program/lib/Roundcube/rcube_ldap.php index 8d08e4455..6b528717e 100644 --- a/program/lib/Roundcube/rcube_ldap.php +++ b/program/lib/Roundcube/rcube_ldap.php @@ -1115,14 +1115,14 @@ class rcube_ldap extends rcube_addressbook $dn = self::dn_decode($dn); if ($rec = $this->ldap->get_entry($dn, $this->prop['attributes'])) { - $rec = array_change_key_case($rec, CASE_LOWER); + $rec = array_change_key_case($rec, \CASE_LOWER); } // Use ldap_list to get subentries like country (c) attribute (#1488123) if (!empty($rec) && $this->sub_filter) { if ($entries = $this->ldap->list_entries($dn, $this->sub_filter, array_keys($this->prop['sub_fields']))) { foreach ($entries as $entry) { - $lrec = array_change_key_case($entry, CASE_LOWER); + $lrec = array_change_key_case($entry, \CASE_LOWER); $rec = array_merge($lrec, $rec); } } @@ -2003,7 +2003,7 @@ class rcube_ldap extends rcube_addressbook } // when using VLV the list of groups is already sorted else { - array_multisort($group_sortnames, SORT_ASC, SORT_STRING, $groups); + array_multisort($group_sortnames, \SORT_ASC, \SORT_STRING, $groups); } // cache this @@ -2315,7 +2315,7 @@ class rcube_ldap extends rcube_addressbook */ static function dn_decode($str) { - $str = str_pad(strtr($str, '-_', '+/'), strlen($str) % 4, '=', STR_PAD_RIGHT); + $str = str_pad(strtr($str, '-_', '+/'), strlen($str) % 4, '=', \STR_PAD_RIGHT); return base64_decode($str); } } diff --git a/program/lib/Roundcube/rcube_ldap_generic.php b/program/lib/Roundcube/rcube_ldap_generic.php index 9e3d2bf3f..9f8562eba 100644 --- a/program/lib/Roundcube/rcube_ldap_generic.php +++ b/program/lib/Roundcube/rcube_ldap_generic.php @@ -63,22 +63,22 @@ class rcube_ldap_generic extends Net_LDAP3 $msg = implode("\n", $msg); switch ($level) { - case LOG_DEBUG: - case LOG_INFO: - case LOG_NOTICE: + case \LOG_DEBUG: + case \LOG_INFO: + case \LOG_NOTICE: if (!empty($this->config['debug'])) { rcube::write_log('ldap', $msg); } break; - case LOG_EMERG: - case LOG_ALERT: - case LOG_CRIT: + case \LOG_EMERG: + case \LOG_ALERT: + case \LOG_CRIT: rcube::raise_error($msg, true, true); break; - case LOG_ERR: - case LOG_WARNING: + case \LOG_ERR: + case \LOG_WARNING: $this->error = $msg; rcube::raise_error($msg, true, false); break; diff --git a/program/lib/Roundcube/rcube_message.php b/program/lib/Roundcube/rcube_message.php index 5895e0522..1237bc4a7 100644 --- a/program/lib/Roundcube/rcube_message.php +++ b/program/lib/Roundcube/rcube_message.php @@ -1158,10 +1158,10 @@ class rcube_message $uu_regexp_begin = '/begin [0-7]{3,4} ([^\r\n]+)\r?\n/s'; $uu_regexp_end = '/`\r?\nend((\r?\n)|($))/s'; - while (preg_match($uu_regexp_begin, $part->body, $matches, PREG_OFFSET_CAPTURE)) { + while (preg_match($uu_regexp_begin, $part->body, $matches, \PREG_OFFSET_CAPTURE)) { $startpos = $matches[0][1]; - if (!preg_match($uu_regexp_end, $part->body, $m, PREG_OFFSET_CAPTURE, $startpos)) { + if (!preg_match($uu_regexp_end, $part->body, $m, \PREG_OFFSET_CAPTURE, $startpos)) { break; } diff --git a/program/lib/Roundcube/rcube_mime.php b/program/lib/Roundcube/rcube_mime.php index 50532a7c7..1e68f06c7 100644 --- a/program/lib/Roundcube/rcube_mime.php +++ b/program/lib/Roundcube/rcube_mime.php @@ -175,7 +175,7 @@ class rcube_mime $re = '/=\?([^?]+)\?([BbQq])\?([^\n]*?)\?=/'; // Find all RFC2047's encoded words - if (preg_match_all($re, $input, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { + if (preg_match_all($re, $input, $matches, \PREG_OFFSET_CAPTURE | \PREG_SET_ORDER)) { // Initialize variables $tmp = []; $out = ''; @@ -753,15 +753,15 @@ class rcube_mime // null as a 2nd argument should be the same as no argument // this however is not true on all systems/versions if ($mime_magic) { - $finfo = finfo_open(FILEINFO_MIME, $mime_magic); + $finfo = finfo_open(\FILEINFO_MIME, $mime_magic); } else { - $finfo = finfo_open(FILEINFO_MIME); + $finfo = finfo_open(\FILEINFO_MIME); } if ($finfo) { $func = $is_stream ? 'finfo_buffer' : 'finfo_file'; - $mime_type = $func($finfo, $path, FILEINFO_MIME_TYPE); + $mime_type = $func($finfo, $path, \FILEINFO_MIME_TYPE); finfo_close($finfo); } } @@ -798,7 +798,7 @@ class rcube_mime // use file name suffix with hard-coded mime-type map if (!empty($mime_ext) && $filename) { - $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); + $ext = strtolower(pathinfo($filename, \PATHINFO_EXTENSION)); if ($ext && !empty($mime_ext[$ext])) { return $mime_ext[$ext]; } @@ -830,7 +830,7 @@ class rcube_mime } // try common locations - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { + if (strtoupper(substr(\PHP_OS, 0, 3)) == 'WIN') { $file_paths[] = 'C:/xampp/apache/conf/mime.types'; } else { @@ -852,7 +852,7 @@ class rcube_mime foreach ($file_paths as $fp) { if (@is_readable($fp)) { - $lines = file($fp, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); + $lines = file($fp, \FILE_IGNORE_NEW_LINES | \FILE_SKIP_EMPTY_LINES); break; } } diff --git a/program/lib/Roundcube/rcube_output.php b/program/lib/Roundcube/rcube_output.php index a91d89c89..63ec81b2d 100644 --- a/program/lib/Roundcube/rcube_output.php +++ b/program/lib/Roundcube/rcube_output.php @@ -294,7 +294,7 @@ abstract class rcube_output public function raise_error($code, $message) { // STUB: to be overloaded by specific output classes - fwrite(STDERR, "Error $code: $message\n"); + fwrite(\STDERR, "Error $code: $message\n"); exit(-1); } @@ -374,16 +374,16 @@ abstract class rcube_output */ public static function json_serialize($input, $pretty = false, $inline = true) { - $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_IGNORE; + $options = \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_INVALID_UTF8_IGNORE; // JSON_HEX_TAG is needed for inlining JSON inside of the