TYPO3 CMS  TYPO3_6-2
DatabaseData.php
Go to the documentation of this file.
1 <?php
3 
21 
27  public function execute() {
28  $result = array();
29 
31  $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
32 
33  $postValues = $this->postValues['values'];
34 
35  $username = strlen($postValues['username']) ? $postValues['username'] : 'admin';
36 
37  // Check password and return early if not good enough
38  $password = $postValues['password'];
39  if (strlen($password) < 8) {
40  $errorStatus = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
41  $errorStatus->setTitle('Administrator password not secure enough!');
42  $errorStatus->setMessage(
43  'You are setting an important password here! It gives an attacker full control over your instance if cracked.' .
44  ' It should be strong (include lower and upper case characters, special characters and numbers) and must be at least eight characters long.'
45  );
46  $result[] = $errorStatus;
47  return $result;
48  }
49 
50  // Set site name
51  if (!empty($postValues['sitename'])) {
52  $configurationManager->setLocalConfigurationValueByPath('SYS/sitename', $postValues['sitename']);
53  }
54 
55  $this->importDatabaseData();
56 
57  // Insert admin user
58  $hashedPassword = $this->getHashedPassword($password);
59  $adminUserFields = array(
60  'username' => $username,
61  'password' => $hashedPassword,
62  'admin' => 1,
63  'tstamp' => $GLOBALS['EXEC_TIME'],
64  'crdate' => $GLOBALS['EXEC_TIME']
65  );
66  $this->getDatabaseConnection()->exec_INSERTquery('be_users', $adminUserFields);
67 
68  // Set password as install tool password
69  $configurationManager->setLocalConfigurationValueByPath('BE/installToolPassword', $hashedPassword);
70 
71  return $result;
72  }
73 
79  public function needsExecution() {
80  $result = FALSE;
81  $existingTables = $this->getDatabaseConnection()->admin_get_tables();
82  if (count($existingTables) === 0) {
83  $result = TRUE;
84  }
85  return $result;
86  }
87 
93  protected function executeAction() {
94  $this->assignSteps();
95  return $this->view->render();
96  }
97 
103  protected function importDatabaseData() {
104  // Will load ext_localconf and ext_tables. This is pretty safe here since we are
105  // in first install (database empty), so it is very likely that no extension is loaded
106  // that could trigger a fatal at this point.
108 
109  // Import database data
110  $database = $this->getDatabaseConnection();
112  $schemaMigrationService = $this->objectManager->get('TYPO3\\CMS\\Install\\Service\\SqlSchemaMigrationService');
114  $expectedSchemaService = $this->objectManager->get('TYPO3\\CMS\\Install\\Service\\SqlExpectedSchemaService');
115 
116  // Raw concatenated ext_tables.sql and friends string
117  $expectedSchemaString = $expectedSchemaService->getTablesDefinitionString(TRUE);
118  $statements = $schemaMigrationService->getStatementArray($expectedSchemaString, TRUE);
119  list($_, $insertCount) = $schemaMigrationService->getCreateTables($statements, TRUE);
120 
121  $fieldDefinitionsFile = $schemaMigrationService->getFieldDefinitions_fileContent($expectedSchemaString);
122  $fieldDefinitionsDatabase = $schemaMigrationService->getFieldDefinitions_database();
123  $difference = $schemaMigrationService->getDatabaseExtra($fieldDefinitionsFile, $fieldDefinitionsDatabase);
124  $updateStatements = $schemaMigrationService->getUpdateSuggestions($difference);
125 
126  $schemaMigrationService->performUpdateQueries($updateStatements['add'], $updateStatements['add']);
127  $schemaMigrationService->performUpdateQueries($updateStatements['change'], $updateStatements['change']);
128  $schemaMigrationService->performUpdateQueries($updateStatements['create_table'], $updateStatements['create_table']);
129 
130  foreach ($insertCount as $table => $count) {
131  $insertStatements = $schemaMigrationService->getTableInsertStatements($statements, $table);
132  foreach ($insertStatements as $insertQuery) {
133  $insertQuery = rtrim($insertQuery, ';');
134  $database->admin_query($insertQuery);
135  }
136  }
137  }
138 }
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
$database
Definition: server.php:38
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]