root/trunk/includes/pages/hostmaster/hostmaster_ranges.php @ 1

Revision 1, 3.7 kB (checked in by Winner, 5 years ago)

Initial import

Line 
1<?php
2/*
3 * WiND - Wireless Nodes Database
4 *
5 * Copyright (C) 2005 Nikolaos Nikalexis <winner@cube.gr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 dated June, 1991.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19 *
20 */
21
22class hostmaster_ranges {
23
24        var $tpl;
25       
26        function hostmaster_ranges() {
27               
28        }
29       
30        function form_search_ranges() {
31                global $construct, $db;
32                $form_search_ranges = new form(array('FORM_NAME' => 'form_search_ranges'));
33                $form_search_ranges->data = array("0" => array("Field" => "ip", "fullField" => "ip"));
34                $form_search_ranges->db_data('ip_ranges.status, ip_ranges.delete_req');
35                $form_search_ranges->db_data_search();
36                return $form_search_ranges;
37        }
38
39        function table_ip_ranges() {
40                global $construct, $db;
41                $form_search_ranges = $this->form_search_ranges();
42                $where = $form_search_ranges->db_data_where(array('ip' => 'exclude'));
43                $table_ip_ranges = new table(array('TABLE_NAME' => 'table_ip_ranges', 'FORM_NAME' => 'table_ip_ranges'));
44                $s_ip = correct_ip($form_search_ranges->data[0]['value']);
45                $where = ($where !=''?"(".$where.") AND ":"").
46                                ($s_ip !=''?"ip_ranges.ip_start <= ".ip2long($s_ip)." AND ip_ranges.ip_end >= ".ip2long($s_ip)." AND ":"");
47                if ($where!='') $where = substr($where, 0, -5);
48                $table_ip_ranges->db_data(
49                        'ip_ranges.id, "" AS ip_range, ip_ranges.ip_start, ip_ranges.ip_end, ip_ranges.date_in, ip_ranges.status, ip_ranges.delete_req',
50                        'ip_ranges',
51                        $where);
52                foreach( (array) $table_ip_ranges->data as $key => $value) {
53                        if ($key != 0) {
54                                $table_ip_ranges->data[$key]['ip_start'] = long2ip($table_ip_ranges->data[$key]['ip_start']);
55                                $table_ip_ranges->data[$key]['ip_end'] = long2ip($table_ip_ranges->data[$key]['ip_end']);
56                                $table_ip_ranges->data[$key]['ip_range'] = $table_ip_ranges->data[$key]['ip_start']." - ".$table_ip_ranges->data[$key]['ip_end'];
57                        }
58                }
59                $table_ip_ranges->db_data_multichoice('ip_ranges', 'id');
60                for($i=1;$i<count($table_ip_ranges->data);$i++) {
61                        if (isset($table_ip_ranges->data[$i])) {
62                                $table_ip_ranges->info['EDIT'][$i] = makelink(array("page" => "hostmaster", "subpage" => "range", "iprange" => $table_ip_ranges->data[$i]['id']));
63                        }
64                }
65                $table_ip_ranges->info['EDIT_COLUMN'] = 'ip_range';
66                $table_ip_ranges->info['MULTICHOICE_LABEL'] = 'delete';
67                $table_ip_ranges->db_data_remove('id', 'ip_start', 'ip_end');
68                $table_ip_ranges->db_data_translate('ip_ranges__status', 'ip_ranges__delete_req');
69                return $table_ip_ranges;
70        }
71
72        function output() {
73                if ($_SERVER['REQUEST_METHOD'] == 'POST' && method_exists($this, 'output_onpost_'.$_POST['form_name'])) return call_user_func(array($this, 'output_onpost_'.$_POST['form_name']));
74                global $construct;
75                $this->tpl['form_search_ranges'] = $construct->form($this->form_search_ranges(), __FILE__);
76                $this->tpl['table_ranges'] = $construct->table($this->table_ip_ranges(), __FILE__);
77                return template($this->tpl, __FILE__);
78        }
79
80        function output_onpost_table_ip_ranges() {
81                global $db, $main;
82                $ret = TRUE;
83                foreach( (array) $_POST['id'] as $key => $value) {
84                        $ret = $ret && $db->del("ip_ranges", "id = '".$value."'");
85                }
86                if ($ret) {
87                        $main->message->set_fromlang('info', 'delete_success', makelink("",TRUE));
88                } else {
89                        $main->message->set_fromlang('error', 'generic');               
90                }
91        }
92
93}
94
95?>
Note: See TracBrowser for help on using the browser.