| 1 |
2
|
Manuela
|
<?php
|
| 2 |
|
|
/**
|
| 3 |
|
|
*
|
| 4 |
|
|
* @category admin
|
| 5 |
|
|
* @package modules
|
| 6 |
|
|
* @author WebsiteBaker Project
|
| 7 |
|
|
* @copyright Ryan Djurovich
|
| 8 |
|
|
* @copyright WebsiteBaker Org. e.V.
|
| 9 |
|
|
* @link http://websitebaker.org/
|
| 10 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
| 11 |
|
|
* @platform WebsiteBaker 2.8.3
|
| 12 |
|
|
* @requirements PHP 5.3.6 and higher
|
| 13 |
|
|
* @version $Id$
|
| 14 |
|
|
* @filesource $HeadURL$
|
| 15 |
|
|
* @lastmodified $Date$
|
| 16 |
|
|
*
|
| 17 |
|
|
*/
|
| 18 |
|
|
|
| 19 |
|
|
// Print admin header
|
| 20 |
|
|
if ( !defined( 'WB_PATH' ) ){ require( dirname(dirname((__DIR__))).'/config.php' ); }
|
| 21 |
|
|
if ( !class_exists('admin', false) ) { require(WB_PATH.'/framework/class.admin.php'); }
|
| 22 |
|
|
$admin = new admin('Addons', 'modules');
|
| 23 |
|
|
|
| 24 |
|
|
// Setup template object, parse vars to it, then parse it
|
| 25 |
|
|
// Create new template object
|
| 26 |
|
|
$template = new Template(dirname($admin->correct_theme_source('modules.htt')));
|
| 27 |
|
|
// $template->debug = true;
|
| 28 |
|
|
$template->set_file ('page', 'modules.htt');
|
| 29 |
|
|
$template->set_block('page', 'main_block', 'main');
|
| 30 |
|
|
|
| 31 |
|
|
$template->set_block('main_block', 'module_install_block', 'module_install');
|
| 32 |
|
|
// Insert values into module list
|
| 33 |
|
|
$template->set_block('main_block', 'module_detail_block', 'module_detail');
|
| 34 |
|
|
$template->set_block('module_detail_block', 'module_detail_select_block', 'module_detail_select');
|
| 35 |
|
|
|
| 36 |
|
|
$template->set_block('main_block', 'module_uninstall_block', 'module_uninstall');
|
| 37 |
|
|
$template->set_block('module_uninstall_block', 'module_uninstall_select_block', 'module_uninstall_select');
|
| 38 |
|
|
$aPreventFromUninstall = array ( 'captcha_control', 'jsadmin', 'output_filter', 'wysiwyg', 'menu_link' );
|
| 39 |
|
|
|
| 40 |
|
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` '
|
| 41 |
|
|
. 'WHERE `type`=\'module\' '
|
| 42 |
|
|
. 'ORDER BY `name`'
|
| 43 |
|
|
. '';
|
| 44 |
|
|
if($oAddons = $database->query($sql)) {
|
| 45 |
|
|
while ($aAddon = $oAddons->fetchRow( MYSQLI_ASSOC )) {
|
| 46 |
|
|
if (!$admin->get_permission( $aAddon['directory'], 'module' )) { continue; }
|
| 47 |
|
|
$aAddonIdKey = $admin->getIDKEY($aAddon['addon_id']);
|
| 48 |
|
|
$sAddsonsPath = WB_PATH.'/modules/'.$aAddon['directory'];
|
| 49 |
|
|
$template->set_var('VALUE', $aAddonIdKey);
|
| 50 |
|
|
$template->set_var('NAME', $aAddon['name']);
|
| 51 |
|
|
$template->parse('module_detail_select', 'module_detail_select_block', true);
|
| 52 |
|
|
if (is_readable($sAddsonsPath.'/uninstall.php') && is_readable($sAddsonsPath . '/info.php')) {
|
| 53 |
|
|
if (!preg_match('/'.$aAddon['directory'].'/si', implode('|', $aPreventFromUninstall))) {
|
| 54 |
|
|
$template->set_var('UNINSTALL_VALUE', $aAddonIdKey);
|
| 55 |
|
|
$template->set_var('UNINSTALL_NAME', $aAddon['name']);
|
| 56 |
|
|
$template->parse('module_uninstall_select', 'module_uninstall_select_block', true);
|
| 57 |
|
|
}
|
| 58 |
|
|
}
|
| 59 |
|
|
}
|
| 60 |
|
|
}
|
| 61 |
|
|
|
| 62 |
|
|
$show_block = false;
|
| 63 |
|
|
$template->set_block('main_block', 'module_advanced_block', 'module_advanced');
|
| 64 |
|
|
$template->set_block('module_advanced_block', 'manuell_install_block', 'manuell_install');
|
| 65 |
|
|
$template->set_block('module_advanced_block', 'manuell_upgrade_block', 'manuell_upgrade');
|
| 66 |
|
|
$template->set_block('module_advanced_block', 'manuell_uninstall_block', 'manuell_uninstall');
|
| 67 |
|
|
// Insert modules which includes a install.php file to install list
|
| 68 |
|
|
$template->set_block('manuell_install_block', 'manuell_install_select_block', 'manuell_install_select');
|
| 69 |
|
|
$module_files = glob(WB_PATH . '/modules/*', GLOB_ONLYDIR|GLOB_NOSORT );
|
| 70 |
|
|
natcasesort($module_files);
|
| 71 |
|
|
foreach ($module_files as $index => $sAddsonsPath)
|
| 72 |
|
|
{
|
| 73 |
|
|
if( !$admin->get_permission( basename($sAddsonsPath), 'module' )) { continue; }
|
| 74 |
|
|
if (is_dir($sAddsonsPath)) {
|
| 75 |
|
|
if (is_readable($sAddsonsPath . '/install.php') && is_readable($sAddsonsPath . '/info.php')) {
|
| 76 |
|
|
require $sAddsonsPath . '/info.php';
|
| 77 |
|
|
$show_block = true;
|
| 78 |
|
|
$AddonIdKey = $admin->getIDKEY(basename($sAddsonsPath),'');
|
| 79 |
|
|
$template->set_var('INSTALL_VISIBLE', '');
|
| 80 |
|
|
$template->set_var('INSTALL_VALUE', $AddonIdKey);
|
| 81 |
|
|
$template->set_var('INSTALL_NAME', ( @$module_name ?: basename($sAddsonsPath)) );
|
| 82 |
|
|
$template->parse('manuell_install_select', 'manuell_install_select_block', true);
|
| 83 |
|
|
} else {
|
| 84 |
|
|
// echo ''.basename($sAddsonsPath).'/install.php<br />';
|
| 85 |
|
|
}
|
| 86 |
|
|
} else {
|
| 87 |
|
|
unset($module_files[$index]);
|
| 88 |
|
|
}
|
| 89 |
|
|
}
|
| 90 |
|
|
$template->set_block('manuell_upgrade_block', 'manuell_upgrade_select_block', 'manuell_upgrade_select');
|
| 91 |
|
|
$template->set_block('manuell_uninstall_block', 'manuell_uninstall_select_block', 'manuell_uninstall_select');
|
| 92 |
|
|
$oAddons->rewind();
|
| 93 |
|
|
while ($aAddon = $oAddons->fetchRow( MYSQLI_ASSOC )) {
|
| 94 |
|
|
if( !$admin->get_permission( $aAddon['directory'], 'module' )) { continue; }
|
| 95 |
|
|
$aAddonIdKey = $admin->getIDKEY($aAddon['addon_id']);
|
| 96 |
|
|
$sAddsonsPath = WB_PATH.'/modules/'.$aAddon['directory'];
|
| 97 |
|
|
if (is_readable($sAddsonsPath.'/upgrade.php') && is_readable($sAddsonsPath . '/info.php')) {
|
| 98 |
|
|
$show_block = true;
|
| 99 |
|
|
$template->set_var('UPGRADE_VISIBLE', '');
|
| 100 |
|
|
$template->set_var('UPGRADE_VALUE', $aAddonIdKey);
|
| 101 |
|
|
$template->set_var('UPGRADE_NAME', $aAddon['name']);
|
| 102 |
|
|
$template->parse('manuell_upgrade_select', 'manuell_upgrade_select_block', true);
|
| 103 |
|
|
} else {
|
| 104 |
|
|
// echo ''.$sAddsonsPath.'/upgrade.php<br />';
|
| 105 |
|
|
}
|
| 106 |
|
|
if (is_readable($sAddsonsPath.'/uninstall.php') && is_readable($sAddsonsPath . '/info.php')) {
|
| 107 |
|
|
if (!preg_match('/'.$aAddon['directory'].'/si', implode('|', $aPreventFromUninstall))) {
|
| 108 |
|
|
$show_block = true;
|
| 109 |
|
|
$template->set_var('UNINSTALL_VISIBLE', '');
|
| 110 |
|
|
$template->set_var('UNINSTALL_VALUE', $aAddonIdKey);
|
| 111 |
|
|
$template->set_var('UNINSTALL_NAME', $aAddon['name']);
|
| 112 |
|
|
$template->parse('manuell_uninstall_select', 'manuell_uninstall_select_block', true);
|
| 113 |
|
|
}
|
| 114 |
|
|
} else {
|
| 115 |
|
|
// echo ''.$sAddsonsPath.'/uninstall.php<br />';
|
| 116 |
|
|
}
|
| 117 |
|
|
}
|
| 118 |
|
|
|
| 119 |
|
|
// Insert permissions values and show or hidden blocks
|
| 120 |
|
|
if($admin->get_permission('modules_install') != true) {
|
| 121 |
|
|
$template->set_block ('module_install', '');
|
| 122 |
|
|
$template->set_block ('manuell_install', '');
|
| 123 |
|
|
} else {
|
| 124 |
|
|
$template->parse('module_install', 'module_install_block', true);
|
| 125 |
|
|
$template->parse('manuell_install', 'manuell_install_block', true);
|
| 126 |
|
|
}
|
| 127 |
|
|
if($admin->get_permission('modules_uninstall') != true) {
|
| 128 |
|
|
$template->set_block ('module_uninstall', '');
|
| 129 |
|
|
$template->set_block ('manuell_uninstall', '');
|
| 130 |
|
|
} else {
|
| 131 |
|
|
$template->parse('module_uninstall', 'module_uninstall_block', true);
|
| 132 |
|
|
$template->parse('manuell_uninstall', 'manuell_uninstall_block', true);
|
| 133 |
|
|
}
|
| 134 |
|
|
if($admin->get_permission('modules_view') != true) {
|
| 135 |
|
|
$template->set_block('module_detail', '');
|
| 136 |
|
|
$template->set_block('manuell_upgrade', '');
|
| 137 |
|
|
} else {
|
| 138 |
|
|
$template->parse('module_detail', 'module_detail_block', true);
|
| 139 |
|
|
$template->parse('manuell_upgrade', 'manuell_upgrade_block', true);
|
| 140 |
|
|
}
|
| 141 |
|
|
// only show block if there is something to show
|
| 142 |
|
|
if(!$show_block || count($module_files) == 0 || !isset($_GET['advanced']) || $admin->get_permission('admintools') != true) {
|
| 143 |
|
|
$template->set_block('module_advanced', '');
|
| 144 |
|
|
} else {
|
| 145 |
|
|
$template->parse('module_advanced', 'module_advanced_block', true);
|
| 146 |
|
|
}
|
| 147 |
|
|
|
| 148 |
|
|
$template->set_block('main_block', 'addon_template_block', 'addon_template');
|
| 149 |
|
|
if($admin->get_permission('templates_view') != true) {
|
| 150 |
|
|
$template->set_block ('addon_template', '');
|
| 151 |
|
|
} else {
|
| 152 |
|
|
$template->parse('addon_template', 'addon_template_block', true);
|
| 153 |
|
|
}
|
| 154 |
|
|
|
| 155 |
|
|
$template->set_block('main_block', 'addon_language_block', 'addon_language');
|
| 156 |
|
|
if($admin->get_permission('languages_view') != true) {
|
| 157 |
|
|
$template->set_block ('addon_language', '');
|
| 158 |
|
|
} else {
|
| 159 |
|
|
$template->parse('addon_language', 'addon_language_block', true);
|
| 160 |
|
|
}
|
| 161 |
|
|
|
| 162 |
|
|
$template->set_block('main_block', 'addon_module_block', 'addon_module');
|
| 163 |
|
|
if($admin->get_permission('admintools') != true) {
|
| 164 |
|
|
$template->set_block ('addon_module', '');
|
| 165 |
|
|
} else {
|
| 166 |
|
|
$template->parse('addon_module', 'addon_module_block', true);
|
| 167 |
|
|
}
|
| 168 |
|
|
|
| 169 |
|
|
// Insert language headings
|
| 170 |
|
|
$template->set_var(array(
|
| 171 |
|
|
'HEADING_INSTALL_MODULE' => $HEADING['INSTALL_MODULE'],
|
| 172 |
|
|
'HEADING_UNINSTALL_MODULE' => $HEADING['UNINSTALL_MODULE'],
|
| 173 |
|
|
'OVERWRITE_NEWER_FILES' => $MESSAGE['ADDON_OVERWRITE_NEWER_FILES'],
|
| 174 |
|
|
'HEADING_MODULE_DETAILS' => $HEADING['MODULE_DETAILS'],
|
| 175 |
|
|
'HEADING_INVOKE_MODULE_FILES' => $HEADING['INVOKE_MODULE_FILES']
|
| 176 |
|
|
)
|
| 177 |
|
|
);
|
| 178 |
|
|
// insert urls
|
| 179 |
|
|
$template->set_var(array(
|
| 180 |
|
|
'ADMIN_URL' => ADMIN_URL,
|
| 181 |
|
|
'WB_URL' => WB_URL,
|
| 182 |
|
|
'THEME_URL' => THEME_URL,
|
| 183 |
|
|
'FTAN' => $admin->getFTAN()
|
| 184 |
|
|
)
|
| 185 |
|
|
);
|
| 186 |
|
|
// Insert language text and messages
|
| 187 |
|
|
$template->set_var(array(
|
| 188 |
|
|
'URL_TEMPLATES' => $admin->get_permission('templates') ? ADMIN_URL . '/templates/index.php' : '#',
|
| 189 |
|
|
'URL_LANGUAGES' => $admin->get_permission('languages') ? ADMIN_URL . '/languages/index.php' : '#',
|
| 190 |
|
|
'URL_ADVANCED' => $admin->get_permission('admintools') ? ADMIN_URL . '/modules/index.php?advanced' : '#',
|
| 191 |
|
|
'MENU_LANGUAGES' => $admin->get_permission('languages') ? $MENU['LANGUAGES'] : '   ',
|
| 192 |
|
|
'MENU_TEMPLATES' => $admin->get_permission('templates') ? $MENU['TEMPLATES'] : '   ',
|
| 193 |
|
|
'TEXT_ADVANCED' => $admin->get_permission('admintools') ? $TEXT['ADVANCED'] : '   ',
|
| 194 |
|
|
'TEXT_INSTALL' => $TEXT['INSTALL'],
|
| 195 |
|
|
'TEXT_UNINSTALL' => $TEXT['UNINSTALL'],
|
| 196 |
|
|
'TEXT_VIEW_DETAILS' => $TEXT['VIEW_DETAILS'],
|
| 197 |
|
|
'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
|
| 198 |
|
|
'TEXT_MANUAL_INSTALLATION' => $MESSAGE['ADDON_MANUAL_INSTALLATION'],
|
| 199 |
|
|
'TEXT_MANUAL_INSTALLATION_WARNING' => $MESSAGE['ADDON_MANUAL_INSTALLATION_WARNING'],
|
| 200 |
|
|
'TEXT_EXECUTE' => $TEXT['EXECUTE'],
|
| 201 |
|
|
'TEXT_FILE' => $TEXT['FILE']
|
| 202 |
|
|
)
|
| 203 |
|
|
);
|
| 204 |
|
|
|
| 205 |
|
|
// Parse template object
|
| 206 |
|
|
$template->parse('main', 'main_block', false);
|
| 207 |
|
|
$template->pparse('output', 'page');
|
| 208 |
|
|
|
| 209 |
|
|
// Print admin footer
|
| 210 |
|
|
$admin->print_footer();
|