Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function gc($dataTTL)
 {
     $files = $this->fileSystem->glob($this->sessionPath . '/*');
     if (is_array($files)) {
         foreach ($files as $file) {
             if ($this->fileSystem->lastModified($file) + $dataTTL < time() && $this->fileSystem->isWritable($file)) {
                 $this->fileSystem->delete($file);
             }
         }
     }
 }
 /**
  * Executes the command.
  *
  * @access  public
  * @param   \mako\application\Application  $application  Application instance
  * @param   \mako\file\FileSystem          $fileSystem   File system instance
  */
 public function execute(Application $application, FileSystem $fileSystem)
 {
     $configFile = $application->getPath() . '/config/application.php';
     if (!$fileSystem->isWritable($configFile)) {
         $this->error('Unable to generate a new secret. Make sure that the [ app/config/application.php ] file is writable.');
         return;
     }
     if (function_exists('openssl_random_pseudo_bytes')) {
         $secret = bin2hex(openssl_random_pseudo_bytes(32));
     } else {
         $secret = str_replace(['"', '\''], ['|', '/'], Str::random(Str::ALNUM . Str::SYMBOLS, 64));
     }
     $contents = $fileSystem->getContents($configFile);
     $contents = preg_replace('/\'secret\'(\\s*)=>(\\s*)\'(.*)\',/', '\'secret\'$1=>$2\'' . $secret . '\',', $contents);
     $fileSystem->putContents($configFile, $contents);
     $this->write('A new application secret has been generated.');
 }