Nette\Configurator::detectDebugMode PHP Method

detectDebugMode() public static method

Detects debug mode by IP address.
public static detectDebugMode ( $list = NULL ) : boolean
return boolean
    public static function detectDebugMode($list = NULL)
    {
        $addr = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : php_uname('n');
        $secret = isset($_COOKIE[self::COOKIE_SECRET]) && is_string($_COOKIE[self::COOKIE_SECRET]) ? $_COOKIE[self::COOKIE_SECRET] : NULL;
        $list = is_string($list) ? preg_split('#[,\\s]+#', $list) : (array) $list;
        if (!isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            $list[] = '127.0.0.1';
            $list[] = '::1';
        }
        return in_array($addr, $list, TRUE) || in_array("{$secret}@{$addr}", $list, TRUE);
    }

Usage Example

Example #1
0
 /**
  * Determines whether a server is running in production mode.
  * @return bool
  */
 public static function isProduction()
 {
     if (self::$productionMode === NULL) {
         self::$productionMode = !Nette\Configurator::detectDebugMode();
     }
     return self::$productionMode;
 }
All Usage Examples Of Nette\Configurator::detectDebugMode