Gets URL of a png img of a website (16x16 pixel).

@param string $domain
@return string
509813
public function siteIconUrl($domain) {
		if (strpos($domain, 'http') === 0) {
			// Strip protocol
			$pieces = parse_url($domain);
			$domain = $pieces['host'];
		}
		return 'http://www.google.com/s2/favicons?domain=' . $domain;
	}
73174
public static function domainToUnicode($domain)
    {
        return mb_strlen($domain, 'UTF-8') <= self::PHP_IDN_HANDLEABLE_LENGTH
            ? idn_to_utf8($domain, 0, INTL_IDNA_VARIANT_UTS46)
            : false;
    }
592926
public function clean($domain)
    {
        $domain = trim($domain);
        $domain = preg_replace('#^https?://#', '', $domain);
        if (substr(strtolower($domain), 0, 4) == "www.") $domain = substr($domain, 4);

        return $domain;
    }
1034852
public function getDomainInfo( $domain ) {
		$domain = $this->normalizeDomain( $domain );
		// Check cache and custom-registered domains
		if ( !isset( $this->domainInfos[ $domain ] ) ) {
			// Default to local domain
			$dir = $this->localBaseDir . '/language/messages/' . $domain;
			if ( !is_dir( $dir ) ) {
				// Domain does not exist
				return false;
			}
			$this->domainInfos[ $domain ] = [
				'dir' => $dir,
			];
		}
		return $this->domainInfos[ $domain ];
	}
165363
public static function getXDomainId($domain)
	{
		$db = \App::get('db');

		if (empty($domain) || ($domain == 'hubzero'))
		{
			return false;
		}

		$query = 'SELECT domain_id FROM `#__xdomains` WHERE domain=' . $db->quote($domain) . ';';
		$db->setQuery($query);

		$result = $db->loadObject();

		if (empty($result))
		{
			return false;
		}

		return $result->domain_id;
	}
1149952
protected function addPortToDomain($domain)
    {
        if (in_array($this->request->getPort(), array('80', '443'))) {
            return $domain;
        }

        return $domain .':' .$this->request->getPort();
    }
501253
protected function _get_domain( $content ) {
		$permalink = $this->get_permalink();
		if ( ! $permalink ) {
			$permalink = $this->_get_permalink( $content );
		}

		preg_match( '/https?:\/\/([^\/]+)/', $permalink, $reg );
		if ( ! empty( $reg[1] ) ) {
			return $reg[1];
		}
	}
436642
public function getSignature($domain, $user)
    {
        $url = self::BASE_URL . "{$domain}/{$user}/signature";
        $request = new \Google_Http_Request($url, 'GET', null, null);

        $httpRequest = $this->helper->getClient()
           ->getAuth()
           ->authenticatedRequest($request);
        if ($httpRequest->getResponseHttpCode() == 200) {
            $xmlResponse = new \SimpleXMLElement($httpRequest->getResponseBody(), 0, false, 'apps', true);

            return (string)$xmlResponse->children('apps', true)
               ->attributes()->value;
        } else {
            // An error occurred.
            return null;
        }
    }
1319381
protected function _get_thumbnail( $content ) {
		preg_match( '/<meta +?property=["\']og:image["\'][^\/>]*? content=["\']([^"\']+?)["\'].*?\/?>/si', $content, $reg );
		if ( empty( $reg[1] ) ) {
			return;
		}

		$thumbnail = $reg[1];
		$thumbnail = $this->_relative_path_to_url( $thumbnail, $content );

		if ( is_ssl() ) {
			$thumbnail = preg_replace( '|^http:|', 'https:', $thumbnail );
		}

		$requester = new Requester( $thumbnail );
		$response  = $requester->request( $thumbnail );
		if ( is_wp_error( $response ) ) {
			return;
		}

		$status_code = $requester->get_status_code();
		if ( 200 != $status_code && 304 != $status_code ) {
			return;
		}

		return $thumbnail;
	}
1154738
static public function getJid( $domain, $node = NULL, $resource = NULL ){
		$jid	= $domain;
		if( strlen( trim( $node ) ) ) 
			$jid	= $node.'@'.$domain;
		if( strlen( trim( $resource ) ) )
			$jid	.= "/".$resource;
		return $jid;
	}
266176
protected function getPictureGeneratorUrl($image, $imageQuery = NULL)
    {
        if(!is_null($imageQuery))
        {
            $image .= '@' . $imageQuery;
        }

        return $this->generator->loadPicture($image)->getUrl();
    }
1036595
public static function domainFromString($url)
    {
        $domain = parse_url($url, PHP_URL_HOST);
        if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {
            return $regs['domain'];
        }
        return false;
    }
590374
protected function stripPort($domain)
    {
        if ($domainStripped = \preg_replace(self::PATTERN_STRIP_PROTOCOL, null, $domain)) {
            return $domainStripped;
        }

        return $domain;
    }
780839
protected function tryGuessScheme(?string $domain) : ?string
    {
        if ($domain !== null) {
            if (Str::startsWith($domain, 'https')) {
                return 'https://';
            }

            if (Str::startsWith($domain, 'http')) {
                return 'http://';
            }
        }

        return (isset($_SERVER['HTTPS'])
            && !empty($_SERVER['HTTPS'])
            && strtolower($_SERVER['HTTPS']) !== 'off')
            ? 'https://' : 'http://';
    }
652817
protected function getImageUrl()
    {
        $imageUrl = "";

        if ($this->getImagePath()) {
            $imageUrl = $this->getImageDirUrl() . $this->getImageName();
        }

        return $imageUrl;
    }
1078777
static public function GetRootDomain($domain=null) 
	{
	    $domain = !empty($domain) ? $domain : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null);
	    if (!$domain) {
	        return 'localhost';
	    }
	    
	    $re_domain = '';
	    $domain_postfix_cn_array = array("com", "net", "org", "gov", "edu", "com.cn", "net.cn", "cn");
	    $array_domain = explode(".", $domain);
	    $array_num = count($array_domain) - 1;
	    if ($array_domain[$array_num] == 'cn') {
	        if (in_array($array_domain[$array_num - 1], $domain_postfix_cn_array)) {
	            $re_domain = $array_domain[$array_num - 2] . "." . $array_domain[$array_num - 1] . "." . $array_domain[$array_num];
	        } else {
	            $re_domain = $array_domain[$array_num - 1] . "." . $array_domain[$array_num];
	        }
	    } else {
	        $re_domain = $array_domain[$array_num - 1] . "." . $array_domain[$array_num];
	    }
	    return $re_domain;
	}
1257790
public function domain($domain = null)
    {
        if (func_num_args() === 0) {
            return $this->_data['domain'];
        }
        return $this->_data['domain'] = $domain === null ?  $domain : (string) $domain;
    }