|
61 | 61 | $t_top = $t_project[0]; |
62 | 62 | $t_bottom = $t_project[count( $t_project ) - 1]; |
63 | 63 |
|
| 64 | +$t_redirect_url = config_get_global( 'default_home_page' ); |
| 65 | + |
64 | 66 | if( ALL_PROJECTS != $t_bottom ) { |
65 | 67 | project_ensure_exists( $t_bottom ); |
66 | 68 | } |
|
77 | 79 | # for proxies that clear out HTTP_REFERER |
78 | 80 | if( !is_blank( $c_ref ) ) { |
79 | 81 | $t_redirect_url = $c_ref; |
80 | | -} else if( !isset( $_SERVER['HTTP_REFERER'] ) || is_blank( $_SERVER['HTTP_REFERER'] ) ) { |
81 | | - $t_redirect_url = config_get_global( 'default_home_page' ); |
82 | | -} else { |
83 | | - $t_home_page = config_get_global( 'default_home_page' ); |
84 | | - |
| 82 | +} else if( isset( $_SERVER['HTTP_REFERER'] ) && !is_blank( $_SERVER['HTTP_REFERER'] ) ) { |
85 | 83 | # Check that referrer matches our address after squashing case (case insensitive compare) |
86 | 84 | $t_path = rtrim( config_get_global( 'path' ), '/' ); |
87 | 85 | if( preg_match( '@^(' . $t_path . ')/(?:/*([^\?#]*))(.*)?$@', $_SERVER['HTTP_REFERER'], $t_matches ) ) { |
88 | 86 | $t_referrer_page = $t_matches[2]; |
89 | 87 | $t_param = $t_matches[3]; |
90 | 88 |
|
91 | | - # if view_all_bug_page, pass on filter |
92 | | - if( strcasecmp( 'view_all_bug_page.php', $t_referrer_page ) == 0 ) { |
93 | | - $t_source_filter_id = filter_db_get_project_current( $t_bottom ); |
94 | | - $t_redirect_url = 'view_all_set.php?type=' . FILTER_ACTION_GENERALIZE; |
95 | | - |
96 | | - if( $t_source_filter_id !== null ) { |
97 | | - $t_redirect_url = 'view_all_set.php?type=' . FILTER_ACTION_LOAD . '&source_query_id=' . $t_source_filter_id; |
98 | | - } |
99 | | - } else if( stripos( $t_referrer_page, '_page.php' ) !== false ) { |
100 | | - switch( $t_referrer_page ) { |
101 | | - case 'bug_view_page.php': |
102 | | - case 'bug_view_advanced_page.php': |
103 | | - case 'bug_update_page.php': |
104 | | - case 'bug_change_status_page.php': |
105 | | - $t_path = $t_home_page; |
106 | | - break; |
107 | | - default: |
108 | | - $t_path = $t_referrer_page . $t_param; |
109 | | - break; |
110 | | - } |
111 | | - $t_redirect_url = $t_path; |
112 | | - } else if( $t_referrer_page == 'plugin.php' ) { |
113 | | - $t_redirect_url = $t_referrer_page . $t_param; # redirect to same plugin page |
114 | | - } else { |
115 | | - $t_redirect_url = $t_home_page; |
| 89 | + switch( $t_referrer_page ) { |
| 90 | + case 'view_all_bug_page.php': |
| 91 | + $t_source_filter_id = filter_db_get_project_current( $t_bottom ); |
| 92 | + $t_redirect_url = 'view_all_set.php?' . string_build_query( |
| 93 | + ( $t_source_filter_id !== null ) |
| 94 | + ? [ 'type' => FILTER_ACTION_LOAD, |
| 95 | + 'source_query_id' => $t_source_filter_id ] |
| 96 | + : [ 'type' => FILTER_ACTION_GENERALIZE ] ); |
| 97 | + break; |
| 98 | + |
| 99 | + case 'manage_proj_edit_page.php': |
| 100 | + case 'manage_proj_page.php': |
| 101 | + $t_redirect_url = ( ALL_PROJECTS != $t_bottom ) |
| 102 | + ? 'manage_proj_edit_page.php?' |
| 103 | + . string_build_query( [ 'project_id' => $t_bottom ] ) |
| 104 | + : 'manage_proj_page.php'; |
| 105 | + break; |
| 106 | + |
| 107 | + case 'bug_view_page.php': |
| 108 | + case 'bug_view_advanced_page.php': |
| 109 | + case 'bug_update_page.php': |
| 110 | + case 'bug_change_status_page.php': |
| 111 | + break; |
| 112 | + |
| 113 | + default: |
| 114 | + if( stripos( $t_referrer_page, '_page.php' ) !== false |
| 115 | + # redirect to same plugin page |
| 116 | + || $t_referrer_page == 'plugin.php' ) { |
| 117 | + $t_redirect_url = $t_referrer_page . $t_param; |
| 118 | + } |
| 119 | + break; |
116 | 120 | } |
117 | | - } else { |
118 | | - $t_redirect_url = $t_home_page; |
119 | 121 | } |
120 | 122 | } |
121 | 123 |
|
|
0 commit comments