Update of /cvsroot/mantisbt/mantisbt/core In directory sc8-pr-cvs1:/tmp/cvs-serv14715/core Modified Files: access_api.php email_api.php file_api.php filter_api.php html_api.php icon_api.php lang_api.php print_api.php project_api.php Log Message: Replace all instances of empty() with our new function called is_blank(). empty() is a horrid function which isn't intended for checking strings. It is intended for checking whether a variable is unset or false (or rather anything that == false, which includes 0 and ''). In every case, as far as we can tell, we are not checking for this but rather for whether the string contains information. So this function first performs trim() on the string and then checks whether the length is 0. The patch was submitted by Robert Foster <rf...@mo...> at my request. Index: access_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/access_api.php,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- access_api.php 21 Sep 2002 10:17:14 -0000 1.7 +++ access_api.php 27 Nov 2002 02:45:20 -0000 1.8 @@ -50,7 +50,7 @@ function access_bug_check( $p_bug_id, $p_view_state='' ) { global $g_private_bug_threshold; - if ( empty ( $p_view_state ) ) { + if ( is_blank( $p_view_state ) ) { $t_view_state = bug_get_field( $p_bug_id, 'view_state' ); } else { $t_view_state = (integer)$p_view_state; @@ -68,7 +68,7 @@ global $g_string_cookie_val; # user isn't logged in - if (( !isset( $g_string_cookie_val ) )||( empty( $g_string_cookie_val ) )) { + if (( !isset( $g_string_cookie_val ) )||( is_blank( $g_string_cookie_val ) )) { return false; } @@ -100,7 +100,7 @@ global $g_string_cookie_val; # user isn't logged in - if (( !isset( $g_string_cookie_val ) )||( empty( $g_string_cookie_val ) )) { + if (( !isset( $g_string_cookie_val ) )||( is_blank( $g_string_cookie_val ) )) { return false; } @@ -144,7 +144,7 @@ # user isn't logged in if (( !isset( $g_string_cookie_val ) ) || - ( empty( $g_string_cookie_val ) )) { + ( is_blank( $g_string_cookie_val ) )) { return false; } Index: email_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/email_api.php,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- email_api.php 20 Oct 2002 22:12:46 -0000 1.25 +++ email_api.php 27 Nov 2002 02:45:20 -0000 1.26 @@ -23,7 +23,7 @@ return true; } - if ( empty( $p_email ) && ON == config_get( 'allow_blank_email' ) ) { + if ( is_blank( $p_email ) && ON == config_get( 'allow_blank_email' ) ) { return true; } @@ -589,14 +589,14 @@ # add to the Recipient list $t_recipient_list = split(',', $t_recipient); while ( list( , $t_recipient ) = each( $t_recipient_list ) ) { - if ( !empty( $t_recipient ) ) { + if ( !is_blank( $t_recipient ) ) { $mail->AddAddress( $t_recipient, '' ); } } # add to the BCC list $t_bcc_list = split(',', $p_header); while(list(, $t_bcc) = each($t_bcc_list)) { - if ( !empty( $t_bcc ) ) { + if ( !is_blank( $t_bcc ) ) { $mail->AddBCC($t_bcc, ''); } } @@ -699,7 +699,7 @@ # Check limit_email_domain option and append the domain name if it is set function email_append_domain( $p_email ) { $t_limit_email_domain = config_get( 'limit_email_domain' ); - if ( $t_limit_email_domain && !empty( $p_email ) ) { + if ( $t_limit_email_domain && !is_blank( $p_email ) ) { $p_email = "$p_email@$t_limit_email_domain"; } Index: file_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/file_api.php,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- file_api.php 23 Oct 2002 04:54:01 -0000 1.14 +++ file_api.php 27 Nov 2002 02:45:20 -0000 1.15 @@ -215,7 +215,7 @@ } # if the allowed list is note populated then the file must be allowed - if ( empty( $t_allowed_files ) ) { + if ( is_blank( $t_allowed_files ) ) { return true; } # check against allowed files Index: filter_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/filter_api.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- filter_api.php 7 Sep 2002 08:36:19 -0000 1.1 +++ filter_api.php 27 Nov 2002 02:45:20 -0000 1.2 @@ -102,7 +102,7 @@ } # Simple Text Search - Thnaks to Alan Knowles - if ( !empty( $t_filter['search'] ) ) { + if ( !is_blank( $t_filter['search'] ) ) { $c_search = db_prepare_string( $t_filter['search'] ); array_push( $t_where_clauses, "((summary LIKE '%$c_search%') @@ -215,7 +215,7 @@ $t_view_all_cookie = gpc_get_cookie( config_get( 'view_all_cookie' ), '' ); # check to see if the cookie does not exist - if ( empty( $t_view_all_cookie ) ) { + if ( is_blank( $t_view_all_cookie ) ) { return false; } Index: html_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/html_api.php,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- html_api.php 30 Oct 2002 10:42:07 -0000 1.22 +++ html_api.php 27 Nov 2002 02:45:20 -0000 1.23 @@ -167,7 +167,7 @@ # (10) $p_page is included. This allows for the admin to have a nice banner or # graphic at the top of every page function print_top_page( $p_page ) { - if (( !empty( $p_page ) )&&( file_exists( $p_page ) )&&( !is_dir( $p_page ) )) { + if (( !is_blank( $p_page ) )&&( file_exists( $p_page ) )&&( !is_dir( $p_page ) )) { include( $p_page ); } } @@ -175,7 +175,7 @@ # (11) $p_page is included. This allows for the admin to have a nice baner or # graphic at the bottom of every page function print_bottom_page( $p_page ) { - if (( !empty( $p_page ) )&&( file_exists( $p_page ) )&&( !is_dir( $p_page ) )) { + if (( !is_blank( $p_page ) )&&( file_exists( $p_page ) )&&( !is_dir( $p_page ) )) { include( $p_page ); } } @@ -189,7 +189,7 @@ $g_show_queries_count, $g_show_queries_list, $g_queries_array; # @@@ - if (isset($g_string_cookie_val)&&!empty($g_string_cookie_val)) { + if (isset($g_string_cookie_val)&&!is_blank($g_string_cookie_val)) { if ( $g_show_footer_menu ) { PRINT '<br />'; print_menu(); Index: icon_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/icon_api.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- icon_api.php 9 Sep 2002 04:31:45 -0000 1.3 +++ icon_api.php 27 Nov 2002 02:45:20 -0000 1.4 @@ -47,7 +47,7 @@ global $g_icon_path, $g_status_icon_arr; $t_none = NONE; - if ( !empty( $g_status_icon_arr[$p_icon] ) ) { + if ( !is_blank( $g_status_icon_arr[$p_icon] ) ) { PRINT "<img src=\"$g_icon_path$g_status_icon_arr[$p_icon]\" alt=\"\" />"; } else { PRINT "<img src=\"$g_icon_path$g_status_icon_arr[$t_none]\" alt=\"\" />"; @@ -74,7 +74,7 @@ } $t_none = NONE; - if ( !empty( $g_sort_icon_arr[$t_dir] ) ) { + if ( !is_blank( $g_sort_icon_arr[$t_dir] ) ) { PRINT "<img src=\"$g_icon_path$g_sort_icon_arr[$t_dir]\" alt=\"\" />"; } else { PRINT "<img src=\"$g_icon_path$g_status_icon_arr[$t_none]\" alt=\"\" />"; @@ -87,7 +87,7 @@ global $g_icon_path, $g_unread_icon_arr; $t_none = NONE; - if ( !empty( $g_unread_icon_arr[$p_unread] ) ) { + if ( !is_blank( $g_unread_icon_arr[$p_unread] ) ) { PRINT "<img src=\"$g_icon_path$g_unread_icon_arr[$p_unread]\" alt=\"\" />"; } else { PRINT "<img src=\"$g_icon_path$g_status_icon_arr[$t_none]\" alt=\"\" />"; Index: lang_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/lang_api.php,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- lang_api.php 10 Nov 2002 22:43:50 -0000 1.5 +++ lang_api.php 27 Nov 2002 02:45:20 -0000 1.6 @@ -35,14 +35,14 @@ } # Nasty code to select the proper language file - if ( !empty( $g_string_cookie_val ) ) { + if ( !is_blank( $g_string_cookie_val ) ) { $query = "SELECT DISTINCT language FROM $g_mantis_user_pref_table p, $g_mantis_user_table u WHERE u.cookie_string='$g_string_cookie_val' AND u.id=p.user_id"; $result = db_query( $query ); $g_active_language = db_result( $result, 0 , 0 ); - if (empty( $g_active_language )) { + if ( false == $g_active_language ) { $g_active_language = $g_default_language; } } else { Index: print_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/print_api.php,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- print_api.php 12 Nov 2002 10:10:35 -0000 1.27 +++ print_api.php 27 Nov 2002 02:45:20 -0000 1.28 @@ -960,7 +960,7 @@ # print the bracketed links used near the top # if the $p_link is blank then the text is printed but no link is created function print_bracket_link( $p_link, $p_url_text ) { - if (empty( $p_link )) { + if (is_blank( $p_link )) { PRINT "[ $p_url_text ]"; } else { PRINT "[ <a href=\"$p_link\">$p_url_text</a> ]"; Index: project_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/project_api.php,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- project_api.php 12 Nov 2002 12:08:36 -0000 1.17 +++ project_api.php 27 Nov 2002 02:45:20 -0000 1.18 @@ -166,7 +166,7 @@ $c_file_path = db_prepare_string( $p_file_path ); $c_enabled = db_prepare_bool( $p_enabled ); - if ( empty( $p_name ) ) { + if ( is_blank( $p_name ) ) { trigger_error( ERROR_PROJECT_NAME_INVALID, ERROR ); } @@ -236,7 +236,7 @@ $c_file_path = db_prepare_string( $p_file_path ); $c_enabled = db_prepare_bool( $p_enabled ); - if ( empty( $p_name ) ) { + if ( is_blank( $p_name ) ) { trigger_error( ERROR_PROJECT_NAME_INVALID, ERROR ); } |