You are here

function _hosting_site_url in Hosting 6.2

Same name and namespace in other branches
  1. 7.4 site/hosting_site.module \_hosting_site_url()
  2. 7.3 site/hosting_site.module \_hosting_site_url()

Get site's URL.

2 calls to _hosting_site_url()
hosting_cron_queue in cron/hosting_cron.module
Implementation of hosting_QUEUE_TYPE_queue().
hosting_site_goto in site/hosting_site.module
Menu callback to go to your site.

File

site/hosting_site.module, line 193

Code

function _hosting_site_url($node) {
  $schema = 'http';
  $port = null;
  $url = strtolower(trim($node->title));
  $platform = node_load($node->platform);
  $server = node_load($platform->web_server);
  if ($server->services['http']
    ->has_port()) {
    $port = $server->services['http']->port;
    if ($port == 80) {
      $port = null;
    }
  }

  /**
   * This is part of the ssl feature, but is better to implement here.
   */
  if (isset($node->ssl_enabled) && $node->ssl_enabled == 2) {

    // this is a bit of a magic number, because we cant rely on the constant being available yet.
    // 2 == Only SSL is enabled.
    $schema = 'https';
    if ($server->services['http']
      ->has_port()) {
      $port = $server->services['http']->ssl_port;
      if ($port == 443) {
        $port = null;
      }
    }
  }
  if (is_numeric($port)) {
    return "{$schema}://{$url}:{$port}";
  }
  return "{$schema}://{$url}";
}