@param $domain
@param $digest
@param $url

@return mixed
13075
public function formatCamoUrl($domain, $digest, $url)
    {
        return 'https://' . $domain . '/' . $digest . '?url=' . $this->encoder->encode($url);
    }
1125646
public function getUrlStatus($path, $domain = '')
    {

        $status = null;
        $url    = null;
        $uri    = empty($domain) ? $this->getDomain() : '';

        $hasSlash = strpos($path, '/');
        // add forward slash
        if($hasSlash === false) {
            $path = '/' . $path;
        }

        $url = $uri . $path;
        if($url) {
            stream_context_set_default(
                array(
                    'http' => array(
                        'method' => 'HEAD'
                    )
                )
            );

            $url    = get_headers($url, 1);
            $status = @explode(' ',$url[0]);

            if($status)
                $status = (int) $status[1];
        }


        return array(
            'status' => $status
        );
    }
1020472
public function parseAuthData($digest)
    {
        if (substr($digest, 0, 7) === 'Digest ') {
            $digest = substr($digest, 7);
        }
        $keys = $match = [];
        $req = ['nonce' => 1, 'nc' => 1, 'cnonce' => 1, 'qop' => 1, 'username' => 1, 'uri' => 1, 'response' => 1];
        preg_match_all('/(\w+)=([\'"]?)([a-zA-Z0-9\:\#\%\?\&@=\.\/_-]+)\2/', $digest, $match, PREG_SET_ORDER);

        foreach ($match as $i) {
            $keys[$i[1]] = $i[3];
            unset($req[$i[1]]);
        }

        if (empty($req)) {
            return $keys;
        }

        return null;
    }
501259
public function getReason($domain)
    {
        $domaincdNode = $this->getDomaincd($domain);
        $node = $this->getFirst('domain:reason', $domaincdNode);

        return $node === null ? null : $node->nodeValue;
    }
1124843
function domain_info($domain)
    {
        // build xml
        $request = $this->get_request_obj();
        $site    = $request->addChild("site");
        $get     = $site->addChild("get");
        $filter  = $get->addChild("filter");

        $filter->addChild("name", utf8_encode($domain));
        $dataset = $get->addChild("dataset");

        $dataset->addChild("hosting");
        $packet = $request->asXML();

        // send the request
        $res = $this->send_request($packet);

        // make it to simple-xml-object
        $xml = new SimpleXMLElement($res);

        return $xml;
    }
613031
static public function getSecondDomain($domain=null)
	{
	    $domain = !empty($domain) ? $domain : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null);
	    $n = preg_match('/([^.]*\.)?([^.]*\.)?\w+\.\w+$/', $domain, $matches);
	    return $domain && isset($matches[2]) ? $matches[2] : (isset($matches[1]) ? $matches[1] : '');
	}
1152811
def create_digest(method, request_uri)
      # http://en.wikipedia.org/wiki/Digest_access_authentication
      first = Digest::MD5.hexdigest("#{@config[:username]}:#{@digest["realm"]}:#{@config[:password]}")
      second = Digest::MD5.hexdigest("#{method}:#{request_uri}")

      # Using the "newer" authentication QOP
      if @digest_type.include?("auth")
        cnonce = Digest::MD5.hexdigest("#{@headers["User-Agent"]}:#{@config[:password]}:#{@request_count}:#{@digest["nonce"]}")
        hash = Digest::MD5.hexdigest("#{first}:#{@digest["nonce"]}:#{"%08X" % @request_count}:#{cnonce}:#{@digest["qop"]}:#{second}")
      # Nothing specified, so default to the old one
      elsif @digest_type.empty?
        hash = Digest::MD5.hexdigest("#{first}:#{@digest["nonce"]}:#{second}")
      else
        raise RETS::HTTPError, "Cannot determine auth type for server (#{@digest_type.join(",")})"
      end

      http_digest = "Digest username=\"#{@config[:username]}\", "
      http_digest << "realm=\"#{@digest["realm"]}\", "
      http_digest << "nonce=\"#{@digest["nonce"]}\", "
      http_digest << "uri=\"#{request_uri}\", "
      http_digest << "algorithm=MD5, " unless @digest_type.empty?
      http_digest << "response=\"#{hash}\", "
      http_digest << "opaque=\"#{@digest["opaque"]}\""

      unless @digest_type.empty?
        http_digest << ", "
        http_digest << "qop=\"#{@digest["qop"]}\", "
        http_digest << "nc=#{"%08X" % @request_count}, "
        http_digest << "cnonce=\"#{cnonce}\""
      end

      http_digest
    end
274817
public function get(string $domain, string $path = '', string $name = null): array {
        $this->clearExpiredCookies();

        $path = $path === "" ? "/" : $path;
        $domain = \strtolower($domain);

        $matches = [];

        foreach ($this->cookies as $cookieDomain => $domainCookies) {
            if (!$this->matchesDomain($domain, $cookieDomain)) {
                continue;
            }

            foreach ($domainCookies as $cookiePath => $pathCookies) {
                if (!$this->matchesPath($path, $cookiePath)) {
                    continue;
                }

                foreach ($pathCookies as $cookieName => $cookie) {
                    if (!isset($name) || $name === $cookieName) {
                        $matches[] = $cookie;
                    }
                }
            }
        }

        return $matches;
    }
342218
protected function getDomaincd($domain)
    {
        $pattern = '//epp:epp/epp:response/epp:resData/domain:chkData/domain:cd[domain:name[php:functionString("XPath\quote", text()) = \'%s\']]';
        $query = sprintf($pattern, XPath\quote($domain));
        $node = $this->getFirst($query);

        if ($node === null) {
            throw new UnexpectedValueException(sprintf('Domain with name [%s] not found.', $domain));
        }

        return $node;
    }
309741
public function createApiDocs($domain)
    {
        ini_set('memory_limit', -1);
        ini_set('max_execution_time', -1);

        $type = $this->getRequest()->get('type') ?: ApiController::PSFS_DOC;
        $download = $this->getRequest()->get('download') ?: false;

        $module = $this->srv->getModules($domain);
        if(empty($module)) {
            return Router::getInstance()->httpNotFound(null, true);
        }
        switch (strtolower($type)) {
            case ApiController::SWAGGER_DOC:
                $doc = DocumentorService::swaggerFormatter($module);
                break;
            case ApiController::POSTMAN_DOC:
                $doc = ['Pending...'];
                break;
            default:
            case ApiController::HTML_DOC:
            case ApiController::PSFS_DOC:
                $doc = $this->srv->extractApiEndpoints($module);
                break;
        }

        ini_restore('max_execution_time');
        ini_restore('memory_limit');

        if($download && $type === ApiController::SWAGGER_DOC) {
            return $this->download(json_encode($doc), 'application/json', 'swagger.json');
        }
        if($type === ApiController::HTML_DOC) {
            return $this->render('documentation.html.twig', ["data" => json_encode($doc)]);
        }
        return $this->json($doc, 200);
    }
860569
protected function getPathAndDomain($path, $domain, $secure = null, $sameSite = null)
    {
        return [$path ?: $this->path, $domain ?: $this->domain, is_bool($secure) ? $secure : $this->secure, $sameSite ?: $this->sameSite];
    }
1103109
protected function getDomain(?string $domain = null) : ?string
    {
        $domain = $domain ?? $this->appUrl;

        if ($domain === null) {
            return null;
        }

        return $this->trim(str_replace(['http:', 'https:'], '', $domain), '/');
    }
976285
protected function parseFragment($url, $template, $tag, $page, $cur)
    {
        $fragment = self::fetchFragment($template, $tag);
        if (empty($fragment)) {
            return $template;
        }
        $replace = '';
        if (is_array($page)) {
            foreach ($page as $number) {
                $replace .= $this->fillLink($fragment, $url, $tag, $number, $cur);
            }
        } else {
            $replace .= $this->fillLink($fragment, $url, $tag, $page, $cur);
        }

        return str_replace($fragment, $replace, $template);
    }
1122053
public function getSiteByDomain($domain)
    {
        $queryBuilder = $this->_em->createQueryBuilder();
        $queryBuilder->select('domain, site, primaryDomain')
            ->from(\Rcm\Entity\Domain::class, 'domain')
            ->leftJoin('domain.site', 'site')
            ->leftJoin('domain.primaryDomain', 'primaryDomain')
            ->where('domain.domain = :domainName')
            ->setParameter('domainName', $domain);

        try {
            /** @var \Rcm\Entity\Domain $domain */
            $domain = $queryBuilder->getQuery()->getSingleResult();
        } catch (NoResultException $e) {
            return null;
        }

        if ($domain->getPrimary()) {
            $site = $domain->getPrimary()->getSite();
            $this->_em->detach($site);
            $this->_em->detach($domain);
            $site->setDomain($domain);
        } else {
            $site = $domain->getSite();
        }

        return $site;
    }
1244891
public static function getLdapServersForDomain($domain)
    {
        $hosts = (new Dns())->getRecord(self::SRV_PREFIX.$domain, DNS_SRV);

        return is_array($hosts) ? array_column($hosts, 'target') : [];
    }
820103
public function digest() {
		if (empty($this->headers['WWW-Authenticate'])) {
			return [];
		}
		$auth = $this->_classes['auth'];
		return $auth::decode($this->headers['WWW-Authenticate']);
	}
596524
private static function domain(string $url): ?string
    {
        $domain = parse_url($url, PHP_URL_HOST);

        if (null !== $domain) {
            return implode('.', array_slice(explode('.', $domain), -2));
        }

        return null;
    }