diff --git a/alias/hosting_alias.module b/alias/hosting_alias.module index 566e17f..63c5a25 100644 --- a/alias/hosting_alias.module +++ b/alias/hosting_alias.module @@ -43,13 +43,14 @@ function hosting_alias_form_alter(&$form, $form_state, $form_id) { '#title' => t('Domain aliases'), '#description' => t('Your site can also be accessed through these domain names. This field requires each domain alias to be on its own line'), '#default_value' => implode("\n", (array) $form['#node']->aliases), - '#weight' => 10, + '#weight' => 9, ); $form['redirection'] = array( '#type' => 'checkbox', '#title' => t('Redirection'), '#description' => t('Aliases will all be redirected to the main domain if this is checked. Otherwise, all aliases will be accessible transparently.'), '#default_value' => isset($form['#node']->redirection) ? $form['#node']->redirection : variable_get('hosting_alias_redirection', FALSE), + '#weight' => 10, ); } } diff --git a/platform/hosting_platform.drush.inc b/platform/hosting_platform.drush.inc index bb11e8a..bfdfc8c 100644 --- a/platform/hosting_platform.drush.inc +++ b/platform/hosting_platform.drush.inc @@ -5,7 +5,7 @@ function drush_hosting_platform_pre_hosting_task($task) { $task =& drush_get_context('HOSTING_TASK'); if ($task->ref->type == 'site') { $node = node_load($task->ref->platform); - $task->options['site_port'] = $task->ref->port; + $task->options['site_port'] = explode(',', $task->ref->port); } elseif ($task->ref->type == 'platform') { $node = $task->ref; diff --git a/site/hosting_site.install b/site/hosting_site.install index 24c8f5e..d796588 100644 --- a/site/hosting_site.install +++ b/site/hosting_site.install @@ -220,3 +220,10 @@ function hosting_site_update_6002() { db_add_field($ret, 'hosting_site', 'ssl_redirect', array('type' => 'int', 'not null' => TRUE, 'default' => 0)); return $ret; } + +function hosting_site_update_6003() { + $ret = array(); + $ret[] = update_sql("ALTER TABLE {hosting_site} CHANGE port port longtext NOT NULL default '0'"); + return $ret; +} + diff --git a/site/hosting_site.module b/site/hosting_site.module index 4cf9729..4bf136f 100644 --- a/site/hosting_site.module +++ b/site/hosting_site.module @@ -314,7 +314,7 @@ function hosting_site_form($node) { $form['platform'] = array('#type' => 'hidden', '#value' => $node->platform); $form['info']['port'] = array( '#type' => 'item', - '#title' => t('Port'), + '#title' => t('Ports'), '#value' => $node->port, ); $form['port'] = array('#type' => 'hidden', '#value' => $node->port); @@ -370,14 +370,20 @@ function hosting_site_validate($node, &$form) { if (!_hosting_valid_fqdn($url)) { form_set_error('title', t("You have not specified a valid url for this site.")); } - - if ($node->port < 1 || $node->port > 65536) { - form_set_error('title', t("You have not specified a valid port for this site.")); - } - if (!array_key_exists($node->port, _hosting_site_allowed_ports($node->platform))) { - form_set_error('title', t("This port is forbidden by the administrators.")); + $element = $node->port; + foreach ($element as $key => $choice) { + if (isset($element[$key]) && $element[$key] != 0) { + $ports[] = $element[$key]; + } } - + foreach ($ports as $port) { + if ($port < 1 || $port > 65536) { + form_set_error('title', t("You have not specified a valid port for this site.")); + } + if (!array_key_exists($port, _hosting_site_allowed_ports($node->platform))) { + form_set_error('title', t("This port is forbidden by the administrators.")); + } + } if (!$node->new_client) { $client = hosting_get_client($node->client); if (!$node->client || !$client) { @@ -417,9 +423,15 @@ function hosting_site_insert(&$node) { $client = hosting_get_client($node->client); $node->client = $client->nid; $node->site_language = ($node->site_language) ? $node->site_language : 'en'; + $element = $node->port; + foreach ($element as $key => $choice) { + if (isset($element[$key]) && $element[$key] != 0) { + $ports[] = $element[$key]; + } + } + db_query("INSERT INTO {hosting_site} (vid, nid, client, db_server, platform, profile, language, last_cron, status, verified, port, `ssl`, ssl_redirect) VALUES (%d, %d, %d, %d, %d, %d, '%s', %d, %d, %d, '%s', %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, @implode(',', $ports), $node->ssl, $node->ssl_redirect); - db_query("INSERT INTO {hosting_site} (vid, nid, client, db_server, platform, profile, language, last_cron, status, verified, port, `ssl`, ssl_redirect) VALUES (%d, %d, %d, %d, %d, %d, '%s', %d, %d, %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, $node->ssl, $node->ssl_redirect); if ((!$node->old_vid)) { if ($node->import) { hosting_add_task($node->nid, 'import'); @@ -450,8 +462,7 @@ function hosting_site_update(&$node) { } 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, port = %d, `ssl` = %d, ssl_redirect = %d WHERE vid=%d", + 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 = '%s', `ssl` = %d, ssl_redirect = %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->ssl, $node->ssl_redirect, $node->vid); } if (!$node->no_verify) { @@ -518,7 +529,7 @@ function hosting_site_view(&$node, $teaser = false) { $node->content['info']['port'] = array( '#type' => 'item', - '#title' => t('Port'), + '#title' => t('Ports'), '#value' => $node->port, ); @@ -842,10 +853,9 @@ function _hosting_site_form_port($platform = HOSTING_DEFAULT_PLATFORM) { $defport = reset($showports); if (sizeof($showports) > 1 && user_access('change site port')) { $form['port'] = array( - '#type' => 'radios', - '#title' => t('Port'), + '#type' => 'checkboxes', + '#title' => t('Ports'), '#required' => TRUE, - '#default_value' => $defport, '#options' => $showports, '#weight' => 5, '#attributes' => array('class' => "hosting-site-form-port-options"), diff --git a/ssl/hosting_ssl.module b/ssl/hosting_ssl.module index 2b182e4..4622211 100644 --- a/ssl/hosting_ssl.module +++ b/ssl/hosting_ssl.module @@ -21,9 +21,9 @@ function hosting_ssl_form_alter(&$form, &$form_state, $form_id) { } // small chunk of code to toggle the ports when SSL is chosen $javascript = '$("#edit-port-80").attr("checked", !this.checked);$("#edit-port-443").attr("checked", this.checked);'; - $form['port']['ssl'] = array('#type' => 'checkbox', '#title' => 'Enable SSL encryption', '#default_value' => $default, '#weight' => 4, '#attributes' => array('onClick' => $javascript . ';if (!this.checked) { $("#edit-ssl-redirect").attr("checked", this.checked) };'),); - $form['port']['ssl_redirect'] = array('#type' => 'checkbox', '#title' => 'Redirect HTTP to HTTPS', '#default_value' => $redirect, '#weight' => 5, '#attributes' => array('onClick' => 'if (this.checked) { ' . $javascript . ';$("#edit-ssl").attr("checked", this.checked);}'),); - $form['port']['#title'] = t("Port and encryption"); + $form['info']['encryption'] = array('#type' => 'item', '#title' => 'Encryption'); + $form['info']['encryption']['ssl'] = array('#type' => 'checkbox', '#title' => 'Enable SSL encryption', '#default_value' => $default, '#weight' => 4, '#attributes' => array('onClick' => $javascript . ';if (!this.checked) { $("#edit-ssl-redirect").attr("checked", this.checked) };'),); + $form['info']['encryption']['ssl_redirect'] = array('#type' => 'checkbox', '#title' => 'Redirect HTTP to HTTPS', '#default_value' => $redirect, '#weight' => 5, '#attributes' => array('onClick' => 'if (this.checked) { ' . $javascript . ';$("#edit-ssl").attr("checked", this.checked);}'),); } } @@ -35,4 +35,4 @@ function hosting_ssl_nodeapi(&$node, $op, $teaser, $page) { } break; } -} \ No newline at end of file +}