Exemple #1
0
 public function executeAction($object)
 {
     $this->object = $object;
     print "   - object '" . PH::boldText($object->name()) . "' passing through Action='{$this->actionRef['name']}'";
     if (count($this->arguments) != 0) {
         print " Args: ";
         foreach ($this->arguments as $argName => $argValue) {
             print "{$argName}={$argValue}, ";
         }
     }
     print "\n";
     $this->actionRef['MainFunction']($this);
 }
function display_error_usage_exit($msg)
{
    fwrite(STDERR, PH::boldText("\n**ERROR** ") . $msg . "\n\n");
    display_usage_and_exit(true);
}
/**
 * Stops script with an error message and a backtrace
 * @param string $msg error message to display
 * @param DOMNode $object
 * @throws Exception
 */
function derr($msg, $object = null)
{
    if ($object !== null) {
        $class = get_class($object);
        if ($class == 'DOMNode' || $class == 'DOMElement' || is_subclass_of($object, 'DOMNode')) {
            $msg .= "\nXML line #" . $object->getLineNo() . ", XPATH: " . DH::elementToPanXPath($object) . "\n" . DH::dom_to_xml($object, 0, true, 3);
        }
    }
    if (PH::$useExceptions) {
        $ex = new Exception($msg);
        throw $ex;
    }
    fwrite(STDERR, PH::boldText("\n* ** ERROR ** * ") . $msg . "\n\n");
    //debug_print_backtrace();
    $d = debug_backtrace();
    $skip = 0;
    fwrite(STDERR, " *** Backtrace ***\n");
    $count = 0;
    foreach ($d as $l) {
        if ($skip >= 0) {
            print "{$count} ****\n";
            if (isset($l['object']) && method_exists($l['object'], 'toString')) {
                fwrite(STDERR, '   ' . $l['object']->toString() . "\n");
            }
            //print $l['function']."()\n";
            if (isset($l['object'])) {
                fwrite(STDERR, '       ' . PH::boldText($l['class'] . '::' . $l['function'] . "()") . " @\n           " . $l['file'] . " line " . $l['line'] . "\n");
            } else {
                fwrite(STDERR, '       ::' . $l['file'] . " line " . $l['line'] . "\n");
            }
        }
        $skip++;
        $count++;
    }
    exit(1);
}
 public function display_statistics()
 {
     print "Statistics for DG '" . PH::boldText($this->name) . "'\n";
     print "- {$this->securityRules->countPreRules()} / {$this->securityRules->countPostRules()} pre/post SecRules\n";
     print "- {$this->natRules->countPreRules()} / {$this->natRules->countPostRules()} pre/post NatRules\n";
     print "- {$this->addressStore->countAddresses()} / {$this->addressStore->countAddressGroups()} / {$this->addressStore->countTmpAddresses()} address/group/tmp/total objects\n";
     print "- {$this->serviceStore->countServices()} / {$this->serviceStore->countServiceGroups()} / {$this->serviceStore->countTmpServices()} service/group/tmp/total objects\n";
     print "- {$this->tagStore->count()} tags. {$this->tagStore->countUnused()} unused\n";
 }