| 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 | |
|---|
| 22 | class mynodes_ipaddr { |
|---|
| 23 | |
|---|
| 24 | var $tpl; |
|---|
| 25 | |
|---|
| 26 | function mynodes_ipaddr() { |
|---|
| 27 | |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | function form_ipaddr() { |
|---|
| 31 | global $db, $vars; |
|---|
| 32 | $form_ipaddr = new form(array('FORM_NAME' => 'form_ipaddr')); |
|---|
| 33 | $form_ipaddr->db_data('ip_addresses.hostname, ip_addresses.ip, ip_addresses.mac, ip_addresses.type, ip_addresses.always_on, ip_addresses.info'); |
|---|
| 34 | $form_ipaddr->db_data_values("ip_addresses", "id", get('ipaddr')); |
|---|
| 35 | if (get('ipaddr') != 'add') { |
|---|
| 36 | $form_ipaddr->data[1]['value'] = long2ip($form_ipaddr->data[1]['value']); |
|---|
| 37 | } |
|---|
| 38 | return $form_ipaddr; |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | function output() { |
|---|
| 42 | if ($_SERVER['REQUEST_METHOD'] == 'POST' && method_exists($this, 'output_onpost_'.$_POST['form_name'])) return call_user_func(array($this, 'output_onpost_'.$_POST['form_name'])); |
|---|
| 43 | global $construct; |
|---|
| 44 | $this->tpl['ip_address_method'] = (get('ipaddr') == 'add' ? 'add' : 'edit' ); |
|---|
| 45 | $this->tpl['form_ipaddr'] = $construct->form($this->form_ipaddr(), __FILE__); |
|---|
| 46 | return template($this->tpl, __FILE__); |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | function output_onpost_form_ipaddr() { |
|---|
| 50 | global $construct, $main, $db; |
|---|
| 51 | $form_ipaddr = $this->form_ipaddr(); |
|---|
| 52 | $ipaddr = get('ipaddr'); |
|---|
| 53 | $ret = TRUE; |
|---|
| 54 | $_POST['ip_addresses__ip'] = ip2long($_POST['ip_addresses__ip']); |
|---|
| 55 | $ret = $form_ipaddr->db_set(array('date_in' => date_now(), 'node_id' => get('node')), |
|---|
| 56 | "ip_addresses", "id", $ipaddr); |
|---|
| 57 | |
|---|
| 58 | if ($ret) { |
|---|
| 59 | $main->message->set_fromlang('info', 'insert_success', makelink("", TRUE)); |
|---|
| 60 | } else { |
|---|
| 61 | $main->message->set_fromlang('error', 'generic'); |
|---|
| 62 | } |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | ?> |
|---|