public function __construct()
 {
     parent::__construct();
     $this->sdb = HBLoader::LoadComponent('SimpleDevkit/SimpleDB');
     $this->moduledir = MAINDIR . 'includes' . DS . 'modules' . DS . 'Other' . DS . 'styleswitcher' . DS;
     $this->_header();
 }
예제 #2
0
 * }
 *
 * Under $port variable HostBill will load port in question.
 * For instance: $port = '1/g2';
 * So cycle power of port 1/g2:
 *
 *
 * Connection details loaded from related App are available in $app array.
 * $app['ip'] - holds PDU ip address
 * $app['username'] - holds switch telnet username
 * $app['password'] - holds switch telnet password
 *
 * If you wish to return error, throw new Exception.
 * like: throw new Exception('Something unexpected happen');
 */
$telnet = HBLoader::LoadComponent('Net/Telnet');
$telnet->SetConnection(array('host' => $app['ip'], 'timeout' => 20, 'debug' => true));
$telnet->connect();
$telnet->login(array('login' => $app['username'], 'password' => $app['password'], 'login_prompt' => "\r\nUser:", 'password_prompt' => 'Password:'******'login_success' => 'console>', 'login_fail' => '', 'prompt' => 'console>'));
$telnet->prompt('console#');
$telnet->cmd('enable');
$telnet->prompt('console(config)#');
$telnet->cmd('configure');
$telnet->prompt('console(config-if-' . $port . ')#');
$telnet->cmd('interface ethernet ' . $port);
if ($state) {
    $telnet->cmd('no shutdown');
} else {
    $telnet->cmd('shutdown');
}
$telnet->disconnect();
예제 #3
0
 *
 * Load available ports into $ports array - HostBill will read from it.
 * I.e.:
 * $ports = array(
 *  "1" => "Port name #1",
 *  "2" => "Port name #2"
 * );
 *
 * Connection details loaded from related App are available in $app array.
 * $app['ip'] - holds Switch ip address
 * $app['read'] - holds SNMP read community, default "public"
 * $app['write'] - holds SNMP write community, default "private"
 *
 *
 * If you wish to return error, throw new Exception.
 * like: throw new Exception('Something unexpected happen');
 */
$ports = array();
/**
 * We're using helper here, but you can use default snmp functions for php
 * http://www.php.net/manual/en/ref.snmp.php
 */
$snmp = HBLoader::LoadComponent('Net/SNMP_wrapper');
$snmp->Connect($app['ip'], 161, $app['read'], 10, 0);
//set timeout to 10sec., retries to 0
$tree = $snmp->GetTree('.1.3.6.1.2.1.2.2.1.2');
if (is_array($tree) && !empty($tree)) {
    foreach ($tree as $k => $itm) {
        $ports[str_ireplace('IF-MIB::ifDescr.', '', $k)] = str_ireplace(array('STRING: ', '"'), '', $itm);
    }
}