Project

General

Profile

1 536 doc
<?php
2 1398 FrankH
/**
3
 *
4
 * @category        admin
5
 * @package         admintools
6 1520 darkviper
 * @author          WB-Project, Werner v.d. Decken
7 1711 Luisehahne
 * @copyright       2012, WebsiteBaker Org. e.V.
8 1398 FrankH
 * @link			http://www.websitebaker2.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10 1520 darkviper
 * @platform        WebsiteBaker 2.8.2
11 1398 FrankH
 * @requirements    PHP 5.2.2 and higher
12
 * @version         $Id$
13 1457 Luisehahne
 * @filesource		$HeadURL$
14
 * @lastmodified    $Date$
15 1398 FrankH
 *
16
 */
17 1805 Luisehahne
18
$config_file = realpath('../../config.php');
19
if(file_exists($config_file) && !defined('WB_URL'))
20
{
21
	require_once($config_file);
22
}
23
24
if(!class_exists('admin', false)){
25
    include(WB_PATH.'/framework/class.admin.php');
26 1806 Luisehahne
    $admin = new admin('Admintools','admintools',false);
27 1805 Luisehahne
}
28
29 536 doc
require_once(WB_PATH.'/framework/functions.php');
30
31 1810 Luisehahne
$toolDir = (isset($_POST['tool']) && (trim($_POST['tool']) != '') ? trim($_POST['tool']) : '');
32
$toolDir = (isset($_GET['tool']) && (trim($_GET['tool']) != '') ? trim($_GET['tool']) : $toolDir);
33 1806 Luisehahne
$doSave  = (isset($_POST['save_settings']) || (isset($_POST['action']) && strtolower($_POST['action']) == 'save'));
34 1805 Luisehahne
35 1520 darkviper
// test for valid tool name
36
	if(preg_match('/^[a-z][a-z_\-0-9]{2,}$/i', $toolDir)) {
37
	// Check if tool is installed
38
		$sql = 'SELECT `name` FROM `'.TABLE_PREFIX.'addons` '.
39
		       'WHERE `type`=\'module\' AND `function`=\'tool\' '.
40
		              'AND `directory`=\''.$toolDir.'\'';
41
		if(($toolName = $database->get_one($sql))) {
42
		// create admin-object and print header if FTAN is NOT supported AND function 'save' is requested
43
			$admin_header = !(is_file(WB_PATH.'/modules/'.$toolDir.'/FTAN_SUPPORTED') && $doSave);
44
			$admin = new admin('admintools', 'admintools', $admin_header );
45
			if(!$doSave) {
46
			// show title if not function 'save' is requested
47
				print '<h4><a href="'.ADMIN_URL.'/admintools/index.php" '.
48
				      'title="'.$HEADING['ADMINISTRATION_TOOLS'].'">'.
49
				      $HEADING['ADMINISTRATION_TOOLS'].'</a>'.
50 1552 Luisehahne
					  '&nbsp;&raquo;&nbsp;'.$toolName.'</h4>'."\n";
51 1520 darkviper
			}
52
			// include modules tool.php
53
			require(WB_PATH.'/modules/'.$toolDir.'/tool.php');
54
			$admin->print_footer();
55 1711 Luisehahne
		} else {
56 1520 darkviper
		// no installed module found, jump to index.php of admintools
57 1711 Luisehahne
//			header('location: '.ADMIN_URL.'/admintools/index.php');
58
//			exit(0);
59
			$admin->send_header(ADMIN_URL.'/admintools/index.php');
60 1520 darkviper
		}
61
	}else {
62
	// invalid module name requested, jump to index.php of admintools
63 1711 Luisehahne
//		header('location: '.ADMIN_URL.'/admintools/index.php');
64
//		exit(0);
65
		$admin->send_header(ADMIN_URL.'/admintools/index.php');
66 1520 darkviper
	}