Project

General

Profile

1
<?php
2
/**
3
 * $Id: reload.php 928 2009-02-15 12:29:07Z doc $
4
 * Website Baker Add-On reload
5
 *
6
 * This file contains the function to update the template information from the
7
 * database with the ones stored in the template info.php files.
8
 *
9
 * LICENSE: GNU Lesser General Public License 3.0
10
 * 
11
 * @author		Christian Sommer
12
 * @copyright	(c) 2009
13
 * @license		http://www.gnu.org/copyleft/lesser.html
14
 * @version		0.1.0
15
 * @platform	Website Baker 2.7
16
 *
17
 * Website Baker Project <http://www.websitebaker.org/>
18
 * Copyright (C) 2004-2009, Ryan Djurovich
19
 *
20
 * Website Baker is free software; you can redistribute it and/or modify
21
 * it under the terms of the GNU General Public License as published by
22
 * the Free Software Foundation; either version 2 of the License, or
23
 * (at your option) any later version.
24
 *
25
 * Website Baker is distributed in the hope that it will be useful,
26
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
 * GNU General Public License for more details.
29
 *
30
 * You should have received a copy of the GNU General Public License
31
 * along with Website Baker; if not, write to the Free Software
32
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
33
*/
34

    
35
// include WB configuration file and WB admin class
36
require_once('../../config.php');
37
require_once('../../framework/class.admin.php');
38

    
39
// check user permissions for admintools (redirect users with wrong permissions)
40
$admin = new admin('Admintools', 'admintools', false, false);
41
if ($admin->get_permission('admintools') == false) die(header('Location: ../../index.php'));
42

    
43
// check if the referer URL if available
44
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 
45
	(isset($HTTP_SERVER_VARS['HTTP_REFERER']) ? $HTTP_SERVER_VARS['HTTP_REFERER'] : '');
46

    
47
// if referer is set, check if script was invoked from "admin/modules/index.php"
48
$required_url = '/admin/templates/index.php';
49
if ($referer != '' && (!(strpos($referer, $required_url) !== false || strpos($referer, $required_url) !== false))) 
50
	die(header('Location: ../../index.php'));
51

    
52
// include WB functions file
53
require_once(WB_PATH . '/framework/functions.php');
54

    
55
// load WB language file
56
require_once(WB_PATH . '/languages/' . LANGUAGE .'.php');
57

    
58
// create Admin object with admin header
59
$admin = new admin('Addons', '', true, false);
60
$js_back = ADMIN_URL . '/templates/index.php';
61

    
62
// reload template information from template "info.php" files
63
if ($handle = opendir(WB_PATH . '/templates/')) {
64
	// remove all templates from database
65
	$table = TABLE_PREFIX . 'addons';
66
	$sql = "DELETE FROM $table WHERE `type` = 'template'";
67
	$database->query($sql);
68

    
69
	// loop over all templates
70
	while(false !== ($file = readdir($handle))) {
71
		if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
72
			load_template(WB_PATH . '/templates/' . $file);
73
		}
74
	}
75
	closedir($handle);
76
	// output success message
77
	$admin->print_success($MESSAGE['ADDON']['TEMPLATES_RELOADED'], $js_back);
78

    
79
} else {
80
	// output error message
81
	$admin->print_error($MESSAGE['ADDON']['ERROR_RELOAD'], $js_back);
82
}
83

    
84
?>
(5-5/7)