当前位置: 首页>>代码示例>>PHP>>正文


PHP URL::getHost方法代码示例

本文整理汇总了PHP中URL::getHost方法的典型用法代码示例。如果您正苦于以下问题:PHP URL::getHost方法的具体用法?PHP URL::getHost怎么用?PHP URL::getHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在URL的用法示例。


在下文中一共展示了URL::getHost方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isExcluded

 /**
  * Check whether a given URL is excluded
  *
  * @param   peer.URL url
  * @return  bool
  */
 public function isExcluded(URL $url)
 {
     foreach ($this->excludes as $pattern) {
         if (stristr($url->getHost(), $pattern)) {
             return TRUE;
         }
     }
     return FALSE;
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:15,代码来源:HttpProxy.class.php

示例2: setup

 /**
  * Setup the class instance. A dsn string must be given with the relevant information
  * about the server and script:
  *
  * Eg: nagios://nagios.xp_framework.net:5667/service_to_monitor
  *
  * @param   string dsn
  */
 public function setup($dsn)
 {
     $url = new URL($dsn);
     $this->server = $url->getHost();
     $this->port = $url->getPort(5667);
     $this->version = $url->getParam('version', NSCA_VERSION_2);
     $this->service = trim($url->getPath(), '/');
     $this->host = $url->getParam('hostname', System::getProperty('host.name'));
     if (FALSE !== $url->getParam('domain', FALSE)) {
         $this->host .= '.' . ltrim($url->getParam('domain'), '.');
     }
 }
开发者ID:Gamepay,项目名称:xp-contrib,代码行数:20,代码来源:Heartbeat.class.php

示例3: newRequest

 /**
  * Creates a new request object
  *
  * @param   string method
  * @param   peer.URL url
  * @return  scriptlet.HttpScriptletRequest
  */
 protected function newRequest($method, URL $url)
 {
     $q = $url->getQuery('');
     $req = new HttpScriptletRequest();
     $req->method = $method;
     $req->env['SERVER_PROTOCOL'] = 'HTTP/1.1';
     $req->env['REQUEST_URI'] = $url->getPath('/') . ($q ? '?' . $q : '');
     $req->env['QUERY_STRING'] = $q;
     $req->env['HTTP_HOST'] = $url->getHost();
     if ('https' === $url->getScheme()) {
         $req->env['HTTPS'] = 'on';
     }
     $req->setHeaders(array());
     $req->setParams($url->getParams());
     return $req;
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:23,代码来源:HttpScriptletProtocolVersionTest.class.php

示例4: send_new_project_email

function send_new_project_email($group_id)
{
    global $Language;
    $res_grp = db_query("SELECT * FROM groups WHERE group_id='" . db_ei($group_id) . "'");
    if (db_numrows($res_grp) < 1) {
        echo $Language->getText('include_proj_email', 'g_not_exist', $group_id);
    }
    $row_grp = db_fetch_array($res_grp);
    $res_admins = db_query("SELECT user.user_name,user.email FROM user,user_group WHERE " . "user.user_id=user_group.user_id AND user_group.group_id='" . db_ei($group_id) . "' AND " . "user_group.admin_flags='A'");
    $nb_recipients = db_numrows($res_admins);
    if ($nb_recipients < 1) {
        echo $Language->getText('include_proj_email', 'no_admin', $group_id);
    }
    // send one email per admin
    $nb_mail_failed = 0;
    $pm = ProjectManager::instance();
    while ($row_admins = db_fetch_array($res_admins)) {
        $server = get_server_url();
        $p = $pm->getProject($group_id);
        $host = $GLOBALS['sys_default_domain'];
        if ($p && $p->usesService('svn')) {
            $sf = new ServerFactory();
            if ($s =& $sf->getServerById($p->services['svn']->getServerId())) {
                $host = URL::getHost($s->getUrl(session_issecure()));
            }
        }
        if ($GLOBALS['sys_force_ssl']) {
            $svn_url = 'https://' . $host;
        } else {
            $svn_url = 'http://svn.' . $row_grp['unix_group_name'] . '.' . $host;
        }
        $svn_url .= '/svnroot/' . $row_grp['unix_group_name'];
        // $message is defined in the content file
        include $Language->getContent('include/new_project_email');
        // LJ Uncomment to test
        //echo $message; return
        $mail = new Mail();
        $mail->setTo($row_admins['email']);
        $mail->setSubject($GLOBALS['sys_name'] . ' ' . $Language->getText('include_proj_email', 'proj_approve', $row_grp['unix_group_name']));
        $mail->setBody($message);
        $mail->setFrom($GLOBALS['sys_email_admin']);
        if (!$mail->send()) {
            $nb_mail_failed++;
        }
    }
    return $nb_mail_failed < $nb_recipients;
}
开发者ID:nterray,项目名称:tuleap,代码行数:47,代码来源:proj_email.php

示例5: acquire

 /**
  * Acquire a handler instance
  *
  * @param   string key
  * @return  remote.protocol.ProtocolHandler
  * @throws  remote.protocol.UnknownProtocolException
  */
 public function acquire($key, $initialize = FALSE)
 {
     $url = new URL($key);
     $key = new URL($url->getScheme() . '://' . $url->getHost());
     if ($this->pool->containsKey($key)) {
         $instance = $this->pool->get($key);
     } else {
         sscanf($url->getScheme(), '%[^+]+%s', $type, $option);
         $class = HandlerFactory::handlerFor($type);
         $instance = $this->pool($key, $class->newInstance($option));
     }
     // Add logger
     if (NULL !== ($cat = $url->getParam('log'))) {
         $instance->setTrace(Logger::getInstance()->getCategory($cat));
     }
     // Set timeout, defaults to 60 seconds
     $instance->setTimeout($url->getParam('timeout', 60));
     $initialize && $instance->initialize($url);
     return $instance;
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:27,代码来源:HandlerInstancePool.class.php

示例6: doCreate

 public function doCreate()
 {
     $req = $this->newRequest('GET', new URL('http://localhost/'));
     $res = new HttpScriptletResponse();
     $s = newinstance('scriptlet.xml.XMLScriptlet', array(), '{
     public function needsSession($request) { return TRUE; }
   }');
     $s->service($req, $res);
     $this->assertEquals(HttpConstants::STATUS_FOUND, $res->statusCode);
     // Check URL from Location: header contains the session ID
     with($redirect = new URL(substr($res->headers[0], strlen('Location: '))));
     $this->assertEquals('http', $redirect->getScheme());
     $this->assertEquals('localhost', $redirect->getHost());
     $this->assertEquals(sprintf('/xml/psessionid=%s/static', session_id()), $redirect->getPath());
     $this->assertEquals(array(), $redirect->getParams(), $redirect->getURL());
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:16,代码来源:XmlScriptletTest.class.php

示例7: newSocket

 /**
  * Creates a socket
  *
  * @param   peer.URL url
  * @param   string arg
  * @return  peer.Socket
  */
 protected function newSocket(URL $url, $arg)
 {
     return new Socket($url->getHost(), $url->getPort(80));
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:11,代码来源:SocketHttpTransport.class.php

示例8: newSocket

 /**
  * Creates a socket - overridden from parent class
  *
  * @param   peer.URL url
  * @param   string arg
  * @return  peer.Socket
  */
 protected function newSocket(URL $url, $arg)
 {
     sscanf($arg, 'v%d', $version);
     return new SSLSocket($url->getHost(), $url->getPort(443), NULL, $version);
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:12,代码来源:SSLSocketHttpTransport.class.php

示例9: handleSessionInitializationError

 public function handleSessionInitializationError()
 {
     $req = $this->newRequest('GET', new URL('http://localhost/?psessionid=MALFORMED'));
     $res = new HttpScriptletResponse();
     $s = newinstance('scriptlet.HttpScriptlet', array(), '{
     public function needsSession($request) { return TRUE; }
     public function handleSessionInitialization($request) {
       if (!preg_match("/^a-f0-9$/", $request->getSessionId())) { 
         throw new IllegalArgumentException("Invalid characters in session id");
       }
       parent::handleSessionInitialization($request);
     }
     public function handleSessionInitializationError($request, $response) {
       $request->getURL()->addParam("relogin", 1);
       return $request->session->initialize(NULL);
     } 
   }');
     $s->service($req, $res);
     $this->assertEquals(HttpConstants::STATUS_FOUND, $res->statusCode);
     // Check URL from Location: header contains the session ID
     with($redirect = new URL(substr($res->headers[0], strlen('Location: '))));
     $this->assertEquals('http', $redirect->getScheme());
     $this->assertEquals('localhost', $redirect->getHost());
     $this->assertEquals('/', $redirect->getPath());
     $this->assertEquals(session_id(), $redirect->getParam('psessionid'));
     $this->assertEquals('1', $redirect->getParam('relogin'));
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:27,代码来源:HttpScriptletTest.class.php

示例10: getHostAddress

 /**
  * Get the IP address of our host. An empty host field or a DNS failure
  * will result in a null return.
  *
  * @param u a URL object
  * @return InetAddress an <code>InetAddress</code> representing the host
  * IP address.
  * @since 1.3
  */
 public function getHostAddress(URL $u)
 {
     if ($u->hostAddress != null) {
         return $u->hostAddress;
     }
     $host = $u->getHost();
     if ($host == null || $host->equals("")) {
         return null;
     } else {
         try {
             $u->hostAddress = InetAddress::getByName($host);
             //            } catch (UnknownHostException $ex) {
             //                return null;
             //            } catch (SecurityException $se) {
             //                return null;
         } catch (\blaze\lang\Exception $e) {
             return null;
         }
     }
     return $u->hostAddress;
 }
开发者ID:robo47,项目名称:BlazeFramework,代码行数:30,代码来源:URLStreamHandler.php

示例11: sqliteUrl

 public function sqliteUrl()
 {
     $u = new URL('sqlite:///path/to/file.db');
     $this->assertEquals(NULL, $u->getHost());
     $this->assertEquals('/path/to/file.db', $u->getPath());
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:6,代码来源:URLTest.class.php

示例12: navigateTo

 /**
  * Navigate to a given URL
  *
  * @param   string target
  * @param   string params
  * @param   string method
  * @throws  unittest.AssertionFailedError  
  */
 public function navigateTo($target, $params = NULL, $method = HttpConstants::GET)
 {
     if (strstr($target, '://')) {
         $url = new URL($target);
         $this->conn = $this->getConnection(sprintf('%s://%s%s/', $url->getScheme(), $url->getHost(), -1 === $url->getPort(-1) ? '' : ':' . $url->getPort()));
         $params ? $url->setParams($params) : '';
         $this->beginAt($url->getPath(), $url->getParams(), $method);
     } else {
         if ('' !== $target && '/' === $target[0]) {
             $this->beginAt($target, $params, $method);
         } else {
             $base = $this->getBase();
             $this->beginAt(substr($base, 0, strrpos($base, '/')) . '/' . $target, $params, $method);
         }
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:24,代码来源:WebTestCase.class.php

示例13: _parsedsn

 /**
  * Parse DSN
  *
  * @param   string dsn
  * @return  bool success
  */
 protected function _parsedsn($dsn)
 {
     if (NULL === $dsn) {
         return TRUE;
     }
     $u = new URL($dsn);
     if (!$u->getHost()) {
         throw new IllegalArgumentException('DSN parsing failed ["' . $dsn . '"]');
     }
     // Scheme
     switch (strtoupper($u->getScheme())) {
         case 'ESMTP':
             $this->ext = TRUE;
             break;
         case 'SMTP':
             $this->ext = FALSE;
             break;
         default:
             throw new IllegalArgumentException('Scheme "' . $u->getScheme() . '" not supported');
     }
     // Copy host and port
     $this->host = $u->getHost();
     $this->port = $u->getPort() ? $u->getPort() : 25;
     // User & password
     if ($u->getUser()) {
         $this->auth = $u->getParam('auth', SMTP_AUTH_PLAIN);
         $this->user = $u->getUser();
         $this->pass = $u->getPassword();
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:36,代码来源:SmtpTransport.class.php

示例14: db_query

// Table for summary info
print '<TABLE width="100%"><TR valign="top"><TD width="65%">' . "\n";
// Get group properties
$res_grp = db_query("SELECT * FROM groups WHERE group_id=" . db_ei($group_id));
$row_grp = db_fetch_array($res_grp);
$pm = ProjectManager::instance();
$p = $pm->getProject($group_id);
// Show CVS access information
if ($row_grp['svn_preamble'] != '') {
    echo $hp->purify(util_unconvert_htmlspecialchars($row_grp['svn_preamble']), CODENDI_PURIFIER_FULL);
} else {
    $host = $GLOBALS['sys_default_domain'];
    if ($p && $p->usesService('svn')) {
        $sf = new ServerFactory();
        if ($server =& $sf->getServerById($p->services['svn']->getServerId())) {
            $host = URL::getHost($server->getUrl(session_issecure()));
        }
    }
    if ($GLOBALS['sys_force_ssl']) {
        $svn_url = 'https://' . $host;
    } else {
        if (isset($GLOBALS['sys_disable_subdomains']) && $GLOBALS['sys_disable_subdomains']) {
            $svn_url = 'http://' . $host;
        } else {
            $svn_url = 'http://svn.' . $row_grp['unix_group_name'] . '.' . $host;
        }
    }
    // Domain name must be lowercase (issue with some SVN clients)
    $svn_url = strtolower($svn_url);
    $svn_url .= '/svnroot/' . $row_grp['unix_group_name'];
    // Hook to replace the default information about subversion
开发者ID:nterray,项目名称:tuleap,代码行数:31,代码来源:svn_intro.php


注:本文中的URL::getHost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。