Exemple #1
0
        $_POST['excludes'][$key] = explode("\n", trim($value));
        for ($j = 0; $j < count($_POST['excludes'][$key]); $j++) {
            $_POST['excludes'][$key][$j] = trim($_POST['excludes'][$key][$j]);
        }
    }
    $cfg['BackupFilesExclude'] = array_combine($_POST['sharenames'], $_POST['excludes']);
    // 2 -Backup Period settings
    $cfg['FullPeriod'] = fmtFloat(fmtfloat($_POST['full']) - 0.03);
    $cfg['IncrPeriod'] = fmtFloat(fmtfloat($_POST['incr']) - 0.03);
    // Blackout periods
    $starthours = $_POST['starthour'];
    $endhours = $_POST['endhour'];
    $cfg['BlackoutPeriods'] = array();
    for ($i = 0; $i < count($starthours); $i++) {
        $daystring = implode(', ', $_POST['days' . $i]);
        $cfg['BlackoutPeriods'][] = array('hourBegin' => hhmm2float($starthours[$i]), 'hourEnd' => hhmm2float($endhours[$i]), 'weekDays' => $daystring);
    }
    // Rsync and NmbLookup command lines
    $cfg['NmbLookupCmd'] = '/usr/bin/python /usr/bin/pulse2-uuid-resolver -A $host';
    $cfg['NmbLookupFindHostCmd'] = '/usr/bin/python /usr/bin/pulse2-uuid-resolver $host';
    $cfg['XferMethod'] = 'rsync';
    $cfg['RsyncClientCmd'] = '$sshPath -q -x -o StrictHostKeyChecking=no -l root $hostIP $rsyncPath $argList+';
    $cfg['RsyncClientRestoreCmd'] = '$sshPath -q -x -o StrictHostKeyChecking=no -l root $hostIP $rsyncPath $argList+';
    $cfg['PingCmd'] = '/bin/true';
    // Enable or disable backup
    $cfg['BackupsDisable'] = isset($_POST['active']) ? '0' : '1';
    set_host_config($_POST['host'], $cfg);
    new NotifyWidgetSuccess(_T('Configuration saved', 'backuppc'));
}
/*
 * Display right top shortcuts menu
require "localSidebar.php";
require "graph/navbar.inc.php";
require_once "modules/backuppc/includes/xmlrpc.php";
require_once "modules/backuppc/includes/functions.php";
require_once "modules/backuppc/includes/html.inc.php";
// Getting Profile ID (if specified) else 0
$ID = intval(@max($_GET['id'], $_POST['id']));
// Receiving POST DATA
if (isset($_POST['bconfirm'])) {
    $cfg = array('profilename' => $_POST['profilename'], 'full' => fmtFloat(fmtfloat($_POST['full']) - 0.03), 'incr' => fmtFloat(fmtfloat($_POST['incr']) - 0.03), 'exclude_periods' => '');
    // Formatting Exclude periods
    $starthours = $_POST['starthour'];
    $endhours = $_POST['endhour'];
    for ($i = 0; $i < count($starthours); $i++) {
        $daystring = implode(',', $_POST['days' . $i]);
        $cfg['exclude_periods'] .= sprintf("%s=>%s:%s\n", hhmm2float($starthours[$i]), hhmm2float($endhours[$i]), $daystring);
    }
    $cfg['exclude_periods'] = trim($cfg['exclude_periods']);
    // If default profile, we add a new herited one
    if ($ID < 1000) {
        $ID = 0;
    }
    if ($ID) {
        $profile = edit_period_profile($ID, $cfg);
        // APPLY PROFILE TO ALL CONCERNED HOSTS
        apply_period_profile($ID);
    } else {
        $profile = add_period_profile($cfg);
    }
} else {
    if ($ID) {