コード例 #1
0
ファイル: view.html.php プロジェクト: rafnixg/jokte-cms
 public function getDataInstall()
 {
     require_once JPATH_INSTALLATION . '/helpers/database.php';
     $site = NULL;
     $result = NULL;
     $path = str_replace('installation', '', JPATH_BASE);
     if (file_exists($path . 'configuration.php')) {
         require $path . 'configuration.php';
         $cfg = new JConfig();
         $site = $cfg->sitename;
         $db = JInstallationHelperDatabase::getDBO($cfg->dbtype, $cfg->host, $cfg->user, $cfg->password, $cfg->db, $cfg->dbprefix);
         $qry = "SELECT * FROM #__users";
         $db->setQuery($qry);
         $result = $db->loadAssocList();
         $result[0]['site'] = $site;
     }
     return isset($result[0]) ? $result[0] : false;
 }
コード例 #2
0
 function _createRootUser($options)
 {
     // Get a database object.
     try {
         $db = JInstallationHelperDatabase::getDBO($options->db_type, $options->db_host, $options->db_user, $options->db_pass, $options->db_name, $options->db_prefix);
     } catch (JDatabaseException $e) {
         $this->setError(JText::sprintf('INSTL_ERROR_CONNECT_DB', $e->getMessage()));
     }
     // Create random salt/password for the admin user
     $salt = JUserHelper::genRandomPassword(32);
     $crypt = JUserHelper::getCryptedPassword($options->admin_password, $salt);
     $cryptpass = $crypt . ':' . $salt;
     // create the admin user
     date_default_timezone_set('UTC');
     $installdate = date('Y-m-d H:i:s');
     $nullDate = $db->getNullDate();
     //sqlsrv change
     $query = $db->getQuery(true);
     $query->select('id');
     $query->from('#__users');
     $query->where('id = 42');
     $db->setQuery($query);
     if ($db->loadResult()) {
         $query = $db->getQuery(true);
         $query->update('#__users');
         $query->set('name = ' . $db->quote('Super User'));
         $query->set('username = '******'email = ' . $db->quote($options->admin_email));
         $query->set('password = '******'block = 0');
         $query->set('sendEmail = 1');
         $query->set('registerDate = ' . $db->quote($installdate));
         $query->set('lastvisitDate = ' . $db->quote($nullDate));
         $query->set('activation = ' . $db->quote('0'));
         $query->set('params = ' . $db->quote(''));
         $query->where('id = 42');
     } else {
         $query = $db->getQuery(true);
         $columns = array($db->quoteName('id'), $db->quoteName('name'), $db->quoteName('username'), $db->quoteName('email'), $db->quoteName('password'), $db->quoteName('block'), $db->quoteName('sendEmail'), $db->quoteName('registerDate'), $db->quoteName('lastvisitDate'), $db->quoteName('activation'), $db->quoteName('params'));
         $query->insert('#__users', true);
         $query->columns($columns);
         $query->values('42' . ', ' . $db->quote('Super User') . ', ' . $db->quote($options->admin_user) . ', ' . $db->quote($options->admin_email) . ', ' . $db->quote($cryptpass) . ', ' . $db->quote('deprecated') . ', ' . $db->quote('1') . ', ' . $db->quote($installdate) . ', ' . $db->quote($nullDate) . ', ' . $db->quote('0') . ', ' . $db->quote(''));
     }
     $db->setQuery($query);
     if (!$db->query()) {
         $this->setError($db->getErrorMsg());
         return false;
     }
     // Map the super admin to the Super Admin Group
     $query = $db->getQuery(true);
     $query->select('user_id');
     $query->from('#__user_usergroup_map');
     $query->where('user_id = 42');
     $db->setQuery($query);
     if ($db->loadResult()) {
         $query = $db->getQuery(true);
         $query->update('#__user_usergroup_map');
         $query->set('user_id = 42');
         $query->set('group_id = 8');
     } else {
         $query = $db->getQuery(true);
         $query->insert('#__user_usergroup_map', false);
         $query->columns(array($db->quoteName('user_id'), $db->quoteName('group_id')));
         $query->values('42' . ', ' . '8');
     }
     $db->setQuery($query);
     if (!$db->query()) {
         $this->setError($db->getErrorMsg());
         return false;
     }
     return true;
 }
コード例 #3
0
ファイル: configuration.php プロジェクト: akksi/jcg
 function _createRootUser($options)
 {
     // Get a database object.
     $db = JInstallationHelperDatabase::getDBO($options->db_type, $options->db_host, $options->db_user, $options->db_pass, $options->db_name, $options->db_prefix);
     // Check for errors.
     if (JError::isError($db)) {
         $this->setError(JText::sprintf('INSTL_ERROR_CONNECT_DB', (string) $db));
         return false;
     }
     // Check for database errors.
     if ($err = $db->getErrorNum()) {
         $this->setError(JText::sprintf('INSTL_ERROR_CONNECT_DB', $db->getErrorNum()));
         return false;
     }
     // Create random salt/password for the admin user
     $salt = JUserHelper::genRandomPassword(32);
     $crypt = JUserHelper::getCryptedPassword($options->admin_password, $salt);
     $cryptpass = $crypt . ':' . $salt;
     // create the admin user
     date_default_timezone_set('UTC');
     $installdate = date('Y-m-d H:i:s');
     $nullDate = $db->getNullDate();
     $query = 'REPLACE INTO #__users SET' . ' id = 42' . ', name = ' . $db->quote('Super User') . ', username = '******', email = ' . $db->quote($options->admin_email) . ', password = '******', usertype = ' . $db->quote('deprecated') . ', block = 0' . ', sendEmail = 1' . ', registerDate = ' . $db->quote($installdate) . ', lastvisitDate = ' . $db->quote($nullDate) . ', activation = ' . $db->quote('') . ', params = ' . $db->quote('');
     $db->setQuery($query);
     if (!$db->query()) {
         $this->setError($db->getErrorMsg());
         return false;
     }
     // Map the super admin to the Super Admin Group
     $query = 'REPLACE INTO #__user_usergroup_map' . ' SET user_id = 42, group_id = 8';
     $db->setQuery($query);
     if (!$db->query()) {
         $this->setError($db->getErrorMsg());
         return false;
     }
     return true;
 }
コード例 #4
0
ファイル: database.php プロジェクト: vuchannguyen/lannuanhe
 function installSampleData($options)
 {
     // Get the options as a JObject for easier handling.
     $options = JArrayHelper::toObject($options, 'JObject');
     // Get a database object.
     try {
         $db = JInstallationHelperDatabase::getDBO($options->db_type, $options->db_host, $options->db_user, $options->db_pass, $options->db_name, $options->db_prefix);
     } catch (RuntimeException $e) {
         $this->setError(JText::sprintf('INSTL_DATABASE_COULD_NOT_CONNECT', $e->getMessage()));
         return false;
     }
     // Build the path to the sample data file.
     $type = $options->db_type;
     if ($type == 'mysqli') {
         $type = 'mysql';
     } elseif ($type == 'sqlsrv') {
         $type = 'sqlazure';
     }
     $data = JPATH_INSTALLATION . '/sql/' . $type . '/' . $options->sample_file;
     // Attempt to import the database schema.
     if (!file_exists($data)) {
         $this->setError(JText::sprintf('INSTL_DATABASE_FILE_DOES_NOT_EXIST', $data));
         return false;
     } elseif (!$this->populateDatabase($db, $data)) {
         $this->setError(JText::sprintf('INSTL_ERROR_DB', $this->getError()));
         return false;
     }
     $this->postInstallSampleData($db);
     return true;
 }
コード例 #5
0
ファイル: configuration.php プロジェクト: rafnixg/jokte-cms
 function _createRootUser($options)
 {
     // Get a database object.
     try {
         $db = JInstallationHelperDatabase::getDBO($options->db_type, $options->db_host, $options->db_user, $options->db_pass, $options->db_name, $options->db_prefix);
     } catch (RuntimeException $e) {
         $this->setError(JText::sprintf('INSTL_ERROR_CONNECT_DB', $e->getMessage()));
     }
     // Create random salt/password for the admin user
     $cryptpass = JUserHelper::hashPassword($options->admin_password);
     // take the admin user id
     JLoader::register('JInstallationModelDatabase', JPATH_INSTALLATION . '/models/database.php');
     $userId = JInstallationModelDatabase::getUserId();
     //we don't need anymore the randUserId in the session, let's remove it
     JInstallationModelDatabase::resetRandUserId();
     // create the admin user
     date_default_timezone_set('UTC');
     $installdate = date('Y-m-d H:i:s');
     $nullDate = $db->getNullDate();
     //sqlsrv change
     $query = $db->getQuery(true);
     $query->select('id');
     $query->from('#__users');
     $query->where('id = ' . $db->quote($userId));
     $db->setQuery($query);
     if ($db->loadResult()) {
         $query = $db->getQuery(true);
         $query->update('#__users');
         $query->set('name = ' . $db->quote('Super User'));
         $query->set('username = '******'email = ' . $db->quote($options->admin_email));
         $query->set('password = '******'usertype = ' . $db->quote('deprecated'));
         $query->set('block = 0');
         $query->set('sendEmail = 1');
         $query->set('registerDate = ' . $db->quote($installdate));
         $query->set('lastvisitDate = ' . $db->quote($nullDate));
         $query->set('activation = ' . $db->quote('0'));
         $query->set('params = ' . $db->quote(''));
         $query->where('id = ' . $db->quote($userId));
     } else {
         $query = $db->getQuery(true);
         $columns = array($db->quoteName('id'), $db->quoteName('name'), $db->quoteName('username'), $db->quoteName('email'), $db->quoteName('password'), $db->quoteName('usertype'), $db->quoteName('block'), $db->quoteName('sendEmail'), $db->quoteName('registerDate'), $db->quoteName('lastvisitDate'), $db->quoteName('activation'), $db->quoteName('params'));
         $query->insert('#__users', true);
         $query->columns($columns);
         $query->values($db->quote($userId) . ', ' . $db->quote('Super User') . ', ' . $db->quote(trim($options->admin_user)) . ', ' . $db->quote($options->admin_email) . ', ' . $db->quote($cryptpass) . ', ' . $db->quote('deprecated') . ', ' . $db->quote('0') . ', ' . $db->quote('1') . ', ' . $db->quote($installdate) . ', ' . $db->quote($nullDate) . ', ' . $db->quote('0') . ', ' . $db->quote(''));
     }
     $db->setQuery($query);
     try {
         $db->execute();
     } catch (RuntimeException $e) {
         $this->setError($e->getMessage());
         return false;
     }
     // Map the super admin to the Super Admin Group
     $query = $db->getQuery(true);
     $query->select('user_id');
     $query->from('#__user_usergroup_map');
     $query->where('user_id = ' . $db->quote($userId));
     $db->setQuery($query);
     if ($db->loadResult()) {
         $query = $db->getQuery(true);
         $query->update('#__user_usergroup_map');
         $query->set('user_id = ' . $db->quote($userId));
         $query->set('group_id = 8');
     } else {
         $query = $db->getQuery(true);
         $query->insert('#__user_usergroup_map', false);
         $query->columns(array($db->quoteName('user_id'), $db->quoteName('group_id')));
         $query->values($userId . ', ' . '8');
     }
     $db->setQuery($query);
     try {
         $db->execute();
     } catch (RuntimeException $e) {
         $this->setError($e->getMessage());
         return false;
     }
     return true;
 }
コード例 #6
0
ファイル: database.php プロジェクト: joebushi/joomla
 function installSampleData($options)
 {
     // Get the options as a JObject for easier handling.
     $options = JArrayHelper::toObject($options, 'JObject');
     // Get a database object.
     $db =& JInstallationHelperDatabase::getDBO($options->db_type, $options->db_host, $options->db_user, $options->db_pass, $options->db_name, $options->db_prefix);
     // Check for errors.
     if (JError::isError($db)) {
         $this->setError(JText::sprintf('WARNNOTCONNECTDB', $db->toString()));
         return false;
     }
     // Check for database errors.
     if ($err = $db->getErrorNum()) {
         $this->setError(JText::sprintf('WARNNOTCONNECTDB', $db->getErrorNum()));
         return false;
     }
     // Build the path to the sample data file.
     $type = $options->db_type;
     if ($type == 'mysqli') {
         $type = 'mysql';
     }
     $data = JPATH_INSTALLATION . '/sql/' . $type . '/sample_data.sql';
     // Attempt to import the database schema.
     if (!$this->populateDatabase($db, $data)) {
         $this->setError(JText::sprintf('Instl_Error_DB', $this->getError()));
         return false;
     }
     return true;
 }
コード例 #7
0
ファイル: install_db.php プロジェクト: sangkasi/joomla
require_once JPATH_LIBRARIES . '/joomla/factory.php';
require_once JPATH_LIBRARIES . '/joomla/import.php';
require_once JPATH_LIBRARIES . '/joomla/error/error.php';
require_once JPATH_LIBRARIES . '/joomla/base/object.php';
require_once JPATH_LIBRARIES . '/joomla/database/database.php';
require_once JPATH_INSTALLATION . '/models/database.php';
// jUpgrade class
require_once JPATH_BASE . '/jupgrade.class.php';
// jUpgrade class
$jupgrade = new jUpgrade();
// Getting the component parameter with global settings
$params = $jupgrade->getParams();
// getting config
$jconfig = new JConfig();
$config = array();
$config['dbo'] =& JInstallationHelperDatabase::getDBO('mysql', $jconfig->host, $jconfig->user, $jconfig->password, $jconfig->db, 'j16_');
// getting helper
$installHelper = new JInstallationModelDatabase($config);
// installing global database
$schema = JPATH_INSTALLATION . '/sql/mysql/joomla.sql';
if (!$installHelper->populateDatabase($config['dbo'], $schema) > 0) {
    return 1;
    exit;
}
// installing Molajo database
if ($params->mode == 1) {
    $schema = JPATH_INSTALLATION . '/sql/mysql/joomla2.sql';
    if (!$installHelper->populateDatabase($config['dbo'], $schema) > 0) {
        return 1;
        exit;
    }