Ejemplo n.º 1
0
function trim_rec($data)
{
    if (is_array($data)) {
        foreach ($data as $k => $v) {
            if (is_array($data[$k])) {
                $data[$k] = trim_rec($data[$k]);
            } else {
                $data[$k] = trim($data[$k]);
            }
        }
        return $data;
    } else {
        return trim($data);
    }
}
Ejemplo n.º 2
0
            }
            $DB->Execute('UPDATE nodes SET access = (CASE access WHEN 1 THEN 0 ELSE 1 END)
			WHERE id = ? AND ownerid = 0', array($_GET['ip']));
        } else {
            $LMS->IPSetU($_GET['id'], $_GET['access']);
        }
        header('Location: ?' . $SESSION->get('backto'));
        break;
    case 'formaddip':
        $subtitle = trans('New IP address');
        $nodeipdata = $_POST['ipadd'];
        $nodeipdata['ownerid'] = 0;
        foreach ($nodeipdata['macs'] as $key => $value) {
            $nodeipdata['macs'][$key] = str_replace('-', ':', $value);
        }
        $nodeipdata = trim_rec($nodeipdata);
        if ($nodeipdata['ipaddr'] == '' && empty($nodeipdata['macs']) && $nodeipdata['name'] == '' && $nodeipdata['passwd'] == '') {
            $SESSION->redirect('?m=netdevedit&action=addip&id=' . $_GET['id']);
        }
        if ($nodeipdata['name'] == '') {
            $error['ipname'] = trans('Address field is required!');
        } elseif (strlen($nodeipdata['name']) > 32) {
            $error['ipname'] = trans('Specified name is too long (max. $a characters)!', '32');
        } elseif ($LMS->GetNodeIDByName($nodeipdata['name'])) {
            $error['ipname'] = trans('Specified name is in use!');
        } elseif (!preg_match('/^[_a-z0-9-]+$/i', $nodeipdata['name'])) {
            $error['ipname'] = trans('Name contains forbidden characters!');
        }
        if ($nodeipdata['ipaddr'] == '') {
            $error['ipaddr'] = trans('IP address is required!');
        } elseif (!check_ip($nodeipdata['ipaddr'])) {