View source
<?php
function hosting_server_schema() {
$schema['hosting_server'] = array(
'fields' => array(
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'vid',
),
);
$schema['hosting_ip_addresses'] = array(
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'ip_address' => array(
'type' => 'text',
'size' => 'small',
'not null' => TRUE,
),
'id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'primary key' => array(
'id',
),
'indexes' => array(
'nid' => array(
'nid',
),
),
);
$schema['hosting_service'] = array(
'fields' => array(
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'service' => array(
'type' => 'text',
'size' => 'small',
'not null' => TRUE,
),
'type' => array(
'type' => 'text',
'size' => 'small',
'not null' => TRUE,
),
'restart_cmd' => array(
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
),
'port' => array(
'type' => 'int',
'default' => 0,
'unsigned' => TRUE,
'not null' => FALSE,
),
'available' => array(
'type' => 'int',
'size' => 'small',
'not null' => TRUE,
'default' => 1,
),
),
'indexes' => array(
'vid' => array(
'vid',
),
),
);
return $schema;
}
function hosting_server_install() {
drupal_install_schema('hosting_server');
}
function hosting_server_uninstall() {
drupal_uninstall_schema('hosting_server');
}
function hosting_server_update_6000() {
$return = array();
db_add_index($return, 'hosting_service', 'vid', array(
'vid',
));
return $return;
}
function hosting_server_update_6001() {
$ret = array();
db_drop_field($ret, "hosting_server", "drush_path");
db_drop_field($ret, "hosting_server", "backup_path");
return $ret;
}
function hosting_server_update_6002() {
$ret = array();
db_query("DELETE FROM {hosting_service} WHERE service='server'");
db_drop_field($ret, "hosting_server", "script_user");
db_drop_field($ret, "hosting_server", "config_path");
return $ret;
}
function hosting_server_update_6003() {
db_add_field($ret, 'hosting_service', 'port', array(
'type' => 'int',
'default' => 0,
'unsigned' => TRUE,
'not null' => FALSE,
));
db_add_field($ret, 'hosting_service', 'restart_cmd', array(
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
));
return $ret;
}
function hosting_server_update_6004() {
$return = array();
$schema = array(
'fields' => array(
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'ip_address' => array(
'type' => 'text',
'size' => 'small',
'not null' => TRUE,
),
),
'indexes' => array(
'vid' => array(
'vid',
),
),
);
db_create_table($return, 'hosting_server_ip', $schema);
return $return;
}
function hosting_server_update_6005() {
$ret = array();
db_rename_table($ret, 'hosting_server_ip', 'hosting_ip_addresses');
return $ret;
}
function hosting_server_update_6200() {
$ret = array();
db_drop_index($ret, 'hosting_ip_addresses', 'vid');
db_drop_field($ret, "hosting_ip_addresses", "vid");
db_add_field($ret, "hosting_ip_addresses", "id", array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
), array(
'primary key' => array(
'id',
),
));
$r = db_query("SELECT nid, ip_address FROM {hosting_ip_addresses}");
for ($i = 0; $row = db_fetch_object($r); $i++) {
$ret[] = update_sql("UPDATE {hosting_ip_addresses} SET id={$i} WHERE nid={$row->nid} AND ip_address='{$row->ip_address}'");
}
db_add_index($ret, 'hosting_ip_addresses', 'nid', array(
'nid',
));
return $ret;
}
function hosting_server_update_6201() {
if (!db_table_exists('hosting_ssl_site')) {
return array(
array(
'success' => TRUE,
),
);
}
$ret = array();
$schema = array(
'fields' => array(
'cid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'ip_address' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'cid' => array(
'cid',
),
'ip_address' => array(
'ip_address',
),
),
);
db_create_table($ret, 'hosting_ssl_cert_ips', $schema);
return $ret;
}
function hosting_server_update_6202() {
if (!db_table_exists('hosting_ssl_site')) {
return array(
array(
'success' => TRUE,
),
);
}
$ret = array();
$ret[] = update_sql("INSERT INTO {hosting_ssl_cert_ips} (cid, ip_address)\n SELECT cert.cid,server_ip.id FROM {hosting_ssl_site} ssl_site\n INNER JOIN {hosting_ssl_cert} cert ON cert.cid = ssl_site.ssl_key\n INNER JOIN {hosting_ip_addresses} site_ip ON site_ip.nid = ssl_site.nid\n INNER JOIN {hosting_site} site ON site.nid = ssl_site.nid\n INNER JOIN {hosting_ip_addresses} server_ip ON server_ip.ip_address = site_ip.ip_address\n INNER JOIN {hosting_platform} p ON site.platform = p.nid AND p.web_server = server_ip.nid\n WHERE ssl_enabled > %d AND site.status > %d GROUP BY cid", HOSTING_SSL_DISABLED, HOSTING_SITE_DELETED);
return $ret;
}