Ejemplo n.º 1
0
/**
 * Given a URI of an existing site, will return settings defined in that site's settings.php
 */
function unl_get_site_settings($uri)
{
    $settings_file = DRUPAL_ROOT . '/sites/' . unl_get_sites_subdir($uri) . '/settings.php';
    if (!is_readable($settings_file)) {
        throw new Exception('No settings.php exists for site at ' . $uri);
    }
    if (is_readable(DRUPAL_ROOT . '/sites/all/settings.php')) {
        require DRUPAL_ROOT . '/sites/all/settings.php';
    }
    require $settings_file;
    unset($uri);
    unset($settings_file);
    return get_defined_vars();
}
Ejemplo n.º 2
0
/**
 * Perform the actual site delete.
 */
function unl_site_remove($site_id)
{
    $uri = db_select('unl_sites', 's')->fields('s', array('uri'))->condition('site_id', $site_id)->execute()->fetchCol();
    if (!isset($uri[0])) {
        form_set_error(NULL, t('The site could not be removed.'));
        return;
    }
    $uri = $uri[0];
    $sites_subdir = unl_get_sites_subdir($uri);
    $sites_subdir = DRUPAL_ROOT . '/sites/' . $sites_subdir;
    $sites_subdir = realpath($sites_subdir);
    // A couple checks to make sure we aren't deleting something we shouldn't be.
    if (substr($sites_subdir, 0, strlen(DRUPAL_ROOT . '/sites/')) != DRUPAL_ROOT . '/sites/') {
        form_set_error(NULL, t('The site could not be removed.'));
        return;
    }
    if (strlen($sites_subdir) <= strlen(DRUPAL_ROOT . '/sites/')) {
        form_set_error(NULL, t('The site could not be removed.'));
        return;
    }
    shell_exec('rm -rf ' . escapeshellarg($sites_subdir));
    db_update('unl_sites')->fields(array('installed' => 3))->condition('site_id', $site_id)->execute();
    db_update('unl_sites_aliases')->fields(array('installed' => 3))->condition('site_id', $site_id)->execute();
    return TRUE;
}
Ejemplo n.º 3
0
function unl_remove_alias($base_uri, $path, $alias_id)
{
    $alias_uri = $base_uri . $path;
    $alias_config_dir = unl_get_sites_subdir($alias_uri, FALSE);
    /* TODO: Remove the next line once all sites have been converted
     *       to the new method of creating aliases.
     */
    unlink(DRUPAL_ROOT . '/sites/' . $alias_config_dir);
    unl_remove_alias_from_sites_php($alias_id);
    unl_remove_site_from_htaccess($alias_id, TRUE);
}