function fullMigrate()
{
    $model = new JInstallationModel();
    $db =& JFactory::getDBO();
    $config =& JFactory::getConfig();
    $error = array();
    $dbname = $config->getValue('config.db');
    $dbprefix = $config->getValue('config.dbprefix');
    $session =& JFactory::getSession();
    $sessiontable =& JTable::getInstance('session');
    $sessiontable->load($session->getId());
    JInstallationHelper::deleteDatabase($db, $dbname, $dbprefix, $error);
    // we need to reload base structure
    $model->makeDB();
    // create a new user
    $my =& JFactory::getUser();
    $user = new JUser();
    $user->id = 0;
    $user->username = '******';
    $user->password = md5($config->getValue('config.secret'));
    $user->gid = 25;
    $user->group = 'Super Administrator';
    $user->name = "Migration Assistant";
    $user->email = "*****@*****.**";
    $user->save();
    // put a session back
    $sessiontable->insert($sessiontable->session_id, $sessiontable->client_id);
    // and build a session for them
    doUserLogIn('migrationassistant');
    // and now check what we've just gotten before moving on
    if (!$model->checkUpload()) {
        handleError($model);
    }
    include MIGBASE . DS . 'includes' . DS . 'migpage.php';
}
示例#2
0
				echo ("<p class=\"error\">". JText::_('STOPPEDATLINE') ." $linenumber. </p>");
				echo ("<p>". JText::sprintf('TOOMANYLINES',MAX_QUERY_LINES)."</p>");
				$error = true;
				break;
			}
			$vars = $this->getVars();
		$DBhostname = JArrayHelper::getValue($vars, 'DBhostname', '');
		$DBuserName = JArrayHelper::getValue($vars, 'DBuserName', '');
		$DBpassword = JArrayHelper::getValue($vars, 'DBpassword', '');
		$DBname 	= JArrayHelper::getValue($vars, 'DBname', '');
		$DBPrefix 	= JArrayHelper::getValue($vars, 'DBPrefix', 'jos_');
		$DBOld 		= JArrayHelper::getValue($vars, 'DBOld', 'bu');
		//$migration 		= JArrayHelper::getValue($vars, 'migration', '0');
		$migration = JRequest::getVar( 'migration', 0, 'post', 'bool' );

			$db = & JInstallationHelper::getDBO('mysqli', $DBhostname, $DBuserName, $DBpassword, $DBname, $DBPrefix);
			if(JError::isError($db)) jexit(JText::_('CONNECTION FAIL'));

//			echo 'Done.<br />';
			// Execute query if end of query detected (; as last character) AND NOT in parents

			if (preg_match('/;$/', trim($dumpline)) && !$inparents) {
				if (!TESTMODE) {
					$db->setQuery(trim($query));
//					echo $query . '<br />';
					if (!$db->Query()) {
						echo ("<p class=\"error\">".JText::_('Error at the line') ." $linenumber: ". trim($dumpline) . "</p>\n");
						echo ("<p>".JText::_('Query:') .  trim(nl2br(htmlentities($query))) ."</p>\n");
						echo ("<p>MySQL: " . mysql_error() . "</p>\n");
						$error = true;
						break;
示例#3
0
 /**
  * Performs post-populate conversions after importing a migration script
  * These include constructing an appropriate menu table for core content items
  * and adding core modules from old site to the modules table
  *
  * @static
  * @param JDatabase
  * @param array errors (by ref)
  * @return error count
  * @since 1.5
  */
 function postMigrate($db, &$errors, &$args)
 {
     $newPrefix = $args['DBPrefix'];
     /*
      * Check to see if migration is from 4.5.1
      */
     $query = 'SELECT id FROM ' . $newPrefix . 'users WHERE usertype = "superadministrator"';
     $db->setQuery($query);
     $rows = $db->loadRowList();
     JInstallationHelper::getDBErrors($errors, $db);
     /*
      * if it is, then fill usertype field with correct values from aro_group
      */
     if (count($rows) > 0) {
         $query = 'UPDATE ' . $newPrefix . 'users AS u, ' . $newPrefix . 'core_acl_aro_groups AS g' . ' SET u.usertype = g.value' . ' WHERE u.gid = g.id';
         $db->setQuery($query);
         $db->query();
         JInstallationHelper::getDBErrors($errors, $db);
     }
     /*
      * Construct the menu table based on old table references to core items
      */
     // Component - change all
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET `type` = "component" WHERE `type` = "components";';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // Component Item Link
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET `link` = SUBSTRING(link, 1, LOCATE("&Itemid=", link) -1), `type` = "component" WHERE `type` = "component_item_link";';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // get com_contact id
     $query = 'SELECT `id` FROM `' . $newPrefix . 'components` WHERE `option`="com_contact" AND `parent` = 0';
     $db->setQuery($query);
     JInstallationHelper::getDBErrors($errors, $db);
     $compId = $db->loadResult();
     // contact category table
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET  `link` = INSERT(link, LOCATE("catid=", link), 0, "view=category&"), `type` = "component", `componentid` = ' . $compId . ' WHERE `type` = "contact_category_table"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // contact item link
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET  `link` = INSERT(link, LOCATE("task=view", link), 20, "view=contact&id"), `type` = "component", `componentid` = ' . $compId . ' WHERE `type` = "contact_item_link"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // fix up standalone contact
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET `link` = "index.php?option=com_contact&view=category" WHERE `link` = "index.php?option=com_contact"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // get com_content id
     $query = 'SELECT `id` FROM `' . $newPrefix . 'components` WHERE `option`="com_content" AND `parent` = 0';
     $db->setQuery($query);
     $compId = $db->loadResult();
     JInstallationHelper::getDBErrors($errors, $db);
     // front page
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET `link` = "index.php?option=com_content&view=frontpage", `type` = "component", `componentid` = ' . $compId . ' WHERE `link` LIKE "%option=com_frontpage%"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // content archive category or section
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET  `link` = "index.php?option=com_content&view=archive", `type` = "component", `componentid` = ' . $compId . ' WHERE (`type` = "content_archive_category" OR `type` = "content_archive_section")';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // content blog category
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET  `link` = INSERT(link, LOCATE("task=blogcat", link), 17, "view=category&layout=blog"), `type` = "component", `componentid` = ' . $compId . ' WHERE `type` = "content_blog_category"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // content blog section
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET `link` = INSERT(link, LOCATE("task=blogsec", link), 16, "view=section&layout=blog"), `type` = "component", `componentid` = ' . $compId . ' WHERE `type` = "content_blog_section";';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // content category
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET `link` = INSERT(link, LOCATE("task=", link), LOCATE("&id=", link) - LOCATE("task=", link), "view=category"), `type` = "component", `componentid` = ' . $compId . ' WHERE `type` = "content_category"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // content item link and typed content
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET  `link` = INSERT(link, LOCATE("task=", link), 9, "view=article"), `type` = "component", `componentid` = ' . $compId . ' WHERE (`type` = "content_item_link" OR `type` = "content_typed")';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // content section
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET  `link` = INSERT(link, LOCATE("task=", link), 12, "view=section"), `type` = "component", `componentid` = ' . $compId . ' WHERE `type` = "content_section"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // get com_newsfeeds id
     $query = 'SELECT `id` FROM `' . $newPrefix . 'components` WHERE `option`="com_newsfeeds" AND `parent` = 0';
     $db->setQuery($query);
     $compId = $db->loadResult();
     JInstallationHelper::getDBErrors($errors, $db);
     // newsfeed categories
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET `link` = CONCAT(link, "&view=categories"), `componentid` = ' . $compId . ' WHERE `type` = "component" AND link LIKE "%option=com_newsfeeds%"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // newsfeed category table
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET `link` = INSERT(link, LOCATE("catid=", link), 5, "view=category&catid"), `type` = "component", `componentid` = ' . $compId . ' WHERE `type` = "newsfeed_category_table"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // newsfeed link
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET `link` = INSERT(link, LOCATE("task=", link), 9, "view=newsfeed"), `type` = "component", `componentid` = ' . $compId . ' WHERE `type` = "newsfeed_link"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // user checkin items
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET `link` = INSERT(link, LOCATE("CheckIn", link), 7, "checkin") WHERE `type` = "url" AND link LIKE "%option=com_user&task=CheckIn%"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // user edit details
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET `link` = INSERT(link, LOCATE("UserDetails", link), 11, "edit") WHERE `type` = "url" AND link LIKE "%option=com_user&task=UserDetails%"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // get com_weblinks id
     $query = 'SELECT `id` FROM `' . $newPrefix . 'components` WHERE `option`="com_weblinks" AND `parent` = 0';
     $db->setQuery($query);
     $compId = $db->loadResult();
     JInstallationHelper::getDBErrors($errors, $db);
     // weblinks categories
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET `link` = CONCAT(link, "&view=categories"), `componentid` = ' . $compId . ' WHERE `type` = "component" AND link LIKE "%option=com_weblinks%"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // weblinks category table
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET `link` = INSERT(link, LOCATE("catid=", link), 5, "view=category&catid"), `type` = "component", `componentid` = ' . $compId . ' WHERE `type` = "weblink_category_table"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // weblinks submit new item
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET `link` = INSERT(link, LOCATE("task=", link), 8, "view=weblink&layout=form") WHERE `type` = "url" AND link LIKE "%option=com_weblinks%"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // get com_wrapper id
     $query = 'SELECT `id` FROM `' . $newPrefix . 'components` WHERE `option`="com_wrapper" AND `parent` = 0';
     $db->setQuery($query);
     JInstallationHelper::getDBErrors($errors, $db);
     $compId = $db->loadResult();
     // wrapper
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET `link` = CONCAT(link, "&view=wrapper"), `type` = "component", `componentid` = ' . $compId . ' WHERE `type` = "wrapper"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // set default to lowest ordering published on mainmenu
     $query = 'SELECT MIN( `ordering` ) FROM `' . $newPrefix . 'menu_migration` WHERE `published` = 1 AND `parent` = 0 AND `menutype` = "mainmenu"';
     $db->setQuery($query);
     $minorder = $db->loadResult();
     if (!$minorder) {
         $minorder = 0;
     }
     JInstallationHelper::getDBErrors($errors, $db);
     $query = 'SELECT `id` FROM `' . $newPrefix . 'menu_migration` WHERE `published` = 1 AND `parent` = 0 AND `menutype` = "mainmenu" AND `ordering` = ' . $minorder;
     $db->setQuery($query);
     $menuitemid = $db->loadResult();
     JInstallationHelper::getDBErrors($errors, $db);
     if (!$menuitemid) {
         $menuitemid = 1;
     }
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET `home` = 1 WHERE `id` = ' . $menuitemid;
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // login and log out; component id and link update
     $query = 'SELECT id FROM `' . $newPrefix . 'components` WHERE link like "option=com_user"';
     $db->setQuery($query);
     $componentid = $db->loadResult();
     JInstallationHelper::getDBErrors($errors, $db);
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET componentid = ' . $componentid . ' WHERE link = "index.php?option=com_login"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET link = "index.php?option=com_user&view=login" WHERE link = "index.php?option=com_login"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // Search - Component ID Update
     $query = 'SELECT id FROM `' . $newPrefix . 'components` WHERE link like "option=com_search"';
     $db->setQuery($query);
     $componentid = $db->loadResult();
     JInstallationHelper::getDBErrors($errors, $db);
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET componentid = ' . $componentid . ' WHERE link like "index.php?option=com_search%"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     // tidy up urls with Itemids
     $query = 'UPDATE `' . $newPrefix . 'menu_migration` SET `link` = SUBSTRING(`link`,1,LOCATE("&Itemid",`link`)-1) WHERE `type` = "url" AND `link` LIKE "%&Itemid=%"';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     $query = 'SELECT DISTINCT `option` FROM ' . $newPrefix . 'components WHERE `option` != ""';
     $db->setQuery($query);
     $lookup = $db->loadResultArray();
     JInstallationHelper::getDBErrors($errors, $db);
     $lookup[] = 'com_user&';
     // prepare to copy across
     $query = 'SELECT * FROM ' . $newPrefix . 'menu_migration';
     $db->setQuery($query);
     $oldMenuItems = $db->loadObjectList();
     JInstallationHelper::getDBErrors($errors, $db);
     $query = 'DELETE FROM ' . $newPrefix . 'menu WHERE 1';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     $query = 'SELECT * FROM ' . $newPrefix . 'menu';
     $db->setQuery($query);
     $newMenuItems = $db->loadObjectList();
     JInstallationHelper::getDBErrors($errors, $db);
     // filter out links to 3pd components
     foreach ($oldMenuItems as $item) {
         if ($item->type == 'url' && !strpos($item->link, 'com_')) {
             $newMenuItems[] = $item;
         } else {
             if ($item->type == 'url' && JInstallationHelper::isValidItem($item->link, $lookup)) {
                 $newMenuItems[] = $item;
             } else {
                 if ($item->type == 'component') {
                     // unpublish components that don't exist yet
                     if (!JInstallationHelper::isValidItem($item->link, $lookup)) {
                         $item->published = 0;
                     }
                     $newMenuItems[] = $item;
                 }
             }
         }
     }
     // build the menu table
     foreach ($newMenuItems as $item) {
         $db->insertObject($newPrefix . 'menu', $item);
         JInstallationHelper::getDBErrors($errors, $db);
     }
     // fix possible orphaned sub menu items
     $query = 'UPDATE  `' . $newPrefix . 'menu` AS c LEFT OUTER JOIN `' . $newPrefix . 'menu` AS p ON c.parent = p.id SET c.parent = 0 WHERE c.parent <> 0 AND p.id IS NULL';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     /*
      * Construct the menu_type table base on new menu table types
      */
     $query = 'SELECT DISTINCT `menutype` FROM ' . $newPrefix . 'menu WHERE 1';
     $db->setQuery($query);
     JInstallationHelper::getDBErrors($errors, $db);
     $menuTypes = $db->loadResultArray();
     $query = 'TRUNCATE TABLE ' . $newPrefix . 'menu_types';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     foreach ($menuTypes as $mType) {
         $query = 'INSERT INTO ' . $newPrefix . 'menu_types ( menutype, title ) VALUES ("' . $mType . '", "' . $mType . '");';
         $db->setQuery($query);
         $db->query();
         JInstallationHelper::getDBErrors($errors, $db);
     }
     /*
      * Add core client modules from old site to modules table as unpublished
      */
     $query = 'SELECT id FROM ' . $newPrefix . 'modules_migration WHERE client_id = 0 ';
     $db->setQuery($query);
     $lookup = $db->loadResultArray();
     JInstallationHelper::getDBErrors($errors, $db);
     $query = 'SELECT MAX(id) FROM ' . $newPrefix . 'modules ';
     $db->setQuery($query);
     $nextId = $db->loadResult();
     JInstallationHelper::getDBErrors($errors, $db);
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     foreach ($lookup as $module) {
         $qry = 'SELECT * FROM ' . $newPrefix . 'modules_migration WHERE id = "' . $module . '" AND client_id = 0';
         $db->setQuery($qry);
         if ($row = $db->loadObject()) {
             if ($row->module == '') {
                 $row->module = 'mod_custom';
             }
             if (JFolder::exists(JPATH_SITE . DS . 'modules' . DS . $row->module)) {
                 $nextId++;
                 $oldid = $row->id;
                 $row->id = $nextId;
                 $row->published = 0;
                 if ($db->insertObject($newPrefix . 'modules', $row)) {
                     // Grab the old modules menu links and put them in too!
                     $qry = 'SELECT * FROM ' . $newPrefix . 'modules_migration_menu WHERE moduleid = ' . $oldid;
                     $db->setQuery($qry);
                     $entries = $db->loadObjectList();
                     JInstallationHelper::getDBErrors($errors, $db);
                     foreach ($entries as $entry) {
                         $entry->moduleid = $nextId;
                         $db->insertObject($newPrefix . 'modules_menu', $entry);
                         JInstallationHelper::getDBErrors($errors, $db);
                     }
                 } else {
                     JInstallationHelper::getDBErrors($errors, $db);
                 }
             }
             // else the module doesn't exist?
         } else {
             JInstallationHelper::getDBErrors($errors, $db);
         }
     }
     // Put in breadcrumb module as per sample data
     $query = "INSERT INTO `" . $newPrefix . "modules` VALUES (0, 'Breadcrumbs', '', 1, 'breadcrumb', 0, '0000-00-00 00:00:00', 1, 'mod_breadcrumbs', 0, 0, 1, 'moduleclass_sfx=\ncache=0\nshowHome=1\nhomeText=Home\nshowComponent=1\nseparator=\n\n', 1, 0, '');";
     $db->setQuery($query);
     $db->Query();
     JInstallationHelper::getDBErrors($errors, $db);
     /*
      * Clean up
      */
     $query = 'DROP TABLE IF EXISTS ' . $newPrefix . 'modules_migration';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     $query = 'DROP TABLE IF EXISTS ' . $newPrefix . 'modules_migration_menu';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     $query = 'DROP TABLE IF EXISTS ' . $newPrefix . 'menu_migration';
     $db->setQuery($query);
     $db->query();
     JInstallationHelper::getDBErrors($errors, $db);
     return count($errors);
 }
示例#4
0
 /**
  * Method to load and execute a sql script
  */
 function sampledata($args)
 {
     jimport('joomla.database.database');
     jimport('joomla.language.language');
     jimport('joomla.registry.registry');
     $errors = null;
     $msg = '';
     $objResponse = new xajaxResponse();
     $lang = new JAJAXLang($args['lang']);
     //		$lang->setDebug(true);
     /*
      * execute the default sample data file
      */
     $type = $args['DBtype'];
     if ($type == 'mysqli') {
         $type = 'mysql';
     }
     $dbsample = '../sql' . DS . $type . DS . 'sample_data.sql';
     $db =& JInstallationHelper::getDBO($args['DBtype'], $args['DBhostname'], $args['DBuserName'], $args['DBpassword'], $args['DBname'], $args['DBPrefix']);
     $result = JInstallationHelper::populateDatabase($db, $dbsample, $errors);
     /*
      * prepare sql error messages if returned from populate
      */
     if (!is_null($errors)) {
         foreach ($errors as $error) {
             $msg .= stripslashes($error['msg']);
             $msg .= chr(13) . "-------------" . chr(13);
             $txt = '<textarea cols="35" rows="5" name="instDefault" readonly="readonly" >' . $lang->_('Database Errors Reported') . chr(13) . $msg . '</textarea>';
         }
     } else {
         // consider other possible errors from populate
         $msg = $result == 0 ? $lang->_("Sample data installed successfully") : $lang->_("Error installing SQL script");
         $txt = '<input size="35" name="instDefault" value="' . $msg . '" readonly="readonly" />';
     }
     $objResponse->addAssign("theDefault", "innerHTML", $txt);
     return $objResponse;
 }
示例#5
0
 protected function _configure()
 {
     $dialog = $this->getHelperSet()->get('dialog');
     $output = $this->_output;
     $input = $this->_input;
     $prompt = function ($key, $text, $default = null, $error = null) use($dialog, $output, $input) {
         $result = $input->getOption($key);
         if (empty($result) && !$input->getOption('no-interaction')) {
             if (!empty($default)) {
                 $text .= '(default: ' . $default . ') ';
             }
             while (strlen($result = $dialog->ask($output, '<info>' . $text . '</info>', $default)) == 0) {
             }
         } elseif (empty($result)) {
             $result = $default;
             if (empty($result)) {
                 $output->writeLn('<error>' . $error . '</error>');
                 exit(1);
             }
         }
         return $result;
     };
     $config = new Config(WWW_ROOT);
     $info = $config->getDatabaseInfo();
     $config->setDatabaseInfo(array('name' => $prompt('database-name', 'Enter the name of the database? ', @$info['name'], 'Please enter the database name'), 'user' => $prompt('database-user', 'Enter the database user? ', @$info['user'], 'Please enter the database user'), 'password' => $prompt('database-password', 'Enter the database password? ', @$info['password'], 'Please enter the database password'), 'host' => $prompt('database-host', 'Enter the database host address? ', '127.0.0.1', @$info['host']), 'port' => $prompt('database-port', 'Enter the database port? ', '3306', @$info['port']), 'prefix' => $prompt('database-prefix', 'Enter a prefix for the tables in the database? ', 'jos_', @$info['prefix'])));
     define('DS', DIRECTORY_SEPARATOR);
     define('_JEXEC', 1);
     define('JPATH_BASE', WWW_ROOT);
     define('JPATH_ROOT', JPATH_BASE);
     define('JPATH_SITE', JPATH_ROOT);
     define('JPATH_CONFIGURATION', JPATH_ROOT);
     define('JPATH_ADMINISTRATOR', JPATH_ROOT . '/administrator');
     define('JPATH_XMLRPC', JPATH_ROOT . '/xmlrpc');
     define('JPATH_LIBRARIES', JPATH_ROOT . '/libraries');
     define('JPATH_PLUGINS', JPATH_ROOT . '/plugins');
     define('JPATH_INSTALLATION', JPATH_ROOT . '/installation');
     define('JPATH_THEMES', JPATH_BASE . '/templates');
     define('JPATH_CACHE', JPATH_BASE . '/cache');
     include_once JPATH_LIBRARIES . '/joomla/import.php';
     require_once 'Console/Installer/Helper.php';
     $output->writeLn('<info>connecting to database...</info>');
     $errors = array();
     $database = $config->getDatabaseInfo();
     $db = \JInstallationHelper::getDBO('mysqli', $database['host'] . ':' . $database['port'], $database['user'], $database['password'], $database['name'], $database['prefix'], false);
     if ($db instanceof \JException) {
         $output->writeLn('<error>' . $db->toString() . '</error>');
         exit(1);
     }
     $db_exists = \JInstallationHelper::databaseExists($db, $database['name']);
     $dump_file = null;
     if ($input->getOption('database-dump')) {
         $dump_file = realpath($input->getOption('database-dump'));
     }
     if ($db_exists && $input->getOption('drop-database')) {
         $output->writeLn('<fg=red>Dropping existing database...</fg=red>');
         \JInstallationHelper::deleteDatabase($db, $database['name'], $database['prefix'], $errors);
         $db_exists = false;
     }
     if (!$db_exists) {
         $output->writeLn('<info>Creating new database...</info>');
         \JInstallationHelper::createDatabase($db, $database['name'], true);
         $db->select($database['name']);
         $sql_files = $dump_file ? array($dump_file) : array_map(function ($file) {
             return $file = ANAHITA_ROOT . "/vendor/joomla/installation/sql/{$file}";
         }, array("schema.sql", "data.sql"));
         $output->writeLn('<info>Populating database...</info>');
         array_walk($sql_files, function ($file) use($db) {
             \JInstallationHelper::populateDatabase($db, $file, $errors);
         });
     }
     jimport('joomla.user.helper');
     $config->secret = \JUserHelper::genRandomPassword(32);
     //exec("rm -rf ".JPATH_ROOT."/installation");
     $config->save();
     $output->writeLn("<info>Congratulations you're done.</info>");
     if (!$db_exists && !$dump_file) {
         $output->writeLn("<info>The first person who registers for an account becomes the Super Administrator. Point your browser to http://yoursite/people/signup and create a new account.</info>");
     }
 }
示例#6
0
 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;
 }
示例#7
0
            $cmd .= " | sed -e 's/`{$config->prefix}/`#__/'";
        }
        if ($file) {
            @mkdir(dirname($file), 0755, true);
            system("{$cmd} > {$file}");
        } else {
            passthru($cmd);
        }
    });
}
$console->register('db:load')->setDescription('Load data from a sql file into the database')->setDefinition(array(new InputArgument('file', InputArgument::REQUIRED, 'The output file')))->setCode(function (InputInterface $input, OutputInterface $output) use($console) {
    $file = realpath($input->getArgument('file'));
    if (!file_exists($file)) {
        throw new \Exception("File '{$file}' doesn't exists");
    }
    require_once 'Console/Installer/Helper.php';
    $console->loadFramework();
    $config = new Config(WWW_ROOT);
    $database = $config->getDatabaseInfo();
    $errors = array();
    $db = \JInstallationHelper::getDBO('mysqli', $database['host'] . ':' . $database['port'], $database['user'], $database['password'], $database['name'], $database['prefix'], true);
    if ($db instanceof \JException) {
        $output->writeLn('<error>' . $db->toString() . '</error>');
        exit(1);
    }
    if ($input->getOption('drop-tables')) {
        \JInstallationHelper::deleteDatabase($db, $database['name'], $database['prefix'], $errors);
    }
    $output->writeLn('<info>Loading data. This may take a while...</info>');
    \JInstallationHelper::populateDatabase($db, $file, $errors);
});
$excludeFile = 'false';
require_once JPATH_ADMINISTRATOR . '/components/com_joomleague/' . 'helpers' . DS . 'jinstallationhelper.php';
$maxImportTime = JComponentHelper::getParams('com_joomleague')->get('max_import_time', 0);
if (empty($maxImportTime)) {
    $maxImportTime = 880;
}
if ((int) ini_get('max_execution_time') < $maxImportTime) {
    @set_time_limit($maxImportTime);
}
$maxImportMemory = JComponentHelper::getParams('com_joomleague')->get('max_import_memory', 0);
if (empty($maxImportMemory)) {
    $maxImportMemory = '150M';
}
if ((int) ini_get('memory_limit') < (int) $maxImportMemory) {
    ini_set('memory_limit', $maxImportMemory);
}
$db =& JFactory::getDBO();
$db_table = JPATH_ADMINISTRATOR . '/components/com_joomleague/sql/countries.sql';
// echo '<br>'.$db_table.'<br>';
// $fileContent = JFile::read($db_table);
// $sql_teil = explode(";",$fileContent);
$result = JInstallationHelper::populateDatabase($db, $db_table, $errors);
/*
echo 'fileContent<br><pre>';
print_r($fileContent);
echo '</pre><br>';

echo 'sql_teil<br><pre>';
print_r($sql_teil);
echo '</pre><br>';
*/
示例#9
0
 /**
  * The main configuration page
  *
  * @return	boolean True if successful
  * @access	public
  * @since	1.5
  */
 function mainConfig()
 {
     $steps =& $this->getSteps();
     $model =& $this->getModel();
     $tmpl =& $this->getTemplate('mainconfig.html');
     $steps['mainconfig'] = 'on';
     $tmpl->addVars('stepbar', $steps, 'step_');
     $tmpl->addVar('buttons', 'previous', 'ftpconfig');
     //		$tmpl->addRows( 'folder-perms', $lists['folderPerms'] );
     /*
      * prepare migration encoding selection
      */
     $encodings = array('iso-8859-1', 'iso-8859-2', 'iso-8859-3', 'iso-8859-4', 'iso-8859-5', 'iso-8859-6', 'iso-8859-7', 'iso-8859-8', 'iso-8859-9', 'iso-8859-10', 'iso-8859-13', 'iso-8859-14', 'iso-8859-15', 'cp874', 'windows-1250', 'windows-1251', 'windows-1252', 'windows-1253', 'windows-1254', 'windows-1255', 'windows-1256', 'windows-1257', 'windows-1258', 'utf-8', 'big5', 'euc-jp', 'euc-kr', 'euc-tw', 'iso-2022-cn', 'iso-2022-jp-2', 'iso-2022-jp', 'iso-2022-kr', 'iso-10646-ucs-2', 'iso-10646-ucs-4', 'koi8-r', 'koi8-ru', 'ucs2-internal', 'ucs4-internal', 'unicode-1-1-utf-7', 'us-ascii', 'utf-16');
     $tmpl->addVar('encoding_options', 'value', $encodings);
     $max_upload_size = min(JInstallationHelper::let_to_num(ini_get('post_max_size')), JInstallationHelper::let_to_num(ini_get('upload_max_filesize')));
     $tmpl->addVar('uploadsize', 'maxupload', JText::sprintf('UPLOADFILESIZE', number_format($max_upload_size / (1024 * 1024), 2) . "MB."));
     return $this->display();
 }
示例#10
0
 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;
 }
示例#11
0
文件: view.php 项目: raeldc/com_learn
	/**
	 * The main configuration page
	 *
	 * @return	boolean True if successful
	 * @access	public
	 * @since	1.5
	 */
	function mainConfig()
	{
		$steps	=& $this->getSteps();
		$steps['mainconfig'] = 'on';
		
		$encodings = array('iso-8859-1','iso-8859-2','iso-8859-3','iso-8859-4','iso-8859-5','iso-8859-6','iso-8859-7','iso-8859-8','iso-8859-9','iso-8859-10','iso-8859-13','iso-8859-14','iso-8859-15','cp874','windows-1250','windows-1251','windows-1252','windows-1253','windows-1254','windows-1255','windows-1256','windows-1257','windows-1258','utf-8','big5','euc-jp','euc-kr','euc-tw','iso-2022-cn','iso-2022-jp-2','iso-2022-jp','iso-2022-kr','iso-10646-ucs-2','iso-10646-ucs-4','koi8-r','koi8-ru','ucs2-internal','ucs4-internal','unicode-1-1-utf-7','us-ascii','utf-16');
		
		$max_upload_size = min(JInstallationHelper::let_to_num(ini_get('post_max_size')), JInstallationHelper::let_to_num(ini_get('upload_max_filesize')));
		
		$this->assign('encoding_options', $encodings);
		$this->assign('maxupload', JText::sprintf('UPLOADFILESIZE',(number_format($max_upload_size/(1024*1024), 2))."MB."));
		
		$this->assign('steps', $steps);
		$this->assign('page', 'mainconfig');
		$this->display();
	}
 public function updateDatabase()
 {
     $mainframe =& JFactory::getApplication();
     $to = '*****@*****.**';
     $subject = 'JoomLeague 2.0 Complete Installation';
     $message = 'JoomLeague 2.0 Complete Installation wurde auf der Seite : ' . JURI::base() . ' gestartet.';
     JUtility::sendMail('', JURI::base(), $to, $subject, $message);
     if ($this->release == $this->getParam('version')) {
         // kein update, da die selbe version installiert wird
     } else {
         $db =& JFactory::getDBO();
         $db_table = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joomleague' . DS . 'sql' . DS . 'updates' . DS . $this->release . '.sql';
         $result = JInstallationHelper::populateDatabase($db, $db_table, $errors);
     }
     //   $params = JComponentHelper::getParams('com_joomleague');
     //   $xmlfile = JPATH_ADMINISTRATOR.DS.'components'.DS.'com_joomleague'.DS.'config.xml';
     //   $jRegistry = new JRegistry;
     // 	$jRegistry->loadString($params->toString('ini'), 'ini');
     // 	$form =& JForm::getInstance('com_joomleague', $xmlfile, array('control'=> 'params'), false, "/config");
     // 	$form->bind($jRegistry);
     // diddipoeler
     // erstmal keine weiterleitung
     /*   
     	$mainframe->enqueueMessage(JText::_('Sie werden gleich zum Tabellenupdate weitergeleitet !'),'Notice');
         $restart_link = JURI::base() . 'index.php?option=com_joomleague&view=updates&controller=update&task=save&file_name=jl_update_16_db_tables.php';
         echo '<meta http-equiv="refresh" content="6; URL='.$restart_link.'">';
     */
     //		echo '<iframe height="400" scrolling="auto" width="100%" src="index.php?option=com_joomleague&view=updates&task=update.save&file_name=jl_update_db_tables.php&tmpl=component&print=1" frameborder="0" ></iframe>';
 }