function table_ip_ranges() { global $construct, $db; $form_search_ranges = $this->form_search_ranges(); $where = $form_search_ranges->db_data_where(array('ip' => 'exclude')); $table_ip_ranges = new table(array('TABLE_NAME' => 'table_ip_ranges', 'FORM_NAME' => 'table_ip_ranges')); $s_ip = $form_search_ranges->data[0]['value']; $where = $where != '' ? "(" . $where . ") AND " : ""; if ($s_ip != '') { $where .= '(ip_ranges.ip_start >= ' . ip2long(correct_ip_min($s_ip, TRUE, 1)) . ' AND ip_ranges.ip_start <= ' . ip2long(correct_ip_max($s_ip, TRUE, 1)) . ") OR " . '(ip_ranges.ip_start >= ' . ip2long(correct_ip_min($s_ip, TRUE, 2)) . ' AND ip_ranges.ip_start <= ' . ip2long(correct_ip_max($s_ip, TRUE, 2)) . ") OR " . '(ip_ranges.ip_start >= ' . ip2long(correct_ip_min($s_ip, TRUE, 3)) . ' AND ip_ranges.ip_start <= ' . ip2long(correct_ip_max($s_ip, TRUE, 3)) . ") AND "; } //$where = // ($s_ip !=''?"ip_ranges.ip_start <= ".ip2long($s_ip)." AND ip_ranges.ip_end >= ".ip2long($s_ip)." AND ":""); if ($where != '') { $where = substr($where, 0, -5); } #@# $table_ip_ranges->db_data('"" AS ip_range, ip_ranges.ip_start, ip_ranges.ip_end, ip_ranges.date_in, ip_ranges.status, nodes.name AS nodes__name, nodes.id AS nodes__id, communities.name AS communities__name', 'ip_ranges LEFT JOIN nodes ON ip_ranges.node_id = nodes.id LEFT JOIN communities ON nodes.community_id = communities.id', $where != '' ? "(" . $where . ")" : "", "", "ip_ranges.status ASC, ip_ranges.ip_start ASC"); #@# foreach ((array) $table_ip_ranges->data as $key => $value) { if ($key != 0) { $table_ip_ranges->data[$key]['ip_start'] = long2ip($table_ip_ranges->data[$key]['ip_start']); $table_ip_ranges->data[$key]['ip_end'] = long2ip($table_ip_ranges->data[$key]['ip_end']); $table_ip_ranges->data[$key]['ip_range'] = $table_ip_ranges->data[$key]['ip_start'] . " - " . $table_ip_ranges->data[$key]['ip_end']; $table_ip_ranges->data[$key]['nodes__name'] .= " (#" . $table_ip_ranges->data[$key]['nodes__id'] . ")"; $table_ip_ranges->info['EDIT'][$key] = makelink(array("page" => "nodes", "node" => $table_ip_ranges->data[$key]['nodes__id'])); } } $table_ip_ranges->info['EDIT_COLUMN'] = 'nodes__name'; $table_ip_ranges->db_data_remove('ip_start', 'ip_end', 'nodes__id'); $table_ip_ranges->db_data_translate('ip_ranges__status'); return $table_ip_ranges; }
function output() { global $db, $vars; $q = get('q'); $i = 0; if (is_numeric($q) && strpos($q, ".") === FALSE) { $this->tpl['nodes_search'] = $db->get('nodes.id, nodes.name', 'nodes INNER JOIN users_nodes ON users_nodes.node_id = nodes.id INNER JOIN users ON users_nodes.user_id = users.id', 'users.status = "activated" AND nodes.id LIKE "' . replace_sql_wildcards($q) . '%"', 'nodes.id', 'nodes.id ASC', $this->limit); foreach ((array) $this->tpl['nodes_search'] as $key => $value) { $this->tpl['nodes_search'][$key]['href'] = makelink(array("page" => "nodes", "node" => $this->tpl['nodes_search'][$key]['id'])); } } elseif (is_ip($q, FALSE)) { $where = '(ip_ranges.ip_start >= ' . ip2long(correct_ip_min($q, TRUE, 1)) . ' AND ip_ranges.ip_start <= ' . ip2long(correct_ip_max($q, TRUE, 1)) . ") OR " . '(ip_ranges.ip_start >= ' . ip2long(correct_ip_min($q, TRUE, 2)) . ' AND ip_ranges.ip_start <= ' . ip2long(correct_ip_max($q, TRUE, 2)) . ") OR " . '(ip_ranges.ip_start >= ' . ip2long(correct_ip_min($q, TRUE, 3)) . ' AND ip_ranges.ip_start <= ' . ip2long(correct_ip_max($q, TRUE, 3)) . ")"; $this->tpl['ip_search'] = $db->get('ip_ranges.ip_start, nodes.id', 'ip_ranges LEFT JOIN nodes ON ip_ranges.node_id = nodes.id', $where, '', 'ip_ranges.status ASC, ip_ranges.ip_start ASC', $this->limit); foreach ((array) $this->tpl['ip_search'] as $key => $value) { $this->tpl['ip_search'][$key]['ip_start'] = long2ip($this->tpl['ip_search'][$key]['ip_start']); $this->tpl['ip_search'][$key]['href'] = makelink(array("page" => "nodes", "node" => $this->tpl['ip_search'][$key]['id'])); } } elseif (strpos($q, ".") !== FALSE && intval($q) == 0 || substr($q, -strlen("." . $vars['dns']['root_zone'])) == "." . $vars['dns']['root_zone']) { $this->tpl['dns_search'] = $db->get('dns_zones.name, dns_zones.type, nodes.id', 'dns_zones LEFT JOIN nodes ON dns_zones.node_id = nodes.id', 'dns_zones.name LIKE "' . replace_sql_wildcards(substr($q, 0, strrpos($q, "."))) . '"', '', 'dns_zones.status ASC, dns_zones.name ASC', $this->limit); foreach ((array) $this->tpl['dns_search'] as $key => $value) { if ($this->tpl['dns_search'][$key]['type'] == "forward") { $this->tpl['dns_search'][$key]['name'] .= "." . $vars['dns']['root_zone']; } $this->tpl['dns_search'][$key]['href'] = makelink(array("page" => "nodes", "node" => $this->tpl['dns_search'][$key]['id'])); } } else { $this->tpl['nodes_search'] = $db->get('nodes.id, nodes.name', 'nodes INNER JOIN users_nodes ON users_nodes.node_id = nodes.id INNER JOIN users ON users_nodes.user_id = users.id', 'users.status = "activated" AND nodes.name LIKE "' . replace_sql_wildcards($q) . '%"', 'nodes.id', 'nodes.name ASC', $this->limit); foreach ((array) $this->tpl['nodes_search'] as $key => $value) { $this->tpl['nodes_search'][$key]['href'] = makelink(array("page" => "nodes", "node" => $this->tpl['nodes_search'][$key]['id'])); } } echo template($this->tpl, __FILE__); exit; }