mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-05 05:55:15 +02:00
This is an attempt to remove problems with "file_exists()" calls in later
versions of PHP. From what I can tell, PHP requires a full path to file_exists() in newer versions, and realpath() will fix it. I noticed that file_exists() doesn't need to have a full path passed to it in older versions, so I just made a fake function, realpath() that will only define itself if realpath() isn't defined. It may or may not work, it seems to work here on PHP 4.2.3, but if it breaks older versions, please *LET ME KNOW* or change it. Because I changed this so quickly, I don't know if everything works exactly. Really, PM or email me if it doesn't. Cross your fingers! :D Thanks! dougk_ff7 dougk_ff7@phpbb.com git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@2935 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
a3d3c7c74f
commit
6913351af7
@ -136,7 +136,7 @@ switch( $mode )
|
||||
{
|
||||
if( !is_file($phpbb_root_path . 'templates/' .$sub_dir) && !is_link($phpbb_root_path . 'templates/' .$sub_dir) && $sub_dir != "." && $sub_dir != ".." && $sub_dir != "CVS" )
|
||||
{
|
||||
if( @file_exists($phpbb_root_path. "templates/" . $sub_dir . "/theme_info.cfg") )
|
||||
if( @file_exists(@realpath($phpbb_root_path. "templates/" . $sub_dir . "/theme_info.cfg")) )
|
||||
{
|
||||
include($phpbb_root_path. "templates/" . $sub_dir . "/theme_info.cfg");
|
||||
|
||||
|
@ -231,7 +231,7 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) |
|
||||
{
|
||||
if( $this_userdata['user_avatar_type'] == USER_AVATAR_UPLOAD && $this_userdata['user_avatar'] != "" )
|
||||
{
|
||||
if( @file_exists("./" . $board_config['avatar_path'] . "/" . $this_userdata['user_avatar']) )
|
||||
if( @file_exists(@realpath("./" . $board_config['avatar_path'] . "/" . $this_userdata['user_avatar'])) )
|
||||
{
|
||||
@unlink("./" . $board_config['avatar_path'] . "/" . $this_userdata['user_avatar']);
|
||||
}
|
||||
@ -256,7 +256,7 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) |
|
||||
|
||||
if( $user_avatar_loc != "" )
|
||||
{
|
||||
if( file_exists($user_avatar_loc) && ereg(".jpg$|.gif$|.png$", $user_avatar_name) )
|
||||
if( file_exists(@realpath($user_avatar_loc)) && ereg(".jpg$|.gif$|.png$", $user_avatar_name) )
|
||||
{
|
||||
if( $user_avatar_size <= $board_config['avatar_filesize'] && $avatar_size > 0)
|
||||
{
|
||||
@ -299,7 +299,7 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) |
|
||||
|
||||
if( $this_userdata['user_avatar_type'] == USER_AVATAR_UPLOAD && $this_userdata['user_avatar'] != "" )
|
||||
{
|
||||
if( @file_exists("./../" . $board_config['avatar_path'] . "/" . $this_userdata['user_avatar']) )
|
||||
if( @file_exists(@realpath("./../" . $board_config['avatar_path'] . "/" . $this_userdata['user_avatar'])) )
|
||||
{
|
||||
@unlink("./../" . $board_config['avatar_path'] . "/". $this_userdata['user_avatar']);
|
||||
}
|
||||
@ -408,7 +408,7 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) |
|
||||
|
||||
if( $this_userdata['user_avatar_type'] == USER_AVATAR_UPLOAD && $this_userdata['user_avatar'] != "")
|
||||
{
|
||||
if( file_exists("./../" . $board_config['avatar_path'] . "/" . $this_userdata['user_avatar']) )
|
||||
if( file_exists(@realpath("./../" . $board_config['avatar_path'] . "/" . $this_userdata['user_avatar'])) )
|
||||
{
|
||||
@unlink("./../" . $board_config['avatar_path'] . "/" . $this_userdata['user_avatar']);
|
||||
}
|
||||
@ -1108,7 +1108,7 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) |
|
||||
'S_PROFILE_ACTION' => append_sid("admin_users.$phpEx"))
|
||||
);
|
||||
|
||||
if( file_exists('./../' . $board_config['avatar_path'] ) && ($board_config['allow_avatar_upload'] == TRUE) )
|
||||
if( file_exists(@realpath('./../' . $board_config['avatar_path'])) && ($board_config['allow_avatar_upload'] == TRUE) )
|
||||
{
|
||||
if ( $form_enctype != '' )
|
||||
{
|
||||
@ -1117,7 +1117,7 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) |
|
||||
$template->assign_block_vars('avatar_remote_upload', array() );
|
||||
}
|
||||
|
||||
if( file_exists('./../' . $board_config['avatar_gallery_path'] ) && ($board_config['allow_avatar_local'] == TRUE) )
|
||||
if( file_exists(@realpath('./../' . $board_config['avatar_gallery_path'])) && ($board_config['allow_avatar_local'] == TRUE) )
|
||||
{
|
||||
$template->assign_block_vars('avatar_local_gallery', array() );
|
||||
}
|
||||
|
@ -88,7 +88,8 @@ class emailer
|
||||
$template_lang = $board_config['default_lang'];
|
||||
}
|
||||
|
||||
$this->tpl_file = $phpbb_root_path . 'language/lang_' . $template_lang . '/email/' . $template_file . '.tpl';
|
||||
$this->tpl_file = realpath($phpbb_root_path . 'language/lang_' . $template_lang . '/email/' . $template_file . '.tpl');
|
||||
|
||||
if ( !file_exists($this->tpl_file) )
|
||||
{
|
||||
message_die(GENERAL_ERROR, 'Could not find email template file ' . $template_file, '', __LINE__, __FILE__);
|
||||
|
@ -220,7 +220,7 @@ function init_userprefs($userdata)
|
||||
}
|
||||
}
|
||||
|
||||
if ( !file_exists($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx) )
|
||||
if ( !file_exists(@realpath($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx)) )
|
||||
{
|
||||
$board_config['default_lang'] = 'english';
|
||||
}
|
||||
@ -229,7 +229,7 @@ function init_userprefs($userdata)
|
||||
|
||||
if ( defined('IN_ADMIN') )
|
||||
{
|
||||
if( !file_exists($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.'.$phpEx) )
|
||||
if( !file_exists(@realpath($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.'.$phpEx)) )
|
||||
{
|
||||
$board_config['default_lang'] = 'english';
|
||||
}
|
||||
@ -288,7 +288,7 @@ function setup_style($style)
|
||||
message_die(CRITICAL_ERROR, "Could not open $template_name template config file", '', __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
$img_lang = ( file_exists($current_template_path . '/images/lang_' . $board_config['default_lang']) ) ? $board_config['default_lang'] : 'english';
|
||||
$img_lang = ( file_exists(@realpath($current_template_path . '/images/lang_' . $board_config['default_lang'])) ) ? $board_config['default_lang'] : 'english';
|
||||
|
||||
while( list($key, $value) = @each($images) )
|
||||
{
|
||||
@ -675,4 +675,19 @@ function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '',
|
||||
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
//
|
||||
// This function is for compatibility with PHP 4.x's realpath()
|
||||
// function. In later versions of PHP, it needs to be called
|
||||
// to do checks with some functions. Older versions of PHP don't
|
||||
// seem to need this, so we'll just return the original value.
|
||||
//
|
||||
// dougk_ff7 <October 5, 2002>
|
||||
if ( !function_exists(realpath) )
|
||||
{
|
||||
function realpath($path)
|
||||
{
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -230,7 +230,7 @@ class Template {
|
||||
// Check if it's an absolute or relative path.
|
||||
if (substr($filename, 0, 1) != '/')
|
||||
{
|
||||
$filename = $this->root . '/' . $filename;
|
||||
$filename = realpath($this->root . '/' . $filename);
|
||||
}
|
||||
|
||||
if (!file_exists($filename))
|
||||
|
@ -53,7 +53,7 @@ function user_avatar_delete($avatar_type, $avatar_file)
|
||||
|
||||
if ( $avatar_type == USER_AVATAR_UPLOAD && $avatar_file != '' )
|
||||
{
|
||||
if ( @file_exists('./' . $board_config['avatar_path'] . '/' . $avatar_file) )
|
||||
if ( @file_exists(@realpath('./' . $board_config['avatar_path'] . '/' . $avatar_file)) )
|
||||
{
|
||||
@unlink('./' . $board_config['avatar_path'] . '/' . $avatar_file);
|
||||
}
|
||||
@ -65,7 +65,7 @@ function user_avatar_delete($avatar_type, $avatar_file)
|
||||
function user_avatar_gallery($mode, &$error, &$error_msg, $avatar_filename)
|
||||
{
|
||||
global $board_config;
|
||||
if ( file_exists($board_config['avatar_gallery_path'] . '/' . $avatar_filename) && ($mode == 'editprofile') )
|
||||
if ( file_exists(@realpath($board_config['avatar_gallery_path'] . '/' . $avatar_filename)) && ($mode == 'editprofile') )
|
||||
{
|
||||
$return = ", user_avatar = '" . str_replace("\'", "''", $avatar_filename) . "', user_avatar_type = " . USER_AVATAR_GALLERY;
|
||||
}
|
||||
@ -167,7 +167,7 @@ function user_avatar_upload($mode, $avatar_mode, &$current_avatar, &$current_typ
|
||||
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $l_avatar_size : $l_avatar_size;
|
||||
}
|
||||
}
|
||||
else if ( $avatar_mode == 'local' && file_exists($avatar_filename) && preg_match('/\.(jpg|jpeg|gif|png)$/i', $avatar_realname) )
|
||||
else if ( file_exists(@realpath($avatar_filename)) ) && preg_match('/\.(jpg|jpeg|gif|png)$/i', $avatar_realname) )
|
||||
{
|
||||
if ( $avatar_filesize <= $board_config['avatar_filesize'] && $avatar_filesize > 0 )
|
||||
{
|
||||
@ -197,7 +197,7 @@ function user_avatar_upload($mode, $avatar_mode, &$current_avatar, &$current_typ
|
||||
|
||||
if ( $mode == 'editprofile' && $current_type == USER_AVATAR_UPLOAD && $current_avatar != '' )
|
||||
{
|
||||
if ( file_exists('./' . $board_config['avatar_path'] . '/' . $current_avatar) )
|
||||
if ( file_exists(@realpath('./' . $board_config['avatar_path'] . '/' . $current_avatar)) )
|
||||
{
|
||||
@unlink('./' . $board_config['avatar_path'] . '/' . $current_avatar);
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ if (
|
||||
$user_avatar = $user_avatar_local;
|
||||
$user_avatar_type = USER_AVATAR_GALLERY;
|
||||
|
||||
if ( $userdata['user_avatar_type'] == USER_AVATAR_UPLOAD && @file_exists('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar']) )
|
||||
if ( $userdata['user_avatar_type'] == USER_AVATAR_UPLOAD && @file_exists(@realpath('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar'])) )
|
||||
{
|
||||
@unlink('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar']);
|
||||
}
|
||||
@ -920,7 +920,7 @@ else
|
||||
{
|
||||
$template->assign_block_vars('switch_avatar_block', array() );
|
||||
|
||||
if ( $board_config['allow_avatar_upload'] && file_exists('./' . $board_config['avatar_path']) )
|
||||
if ( $board_config['allow_avatar_upload'] && file_exists(@realpath('./' . $board_config['avatar_path'])) )
|
||||
{
|
||||
if ( $form_enctype != '' )
|
||||
{
|
||||
@ -934,7 +934,7 @@ else
|
||||
$template->assign_block_vars('switch_avatar_block.switch_avatar_remote_link', array() );
|
||||
}
|
||||
|
||||
if ( $board_config['allow_avatar_local'] && file_exists('./' . $board_config['avatar_gallery_path']) )
|
||||
if ( $board_config['allow_avatar_local'] && file_exists(@realpath('./' . $board_config['avatar_gallery_path'])) )
|
||||
{
|
||||
$template->assign_block_vars('switch_avatar_block.switch_avatar_local_gallery', array() );
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ $server_port = ( !empty($HTTP_POST_VARS['server_port']) ) ? $HTTP_POST_VARS['ser
|
||||
$board_email = ( !empty($HTTP_POST_VARS['board_email']) ) ? $HTTP_POST_VARS['board_email'] : "";
|
||||
$script_path = ( !empty($HTTP_POST_VARS['script_path']) ) ? $HTTP_POST_VARS['script_path'] : "";
|
||||
|
||||
if( @file_exists('config.'.$phpEx) )
|
||||
if( @file_exists(@realpath('config.'.$phpEx)) )
|
||||
{
|
||||
include('config.'.$phpEx);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user