Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        WBCore
5
 * @package         WBCore_addons
6
 * @author          Werner v.d.Decken
7
 * @copyright       Website Baker Org. e.V.
8
 * @link			http://www.websitebaker2.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @revision        $Revision: 1643 $
11
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/addons/reload.php $
12
 * @lastmodified    $Date: 2012-03-22 16:30:03 +0100 (Thu, 22 Mar 2012) $
13
 */
14

    
15
/**
16
 * loop through all resource directories of one type and reload the resources
17
 * @param string $sType type of resource ( module / template / language )
18
 * @return bool
19
 */
20
	function ReloadAddonLoop($sType)
21
	{
22
		global $database;
23
		$database->query('DELETE FROM `'.TABLE_PREFIX.'addons` WHERE `type`=\''.$sType.'\'');
24
		try{
25
			$oIterator = new DirectoryIterator(WB_PATH.'/'.$sType.'s');
26
			$_Function = 'load_'.$sType;
27
			foreach ($oIterator as $oFileinfo) {
28
				if( ( $oFileinfo->isFile() &&
29
					   $sType == 'language' &&
30
					   preg_match('/^([A-Z]{2}.php)/', $oFileinfo->getBasename())
31
					) ||
32
				    ($oFileinfo->isDir() && $sType != 'language')
33
				  )
34
				{
35
					if(substr($oFileinfo->getBasename(), 0,1) != '.') {
36
						$_Function($oFileinfo->getPathname());
37
					}
38
				}
39
			}
40
		}catch(Exception $e) {
41
			return false;
42
		}
43
		return true;
44
	}
45
/**
46
 * check if user has permissions to access this file
47
 */
48
// include all needed core files and check permission
49
	require_once('../../config.php');
50
	require_once('../../framework/class.admin.php');
51
	$aMsg = array();
52
	$aErrors = array();
53
// check user permissions for admintools (redirect users with wrong permissions)
54
	$admin = new admin('Admintools', 'admintools', false, false);
55
	if ($admin->get_permission('admintools'))
56
	{
57
		require_once(WB_PATH . '/framework/functions.php');
58
		require_once(WB_PATH . '/languages/' . LANGUAGE .'.php');
59
	// recreate Admin object without admin header
60
		$admin = new admin('Addons', '', false, false);
61
		$js_back = ADMIN_URL . '/addons/index.php?advanced';
62
	// check transaction
63
		if ($admin->checkFTAN())
64
		{
65
		// start the selected action
66
			if(isset($_POST['cmdCopyTheme']))
67
			{
68
				$sNewTheme = (isset($_POST['ThNewTheme']) ? $_POST['ThNewTheme'] : '');
69
				require(dirname(__FILE__).'/CopyTheme.php');
70
				$ct = new CopyTheme();
71
				$ct->execute(THEME_PATH, $sNewTheme);
72
				if($ct->isError()) {
73
					$aErrors[] = $ct->getError();
74
				}else {
75
					$aMsg[] = $TEXT['THEME_COPY_CURRENT'].' :: '.$MESSAGE['GENERIC_COMPARE'];
76
				}
77
				unset($ct);
78
		// ---------------------------
79
			}elseif(isset($_POST['cmdCopyTemplate']))
80
			{
81
				$aFileList = (isset($_POST['ThTemplate']) ? $_POST['ThTemplate'] : array());
82
				require(dirname(__FILE__).'/CopyThemeHtt.php');
83
				$x = CopyThemeHtt::doImport($aFileList);
84
				if(is_null($x)) {
85
					$aMsg[] = $TEXT['THEME_IMPORT_HTT'].' :: '.$MESSAGE['GENERIC_COMPARE'];
86
				}else {
87
					$aErrors = array_merge($aErrors, $x);
88
				}
89
		// ---------------------------
90
			}elseif(isset($_POST['cmdReload']))
91
			{
92
				$aReloadType = (isset($_POST['reload']) && is_array($_POST['reload'])) ? $_POST['reload'] : array();
93
				foreach($aReloadType as $sType) {
94
					switch($sType) {
95
						case 'modules':
96
						// reload all modules
97
							if(ReloadAddonLoop('module')) {
98
								$aMsg[] = $MESSAGE['ADDON_MODULES_RELOADED'];
99
							}else {
100
								$aErrors[] = $MESSAGE['ADDON_ERROR_RELOAD'];
101
							}
102
							break;
103
						case 'templates':
104
						// reload all templates
105
							if(ReloadAddonLoop('template')) {
106
								$aMsg[] = $MESSAGE['ADDON_TEMPLATES_RELOADED'];
107
							}else {
108
								$aErrors[] = $MESSAGE['ADDON_ERROR_RELOAD'];
109
							}
110
							break;
111
						case 'languages':
112
						// reload all languages
113
							if(ReloadAddonLoop('language')) {
114
								$aMsg[] = $MESSAGE['ADDON_LANGUAGES_RELOADED'];
115
							}else {
116
								$aErrors[] = $MESSAGE['ADDON_ERROR_RELOAD'];
117
							}
118
							break;
119
						default:
120
							$aErrors[] = $MESSAGE['GENERIC_NOT_COMPARE'].' ['.$sType.']';
121
							break;
122
					}
123
				}
124
			}else {
125
		// ---------------------------
126
				$aErrors[] = $MESSAGE['ADDON_ERROR_RELOAD'];
127
			}
128
		}else { // invalid FTAN
129
			$aErrors[] = $MESSAGE['GENERIC_SECURITY_ACCESS'];
130
		}
131
	}else { // no permission
132
		$aErrors[] = $MESSAGE['ADMIN_INSUFFICIENT_PRIVELLIGES'];
133
	}
134
	if(sizeof($aErrors) > 0)  {
135
// output error message
136
		$admin->print_header();
137
		$admin->print_error(implode('<br />', $aErrors), $js_back);
138
	}else {
139
// output success message
140
		$admin->print_header();
141
		$admin->print_success(implode('<br />', $aMsg), $js_back);
142
		$admin->print_footer();
143
	}
(4-4/4)