# Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
if (!defined("EXPONENT")) {
    exit("");
}
if (exponent_permissions_check('manage_site', exponent_core_makeLocation('SharedCoreModule'))) {
    $i18n = exponent_lang_loadFile('modules/sharecoremodule/actions/save_site.php');
    $site = null;
    if (isset($_POST['id'])) {
        $site = $db->selectObject("sharedcore_site", "id=" . intval($_POST['id']));
    }
    $site = sharedcore_site::update($_POST, $site);
    if ($site == null) {
        header("Location: " . $_SERVER['HTTP_REFERER']);
        exit('Redirecting');
    }
    if (substr($site->path, -1, 1) != "/") {
        $site->path .= "/";
    }
    if (is_really_writable($site->path)) {
        if (!isset($site->id)) {
            // New -- link stuff
            if (!file_exists($site->path . "exponent_version.php")) {
                if (!defined("SYS_SHAREDCORE")) {
                    require_once BASE . "subsystems/sharedcore.php";
                }
                $core = $db->selectobject("sharedcore_core", "id=" . $site->core_id);