예제 #1
0
function channelReconfigure($service_id, $array, $force = false)
{
    global $config, $channelParameters;
    //get the identifier
    $id = stripAlphaNumeric(getServiceParam($service_id, "id"));
    if ($id === false) {
        return false;
    }
    //we allow admin to add some extra keys for this instance in configuration
    $extraKeys = getServiceParam($service_id, "extrakeys");
    if ($extraKeys === false) {
        $extraKeys = array();
    } else {
        $extraKeys = explode(" ", $extraKeys);
    }
    //get the existing configuration
    $channelConfiguration = channelGetConfiguration($service_id, false);
    //modify the configuration based on input $array settings
    foreach ($array as $k => $v) {
        if (isset($channelParameters[$k])) {
            $channelConfiguration[$k] = channelEscape($channelParameters[$k][0], $channelParameters[$k][1], $channelParameters[$k][2], $v);
        } else {
            if (in_array($k, $extraKeys) || $force) {
                $channelConfiguration[$k] = channelEscape(0, 0, 0, $v);
            }
        }
    }
    //sort the configuration intelligently
    uksort($channelConfiguration, 'channelConfigurationComparator');
    //write the configuration out
    $fout = fopen($config['channel_path'] . $id . "/chop.cfg", 'w');
    foreach ($channelConfiguration as $k => $v) {
        fwrite($fout, "{$k} = {$v}\n");
    }
    fclose($fout);
    $jail = jailEnabled($service_id);
    if ($jail) {
        jailFileClose($service_id, "channel", "chop.cfg", true);
    }
    return true;
}
예제 #2
0
<?php

include "../include/common.php";
include "../config.php";
include "../include/session.php";
include "../include/dbconnect.php";
include "../include/account.php";
include "../include/channel.php";
if (isset($_SESSION['account_id']) && isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) && isset($_SESSION['is_' . $_REQUEST['id'] . '_channel'])) {
    if (isset($_POST['action']) && $_POST['action'] == "update") {
        //create array of configurations we are updating
        $array = channelGetConfigFromRequest(channelGetParameters($_REQUEST['id']), $_REQUEST);
        channelReconfigure($_REQUEST['id'], $array);
        if (!isset($_SESSION['noredirect'])) {
            header("Location: config_main.php?id=" . $_REQUEST['id']);
            return;
        }
    }
    $mconfig = channelGetConfiguration($_REQUEST['id']);
    get_page("config_main", "channel", array('service_id' => $_REQUEST['id'], 'mconfig' => $mconfig, 'parameters' => $channelParameters));
} else {
    header("Location: ../panel/");
}