if (is_admin() === false) {
    die('ERROR: You need to be admin');
}
$rule = implode(" ", $_POST['rules']);
$rule = rtrim($rule, '&&');
$rule = rtrim($rule, '||');
$alert_id = $_POST['alert_id'];
$count = mres($_POST['count']);
$delay = mres($_POST['delay']);
$interval = mres($_POST['interval']);
$mute = mres($_POST['mute']);
$invert = mres($_POST['invert']);
$name = mres($_POST['name']);
if (empty($rule)) {
    $update_message = "ERROR: No rule was generated - did you forget to click and / or?";
} elseif (validate_device_id($_POST['device_id']) || $_POST['device_id'] == '-1' || $_POST['device_id'][0] == ':') {
    $device_id = $_POST['device_id'];
    if (!is_numeric($count)) {
        $count = '-1';
    }
    $delay_sec = convert_delay($delay);
    $interval_sec = convert_delay($interval);
    if ($mute == 'on') {
        $mute = true;
    } else {
        $mute = false;
    }
    if ($invert == 'on') {
        $invert = true;
    } else {
        $invert = false;
<?php

if (is_admin() === false) {
    die('ERROR: You need to be admin');
}
// FUA
$device['device_id'] = $_POST['device_id'];
$module = 'poll_' . $_POST['poller_module'];
if (!isset($module) && validate_device_id($device['device_id']) === false) {
    echo 'error with data';
    exit;
} else {
    if ($_POST['state'] == 'true') {
        $state = 1;
    } else {
        if ($_POST['state'] == 'false') {
            $state = 0;
        } else {
            $state = 0;
        }
    }
    if (isset($attribs['poll_' . $module]) && $attribs['poll_' . $module] != $config['poller_modules'][$module]) {
        del_dev_attrib($device, $module);
    } else {
        set_dev_attrib($device, $module, $state);
    }
}
Example #3
0
    include_once "{$librenms_base}/includes/definitions.inc.php";
    include_once "{$librenms_base}/includes/functions.php";
    include_once "{$librenms_base}/html/includes/functions.inc.php";
    require_once "{$librenms_base}/html/includes/authenticate.inc.php";
    if (empty($_SESSION['authenticated']) || !isset($_SESSION['authenticated'])) {
        header('Location: /');
    }
    chdir('plugins/Weathermap');
    $librenms_found = TRUE;
    /* Validate configuration, see defaults.inc.php for explaination */
    if (in_array($config['plugins']['Weathermap']['sort_if_by'], $valid_sort_if_by)) {
        $weathermap_config['sort_if_by'] = $config['plugins']['Weathermap']['sort_if_by'];
    }
    if (in_array($config['plugins']['Weathermap']['show_interfaces'], $valid_show_interfaces)) {
        $weathermap_config['show_interfaces'] = $valid_show_interfaces[$config['plugins']['Weathermap']['show_interfaces']];
    } elseif (validate_device_id($config['plugins']['Weathermap']['show_interfaces'])) {
        $weathermap_config['show_interfaces'] = $config['plugins']['Weathermap']['show_interfaces'];
    }
} else {
    $librenms_found = FALSE;
}
$link = mysqli_connect($config['db_host'], $config['db_user'], $config['db_pass'], $config['db_name']) or die('Could not connect: ' . mysqli_error($link));
// ******************************************
function js_escape($str)
{
    $str = str_replace('\\', '\\\\', $str);
    $str = str_replace("'", "\\\\'", $str);
    $str = "'" . $str . "'";
    return $str;
}
if (isset($_REQUEST['command']) && $_REQUEST["command"] == 'link_step2') {