TYPO3 CMS  TYPO3_6-2
EnableFileService.php
Go to the documentation of this file.
1 <?php
3 
21 
25  const INSTALL_TOOL_ENABLE_FILE_PATH = 'typo3conf/ENABLE_INSTALL_TOOL';
26 
30  const FIRST_INSTALL_FILE_PATH = 'FIRST_INSTALL';
31 
36 
40  static public function isFirstInstallAllowed() {
41  if (!is_dir(PATH_typo3conf) && is_file(self::getFirstInstallFilePath())) {
42  return TRUE;
43  }
44  return FALSE;
45  }
46 
52  static public function createInstallToolEnableFile() {
53  $installEnableFilePath = self::getInstallToolEnableFilePath();
54  if (!is_file($installEnableFilePath)) {
55  $result = touch($installEnableFilePath);
56  } else {
57  $result = TRUE;
58  self::extendInstallToolEnableFileLifetime();
59  }
61  return $result;
62  }
63 
69  static public function removeInstallToolEnableFile() {
70  return unlink(self::getInstallToolEnableFilePath());
71  }
72 
78  static public function removeFirstInstallFile() {
79  return unlink(self::getFirstInstallFilePath());
80  }
81 
87  static public function installToolEnableFileExists() {
88  return @is_file(self::getInstallToolEnableFilePath());
89  }
90 
96  static public function checkInstallToolEnableFile() {
97  if (!self::installToolEnableFileExists()) {
98  return FALSE;
99  }
100  if (!self::isInstallToolEnableFilePermanent()) {
101  if (self::installToolEnableFileLifetimeExpired()) {
102  self::removeInstallToolEnableFile();
103  return FALSE;
104  }
105  self::extendInstallToolEnableFileLifetime();
106  }
107  return TRUE;
108  }
109 
115  static public function isInstallToolEnableFilePermanent() {
116  if (self::installToolEnableFileExists()) {
117  $content = @file_get_contents(self::getInstallToolEnableFilePath());
118  if (strpos($content, 'KEEP_FILE') !== FALSE) {
119  return TRUE;
120  }
121  }
122  return FALSE;
123  }
124 
125 
131  static public function installToolEnableFileLifetimeExpired() {
132  if (time() - @filemtime(self::getInstallToolEnableFilePath()) > self::INSTALL_TOOL_ENABLE_FILE_LIFETIME) {
133  return TRUE;
134  } else {
135  return FALSE;
136  }
137  }
138 
144  static protected function extendInstallToolEnableFileLifetime() {
145  $enableFile = self::getInstallToolEnableFilePath();
146  // Extend the age of the ENABLE_INSTALL_TOOL file by one hour
147  if (is_file($enableFile)) {
148  $couldTouch = @touch($enableFile);
149  if (!$couldTouch) {
150  // If we can't remove the creation method will call us again.
151  if (self::removeInstallToolEnableFile()) {
152  self::createInstallToolEnableFile();
153  }
154  }
155  }
156  }
157 
163  static protected function getInstallToolEnableFilePath() {
164  return PATH_site . self::INSTALL_TOOL_ENABLE_FILE_PATH;
165  }
166 
172  static protected function getFirstInstallFilePath() {
173  return PATH_site . self::FIRST_INSTALL_FILE_PATH;
174  }
175 }
static fixPermissions($path, $recursive=FALSE)
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.