| 11 |
/** ensure this file is being included by a parent file */ |
/** ensure this file is being included by a parent file */ |
| 12 |
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); |
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); |
| 13 |
|
|
|
// XML library |
|
|
require_once( $mosConfig_absolute_path . '/includes/domit/xml_domit_lite_include.php' ); |
|
| 14 |
require_once( $mainframe->getPath( 'admin_html' ) ); |
require_once( $mainframe->getPath( 'admin_html' ) ); |
| 15 |
require_once( $mainframe->getPath( 'class' ) ); |
require_once( $mainframe->getPath( 'class' ) ); |
| 16 |
|
|
| 46 |
break; |
break; |
| 47 |
|
|
| 48 |
case 'remove': |
case 'remove': |
| 49 |
removeElement( $classMap[$element], $option, $element, $client ); |
$uninstaller = $element.'_uninstall'; |
| 50 |
|
if (is_callable($uninstaller)) { |
| 51 |
|
$cid = mosGetParam($_REQUEST, 'cid', array(0)); |
| 52 |
|
if (is_array($cid) AND isset($cid[0])) { |
| 53 |
|
$result = $uninstaller ($cid[0], $option, $client); |
| 54 |
|
$msg = ''; |
| 55 |
|
} |
| 56 |
|
mosRedirect(returnTo($option, $element, $client), $result ? 'Success ' . $msg : 'Failed ' . $msg ); |
| 57 |
|
} |
| 58 |
|
else echo "Uninstaller not found for element [$element]"; |
| 59 |
break; |
break; |
| 60 |
|
|
| 61 |
default: |
default: |
| 64 |
if (file_exists( $path )) { |
if (file_exists( $path )) { |
| 65 |
require $path; |
require $path; |
| 66 |
} else { |
} else { |
| 67 |
echo T_('Installer not found for element')." [$element]"; |
echo "Installer not found for element [$element]"; |
| 68 |
} |
} |
| 69 |
break; |
break; |
| 70 |
} |
} |
| 71 |
} else { |
} |
| 72 |
echo T_('Installer not available for element')." [$element]"; |
else { |
| 73 |
|
echo "Installer not available for element [$element]"; |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
|
| 77 |
|
function returnTo ($option, $element, $client) { |
| 78 |
|
switch ($element) { |
| 79 |
|
case 'template': |
| 80 |
|
return "index2.php?option=com_templates&client=$client"; |
| 81 |
|
case 'language': |
| 82 |
|
return "index2.php?option=com_languages"; |
| 83 |
|
default: |
| 84 |
|
return "index2.php?option=$option&element=$element"; |
| 85 |
|
} |
| 86 |
} |
} |
| 87 |
|
|
| 88 |
/** |
/** |
| 97 |
|
|
| 98 |
// Check if file uploads are enabled |
// Check if file uploads are enabled |
| 99 |
if (!(bool)ini_get('file_uploads')) { |
if (!(bool)ini_get('file_uploads')) { |
| 100 |
HTML_installer::showInstallMessage( T_("The installer can't continue before file uploads are enabled. Please use the install from directory method."), |
HTML_installer::showInstallMessage( "The installer can't continue before file uploads are enabled. Please use the install from directory method.", |
| 101 |
'Installer - Error', $installer->returnTo( $option, $element, $client ) ); |
'Installer - Error', returnTo( $option, $element, $client ) ); |
| 102 |
exit(); |
exit(); |
| 103 |
} |
} |
| 104 |
|
|
| 105 |
// Check that the zlib is available |
// Check that the zlib is available |
| 106 |
if(!extension_loaded('zlib')) { |
if(!extension_loaded('zlib')) { |
| 107 |
HTML_installer::showInstallMessage( T_("The installer can't continue before zlib is installed"), |
HTML_installer::showInstallMessage( "The installer can't continue before zlib is installed", |
| 108 |
T_('Installer - Error'), $installer->returnTo( $option, $element, $client ) ); |
'Installer - Error', returnTo( $option, $element, $client ) ); |
| 109 |
exit(); |
exit(); |
| 110 |
} |
} |
| 111 |
|
|
| 112 |
$userfile = mosGetParam( $_FILES, 'userfile', null ); |
$userfile = mosGetParam( $_FILES, 'userfile', null ); |
| 113 |
|
|
| 114 |
if (!$userfile) { |
if (!$userfile) { |
| 115 |
HTML_installer::showInstallMessage( T_('No file selected'), T_('Upload new module - error'), |
HTML_installer::showInstallMessage( 'No file selected', 'Upload new module - error', |
| 116 |
$installer->returnTo( $option, $element, $client )); |
returnTo( $option, $element, $client )); |
| 117 |
exit(); |
exit(); |
| 118 |
} |
} |
| 119 |
|
|
| 123 |
$resultdir = uploadFile( $userfile['tmp_name'], $userfile['name'], $msg ); |
$resultdir = uploadFile( $userfile['tmp_name'], $userfile['name'], $msg ); |
| 124 |
|
|
| 125 |
if ($resultdir !== false) { |
if ($resultdir !== false) { |
| 126 |
if (!$installer->upload( $userfile['name'] )) { |
if (!$installer->extractArchive( $userfile['name'] )) { |
| 127 |
HTML_installer::showInstallMessage( $installer->getError(), T_('Upload').' '.$element.' - '.T_('Upload Failed'), |
HTML_installer::showInstallMessage( $installer->getError(), 'Upload '.$element.' - Upload Failed', |
| 128 |
$installer->returnTo( $option, $element, $client ) ); |
returnTo( $option, $element, $client ) ); |
| 129 |
} |
} |
| 130 |
$ret = $installer->install(); |
$ret = $installer->install(); |
| 131 |
|
|
| 132 |
HTML_installer::showInstallMessage( $installer->getError(), 'Upload '.$element.' - '.($ret ? T_('Success') : T_('Failed')), |
HTML_installer::showInstallMessage( $installer->getError(), 'Upload '.$element.' - '.($ret ? 'Success' : 'Failed'), |
| 133 |
$installer->returnTo( $option, $element, $client ) ); |
returnTo( $option, $element, $client ) ); |
| 134 |
cleanupInstall( $userfile['name'], $installer->unpackDir() ); |
$installer->cleanUpInstall(); |
| 135 |
} else { |
} else { |
| 136 |
HTML_installer::showInstallMessage( $msg, T_('Upload').' '.$element.' - '.T_('Upload Error'), |
HTML_installer::showInstallMessage( $msg, 'Upload '.$element.' - Upload Error', |
| 137 |
$installer->returnTo( $option, $element, $client ) ); |
$installer->returnTo( $option, $element, $client ) ); |
| 138 |
} |
} |
| 139 |
} |
} |
| 146 |
$userfile = mosGetParam( $_REQUEST, 'userfile', '' ); |
$userfile = mosGetParam( $_REQUEST, 'userfile', '' ); |
| 147 |
|
|
| 148 |
if (!$userfile) { |
if (!$userfile) { |
| 149 |
mosRedirect( "index2.php?option=$option&element=module", T_("Please select a directory") ); |
mosRedirect( "index2.php?option=$option&element=module", "Please select a directory" ); |
| 150 |
} |
} |
| 151 |
|
|
| 152 |
$installer = new $installerClass(); |
$installer = new $installerClass(); |
| 157 |
} |
} |
| 158 |
|
|
| 159 |
$ret = $installer->install( $path ); |
$ret = $installer->install( $path ); |
| 160 |
HTML_installer::showInstallMessage( $installer->getError(), T_('Upload new').' '.$element.' - '.($ret ? T_('Success') : T_('Error')), |
HTML_installer::showInstallMessage( $installer->getError(), 'Upload new '.$element.' - '.($ret ? 'Success' : 'Error'), |
| 161 |
$installer->returnTo( $option, $element, $client ) ); |
returnTo( $option, $element, $client ) ); |
| 162 |
} |
} |
| 163 |
/** |
/** |
| 164 |
* |
* |
| 178 |
|
|
| 179 |
$msg = $installer->getError(); |
$msg = $installer->getError(); |
| 180 |
|
|
| 181 |
mosRedirect( $installer->returnTo( $option, $element, $client ), $result ? T_('Success').' ' . $msg : T_('Failed').' '. $msg ); |
mosRedirect( returnTo( $option, $element, $client ), $result ? 'Success ' . $msg : 'Failed ' . $msg ); |
| 182 |
} |
} |
| 183 |
/** |
/** |
| 184 |
* @param string The name of the php (temporary) uploaded file |
* @param string The name of the php (temporary) uploaded file |
| 195 |
if (mosChmod( $baseDir . $userfile_name )) { |
if (mosChmod( $baseDir . $userfile_name )) { |
| 196 |
return true; |
return true; |
| 197 |
} else { |
} else { |
| 198 |
$msg = T_('Failed to change the permissions of the uploaded file.'); |
$msg = 'Failed to change the permissions of the uploaded file.'; |
| 199 |
} |
} |
| 200 |
} else { |
} else { |
| 201 |
$msg = T_('Failed to move uploaded file to <code>/media</code> directory.'); |
$msg = 'Failed to move uploaded file to <code>/media</code> directory.'; |
| 202 |
} |
} |
| 203 |
} else { |
} else { |
| 204 |
$msg = T_('Upload failed as <code>/media</code> directory is not writable.'); |
$msg = 'Upload failed as <code>/media</code> directory is not writable.'; |
| 205 |
} |
} |
| 206 |
} else { |
} else { |
| 207 |
$msg = T_('Upload failed as <code>/media</code> directory does not exist.'); |
$msg = 'Upload failed as <code>/media</code> directory does not exist.'; |
| 208 |
|
} |
| 209 |
|
return false; |
| 210 |
|
} |
| 211 |
|
|
| 212 |
|
/** |
| 213 |
|
* Component uninstall method |
| 214 |
|
* @param int The id of the module |
| 215 |
|
* @param string The URL option |
| 216 |
|
* @param int The client id |
| 217 |
|
*/ |
| 218 |
|
function component_uninstall( $cid, $option, $client=0 ) { |
| 219 |
|
$database = mamboDatabase::getInstance(); |
| 220 |
|
$sql = "SELECT * FROM #__components WHERE id=$cid"; |
| 221 |
|
$database->setQuery($sql); |
| 222 |
|
if (!$database->loadObject( $row )) { |
| 223 |
|
HTML_installer::showInstallMessage($database->stderr(true),'Uninstall - error', |
| 224 |
|
"index2.php?option=$option&element=component"); |
| 225 |
|
exit(); |
| 226 |
|
} |
| 227 |
|
if ($row->iscore) { |
| 228 |
|
die('Is core component - may not be deleted'); |
| 229 |
|
HTML_installer::showInstallMessage("Component $row->name is a core component, and can not be uninstalled.<br />You need to unpublish it if you don't want to use it", 'Uninstall - error', |
| 230 |
|
"index2.php?option=$option&element=component"); |
| 231 |
|
exit(); |
| 232 |
|
} |
| 233 |
|
// Try to find the XML file |
| 234 |
|
$here = mosPathName( mamboCore::get('mosConfig_absolute_path').'/administrator/components/'.$row->option ); |
| 235 |
|
$filesindir = mosReadDirectory($here, '.xml$'); |
| 236 |
|
if (count($filesindir) > 0) { |
| 237 |
|
foreach ($filesindir as $file) { |
| 238 |
|
$parser = new mosUninstallXML ($here.$file); |
| 239 |
|
$parser->uninstall(); |
| 240 |
|
if ($parser->terminalError) { |
| 241 |
|
var_dump ($parser->errors); |
| 242 |
|
return false; |
| 243 |
|
} |
| 244 |
|
} |
| 245 |
|
} |
| 246 |
|
else { |
| 247 |
|
// no XML file |
| 248 |
|
return false; |
| 249 |
|
/* |
| 250 |
|
HTML_installer::showInstallMessage( 'Could not find XML Setup file in '.$mosConfig_absolute_path.'/administrator/components/'.$row->option, |
| 251 |
|
'Uninstall - error', $option, 'component' ); |
| 252 |
|
exit(); |
| 253 |
|
*/ |
| 254 |
|
} |
| 255 |
|
return true; |
| 256 |
|
} |
| 257 |
|
|
| 258 |
|
/** |
| 259 |
|
* Module uninstall method |
| 260 |
|
* @param int The id of the module |
| 261 |
|
* @param string The URL option |
| 262 |
|
* @param int The client id |
| 263 |
|
*/ |
| 264 |
|
function module_uninstall( $id, $option, $client=0 ) { |
| 265 |
|
$database = mamboDatabase::getInstance(); |
| 266 |
|
$mosConfig_absolute_path = mamboCore::get('mosConfig_absolute_path'); |
| 267 |
|
$query = "SELECT module, iscore, client_id FROM #__modules WHERE id = '$id'"; |
| 268 |
|
$database->setQuery( $query ); |
| 269 |
|
$database->loadObject( $row ); |
| 270 |
|
if ($row->iscore) { |
| 271 |
|
HTML_installer::showInstallMessage( $row->title .'is a core module, and can not be uninstalled.<br />You need to unpublish it if you don\'t want to use it', 'Uninstall - error', returnTo( $option, 'module', $row->client_id ? '' : 'admin' ) ); |
| 272 |
|
exit(); |
| 273 |
|
} |
| 274 |
|
$query = "DELETE FROM #__modules_menu WHERE moduleid=$id"; |
| 275 |
|
$database->setQuery( $query ); |
| 276 |
|
if (!$database->query()) { |
| 277 |
|
$msg = $database->stderr; |
| 278 |
|
die( $msg ); |
| 279 |
|
} |
| 280 |
|
if ( $row->client_id ) $basepath = $mosConfig_absolute_path . '/administrator/modules/'; |
| 281 |
|
else $basepath = $mosConfig_absolute_path . '/modules/'; |
| 282 |
|
$xmlfile = $basepath . $row->module . '.xml'; |
| 283 |
|
$parser = new mosUninstallXML ($xmlfile); |
| 284 |
|
$parser->uninstall(); |
| 285 |
|
if ($parser->terminalError) { |
| 286 |
|
var_dump($parser->errors); |
| 287 |
|
die('Uninstall failed'); |
| 288 |
|
} |
| 289 |
|
return true; |
| 290 |
|
} |
| 291 |
|
|
| 292 |
|
/** |
| 293 |
|
* Mambot install method |
| 294 |
|
* @param int The id of the module |
| 295 |
|
* @param string The URL option |
| 296 |
|
* @param int The client id |
| 297 |
|
*/ |
| 298 |
|
function mambot_uninstall( $id, $option, $client=0 ) { |
| 299 |
|
$database = mamboDatabase::getInstance(); |
| 300 |
|
$mosConfig_absolute_path = mamboCore::get('mosConfig_absolute_path'); |
| 301 |
|
$database->setQuery( "SELECT name, folder, element, iscore FROM #__mambots WHERE id = '$id'" ); |
| 302 |
|
$database->loadObject( $row ); |
| 303 |
|
if ($database->getErrorNum()) { |
| 304 |
|
HTML_installer::showInstallMessage( $database->stderr(), 'Uninstall - error', |
| 305 |
|
returnTo( $option, 'mambot', $client ) ); |
| 306 |
|
exit(); |
| 307 |
|
} |
| 308 |
|
if ($row == null) { |
| 309 |
|
HTML_installer::showInstallMessage( 'Invalid object id', 'Uninstall - error', |
| 310 |
|
returnTo( $option, 'mambot', $client ) ); |
| 311 |
|
exit(); |
| 312 |
|
} |
| 313 |
|
if (trim( $row->folder ) == '') { |
| 314 |
|
HTML_installer::showInstallMessage( 'Folder field empty, cannot remove files', 'Uninstall - error', |
| 315 |
|
returnTo( $option, 'mambot', $client ) ); |
| 316 |
|
exit(); |
| 317 |
} |
} |
| 318 |
|
$xmlfile = $mosConfig_absolute_path.'/mambots/'.$row->folder.'/'.$row->element.'.xml'; |
| 319 |
|
$parser = new mosUninstallXML ($xmlfile); |
| 320 |
|
$parser->uninstall(); |
| 321 |
|
if ($parser->terminalError) { |
| 322 |
|
var_dump($parser->errors); |
| 323 |
|
die('Uninstall failed'); |
| 324 |
|
} |
| 325 |
|
return true; |
| 326 |
|
} |
| 327 |
|
|
| 328 |
|
/** |
| 329 |
|
* Template uninstall method |
| 330 |
|
* @param int The id of the module |
| 331 |
|
* @param string The URL option |
| 332 |
|
* @param int The client id |
| 333 |
|
*/ |
| 334 |
|
function template_uninstall( $id, $option, $client=0 ) { |
| 335 |
|
$mosConfig_absolute_path = mamboCore::get('mosConfig_absolute_path'); |
| 336 |
|
// Delete directories |
| 337 |
|
$path = mosPathName($mosConfig_absolute_path |
| 338 |
|
. ($client == 'admin' ? '/administrator' : '' ) |
| 339 |
|
. '/templates/' . $id); |
| 340 |
|
$filesindir = mosReadDirectory($path, '.xml$'); |
| 341 |
|
if (count($filesindir) > 0) { |
| 342 |
|
foreach ($filesindir as $file) { |
| 343 |
|
$parser = new mosUninstallXML ($path.$file); |
| 344 |
|
$parser->uninstall(); |
| 345 |
|
if ($parser->terminalError) { |
| 346 |
|
var_dump ($parser->errors); |
| 347 |
return false; |
return false; |
| 348 |
} |
} |
| 349 |
|
} |
| 350 |
|
} |
| 351 |
|
else { |
| 352 |
|
// no XML - just delete the template directory |
| 353 |
|
$tdir = new mosDirectory($path); |
| 354 |
|
$tdir->deleteAll(); |
| 355 |
|
} |
| 356 |
|
return true; |
| 357 |
|
} |
| 358 |
|
|
| 359 |
|
/** |
| 360 |
|
* Language uninstall method |
| 361 |
|
* @param int The id of the module |
| 362 |
|
* @param string The URL option |
| 363 |
|
* @param int The client id |
| 364 |
|
*/ |
| 365 |
|
function language_uninstall( $id, $option, $client=0 ) { |
| 366 |
|
$id = str_replace( array( '\\', '/' ), '', $id ); |
| 367 |
|
$basepath = mamboCore::get('mosConfig_absolute_path').'/language/'; |
| 368 |
|
$xmlfile = $basepath . $id . '.xml'; |
| 369 |
|
// see if there is an xml install file, must be same name as element |
| 370 |
|
if (file_exists( $xmlfile )) { |
| 371 |
|
$parser = new mosUninstallXML ($xmlfile); |
| 372 |
|
$parser->uninstall(); |
| 373 |
|
if ($parser->terminalError) { |
| 374 |
|
var_dump($parser->errors); |
| 375 |
|
die('Uninstall failed'); |
| 376 |
|
} |
| 377 |
|
return true; |
| 378 |
|
} |
| 379 |
|
else { |
| 380 |
|
HTML_installer::showInstallMessage( 'Language id empty, cannot remove files', 'Uninstall - error', "index2.php?option=com_languages"); |
| 381 |
|
exit(); |
| 382 |
|
} |
| 383 |
|
} |
| 384 |
|
|
| 385 |
|
|
| 386 |
?> |
?> |