1<?php 2# MantisBT - A PHP based bugtracking system 3 4# MantisBT is free software: you can redistribute it and/or modify 5# it under the terms of the GNU General Public License as published by 6# the Free Software Foundation, either version 2 of the License, or 7# (at your option) any later version. 8# 9# MantisBT is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with MantisBT. If not, see <http://www.gnu.org/licenses/>. 16 17/** 18 * Plugin file loader 19 * @package MantisBT 20 * @copyright Copyright 2002 MantisBT Team - mantisbt-dev@lists.sourceforge.net 21 * @link http://www.mantisbt.org 22 * 23 * @uses core.php 24 * @uses config_api.php 25 * @uses constant_inc.php 26 * @uses gpc_api.php 27 * @uses plugin_api.php 28 */ 29 30require_once( 'core.php' ); 31require_api( 'config_api.php' ); 32require_api( 'constant_inc.php' ); 33require_api( 'gpc_api.php' ); 34require_api( 'plugin_api.php' ); 35 36$t_plugin_path = config_get_global( 'plugin_path' ); 37 38$f_page = gpc_get_string( 'page' ); 39 40if( !preg_match( '/^([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+[\/a-zA-Z0-9_-]*)/', $f_page, $t_matches ) ) { 41 error_parameters( $f_page ); 42 trigger_error( ERROR_PLUGIN_INVALID_PAGE, ERROR ); 43} 44 45$t_basename = $t_matches[1]; 46$t_action = $t_matches[2]; 47 48$t_plugin = plugin_get( $t_basename ); 49 50if( plugin_needs_upgrade( $t_plugin ) ) { 51 error_parameters( $t_basename ); 52 trigger_error( ERROR_PLUGIN_UPGRADE_NEEDED, ERROR ); 53} 54 55# Plugin can be registered but fail to load e.g. due to unmet dependencies 56if( !plugin_is_loaded( $t_basename ) ) { 57 error_parameters( $t_basename ); 58 trigger_error( ERROR_PLUGIN_NOT_LOADED, ERROR ); 59} 60 61$t_page = $t_plugin_path . $t_basename . '/pages/' . $t_action . '.php'; 62 63if( !is_file( $t_page ) ) { 64 error_parameters( $t_basename, $t_action ); 65 trigger_error( ERROR_PLUGIN_PAGE_NOT_FOUND, ERROR ); 66} 67 68# rewrite headers to allow caching 69if( gpc_isset( 'cache_key' ) ) { 70 http_caching_headers( true ); 71} 72 73plugin_push_current( $t_basename ); 74include( $t_page ); 75