Ejemplo n.º 1
0
function generate_graph_url($args)
{
    foreach ($args as $key => $arg) {
        if (is_array($arg)) {
            $arg = var_encode($arg);
        }
        // Encode arrays
        $urlargs[] = $key . "=" . $arg;
    }
    $url = 'graph.php?' . implode('&', $urlargs);
    if (is_cli()) {
        if ($GLOBALS['config']['web_url'] == 'http://localhost:80/') {
            // override default web_url by http://localhost/
            $url = 'http://' . get_localhost() . '/' . $url;
        } else {
            $url = $GLOBALS['config']['web_url'] . $url;
        }
    }
    return $url;
}
function generate_url($vars, $new_vars = array())
{
    $vars = $vars ? array_merge($vars, $new_vars) : $new_vars;
    $url = $vars['page'];
    if ($url[strlen($url) - 1] !== '/') {
        $url .= '/';
    }
    unset($vars['page']);
    foreach ($vars as $var => $value) {
        if ($var == "username" || $var == "password") {
            // Ignore these vars. They shouldn't end up in URLs.
        } else {
            if (is_array($value)) {
                $url .= urlencode($var) . '=' . var_encode($value) . '/';
            } else {
                if ($value == "0" || $value != "" && strstr($var, "opt") === FALSE && is_numeric($var) === FALSE) {
                    $url .= urlencode($var) . '=' . urlencode($value) . '/';
                }
            }
        }
    }
    // If we're being generated outside of the web interface, prefix the generated URL to make it work properly.
    if (is_cli()) {
        if ($GLOBALS['config']['web_url'] == 'http://localhost:80/') {
            // override default web_url by http://localhost/
            $url = 'http://' . get_localhost() . '/' . $url;
        } else {
            $url = $GLOBALS['config']['web_url'] . $url;
        }
    }
    return $url;
}
Ejemplo n.º 3
0
*/
// Disable nonexistant features in CE, do not try to turn on, it will not give effect
if (OBSERVIUM_EDITION == 'community') {
    $config['enable_billing'] = 0;
    $config['api']['enabled'] = 0;
    // Disabled (not exist) modules
    unset($config['poller_modules']['oids'], $config['poller_modules']['loadbalancer'], $config['poller_modules']['aruba-controller'], $config['poller_modules']['netscaler-vsvr']);
}
// Self hostname for observium server
// FIXME, used only in smokeping integration
if (!isset($config['own_hostname'])) {
    $config['own_hostname'] = get_localhost();
}
// Set web_url setting to default, add trailing slash if not present
if (!isset($config['web_url'])) {
    $config['web_url'] = isset($config['base_url']) ? $config['base_url'] : 'http://' . get_localhost();
}
if (substr($config['web_url'], -1) != '/') {
    $config['web_url'] .= '/';
}
if (!isset($config['base_url'])) {
    if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["SERVER_PORT"])) {
        if (strpos($_SERVER["SERVER_NAME"], ":")) {
            // Literal IPv6
            $config['base_url'] = "http://[" . $_SERVER["SERVER_NAME"] . "]" . ($_SERVER["SERVER_PORT"] != 80 ? ":" . $_SERVER["SERVER_PORT"] : '') . "/";
        } else {
            $config['base_url'] = "http://" . $_SERVER["SERVER_NAME"] . ($_SERVER["SERVER_PORT"] != 80 ? ":" . $_SERVER["SERVER_PORT"] : '') . "/";
        }
    }
    //} else {
    //  // Try to detect base_url in cli based on hostname
Ejemplo n.º 4
0
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage alerting
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
// Find local hostname
$localhost = get_localhost();
$emails = array();
$emails[$endpoint['email']] = $endpoint['contact_descr'];
// Mail backend params
$backend = strtolower(trim($config['email']['backend']));
switch ($backend) {
    case 'sendmail':
        $params['sendmail_path'] = $config['email']['sendmail_path'];
        break;
    case 'smtp':
        $params['host'] = $config['email']['smtp_host'];
        $params['port'] = $config['email']['smtp_port'];
        if ($config['email']['smtp_secure'] == 'ssl') {
            $params['host'] = 'ssl://' . $config['email']['smtp_host'];
            if ($config['email']['smtp_port'] == 25) {
                $params['port'] = 465;
                // Default port for SSL
            }
Ejemplo n.º 5
0
/**
 * Check username and password against RADIUS authentication backend.
 *
 * @param string $username User name to check
 * @param string $password User password to check
 * @return int Authentication success (0 = fail, 1 = success) FIXME bool
 */
function radius_authenticate($username, $password)
{
    global $config, $rad;
    radius_init();
    if ($username && $rad) {
        //print_vars(radius_server_secret($rad));
        radius_create_request($rad, RADIUS_ACCESS_REQUEST);
        radius_put_attr($rad, RADIUS_USER_NAME, $username);
        switch (strtolower($config['auth_radius_method'])) {
            // CHAP-MD5 see RFC1994
            case 'chap':
            case 'chap_md5':
                $chapid = 1;
                // Specify a CHAP identifier
                //$challenge = mt_rand(); // Generate a challenge
                //$cresponse = md5(pack('Ca*', $chapid, $password.$challenge), TRUE);
                new Crypt_CHAP();
                // Pre load class
                $crpt = new Crypt_CHAP_MD5();
                $crpt->password = $password;
                $challenge = $crpt->challenge;
                $resp_md5 = $crpt->challengeResponse();
                $resp = pack('C', $chapid) . $resp_md5;
                radius_put_attr($rad, RADIUS_CHAP_PASSWORD, $resp);
                // Add the Chap-Password attribute
                radius_put_attr($rad, RADIUS_CHAP_CHALLENGE, $challenge);
                // Add the Chap-Challenge attribute.
                break;
                // MS-CHAPv1 see RFC2433
            // MS-CHAPv1 see RFC2433
            case 'mschapv1':
                $chapid = 1;
                // Specify a CHAP identifier
                $flags = 1;
                // 0 = use LM-Response, 1 = use NT-Response (we not use old LM)
                new Crypt_CHAP();
                // Pre load class
                $crpt = new Crypt_CHAP_MSv1();
                $crpt->password = $password;
                $challenge = $crpt->challenge;
                $resp_lm = str_repeat("", 24);
                $resp_nt = $crpt->challengeResponse();
                $resp = pack('CC', $chapid, $flags) . $resp_lm . $resp_nt;
                radius_put_vendor_attr($rad, RADIUS_VENDOR_MICROSOFT, RADIUS_MICROSOFT_MS_CHAP_RESPONSE, $resp);
                radius_put_vendor_attr($rad, RADIUS_VENDOR_MICROSOFT, RADIUS_MICROSOFT_MS_CHAP_CHALLENGE, $challenge);
                break;
                // MS-CHAPv2 see RFC2759
            // MS-CHAPv2 see RFC2759
            case 'mschapv2':
                $chapid = 1;
                // Specify a CHAP identifier
                $flags = 1;
                // 0 = use LM-Response, 1 = use NT-Response (we not use old LM)
                new Crypt_CHAP();
                // Pre load class
                $crpt = new Crypt_CHAP_MSv2();
                $crpt->username = $username;
                $crpt->password = $password;
                $challenge = $crpt->authChallenge;
                $challenge_p = $crpt->peerChallenge;
                $resp_nt = $crpt->challengeResponse();
                // Response: chapid, flags (1 = use NT Response), Peer challenge, reserved, Response
                $resp = pack('CCa16a8a24', $chapid, $flags, $challenge_p, str_repeat("", 8), $resp_nt);
                radius_put_vendor_attr($rad, RADIUS_VENDOR_MICROSOFT, RADIUS_MICROSOFT_MS_CHAP2_RESPONSE, $resp);
                radius_put_vendor_attr($rad, RADIUS_VENDOR_MICROSOFT, RADIUS_MICROSOFT_MS_CHAP_CHALLENGE, $challenge);
                break;
                // PAP (Plaintext)
            // PAP (Plaintext)
            default:
                radius_put_attr($rad, RADIUS_USER_PASSWORD, $password);
        }
        // Puts standard attributes
        $radius_ip = get_ip_version($config['auth_radius_nas_address']) ? $config['auth_radius_nas_address'] : $_SERVER['SERVER_ADDR'];
        if (get_ip_version($radius_ip) == 6) {
            // FIXME, not sure that this work correctly
            radius_put_attr($rad, RADIUS_NAS_IPV6_ADDRESS, $radius_ip);
        } else {
            radius_put_addr($rad, RADIUS_NAS_IP_ADDRESS, $radius_ip);
        }
        $radius_id = empty($config['auth_radius_id']) ? get_localhost() : $config['auth_radius_id'];
        radius_put_attr($rad, RADIUS_NAS_IDENTIFIER, $radius_id);
        //radius_put_attr($rad, RADIUS_NAS_PORT_TYPE, RADIUS_VIRTUAL);
        //radius_put_attr($rad, RADIUS_SERVICE_TYPE, RADIUS_FRAMED);
        //radius_put_attr($rad, RADIUS_FRAMED_PROTOCOL, RADIUS_PPP);
        radius_put_attr($rad, RADIUS_CALLING_STATION_ID, isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1');
        $response = radius_send_request($rad);
        //print_vars($response);
        switch ($response) {
            case RADIUS_ACCESS_ACCEPT:
                // An Access-Accept response to an Access-Request indicating that the RADIUS server authenticated the user successfully.
                //echo 'Authentication successful';
                return 1;
                break;
            case RADIUS_ACCESS_REJECT:
                // An Access-Reject response to an Access-Request indicating that the RADIUS server could not authenticate the user.
                //echo 'Authentication failed';
                break;
            case RADIUS_ACCESS_CHALLENGE:
                // An Access-Challenge response to an Access-Request indicating that the RADIUS server requires further information
                // in another Access-Request before authenticating the user.
                //echo 'Challenge required';
                break;
            default:
                print_error('A RADIUS error has occurred: ' . radius_strerror($rad));
        }
    }
    //session_logout();
    return 0;
}