• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP php_sapi_name函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中php_sapi_name函数的典型用法代码示例。如果您正苦于以下问题:PHP php_sapi_name函数的具体用法?PHP php_sapi_name怎么用?PHP php_sapi_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: __construct

 /**
  * Making the class non-abstract with a protected constructor does a better
  * job of preventing instantiation than just marking the class as abstract.
  *
  * @see start()
  */
 public function __construct(array $configs)
 {
     // Quickly initialize some defaults like usePEAR
     // by adding the $premature flag
     $this->_optionsInit(true);
     $this->setOptions($configs);
     if ($this->opt('logPhpErrors')) {
         set_error_handler(array('self', 'phpErrors'), E_ALL);
     }
     // Check the PHP configuration
     if (!defined('SIGHUP')) {
         trigger_error('PHP is compiled without --enable-pcntl directive', E_USER_ERROR);
     }
     // Check for CLI
     if (php_sapi_name() !== 'cli') {
         trigger_error('You can only create daemon from the command line (CLI-mode)', E_USER_ERROR);
     }
     // Check for POSIX
     if (!function_exists('posix_getpid')) {
         trigger_error('PHP is compiled without --enable-posix directive', E_USER_ERROR);
     }
     // Enable Garbage Collector (PHP >= 5.3)
     if (function_exists('gc_enable')) {
         gc_enable();
     }
     // Initialize & check variables
     if (false === $this->_optionsInit(false)) {
         if (is_object($this->_option) && is_array($this->_option->errors)) {
             foreach ($this->_option->errors as $error) {
                 $this->notice($error);
             }
         }
         trigger_error('Crucial options are not set. Review log:', E_USER_ERROR);
     }
 }
开发者ID:uecode,项目名称:daemon,代码行数:41,代码来源:Daemon.php


示例2: index

 public function index()
 {
     $os = explode(' ', php_uname());
     $mysql_support = function_exists('mysql_close') ? '<font color="green">√</font>' : '<font color="red">×</font>';
     $register_globals = get_cfg_var("register_globals") ? '<font color="green">√</font>' : '<font color="red">×</font>';
     $enable_dl = get_cfg_var("enable_dl") ? '<font color="green">√</font>' : '<font color="red">×</font>';
     $allow_url_fopen = get_cfg_var("allow_url_fopen") ? '<font color="green">√</font>' : '<font color="red">×</font>';
     $display_errors = get_cfg_var("display_errors") ? '<font color="green">√</font>' : '<font color="red">×</font>';
     $session_support = function_exists('session_start') ? '<font color="green">√</font>' : '<font color="red">×</font>';
     $config['server_name'] = $_SERVER['SERVER_NAME'];
     $config['server_ip'] = @gethostbyname($_SERVER['SERVER_NAME']);
     $config['server_time'] = date("Y年n月j日 H:i:s");
     $config['os'] = $os[0];
     $config['os_core'] = $os[2];
     $config['server_root'] = dirname(dirname($_SERVER['SCRIPT_FILENAME']));
     $config['server_engine'] = $_SERVER['SERVER_SOFTWARE'];
     $config['server_port'] = $_SERVER['SERVER_PORT'];
     $config['php_version'] = PHP_VERSION;
     $config['php_run_type'] = strtoupper(php_sapi_name());
     $config['mysql_support'] = $mysql_support;
     $config['register_globals'] = $register_globals;
     $config['allow_url_fopen'] = $allow_url_fopen;
     $config['display_errors'] = $display_errors;
     $config['enable_dl'] = $enable_dl;
     $config['memory_limit'] = get_cfg_var("memory_limit");
     $config['post_max_size'] = get_cfg_var("post_max_size");
     $config['upload_max_filesize'] = get_cfg_var("upload_max_filesize");
     $config['max_execution_time'] = get_cfg_var("max_execution_time");
     $config['session_support'] = $session_support;
     $this->config_arr = $config;
     $this->display();
 }
开发者ID:redisck,项目名称:xiangmu,代码行数:32,代码来源:ConfigAction.class.php


示例3: upgrade

 public function upgrade()
 {
     if (php_sapi_name() == "cli") {
         // @todo this may screw up some module installers, but we don't have a better answer at
         // this time.
         $_SERVER["HTTP_HOST"] = "example.com";
     } else {
         if (!user::active()->admin && !Session::instance()->get("can_upgrade", false)) {
             access::forbidden();
         }
     }
     // Upgrade gallery and user first
     module::install("gallery");
     module::install("user");
     // Then upgrade the rest
     foreach (module::available() as $id => $module) {
         if ($id == "gallery") {
             continue;
         }
         if ($module->active && $module->code_version != $module->version) {
             module::install($id);
         }
     }
     if (php_sapi_name() == "cli") {
         print "Upgrade complete\n";
     } else {
         url::redirect("upgrader?done=1");
     }
 }
开发者ID:kstyrvoll,项目名称:gallery3,代码行数:29,代码来源:upgrader.php


示例4: run

 public function run()
 {
     if (fnmatch('*cli*', php_sapi_name())) {
         $dir = Config::get('dir.schedules', APPLICATION_PATH . DS . 'schedules');
         if (is_dir($dir)) {
             Timer::start();
             Cli::show("Start of execution", 'COMMENT');
             $files = glob($dir . DS . '*.php');
             foreach ($files as $file) {
                 require_once $file;
                 $object = str_replace('.php', '', Arrays::last(explode(DS, $file)));
                 $class = 'Thin\\' . ucfirst(Inflector::camelize($object . '_schedule'));
                 $instance = lib('app')->make($class);
                 $methods = get_class_methods($instance);
                 Cli::show("Start schedule '{$object}'", 'COMMENT');
                 foreach ($methods as $method) {
                     $when = $this->getWhen($instance, $method);
                     $isDue = $this->isDue($object, $method, $when);
                     if (true === $isDue) {
                         Cli::show("Execution of {$object}->{$method}", 'INFO');
                         $instance->{$method}();
                     } else {
                         Cli::show("No need to execute {$object}->{$method}", 'QUESTION');
                     }
                 }
             }
             Cli::show("Time of execution [" . Timer::get() . " s.]", 'SUCCESS');
             Cli::show("end of execution", 'COMMENT');
         }
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:31,代码来源:schedule.php


示例5: ic_system_info

function ic_system_info()
{
    $thread_safe = false;
    $debug_build = false;
    $cgi_cli = false;
    $php_ini_path = '';
    ob_start();
    phpinfo(INFO_GENERAL);
    $php_info = ob_get_contents();
    ob_end_clean();
    foreach (split("\n", $php_info) as $line) {
        if (eregi('command', $line)) {
            continue;
        }
        if (eregi('thread safety.*(enabled|yes)', $line)) {
            $thread_safe = true;
        }
        if (eregi('debug.*(enabled|yes)', $line)) {
            $debug_build = true;
        }
        if (eregi("configuration file.*(</B></td><TD ALIGN=\"left\">| => |v\">)([^ <]*)(.*</td.*)?", $line, $match)) {
            $php_ini_path = $match[2];
            if (!@file_exists($php_ini_path)) {
                $php_ini_path = '';
            }
        }
        $cgi_cli = strpos(php_sapi_name(), 'cgi') !== false || strpos(php_sapi_name(), 'cli') !== false;
    }
    return array('THREAD_SAFE' => $thread_safe, 'DEBUG_BUILD' => $debug_build, 'PHP_INI' => $php_ini_path, 'CGI_CLI' => $cgi_cli);
}
开发者ID:holandacz,项目名称:nb4,代码行数:30,代码来源:test.php


示例6: scanInput

 /**
  * Scan the input for XXE attacks.
  *
  * @param string $input
  *        	Unsafe input
  * @param Closure $callback
  *        	Callback called to build the dom.
  *        	Must be an instance of DomDocument and receives the input as argument
  *        	
  * @return bool|DomDocument False if an XXE attack was discovered,
  *         otherwise the return of the callback
  */
 private static function scanInput($input, Closure $callback)
 {
     $isRunningFpm = substr(php_sapi_name(), 0, 3) === 'fpm';
     if ($isRunningFpm) {
         // If running with PHP-FPM and an entity is detected we refuse to parse the feed
         // @see https://bugs.php.net/bug.php?id=64938
         if (strpos($input, '<!ENTITY') !== false) {
             return false;
         }
     } else {
         $entityLoaderDisabled = libxml_disable_entity_loader(true);
     }
     libxml_use_internal_errors(true);
     $dom = $callback($input);
     // Scan for potential XEE attacks using ENTITY
     foreach ($dom->childNodes as $child) {
         if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
             if ($child->entities->length > 0) {
                 return false;
             }
         }
     }
     if ($isRunningFpm === false) {
         libxml_disable_entity_loader($entityLoaderDisabled);
     }
     return $dom;
 }
开发者ID:imonroe,项目名称:coldreader,代码行数:39,代码来源:XmlParser.php


示例7: register

 /**
  * Automatically registers all service classes in $this->services array
  * {@inheritdoc}
  * @param Application|\Apitude\Core\Application $app
  */
 public function register(Application $app)
 {
     foreach ($this->services as $key => $class) {
         if (is_numeric($key)) {
             $key = $class;
         }
         $app[$key] = $app->share(function () use($class, $app) {
             $result = new $class();
             $app->initialize($result);
             return $result;
         });
     }
     if (!empty($this->doctrineEventSubscribers)) {
         $config = $app['config'];
         foreach ($this->doctrineEventSubscribers as $class) {
             $config['orm.subscribers'][] = $class;
         }
     }
     if (!empty($this->entityFolders)) {
         if (!isset($config)) {
             $config = $app['config'];
         }
         foreach ($this->entityFolders as $namespace => $path) {
             $config['orm.options']['orm.em.options']['mappings'][] = ['type' => 'annotation', 'namespace' => $namespace, 'path' => $path, 'use_simple_annotation_reader' => false];
         }
     }
     if (isset($config)) {
         $app['config'] = $config;
     }
     if (php_sapi_name() === 'cli' && !empty($this->commands)) {
         $app['base_commands'] = $app->extend('base_commands', function (array $commands) {
             return array_merge($commands, $this->commands);
         });
     }
 }
开发者ID:apitude,项目名称:apitude,代码行数:40,代码来源:AbstractServiceProvider.php


示例8: dump

 /**
  * Dump specified value.
  *
  * @param mixed $value
  * @param int   $output
  * @return null|string
  */
 public function dump($value, $output = self::OUTPUT_ECHO)
 {
     if (php_sapi_name() === 'cli' && $output == self::OUTPUT_ECHO) {
         print_r($value);
         if (is_scalar($value)) {
             echo "\n";
         }
         return null;
     }
     //Dumping is pretty slow operation, let's record it so we can exclude dump time from application
     //timeline
     $benchmark = $this->benchmark('dump');
     try {
         switch ($output) {
             case self::OUTPUT_ECHO:
                 echo $this->style->mountContainer($this->dumpValue($value, '', 0));
                 break;
             case self::OUTPUT_RETURN:
                 return $this->style->mountContainer($this->dumpValue($value, '', 0));
                 break;
             case self::OUTPUT_LOG:
                 $this->logger()->debug(print_r($value, true));
                 break;
             case self::OUTPUT_LOG_NICE:
                 $this->logger()->debug($this->dump($value, self::OUTPUT_RETURN));
                 break;
         }
         return null;
     } finally {
         $this->benchmark($benchmark);
     }
 }
开发者ID:tuneyourserver,项目名称:components,代码行数:39,代码来源:Dumper.php


示例9: __construct

 /**
  * 构造函数
  * @param mixed $arg 对象参数, 常为 SQL 语句或要导入的文件路径
  */
 public function __construct($type, $arg)
 {
     $this->type = $type;
     $this->arg = $arg;
     $this->inCli = php_sapi_name() === 'cli';
     $this->init();
 }
开发者ID:flying3615,项目名称:chuniang,代码行数:11,代码来源:XSDataSource.class.php


示例10: _prepare

 /**
  * (non-PHPdoc)
  * @see \parallely\AbstractTransport::_prepare()
  */
 protected function _prepare()
 {
     if (extension_loaded('xcache') !== true or php_sapi_name() === 'cli') {
         throw new \parallely\Exception(\parallely\Exception::SETUP_ERROR);
     }
     return $this;
 }
开发者ID:hpbuniat,项目名称:parallely,代码行数:11,代码来源:Xcache.php


示例11: run

 public function run()
 {
     // Initialize router
     try {
         if (php_sapi_name() == 'cli') {
             // Handle console apps
             // @todo: finish!
             $router = new Router($this->getProjectFromArgs());
         } else {
             // Handle web apps
             $url = UrlFactory::autodetect();
             $router = new Router($this->getProjectFromUrl($url));
             $router->parseUrl($url);
         }
     } catch (RouteNotFoundException $e) {
         $context = new Context($e->getProject(), $e->getUrl());
         if ($this->onRouteNotFound) {
             // Call the user defined route not found handler
             call_user_func($this->onRouteNotFound, ['statusCode' => 404, 'context' => $context, 'exceptionMessage' => $e->getMessage()]);
         } else {
             // Display a default error page
             $response = new Phtml($context);
             $response->setStatusCode(404)->setViewDir(__DIR__ . '/Scripts')->setViewFilename('error.phtml')->setViewParams(['statusCode' => 404, 'exceptionMessage' => $e->getMessage()])->render();
         }
     }
 }
开发者ID:shaggy8871,项目名称:frame,代码行数:26,代码来源:Init.php


示例12: run

 public function run()
 {
     static::$netteDirectory = realpath(__DIR__ . '/../../../../app');
     $netteContainer = $this->getNetteContainer();
     if (php_sapi_name() !== 'cli') {
         define('STDIN', fopen('php://stdin', 'r'));
         echo '<pre>';
     }
     CLI::write('Welcome to the Nette Framework CRUD generator 1.0@beta5.', 0, FALSE);
     static::$settings = (object) ['netteRoot' => realpath(static::$netteDirectory . '/..'), 'netteConfig' => FALSE, 'netteDatabase' => FALSE, 'source' => \Utils\Constants::SOURCE_MYSQL_DISCOVERED, 'tables' => [], 'table' => FALSE, 'target' => \Utils\Constants::TARGET_NETTE_DATABASE, 'foreignKeys' => \Utils\Constants::FOREIGN_KEYS_TABLE, 'module' => FALSE, 'template' => realpath(__DIR__ . '/Templates/default'), 'php' => '<?php', 'entityManager' => NULL];
     $this->showSourceDialog();
     CLI::write('Verifying Nette configuration:', 0, TRUE, TRUE, TRUE);
     static::$settings->netteDatabase = $this->getDatabaseConnectionParameters($netteContainer);
     static::$settings->netteConfig = \Nette\Neon\Neon::decode(\Bruha\Generator\Utils\File::read(static::$netteDirectory . '/config/config.neon'));
     if ($this->checkExtensionsConfiguration()) {
         CLI::write('New extensions were installed.', 0, TRUE, TRUE, TRUE);
         CLI::write('Application needs to be restarted for loading them.', 1);
         CLI::write("Write 'php -f index.php' for start with new loaded extensions.", 2);
         exit;
     }
     $this->showTablesDialog($this->processSourceDialog($netteContainer));
     $this->showTargetDialog();
     $this->showForeignKeysDialog();
     $this->showModuleDialog();
     $this->chooseTemplatesDialog();
     static::$startTime = microtime(TRUE);
     $this->generate();
 }
开发者ID:r-bruha,项目名称:nette-generator,代码行数:28,代码来源:Generator.php


示例13: isConsole

 /**
  * isConsole
  * 
  * @return boolean
  */
 public static function isConsole()
 {
     if (php_sapi_name() == 'cli') {
         return true;
     }
     return false;
 }
开发者ID:bartekpie3,项目名称:PhpConsole,代码行数:12,代码来源:Console.php


示例14: loadSecurity

 private function loadSecurity()
 {
     if (php_sapi_name() != 'cli') {
         $this->__security = new \PAJ\Library\Security\SecurityController();
         $this->set('loggedin', $this->__security->get('loggedin'));
     }
 }
开发者ID:tboulogne,项目名称:magento-facebookstorefront,代码行数:7,代码来源:Loader.php


示例15: __construct

 /**
  * Class constructor
  *
  * @param	array An optional associative array of configuration settings.
  * Recognized key values include 'clientId' (this list is not meant to be comprehensive).
  */
 public function __construct($config = array())
 {
     $config['clientId'] = 0;
     \Event::listen(function ($event) {
         // This must be done before the session is read, otherwise it will overwrite
         // the existing session with a guest non-https session prior to redirecting to https
         // NOTE: we're including a cli check here because the console currently uses the 'site'
         // application.  This should be remedied in the new framework.
         $app = $event->getArgument('app');
         if ($app->getCfg('force_ssl') == 2 && php_sapi_name() != 'cli') {
             $uri = JURI::getInstance();
             if (strtolower($uri->getScheme()) != 'https') {
                 // We also can't use the Application::redirect method here as
                 // it tries to use JFactory::getDocument, which doesn't work
                 // prior to application initialization
                 $uri->setScheme('https');
                 header('HTTP/1.1 303 See other');
                 header('Location: ' . (string) $uri);
                 header('Content-Type: text/html;');
                 $app->close();
             }
         }
     }, 'application_onBeforeSessionCreate');
     parent::__construct($config);
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:31,代码来源:application.php


示例16: getBestLocale

 public function getBestLocale()
 {
     if (isset($this->locale)) {
         return $this->locale;
     }
     if (php_sapi_name() === 'cli') {
         $localeRaw = $this->default;
     } else {
         // Get the locale from the request headers
         $localeRaw = $this->getDI()->getRequest()->getBestLanguage();
         $localeRaw = str_replace('-', '_', $localeRaw);
     }
     if (strpos($localeRaw, '..') !== false) {
         throw new Exception('Locale has dangerous characters');
     }
     $localeParts = explode('_', $localeRaw);
     $language = $localeParts[0];
     $country = count($localeParts) > 1 ? '_' . strtoupper($localeParts[1]) : '';
     if ($this->isLocaleSupported("{$language}{$country}")) {
         $locale = "{$language}{$country}";
     } else {
         if (array_key_exists($language, $this->map)) {
             $locale = $this->map[$language];
         } else {
             $locale = $this->default;
         }
     }
     $this->locale = $locale;
     return $this->locale;
 }
开发者ID:JanOschii,项目名称:webird,代码行数:30,代码来源:Locale.php


示例17: getAssetsUrl

 /**
  * Get the URL of assets.
  * The base URL that contains all published asset files of yii-debug-toolbar.
  * @return string
  */
 public function getAssetsUrl()
 {
     if (null === $this->_assetsUrl && 'cli' !== php_sapi_name()) {
         $this->_assetsUrl = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . '/assets', false, -1, YII_DEBUG);
     }
     return $this->_assetsUrl;
 }
开发者ID:nurirahmat,项目名称:Yii-Extensions,代码行数:12,代码来源:YiiDebugToolbar.php


示例18: drush_verify_cli

/**
 * Verify that we are running PHP through the command line interface.
 *
 * This function is useful for making sure that code cannot be run via the web server,
 * such as a function that needs to write files to which the web server should not have
 * access to.
 *
 * @return
 *   A boolean value that is true when PHP is being run through the command line, 
 *   and false if being run through cgi or mod_php.
 */
function drush_verify_cli()
{
    if (php_sapi_name() == 'cgi') {
        return is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0;
    }
    return php_sapi_name() == 'cli';
}
开发者ID:kimpepper,项目名称:drupal-base,代码行数:18,代码来源:drush.php


示例19: __construct

 /**
  * Constructor
  */
 public function __construct()
 {
     $this->webroot = dirname(ABSPATH);
     $this->root = dirname($this->webroot);
     $this->name = WP_ENV;
     $this->mode = php_sapi_name() === 'cli' ? 'cli' : 'http';
 }
开发者ID:wells5609,项目名称:wp-app,代码行数:10,代码来源:Env.php


示例20: check

 public function check()
 {
     $report = null;
     if (php_sapi_name() === 'cli') {
         // @todo find a way to detect this in CLI.
         return new common_configuration_Report(common_configuration_Report::VALID, 'The AllowOverride directive cannot be checked in CLI mode.', $this);
     }
     $server = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on" ? 'https' : 'http') . "://" . $_SERVER['SERVER_NAME'] . ($_SERVER["SERVER_PORT"] != "80" ? ":" . $_SERVER["SERVER_PORT"] : '');
     $request = $_SERVER["REQUEST_URI"];
     $request = substr($request, 0, strpos($request, '?'));
     $request = substr($request, 0, strrpos($request, '/'));
     $url = $server . $request . '/checks/testAllowOverride/noneOrAll/';
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_HEADER, true);
     curl_setopt($ch, CURLOPT_NOBODY, true);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_TIMEOUT, 10);
     $output = curl_exec($ch);
     $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     curl_close($ch);
     if ($httpcode == '403') {
         $report = new common_configuration_Report(common_configuration_Report::VALID, 'The AllowOverride directive is set to All.', $this);
     } else {
         $report = new common_configuration_Report(common_configuration_Report::INVALID, 'The AllowOverride directive may not be set to All.', $this);
     }
     return $report;
 }
开发者ID:oat-sa,项目名称:tao-core,代码行数:27,代码来源:class.AllowOverride.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP php_strip_whitespace函数代码示例发布时间:2022-05-15
下一篇:
PHP php_ini_scanned_files函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap