diff options
Diffstat (limited to 'phpBB/includes')
29 files changed, 145 insertions, 414 deletions
diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 74df9240a1..1811748c2f 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -410,7 +410,7 @@ class acp_board 'ip_check' => array('lang' => 'IP_VALID', 'validate' => 'int', 'type' => 'custom', 'method' => 'select_ip_check', 'explain' => true), 'browser_check' => array('lang' => 'BROWSER_VALID', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'forwarded_for_check' => array('lang' => 'FORWARDED_FOR_VALID', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'referer_validation' => array('lang' => 'REFERER_VALID', 'validate' => 'int:0:3','type' => 'custom', 'method' => 'select_ref_check', 'explain' => true), + 'referer_validation' => array('lang' => 'REFERRER_VALID', 'validate' => 'int:0:3','type' => 'custom', 'method' => 'select_ref_check', 'explain' => true), 'check_dnsbl' => array('lang' => 'CHECK_DNSBL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'email_check_mx' => array('lang' => 'EMAIL_CHECK_MX', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'max_pass_chars' => array('lang' => 'PASSWORD_LENGTH', 'validate' => 'int:8:255', 'type' => false, 'method' => false, 'explain' => false,), diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php index 76da43341d..8f9c155ffc 100644 --- a/phpBB/includes/acp/acp_database.php +++ b/phpBB/includes/acp/acp_database.php @@ -90,7 +90,7 @@ class acp_database $time = time(); $filename = 'backup_' . $time . '_' . unique_id(); - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'mysqli': case 'mysql4': @@ -133,7 +133,7 @@ class acp_database else { // We might wanna empty out all that junk :D - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'sqlite': case 'sqlite3': @@ -320,7 +320,7 @@ class acp_database break; } - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'mysql': case 'mysql4': @@ -365,10 +365,10 @@ class acp_database { trigger_error($user->lang['RESTORE_FAILURE'] . adm_back_link($this->u_action), E_USER_WARNING); } - pg_put_line($db->db_connect_id, $sub . "\n"); + pg_put_line($db->get_db_connect_id(), $sub . "\n"); } - pg_put_line($db->db_connect_id, "\\.\n"); - pg_end_copy($db->db_connect_id); + pg_put_line($db->get_db_connect_id(), "\\.\n"); + pg_end_copy($db->get_db_connect_id()); } } break; @@ -623,7 +623,7 @@ class mysql_extractor extends base_extractor if ($new_extract === null) { - if ($db->sql_layer === 'mysqli' || version_compare($db->sql_server_info(true), '3.23.20', '>=')) + if ($db->get_sql_layer() === 'mysqli' || version_compare($db->sql_server_info(true), '3.23.20', '>=')) { $new_extract = true; } @@ -646,7 +646,7 @@ class mysql_extractor extends base_extractor function write_data($table_name) { global $db; - if ($db->sql_layer === 'mysqli') + if ($db->get_sql_layer() === 'mysqli') { $this->write_data_mysqli($table_name); } @@ -661,7 +661,7 @@ class mysql_extractor extends base_extractor global $db; $sql = "SELECT * FROM $table_name"; - $result = mysqli_query($db->db_connect_id, $sql, MYSQLI_USE_RESULT); + $result = mysqli_query($db->get_db_connect_id(), $sql, MYSQLI_USE_RESULT); if ($result != false) { $fields_cnt = mysqli_num_fields($result); @@ -740,7 +740,7 @@ class mysql_extractor extends base_extractor global $db; $sql = "SELECT * FROM $table_name"; - $result = mysql_unbuffered_query($sql, $db->db_connect_id); + $result = mysql_unbuffered_query($sql, $db->get_db_connect_id()); if ($result != false) { @@ -993,11 +993,11 @@ class sqlite_extractor extends base_extractor { global $db; - $col_types = sqlite_fetch_column_types($db->db_connect_id, $table_name); + $col_types = sqlite_fetch_column_types($db->get_db_connect_id(), $table_name); $sql = "SELECT * FROM $table_name"; - $result = sqlite_unbuffered_query($db->db_connect_id, $sql); + $result = sqlite_unbuffered_query($db->get_db_connect_id(), $sql); $rows = sqlite_fetch_all($result, SQLITE_ASSOC); $sql_insert = 'INSERT INTO ' . $table_name . ' (' . implode(', ', array_keys($col_types)) . ') VALUES ('; foreach ($rows as $row) @@ -1553,11 +1553,11 @@ class mssql_extractor extends base_extractor { global $db; - if ($db->sql_layer === 'mssql') + if ($db->get_sql_layer() === 'mssql') { $this->write_data_mssql($table_name); } - else if($db->sql_layer === 'mssqlnative') + else if($db->get_sql_layer() === 'mssqlnative') { $this->write_data_mssqlnative($table_name); } diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index b2a6820461..aba9caaece 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -137,7 +137,7 @@ class acp_extensions trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING); } - if ($phpbb_extension_manager->enabled($ext_name)) + if ($phpbb_extension_manager->is_enabled($ext_name)) { redirect($this->u_action); } @@ -162,7 +162,7 @@ class acp_extensions trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING); } - if ($phpbb_extension_manager->enabled($ext_name)) + if ($phpbb_extension_manager->is_enabled($ext_name)) { redirect($this->u_action); } @@ -194,7 +194,7 @@ class acp_extensions break; case 'disable_pre': - if (!$phpbb_extension_manager->enabled($ext_name)) + if (!$phpbb_extension_manager->is_enabled($ext_name)) { redirect($this->u_action); } @@ -209,7 +209,7 @@ class acp_extensions break; case 'disable': - if (!$phpbb_extension_manager->enabled($ext_name)) + if (!$phpbb_extension_manager->is_enabled($ext_name)) { redirect($this->u_action); } @@ -234,7 +234,7 @@ class acp_extensions break; case 'delete_data_pre': - if ($phpbb_extension_manager->enabled($ext_name)) + if ($phpbb_extension_manager->is_enabled($ext_name)) { redirect($this->u_action); } @@ -248,7 +248,7 @@ class acp_extensions break; case 'delete_data': - if ($phpbb_extension_manager->enabled($ext_name)) + if ($phpbb_extension_manager->is_enabled($ext_name)) { redirect($this->u_action); } diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index f8c463e158..adf5de44f5 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1827,7 +1827,7 @@ class acp_forums } $db->sql_freeresult($result); - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'mysql4': case 'mysqli': diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index b9a6ef17ce..028025b547 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -538,7 +538,7 @@ class acp_icons // The user has already selected a smilies_pak file if ($current == 'delete') { - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'sqlite': case 'sqlite3': diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 247460ec8e..0d0d49774c 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -269,7 +269,7 @@ class acp_main break; case 'db_track': - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'sqlite': case 'sqlite3': @@ -374,7 +374,7 @@ class acp_main foreach ($tables as $table) { - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'sqlite': case 'sqlite3': diff --git a/phpBB/includes/acp/acp_permission_roles.php b/phpBB/includes/acp/acp_permission_roles.php index 9715b9bce8..cd3616208d 100644 --- a/phpBB/includes/acp/acp_permission_roles.php +++ b/phpBB/includes/acp/acp_permission_roles.php @@ -253,7 +253,7 @@ class acp_permission_roles { $sql = 'SELECT auth_option_id, auth_option FROM ' . ACL_OPTIONS_TABLE . " - WHERE auth_option " . $db->sql_like_expression($permission_type . $db->any_char) . " + WHERE auth_option " . $db->sql_like_expression($permission_type . $db->get_any_char()) . " AND auth_option <> '{$permission_type}' ORDER BY auth_option_id"; $result = $db->sql_query($sql); @@ -315,7 +315,7 @@ class acp_permission_roles // We need to fill the auth options array with ACL_NO options ;) $sql = 'SELECT auth_option_id, auth_option FROM ' . ACL_OPTIONS_TABLE . " - WHERE auth_option " . $db->sql_like_expression($permission_type . $db->any_char) . " + WHERE auth_option " . $db->sql_like_expression($permission_type . $db->get_any_char()) . " AND auth_option <> '{$permission_type}' ORDER BY auth_option_id"; $result = $db->sql_query($sql); @@ -519,7 +519,7 @@ class acp_permission_roles // Get complete auth array $sql = 'SELECT auth_option, auth_option_id FROM ' . ACL_OPTIONS_TABLE . " - WHERE auth_option " . $db->sql_like_expression($permission_type . $db->any_char); + WHERE auth_option " . $db->sql_like_expression($permission_type . $db->get_any_char()); $result = $db->sql_query($sql); $auth_settings = array(); diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php index 6540173433..cb408e304f 100644 --- a/phpBB/includes/acp/acp_permissions.php +++ b/phpBB/includes/acp/acp_permissions.php @@ -1238,7 +1238,7 @@ class acp_permissions $sql = 'SELECT auth_option_id FROM ' . ACL_OPTIONS_TABLE . ' - WHERE auth_option ' . $db->sql_like_expression($permission_type . $db->any_char); + WHERE auth_option ' . $db->sql_like_expression($permission_type . $db->get_any_char()); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index c291ee43c8..fda6ef25ec 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -112,7 +112,7 @@ class acp_profile $db->sql_query('DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " WHERE field_id = $field_id"); $db->sql_query('DELETE FROM ' . PROFILE_LANG_TABLE . " WHERE field_id = $field_id"); - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'sqlite': case 'sqlite3': @@ -1196,7 +1196,7 @@ class acp_profile { global $db; - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'mysql': case 'mysql4': diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php index 2ddda28afc..a10b248324 100644 --- a/phpBB/includes/acp/acp_prune.php +++ b/phpBB/includes/acp/acp_prune.php @@ -436,8 +436,8 @@ class acp_prune $sort_by_types = array('username', 'user_email', 'user_posts', 'user_regdate', 'user_lastvisit'); $where_sql = ''; - $where_sql .= ($username) ? ' AND username_clean ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($username))) : ''; - $where_sql .= ($email) ? ' AND user_email ' . $db->sql_like_expression(str_replace('*', $db->any_char, $email)) . ' ' : ''; + $where_sql .= ($username) ? ' AND username_clean ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($username))) : ''; + $where_sql .= ($email) ? ' AND user_email ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), $email)) . ' ' : ''; $where_sql .= $joined_sql; $where_sql .= ($count) ? " AND user_posts " . $key_match[$count_select] . ' ' . (int) $count . ' ' : ''; diff --git a/phpBB/includes/acp/acp_reasons.php b/phpBB/includes/acp/acp_reasons.php index 9cb5efdbe0..3d7ccf422c 100644 --- a/phpBB/includes/acp/acp_reasons.php +++ b/phpBB/includes/acp/acp_reasons.php @@ -219,7 +219,7 @@ class acp_reasons $other_reason_id = (int) $db->sql_fetchfield('reason_id'); $db->sql_freeresult($result); - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { // The ugly one! case 'mysqli': diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index d07120a65f..71880c2267 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -2384,7 +2384,7 @@ class acp_users // Select auth options $sql = 'SELECT auth_option, is_local, is_global FROM ' . ACL_OPTIONS_TABLE . ' - WHERE auth_option ' . $db->sql_like_expression($db->any_char . '_') . ' + WHERE auth_option ' . $db->sql_like_expression($db->get_any_char() . '_') . ' AND is_global = 1 ORDER BY auth_option'; $result = $db->sql_query($sql); @@ -2404,7 +2404,7 @@ class acp_users { $sql = 'SELECT auth_option, is_local, is_global FROM ' . ACL_OPTIONS_TABLE . " - WHERE auth_option " . $db->sql_like_expression($db->any_char . '_') . " + WHERE auth_option " . $db->sql_like_expression($db->get_any_char() . '_') . " AND is_local = 1 ORDER BY is_global DESC, auth_option"; $result = $db->sql_query($sql); diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php index 7bb8e824d6..7ff3212b72 100644 --- a/phpBB/includes/acp/auth.php +++ b/phpBB/includes/acp/auth.php @@ -1024,7 +1024,7 @@ class auth_admin extends \phpbb\auth\auth // Get permission type $sql = 'SELECT auth_option, auth_option_id FROM ' . ACL_OPTIONS_TABLE . " - WHERE auth_option " . $db->sql_like_expression($permission_type . $db->any_char); + WHERE auth_option " . $db->sql_like_expression($permission_type . $db->get_any_char()); $result = $db->sql_query($sql); $auth_id_ary = array(); diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 2287639aee..cd4e19bf1d 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -28,7 +28,7 @@ if (!defined('IN_PHPBB')) */ // phpBB Version -define('PHPBB_VERSION', '3.1.0-RC2-dev'); +define('PHPBB_VERSION', '3.1.0-RC3-dev'); // QA-related // define('PHPBB_QA', 1); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 32acb0c9ff..8b9969aced 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -21,6 +21,37 @@ if (!defined('IN_PHPBB')) // Common global functions /** +* Load the autoloaders added by the extensions. +* +* @param string $phpbb_root_path Path to the phpbb root directory. +*/ +function phpbb_load_extensions_autoloaders($phpbb_root_path) +{ + $iterator = new \RecursiveIteratorIterator( + new \phpbb\recursive_dot_prefix_filter_iterator( + new \RecursiveDirectoryIterator( + $phpbb_root_path . 'ext/', + \FilesystemIterator::SKIP_DOTS + ) + ), + \RecursiveIteratorIterator::SELF_FIRST + ); + $iterator->setMaxDepth(2); + + foreach ($iterator as $file_info) + { + if ($file_info->getFilename() === 'vendor' && $iterator->getDepth() === 2) + { + $filename = $file_info->getRealPath() . '/autoload.php'; + if (file_exists($filename)) + { + require $filename; + } + } + } +} + +/** * Casts a variable to the given type. * * @deprecated @@ -3998,7 +4029,7 @@ function obtain_guest_count($item_id = 0, $item = 'forum') // Get number of online guests - if ($db->sql_layer === 'sqlite' || $db->sql_layer === 'sqlite3') + if ($db->get_sql_layer() === 'sqlite' || $db->get_sql_layer() === 'sqlite3') { $sql = 'SELECT COUNT(session_ip) as num_guests FROM ( @@ -4881,6 +4912,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id = 'PRIVATE_MESSAGE_COUNT' => (!empty($user->data['user_unread_privmsg'])) ? $user->data['user_unread_privmsg'] : 0, 'CURRENT_USER_AVATAR' => phpbb_get_user_avatar($user->data), + 'CURRENT_USERNAME_SIMPLE' => get_username_string('no_profile', $user->data['user_id'], $user->data['username'], $user->data['user_colour']), 'CURRENT_USERNAME_FULL' => get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour']), 'UNREAD_NOTIFICATIONS_COUNT' => ($notifications !== false) ? $notifications['unread_count'] : '', 'NOTIFICATIONS_COUNT' => ($notifications !== false) ? $notifications['unread_count'] : '', @@ -4923,7 +4955,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id = 'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'), 'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'), - 'U_CONTACT_US' => ($config['contact_admin_form_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin') : '', + 'U_CONTACT_US' => ($config['contact_admin_form_enable'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin') : '', 'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=team'), 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'), 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), @@ -5064,7 +5096,7 @@ function phpbb_generate_debug_output(phpbb\db\driver\driver_interface $db, \phpb if (isset($GLOBALS['starttime'])) { $totaltime = microtime(true) - $GLOBALS['starttime']; - $debug_info[] = sprintf('<abbr title="SQL time: %.3fs / PHP time: %.3fs">Time: %.3fs</abbr>', $db->sql_time, ($totaltime - $db->sql_time), $totaltime); + $debug_info[] = sprintf('<abbr title="SQL time: %.3fs / PHP time: %.3fs">Time: %.3fs</abbr>', $db->get_sql_time(), ($totaltime - $db->get_sql_time()), $totaltime); } $debug_info[] = sprintf('<abbr title="Cached: %d">Queries: %d</abbr>', $db->sql_num_queries(true), $db->sql_num_queries()); @@ -5295,52 +5327,6 @@ function phpbb_to_numeric($input) } /** -* Convert either 3.0 dbms or 3.1 db driver class name to 3.1 db driver class name. -* -* If $dbms is a valid 3.1 db driver class name, returns it unchanged. -* Otherwise prepends phpbb\db\driver\ to the dbms to convert a 3.0 dbms -* to 3.1 db driver class name. -* -* @param string $dbms dbms parameter -* @return db driver class -*/ -function phpbb_convert_30_dbms_to_31($dbms) -{ - // Note: this check is done first because mysqli extension - // supplies a mysqli class, and class_exists($dbms) would return - // true for mysqli class. - // However, per the docblock any valid 3.1 driver name should be - // recognized by this function, and have priority over 3.0 dbms. - if (strpos($dbms, 'phpbb\db\driver') === false && class_exists('phpbb\db\driver\\' . $dbms)) - { - return 'phpbb\db\driver\\' . $dbms; - } - - if (class_exists($dbms)) - { - // Additionally we could check that $dbms extends phpbb\db\driver\driver. - // http://php.net/manual/en/class.reflectionclass.php - // Beware of possible performance issues: - // http://stackoverflow.com/questions/294582/php-5-reflection-api-performance - // We could check for interface implementation in all paths or - // only when we do not prepend phpbb\db\driver\. - - /* - $reflection = new \ReflectionClass($dbms); - - if ($reflection->isSubclassOf('phpbb\db\driver\driver')) - { - return $dbms; - } - */ - - return $dbms; - } - - throw new \RuntimeException("You have specified an invalid dbms driver: $dbms"); -} - -/** * Get the board contact details (e.g. for emails) * * @param \phpbb\config\config $config @@ -5369,7 +5355,7 @@ function phpbb_get_board_contact(\phpbb\config\config $config, $phpEx) */ function phpbb_get_board_contact_link(\phpbb\config\config $config, $phpbb_root_path, $phpEx) { - if ($config['contact_admin_form_enable']) + if ($config['contact_admin_form_enable'] && $config['email_enable']) { return append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin'); } diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 6bf8ce2c81..accc8a6a83 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1435,7 +1435,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, { case 'topic_moved': $db->sql_transaction('begin'); - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'mysql4': case 'mysqli': @@ -2441,7 +2441,7 @@ function phpbb_cache_moderators($db, $cache, $auth) $cache->destroy('sql', MODERATOR_CACHE_TABLE); // Clear table - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'sqlite': case 'sqlite3': @@ -2491,7 +2491,7 @@ function phpbb_cache_moderators($db, $cache, $auth) AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) AND ' . $db->sql_in_set('ug.user_id', $ug_id_ary) . " AND ug.user_pending = 0 - AND o.auth_option " . $db->sql_like_expression('m_' . $db->any_char), + AND o.auth_option " . $db->sql_like_expression('m_' . $db->get_any_char()), ); $sql = $db->sql_build_query('SELECT', $sql_ary_deny); $result = $db->sql_query($sql); @@ -2697,11 +2697,11 @@ function phpbb_update_foes($db, $auth, $group_id = false, $user_id = false) return; } - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'mysqli': case 'mysql4': - $sql = 'DELETE ' . (($db->sql_layer === 'mysqli' || version_compare($db->sql_server_info(true), '4.1', '>=')) ? 'z.*' : ZEBRA_TABLE) . ' + $sql = 'DELETE ' . (($db->get_sql_layer() === 'mysqli' || version_compare($db->sql_server_info(true), '4.1', '>=')) ? 'z.*' : ZEBRA_TABLE) . ' FROM ' . ZEBRA_TABLE . ' z, ' . USER_GROUP_TABLE . ' ug WHERE z.zebra_id = ug.user_id AND z.foe = 1 @@ -2854,7 +2854,7 @@ function get_database_size() $database_size = false; // This code is heavily influenced by a similar routine in phpMyAdmin 2.2.0 - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'mysql': case 'mysql4': @@ -2870,7 +2870,7 @@ function get_database_size() if (preg_match('#(3\.23|[45]\.)#', $version)) { - $db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.#', $version)) ? "`{$db->dbname}`" : $db->dbname; + $db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.#', $version)) ? "`{$db->get_db_name()}`" : $db->get_db_name(); $sql = 'SHOW TABLE STATUS FROM ' . $db_name; @@ -2946,7 +2946,7 @@ function get_database_size() if ($row['proname'] == 'pg_database_size') { - $database = $db->dbname; + $database = $db->get_db_name(); if (strpos($database, '.') !== false) { list($database, ) = explode('.', $database); diff --git a/phpBB/includes/functions_container.php b/phpBB/includes/functions_container.php deleted file mode 100644 index 5794d2f403..0000000000 --- a/phpBB/includes/functions_container.php +++ /dev/null @@ -1,291 +0,0 @@ -<?php -/** -* -* This file is part of the phpBB Forum Software package. -* -* @copyright (c) phpBB Limited <https://www.phpbb.com> -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Dumper\PhpDumper; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Get DB connection from config.php. -* -* Used to bootstrap the container. -* -* @param string $config_file -* @return \phpbb\db\driver\driver_interface -*/ -function phpbb_bootstrap_db_connection($config_file) -{ - require($config_file); - $dbal_driver_class = phpbb_convert_30_dbms_to_31($dbms); - - $db = new $dbal_driver_class(); - $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, defined('PHPBB_DB_NEW_LINK')); - - return $db; -} - -/** -* Get table prefix from config.php. -* -* Used to bootstrap the container. -* -* @param string $config_file -* @return string table prefix -*/ -function phpbb_bootstrap_table_prefix($config_file) -{ - require($config_file); - return $table_prefix; -} - -/** -* Get enabled extensions. -* -* Used to bootstrap the container. -* -* @param string $config_file -* @param string $phpbb_root_path -* @return array enabled extensions -*/ -function phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path) -{ - $db = phpbb_bootstrap_db_connection($config_file); - $table_prefix = phpbb_bootstrap_table_prefix($config_file); - $extension_table = $table_prefix.'ext'; - - $sql = 'SELECT * - FROM ' . $extension_table . ' - WHERE ext_active = 1'; - - $result = $db->sql_query($sql); - $rows = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - $exts = array(); - foreach ($rows as $row) - { - $exts[$row['ext_name']] = $phpbb_root_path . 'ext/' . $row['ext_name'] . '/'; - } - - return $exts; -} - -/** -* Create the ContainerBuilder object -* -* @param array $extensions Array of Container extension objects -* @param string $phpbb_root_path Root path -* @param string $php_ext PHP Extension -* @return ContainerBuilder object -*/ -function phpbb_create_container(array $extensions, $phpbb_root_path, $php_ext) -{ - $container = new ContainerBuilder(); - - foreach ($extensions as $extension) - { - $container->registerExtension($extension); - $container->loadFromExtension($extension->getAlias()); - } - - $container->setParameter('core.root_path', $phpbb_root_path); - $container->setParameter('core.php_ext', $php_ext); - - return $container; -} - -/** -* Create installer container -* -* @param string $phpbb_root_path Root path -* @param string $php_ext PHP Extension -* @return ContainerBuilder object -*/ -function phpbb_create_install_container($phpbb_root_path, $php_ext) -{ - $other_config_path = $phpbb_root_path . 'install/update/new/config/'; - $config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config/'; - - $core = new \phpbb\di\extension\core($config_path); - $container = phpbb_create_container(array($core), $phpbb_root_path, $php_ext); - - $container->setParameter('core.root_path', $phpbb_root_path); - $container->setParameter('core.adm_relative_path', $phpbb_adm_relative_path); - $container->setParameter('core.php_ext', $php_ext); - $container->setParameter('core.table_prefix', ''); - - $container->register('dbal.conn')->setSynthetic(true); - - $container->setAlias('cache.driver', 'cache.driver.install'); - - $container->compile(); - - return $container; -} - -/** -* Create updater container -* -* @param string $phpbb_root_path Root path -* @param string $php_ext PHP Extension -* @param array $config_path Path to config directory -* @return ContainerBuilder object (compiled) -*/ -function phpbb_create_update_container($phpbb_root_path, $php_ext, $config_path) -{ - $config_file = $phpbb_root_path . 'config.' . $php_ext; - return phpbb_create_compiled_container( - $config_file, - array( - new phpbb\di\extension\config($config_file), - new phpbb\di\extension\core($config_path), - ), - array( - new phpbb\di\pass\collection_pass(), - new phpbb\di\pass\kernel_pass(), - ), - $phpbb_root_path, - $php_ext - ); -} - -/** -* Create a compiled ContainerBuilder object -* -* @param array $extensions Array of Container extension objects -* @param array $passes Array of Compiler Pass objects -* @param string $phpbb_root_path Root path -* @param string $php_ext PHP Extension -* @return ContainerBuilder object (compiled) -*/ -function phpbb_create_compiled_container($config_file, array $extensions, array $passes, $phpbb_root_path, $php_ext) -{ - // Create the final container to be compiled and cached - $container = phpbb_create_container($extensions, $phpbb_root_path, $php_ext); - - // Compile the container - foreach ($passes as $pass) - { - $container->addCompilerPass($pass); - } - $container->compile(); - - return $container; -} - -/** -* Create a compiled and dumped ContainerBuilder object -* -* @param array $extensions Array of Container extension objects -* @param array $passes Array of Compiler Pass objects -* @param string $phpbb_root_path Root path -* @param string $php_ext PHP Extension -* @return ContainerBuilder object (compiled) -*/ -function phpbb_create_dumped_container($config_file, array $extensions, array $passes, $phpbb_root_path, $php_ext) -{ - // Check for our cached container; if it exists, use it - $container_filename = phpbb_container_filename($phpbb_root_path, $php_ext); - if (file_exists($container_filename)) - { - require($container_filename); - return new phpbb_cache_container(); - } - - $container = phpbb_create_compiled_container($config_file, $extensions, $passes, $phpbb_root_path, $php_ext); - - // Lastly, we create our cached container class - $dumper = new PhpDumper($container); - $cached_container_dump = $dumper->dump(array( - 'class' => 'phpbb_cache_container', - 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder', - )); - - file_put_contents($container_filename, $cached_container_dump); - - return $container; -} - -/** -* Create an environment-specific ContainerBuilder object -* -* If debug is enabled, the container is re-compiled every time. -* This ensures that the latest changes will always be reflected -* during development. -* -* Otherwise it will get the existing dumped container and use -* that one instead. -* -* @param array $extensions Array of Container extension objects -* @param array $passes Array of Compiler Pass objects -* @param string $phpbb_root_path Root path -* @param string $php_ext PHP Extension -* @return ContainerBuilder object (compiled) -*/ -function phpbb_create_dumped_container_unless_debug($config_file, array $extensions, array $passes, $phpbb_root_path, $php_ext) -{ - $container_factory = defined('DEBUG_CONTAINER') ? 'phpbb_create_compiled_container' : 'phpbb_create_dumped_container'; - return $container_factory($config_file, $extensions, $passes, $phpbb_root_path, $php_ext); -} - -/** -* Create a default ContainerBuilder object -* -* Contains the default configuration of the phpBB container. -* -* @param array $extensions Array of Container extension objects -* @param array $passes Array of Compiler Pass objects -* @return ContainerBuilder object (compiled) -*/ -function phpbb_create_default_container($phpbb_root_path, $php_ext) -{ - $config_file = $phpbb_root_path . 'config.' . $php_ext; - $installed_exts = phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path); - - return phpbb_create_dumped_container_unless_debug( - $config_file, - array( - new \phpbb\di\extension\config($config_file), - new \phpbb\di\extension\core($phpbb_root_path . 'config'), - new \phpbb\di\extension\ext($installed_exts), - ), - array( - new \phpbb\di\pass\collection_pass(), - new \phpbb\di\pass\kernel_pass(), - ), - $phpbb_root_path, - $php_ext - ); -} - -/** -* Get the filename under which the dumped container will be stored. -* -* @param string $phpbb_root_path Root path -* @param string $php_ext PHP Extension -* @return Path for dumped container -*/ -function phpbb_container_filename($phpbb_root_path, $php_ext) -{ - $filename = str_replace(array('/', '.'), array('slash', 'dot'), $phpbb_root_path); - return $phpbb_root_path . 'cache/container_' . $filename . '.' . $php_ext; -} diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 74b3e0c70f..ee78364083 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -174,8 +174,9 @@ function make_jumpbox($action, $forum_id = false, $select_all = false, $acl_list $template->assign_block_vars('jumpbox_forums', array( 'FORUM_ID' => ($select_all) ? 0 : -1, 'FORUM_NAME' => ($select_all) ? $user->lang['ALL_FORUMS'] : $user->lang['SELECT_FORUM'], - 'S_FORUM_COUNT' => $iteration) - ); + 'S_FORUM_COUNT' => $iteration, + 'LINK' => $phpbb_path_helper->append_url_params($action, array('f' => $forum_id)), + )); $iteration++; $display_jumpbox = true; @@ -188,8 +189,9 @@ function make_jumpbox($action, $forum_id = false, $select_all = false, $acl_list 'S_FORUM_COUNT' => $iteration, 'S_IS_CAT' => ($row['forum_type'] == FORUM_CAT) ? true : false, 'S_IS_LINK' => ($row['forum_type'] == FORUM_LINK) ? true : false, - 'S_IS_POST' => ($row['forum_type'] == FORUM_POST) ? true : false) - ); + 'S_IS_POST' => ($row['forum_type'] == FORUM_POST) ? true : false, + 'LINK' => $phpbb_path_helper->append_url_params($action, array('f' => $row['forum_id'])), + )); for ($i = 0; $i < $padding; $i++) { @@ -1334,9 +1336,9 @@ function get_username_string($mode, $user_id, $username, $username_colour = '', global $phpbb_root_path, $phpEx; $_profile_cache['base_url'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u={USER_ID}'); - $_profile_cache['tpl_noprofile'] = '{USERNAME}'; + $_profile_cache['tpl_noprofile'] = '<span class="username">{USERNAME}</span>'; $_profile_cache['tpl_noprofile_colour'] = '<span style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</span>'; - $_profile_cache['tpl_profile'] = '<a href="{PROFILE_URL}">{USERNAME}</a>'; + $_profile_cache['tpl_profile'] = '<a href="{PROFILE_URL}" class="username">{USERNAME}</a>'; $_profile_cache['tpl_profile_colour'] = '<a href="{PROFILE_URL}" style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</a>'; } @@ -1452,16 +1454,19 @@ function get_username_string($mode, $user_id, $username, $username_colour = '', /** * Add an option to the quick-mod tools. * + * @param string $url The recepting URL for the quickmod actions. * @param string $option The language key for the value of the option. * @param string $lang_string The language string to use. */ -function phpbb_add_quickmod_option($option, $lang_string) +function phpbb_add_quickmod_option($url, $option, $lang_string) { - global $template, $user; + global $template, $user, $phpbb_path_helper; + $lang_string = $user->lang($lang_string); $template->assign_block_vars('quickmod', array( - 'VALUE' => $option, - 'TITLE' => $lang_string, + 'VALUE' => $option, + 'TITLE' => $lang_string, + 'LINK' => $phpbb_path_helper->append_url_params($url, array('action' => $option)), )); } diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php index 864a43c6e7..9d480692e9 100644 --- a/phpBB/includes/functions_convert.php +++ b/phpBB/includes/functions_convert.php @@ -1647,7 +1647,7 @@ function mass_auth($ug_type, $forum_id, $ug_id, $acl_list, $setting = ACL_NO) switch ($sql_type) { case 'insert': - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'mysql': case 'mysql4': @@ -2041,7 +2041,7 @@ function update_topics_posted() { global $db, $config; - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'sqlite': case 'sqlite3': diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 5836d8816d..68b1356297 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -622,7 +622,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod 'L_SUBFORUM' => ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'], 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPICS_UNAPPROVED'), - 'UNAPPROVED_POST_IMG' => $user->img('icon_topic_unapproved', 'POSTS_UNAPPROVED'), + 'UNAPPROVED_POST_IMG' => $user->img('icon_topic_unapproved', 'POSTS_UNAPPROVED_FORUM'), )); if ($return_moderators) diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index b5d1573d12..06f49e4b50 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -290,7 +290,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, switch ($dbms_details['DRIVER']) { case 'phpbb\db\driver\mysqli': - if (version_compare(mysqli_get_server_info($db->db_connect_id), '4.1.3', '<')) + if (version_compare(mysqli_get_server_info($db->get_db_connect_id()), '4.1.3', '<')) { $error[] = $lang['INST_ERR_DB_NO_MYSQLI']; } diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index d11193e4b0..d39be50251 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1137,7 +1137,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas // Update log $log_entry = ($ban_exclude) ? 'LOG_BAN_EXCLUDE_' : 'LOG_BAN_'; - // Add to moderator log, admin log and user notes + // Add to admin log, moderator log and user notes add_log('admin', $log_entry . strtoupper($mode), $ban_reason, $ban_list_log); add_log('mod', 0, 0, $log_entry . strtoupper($mode), $ban_reason, $ban_list_log); if ($mode == 'user') diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php index 2945e1ec8a..92dcdb5499 100644 --- a/phpBB/includes/mcp/mcp_logs.php +++ b/phpBB/includes/mcp/mcp_logs.php @@ -115,7 +115,7 @@ class mcp_logs if ($deletemark && sizeof($marked)) { $conditions = array( - 'forum_id' => $forum_list, + 'forum_id' => array('IN' => $forum_list), 'log_id' => array('IN' => $marked), ); @@ -126,7 +126,7 @@ class mcp_logs $keywords = utf8_normalize_nfc(request_var('keywords', '', true)); $conditions = array( - 'forum_id' => $forum_list, + 'forum_id' => array('IN' => $forum_list), 'keywords' => $keywords, ); diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php index e81abd0c8e..1687409198 100644 --- a/phpBB/includes/mcp/mcp_post.php +++ b/phpBB/includes/mcp/mcp_post.php @@ -151,6 +151,7 @@ function mcp_post_details($id, $mode, $action) if (sizeof($attachments)) { + $user->add_lang('viewtopic'); $update_count = array(); parse_attachments($post_info['forum_id'], $message, $attachments, $update_count); } diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 8d926ec70a..da27d8900d 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -1350,7 +1350,7 @@ class parse_message extends bbcode_firstpass // NOTE: obtain_* function? chaching the table contents? // For now setting the ttl to 10 minutes - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'mssql': case 'mssql_odbc': diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php index b4b01a74bf..63ea432863 100644 --- a/phpBB/includes/questionnaire/questionnaire.php +++ b/phpBB/includes/questionnaire/questionnaire.php @@ -257,11 +257,12 @@ class phpbb_questionnaire_phpbb_data_provider */ function get_data() { - global $phpbb_root_path, $phpEx; - include("{$phpbb_root_path}config.$phpEx"); + global $phpbb_root_path, $phpEx, $phpbb_config_php_file; + + extract($phpbb_config_php_file->get_all()); unset($dbhost, $dbport, $dbname, $dbuser, $dbpasswd); // Just a precaution - $dbms = phpbb_convert_30_dbms_to_31($dbms); + $dbms = $phpbb_config_php_file->convert_30_dbms_to_31($dbms); // Only send certain config vars $config_vars = array( diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index fc568abc68..94383b935f 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -85,7 +85,16 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) // Editing information if ($message_row['message_edit_count'] && $config['display_last_edited']) { - $l_edited_by = '<br /><br />' . $user->lang('EDITED_TIMES_TOTAL', (int) $message_row['message_edit_count'], (!$message_row['message_edit_user']) ? $message_row['username'] : $message_row['message_edit_user'], $user->format_date($message_row['message_edit_time'], false, true)); + if (!$message_row['message_edit_user']) + { + $display_username = get_username_string('full', $author_id, $user_info['username'], $user_info['user_colour']); + } + else + { + $edit_user_info = get_user_information($message_row['message_edit_user'], false); + $display_username = get_username_string('full', $message_row['message_edit_user'], $edit_user_info['username'], $edit_user_info['user_colour']); + } + $l_edited_by = '<br /><br />' . $user->lang('EDITED_TIMES_TOTAL', (int) $message_row['message_edit_count'], $display_username, $user->format_date($message_row['message_edit_time'], false, true)); } else { @@ -204,6 +213,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) 'AUTHOR_AVATAR' => (isset($user_info['avatar'])) ? $user_info['avatar'] : '', 'AUTHOR_JOINED' => $user->format_date($user_info['user_regdate']), 'AUTHOR_POSTS' => (int) $user_info['user_posts'], + 'CONTACT_USER' => $user->lang('CONTACT_USER', get_username_string('username', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username'])), 'ONLINE_IMG' => (!$config['load_onlinetrack']) ? '' : ((isset($user_info['online']) && $user_info['online']) ? $user->img('icon_user_online', $user->lang['ONLINE']) : $user->img('icon_user_offline', $user->lang['OFFLINE'])), 'S_ONLINE' => (!$config['load_onlinetrack']) ? false : ((isset($user_info['online']) && $user_info['online']) ? true : false), diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index 35bb844170..df1e722fa4 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -115,7 +115,7 @@ class ucp_prefs * * @event core.ucp_prefs_personal_update_data * @var array data Submitted display options data - * @var array sql_ary Display options data we udpate + * @var array sql_ary Display options data we update * @since 3.1.0-a1 */ $vars = array('data', 'sql_ary'); @@ -294,7 +294,7 @@ class ucp_prefs * * @event core.ucp_prefs_view_update_data * @var array data Submitted display options data - * @var array sql_ary Display options data we udpate + * @var array sql_ary Display options data we update * @since 3.1.0-a1 */ $vars = array('data', 'sql_ary'); @@ -420,7 +420,7 @@ class ucp_prefs * * @event core.ucp_prefs_post_update_data * @var array data Submitted display options data - * @var array sql_ary Display options data we udpate + * @var array sql_ary Display options data we update * @since 3.1.0-a1 */ $vars = array('data', 'sql_ary'); @@ -451,6 +451,24 @@ class ucp_prefs break; } + /** + * Modify UCP preferences data before the page load + * + * @event core.ucp_prefs_modify_common + * @var array data Array with current/submitted UCP options data + * @var array error Errors data + * @var string mode UCP prefs operation mode + * @var string s_hidden_fields Hidden fields data + * @since 3.1.0-RC3 + */ + $vars = array( + 'data', + 'error', + 'mode', + 's_hidden_fields', + ); + extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_modify_common', compact($vars))); + $template->assign_vars(array( 'L_TITLE' => $user->lang['UCP_PREFS_' . strtoupper($mode)], diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 5ba5f1e830..a315b167d7 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -393,8 +393,9 @@ class ucp_profile } $template->assign_vars(array( - 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '', - 'JABBER' => $data['jabber'], + 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '', + 'S_JABBER_ENABLED' => $config['jab_enable'], + 'JABBER' => $data['jabber'], )); // Get additional profile fields and assign them to the template block var 'profile_fields' |