Beispiel #1
0
function find_config_xml()
{
    global $g, $debug;
    $disks = get_disks();
    // Safety check.
    if (!is_array($disks)) {
        return;
    }
    $boot_disk = get_boot_disk();
    exec("/bin/mkdir -p /tmp/mnt/cf");
    foreach ($disks as $disk) {
        $slices = get_disk_slices($disk);
        if (is_array($slices)) {
            foreach ($slices as $slice) {
                if ($slice == "") {
                    continue;
                }
                if (stristr($slice, $boot_disk)) {
                    if ($debug) {
                        echo "\nSkipping boot device slice {$slice}";
                    }
                    continue;
                }
                echo " {$slice}";
                // First try msdos fs
                if ($debug) {
                    echo "\n/sbin/mount -t msdosfs /dev/{$slice} /tmp/mnt/cf 2>/dev/null \n";
                }
                $result = exec("/sbin/mount -t msdosfs /dev/{$slice} /tmp/mnt/cf 2>/dev/null");
                // Next try regular fs (ufs)
                if (!$result) {
                    if ($debug) {
                        echo "\n/sbin/mount /dev/{$slice} /tmp/mnt/cf 2>/dev/null \n";
                    }
                    $result = exec("/sbin/mount /dev/{$slice} /tmp/mnt/cf 2>/dev/null");
                }
                $mounted = trim(exec("/sbin/mount | /usr/bin/grep -v grep | /usr/bin/grep '/tmp/mnt/cf' | /usr/bin/wc -l"));
                if ($debug) {
                    echo "\nmounted: {$mounted} ";
                }
                if (intval($mounted) > 0) {
                    // Item was mounted - look for config.xml file
                    $config_location = discover_config($slice);
                    if ($config_location) {
                        if (test_config($config_location)) {
                            // We have a valid configuration.  Install it.
                            echo " -> found config.xml\n";
                            echo "Backing up old configuration...\n";
                            backup_config();
                            echo "Restoring [{$slice}] {$config_location}...\n";
                            restore_backup($config_location);
                            echo "Cleaning up...\n";
                            exec("/sbin/umount /tmp/mnt/cf");
                            exit;
                        }
                    }
                    exec("/sbin/umount /tmp/mnt/cf");
                }
            }
        }
    }
}
Beispiel #2
0
    exit;
}
if (isset($_GET["tabs"])) {
    tabs();
    exit;
}
if (isset($_POST["COMPRESS_ENABLE"])) {
    Save();
    exit;
}
if (isset($_GET["res-list"])) {
    echo list_ressource();
    exit;
}
if (isset($_GET["backup-config"])) {
    echo backup_config();
    exit;
}
if (isset($_GET["backup-save-config"])) {
    backup_save_config();
    exit;
}
if (isset($_GET["cyrus-delete"])) {
    backup_delete();
    exit;
}
if (isset($_GET["backup-perform-now"])) {
    backup_now();
    exit;
}
js();
Beispiel #3
0
function adm_params($curauth, $rep)
{
    $auth = ses('auth');
    $goto = '/?admin=params';
    $qb = ses('qb');
    req('boot,adminx');
    connect();
    //$db
    if ($auth > 6 && $_GET['m_cnfg'] == '=') {
        $mcfg = '&m_cnfg==';
        $f = 'params/_' . $db . '_config.txt';
        if (is_file($f)) {
            $prms = explode('#', read_file($f));
        }
        $arr = msql_read_prep('system', 'admin_config');
        $hl = 'lang_admin*config_';
    } else {
        $prms = $_SESSION['prmb'];
        $prmb = sql('config', 'qdu', 'v', 'name="' . ses('qb') . '"');
        $prms = explode('#', $prmb);
        $prms = prmb_defaults($prms);
        $arr = msql_read_prep('system', 'admin_params');
        $hl = 'lang_admin*params_';
    }
    if ($_GET['params'] == 'save' && $auth >= $curauth) {
        for ($i = 0; $i <= $_POST['valmax']; $i++) {
            $prms[$i] = $_POST['pms' . $i];
            $vaue .= $prms[$i] . '#';
        }
        if ($prms[1] != prmb(1) && !$_GET['m_cnfg']) {
            newmodfrom($prms[1]);
        }
        if ($_GET['m_cnfg'] == '=') {
            write_file($f, $vaue);
            update('qdu', 'struct', $vaue, 'name', $qb);
            master_params('params/_' . $db, $qd, $aqb, $subd);
            alert(lkt('txtyl', $f, $db . '_config'));
        } else {
            $_SESSION['prmb'] = $prms;
            update('qdu', 'config', $vaue, 'name', $qb);
        }
    }
    $sty = '" style="width:200px;';
    //read
    foreach ($arr as $t => $ak) {
        foreach ($ak as $i => $v) {
            if ($i != 22) {
                if ($valmax < $i) {
                    $valmax = $i;
                }
                $attr = array('name' => 'pms' . $i, 'style' => 'width:200px;');
                if ($i == 11 && !$_GET['m_cnfg']) {
                    //$r[$t].=menuder_form_kv(affect_auth($auth),'pms'.$i.$sty,$prms[$i],'kv');
                    $r[$t] .= select($attr, affect_auth($auth), 'kv', $prms[$i]);
                } elseif ($i == 25) {
                    $lc = 'msql/lang/';
                    $dirs = explore($lc, 'dirs', 1);
                    $dirs = str_replace($lc, '', $dirs);
                    //$r[$t].=menuder_form_kv($dirs,'pms'.$i.$sty,$prms[$i],'vv').' ';
                    $r[$t] .= select($attr, $dirs, 'vv', $prms[$i]);
                } elseif ($i == 21) {
                    $r[$t] .= txarea('pms' . $i, $prms[$i], 31, 5) . ' ';
                } else {
                    $r[$t] .= input2('text" size="34', 'pms' . $i, $prms[$i], '') . ' ';
                }
                $r[$t] .= btn('txtblc', $v) . ' ' . btn('txtsmall2', bubble('grey', 'popmsqt', $hl . $i, $i)) . br();
            }
        }
    }
    $r[$t] .= hidden('valmax', '', $valmax) . br();
    $ret = form($goto . $mcfg . '&params=save', make_tabs($r, 'prm') . input2('submit', 'Submit', nms(27), '')) . br();
    if ($auth > 6 && !$mcfg) {
        $ret .= lkc('txtbox', $goto . '&m_cnfg==', 'server') . ' ' . backup_config();
    }
    return $ret;
}