[!!!][SECURITY] Allow first install only with FIRST_INSTALL file
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Service / EnableFileService.php
index 24b2343..74bd686 100644 (file)
@@ -37,6 +37,21 @@ class EnableFileService {
         */
        const INSTALL_TOOL_ENABLE_FILE_PATH = 'typo3conf/ENABLE_INSTALL_TOOL';
 
+       /**
+        * @constant Relative path to  FIRST_INSTALL file
+        */
+       const FIRST_INSTALL_FILE_PATH = 'FIRST_INSTALL';
+
+       /**
+        * @return bool
+        */
+       static public function isFirstInstallAllowed() {
+               if (!is_dir(PATH_typo3conf) && is_file(self::getFirstInstallFilePath())) {
+                       return TRUE;
+               }
+               return FALSE;
+       }
+
        /**
         * Creates the INSTALL_TOOL_ENABLE file
         *
@@ -63,6 +78,15 @@ class EnableFileService {
                return unlink(self::getInstallToolEnableFilePath());
        }
 
+       /**
+        * Removes the FIRST_INSTALL file
+        *
+        * @return boolean
+        */
+       static public function removeFirstInstallFile() {
+               return unlink(self::getFirstInstallFilePath());
+       }
+
        /**
         * Checks if the install tool file exists
         *
@@ -114,4 +138,13 @@ class EnableFileService {
        static protected function getInstallToolEnableFilePath() {
                return PATH_site . self::INSTALL_TOOL_ENABLE_FILE_PATH;
        }
+
+       /**
+        * Returns the path to the INSTALL_TOOL_ENABLE file
+        *
+        * @return string
+        */
+       static protected function getFirstInstallFilePath() {
+               return PATH_site . self::FIRST_INSTALL_FILE_PATH;
+       }
 }