? .DS_Store
Index: alias/hosting_alias.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/hosting/alias/hosting_alias.module,v
retrieving revision 1.10
diff -u -r1.10 hosting_alias.module
--- alias/hosting_alias.module	27 May 2009 17:31:49 -0000	1.10
+++ alias/hosting_alias.module	10 Jul 2009 14:29:49 -0000
@@ -133,7 +133,7 @@
         $aliases = explode("\n", $node->aliases);
         foreach ($aliases as $alias) {
           if ($alias = trim($alias)) {
-            if (hosting_site_exists($alias, $node->nid)) {
+            if (hosting_site_exists($alias, $node->port, $node->nid)) {
               form_set_error('aliases', t('The domain name @alias is already in use by another site', array('@alias' => $alias)));
             }
           }
@@ -220,7 +220,7 @@
  * This function will check the existing aliases and the automatically
  * generated aliases to ensure that this url has not been used before
  */
-function hosting_alias_allow_domain($url, $nid = null) {
+function hosting_alias_allow_domain($url, $port = null, $nid = null) {
   $query = "SELECT COUNT(n.nid) FROM {node} n 
       LEFT JOIN {hosting_site} h ON h.nid=n.nid 
       LEFT JOIN {hosting_site_alias} a  ON n.vid = a.vid 
@@ -230,6 +230,11 @@
   $args[] = $url;
   $args[] = ~HOSTING_SITE_DELETED;
 
+  if ($port) {
+    $query .= ' AND h.port = %d';
+    $args[] = $port;
+  }
+  
   if ($nid) {
     $query .= ' AND n.nid <> %d';
     $args[] = $nid;
Index: platform/hosting_platform.drush.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/hosting/platform/hosting_platform.drush.inc,v
retrieving revision 1.3
diff -u -r1.3 hosting_platform.drush.inc
--- platform/hosting_platform.drush.inc	20 May 2009 21:24:28 -0000	1.3
+++ platform/hosting_platform.drush.inc	10 Jul 2009 14:29:49 -0000
@@ -5,6 +5,7 @@
   $task =& drush_get_context('HOSTING_TASK');
   if ($task->ref->type == 'site') {
     $node = node_load($task->ref->platform);
+    $task->options['site_port'] = $task->ref->port;
   }
   elseif ($task->ref->type == 'platform') {
     $node = $task->ref;
Index: site/hosting_site.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/hosting/site/hosting_site.install,v
retrieving revision 1.8
diff -u -r1.8 hosting_site.install
--- site/hosting_site.install	28 May 2009 05:54:43 -0000	1.8
+++ site/hosting_site.install	10 Jul 2009 14:29:50 -0000
@@ -61,6 +61,11 @@
         'not null' => TRUE,
         'default' => 0,
       ),
+      'port' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
     ),
     'primary key' => array('vid'),
   );
@@ -188,3 +193,10 @@
 
   return $ret;
 }
+
+function hosting_site_update_6() {
+  $ret = array();
+  $ret[] = update_sql("ALTER TABLE {hosting_site} ADD COLUMN port int(10) NOT NULL default '0'");
+  db_query("UPDATE {hosting_site} SET port=80");
+  return $ret;
+}
Index: site/hosting_site.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/hosting/site/hosting_site.module,v
retrieving revision 1.107
diff -u -r1.107 hosting_site.module
--- site/hosting_site.module	28 May 2009 05:54:43 -0000	1.107
+++ site/hosting_site.module	10 Jul 2009 14:29:50 -0000
@@ -208,6 +208,8 @@
       '#default_value' => $node->title,
       '#weight' => -5
     );
+    $form['port'] = _hosting_site_form_port();
+
   }
   else {
     $form['info']['title'] = array(
@@ -218,6 +220,13 @@
     );
 
     $form['title'] = array('#type' => 'hidden', '#value' => $node->title);
+    
+    $form['info']['port'] = array(
+      '#type' => 'item',
+      '#title' => t('Port'),
+      '#value' => $node->port,
+     );
+    $form['port'] = array('#type' => 'hidden', '#value' => $node->port);
   }
 
 
@@ -352,8 +361,13 @@
   if (!_hosting_valid_fqdn($url)) {
     form_set_error('title', t("You have not specified a valid url for this site."));
   }
+  
+  if ($node->port<1) {
+    form_set_error('title', t("You have not specified a valid port for this site."));
+  }
+  
   # TODO: maybe we should allow creation of sites that conflict with HOSTING_SITE_DISABLED (which would then need to be renamed before being re-enabled)
-  if (hosting_site_exists($url, $node->nid)) {
+  if (hosting_site_exists($url, $node->port, $node->nid)) {
     form_set_error('title', t("The domain name you have specified is not unique."));
   }
   if (!$node->new_client) {
@@ -390,8 +404,8 @@
   $node->client = $client->nid;
   $node->site_language = ($node->site_language) ? $node->site_language : 'en';
 
-  db_query("INSERT INTO {hosting_site} (vid, nid, client, db_server, platform, profile, language, last_cron, status, verified) VALUES (%d, %d, %d, %d, %d, %d, '%s', %d, %d, %d)",
-    $node->vid, $node->nid, $node->client, $node->db_server, $node->platform, $node->profile, $node->site_language, $node->last_cron, $node->site_status, $node->verified);
+  db_query("INSERT INTO {hosting_site} (vid, nid, client, db_server, platform, profile, language, last_cron, status, verified, port) VALUES (%d, %d, %d, %d, %d, %d, '%s', %d, %d, %d, %d)",
+    $node->vid, $node->nid, $node->client, $node->db_server, $node->platform, $node->profile, $node->site_language, $node->last_cron, $node->site_status, $node->verified, $node->port);
   if ((!$node->old_vid)) {
     if ($node->import) {
       hosting_add_task($node->nid, 'import');
@@ -402,6 +416,19 @@
   }
 }
  
+function _hosting_site_allowed_ports($platform) {
+  $ports = db_result(db_query("SELECT ports FROM {hosting_platform} p JOIN {hosting_web_server} w ON p.web_server = w.nid WHERE p.nid = %d", $platform));
+  $ports = explode(",", $ports);
+  $ret = array();
+  foreach($ports as $p) {
+    $p = trim($p);
+    if(is_numeric($p)) {
+      $ret[$p] = $p;
+    }
+  }
+  return $ret;
+}
+
 function hosting_site_update(&$node) {
   // if this is a new node or we're adding a new revision,
   if ($node->revision) {
@@ -410,8 +437,8 @@
   else {
     $client = hosting_get_client($node->client);
     $node->client = $client->nid;
-    db_query("UPDATE {hosting_site} SET client = %d, db_server = %d, platform = %d, last_cron = %d, status = %d, profile = %d, language = '%s', verified = %d WHERE vid=%d",
-              $node->client, $node->db_server, $node->platform, $node->last_cron, $node->site_status, $node->profile, $node->site_language, $node->verified, $node->vid);
+    db_query("UPDATE {hosting_site} SET client = %d, db_server = %d, platform = %d, last_cron = %d, status = %d, profile = %d, language = '%s', verified = %d, port = %d WHERE vid=%d",
+              $node->client, $node->db_server, $node->platform, $node->last_cron, $node->site_status, $node->profile, $node->site_language, $node->verified, $node->port, $node->vid);
   }
   if (!$node->no_verify) {
     hosting_add_task($node->nid, 'verify');
@@ -419,7 +446,7 @@
 }
 
 function hosting_site_load($node) {
-  $additions = db_fetch_object(db_query('SELECT  client, db_server, platform, profile, language as site_language, last_cron, status AS site_status, verified FROM {hosting_site} WHERE vid = %d', $node->vid));
+  $additions = db_fetch_object(db_query('SELECT  client, db_server, platform, profile, language as site_language, last_cron, status AS site_status, verified, port FROM {hosting_site} WHERE vid = %d', $node->vid));
   return $additions;
 }
 
@@ -443,9 +470,19 @@
   hosting_set_breadcrumb($node);
   $node->content['info']['#prefix'] = '<div id="hosting-site-info">';
   if ($node->site_status == HOSTING_SITE_ENABLED) {
+    switch($node->port) {
+      case 80:
+      $theurl = 'http://' . $node->title;
+      break;
+      case 443:
+      $theurl = 'https://' . $node->title;
+      break;
+      default:
+      $theurl = 'http://' . $node->title . ':' . $node->port;
+    }
     $node->content['info']['link'] = array(
       '#value' => l(t('Go to site'),
-      'http://' . $node->title),
+      $theurl),
       '#weight' => -10
     );
   }
@@ -464,6 +501,12 @@
     '#title' => t('Verified'),
     '#value' => hosting_format_interval($node->verified),
   );
+  
+  $node->content['info']['port'] = array(
+    '#type' => 'item',
+    '#title' => t('Port'),
+    '#value' => $node->port,
+  );
 
   $node->content['info']['platform'] = array(
     '#type' => 'item',
@@ -585,8 +628,8 @@
  * This function hooks into hook_allow_domain to let contrib modules
  * weigh in on whether the site should be created.
  */
-function hosting_site_exists($url, $nid = null) {
-  $results = module_invoke_all('allow_domain', $url, $nid);
+function hosting_site_exists($url, $port = null, $nid = null) {
+  $results = module_invoke_all('allow_domain', $url, $port, $nid);
   $result = in_array(TRUE, $results);
   return $result; 
 }
@@ -594,13 +637,18 @@
 /*
  * Check if a site with a specific url exists, ignoring deleted sites
  */
-function hosting_site_allow_domain($url, $nid=null) {
+function hosting_site_allow_domain($url, $port = null, $nid=null) {
   $query = "SELECT COUNT(n.nid) FROM 
     {node} n JOIN {hosting_site} h 
     ON n.nid = h.nid WHERE type='site'
     AND title='%s' AND h.status <> %d";
   $args[] = $url;
   $args[] = HOSTING_SITE_DELETED;
+  
+  if ($port) {
+    $query .= ' AND h.port = %d';
+    $args[] = $port;
+  }
 
   if ($nid) {
     $query .= ' AND n.nid <> %d';
@@ -735,6 +783,32 @@
   return $form['profile'];
 }
 
+function _hosting_site_form_port($platform = HOSTING_DEFAULT_PLATFORM) {
+  $showports = _hosting_site_allowed_ports($platform);
+  $defport = reset($showports);
+  foreach($showports as $key => $val) {
+    if ($key == 80 ){
+      $showports[$key] .= " (http)";
+    }
+    if ($key == 443) {
+      $showports[$key] .= " (https)";
+    }
+  }
+  if (sizeof($showports) > 1) {
+    $form['port'] = array(
+      '#type' => 'radios',
+      '#title' => t('Port'),
+      '#required' => TRUE,
+      '#default_value' => $defport,
+      '#options' => $showports,
+      '#attributes' => array('class' => "hosting-site-form-port-options"),
+     );
+  } else {
+      $form['port'] = array('#type' => 'hidden', '#default_value' => $defport, '#attributes' => array('class' => "hosting-site-form-port-options"));
+  }
+  return $form['port'];
+}
+
 /**
  * generate hosting site node form element 'language'
  */
Index: site/hosting_site_form.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/hosting/site/hosting_site_form.js,v
retrieving revision 1.6
diff -u -r1.6 hosting_site_form.js
--- site/hosting_site_form.js	28 May 2009 05:54:43 -0000	1.6
+++ site/hosting_site_form.js	10 Jul 2009 14:29:50 -0000
@@ -7,7 +7,9 @@
     $('div.hosting-site-form-site-language-options').parent().hide();
     $('input[@name=platform]').change(function() {
       hostingSitePopulate('profile');
+      hostingSitePopulate('port');
       $('div.hosting-site-form-site-language-options').parent().hide();
+      $('div.hosting-site-form-site-port-options').parent().hide();
     });
     $('input[@name=profile]').change(function() {
       hostingSitePopulate('site_language');
@@ -20,7 +22,7 @@
  */
 function hostingSitePopulate(option) {
   // initialize variables
-  parent_field = ((option == 'profile') ? 'platform' : 'profile');
+  parent_field = ((option == 'profile' || option == 'port') ? 'platform' : 'profile');
   obj = _hostingSiteField(parent_field); 
   value = $('input[@name=' + option + ']:checked').val();
   
@@ -64,7 +66,7 @@
     $('div#hm-processing').remove();
   }
   // prepare url params
-  params = (option == 'profile') ? $(obj).val() : ($(obj).val() + '/' + $(_hostingSiteField('platform')).val());
+  params = (option == 'profile' || option == 'port') ? $(obj).val() : ($(obj).val() + '/' + $(_hostingSiteField('platform')).val());
   $.get('/hosting/hosting_site_form_populate/' + option + '/' + params, null, resultOptions);
 }
 
Index: web_server/hosting_web_server.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/hosting/web_server/hosting_web_server.install,v
retrieving revision 1.4
diff -u -r1.4 hosting_web_server.install
--- web_server/hosting_web_server.install	27 May 2009 17:31:50 -0000	1.4
+++ web_server/hosting_web_server.install	10 Jul 2009 14:29:50 -0000
@@ -55,6 +55,11 @@
         'size' => 'big',
         'not null' => FALSE,
       ),
+      'ports' => array(
+        'type' => 'text',
+        'size' => 'big',
+        'not null' => FALSE,
+      ),
     ),
     'primary key' => array('vid'),
   );
@@ -75,3 +80,10 @@
   $ret[] = update_sql("ALTER TABLE {hosting_web_server} ADD COLUMN drush_path longtext NOT NULL default ''");
   return $ret;
 }
+
+function hosting_web_server_update_2() {
+  $ret = array();
+  $ret[] = update_sql("ALTER TABLE {hosting_web_server} ADD COLUMN ports longtext NOT NULL default ''");
+  db_query("UPDATE {hosting_web_server} SET ports = '80'");
+  return $ret;
+}
Index: web_server/hosting_web_server.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/hosting/web_server/hosting_web_server.module,v
retrieving revision 1.35
diff -u -r1.35 hosting_web_server.module
--- web_server/hosting_web_server.module	5 Jun 2009 18:03:34 -0000	1.35
+++ web_server/hosting_web_server.module	10 Jul 2009 14:29:50 -0000
@@ -199,6 +199,16 @@
     '#weight' => -8,
   );
 
+  $form['ports'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Ports'),
+    '#required' => TRUE,
+    '#size' => 40,
+    '#default_value' => ($node->ports) ? $node->ports : '80',
+    '#description' => t("All the ports enabled on this server, comma separated. Port 80 is the default http, 443 is https."),
+    '#maxlength' => 255,
+    '#weight' => -8,
+  );
 
   $form['restart_cmd'] = array(
       '#type' => 'textfield',
@@ -284,6 +294,16 @@
   if (!_hosting_valid_fqdn($node->title)) {
     form_set_error('title', t('Invalid valid domain name. Either choose a proper domain name or hardcode the IP address of the webserver.'));
   }
+  $ports = explode(",", $node->ports);
+  if (count($ports) < 1) {
+    form_set_error('ports', t('At least one port must be provided.'));
+  }
+  foreach($ports as $port) {
+    if ($port < 1) {
+      form_set_error('ports', t('Invalid port specified'));
+    }
+  }
+  
   if ($node->script_user == 'root') {
     form_set_error('script_user', t('For security reasons, you should not run drush commands as the root user. Please choose a different system account name.'));
   }
@@ -299,9 +319,9 @@
  */
 function hosting_web_server_insert($node) {
   print_r($form);
-  db_query("INSERT INTO {hosting_web_server} (vid, nid, ip_address, script_user, web_group, config_path, backup_path, restart_cmd, drush_path) 
-      VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')", 
-        $node->vid, $node->nid, $node->ip_address, $node->script_user, $node->web_group, $node->config_path, $node->backup_path, $node->restart_cmd, $node->drush_path);
+  db_query("INSERT INTO {hosting_web_server} (vid, nid, ip_address, script_user, web_group, config_path, backup_path, restart_cmd, drush_path, ports) 
+      VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", 
+        $node->vid, $node->nid, $node->ip_address, $node->script_user, $node->web_group, $node->config_path, $node->backup_path, $node->restart_cmd, $node->drush_path, $node->ports);
 }
 
 /**
@@ -319,12 +339,12 @@
     db_query("UPDATE {hosting_web_server} SET 
                   ip_address = '%s', script_user = '%s', web_group = '%s', 
                   config_path = '%s', backup_path = '%s', restart_cmd = '%s',
-                  drush_path = '%s'
+                  drush_path = '%s', ports = '%s'
               WHERE 
                   vid = %d", 
                   $node->ip_address, $node->script_user, $node->web_group,
                   $node->config_path, $node->backup_path, $node->restart_cmd, 
-                  $node->drush_path,
+                  $node->drush_path, $node->ports,
                   $node->vid);
   }
 }
@@ -344,7 +364,7 @@
  * Implementation of hook_load().
  */
 function hosting_web_server_load($node) {
-  $additions = db_fetch_object(db_query('SELECT ip_address, script_user, web_group, config_path, backup_path, restart_cmd, drush_path FROM {hosting_web_server} WHERE vid = %d', $node->vid));
+  $additions = db_fetch_object(db_query('SELECT ip_address, script_user, web_group, config_path, backup_path, restart_cmd, drush_path, ports FROM {hosting_web_server} WHERE vid = %d', $node->vid));
   return $additions;
 }
 
@@ -371,6 +391,11 @@
     '#title' => t('Drush path'),
     '#value' => filter_xss($node->drush_path),
   );
+  $node->content['info']['ports'] = array(
+    '#type' => 'item',
+    '#title' => t('Ports'),
+    '#value' => $node->ports,
+  );
   $node->content['info']['script_user'] = array(
     '#type' => 'item',
     '#title' => t('Script user'),
