Exemplo n.º 1
0
/*****************************************************************************
*
*	 This script is doing basic use PAN-Configurator API.
*		
*	It will load a sample PANOS config and make some rules and object 
*	editing.
*
*****************************************************************************/
// load PAN-Configurator library
require_once "../lib/panconfigurator.php";
// input and output files
$origfile = "sample-configs/panos-example-2.xml";
$outputfile = "output.xml";
// We're going to load a PANConf object (PANConf is for PANOS Firewall,
//	PanoramaConf is obviously for Panorama which is covered in another example)
$panc = new PANconf();
$panc->load_from_file($origfile);
// Did we find VSYS1 ?
$vsys1 = $panc->findVirtualSystem('vsys1');
if (is_null($vsys1)) {
    derr("vsys1 was not found ? Exit\n");
}
print "\n***********************************************\n\n";
// look for an object named server-4-address
$addressObject = $vsys1->addressStore->find('server-4-address');
// display the list of objects that are using this
$addressObject->display_references();
print "\n";
// look for an object called client-2-address
$anotherObject = $vsys1->addressStore->find('client-2-address');
// display the list of objects that are using this
<?php

/*****************************************************************************
*
*	 more comments needed
*		
*	This script will load a PANOS config and create 15000 random rules
*
*****************************************************************************/
require_once "../lib/panconfigurator.php";
$origfile = "sample-configs/pan-example1.xml";
$output = "output.xml";
$panc = new PANconf();
$panc->load_from_file($origfile);
// Did we find VSYS1 ?
$v =& $panc->findVirtualSystem('vsys1');
if (is_null($v)) {
    derr("vsys1 was not found ? Exit\n");
}
print "\n***********************************************\n\n";
$newrules = array();
$addresses = $v->addressStore->all();
$ac = count($addresses);
$ak = array_keys($addresses);
for ($i = 0; $i < 15001; $i++) {
    $newrules[$i] = $v->securityRules->newSecurityRule('autogen-' . $i);
    $newrules[$i]->setName('autogen2-' . $i);
    if ($i % 500 == 0) {
        memory_and_gc("i={$i}");
    }
    $r = rand(1, 10);