‪TYPO3CMS  9.5
EnableFileService.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
18 
24 {
28  const ‪INSTALL_TOOL_ENABLE_FILE_PATH = 'typo3conf/ENABLE_INSTALL_TOOL';
29 
33  const ‪FIRST_INSTALL_FILE_PATH = 'FIRST_INSTALL';
34 
39 
43  public static function ‪isFirstInstallAllowed()
44  {
46  if (!empty($files)) {
47  return true;
48  }
49  return false;
50  }
51 
57  public static function ‪createInstallToolEnableFile()
58  {
59  $installEnableFilePath = ‪self::getInstallToolEnableFilePath();
60  if (!is_file($installEnableFilePath)) {
61  $result = touch($installEnableFilePath);
62  } else {
63  $result = true;
65  }
66  GeneralUtility::fixPermissions($installEnableFilePath);
67  return $result;
68  }
69 
75  public static function ‪removeInstallToolEnableFile()
76  {
77  return unlink(self::getInstallToolEnableFilePath());
78  }
79 
85  public static function ‪removeFirstInstallFile()
86  {
87  $result = true;
89  foreach ($files as $file) {
90  $result = unlink(‪Environment::getPublicPath() . '/' . $file) && $result;
91  }
92  return $result;
93  }
94 
100  public static function ‪installToolEnableFileExists()
101  {
102  return @is_file(self::getInstallToolEnableFilePath());
103  }
104 
110  public static function ‪checkInstallToolEnableFile()
111  {
112  if (!self::installToolEnableFileExists()) {
113  return false;
114  }
115  if (!self::isInstallToolEnableFilePermanent()) {
116  if (self::installToolEnableFileLifetimeExpired()) {
118  return false;
119  }
121  }
122  return true;
123  }
124 
130  public static function ‪isInstallToolEnableFilePermanent()
131  {
132  if (self::installToolEnableFileExists()) {
133  $content = @file_get_contents(self::getInstallToolEnableFilePath());
134  if (strpos($content, 'KEEP_FILE') !== false) {
135  return true;
136  }
137  }
138  return false;
139  }
140 
147  {
148  if (time() - @filemtime(self::getInstallToolEnableFilePath()) > self::INSTALL_TOOL_ENABLE_FILE_LIFETIME) {
149  return true;
150  }
151  return false;
152  }
153 
157  protected static function ‪extendInstallToolEnableFileLifetime()
158  {
160  // Extend the age of the ENABLE_INSTALL_TOOL file by one hour
161  if (is_file($enableFile)) {
162  $couldTouch = @touch($enableFile);
163  if (!$couldTouch) {
164  // If we can't remove the creation method will call us again.
165  if (self::removeInstallToolEnableFile()) {
167  }
168  }
169  }
170  }
171 
177  protected static function ‪getInstallToolEnableFilePath()
178  {
180  }
181 
187  protected static function ‪getFirstInstallFilePaths()
188  {
189  $files = array_filter(scandir(‪Environment::getPublicPath() . '/'), function ($file) {
190  return @is_file(‪Environment::getPublicPath() . '/' . $file) && preg_match('~^' . self::FIRST_INSTALL_FILE_PATH . '.*~i', $file);
191  });
192  return $files;
193  }
194 }
‪TYPO3\CMS\Install\Service\EnableFileService\getFirstInstallFilePaths
‪static array getFirstInstallFilePaths()
Definition: EnableFileService.php:187
‪TYPO3\CMS\Install\Service\EnableFileService\FIRST_INSTALL_FILE_PATH
‪const FIRST_INSTALL_FILE_PATH
Definition: EnableFileService.php:33
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:153
‪TYPO3\CMS\Install\Service\EnableFileService\installToolEnableFileLifetimeExpired
‪static bool installToolEnableFileLifetimeExpired()
Definition: EnableFileService.php:146
‪TYPO3\CMS\Install\Service\EnableFileService\extendInstallToolEnableFileLifetime
‪static extendInstallToolEnableFileLifetime()
Definition: EnableFileService.php:157
‪TYPO3\CMS\Install\Service\EnableFileService\INSTALL_TOOL_ENABLE_FILE_PATH
‪const INSTALL_TOOL_ENABLE_FILE_PATH
Definition: EnableFileService.php:28
‪TYPO3\CMS\Install\Service\EnableFileService
Definition: EnableFileService.php:24
‪TYPO3\CMS\Install\Service\EnableFileService\INSTALL_TOOL_ENABLE_FILE_LIFETIME
‪const INSTALL_TOOL_ENABLE_FILE_LIFETIME
Definition: EnableFileService.php:38
‪TYPO3\CMS\Install\Service\EnableFileService\getInstallToolEnableFilePath
‪static string getInstallToolEnableFilePath()
Definition: EnableFileService.php:177
‪TYPO3\CMS\Install\Service\EnableFileService\checkInstallToolEnableFile
‪static bool checkInstallToolEnableFile()
Definition: EnableFileService.php:110
‪TYPO3\CMS\Install\Service\EnableFileService\removeInstallToolEnableFile
‪static bool removeInstallToolEnableFile()
Definition: EnableFileService.php:75
‪TYPO3\CMS\Install\Service\EnableFileService\installToolEnableFileExists
‪static bool installToolEnableFileExists()
Definition: EnableFileService.php:100
‪TYPO3\CMS\Install\Service\EnableFileService\removeFirstInstallFile
‪static bool removeFirstInstallFile()
Definition: EnableFileService.php:85
‪TYPO3\CMS\Install\Service\EnableFileService\isInstallToolEnableFilePermanent
‪static bool isInstallToolEnableFilePermanent()
Definition: EnableFileService.php:130
‪TYPO3\CMS\Install\Service\EnableFileService\isFirstInstallAllowed
‪static bool isFirstInstallAllowed()
Definition: EnableFileService.php:43
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:39
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Install\Service
Definition: ClearCacheService.php:2
‪TYPO3\CMS\Install\Service\EnableFileService\createInstallToolEnableFile
‪static bool createInstallToolEnableFile()
Definition: EnableFileService.php:57