public static function getInstance($source_name)
 {
     if (empty(self::$source_map[$source_name])) {
         require_once 'include/connectors/sources/SourceFactory.php';
         require_once 'include/connectors/component.php';
         $source = SourceFactory::getSource($source_name);
         $component = new component();
         $component->setSource($source);
         $component->init();
         self::$source_map[$source_name] = $component;
     }
     return self::$source_map[$source_name];
 }
	function prepare()
	{
		$params = array();
		$params['id'] = $this->get('node_id');
		$params['action'] = 'order';
		$params['rn'] = time();
		$params['popup'] = 1;
		
		$this->set('order_up_alt', strings :: get('order_up'));
		$this->set('order_down_alt', strings :: get('order_down'));
		
		if (!$this->get('is_first_child'))
		{
			$params['direction'] = 'up';
			$this->set('order_up_href', add_url_query_items($_SERVER['PHP_SELF'], $params));
		}	
		else
			$this->set('order_up_href', '');

		if (!$this->get('is_last_child'))
		{
			$params['direction'] = 'down';
			$this->set('order_down_href', add_url_query_items($_SERVER['PHP_SELF'], $params));
		}	
		else
			$this->set('order_down_href', '');
		
		return parent :: prepare();	
	} 
Exemple #3
0
 /**
  * Constructor
  *
  */
 function __construct($nickname)
 {
     // Declare objects
     $this->openid = new openid();
     $this->r = new userRenderer($this->module);
     // Renderer
     suxValidate::register_object('this', $this);
     // Register self to validator
     parent::__construct();
     // Let the parent do the rest
     // Redirect if not logged in
     if (empty($_SESSION['users_id'])) {
         suxFunct::redirect(suxFunct::makeUrl('/user/register'));
     }
     // Security check. Is the user allowed to edit this?
     $tmp = $this->user->getByNickname($nickname, true);
     if (!$tmp) {
         suxFunct::redirect(suxFunct::getPreviousURL());
     } elseif ($tmp['users_id'] != $_SESSION['users_id']) {
         // Check that the user is allowed to be here
         if (!$this->user->isRoot()) {
             suxFunct::redirect(suxFunct::getPreviousURL());
         }
     }
     // Declare properties
     $this->nickname = $nickname;
     $this->users_id = $tmp['users_id'];
 }
Exemple #4
0
 /**
  * Constructor
  *
  */
 function __construct()
 {
     // Declare objects
     $this->photo = new suxPhoto();
     // Photos
     $this->r = new photosRenderer($this->module);
     // Renderer
     suxValidate::register_object('this', $this);
     // Register self to validator
     parent::__construct();
     // Let the parent do the rest
     // Declare Properties
     $this->photo->setPublished(null);
     // Redirect if not logged in
     if (empty($_SESSION['users_id'])) {
         suxFunct::redirect(suxFunct::makeUrl('/user/register'));
     }
     // Security check
     if (!$this->user->isRoot()) {
         $access = $this->user->getAccess($this->module);
         if ($access < $GLOBALS['CONFIG']['ACCESS'][$this->module]['admin']) {
             suxFunct::redirect(suxFunct::makeUrl('/home'));
         }
     }
 }
Exemple #5
0
 /**
  * Constructor
  *
  * @param string $nickname
  */
 function __construct($nickname)
 {
     // Declare objects
     $this->soc = new suxSocialNetwork();
     // User
     $this->r = new societyRenderer($this->module);
     // Renderer
     suxValidate::register_object('this', $this);
     // Register self to validator
     parent::__construct();
     // Let the parent do the rest
     // Redirect if not logged in
     if (empty($_SESSION['users_id'])) {
         suxFunct::redirect(suxFunct::makeUrl('/user/register'));
     }
     $tmp = $this->user->getByNickname($nickname);
     if (!$tmp) {
         suxFunct::redirect(suxFunct::getPreviousURL());
     }
     // Invalid user
     // Don't let the user establish a relationship with themselves
     if ($tmp['users_id'] == $_SESSION['users_id']) {
         suxFunct::redirect(suxFunct::getPreviousURL());
     }
     // Declare properties
     $this->nickname = $nickname;
     $this->users_id = $tmp['users_id'];
 }
Exemple #6
0
 /**
  * Constructor
  *
  * @param int $id album id
  */
 function __construct($id)
 {
     if (!filter_var($id, FILTER_VALIDATE_INT) || $id < 1) {
         suxFunct::redirect(suxFunct::makeURL('/photos'));
     }
     // Invalid id
     // Declare objects
     $this->photo = new suxPhoto();
     // Photos
     $this->r = new photosRenderer($this->module);
     // Renderer
     suxValidate::register_object('this', $this);
     // Register self to validator
     parent::__construct();
     // Let the parent do the rest
     // Declare properties
     $this->photo->setPublished(null);
     $this->id = $id;
     $this->per_page = $this->tpl->getConfigVars('perPage');
     // Redirect if not logged in
     if (empty($_SESSION['users_id'])) {
         suxFunct::redirect(suxFunct::makeUrl('/user/register'));
     }
     // Security check
     if (!$this->user->isRoot()) {
         $access = $this->user->getAccess($this->module);
         if ($access < $GLOBALS['CONFIG']['ACCESS'][$this->module]['admin']) {
             if ($access < $GLOBALS['CONFIG']['ACCESS'][$this->module]['publisher']) {
                 suxFunct::redirect(suxFunct::makeURL('/photos'));
             } elseif (!$this->photo->isAlbumOwner($id, $_SESSION['users_id'])) {
                 suxFunct::redirect(suxFunct::makeURL('/photos'));
             }
         }
     }
 }
Exemple #7
0
 /**
  * Constructor
  *
  */
 function __construct($nickname)
 {
     // Declare objects
     $this->r = new adminRenderer($this->module);
     // Renderer
     suxValidate::register_object('this', $this);
     // Register self to validator
     parent::__construct();
     // Let the parent do the rest
     // Redirect if not logged in
     if (empty($_SESSION['users_id'])) {
         suxFunct::redirect(suxFunct::makeUrl('/user/register'));
     }
     // Security check
     if (!$this->user->isRoot()) {
         suxFunct::redirect(suxFunct::makeUrl('/home'));
     }
     $tmp = $this->user->getByNickname($nickname);
     if (!$tmp) {
         suxFunct::redirect(suxFunct::getPreviousURL());
     }
     // Invalid user
     // Declare properties
     $this->nickname = $nickname;
     $this->users_id = $tmp['users_id'];
     $this->root = $tmp['root'];
     $this->banned = $tmp['banned'];
 }
Exemple #8
0
 /**
  * Constructor
  *
  */
 function __construct()
 {
     $this->r = new suxRenderer($this->module);
     // Renderer
     parent::__construct();
     // Let the parent do the rest
 }
Exemple #9
0
 /**
  * Extends abstract method
  */
 protected function init()
 {
     parent::init();
     $this->config_path = APP_CONTENT_ROOT_DIR;
     $this->config_path .= rtrim($this->request->dirname, '/');
     $this->config_path .= '/' . $this->request->filename . '.php';
     $this->set_array($this->get_defaults());
 }
 public static function getInstance($source_name)
 {
     if (empty(self::$source_map[$source_name])) {
         require_once 'include/connectors/sources/SourceFactory.php';
         require_once 'include/connectors/component.php';
         $source = SourceFactory::getSource($source_name);
         if (empty($source)) {
             $GLOBALS['log']->fatal("Failed to load source {$source_name}");
             return false;
         }
         $component = new component();
         $component->setSource($source);
         $component->init();
         self::$source_map[$source_name] = $component;
     }
     return self::$source_map[$source_name];
 }
Exemple #11
0
 /**
  * Constructor
  *
  */
 function __construct()
 {
     // Declare objects
     $this->r = new globalsRenderer($this->module);
     // Renderer
     parent::__construct();
     // Let the parent do the rest
 }
 /**
  * Constructor
  */
 function __construct()
 {
     // Pre-condition sanity check
     if (!$this->nb instanceof suxUserNaiveBayesian) {
         throw new Exception('$this->nb is not an instance of suxUserNaiveBayesian()');
     }
     parent::__construct();
     // Let the parent do the rest
 }
Exemple #13
0
 /**
  * Constructor
  *
  */
 function __construct()
 {
     // Declare objects
     $this->r = new cropperRenderer($this->module);
     // Renderer
     suxValidate::register_object('this', $this);
     // Register self to validator
     parent::__construct();
     // Let the parent do the rest
 }
Exemple #14
0
 /**
  * Constructor
  *
  */
 function __construct()
 {
     // Declare objects
     $this->r = new homeRenderer($this->module);
     // Renderer
     parent::__construct();
     // Let the parent do the rest
     // Declare properties
     $this->r->bool['analytics'] = true;
     // Turn on analytics
 }
Exemple #15
0
 /**
  * Constructor
  *
  */
 function __construct()
 {
     // Declare objects
     $this->photo = new suxPhoto();
     // Photos
     $this->r = new photosRenderer($this->module);
     // Renderer
     parent::__construct();
     // Let the parent do the rest
     // Declare properties
     $this->r->bool['analytics'] = true;
     // Turn on analytics
     $this->per_page = $this->tpl->getConfigVars('perPage');
 }
Exemple #16
0
 /**
  * Constructor
  *
  * @param int $id item id
  */
 function __construct($id = null)
 {
     // Declare objects
     ### add objects here
     $this->r = new blogRenderer($this->module);
     // Renderer
     suxValidate::register_object('this', $this);
     // Register self to validator
     parent::__construct();
     // Let the parent do the rest
     ### do sanity and security checks here
     // Assign id:
     $this->id = $id;
 }
Exemple #17
0
 /**
  * Constructor
  *
  */
 function __construct()
 {
     // Declare objects
     $this->rss = new suxRSS();
     $this->r = new suxRenderer($this->module);
     // Renderer
     suxValidate::register_object('this', $this);
     // Register self to validator
     parent::__construct();
     // Let the parent do the rest
     // Redirect if not logged in
     if (empty($_SESSION['users_id'])) {
         suxFunct::redirect(suxFunct::makeUrl('/user/register'));
     }
 }
Exemple #18
0
 /**
  * Constructor
  *
  */
 function __construct()
 {
     // Declare objects
     $this->r = new adminRenderer($this->module);
     // Renderer
     parent::__construct();
     // Let the parent do the rest
     // Redirect if not logged in
     if (empty($_SESSION['users_id'])) {
         suxFunct::redirect(suxFunct::makeUrl('/user/register'));
     }
     // Security check
     if (!$this->user->isRoot()) {
         suxFunct::redirect(suxFunct::makeUrl('/home'));
     }
 }
Exemple #19
0
 /**
  * Constructor
  *
  */
 function __construct()
 {
     // Declare objects
     $this->r = new userRenderer($this->module);
     // Renderer
     suxValidate::register_object('this', $this);
     // Register self to validator
     parent::__construct();
     // Let the parent do the rest
     // This module can fallback on user/openid module
     foreach ($GLOBALS['CONFIG']['PREV_SKIP'] as $val) {
         if (mb_strpos($val, 'user/openid') === false) {
             $this->prev_skip[] = $val;
         }
     }
 }
Exemple #20
0
 /**
  * Constructor
  *
  * @param string $nickname nickname
  */
 function __construct($nickname)
 {
     // Declare objects
     $this->r = new userRenderer($this->module);
     // Renderer
     parent::__construct();
     // Let the parent do the rest
     // Declare properties
     $this->r->bool['analytics'] = true;
     // Turn on analytics
     $this->profile = $this->user->getByNickname($nickname, true);
     unset($this->profile['password']);
     // We don't need this
     if (!$this->profile) {
         suxFunct::redirect(suxFunct::getPreviousURL());
     }
     // Redirect for invalid profiles
 }
Exemple #21
0
 /**
  * Constructor
  *
  */
 function __construct()
 {
     // Declare objects
     $this->nb = new suxUserNaiveBayesian();
     $this->r = new bayesRenderer($this->module);
     // Renderer
     suxValidate::register_object('this', $this);
     // Register self to validator
     parent::__construct();
     // Let the parent do the rest
     // If feature is turned off, then redirect
     if ($GLOBALS['CONFIG']['FEATURE']['bayes'] == false) {
         suxFunct::redirect(suxFunct::getPreviousURL());
     }
     // Redirect if not logged in
     if (empty($_SESSION['users_id'])) {
         suxFunct::redirect(suxFunct::makeUrl('/user/register'));
     }
 }
Exemple #22
0
 /**
  * Constructor
  *
  * @param int $id message id
  */
 function __construct($id = null)
 {
     // Declare objects
     $this->nb = new suxUserNaiveBayesian();
     $this->msg = new suxThreadedMessages();
     $this->r = new blogRenderer($this->module);
     // Renderer
     suxValidate::register_object('this', $this);
     // Register self to validator
     parent::__construct();
     // Let the parent do the rest
     // Declare properties
     $this->msg->setPublished(null);
     if ($id) {
         if (!filter_var($id, FILTER_VALIDATE_INT) || $id < 1) {
             suxFunct::redirect(suxFunct::makeURL('/blog'));
         }
         // Invalid id
     }
     // Redirect if not logged in
     if (empty($_SESSION['users_id'])) {
         suxFunct::redirect(suxFunct::makeUrl('/user/register'));
     }
     // Security check
     if (!$this->user->isRoot()) {
         $access = $this->user->getAccess($this->module);
         if ($access < $GLOBALS['CONFIG']['ACCESS'][$this->module]['admin']) {
             if ($access < $GLOBALS['CONFIG']['ACCESS'][$this->module]['publisher']) {
                 suxFunct::redirect(suxFunct::makeUrl('/blog'));
             }
             // Verfiy that we are allowed to edit this
             if (filter_var($id, FILTER_VALIDATE_INT)) {
                 $tmp = $this->msg->getByID($id);
                 if ($tmp['users_id'] != $_SESSION['users_id']) {
                     suxFunct::redirect(suxFunct::makeUrl('/blog'));
                 }
             }
         }
     }
     // Assign id:
     $this->id = $id;
 }
Exemple #23
0
 /**
  * Constructor
  *
  * @param int $parent_id
  */
 function __construct($parent_id)
 {
     // Declare objects
     $this->msg = new suxThreadedMessages();
     $this->r = new blogRenderer($this->module);
     // Renderer
     suxValidate::register_object('this', $this);
     // Register self to validator
     parent::__construct();
     // Let the parent do the rest
     // Redirect if not logged in
     if (empty($_SESSION['users_id'])) {
         suxFunct::redirect(suxFunct::makeUrl('/user/register'));
     }
     $parent = $this->msg->getByID($parent_id);
     if (!$parent) {
         suxFunct::redirect(suxFunct::getPreviousURL());
     }
     // Invalid message, redirect
     $this->parent = $parent;
 }
Exemple #24
0
 /**
  * Constructor
  *
  * @param int $id message id
  */
 function __construct($id = null)
 {
     // Declare objects
     $this->bm = new suxBookmarks();
     $this->r = new bookmarksRenderer($this->module);
     // Renderer
     suxValidate::register_object('this', $this);
     // Register self to validator
     parent::__construct();
     // Let the parent do the rest
     // Declare properties
     $this->bm->setPublished(null);
     if ($id) {
         if (!filter_var($id, FILTER_VALIDATE_INT) || $id < 1) {
             suxFunct::redirect(suxFunct::makeURL('/bookmarks'));
         }
         // Invalid id
     }
     // Redirect if not logged in
     if (empty($_SESSION['users_id'])) {
         suxFunct::redirect(suxFunct::makeUrl('/user/register'));
     }
     // Check that the user is allowed to be here
     if (!$this->user->isRoot()) {
         $access = $this->user->getAccess($this->module);
         if ($access < $GLOBALS['CONFIG']['ACCESS'][$this->module]['admin']) {
             suxFunct::redirect(suxFunct::makeUrl('/bookmarks'));
         }
     }
     // This module can fallback on approve module
     foreach ($GLOBALS['CONFIG']['PREV_SKIP'] as $val) {
         if (mb_strpos($val, 'bookmarks/approve') === false) {
             $this->prev_skip[] = $val;
         }
     }
     // Assign id:
     $this->id = $id;
 }
Exemple #25
0
 /**
  * Constructor
  *
  * @param string nickname
  */
 function __construct($nickname = null)
 {
     // Declare objects
     $this->r = new adminRenderer($this->module);
     // Renderer
     parent::__construct();
     // Let the parent do the rest
     // Redirect if not logged in
     if (empty($_SESSION['users_id'])) {
         suxFunct::redirect(suxFunct::makeUrl('/user/register'));
     }
     // Security check
     if (!$this->user->isRoot()) {
         suxFunct::redirect(suxFunct::makeUrl('/home'));
     }
     // Declare properties
     $this->log->setPublished(null);
     $tmp = $this->user->getByNickname($nickname);
     if ($tmp) {
         $this->users_id = $tmp['users_id'];
         $this->nickname = $tmp['nickname'];
     }
 }
Exemple #26
0
 /**
  * Constructor
  *
  */
 function __construct($mode = 'register', $user = null)
 {
     // Declare objects
     $this->r = new userRenderer($this->module);
     // Renderer
     suxValidate::register_object('this', $this);
     // Register self to validator
     parent::__construct();
     // Let the parent do the rest
     // Give a unique form name
     $form_name = 'userEdit';
     $this->tpl->assign('form_name', $form_name);
     suxValidate::set_form($form_name);
     // -------------------------------------------------------------------
     // Edit mode
     // -------------------------------------------------------------------
     if ($mode == 'edit') {
         // Redirect if invalid
         if ($this->user->loginCheck(suxfunct::makeUrl('/user/register'))) {
             $this->mode = 'edit';
         }
         if ($user != $_SESSION['nickname']) {
             // Security check
             // Only a root user can modify other users
             if (!$this->user->isRoot()) {
                 suxFunct::redirect(suxFunct::makeUrl('/home'));
             }
         }
         // Get user
         $u = $this->user->getByNickname($user);
         if (!$u) {
             suxFunct::redirect(suxFunct::getPreviousURL());
         }
         // Invalid user
         $this->users_id = $u['users_id'];
     }
 }
<?php

/*
 * LibreNMS module to display Cisco Class-Based QoS Details
 *
 * Copyright (c) 2015 Aaron Daniels <*****@*****.**>
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.  Please see LICENSE.txt at the top level of
 * the source code distribution for details.
 */
require_once "../includes/component.php";
$component = new component();
$options['filter']['type'] = array('=', 'Cisco-CBQOS');
$components = $component->getComponents($device['device_id'], $options);
// We only care about our device id.
$components = $components[$device['device_id']];
// Determine a policy to show.
if (!isset($vars['policy'])) {
    foreach ($components as $id => $array) {
        if ($array['qos-type'] == 1 && $array['ifindex'] == $port['ifIndex'] && $array['parent'] == 0) {
            // Found the first policy
            $vars['policy'] = $id;
            continue;
        }
    }
}
include "includes/graphs/common.inc.php";
$rrd_options .= " -l 0 -E ";
Exemple #28
0
function delete_components()
{
    global $config;
    $app = \Slim\Slim::getInstance();
    $router = $app->router()->getCurrentRoute()->getParams();
    $cid = $router['component'];
    $COMPONENT = new component();
    if ($COMPONENT->deleteComponent($cid)) {
        // Edit Success.
        $code = 200;
        $status = 'ok';
        $message = '';
    } else {
        // Edit Failure.
        $code = 500;
        $status = 'error';
        $message = 'Components could not be deleted.';
    }
    $output = array('status' => "{$status}", 'err-msg' => $message);
    $app->response->setStatus($code);
    $app->response->headers->set('Content-Type', 'application/json');
    echo _json_encode($output);
}
Exemple #29
0
/*
 * LibreNMS module to capture Cisco Class-Based QoS Details
 *
 * Copyright (c) 2015 Aaron Daniels <*****@*****.**>
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.  Please see LICENSE.txt at the top level of
 * the source code distribution for details.
 */
if ($device['os_group'] == "cisco") {
    $module = 'Cisco-CBQOS';
    require_once 'includes/component.php';
    $component = new component();
    $options['filter']['type'] = array('=', $module);
    $options['filter']['disabled'] = array('=', 0);
    $options['filter']['ignore'] = array('=', 0);
    $components = $component->getComponents($device['device_id'], $options);
    // We only care about our device id.
    $components = $components[$device['device_id']];
    // Only collect SNMP data if we have enabled components
    if (count($components > 0)) {
        // Let's gather the stats..
        $tblcbQosClassMapStats = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.15.1.1', 2);
        // Loop through the components and extract the data.
        foreach ($components as $key => $array) {
            $type = $array['qos-type'];
            // Get data from the class table.
            if ($type == 2) {
Exemple #30
0
     $routing_tabs[] = 'bgp';
 }
 $device_routing_count['ospf'] = dbFetchCell("SELECT COUNT(*) FROM `ospf_instances` WHERE `ospfAdminStat` = 'enabled' AND `device_id` = ?", array($device['device_id']));
 if ($device_routing_count['ospf']) {
     $routing_tabs[] = 'ospf';
 }
 $device_routing_count['cef'] = dbFetchCell('SELECT COUNT(*) FROM `cef_switching` WHERE `device_id` = ?', array($device['device_id']));
 if ($device_routing_count['cef']) {
     $routing_tabs[] = 'cef';
 }
 $device_routing_count['vrf'] = @dbFetchCell('SELECT COUNT(*) FROM `vrfs` WHERE `device_id` = ?', array($device['device_id']));
 if ($device_routing_count['vrf']) {
     $routing_tabs[] = 'vrf';
 }
 require_once "../includes/component.php";
 $component = new component();
 $options['type'] = 'Cisco-OTV';
 $options['filter']['device_id'] = array('=', $device['device_id']);
 $otv = $component->getComponents(null, $options);
 $device_routing_count['cisco-otv'] = count($otv);
 if ($device_routing_count['cisco-otv'] > 0) {
     $routing_tabs[] = 'cisco-otv';
 }
 if (is_array($routing_tabs)) {
     echo '<li class="' . $select['routing'] . '">
         <a href="' . generate_device_url($device, array('tab' => 'routing')) . '">
         <img src="images/16/arrow_branch.png" align="absmiddle" border="0" /> Routing
         </a>
         </li>';
 }
 $device_pw_count = @dbFetchCell('SELECT COUNT(*) FROM `pseudowires` WHERE `device_id` = ?', array($device['device_id']));