当前位置: 首页>>代码示例>>PHP>>正文


PHP Phprojekt::checkExtensionsAndSettings方法代码示例

本文整理汇总了PHP中Phprojekt::checkExtensionsAndSettings方法的典型用法代码示例。如果您正苦于以下问题:PHP Phprojekt::checkExtensionsAndSettings方法的具体用法?PHP Phprojekt::checkExtensionsAndSettings怎么用?PHP Phprojekt::checkExtensionsAndSettings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phprojekt的用法示例。


在下文中一共展示了Phprojekt::checkExtensionsAndSettings方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _checkServer

 /**
  * Do some checks before install.
  *
  * @throws Expeption If the server don't have the requirements.
  *
  * @return void
  */
 private function _checkServer()
 {
     // Check the server
     $checkServer = Phprojekt::checkExtensionsAndSettings();
     // Check the PHP version
     if (!$checkServer['requirements']['php']['checked']) {
         $missingRequirements[] = "You need the PHP Version " . $checkServer['requirements']['php']['required'] . " or newer. Follow this link for help: <a href=\"" . $checkServer['requirements']['php']['help'] . "\"" . " target=\"_new\">HELP</a>";
     }
     // Check required extension
     foreach ($checkServer['requirements']['extension'] as $name => $values) {
         if (!$values['checked']) {
             $missingRequirements[] = "The '" . $name . "' extension must be enabled. Follow this link for help: " . "<a href=\"" . $values['help'] . "\" target=\"_new\">HELP</a>";
         }
     }
     // Check required settings
     foreach ($checkServer['requirements']['settings'] as $name => $values) {
         if (!$values['checked']) {
             $missingRequirements[] = "The php.ini setting of '" . $name . "' has to be '" . $values['required'] . "'. Follow this link for help: <a href=\"" . $values['help'] . "\"" . " target=\"_new\">HELP</a>";
         }
     }
     // Checking if configuration.php exists
     $baseDir = str_replace('htdocs/setup.php', '', $_SERVER['SCRIPT_FILENAME']);
     if (file_exists($baseDir . "configuration.php")) {
         throw new Exception("Configuration file found. Please, delete it before run setup again.");
     }
     if (!empty($missingRequirements)) {
         $message = implode("\n", $missingRequirements);
         throw new Exception($message);
     }
     if (strncmp($_SERVER['SCRIPT_NAME'], '/setup.php', 10) != 0) {
         $this->_message[] = "It is recommend install PHProjekt 6 using a virtual host.<br />" . "You should try to generate an extra virtual host (or a sub-domain) to phprojekt/htdocs.";
         // Works the .htaccess?
         $response = new Zend_Controller_Request_Http();
         $webpath = $response->getHttpHost();
         $str = '';
         $sock = fsockopen($webpath, $response->getServer('SERVER_PORT'));
         $request = "GET " . str_replace('htdocs/setup.php', '', $response->getRequestUri()) . '/application/' . " HTTP/1.1\r\n" . "Host: " . $webpath . "\r\nConnection: close\r\n\r\n";
         fwrite($sock, $request);
         while ($buff = fread($sock, 1024)) {
             $str .= $buff;
         }
         $response = Zend_Http_Response::fromString($str);
         if ($response->getStatus() != '403') {
             $this->_message[] = "Please note that your webserver needs to support .htaccess files " . "to deny access to the configuration files.<br />" . "Running PHProjekt 6 without using the provided .htaccess files to deny access to " . "certain files and folders, might not be secure and is not recommended.";
         }
         fclose($sock);
     }
     foreach ($checkServer['recommendations']['settings'] as $name => $values) {
         if (!$values['checked']) {
             $this->_message[] = "It is recommend to have '" . $name . "' set to '" . $values['required'] . "', but it is not required to run PHProjekt. Follow this link for help: <a href=\"" . $values['help'] . "\" target=\"_new\">HELP</a>";
         }
     }
 }
开发者ID:victorli,项目名称:PHProjekt,代码行数:60,代码来源:Setup.php

示例2: _initialize

 /**
  * Initialize the paths, the config values and all the render stuff.
  *
  * @return void
  */
 public function _initialize()
 {
     // Report all PHP errors
     error_reporting(-1);
     define('PHPR_CORE_PATH', PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'application');
     define('PHPR_LIBRARY_PATH', PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'library');
     if (!defined('PHPR_CONFIG_FILE')) {
         define('PHPR_CONFIG_FILE', PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'configuration.php');
     }
     set_include_path('.' . PATH_SEPARATOR . PHPR_LIBRARY_PATH . PATH_SEPARATOR . get_include_path());
     require_once 'Zend/Loader/Autoloader.php';
     require_once 'Phprojekt/Loader.php';
     $autoloader = Zend_Loader_Autoloader::getInstance();
     $autoloader->pushAutoloader(array('Phprojekt_Loader', 'autoload'));
     // Read the config file, but only the production setting
     try {
         $this->_config = new Zend_Config_Ini(PHPR_CONFIG_FILE, PHPR_CONFIG_SECTION, true);
     } catch (Zend_Config_Exception $error) {
         $response = new Zend_Controller_Request_Http();
         $webPath = $response->getScheme() . '://' . $response->getHttpHost() . $response->getBasePath() . '/';
         header("Location: " . $webPath . "setup.php");
         die('You need the file configuration.php to continue. Have you tried the <a href="' . $webPath . 'setup.php">setup</a> routine?' . "\n" . '<br />Original error: ' . $error->getMessage());
     }
     // Set webpath, tmpPath and applicationPath
     if (empty($this->_config->webpath)) {
         $response = new Zend_Controller_Request_Http();
         $this->_config->webpath = $response->getScheme() . '://' . $response->getHttpHost() . $response->getBasePath() . '/';
     }
     define('PHPR_ROOT_WEB_PATH', $this->_config->webpath . 'index.php/');
     define('PHPR_TEMP_PATH', $this->_config->tmpPath);
     define('PHPR_USER_CORE_PATH', $this->_config->applicationPath);
     set_include_path('.' . PATH_SEPARATOR . PHPR_LIBRARY_PATH . PATH_SEPARATOR . PHPR_CORE_PATH . PATH_SEPARATOR . PHPR_USER_CORE_PATH . PATH_SEPARATOR . get_include_path());
     // Set the timezone to UTC
     date_default_timezone_set('UTC');
     // Start zend session to handle all session stuff
     try {
         Zend_Session::start();
     } catch (Zend_Session_Exception $error) {
         Zend_Session::writeClose();
         Zend_Session::start();
         Zend_Session::regenerateId();
         error_log($error);
     }
     // Set a metadata cache and clean it
     $frontendOptions = array('automatic_serialization' => true);
     $backendOptions = array('cache_dir' => PHPR_TEMP_PATH . 'zendCache' . DIRECTORY_SEPARATOR);
     try {
         $this->_cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     } catch (Exception $error) {
         die("The directory " . PHPR_TEMP_PATH . "zendCache do not exists or not have write access.");
     }
     Zend_Db_Table_Abstract::setDefaultMetadataCache($this->_cache);
     // Use for Debug only
     //Zend_Db_Table_Abstract::getDefaultMetadataCache()->clean();
     // Check Logs
     $this->getLog();
     // Check the server
     $checkServer = Phprojekt::checkExtensionsAndSettings();
     // Check the PHP version
     if (!$checkServer['requirements']['php']['checked']) {
         $missingRequirements[] = "- You need the PHP Version '" . $checkServer['requirements']['php']['required'] . "' or newer";
     }
     // Check required extension
     foreach ($checkServer['requirements']['extension'] as $name => $values) {
         if (!$values['checked']) {
             $missingRequirements[] = "- The '" . $name . "' extension must be enabled.";
         }
     }
     // Check required settings
     foreach ($checkServer['requirements']['settings'] as $name => $values) {
         if (!$values['checked']) {
             $missingRequirements[] = "- The php.ini setting of '" . $name . "' has to be '" . $values['required'] . "'.";
         }
     }
     // Show message
     if (!empty($missingRequirements)) {
         $message = "Your PHP does not meet the requirements needed for P6.<br />" . implode("<br />", $missingRequirements);
         die($message);
     }
     $helperPaths = $this->_getHelperPaths();
     $view = $this->_setView($helperPaths);
     $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
     $viewRenderer->setViewBasePathSpec(':moduleDir/Views');
     $viewRenderer->setViewScriptPathSpec(':action.:suffix');
     Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
     foreach ($helperPaths as $helperPath) {
         Zend_Controller_Action_HelperBroker::addPath($helperPath['directory']);
     }
     $plugin = new Zend_Controller_Plugin_ErrorHandler();
     $plugin->setErrorHandlerModule('Default');
     $plugin->setErrorHandlerController('Error');
     $plugin->setErrorHandlerAction('error');
     $front = Zend_Controller_Front::getInstance();
     $front->setDispatcher(new Phprojekt_Dispatcher());
     $front->registerPlugin($plugin);
//.........这里部分代码省略.........
开发者ID:victorli,项目名称:PHProjekt,代码行数:101,代码来源:Phprojekt.php

示例3: testCheckExtensionsAndSettings

 public function testCheckExtensionsAndSettings()
 {
     $spected = array('requirements' => array('extension' => array('mbstring' => array('required' => true, 'checked' => true, 'help' => 'http://us.php.net/manual/en/mbstring.installation.php'), 'iconv' => array('required' => true, 'checked' => true, 'help' => 'http://us.php.net/manual/en/iconv.installation.php'), 'ctype' => array('required' => true, 'checked' => true, 'help' => 'http://us.php.net/manual/en/ctype.installation.php'), 'gd' => array('required' => true, 'checked' => true, 'help' => 'http://us.php.net/manual/en/image.installation.php'), 'pcre' => array('required' => true, 'checked' => true, 'help' => 'http://us.php.net/manual/en/pcre.installation.php'), 'pdo' => array('required' => true, 'checked' => true, 'help' => 'http://us.php.net/manual/en/pdo.installation.php'), 'Reflection' => array('required' => true, 'checked' => true, 'help' => 'http://us.php.net/manual/en/reflection.installation.php'), 'session' => array('required' => true, 'checked' => true, 'help' => 'http://us.php.net/manual/en/session.installation.php'), 'SPL' => array('required' => true, 'checked' => true, 'help' => 'http://us.php.net/manual/en/spl.installation.php'), 'zlib' => array('required' => true, 'checked' => true, 'help' => 'http://us.php.net/manual/en/zlib.installation.php'), 'pdo_mysql | pdo_sqlite2 | pdo_pgsql' => array('required' => true, 'checked' => true, 'help' => 'http://us.php.net/manual/en/pdo.installation.php')), 'settings' => array('magic_quotes_gpc' => array('required' => 0, 'checked' => true, 'help' => 'http://us.php.net/manual/en/info.configuration.php#ini.magic-quotes-gpc'), 'magic_quotes_runtime' => array('required' => 0, 'checked' => true, 'help' => 'http://us.php.net/manual/en/info.configuration.php#ini.magic-quotes-runtime'), 'magic_quotes_sybase' => array('required' => 0, 'checked' => true, 'help' => 'http://us.php.net/manual/en/sybase.configuration.php#ini.magic-quotes-sybase')), 'php' => array('required' => '5.2.4', 'checked' => true, 'help' => 'http://us.php.net/')), 'recommendations' => array('settings' => array('register_globals' => array('required' => 0, 'checked' => true, 'help' => 'http://us.php.net/manual/en/ini.core.php#ini.register-globals'), 'safe_mode' => array('required' => 0, 'checked' => true, 'help' => 'http://us.php.net/manual/en/features.safe-mode.php'))));
     $this->assertEquals($spected, Phprojekt::checkExtensionsAndSettings());
 }
开发者ID:victorli,项目名称:PHProjekt,代码行数:5,代码来源:PhprojektTest.php


注:本文中的Phprojekt::checkExtensionsAndSettings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。