You are here

function _lockr_write_key_files in Lockr 7.3

Same name and namespace in other branches
  1. 7.2 lockr.module \_lockr_write_key_files()

Writes key files.

Parameters

string $dir:

array $texts:

3 calls to _lockr_write_key_files()
drush_lockr_register in ./lockr.drush.inc
Registers the site with lockr.
lockr_admin_migrate_form_submit in ./lockr.admin.inc
lockr_admin_register_form_submit in ./lockr.admin.inc

File

./lockr.module, line 189
Hook implementations and callbacks for lockr.

Code

function _lockr_write_key_files($dir, array $texts) {
  @mkdir($dir, 0700, TRUE);
  $key_file = "{$dir}/key.pem";
  $key_fd = fopen($key_file, 'w');
  fwrite($key_fd, $texts['key_text']);
  fclose($key_fd);
  chmod($key_file, 0600);
  $cert_file = "{$dir}/crt.pem";
  $cert_fd = fopen($cert_file, 'w');
  fwrite($cert_fd, $texts['cert_text']);
  fclose($cert_fd);
  chmod($cert_file, 0600);
  $pair_file = "{$dir}/pair.pem";
  $pair_fd = fopen($pair_file, 'w');
  fwrite($pair_fd, $texts['key_text']);
  fwrite($pair_fd, $texts['cert_text']);
  fclose($pair_fd);
  chmod($pair_file, 0600);
}