From 5d8b228bb00339ff2c2620af4ac140e69fa66f96 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Sat, 21 Dec 2002 19:09:57 +0000 Subject: [PATCH] "Fix" for realpath and Lycos? git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@3222 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/admin/admin_db_utilities.php | 2 +- phpBB/admin/admin_smilies.php | 2 +- phpBB/admin/admin_styles.php | 8 ++++---- phpBB/admin/admin_users.php | 14 +++++++------- phpBB/includes/constants.php | 2 +- phpBB/includes/emailer.php | 6 +++--- phpBB/includes/functions.php | 14 +++++--------- phpBB/includes/template.php | 2 +- phpBB/includes/usercp_avatar.php | 8 ++++---- phpBB/includes/usercp_register.php | 8 ++++---- phpBB/install/install.php | 4 ++-- 11 files changed, 33 insertions(+), 37 deletions(-) diff --git a/phpBB/admin/admin_db_utilities.php b/phpBB/admin/admin_db_utilities.php index 3f364972e6..a3dfa844dd 100644 --- a/phpBB/admin/admin_db_utilities.php +++ b/phpBB/admin/admin_db_utilities.php @@ -903,7 +903,7 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) ) // a hackers attempt at getting us to process a local system // file. // - if( file_exists(realpath($backup_file_tmpname)) ) + if( file_exists(phpbb_realpath($backup_file_tmpname)) ) { if( preg_match("/^(text\/[a-zA-Z]+)|(application\/(x\-)?gzip(\-compressed)?)|(application\/octet-stream)$/is", $backup_file_type) ) { diff --git a/phpBB/admin/admin_smilies.php b/phpBB/admin/admin_smilies.php index be8b9bfd3b..cadd71654d 100644 --- a/phpBB/admin/admin_smilies.php +++ b/phpBB/admin/admin_smilies.php @@ -72,7 +72,7 @@ $dir = @opendir($phpbb_root_path . $board_config['smilies_path']); while($file = @readdir($dir)) { - if( !@is_dir(realpath($phpbb_root_path . $board_config['smilies_path'] . '/' . $file)) ) + if( !@is_dir(phpbb_realpath($phpbb_root_path . $board_config['smilies_path'] . '/' . $file)) ) { $img_size = @getimagesize($phpbb_root_path . $board_config['smilies_path'] . '/' . $file); diff --git a/phpBB/admin/admin_styles.php b/phpBB/admin/admin_styles.php index 478369a4f9..f658d982ac 100644 --- a/phpBB/admin/admin_styles.php +++ b/phpBB/admin/admin_styles.php @@ -132,9 +132,9 @@ switch( $mode ) { while( $sub_dir = @readdir($dir) ) { - if( !is_file(realpath($phpbb_root_path . 'templates/' .$sub_dir)) && !is_link(realpath($phpbb_root_path . 'templates/' .$sub_dir)) && $sub_dir != "." && $sub_dir != ".." && $sub_dir != "CVS" ) + if( !is_file(phpbb_realpath($phpbb_root_path . 'templates/' .$sub_dir)) && !is_link(phpbb_realpath($phpbb_root_path . 'templates/' .$sub_dir)) && $sub_dir != "." && $sub_dir != ".." && $sub_dir != "CVS" ) { - if( @file_exists(@realpath($phpbb_root_path. "templates/" . $sub_dir . "/theme_info.cfg")) ) + if( @file_exists(@phpbb_realpath($phpbb_root_path. "templates/" . $sub_dir . "/theme_info.cfg")) ) { include($phpbb_root_path. "templates/" . $sub_dir . "/theme_info.cfg"); @@ -549,7 +549,7 @@ switch( $mode ) $s_template_select = ''; while( $file = @readdir($dir) ) { - if( !is_file(realpath($phpbb_root_path . 'templates/' . $file)) && !is_link(realpath($phpbb_root_path . 'templates/' .$file)) && $file != "." && $file != ".." && $file != "CVS" ) + if( !is_file(phpbb_realpath($phpbb_root_path . 'templates/' . $file)) && !is_link(phpbb_realpath($phpbb_root_path . 'templates/' .$file)) && $file != "." && $file != ".." && $file != "CVS" ) { $s_template_select .= '\n"; } diff --git a/phpBB/admin/admin_users.php b/phpBB/admin/admin_users.php index 162f126ba3..dbbb5e04f0 100644 --- a/phpBB/admin/admin_users.php +++ b/phpBB/admin/admin_users.php @@ -379,7 +379,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(@realpath("./" . $board_config['avatar_path'] . "/" . $this_userdata['user_avatar'])) ) + if( @file_exists(@phpbb_realpath("./" . $board_config['avatar_path'] . "/" . $this_userdata['user_avatar'])) ) { @unlink("./" . $board_config['avatar_path'] . "/" . $this_userdata['user_avatar']); } @@ -404,7 +404,7 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) | if( $user_avatar_loc != "" ) { - if( file_exists(@realpath($user_avatar_loc)) && ereg(".jpg$|.gif$|.png$", $user_avatar_name) ) + if( file_exists(@phpbb_realpath($user_avatar_loc)) && ereg(".jpg$|.gif$|.png$", $user_avatar_name) ) { if( $user_avatar_size <= $board_config['avatar_filesize'] && $user_avatar_size > 0) { @@ -447,7 +447,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(@realpath("./../" . $board_config['avatar_path'] . "/" . $this_userdata['user_avatar'])) ) + if( @file_exists(@phpbb_realpath("./../" . $board_config['avatar_path'] . "/" . $this_userdata['user_avatar'])) ) { @unlink("./../" . $board_config['avatar_path'] . "/". $this_userdata['user_avatar']); } @@ -556,7 +556,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(@realpath("./../" . $board_config['avatar_path'] . "/" . $this_userdata['user_avatar'])) ) + if( file_exists(@phpbb_realpath("./../" . $board_config['avatar_path'] . "/" . $this_userdata['user_avatar'])) ) { @unlink("./../" . $board_config['avatar_path'] . "/" . $this_userdata['user_avatar']); } @@ -788,7 +788,7 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) | $avatar_images = array(); while( $file = @readdir($dir) ) { - if( $file != "." && $file != ".." && !is_file(realpath("./../" . $board_config['avatar_gallery_path'] . "/" . $file)) && !is_link(realpath("./../" . $board_config['avatar_gallery_path'] . "/" . $file)) ) + if( $file != "." && $file != ".." && !is_file(phpbb_realpath("./../" . $board_config['avatar_gallery_path'] . "/" . $file)) && !is_link(phpbb_realpath("./../" . $board_config['avatar_gallery_path'] . "/" . $file)) ) { $sub_dir = @opendir("../" . $board_config['avatar_gallery_path'] . "/" . $file); @@ -1078,7 +1078,7 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) | 'S_PROFILE_ACTION' => append_sid("admin_users.$phpEx")) ); - if( file_exists(@realpath('./../' . $board_config['avatar_path'])) && ($board_config['allow_avatar_upload'] == TRUE) ) + if( file_exists(@phpbb_realpath('./../' . $board_config['avatar_path'])) && ($board_config['allow_avatar_upload'] == TRUE) ) { if ( $form_enctype != '' ) { @@ -1087,7 +1087,7 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) | $template->assign_block_vars('avatar_remote_upload', array() ); } - if( file_exists(@realpath('./../' . $board_config['avatar_gallery_path'])) && ($board_config['allow_avatar_local'] == TRUE) ) + if( file_exists(@phpbb_realpath('./../' . $board_config['avatar_gallery_path'])) && ($board_config['allow_avatar_local'] == TRUE) ) { $template->assign_block_vars('avatar_local_gallery', array() ); } diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index ad2e9eb74e..2da9518b04 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -27,7 +27,7 @@ if ( !defined('IN_PHPBB') ) // Debug Level //define('DEBUG', 1); // Debugging on -define('DEBUG', 0); // Debugging off +define('DEBUG', 1); // Debugging off // User Levels <- Do not change the values of USER or ADMIN diff --git a/phpBB/includes/emailer.php b/phpBB/includes/emailer.php index 13c82c5a29..84da9bf87a 100755 --- a/phpBB/includes/emailer.php +++ b/phpBB/includes/emailer.php @@ -88,9 +88,9 @@ class emailer $template_lang = $board_config['default_lang']; } - $this->tpl_file = @realpath($phpbb_root_path . 'language/lang_' . $template_lang . '/email/' . $template_file . '.tpl'); + $this->tpl_file = @phpbb_realpath($phpbb_root_path . 'language/lang_' . $template_lang . '/email/' . $template_file . '.tpl'); - if ( !file_exists(realpath($this->tpl_file)) ) + if ( !file_exists(phpbb_realpath($this->tpl_file)) ) { message_die(GENERAL_ERROR, 'Could not find email template file ' . $template_file, '', __LINE__, __FILE__); } @@ -307,7 +307,7 @@ class emailer // function encode_file($sourcefile) { - if (is_readable(realpath($sourcefile))) + if (is_readable(phpbb_realpath($sourcefile))) { $fd = fopen($sourcefile, "r"); $contents = fread($fd, filesize($sourcefile)); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 58718a75fe..c9dd532141 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -220,7 +220,7 @@ function init_userprefs($userdata) } } - if ( !file_exists(@realpath($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx)) ) + if ( !file_exists(@phpbb_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(@realpath($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.'.$phpEx)) ) + if( !file_exists(@phpbb_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(@realpath($phpbb_root_path . $current_template_path . '/images/lang_' . $board_config['default_lang'])) ) ? $board_config['default_lang'] : 'english'; + $img_lang = ( file_exists(@phpbb_realpath($phpbb_root_path . $current_template_path . '/images/lang_' . $board_config['default_lang'])) ) ? $board_config['default_lang'] : 'english'; while( list($key, $value) = @each($images) ) { @@ -681,14 +681,10 @@ function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', // 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 -if ( !function_exists(realpath) ) +function phpbb_realpath($path) { - function realpath($path) - { - return $path; - } + return (!@function_exists('realpath') || !@realpath($phpbb_root_path . 'includes/functions.'.$phpEx)) ? $path : realpath($path); } function redirect($url) diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index dbd771ca77..fa17b4173e 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -230,7 +230,7 @@ class Template { // Check if it's an absolute or relative path. if (substr($filename, 0, 1) != '/') { - $filename = realpath($this->root . '/' . $filename); + $filename = phpbb_realpath($this->root . '/' . $filename); } if (!file_exists($filename)) diff --git a/phpBB/includes/usercp_avatar.php b/phpBB/includes/usercp_avatar.php index 68bce7640c..69f61ff056 100644 --- a/phpBB/includes/usercp_avatar.php +++ b/phpBB/includes/usercp_avatar.php @@ -53,7 +53,7 @@ function user_avatar_delete($avatar_type, $avatar_file) if ( $avatar_type == USER_AVATAR_UPLOAD && $avatar_file != '' ) { - if ( @file_exists(@realpath('./' . $board_config['avatar_path'] . '/' . $avatar_file)) ) + if ( @file_exists(@phpbb_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(@realpath($board_config['avatar_gallery_path'] . '/' . $avatar_filename)) && ($mode == 'editprofile') ) + if ( file_exists(@phpbb_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 . '
' . $l_avatar_size : $l_avatar_size; } } - else if ( ( file_exists(@realpath($avatar_filename)) ) && preg_match('/\.(jpg|jpeg|gif|png)$/i', $avatar_realname) ) + else if ( ( file_exists(@phpbb_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(@realpath('./' . $board_config['avatar_path'] . '/' . $current_avatar)) ) + if ( file_exists(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $current_avatar)) ) { @unlink('./' . $board_config['avatar_path'] . '/' . $current_avatar); } diff --git a/phpBB/includes/usercp_register.php b/phpBB/includes/usercp_register.php index 06653a6739..c821265542 100644 --- a/phpBB/includes/usercp_register.php +++ b/phpBB/includes/usercp_register.php @@ -402,7 +402,7 @@ if ( isset($HTTP_POST_VARS['submit']) ) } else if ( $user_avatar_remoteurl != '' && $board_config['allow_avatar_remote'] ) { - if ( @file_exists(@realpath('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar'])) ) + if ( @file_exists(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar'])) ) { @unlink('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar']); } @@ -410,7 +410,7 @@ if ( isset($HTTP_POST_VARS['submit']) ) } else if ( $user_avatar_local != '' && $board_config['allow_avatar_local'] ) { - if ( @file_exists(@realpath('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar'])) ) + if ( @file_exists(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar'])) ) { @unlink('./' . $board_config['avatar_path'] . '/' . $userdata['user_avatar']); } @@ -937,7 +937,7 @@ else { $template->assign_block_vars('switch_avatar_block', array() ); - if ( $board_config['allow_avatar_upload'] && file_exists(@realpath('./' . $board_config['avatar_path'])) ) + if ( $board_config['allow_avatar_upload'] && file_exists(@phpbb_realpath('./' . $board_config['avatar_path'])) ) { if ( $form_enctype != '' ) { @@ -951,7 +951,7 @@ else $template->assign_block_vars('switch_avatar_block.switch_avatar_remote_link', array() ); } - if ( $board_config['allow_avatar_local'] && file_exists(@realpath('./' . $board_config['avatar_gallery_path'])) ) + if ( $board_config['allow_avatar_local'] && file_exists(@phpbb_realpath('./' . $board_config['avatar_gallery_path'])) ) { $template->assign_block_vars('switch_avatar_block.switch_avatar_local_gallery', array() ); } diff --git a/phpBB/install/install.php b/phpBB/install/install.php index cb5114b083..7cccfd34f2 100644 --- a/phpBB/install/install.php +++ b/phpBB/install/install.php @@ -205,7 +205,7 @@ function guess_lang() { if (preg_match('#' . $match . '#i', trim($accept_lang_ary[$i]))) { - if (file_exists(@realpath($phpbb_root_path . 'language/lang_' . $lang))) + if (file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $lang))) { return $lang; } @@ -435,7 +435,7 @@ else } // Open config.php ... if it exists -if (@file_exists(@realpath('config.'.$phpEx))) +if (@file_exists(@phpbb_realpath('config.'.$phpEx))) { include($phpbb_root_path.'config.'.$phpEx); }