Returns a CTCP SOURCE reply message.

@param string $nickname
@param string $host
@param string $directories
@param string $files
@return string
180387
public function ctcpSourceResponse($nickname, $host, $directories, $files)
    {
        return $this->getCtcpResponse($nickname, 'SOURCE ' . $host . ':' . $directories . ':' . $files);
    }
255844
public function admin($channel, $nickname, $priority = SMARTIRC_MEDIUM)
    {
        return $this->mode($channel, '+a '.$nickname, $priority);
    }
498953
private function get_contact_vcard($source, $cid, &$filename = null)
    {
        $rcmail  = rcmail::get_instance();
        $source  = $rcmail->get_address_book($source);
        $contact = $source->get_record($cid, true);

        if ($contact) {
            $fieldmap = $source ? $source->vcard_map : null;

            if (empty($contact['vcard'])) {
                $vcard = new rcube_vcard('', RCUBE_CHARSET, false, $fieldmap);
                $vcard->reset();

                foreach ($contact as $key => $values) {
                    list($field, $section) = explode(':', $key);
                    // avoid unwanted casting of DateTime objects to an array
                    // (same as in rcube_contacts::convert_save_data())
                    if (is_object($values) && is_a($values, 'DateTime')) {
                        $values = array($values);
                    }

                    foreach ((array) $values as $value) {
                        if (is_array($value) || is_a($value, 'DateTime') || @strlen($value)) {
                            $vcard->set($field, $value, strtoupper($section));
                        }
                    }
                }

                $contact['vcard'] = $vcard->export();
            }

            $name     = rcube_addressbook::compose_list_name($contact);
            $filename = (self::parse_filename($name) ?: 'contact') . '.vcf';

            // fix folding and end-of-line chars
            $vcard = preg_replace('/\r|\n\s+/', '', $contact['vcard']);
            $vcard = preg_replace('/\n/', rcube_vcard::$eol, $vcard);

            return rcube_vcard::rfc2425_fold($vcard) . rcube_vcard::$eol;
        }
    }
241337
private function filterHost(string $host): string
    {
        return preg_replace_callback(
            '/(?:[^'.self::UNRESERVED.self::SUB_DELIMS.':%\[\]]+|%(?![A-Fa-f0-9]{2}))/',
            function (array $match) {
                return rawurlencode($match[0]);
            },
            $host
        );
    }
807801
protected function addPathToViewPaths(array &$paths, $host)
    {
        $path = $this->createViewPath($host);

        if ($path && !in_array($path, $paths)) {
            $paths[] = $path;
        }

        return $path;
    }
1038793
public function invokePluginOnFilesystem($method, $arguments, $prefix)
    {
        $filesystem = $this->getFilesystem($prefix);

        try {
            return $this->invokePlugin($method, $arguments, $filesystem);
        } catch (PluginNotFoundException $e) {
            // Let it pass, it's ok, don't panic.
        }

        $callback = [$filesystem, $method];

        return call_user_func_array($callback, $arguments);
    }
1000569
public function isOpped($channel, $nickname = null)
    {
        if (!$this->_channelsyncing) {
            $this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isOpped() is called '
                .'and the required Channel Syncing is not activated!',
                __FILE__, __LINE__
            );
            return false;
        }

        if ($nickname === null) {
            $nickname = $this->_nick;
        }

        return ($this->isJoined($channel, $nickname)
            && $this->getUser($channel, $nickname)->op
        );
    }
453311
protected function ensureLocation(BucketInterface $bucket, string $name): string
    {
        $directory = dirname($this->getPath($bucket, $name));
        $mode = $bucket->getOption('mode', FilesInterface::RUNTIME);

        try {
            if (ftp_chdir($this->conn, $directory)) {
                ftp_chmod($this->conn, $mode | 0111, $directory);

                return $this->getPath($bucket, $name);
            }
        } catch (\Exception $e) {
            //Directory has to be created
        }

        ftp_chdir($this->conn, $this->options['home']);

        $directories = explode('/', substr($directory, strlen($this->options['home'])));
        foreach ($directories as $directory) {
            if (!$directory) {
                continue;
            }

            try {
                ftp_chdir($this->conn, $directory);
            } catch (\Exception $e) {
                ftp_mkdir($this->conn, $directory);
                ftp_chmod($this->conn, $mode | 0111, $directory);
                ftp_chdir($this->conn, $directory);
            }
        }

        return $this->getPath($bucket, $name);
    }
129927
public function show(string $host, array $params = [])
    {
        $path = $this->buildKnownHostsPath($host);

        return $this->get($path, $params);
    }
289234
protected static function getHostAndPortFromHeader(&$host, &$port, $headerHost)
    {
        if (is_array($headerHost)) {
            $headerHost = implode(', ', $headerHost);
        }

        $host = $headerHost;

        if (preg_match('|\:(\d+)$|', $host, $matches)) {
            $host = substr($host, 0, -1 * (strlen($matches[1]) + 1));
            $port = (int) $matches[1];
        }
    }
31807
public static function detectCmdLocationInPaths($cmd, array $paths) : string
    {
        foreach ($paths as $path) {
            $command = $path . DIRECTORY_SEPARATOR . $cmd;
            $bin     = self::getExecutable($command);
            if (null !== $bin) {
                return $bin;
            }
        }
        return '';
    }
27610
static function copy( $sourceFilename, $destinationFilename )
    {
        if ( is_dir( $sourceFilename ) )
        {
            eZDebug::writeError( "Unable to copy directory $sourceFilename, use eZDir::copy instead", __METHOD__ );
            return false;
        }
        $sourceFD = @fopen( $sourceFilename, 'rb' );
        if ( !$sourceFD )
        {
            eZDebug::writeError( "Unable to open source file $sourceFilename in read mode", __METHOD__ );
            return false;
        }
        if ( is_dir( $destinationFilename ) )
        {
            $dirPosition = strrpos( $sourceFilename, '/' );
            $filePosition = 0;
            if ( $dirPosition !== false )
                $filePosition = $dirPosition + 1;
            if ( strlen( $destinationFilename ) > 0 and
                 $destinationFilename[strlen( $destinationFilename ) - 1] == '/' )
                $destinationFilename .= substr( $sourceFilename, $filePosition );
            else
                $destinationFilename .= '/' . substr( $sourceFilename, $filePosition );
        }

        // If source and destination are the same files we just return true
        if ( $sourceFilename == $destinationFilename )
        {
            @fclose( $sourceFD );
            return true;
        }

        $destinationFD = fopen( $destinationFilename, 'wb' );
        chmod( $destinationFilename, octdec( eZINI::instance()->variable( 'FileSettings', 'StorageFilePermissions' ) ) );
        if ( !$destinationFD )
        {
            @fclose( $sourceFD );
            eZDebug::writeError( "Unable to open destination file $destinationFilename in write mode", __METHOD__ );
            return false;
        }
        $bytesCopied = 0;
        do
        {
            $data = fread( $sourceFD, 4096 );
            if ( strlen( $data ) == 0 )
                break;
            fwrite( $destinationFD, $data );
            $bytesCopied += strlen( $data );
        } while( true );

        @fclose( $sourceFD );
        @fclose( $destinationFD );
        return true;
    }
138685
public static function getRemoteHostname(ServerRequestInterface $request, bool $hostnameLookups = false): string
    {
        $ip = self::getServerParamIp($request, 'REMOTE_ADDR');

        if ($ip !== '-' && $hostnameLookups) {
            return gethostbyaddr($ip);
        }

        return $ip;
    }
694746
public function withHost($host)
    {
        $uri = $this->getUri()->withHost($host);

        /** @var static $clone */
        $clone = $this->withUri($uri);

        return $clone;
    }
976406
public static function generateImageSecretSignature($host, $uri, $key, $secret)
    {
        $host = strtolower($host);
        $key = (string) $key;

        $base = [];

        $magicsLength = sizeof(self::$imageUrlSecretMagics);
        $additional = [$host, $uri, $secret, $key];
        $offset = 0;
        foreach (str_split($key) as $number) {
            $offset += $number;
            $magic = self::$imageUrlSecretMagics[$offset % $magicsLength];
            $base[] = $magic;
            $base[] = array_pop($additional);
            $offset += ord($magic[0]);
            $base[] = sha1($offset, true);
            if (!$additional) {
                break;
            }
        }
        $base = join(chr($offset & 0xff), $base);
        $sha1 = str_split(sha1($base, true));
        $base = [];
        for ($i = 0; $i < 24; $i++) {
            $base[] = $sha1[($i + $offset)%sizeof($sha1)];
        }
        $base = join('', $base);
        
        return str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($base))
                . substr($key, -2);
    }
317258
def on_ctcp(self, connection, event):
        
        nick = event.source.nick
        if event.arguments[0] == "VERSION":
            connection.ctcp_reply(nick, "VERSION " + self.get_version())
        elif event.arguments[0] == "PING":
            if len(event.arguments) > 1:
                connection.ctcp_reply(nick, "PING " + event.arguments[1])
        elif (
            event.arguments[0] == "DCC"
                and event.arguments[1].split(" ", 1)[0] == "CHAT"):
            self.on_dccchat(connection, event)
383877
protected function findHost(array $headers): string
    {
        foreach ($headers as $name => $values) {
            if (strtolower($name) === 'host') {
                return $values[0];
            }
        }

        throw new MessageException(Response::BAD_REQUEST, 'No host header in message.');
    }