/** * Delete node * * @return boolean * @author Alberto Basso <*****@*****.**> */ function sumo_delete_node($id = 0) { $id = intval($id); if ($id > 1) { global $SUMO; $node = sumo_get_node_info($id, 'id', FALSE); $SUMO['DB']->CacheFlush(); $query = "DELETE FROM " . SUMO_TABLE_NODES . " \n \t\t \t WHERE id=" . $id; $SUMO['DB']->Execute($query); $query = "SELECT COUNT(id) FROM " . SUMO_TABLE_NODES . " \n \t\t WHERE id=" . $id; // verify if deleted: $rs = $SUMO['DB']->Execute($query); $tab = $rs->FetchRow(); // if yes: if ($tab[0] == 0) { // Delete all accesspoints of deleted node $query1 = "DELETE FROM " . SUMO_TABLE_ACCESSPOINTS . " \n\t \t\t \t WHERE node=" . $id; $query2 = "DELETE FROM " . SUMO_TABLE_ACCESSPOINTS_STATS . " \n\t\t\t\t WHERE id_page=" . $id; $SUMO['DB']->Execute($query1); $SUMO['DB']->Execute($query2); sumo_write_log('W09000X', array($node['name'], $id, $SUMO['user']['user']), 3, 2, 'system', FALSE); return TRUE; } else { return FALSE; } } else { return FALSE; } }
<?php /** * SUMO MODULE: Network | Edit Node * * @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 */ $tab = sumo_get_node_info($_GET['id'], 'id', FALSE); $tpl['GET:UpdateForm'] = sumo_get_form_req('', 'modify_node', 'id=' . $tab['id']); $tpl['PUT:Protocol'] = sumo_put_node_protocol($tab['protocol']); $tpl['PUT:NodeName'] = "<input type='text' size='25' name='name' value='" . $tab['name'] . "'>"; $tpl['PUT:Host'] = "<input type='text' size='25' name='host' value='" . $tab['host'] . "'>"; $tpl['PUT:Port'] = "<input type='text' size='7' name='port' value='" . $tab['port'] . "'>"; $tpl['PUT:SumoPath'] = "<input type='text' size='25' name='sumo_path' value='" . $tab['sumo_path'] . "'>"; $tpl['BUTTON:Back'] = "<input type='button' class='button-red' value='" . $language["Back"] . "' onclick='javascript:sumo_ajax_get(\"network\",\"?module=network&action=view_node&id=" . $tab['id'] . "\");'>"; $tpl['LINK:Add'] = sumo_verify_permissions(4, 'sumo') ? sumo_get_action_icon("network", "add_node", "network.content", "?module=network&action=new_node&decoration=false") : sumo_get_action_icon("", "add_node"); $tpl['LINK:Edit'] = sumo_get_action_icon("", "edit_node"); // Change status if ($tab['active']) { $tpl['GET:Status'] = "<font class='status-green'>" . $language['Active'] . "</font>"; $tpl['PUT:Status'] = "<select name='status'>\n<option value='1'>" . $language['Enable'] . "</option>\n<option value='0'>" . $language['Disable'] . "</option>\n</select>"; } else { $tpl['GET:Status'] = "<font class='status-red'>" . $language['Disabled'] . "</font>"; $tpl['PUT:Status'] = "<select name='status'>\n<option value='0'>" . $language['Disable'] . "</option>\n<option value='1'>" . $language['Enable'] . "</option>\n</select>"; } // if it's current node
unset($tab); } $checked['http_auth'] = $tab['http_auth'] ? " checked='checked'" : ""; $checked['filtering'] = $tab['filtering'] ? " checked='checked'" : ""; $checked['pwd_encrypt'] = $tab['pwd_encrypt'] ? " checked='checked'" : ""; $checked['change_pwd'] = $tab['change_pwd'] ? " checked='checked'" : ""; $checked['registration'] = $tab['registration'] ? " checked='checked'" : ""; $checked['reg_group'] = $tab['registration'] ? true : false; // Delete if ($SUMO['user']['group_level']['sumo'] > 4 && (!sumo_verify_is_console($tab['path']) || $tab['id'] != 1)) { $msg = sumo_get_simple_rand_string(4, "123456789"); $delete = "<div class='sub-module-icon' " . "onmouseover='this.style.outline=\"1px solid #999999\";this.style.background=\"#FFFFFF\"' " . "onmouseout='this.style.outline=\"\";this.style.background=\"\"'>" . "<a href=\"javascript:" . "sumo_show_message('msg{$msg}', '" . htmlspecialchars(sumo_get_message('AreYouSureDelete', array($tab['path'], htmlspecialchars(sumo_get_accesspoint_name($tab['name'], $_COOKIE['language']), ENT_QUOTES)))) . "', \n\t\t\t\t\t\t'h', 0, \n\t\t\t\t\t\t'" . base64_encode(sumo_get_form_req('', 'delete', 'id=' . $tab['id'])) . "',\n\t\t\t\t\t\t'" . base64_encode('') . "',\n\t\t\t\t\t\t'" . base64_encode("<input type='button' value='" . $language['Cancel'] . "' onclick='javascript:sumo_remove_window(\"msg{$msg}\");' class='button'>") . "',\n\t\t\t\t\t\t'" . base64_encode("<input type='submit' value='" . $language['Ok'] . "' onclick='javascript:sumo_remove_window(\"msg{$msg}\");' class='button'>") . "'\n\t\t\t\t);\">" . "<img src='themes/" . $SUMO['page']['theme'] . "/images/modules/accesspoints/remove.png' vspace='4'><br>" . $language['Remove'] . "</a>" . "</div>"; } else { $delete = sumo_get_action_icon("", "remove"); } $node = sumo_get_node_info($tab['node']); $tpl['GET:ID'] = $tab['id']; $tpl['GET:RegGroup'] = $tab['reg_group']; $tpl['GET:Updated'] = sumo_get_human_date($tab['updated']); $tpl['GET:Created'] = sumo_get_human_date($tab['created']); $tpl['GET:Created'] = sumo_get_human_date($tab['created']); $tpl['GET:Node'] = $node['name']; $tpl['GET:Groups'] = implode(", ", $tab['usergroup']); $tpl['GET:RegGroup'] = $tab['reg_group']; $tpl['GET:Theme'] = ucfirst($tab['theme']); $tpl['GET:Name'] = sumo_get_accesspoint_name($tab['name'], $_COOKIE['language']); $tpl['GET:Filtering'] = "<input type='checkbox' name='filtering' " . $checked['filtering'] . " disabled />"; $tpl['GET:ChangePwd'] = "<input type='checkbox' name='change_pwd' " . $checked['change_pwd'] . " disabled />"; $tpl['GET:Registration'] = "<input type='checkbox' name='registration' " . $checked['registration'] . " disabled />"; $tpl['GET:Path'] = "<input type='text' size='50' name='path' value='" . $tab['path'] . "' disabled />"; $tpl['GET:HTTPAuth'] = "<input type='checkbox' name='http_auth' " . $checked['http_auth'] . " disabled />";
} if ($_SESSION['security'][$submodule]['col'][6]) { $excel->WriteText($row, $col, $language['Country']); $col++; } if ($_SESSION['security'][$submodule]['col'][7]) { $excel->WriteText($row, $col, $language['LogMessage']); $col++; } if ($_SESSION['security'][$submodule]['col'][8]) { $excel->WriteText($row, $col, $language['Date']); } while ($tab = $rs->FetchRow()) { $col = 0; $row++; $node = sumo_get_node_info($tab['node'], 'ip'); if ($_SESSION['security'][$submodule]['col'][3]) { $excel->WriteNumber($row, $col, $tab['id']); $col++; } if ($_SESSION['security'][$submodule]['col'][3]) { $excel->WriteNumber($row, $col, $tab['priority']); $col++; } if ($_SESSION['security'][$submodule]['col'][3]) { $excel->WriteText($row, $col, $tab['code']); $col++; } if ($_SESSION['security'][$submodule]['col'][4]) { $excel->WriteText($row, $col, $node['name']); $col++;
/** * Update accesspoint data */ function sumo_update_accesspoint_data($data = array()) { if (!empty($data)) { global $SUMO; $id = intval($data['id']); $node = $data['node'] ? intval($data['node']) : "NULL"; $path = $data['path']; $group = $data['group']; $reg_group = $data['reg_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; // 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); $filtering = sumo_verify_is_console($path) ? 1 : $filtering; /** * Kill all sessions at path where pwd_encrypt * or http_auth it has been changed */ $accesspoint = sumo_get_accesspoint_info($id, 'id', FALSE); $nodeinfo = sumo_get_node_info($node); if ($accesspoint['pwd_encrypt'] != $pwd_encrypt || $accesspoint['http_auth'] != $http_auth) { $query = "DELETE FROM " . SUMO_TABLE_SESSIONS . " \r\n\t\t\t\t\t WHERE node='" . $nodeinfo['ip'] . "' AND url LIKE '%" . $path . "'"; $SUMO['DB']->Execute($query); } // Delete cached data #if($path) $SUMO['DB']->CacheFlush("SELECT * FROM ".SUMO_TABLE_ACCESSPOINTS." # WHERE path='".$path."'"); if ($node >= 1) { $record['node'] = "node=" . $node; } if ($path) { $record['path'] = "path='" . $path . "'"; } if ($name) { $record['name'] = "name='" . $name . "'"; } if ($group) { $record['group'] = "usergroup='" . sumo_get_ordered_groups($group) . "'"; } if ($reg_group) { $record['reg_group'] = "reg_group='" . $reg_group . "'"; } if ($theme) { $record['theme'] = "theme='" . $theme . "'"; } $record['http_auth'] = "http_auth=" . $http_auth; $record['filtering'] = "filtering=" . $filtering; $record['pwd_encrypt'] = "pwd_encrypt=" . $pwd_encrypt; $record['change_pwd'] = "change_pwd=" . $change_pwd; $record['registration'] = "registration=" . $registration; $record['updated'] = "updated=" . $SUMO['server']['time']; // Create fields for query $new_record = array_values($record); for ($r = 0; $r < count($new_record); $r++) { if ($new_record[$r]) { $records[$r] = $new_record[$r]; } } $update = implode(', ', $records); $select = implode(' AND ', $records); // create query $query = "UPDATE " . SUMO_TABLE_ACCESSPOINTS . " \r\n\t\t\t\t SET " . $update . " \r\n\t\t\t\t WHERE id=" . $id; $SUMO['DB']->CacheFlush(); $SUMO['DB']->Execute($query); // verify query success $query = "SELECT COUNT(id) FROM " . SUMO_TABLE_ACCESSPOINTS . " \r\n\t\t\t\t WHERE id=" . $id . " \r\n\t\t\t\t AND " . $select; $rs = $SUMO['DB']->Execute($query); $tab = $rs->FetchRow(); // if updated: if ($tab[0] == 1) { if ($nodeinfo['ip'] == '') { $nodeinfo['ip'] = 'UNDEFINED'; } $apname = sumo_get_accesspoint_name($name, $SUMO['config']['server']['language']); sumo_write_log('I07000X', array($id, $apname, $nodeinfo['ip'], $SUMO['user']['user']), 3, 3, 'system', FALSE); return TRUE; } else { return FALSE; } } }
// Create sql query to select only groups of user $group_query = sumo_get_group_query($search); $operand = $search || $group_query ? ' AND ' : ' WHERE '; $query1 = "SELECT b.node AS node, b.id_page AS id_page, a.name AS name, a.path AS path, b.access AS access, \n\t\t\t\t b.activity AS activity, b.last_login AS last_login, b.updated AS updated\n\t\t FROM " . SUMO_TABLE_ACCESSPOINTS . " a, " . SUMO_TABLE_ACCESSPOINTS_STATS . " b \n\t\t " . $search . $group_query . $operand . "\n\t\t a.id = b.id_page"; $query2 = $query1 . " ORDER BY " . $_SESSION['accesspoints']['stats']['col_sql'] . " " . $_SESSION['accesspoints']['stats']['mode_sql']; $rs = $SUMO['DB']->CacheExecute(15, $query1); $tot = $rs->PO_RecordCount(); $SUMO['DB']->cacheSecs = 15; $rs = $SUMO['DB']->CacheSelectLimit($query2, $_SESSION['rows_accesspoints_stats'], $_SESSION['start_accesspoints_stats']); $vis = $rs->PO_RecordCount(); /** * Create list */ if ($tot > 0) { // Get nodes info $node = sumo_get_node_info(); $list = sumo_get_table_header($table['data']['stats']); while ($tab = $rs->FetchRow()) { $query2 = "SELECT MAX(access) FROM " . SUMO_TABLE_ACCESSPOINTS_STATS; $query3 = "SELECT MAX(activity) FROM " . SUMO_TABLE_ACCESSPOINTS_STATS; $style = sumo_alternate_str('tab-row-on', 'tab-row-off'); $rs2 = $SUMO['DB']->CacheExecute(15, $query2); $rs3 = $SUMO['DB']->CacheExecute(15, $query3); $max2 = $rs2->FetchRow(); $max3 = $rs3->FetchRow(); $path2 = $tab['path']; $path3 = sumo_get_accesspoint_name($tab['name'], $_COOKIE['language']); $max_access = $max2[0]; $max_activity = $max3[0]; if ($search) { $path2 = sumo_color_match_string($field['path'][1], $tab['path']);
// Create search query $search = ''; if ($_SESSION['search_network_dlist']) { $field['name'] = sumo_search_composer($_SESSION['search_network_dlist'], 'name'); $search = $field['name'][0] ? " WHERE " . $field['name'][0] . " " : ''; } $query1 = "SELECT * FROM " . SUMO_TABLE_DATASOURCES . " " . $search; $query2 = $query1 . " ORDER BY " . $_SESSION['network']['dlist']['col_sql'] . " " . $_SESSION['network']['dlist']['mode_sql']; $rs = $SUMO['DB']->Execute($query1); $tot = $rs->PO_RecordCount(); $rs = $SUMO['DB']->SelectLimit($query2, $_SESSION['rows_network_dlist'], $_SESSION['start_network_dlist']); $vis = $rs->PO_RecordCount(); /** * Create list */ $node = sumo_get_node_info(1, 'id', FALSE); // to testing DS connection $list = sumo_get_table_header($table['data']['dlist']); $col = $_SESSION['network']['dlist']['col']; while ($tab = $rs->FetchRow()) { $style = sumo_alternate_str('tab-row-on', 'tab-row-off'); if ($search) { $tab['name'] = sumo_color_match_string($field['name'][1], $tab['name']); } if ($tab['password']) { $tab['password'] = '******'; } $name = "<a href='javascript:sumo_ajax_get(\"network\",\"?module=network&action=view_datasource&id=" . $tab['id'] . "\");' title='" . $language['View'] . "'>" . $tab['name'] . "</a>"; // Check Datasource if ($tab['type'] != 'SUMO' && $_GET['test']) { $url = parse_url($node['protocol'] . "://" . $node['host'] . ":" . $node['port'] . $node['sumo_path'] . "services.php");