| 46 |
installFromDirectory( $classMap[$element], $option, $element, $client ); |
installFromDirectory( $classMap[$element], $option, $element, $client ); |
| 47 |
break; |
break; |
| 48 |
|
|
| 49 |
|
case 'installfromurl': |
| 50 |
|
installFromUrl ($classMap[$element], $option, $element, $client); |
| 51 |
|
break; |
| 52 |
|
|
| 53 |
case 'remove': |
case 'remove': |
| 54 |
$uninstaller = $element.'_uninstall'; |
$uninstaller = $element.'_uninstall'; |
| 55 |
if (is_callable($uninstaller)) { |
if (is_callable($uninstaller)) { |
| 98 |
function uploadPackage( $installerClass, $option, $element, $client ) { |
function uploadPackage( $installerClass, $option, $element, $client ) { |
| 99 |
global $mainframe; |
global $mainframe; |
| 100 |
|
|
| 101 |
$installer = new $installerClass(); |
$installer =& new $installerClass(); |
| 102 |
|
|
| 103 |
// Check if file uploads are enabled |
// Check if file uploads are enabled |
| 104 |
if (!(bool)ini_get('file_uploads')) { |
if (!(bool)ini_get('file_uploads')) { |
| 151 |
$userfile = mosGetParam( $_REQUEST, 'userfile', '' ); |
$userfile = mosGetParam( $_REQUEST, 'userfile', '' ); |
| 152 |
|
|
| 153 |
if (!$userfile) { |
if (!$userfile) { |
| 154 |
mosRedirect( "index2.php?option=$option&element=module", T_("Please select a directory") ); |
mosRedirect( "index2.php?option=$option&element=module", T_('Please select a directory') ); |
| 155 |
} |
} |
| 156 |
|
|
| 157 |
$installer = new $installerClass(); |
$installer =& new $installerClass(); |
| 158 |
|
|
| 159 |
$path = mosPathName( $userfile ); |
$path = mosPathName( $userfile ); |
| 160 |
if (!is_dir( $path )) { |
if (!is_dir( $path )) { |
| 166 |
returnTo( $option, $element, $client ) ); |
returnTo( $option, $element, $client ) ); |
| 167 |
} |
} |
| 168 |
/** |
/** |
| 169 |
|
* Install a template from an HTTP URL |
| 170 |
|
* @param string The URL option |
| 171 |
|
*/ |
| 172 |
|
function installFromUrl( $installerClass, $option, $element, $client ) { |
| 173 |
|
$userfile = mosGetParam( $_REQUEST, 'userurl', '' ); |
| 174 |
|
|
| 175 |
|
if (!$userfile) { |
| 176 |
|
mosRedirect( "index2.php?option=$option&element=module", T_('Please select an HTTP URL') ); |
| 177 |
|
} |
| 178 |
|
|
| 179 |
|
$installer =& new $installerClass(); |
| 180 |
|
|
| 181 |
|
$msg = ''; |
| 182 |
|
$resultdir = uploadUrl( $userfile, $msg ); |
| 183 |
|
|
| 184 |
|
if ($resultdir !== false) { |
| 185 |
|
if (!$installer->extractArchive( $userfile['name'] )) { |
| 186 |
|
HTML_installer::showInstallMessage( $installer->getErrors(), 'Upload '.$element.' - Upload Failed', |
| 187 |
|
returnTo( $option, $element, $client ) ); |
| 188 |
|
} |
| 189 |
|
$ret = $installer->install(); |
| 190 |
|
|
| 191 |
|
HTML_installer::showInstallMessage( $installer->getErrors(), 'Upload '.$element.' - '.($ret ? 'Success' : 'Failed'), |
| 192 |
|
returnTo( $option, $element, $client ) ); |
| 193 |
|
$installer->cleanUpInstall(); |
| 194 |
|
} else { |
| 195 |
|
HTML_installer::showInstallMessage( $msg, 'Upload '.$element.' - Upload Error', |
| 196 |
|
returnTo( $option, $element, $client ) ); |
| 197 |
|
} |
| 198 |
|
} |
| 199 |
|
/** |
| 200 |
* |
* |
| 201 |
* @param |
* @param |
| 202 |
*/ |
*/ |
| 206 |
$cid = array(0); |
$cid = array(0); |
| 207 |
} |
} |
| 208 |
|
|
| 209 |
$installer = new $installerClass(); |
$installer =& new $installerClass(); |
| 210 |
$result = false; |
$result = false; |
| 211 |
if ($cid[0]) { |
if ($cid[0]) { |
| 212 |
$ret = $installer->uninstall( $cid[0], $option, $client ); |
$ret = $installer->uninstall( $cid[0], $option, $client ); |
| 244 |
} |
} |
| 245 |
return false; |
return false; |
| 246 |
} |
} |
| 247 |
|
/** |
| 248 |
|
* @param string The name of the php (temporary) uploaded file |
| 249 |
|
* @param string The name of the file to put in the temp directory |
| 250 |
|
* @param string The message to return |
| 251 |
|
*/ |
| 252 |
|
function uploadUrl( $filename, &$msg ) { |
| 253 |
|
global $mosConfig_absolute_path; |
| 254 |
|
$baseDir = mosPathName( $mosConfig_absolute_path . '/media' ); |
| 255 |
|
|
| 256 |
|
if (file_exists( $baseDir )) { |
| 257 |
|
if (is_writable( $baseDir )) { |
| 258 |
|
if (move_uploaded_file( $filename, $baseDir . $userfile_name )) { |
| 259 |
|
if (mosChmod( $baseDir . $userfile_name )) { |
| 260 |
|
return true; |
| 261 |
|
} else { |
| 262 |
|
$msg = T_('Failed to change the permissions of the uploaded file.'); |
| 263 |
|
} |
| 264 |
|
} else { |
| 265 |
|
$msg = T_('Failed to move uploaded file to <code>/media</code> directory.'); |
| 266 |
|
} |
| 267 |
|
} else { |
| 268 |
|
$msg = T_('Upload failed as <code>/media</code> directory is not writable.'); |
| 269 |
|
} |
| 270 |
|
} else { |
| 271 |
|
$msg = T_('Upload failed as <code>/media</code> directory does not exist.'); |
| 272 |
|
} |
| 273 |
|
return false; |
| 274 |
|
} |
| 275 |
|
|
| 276 |
/** |
/** |
| 277 |
* Component uninstall method |
* Component uninstall method |
| 280 |
* @param int The client id |
* @param int The client id |
| 281 |
*/ |
*/ |
| 282 |
function component_uninstall( $cid, $option, $client=0 ) { |
function component_uninstall( $cid, $option, $client=0 ) { |
| 283 |
$database = mamboDatabase::getInstance(); |
$database =& mamboDatabase::getInstance(); |
| 284 |
$sql = "SELECT * FROM #__components WHERE id=$cid"; |
$sql = "SELECT * FROM #__components WHERE id=$cid"; |
| 285 |
$database->setQuery($sql); |
$database->setQuery($sql); |
| 286 |
if (!$database->loadObject( $row )) { |
if (!$database->loadObject( $row )) { |
| 299 |
$filesindir = mosReadDirectory($here, '.xml$'); |
$filesindir = mosReadDirectory($here, '.xml$'); |
| 300 |
if (count($filesindir) > 0) { |
if (count($filesindir) > 0) { |
| 301 |
foreach ($filesindir as $file) { |
foreach ($filesindir as $file) { |
| 302 |
$parser = new mosUninstallXML ($here.$file); |
$parser =& new mosUninstallXML ($here.$file); |
| 303 |
$parser->uninstall(); |
$parser->uninstall(); |
| 304 |
if ($parser->errors->getMaxLevel() >= _MOS_ERROR_FATAL) return false; |
if ($parser->errors->getMaxLevel() >= _MOS_ERROR_FATAL) return false; |
| 305 |
} |
} |
| 323 |
* @param int The client id |
* @param int The client id |
| 324 |
*/ |
*/ |
| 325 |
function module_uninstall( $id, $option, $client=0 ) { |
function module_uninstall( $id, $option, $client=0 ) { |
| 326 |
$database = mamboDatabase::getInstance(); |
$database =& mamboDatabase::getInstance(); |
| 327 |
$mosConfig_absolute_path = mamboCore::get('mosConfig_absolute_path'); |
$mosConfig_absolute_path = mamboCore::get('mosConfig_absolute_path'); |
| 328 |
$query = "SELECT module, iscore, client_id FROM #__modules WHERE id = '$id'"; |
$query = "SELECT module, iscore, client_id FROM #__modules WHERE id = '$id'"; |
| 329 |
$database->setQuery( $query ); |
$database->setQuery( $query ); |
| 341 |
if ( $row->client_id ) $basepath = $mosConfig_absolute_path . '/administrator/modules/'; |
if ( $row->client_id ) $basepath = $mosConfig_absolute_path . '/administrator/modules/'; |
| 342 |
else $basepath = $mosConfig_absolute_path . '/modules/'; |
else $basepath = $mosConfig_absolute_path . '/modules/'; |
| 343 |
$xmlfile = $basepath . $row->module . '.xml'; |
$xmlfile = $basepath . $row->module . '.xml'; |
| 344 |
$parser = new mosUninstallXML ($xmlfile); |
$parser =& new mosUninstallXML ($xmlfile); |
| 345 |
$parser->uninstall(); |
$parser->uninstall(); |
| 346 |
if ($parser->errors->getMaxLevel() < _MOS_ERROR_FATAL) return true; |
if ($parser->errors->getMaxLevel() < _MOS_ERROR_FATAL) return true; |
| 347 |
return false; |
return false; |
| 354 |
* @param int The client id |
* @param int The client id |
| 355 |
*/ |
*/ |
| 356 |
function mambot_uninstall( $id, $option, $client=0 ) { |
function mambot_uninstall( $id, $option, $client=0 ) { |
| 357 |
$database = mamboDatabase::getInstance(); |
$database =& mamboDatabase::getInstance(); |
| 358 |
$mosConfig_absolute_path = mamboCore::get('mosConfig_absolute_path'); |
$mosConfig_absolute_path = mamboCore::get('mosConfig_absolute_path'); |
| 359 |
$database->setQuery( "SELECT name, folder, element, iscore FROM #__mambots WHERE id = '$id'" ); |
$database->setQuery( "SELECT name, folder, element, iscore FROM #__mambots WHERE id = '$id'" ); |
| 360 |
$database->loadObject( $row ); |
$database->loadObject( $row ); |
| 374 |
exit(); |
exit(); |
| 375 |
} |
} |
| 376 |
$xmlfile = $mosConfig_absolute_path.'/mambots/'.$row->folder.'/'.$row->element.'.xml'; |
$xmlfile = $mosConfig_absolute_path.'/mambots/'.$row->folder.'/'.$row->element.'.xml'; |
| 377 |
$parser = new mosUninstallXML ($xmlfile); |
$parser =& new mosUninstallXML ($xmlfile); |
| 378 |
$parser->uninstall(); |
$parser->uninstall(); |
| 379 |
if ($parser->errors->getMaxLevel() < _MOS_ERROR_FATAL) return true; |
if ($parser->errors->getMaxLevel() < _MOS_ERROR_FATAL) return true; |
| 380 |
return false; |
return false; |
| 395 |
$filesindir = mosReadDirectory($path, '.xml$'); |
$filesindir = mosReadDirectory($path, '.xml$'); |
| 396 |
if (count($filesindir) > 0) { |
if (count($filesindir) > 0) { |
| 397 |
foreach ($filesindir as $file) { |
foreach ($filesindir as $file) { |
| 398 |
$parser = new mosUninstallXML ($path.$file); |
$parser =& new mosUninstallXML ($path.$file); |
| 399 |
$parser->uninstall(); |
$parser->uninstall(); |
| 400 |
if ($parser->errors->getMaxLevel() >= _MOS_ERROR_FATAL) return false; |
if ($parser->errors->getMaxLevel() >= _MOS_ERROR_FATAL) return false; |
| 401 |
} |
} |
| 420 |
$xmlfile = $basepath . $id . '.xml'; |
$xmlfile = $basepath . $id . '.xml'; |
| 421 |
// see if there is an xml install file, must be same name as element |
// see if there is an xml install file, must be same name as element |
| 422 |
if (file_exists( $xmlfile )) { |
if (file_exists( $xmlfile )) { |
| 423 |
$parser = new mosUninstallXML ($xmlfile); |
$parser =& new mosUninstallXML ($xmlfile); |
| 424 |
$parser->uninstall(); |
$parser->uninstall(); |
| 425 |
if ($parser->errors->getMaxLevel() < _MOS_ERROR_FATAL) return true; |
if ($parser->errors->getMaxLevel() < _MOS_ERROR_FATAL) return true; |
| 426 |
return false; |
return false; |