From cb1d98ab7f588a38fcae680aca839b805caf2a23 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 26 Nov 2012 23:06:38 +0100 Subject: [PATCH] [feature/avatars] Check for existing functions rather than using _once PHPBB3-10018 --- phpBB/includes/avatar/driver/gravatar.php | 5 ++++- phpBB/includes/avatar/driver/remote.php | 11 +++++++++-- phpBB/includes/avatar/driver/upload.php | 5 ++++- phpBB/includes/ucp/ucp_profile.php | 5 ++++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/avatar/driver/gravatar.php b/phpBB/includes/avatar/driver/gravatar.php index a90c0e3ce1..7e21a737a1 100644 --- a/phpBB/includes/avatar/driver/gravatar.php +++ b/phpBB/includes/avatar/driver/gravatar.php @@ -95,7 +95,10 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver $row['avatar_width'] = $this->request->variable('avatar_gravatar_width', 0); $row['avatar_height'] = $this->request->variable('avatar_gravatar_height', 0); - require_once($this->phpbb_root_path . 'includes/functions_user' . $this->php_ext); + if (!function_exists('user_add')) + { + require($this->phpbb_root_path . 'includes/functions_user' . $this->php_ext); + } $error = array_merge($error, validate_data(array( 'email' => $row['avatar'], diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php index b7522ac3e1..1da5fc16e8 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/remote.php @@ -82,7 +82,10 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver $url = 'http://' . $url; } - require_once($this->phpbb_root_path . 'includes/functions_user' . $this->php_ext); + if (!function_exists('user_add')) + { + require($this->phpbb_root_path . 'includes/functions_user' . $this->php_ext); + } $error = array_merge($error, validate_data(array( 'url' => $url, @@ -128,7 +131,11 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver return false; } - include_once($this->phpbb_root_path . 'includes/functions_upload' . $this->php_ext); + if (!class_exists('fileupload')) + { + include_once($this->phpbb_root_path . 'includes/functions_upload' . $this->php_ext); + } + $types = fileupload::image_types(); $extension = strtolower(filespec::get_extension($url)); diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php index f00033d6bd..497dd8ad19 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/upload.php @@ -72,7 +72,10 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver return false; } - include_once($this->phpbb_root_path . 'includes/functions_upload' . $this->php_ext); + if (!class_exists('fileupload')) + { + include_once($this->phpbb_root_path . 'includes/functions_upload' . $this->php_ext); + } $upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), $this->config['avatar_filesize'], $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], (isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false)); diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index c05105eaff..c8547e48d8 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -545,7 +545,10 @@ class ucp_profile break; case 'avatar': - include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx); + if (!function_exists('display_forums')) + { + include($phpbb_root_path . 'includes/functions_display.' . $phpEx); + } add_form_key('ucp_avatar');