| 1 |
1425
|
Luisehahne
|
<?php
|
| 2 |
|
|
/**
|
| 3 |
|
|
*
|
| 4 |
1643
|
darkviper
|
* @category WBCore
|
| 5 |
|
|
* @package WBCore_addons
|
| 6 |
|
|
* @author Werner v.d.Decken
|
| 7 |
|
|
* @copyright Website Baker Org. e.V.
|
| 8 |
1425
|
Luisehahne
|
* @link http://www.websitebaker2.org/
|
| 9 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
| 10 |
1643
|
darkviper
|
* @revision $Revision$
|
| 11 |
1457
|
Luisehahne
|
* @filesource $HeadURL$
|
| 12 |
|
|
* @lastmodified $Date$
|
| 13 |
1425
|
Luisehahne
|
*/
|
| 14 |
|
|
|
| 15 |
|
|
/**
|
| 16 |
1643
|
darkviper
|
* 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 |
1425
|
Luisehahne
|
*/
|
| 20 |
1643
|
darkviper
|
function ReloadAddonLoop($sType)
|
| 21 |
|
|
{
|
| 22 |
|
|
global $database;
|
| 23 |
1669
|
darkviper
|
$sql = 'DELETE FROM `'.TABLE_PREFIX.'addons` WHERE `type`=\''.$sType.'\'';
|
| 24 |
1643
|
darkviper
|
try{
|
| 25 |
1669
|
darkviper
|
if(!$database->query($sql)) {
|
| 26 |
|
|
throw new Exception('database error');
|
| 27 |
|
|
}
|
| 28 |
1643
|
darkviper
|
$oIterator = new DirectoryIterator(WB_PATH.'/'.$sType.'s');
|
| 29 |
|
|
$_Function = 'load_'.$sType;
|
| 30 |
|
|
foreach ($oIterator as $oFileinfo) {
|
| 31 |
|
|
if( ( $oFileinfo->isFile() &&
|
| 32 |
|
|
$sType == 'language' &&
|
| 33 |
|
|
preg_match('/^([A-Z]{2}.php)/', $oFileinfo->getBasename())
|
| 34 |
|
|
) ||
|
| 35 |
|
|
($oFileinfo->isDir() && $sType != 'language')
|
| 36 |
|
|
)
|
| 37 |
|
|
{
|
| 38 |
|
|
if(substr($oFileinfo->getBasename(), 0,1) != '.') {
|
| 39 |
|
|
$_Function($oFileinfo->getPathname());
|
| 40 |
|
|
}
|
| 41 |
|
|
}
|
| 42 |
|
|
}
|
| 43 |
|
|
}catch(Exception $e) {
|
| 44 |
|
|
return false;
|
| 45 |
|
|
}
|
| 46 |
|
|
return true;
|
| 47 |
|
|
}
|
| 48 |
1425
|
Luisehahne
|
/**
|
| 49 |
|
|
* check if user has permissions to access this file
|
| 50 |
|
|
*/
|
| 51 |
1643
|
darkviper
|
// include all needed core files and check permission
|
| 52 |
|
|
require_once('../../config.php');
|
| 53 |
|
|
require_once('../../framework/class.admin.php');
|
| 54 |
|
|
$aMsg = array();
|
| 55 |
|
|
$aErrors = array();
|
| 56 |
1425
|
Luisehahne
|
// check user permissions for admintools (redirect users with wrong permissions)
|
| 57 |
1643
|
darkviper
|
$admin = new admin('Admintools', 'admintools', false, false);
|
| 58 |
|
|
if ($admin->get_permission('admintools'))
|
| 59 |
|
|
{
|
| 60 |
|
|
require_once(WB_PATH . '/framework/functions.php');
|
| 61 |
|
|
require_once(WB_PATH . '/languages/' . LANGUAGE .'.php');
|
| 62 |
|
|
// recreate Admin object without admin header
|
| 63 |
|
|
$admin = new admin('Addons', '', false, false);
|
| 64 |
|
|
$js_back = ADMIN_URL . '/addons/index.php?advanced';
|
| 65 |
|
|
// check transaction
|
| 66 |
|
|
if ($admin->checkFTAN())
|
| 67 |
|
|
{
|
| 68 |
|
|
// start the selected action
|
| 69 |
|
|
if(isset($_POST['cmdCopyTheme']))
|
| 70 |
|
|
{
|
| 71 |
|
|
$sNewTheme = (isset($_POST['ThNewTheme']) ? $_POST['ThNewTheme'] : '');
|
| 72 |
|
|
require(dirname(__FILE__).'/CopyTheme.php');
|
| 73 |
|
|
$ct = new CopyTheme();
|
| 74 |
|
|
$ct->execute(THEME_PATH, $sNewTheme);
|
| 75 |
|
|
if($ct->isError()) {
|
| 76 |
|
|
$aErrors[] = $ct->getError();
|
| 77 |
|
|
}else {
|
| 78 |
|
|
$aMsg[] = $TEXT['THEME_COPY_CURRENT'].' :: '.$MESSAGE['GENERIC_COMPARE'];
|
| 79 |
1425
|
Luisehahne
|
}
|
| 80 |
1643
|
darkviper
|
unset($ct);
|
| 81 |
|
|
// ---------------------------
|
| 82 |
|
|
}elseif(isset($_POST['cmdCopyTemplate']))
|
| 83 |
|
|
{
|
| 84 |
|
|
$aFileList = (isset($_POST['ThTemplate']) ? $_POST['ThTemplate'] : array());
|
| 85 |
|
|
require(dirname(__FILE__).'/CopyThemeHtt.php');
|
| 86 |
|
|
$x = CopyThemeHtt::doImport($aFileList);
|
| 87 |
|
|
if(is_null($x)) {
|
| 88 |
|
|
$aMsg[] = $TEXT['THEME_IMPORT_HTT'].' :: '.$MESSAGE['GENERIC_COMPARE'];
|
| 89 |
|
|
}else {
|
| 90 |
|
|
$aErrors = array_merge($aErrors, $x);
|
| 91 |
1425
|
Luisehahne
|
}
|
| 92 |
1643
|
darkviper
|
// ---------------------------
|
| 93 |
|
|
}elseif(isset($_POST['cmdReload']))
|
| 94 |
|
|
{
|
| 95 |
|
|
$aReloadType = (isset($_POST['reload']) && is_array($_POST['reload'])) ? $_POST['reload'] : array();
|
| 96 |
|
|
foreach($aReloadType as $sType) {
|
| 97 |
1669
|
darkviper
|
$sType = rtrim($sType, 's');
|
| 98 |
1643
|
darkviper
|
switch($sType) {
|
| 99 |
1669
|
darkviper
|
case 'module':
|
| 100 |
|
|
case 'template':
|
| 101 |
|
|
case 'language':
|
| 102 |
|
|
// reload all addons from given type
|
| 103 |
|
|
if(ReloadAddonLoop($sType)) {
|
| 104 |
|
|
$aMsg[] = $MESSAGE['ADDON_'.strtoupper($sType).'S_RELOADED'];
|
| 105 |
1643
|
darkviper
|
}else {
|
| 106 |
|
|
$aErrors[] = $MESSAGE['ADDON_ERROR_RELOAD'];
|
| 107 |
|
|
}
|
| 108 |
|
|
break;
|
| 109 |
|
|
default:
|
| 110 |
|
|
$aErrors[] = $MESSAGE['GENERIC_NOT_COMPARE'].' ['.$sType.']';
|
| 111 |
|
|
break;
|
| 112 |
1425
|
Luisehahne
|
}
|
| 113 |
|
|
}
|
| 114 |
1643
|
darkviper
|
}else {
|
| 115 |
|
|
// ---------------------------
|
| 116 |
|
|
$aErrors[] = $MESSAGE['ADDON_ERROR_RELOAD'];
|
| 117 |
1425
|
Luisehahne
|
}
|
| 118 |
1643
|
darkviper
|
}else { // invalid FTAN
|
| 119 |
|
|
$aErrors[] = $MESSAGE['GENERIC_SECURITY_ACCESS'];
|
| 120 |
|
|
}
|
| 121 |
|
|
}else { // no permission
|
| 122 |
|
|
$aErrors[] = $MESSAGE['ADMIN_INSUFFICIENT_PRIVELLIGES'];
|
| 123 |
1425
|
Luisehahne
|
}
|
| 124 |
1643
|
darkviper
|
if(sizeof($aErrors) > 0) {
|
| 125 |
|
|
// output error message
|
| 126 |
|
|
$admin->print_header();
|
| 127 |
|
|
$admin->print_error(implode('<br />', $aErrors), $js_back);
|
| 128 |
|
|
}else {
|
| 129 |
1425
|
Luisehahne
|
// output success message
|
| 130 |
1643
|
darkviper
|
$admin->print_header();
|
| 131 |
|
|
$admin->print_success(implode('<br />', $aMsg), $js_back);
|
| 132 |
|
|
$admin->print_footer();
|
| 133 |
|
|
}
|