Exemplo n.º 1
0
 /**
  * Save to filename
  *
  * @param string $code
  * @return string filename
  */
 public function saveCode($code)
 {
     $config = APPLICATION_PATH . '/modules/install/configs/checks.yaml';
     require_once 'Zend/Config/Yaml.php';
     require_once 'Core/Config/Yaml.php';
     $result = new Core_Config_Yaml($config);
     $requirements = $result->toArray();
     do {
         $filename = APPLICATION_PATH . '/../' . $requirements['directories']['cache_dir'] . '/' . uniqid() . '.php';
     } while (is_file($filename));
     file_put_contents($filename, '<?php /*' . PHP_EOL . PHP_EOL . $code . PHP_EOL);
     return $filename;
 }
Exemplo n.º 2
0
 /**
  * Requirements action
  */
 public function requirementsAction()
 {
     $config = APPLICATION_PATH . '/modules/install/configs/checks.yaml';
     $isValid = true;
     $rootDirectory = realpath(APPLICATION_PATH . '/../');
     $result = new Core_Config_Yaml($config);
     $requirements = $result->toArray();
     $this->view->requirements = $requirements;
     $resources = $this->_store->config->production->resources;
     $resources->session->save_path = APPLICATION_PATH . '/../' . $requirements['directories']['session_dir'];
     $directories = array();
     //check directories
     foreach ($requirements['directories'] as $directory) {
         $info = array();
         $info['path'] = $rootDirectory . '/' . $directory;
         $info['exists'] = file_exists($info['path']);
         $info['writable'] = $info['exists'] && is_writable($info['path']);
         if (!$info['writable']) {
             $isValid = false;
         }
         $directories[$directory] = $info;
     }
     $this->view->directories = $directories;
     //remove postfix
     $phpVersion = PHP_VERSION;
     $this->view->phpversion = $phpVersion;
     $this->view->minPhpVersion = $requirements['minPhpVersion'];
     $isValidPhpVersion = false;
     //check PHP version
     if (version_compare($phpVersion, $requirements['minPhpVersion'], '>=')) {
         $isValidPhpVersion = true;
     }
     $this->view->isValidPhpVersion = $isValidPhpVersion;
     if (!$isValidPhpVersion) {
         $isValid = false;
     }
     $this->view->isValid = $isValid;
     $phpOptions = array();
     //check PHP options
     foreach ($requirements['phpOptions'] as $option => $val) {
         $phpOptions[$option] = $val;
         if (ini_get($option) == $val['desired']) {
             $phpOptions[$option]['check'] = true;
         } else {
             $phpOptions[$option]['check'] = false;
         }
     }
     $this->view->phpOptions = $phpOptions;
     //check PHP extensions
     $phpExtensions = array();
     foreach ($requirements['extensions'] as $ext => $desc) {
         $phpExtensions[$ext] = $desc;
         if (in_array($ext, get_loaded_extensions())) {
             $phpExtensions[$ext]['check'] = true;
         } else {
             $phpExtensions[$ext]['check'] = false;
         }
     }
     $this->view->phpExtensions = $phpExtensions;
     if ($this->_request->isPost() && $isValid) {
         $this->_store->progress['install-index-requirements'] = true;
         foreach ($this->_store->progress as $route => $status) {
             if (!$status) {
                 $this->_store->progress[$route] = null;
                 $this->_helper->redirector->gotoRoute(array(), $route);
             }
         }
         $this->_helper->redirector->gotoRoute(array(), 'install-index-finish');
     }
     $this->view->currentPage = 'install-index-requirements';
 }