コード例 #1
0
ファイル: model.php プロジェクト: kumarsivarajan/jaderp
 function postMigrate()
 {
     $migErrors = null;
     $args =& $this->getVars();
     $db =& JInstallationHelper::getDBO($args['DBtype'], $args['DBhostname'], $args['DBuserName'], $args['DBpassword'], $args['DBname'], $args['DBPrefix']);
     $migResult = JInstallationHelper::postMigrate($db, $migErrors, $args);
     if (!$migResult) {
         echo JText::_("Migration Successful");
     } else {
         echo '<div id="installer">';
         echo '<p>' . JText::_('Migration failed') . ':</p>';
         foreach ($migErrors as $error) {
             echo '<p>' . $error['msg'] . '</p>';
         }
         echo '</div>';
     }
     return $migResult;
 }
コード例 #2
0
ファイル: helper.php プロジェクト: rafarubert/megafiltros
 /**
  * Uploads a sql script and executes it. Script can be text file or zip/gz packed
  *
  * @static
  * @param array The installation variables
  * @param boolean true if the script is a migration script
  * @return string Success or error messages
  * @since 1.5
  */
 function uploadSql(&$args, $migration = false, $preconverted = false)
 {
     global $mainframe;
     $archive = '';
     $script = '';
     /*
      * Check for iconv
      */
     if ($migration && !$preconverted && !function_exists('iconv')) {
         return JText::_('WARNICONV');
     }
     /*
      * Get the uploaded file information
      */
     if ($migration) {
         $sqlFile = JRequest::getVar('migrationFile', '', 'files', 'array');
     } else {
         $sqlFile = JRequest::getVar('sqlFile', '', 'files', 'array');
     }
     /*
      * Make sure that file uploads are enabled in php
      */
     if (!(bool) ini_get('file_uploads')) {
         return JText::_('WARNINSTALLFILE');
     }
     /*
      * Make sure that zlib is loaded so that the package can be unpacked
      */
     if (!extension_loaded('zlib')) {
         return JText::_('WARNINSTALLZLIB');
     }
     /*
      * If there is no uploaded file, we have a problem...
      */
     if (!is_array($sqlFile) || $sqlFile['size'] < 1) {
         return JText::_('WARNNOFILE');
     }
     /*
      * Move uploaded file
      */
     // Set permissions for tmp dir
     JInstallationHelper::_chmod(JPATH_SITE . DS . 'tmp', 0777);
     jimport('joomla.filesystem.file');
     $uploaded = JFile::upload($sqlFile['tmp_name'], JPATH_SITE . DS . 'tmp' . DS . $sqlFile['name']);
     if (!$uploaded) {
         return JText::_('WARNUPLOADFAILURE');
     }
     if (!eregi('.sql$', $sqlFile['name'])) {
         $archive = JPATH_SITE . DS . 'tmp' . DS . $sqlFile['name'];
     } else {
         $script = JPATH_SITE . DS . 'tmp' . DS . $sqlFile['name'];
     }
     // unpack archived sql files
     if ($archive) {
         $package = JInstallationHelper::unpack($archive, $args);
         if ($package === false) {
             return JText::_('WARNUNPACK');
         }
         $script = $package['folder'] . DS . $package['script'];
     }
     $db =& JInstallationHelper::getDBO($args['DBtype'], $args['DBhostname'], $args['DBuserName'], $args['DBpassword'], $args['DBname'], $args['DBPrefix']);
     /*
      * If migration perform manipulations on script file before population
      */
     if ($migration) {
         $script = JInstallationHelper::preMigrate($script, $args, $db);
         if ($script == false) {
             return JText::_('Script operations failed');
         }
     }
     $errors = null;
     $msg = '';
     $result = JInstallationHelper::populateDatabase($db, $script, $errors);
     /*
      * If migration, perform post population manipulations (menu table construction)
      */
     $migErrors = null;
     if ($migration) {
         $migResult = JInstallationHelper::postMigrate($db, $migErrors, $args);
         if ($migResult != 0) {
             /*
              * Merge populate and migrate processing errors
              */
             if ($result == 0) {
                 $result = $migResult;
                 $errors = $migErrors;
             } else {
                 $result += $migResult;
                 $errors = array_merge($errors, $migErrors);
             }
         }
     }
     /*
      * prepare sql error messages if returned from populate and migrate
      */
     if (!is_null($errors)) {
         foreach ($errors as $error) {
             $msg .= stripslashes($error['msg']);
             $msg .= chr(13) . "-------------" . chr(13);
             $txt = '<textarea cols="40" rows="4" name="instDefault" readonly="readonly" >' . JText::_("Database Errors Reported") . chr(13) . $msg . '</textarea>';
         }
     } else {
         // consider other possible errors from populate
         $msg = $result == 0 ? JText::_('SQL script installed successfully') : JText::_('Error installing SQL script');
         $txt = '<input size="50" value="' . $msg . '" readonly="readonly" />';
     }
     /*
      * Clean up
      */
     if ($archive) {
         JFile::delete($archive);
         JFolder::delete($package['folder']);
     } else {
         JFile::delete($script);
     }
     return $txt;
 }
コード例 #3
0
ファイル: model.php プロジェクト: joomline/Joomla1.5.999
 function postMigrate()
 {
     $migErrors = null;
     $args =& $this->getVars();
     $db =& JInstallationHelper::getDBO($args['DBtype'], $args['DBhostname'], $args['DBuserName'], $args['DBpassword'], $args['DBname'], $args['DBPrefix']);
     $migResult = JInstallationHelper::postMigrate($db, $migErrors, $args);
     // Clean up the migration SQL file
     $migratePath = JPATH_BASE . DS . 'sql' . DS . 'migration' . DS . 'migrate.sql';
     jimport('joomla.filesystem.file');
     if (JFile::exists($migratePath)) {
         JFile::delete($migratePath);
     }
     if ($migResult) {
         echo '<div id="installer">';
         echo '<p>' . JText::_('Migration failed') . ':</p>';
         foreach ($migErrors as $error) {
             echo '<p>' . $error['msg'] . '</p>';
         }
         echo '</div>';
     } else {
         echo JText::_("Migration Successful");
     }
     return $migResult;
 }