Method openHandle

@access private

@return void
504863
private function openHandle()
	{
		if( !$this->host )
			throw new \Exception('Host is not defined.');

		$this->handle= ($this->scheme==='https'?
			fsockopen( 'ssl://'.$this->host, $this->port?:443 )
		:
			fsockopen( $this->host, $this->port?:80 )
		);
	}
56286
private function open()
    {
        // Used for trapping `fopen()` errors.
        $this->trappedErrorNumber = null;
        $this->trappedErrorString = null;

        set_error_handler(
            function($errorNo, $errorString) {
                $this->trapError($errorNo, $errorString);
            }
        );

        $needsChmod = !file_exists($this->file);
        $file = fopen($this->file, 'a');

        restore_error_handler();

        // Handles trapped `fopen()` errors.
        if ($this->trappedErrorNumber) {
            throw new Exception(
                sprintf(
                    "Logger Error: '%s'",
                    $this->trappedErrorString
                ),
                $this->trappedErrorNumber
            );
        }

        if ($needsChmod) {
            @chmod($this->file, $this->mode & ~umask());
        }

        return $this->file = $file;
    }
785479
protected function ensureWritableHandle()
    {
        if ( ! $this->needsCowCheck) {
            return;
        }

        $this->needsCowCheck = false;

        if (StreamUtil::isWritable($this->handle)) {
            return;
        }

        $this->handle = StreamUtil::copy($this->handle);
    }
1133648
protected function registerHandler()
	{
		$this->app['exception'] = $this->app->share(function($app)
		{
			return new Handler($app, $app['exception.plain'], $app['exception.debug']);
		});
	}
80997
public function handle()
    {
        switch (strtolower($_SERVER['QUERY_STRING'])){
        case 'wsdl':
            $this->intoStruct();
            $this->handleWSDL();
            break;
        case 'disco':
            $this->intoStruct();
            $this->handleDISCO();
            break;
        default:
            $this->intoStruct();
            if (isset($_SERVER['HTTP_SOAPACTION'])) {
                $this->createServer();
            } elseif (isset($_REQUEST['svc'])) {
               	$this->handleHTTP(); // by JG
            } else {
                $this->handleINFO();
            }
            break;
        }
    }
734977
private function resetCurlHandle()
    {
        if (!is_null($this->curlHandle) && $this->getEnablePersistentConnections()) {
            curl_reset($this->curlHandle);
        } else {
            $this->initCurlHandle();
        }
    }
352233
private function setupFingerprintHandler()
    {
        if ($this->userAgentFingerprinted || $this->ipAddressFingerprinted
            && !isset($_SESSION['__HANDLER_FINGERPRINT'])) {
            $_SESSION['__HANDLER_FINGERPRINT'] = $this->createFingerprint();
        }
    }
1346610
private function getHandle()
    {
        // make sure to clean up old handles
        if ($this->handle !== null && feof($this->handle)) {
            $this->resetHandle();
        }

        // provision new handle
        if ($this->handle == null) {
            $params = $this->params;
            if (!empty($this->getResourceVersion())) {
                $params['resourceVersion'] = $this->getResourceVersion();
            }
            $query = http_build_query($params);
            $base = $this->getClient()->getConfig()->getServer().$this->endpoint;
            $url = $base;

            if (!empty($query)) {
                $parsed = parse_url($base);
                if (key_exists('query', $parsed) || substr($base, -1) == "?") {
                    $url .= '&'.$query;
                } else {
                    $url .= '?'.$query;
                }
            }
            $handle = @fopen($url, 'r', false, $this->getClient()->getStreamContext());
            if ($handle === false) {
                $e = error_get_last();
                throw new \Exception($e['message'], $e['type']);
            }
            stream_set_timeout($handle, 0, $this->getStreamTimeout());
            $this->handle = $handle;
        }

        return $this->handle;
    }
793794
public function runHandler()
    {
        $currentData = $this->_defaultData($this->_block->getContent());
        $uploadHandler = new GalleryUploadHandler([
            'print_response' => false,
            'selected_data' => $currentData,
            'script_url' => Request::url(),
            'max_file_size' => 2000000, //2MB   (will also error if over php.ini post_max_size)
            'accept_file_types' => '/\.(gif|jpe?g|png)$/i',
            'upload_dir' => public_path() . '/uploads/system/gallery/' . $this->_block->name . '/' . $this->_block->getPageId() . '/',
            'upload_url' => URL::to('/uploads/system/gallery/' . $this->_block->name . '/' . $this->_block->getPageId()) . '/'
        ]);
        if (!empty($uploadHandler->name)) {
            $order = 0;
            foreach ($currentData as $imageData) {
                if ($order < $imageData->order) {
                    $order = $imageData->order;
                }
            }
            AdminLog::new_log('Uploaded files to Gallery (ID ' . $this->_block->id . ')');
            $currentData[$uploadHandler->name] = new \stdClass;
            $currentData[$uploadHandler->name]->caption = '';
            $currentData[$uploadHandler->name]->order = $order + 1;
            $currentData[$uploadHandler->name]->path = '/' . $this->_block->getPageId() . '/';
            $this->_block->updateContent(serialize($currentData));
        }
        if ($this->_block->getPageId() && !config('coaster::admin.publishing')) { // update live page if no publishing
            PageVersion::latest_version($this->_block->getPageId(), true)->publish();
        }
        return $uploadHandler->get_response();
    }
384847
protected function open()
    {
        if (isset($this->options['stdin'])) {
            $this->input = $this->options['stdin'];
        } else {
            $this->input = fopen('php://stdin', 'r');
        }
        if (isset($this->options['stdout'])) {
            $this->output = $this->options['stdout'];
        } else {
            $this->output = fopen('php://stdout', 'w');
        }
        while (true) {
            $line = $this->read($this->input);
            if ($this->isEndOfEnvironmentVariables($line)) {
                break;
            }
            $this->readEnvironmentVariable($line);
        }
        $this->logger->debug(print_r($this->variables, true));
    }
646893
private function getHandle()
    {
        if (null === $this->handle) {
            if (false === ($this->handle = @fopen($this->file, 'rb'))) {
                $error = error_get_last();

                throw new RuntimeException($error['message']);
            }
        }

        return $this->handle;
    }
288247
function open()
    {
        if (!$this->_opened || $this->_reopen) {
            $this->_opened = openlog($this->_ident, LOG_PID, $this->_name);
        }

        return $this->_opened;
    }
1308571
public function open()
    {
        if (self::$monitorQueries) {
            self::$strQueries .= "Before @mysqli_connect\n";
            global $time;
            $curTime          = microtime(true) - $time;
            self::$strQueries .= sprintf('%f', $curTime) . "\n";
        }

        $this->connect();
    }
1173893
private function open()
  {
    // Used for trapping `fopen()` errors.
    $this->trappedErrorNumber = null;
    $this->trappedErrorString = null;

    $old = set_error_handler(array($this, 'trapError'));

    $needsChmod = !file_exists($this->file);
    $fh = fopen($this->file, 'a');

    restore_error_handler();

    // Handles trapped `fopen()` errors.
    if ($this->trappedErrorNumber) {
      throw new Exception(
          sprintf(
              "Logger Error: '%s'",
              $this->trappedErrorString
          ),
          $this->trappedErrorNumber
      );
    }

    if ($needsChmod) {
      @chmod($this->file, $this->mode & ~umask());
    }

    return $this->file = $fh;
  }
275353
public function start()
    {
        $__scope = $this->_runHooks($this->_startHooks);
        extract($__scope);
        
        $this->_write($this->_socket, self::READY);
        
        /* Note the naming of the local variables due to shared scope with the user here */
        for (;;) {
            declare (ticks = 1);
            // don't exit on ctrl-c
            pcntl_signal(SIGINT, SIG_IGN, true);
            
            $this->_cancelled = false;
            
            $__input = $this->_transform($this->_read($this->_socket));
            
            if ($__input === null) {
                continue;
            }
            
            $__response = self::DONE;
            
            $this->_ppid = posix_getpid();
            $this->_pid  = pcntl_fork();
            
            if ($this->_pid < 0) {
                throw new \RuntimeException('Failed to fork child labourer');
            } elseif ($this->_pid > 0) {
                // kill the child on ctrl-c
                pcntl_signal(SIGINT, array(
                    $this,
                    'cancelOperation'
                ), true);
                pcntl_waitpid($this->_pid, $__status);
                
                if (!$this->_cancelled && $__status != (self::ABNORMAL_EXIT << 8)) {
                    $__response = self::EXITED;
                } else {
                    $this->_runHooks($this->_failureHooks);
                    $__response = self::FAILED;
                }
            } else {
                // if the user has installed a custom exception handler, install a new
                // one which calls it and then (if the custom handler didn't already exit)
                // exits with the correct status.
                // If not, leave the exception handler unset; we'll display
                // an uncaught exception error and carry on.
                $__oldexh = set_exception_handler(array(
                    $this,
                    'delegateExceptionHandler'
                ));
                if ($__oldexh && !$this->_userExceptionHandler) {
                    $this->_userExceptionHandler = $__oldexh; // save the old handler (once)
                } else {
                    restore_exception_handler();
                }
                
                // undo ctrl-c signal handling ready for user code execution
                pcntl_signal(SIGINT, SIG_DFL, true);
                $__pid = posix_getpid();
                
                $__result = eval($__input);
                
                if (posix_getpid() != $__pid) {
                    // whatever the user entered caused a forked child
                    // (totally valid, but we don't want that child to loop and wait for input)
                    exit(0);
                }
                
                if (preg_match('/\s*return\b/i', $__input)) {
                    fwrite(STDOUT, sprintf("%s\n", $this->_inspector->inspect($__result)));
                }
                $this->_expungeOldWorker();
            }
            
            $this->_write($this->_socket, $__response);
            
            if ($__response == self::EXITED) {
                exit(0);
            }
        }
    }
1375042
public function openWithTruncate()
    {
        $this->open();
        $this->content->truncate(0);
        $time               = time();
        $this->lastAccessed = $time;
        $this->lastModified = $time;
    }
1296293
protected function init()
    {
        $this->win = defined('PHP_WINDOWS_VERSION_BUILD');

        $this->hiddenExe = __DIR__ . '/../bin/hiddeninput.exe';

        // Default handler
        $closure = function ($value) {
            return count($value);
        };

        $this->setHandler($closure);
    }