/** * SUMO MODULE: Accesspoints | Modify * * @version 0.5.0 * @link http://sumoam.sourceforge.net SUMO Access Manager * @author Alberto Basso <*****@*****.**> * @copyright Copyright © 2003-2009, Alberto Basso * @package SUMO * @category Console */ // 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('id', $_GET['id'], 1), 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'])); // Verify submittedd groups with current user group if ($validate[0]) { $submitted_group = sumo_get_grouplevel($_POST['group'], TRUE); $available_group = sumo_get_available_group(); for ($g = 0; $g < count($submitted_group); $g++) {
if ($tab['expire'] < $SUMO['server']['time'] + 500) { $color = 'orange'; } if ($tab['expire'] < $SUMO['server']['time'] + 300) { $color = 'red'; } $country = explode('-', $tab['country_name']); $country[0] = ucwords(strtolower($country[0])); $country[1] = strtolower($country[1]); $flag = trim($country[1]) ? trim($country[1]) . ".png" : "blank.png"; if (!$country[1]) { $country[1] = 'blank'; } $user = $search ? sumo_color_match_string($field['user'][1], $tab['username']) : $tab['username']; $username = sumo_get_username($tab['username']); $apinfo = sumo_get_accesspoint_info(sumo_get_normalized_accesspoint($tab['url']), 'path'); $apname = sumo_get_accesspoint_name($apinfo['name'], $_COOKIE['language']); $list .= "<tr>\n"; if ($col[1]) { $list .= " <td class='" . $style . "'><img src='themes/" . $SUMO['page']['theme'] . "/images/modules/sessions/status_" . $color . ".gif' class='session-status'> " . $tab['id'] . "</td>\n"; } if ($col[4]) { $list .= " <td class='" . $style . "'><a href='javascript:sumo_ajax_get(\"users\",\"?module=users&action=view&id=" . $tab['id_user'] . "\");" . "' title='" . $language['ViewUser'] . ": " . $username . "'>" . $user . "</a></td>\n"; } if ($col[2]) { $list .= " <td class='" . $style . "' align='right'><a href='javascript:sumo_ajax_get(\"network\",\"?module=network&action=view_node&id=" . $node[$tab['node']]['id'] . "\");'>" . $node[$tab['node']]['name'] . "</a></td>\n"; } //if($col[2]) $list .= " <td class='".$style."'><a href='javascript:sumo_ajax_get(\"network\",\"?module=network&action=nlist\");'>".$node[$tab['node']]['name']."</a></td>\n"; if ($col[7]) { $list .= " <td class='" . $style . "' align='right'>" . $tab['ip'] . "</td>\n"; }
/** * 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; } }