示例#1
0
function get_current_nodeid($forse_all_nodes = null, $perm = null)
{
    global $USER_DETAILS, $ZBX_CURRENT_NODEID, $ZBX_AVAILABLE_NODES, $ZBX_VIEWED_NODES;
    if (!isset($ZBX_CURRENT_NODEID)) {
        init_nodes();
    }
    if (!is_null($perm)) {
        return get_accessible_nodes_by_user($USER_DETAILS, $perm, PERM_RES_IDS_ARRAY, $ZBX_AVAILABLE_NODES);
    } else {
        if (is_null($forse_all_nodes)) {
            if ($ZBX_VIEWED_NODES['selected'] == 0) {
                $result = $ZBX_VIEWED_NODES['nodeids'];
            } else {
                $result = $ZBX_VIEWED_NODES['selected'];
            }
            if (empty($result)) {
                $result = $USER_DETAILS['node']['nodeid'];
            }
        } else {
            if ($forse_all_nodes) {
                $result = $ZBX_AVAILABLE_NODES;
            } else {
                $result = $ZBX_CURRENT_NODEID;
            }
        }
    }
    return $result;
}
示例#2
0
if (!isset($page['type'])) {
    $page['type'] = PAGE_TYPE_HTML;
}
if (!isset($page['file'])) {
    $page['file'] = basename($_SERVER['PHP_SELF']);
}
if ($_REQUEST['fullscreen'] = get_request('fullscreen', 0)) {
    define('ZBX_PAGE_NO_MENU', 1);
}
include_once 'include/locales/en_gb.inc.php';
process_locales();
set_zbx_locales();
require_once 'include/menu.inc.php';
zbx_define_menu_restrictions();
/* Init CURRENT NODE ID */
init_nodes();
/* switch($page["type"]) */
switch ($page['type']) {
    case PAGE_TYPE_IMAGE:
        set_image_header();
        define('ZBX_PAGE_NO_MENU', 1);
        break;
    case PAGE_TYPE_XML:
        header('Content-Type: text/xml');
        header('Content-Disposition: attachment; filename="' . $page['file'] . '"');
        if (!defined('ZBX_PAGE_NO_MENU')) {
            define('ZBX_PAGE_NO_MENU', 1);
        }
        break;
    case PAGE_TYPE_JS:
        header('Content-Type: application/javascript; charset=UTF-8');
示例#3
0
 /**
  * Initializes the application.
  */
 public function run($mode = self::EXEC_MODE_DEFAULT)
 {
     $this->init();
     $this->setMaintenanceMode();
     $this->setErrorHandler();
     switch ($mode) {
         case self::EXEC_MODE_DEFAULT:
             $this->loadConfigFile();
             $this->initDB();
             $this->initNodes();
             $this->authenticateUser();
             // init nodes after user is authenticated
             init_nodes();
             $this->initLocales();
             break;
         case self::EXEC_MODE_API:
             $this->loadConfigFile();
             $this->initDB();
             $this->initNodes();
             $this->initLocales();
             break;
         case self::EXEC_MODE_SETUP:
             try {
                 // try to load config file, if it exists we need to init db and authenticate user to check permissions
                 $this->loadConfigFile();
                 $this->initDB();
                 $this->initNodes();
                 $this->authenticateUser();
                 // init nodes after user is authenticated
                 init_nodes();
                 $this->initLocales();
                 DBclose();
             } catch (ConfigFileException $e) {
             }
             break;
     }
 }
示例#4
0
function get_current_nodeid($forse_with_subnodes = null, $perm = null)
{
    global $USER_DETAILS, $ZBX_CURRENT_NODEID, $ZBX_CURRENT_SUBNODES, $ZBX_WITH_SUBNODES;
    if (!isset($ZBX_CURRENT_NODEID)) {
        init_nodes();
    }
    $result = is_show_subnodes($forse_with_subnodes) ? $ZBX_CURRENT_SUBNODES : $ZBX_CURRENT_NODEID;
    if (!is_null($perm)) {
        $result = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY, $ZBX_CURRENT_SUBNODES);
    }
    return $result;
}
示例#5
0
/**
 * Returns the ID of the currently selected node(s).
 *
 * Supported $forceAllNodes values:
 * - null 	- return the currently visible nodes;
 * - true 	- return all nodes that the user has read permissions to, including the master node;
 * - false	- return the currently selected node or the local node if all nodes are selected.
 *
 * @param bool 	$forceAllNodes	which nodes to return
 * @param int 	$permission		required node permissions
 *
 * @return array|int
 */
function get_current_nodeid($forceAllNodes = null, $permission = null)
{
    global $ZBX_CURRENT_NODEID, $ZBX_AVAILABLE_NODES, $ZBX_VIEWED_NODES;
    if (!ZBX_DISTRIBUTED) {
        return 0;
    }
    if (!isset($ZBX_CURRENT_NODEID)) {
        init_nodes();
    }
    if (!is_null($permission)) {
        return get_accessible_nodes_by_user(CWebUser::$data, $permission, PERM_RES_IDS_ARRAY, $ZBX_AVAILABLE_NODES);
    } elseif (is_null($forceAllNodes)) {
        $result = $ZBX_VIEWED_NODES['selected'] == 0 ? $ZBX_VIEWED_NODES['nodeids'] : $ZBX_VIEWED_NODES['selected'];
        if (empty($result)) {
            $result = CWebUser::$data['node']['nodeid'];
        }
        if (empty($result)) {
            $result = $ZBX_CURRENT_NODEID;
        }
    } elseif ($forceAllNodes) {
        $result = $ZBX_AVAILABLE_NODES;
    } else {
        $result = $ZBX_CURRENT_NODEID;
    }
    return $result;
}