Exemplo n.º 1
0
 public function uninstallApplication()
 {
     // check for request forgeries
     YRequest::checkToken() or jexit('Invalid Token');
     try {
         InstallHelper::uninstallApplication($this->application);
         // set redirect message
         $msg = JText::_('Application group uninstalled successful.');
         $link = $this->baseurl;
     } catch (InstallHelperException $e) {
         // raise notice on exception
         JError::raiseNotice(0, JText::_('Error uninstalling application group') . ' (' . $e . ')');
         $msg = null;
         $link = $this->baseurl . '&task=info';
     }
     $this->setRedirect($link, $msg);
 }
Exemplo n.º 2
0
 public static function doInstall(JInstallerComponent &$component)
 {
     // fix joomla 1.5 bug
     $component->parent->getDBO = $component->parent->getDBO();
     // initialize zoo framework
     require_once $component->parent->getPath('source') . '/admin/config.php';
     // sanatize table indexes
     $index_sql_path = $component->parent->getPath('source') . '/admin/installation/index.sql';
     if (JFile::exists($index_sql_path)) {
         $db = YDatabase::getInstance();
         // read index.sql
         $buffer = JFile::read($index_sql_path);
         // Create an array of queries from the sql file
         jimport('joomla.installer.helper');
         $queries = JInstallerHelper::splitSql($buffer);
         if (!empty($queries)) {
             foreach ($queries as $query) {
                 // replace table prefixes
                 $query = $db->replacePrefix($query);
                 // parse table name
                 preg_match('/ALTER\\s*TABLE\\s*`(.*)`/i', $query, $result);
                 if (count($result) < 2) {
                     continue;
                 }
                 $table = $result[1];
                 // get existing indexes
                 $indexes = $db->queryObjectList('SHOW INDEX FROM ' . $table);
                 // drop existing indexes
                 $removed = array();
                 foreach ($indexes as $index) {
                     if (in_array($index->Key_name, $removed)) {
                         continue;
                     }
                     if ($index->Key_name != 'PRIMARY') {
                         $db->query('DROP INDEX ' . $index->Key_name . ' ON ' . $table);
                         $removed[] = $index->Key_name;
                     }
                 }
                 // add new indexes
                 $db->query($query);
             }
         }
     }
     // applications
     if (!JFolder::exists(ZOO_APPLICATION_PATH)) {
         JFolder::create(ZOO_APPLICATION_PATH);
     }
     $applications = array();
     foreach (JFolder::folders($component->parent->getPath('source') . '/applications', '.', false, true) as $folder) {
         try {
             if ($manifest = InstallHelper::findManifest($folder)) {
                 $name = InstallHelper::getName($manifest);
                 $status = InstallHelper::installApplicationFromFolder($folder);
                 $applications[] = compact('name', 'status');
             }
         } catch (YException $e) {
             $name = basename($folder);
             $status = false;
             $applications[] = compact('name', 'status');
         }
     }
     self::displayResults($applications, 'Applications', 'Application');
     // additional extensions
     // init vars
     $error = false;
     $extensions = array();
     // get plugin files
     $plugin_files = array();
     foreach (YFile::readDirectoryFiles(JPATH_PLUGINS, JPATH_PLUGINS . '/', '/\\.php$/', true) as $file) {
         $plugin_files[] = basename($file);
     }
     // get extensions
     if (isset($component->manifest->additional[0])) {
         $add = $component->manifest->additional[0];
         if (count($add->children())) {
             $exts = $add->children();
             foreach ($exts as $ext) {
                 $installer = new JInstaller();
                 $installer->setOverwrite(true);
                 $update = false;
                 if ($ext->name() == 'module' && JFolder::exists(JPATH_ROOT . '/modules/' . $ext->attributes('name')) || $ext->name() == 'plugin' && in_array($ext->attributes('name') . '.php', $plugin_files)) {
                     $update = true;
                 }
                 $folder = $component->parent->getPath('source') . '/' . $ext->attributes('folder');
                 $folder = rtrim($folder, "\\/") . '/';
                 if (JFolder::exists($folder)) {
                     if ($update) {
                         foreach (YFile::readDirectoryFiles($folder, $folder, '/positions\\.config$/', true) as $file) {
                             JFile::delete($file);
                         }
                     }
                     $extensions[] = array('name' => $ext->data(), 'type' => $ext->name(), 'folder' => $folder, 'installer' => $installer, 'status' => false, 'update' => $update);
                 }
             }
         }
     }
     // install additional extensions
     for ($i = 0; $i < count($extensions); $i++) {
         if (is_dir($extensions[$i]['folder'])) {
             if (@$extensions[$i]['installer']->install($extensions[$i]['folder'])) {
                 $extensions[$i]['status'] = $extensions[$i]['update'] ? 2 : 1;
             } else {
                 $error = true;
                 break;
             }
         }
     }
     // rollback on installation errors
     if ($error) {
         $component->parent->abort(JText::_('Component') . ' ' . JText::_('Install') . ': ' . JText::_('Error'), 'component');
         for ($i = 0; $i < count($extensions); $i++) {
             if ($extensions[$i]['status']) {
                 $extensions[$i]['installer']->abort(JText::_($extensions[$i]['type']) . ' ' . JText::_('Install') . ': ' . JText::_('Error'), $extensions[$i]['type']);
                 $extensions[$i]['status'] = false;
             }
         }
         return false;
     }
     self::displayResults($extensions, 'Extensions', 'Extension');
     // UPGRADES
     // get versions
     $new_version = $component->manifest->getElementByPath('version')->data();
     $version = '';
     // check for old version number
     $version_file_path = $component->parent->getPath('extension_administrator') . '/version.php';
     if (JFile::exists($version_file_path)) {
         require_once $version_file_path;
     }
     // write new version file
     $buffer = "<?php\n\ndefined('_JEXEC') or die('Restricted access');\n\n\$version = '{$new_version}';";
     JFile::write($version_file_path, $buffer);
     // include update script
     require_once $component->parent->getPath('source') . '/admin/installation/update.php';
     return true;
 }
Exemplo n.º 3
0
 public function actionStep3()
 {
     $configs = Yii::app()->user->getState('install_configs');
     foreach ($configs as $file => $data) {
         InstallHelper::parseConfig($file, $data);
     }
     //        @unlink(Yii::getPathOfAlias('webroot.insall').'.php');
     //        @unlink(Yii::getPathOfAlias('application.config.install').'.php');
     $this->redirect('/install.php?r=/install/install/end');
 }