[ Index ] |
|
Code source de Joomla 1.0.13 |
1 <?php 2 /** 3 * @version $Id: admin.installer.php 4623 2006-08-21 16:40:39Z stingrey $ 4 * @package Joomla 5 * @subpackage Installer 6 * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved. 7 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php 8 * Joomla! is free software. This version may have been modified pursuant 9 * to the GNU General Public License, and as distributed it includes or 10 * is derivative of works licensed under the GNU General Public License or 11 * other free or open source software licenses. 12 * See COPYRIGHT.php for copyright notices and details. 13 */ 14 15 // no direct access 16 defined( '_VALID_MOS' ) or die( 'Restricted access' ); 17 18 // XML library 19 require_once ( $mosConfig_absolute_path . '/includes/domit/xml_domit_lite_include.php' ); 20 require_once( $mainframe->getPath( 'admin_html' ) ); 21 require_once( $mainframe->getPath( 'class' ) ); 22 23 $element = mosGetParam( $_REQUEST, 'element', '' ); 24 $client = mosGetParam( $_REQUEST, 'client', '' ); 25 $path = $mosConfig_absolute_path . "/administrator/components/com_installer/$element/$element.php"; 26 27 // ensure user has access to this function 28 if ( !$acl->acl_check( 'administration', 'install', 'users', $my->usertype, $element . 's', 'all' ) ) { 29 mosRedirect( 'index2.php', _NOT_AUTH ); 30 } 31 32 // map the element to the required derived class 33 $classMap = array( 34 'component' => 'mosInstallerComponent', 35 'language' => 'mosInstallerLanguage', 36 'mambot' => 'mosInstallerMambot', 37 'module' => 'mosInstallerModule', 38 'template' => 'mosInstallerTemplate' 39 ); 40 41 if (array_key_exists ( $element, $classMap )) { 42 require_once( $mainframe->getPath( 'installer_class', $element ) ); 43 44 switch ($task) { 45 46 case 'uploadfile': 47 uploadPackage( $classMap[$element], $option, $element, $client ); 48 break; 49 50 case 'installfromdir': 51 installFromDirectory( $classMap[$element], $option, $element, $client ); 52 break; 53 54 case 'remove': 55 removeElement( $classMap[$element], $option, $element, $client ); 56 break; 57 58 default: 59 $path = $mosConfig_absolute_path . "/administrator/components/com_installer/$element/$element.php"; 60 61 if (file_exists( $path )) { 62 require $path; 63 } else { 64 echo "Installer not found for element [$element]"; 65 } 66 break; 67 } 68 } else { 69 echo "Installer not available for element [$element]"; 70 } 71 72 /** 73 * @param string The class name for the installer 74 * @param string The URL option 75 * @param string The element name 76 */ 77 function uploadPackage( $installerClass, $option, $element, $client ) { 78 $installer = new $installerClass(); 79 80 // Check if file uploads are enabled 81 if (!(bool)ini_get('file_uploads')) { 82 HTML_installer::showInstallMessage( "The installer can't continue before file uploads are enabled. Please use the install from directory method.", 83 'Installer - Error', $installer->returnTo( $option, $element, $client ) ); 84 exit(); 85 } 86 87 // Check that the zlib is available 88 if(!extension_loaded('zlib')) { 89 HTML_installer::showInstallMessage( "The installer can't continue before zlib is installed", 90 'Installer - Error', $installer->returnTo( $option, $element, $client ) ); 91 exit(); 92 } 93 94 $userfile = mosGetParam( $_FILES, 'userfile', null ); 95 96 if (!$userfile) { 97 HTML_installer::showInstallMessage( 'No file selected', 'Upload new module - error', 98 $installer->returnTo( $option, $element, $client )); 99 exit(); 100 } 101 102 $userfile_name = $userfile['name']; 103 104 $msg = ''; 105 $resultdir = uploadFile( $userfile['tmp_name'], $userfile['name'], $msg ); 106 107 if ($resultdir !== false) { 108 if (!$installer->upload( $userfile['name'] )) { 109 HTML_installer::showInstallMessage( $installer->getError(), 'Upload '.$element.' - Upload Failed', 110 $installer->returnTo( $option, $element, $client ) ); 111 } 112 $ret = $installer->install(); 113 114 HTML_installer::showInstallMessage( $installer->getError(), 'Upload '.$element.' - '.($ret ? 'Success' : 'Failed'), 115 $installer->returnTo( $option, $element, $client ) ); 116 cleanupInstall( $userfile['name'], $installer->unpackDir() ); 117 } else { 118 HTML_installer::showInstallMessage( $msg, 'Upload '.$element.' - Upload Error', 119 $installer->returnTo( $option, $element, $client ) ); 120 } 121 } 122 123 /** 124 * Install a template from a directory 125 * @param string The URL option 126 */ 127 function installFromDirectory( $installerClass, $option, $element, $client ) { 128 $userfile = mosGetParam( $_REQUEST, 'userfile', '' ); 129 130 if (!$userfile) { 131 mosRedirect( "index2.php?option=$option&element=module", "Please select a directory" ); 132 } 133 134 $installer = new $installerClass(); 135 136 $path = mosPathName( $userfile ); 137 if (!is_dir( $path )) { 138 $path = dirname( $path ); 139 } 140 141 $ret = $installer->install( $path ); 142 HTML_installer::showInstallMessage( $installer->getError(), 'Upload new '.$element.' - '.($ret ? 'Success' : 'Error'), $installer->returnTo( $option, $element, $client ) ); 143 } 144 /** 145 * 146 * @param 147 */ 148 function removeElement( $installerClass, $option, $element, $client ) { 149 $cid = mosGetParam( $_REQUEST, 'cid', array(0) ); 150 if (!is_array( $cid )) { 151 $cid = array(0); 152 } 153 154 $installer = new $installerClass(); 155 $result = false; 156 if ($cid[0]) { 157 $result = $installer->uninstall( $cid[0], $option, $client ); 158 } 159 160 $msg = $installer->getError(); 161 162 mosRedirect( $installer->returnTo( $option, $element, $client ), $result ? 'Success ' . $msg : 'Failed ' . $msg ); 163 } 164 /** 165 * @param string The name of the php (temporary) uploaded file 166 * @param string The name of the file to put in the temp directory 167 * @param string The message to return 168 */ 169 function uploadFile( $filename, $userfile_name, &$msg ) { 170 global $mosConfig_absolute_path; 171 $baseDir = mosPathName( $mosConfig_absolute_path . '/media' ); 172 173 if (file_exists( $baseDir )) { 174 if (is_writable( $baseDir )) { 175 if (move_uploaded_file( $filename, $baseDir . $userfile_name )) { 176 if (mosChmod( $baseDir . $userfile_name )) { 177 return true; 178 } else { 179 $msg = 'Failed to change the permissions of the uploaded file.'; 180 } 181 } else { 182 $msg = 'Failed to move uploaded file to <code>/media</code> directory.'; 183 } 184 } else { 185 $msg = 'Upload failed as <code>/media</code> directory is not writable.'; 186 } 187 } else { 188 $msg = 'Upload failed as <code>/media</code> directory does not exist.'; 189 } 190 return false; 191 } 192 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 14:43:32 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |