You are here

function hosting_ssl_save_key in Hostmaster (Aegir) 6

Store the SSL Cert key in the database.

2 calls to hosting_ssl_save_key()
hosting_ssl_nodeapi_site_insert in modules/hosting/web_server/ssl/hosting_ssl.nodeapi.inc
hosting_ssl_nodeapi_site_update in modules/hosting/web_server/ssl/hosting_ssl.nodeapi.inc

File

modules/hosting/web_server/ssl/hosting_ssl.nodeapi.inc, line 231

Code

function hosting_ssl_save_key($key, $ssl_enabled = TRUE, $client = null) {
  if (empty($ssl_enabled)) {
    return 0;
  }

  // we only save the new key if it's a string
  if (!is_numeric($key)) {
    $result = db_query("SELECT * FROM {hosting_ssl_cert} WHERE ssl_key = '%s'", $key);
    if ($obj = db_fetch_object($result)) {

      // update
      if ($client != null) {
        $obj->client = $client;
      }
      drupal_write_record("hosting_ssl_cert", $obj, 'cid');
    }
    else {

      // insert
      $obj = new stdClass();
      $obj->ssl_key = $key;
      $obj->client = $client;
      $obj->status = 0;
      drupal_write_record("hosting_ssl_cert", $obj);
    }
    return $obj->cid;
  }
  return $key;
}