Esempio n. 1
0
/**
 * Add accesspoint
 */
function sumo_add_accesspoint($data = array())
{
    if (!empty($data)) {
        global $SUMO;
        $path = sumo_get_normalized_accesspoint($data['path']);
        $node = $data['node'] ? $data['node'] : "NULL";
        $group = sumo_get_ordered_groups($data['usergroup']);
        $reg_group = $data['reg_group'] ? $data['reg_group'] : $SUMO['config']['accesspoints']['def_group'];
        $theme = $data['theme'];
        $http_auth = $data['http_auth'] == 'on' || $data['http_auth'] == 1 ? 1 : 0;
        $filtering = $data['filtering'] == 'on' || $data['filtering'] == 1 ? 1 : 0;
        $pwd_encrypt = $data['pwd_encrypt'] == 'on' || $data['pwd_encrypt'] == 1 ? 1 : 0;
        $change_pwd = $data['change_pwd'] == 'on' || $data['change_pwd'] == 1 ? 1 : 0;
        $registration = $data['registration'] == 'on' || $data['registration'] == 1 ? 1 : 0;
        //
        $filtering = $data['filtering'] == 'false' && sumo_verify_is_console($path) ? 1 : $filtering;
        // AP names
        $languages = sumo_get_available_languages();
        $names = "";
        for ($l = 0; $l < count($languages); $l++) {
            $names[$l] = $languages[$l] . ":" . $data['name'][$languages[$l]];
        }
        $name = implode(";", $names);
        $query = "INSERT INTO " . SUMO_TABLE_ACCESSPOINTS . " \r\n\t\t\t\t  (\r\n\t\t\t\t\tnode, path, name,usergroup, http_auth, filtering, pwd_encrypt,\r\n\t\t\t\t  \treg_group, change_pwd, registration, theme, created\r\n\t\t\t\t  ) \r\n\t\t\t\t  VALUES (\r\n\t\t\t\t  \t" . $node . ", '" . $path . "', '" . $name . "', '" . $group . "', " . $http_auth . ", " . $filtering . ", \r\n\t\t\t\t  \t" . $pwd_encrypt . ", '" . $reg_group . "', " . $change_pwd . ", " . $registration . ", '" . $theme . "', \r\n\t\t\t\t  \t" . $SUMO['server']['time'] . "\r\n\t\t\t\t  )";
        $SUMO['DB']->Execute($query);
        // Create row stats for accesspoint
        $accesspoint = sumo_get_accesspoint_info($SUMO['server']['time'], 'created', FALSE);
        $query = "INSERT INTO " . SUMO_TABLE_ACCESSPOINTS_STATS . " \r\n\t\t\t\t  (\r\n\t\t\t\t  \tnode, id_page, access, activity, updated\r\n\t\t\t\t  ) \r\n\t\t\t\t  VALUES (\r\n\t\t\t\t  \t" . $node . ", " . $accesspoint['id'] . ", 0, 0, " . $SUMO['server']['time'] . "\r\n\t\t\t\t  )";
        $SUMO['DB']->Execute($query);
        // if accesspoint was added
        if (sumo_verify_accesspoint_exist($node, $path)) {
            sumo_write_log('I07003X', array(sumo_get_accesspoint_name($name, $SUMO['config']['server']['language']), $node, $path, $SUMO['user']['user']), 3, 3, 'system', FALSE);
            $SUMO['DB']->CacheFlush();
            return TRUE;
        } else {
            return FALSE;
        }
    } else {
        return FALSE;
    }
}
Esempio n. 2
0
 */
// Create group string
if ($_POST['group']) {
    $_POST['group'] = sumo_get_normalized_group(implode(";", $_POST['group']), TRUE);
}
$_POST['path'] = sumo_get_normalized_accesspoint($_POST['path']);
// If new group exist add it
if ($_POST['newgroup']) {
    $_POST['group'] = sumo_get_normalized_group($_POST['newgroup'] . ";" . $_POST['group'], TRUE);
}
// If registration enabled require reg_group
$reg_group = $_POST['registration'] ? 1 : 0;
$data = array(array('node', $_POST['node'], 1), array('name', $_POST['name'], 1), array('path', $_POST['path'], 1), array('usergroup', $_POST['group'], 1), array('reg_group', $_POST['reg_group'], $reg_group), array('boolean', $_POST['http_auth'], 1), array('boolean', $_POST['filtering'], 1), array('boolean', $_POST['pwd_encrypt'], 1), array('boolean', $_POST['change_pwd'], 1), array('boolean', $_POST['registration'], 1), array('theme', $_POST['theme']));
$validate = sumo_validate_accesspoint_data($data, TRUE);
// verify if accesspoint already exist
if (sumo_verify_accesspoint_exist($_POST['node'], $_POST['path'])) {
    $validate = array(FALSE, sumo_get_message('I07002C', $_POST['path']));
}
if (!$validate[0]) {
    $tpl['MESSAGE:H'] = $language['AccessPointNotAdded'] . ": " . $validate[1];
} else {
    $update = sumo_add_accesspoint(array('name' => $_POST['name'], 'node' => $_POST['node'], 'path' => $_POST['path'], 'usergroup' => $_POST['group'], 'reg_group' => $_POST['reg_group'], 'http_auth' => $_POST['http_auth'], 'filtering' => $_POST['filtering'], 'pwd_encrypt' => $_POST['pwd_encrypt'], 'change_pwd' => $_POST['change_pwd'], 'registration' => $_POST['registration'], 'theme' => $_POST['theme']));
    if ($update) {
        $tpl['MESSAGE:L'] = $language['AccessPointAdded'];
        $tpl['GET:WindowScripts'] = "sumo_ajax_get('accesspoints.content','?module=accesspoints&action=list&decoration=false');";
    } else {
        $tpl['MESSAGE:H'] = $language['AccessPointNotAdded'];
    }
}
$_SESSION['action'] = 'new';
require "action.new.php";