Source for file Config.php
Documentation is available at Config.php
// +----------------------------------------------------------------------+
// | PEAR :: System :: ProcWatch :: Config |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is available at http://www.php.net/license/3_0.txt |
// | If you did not receive a copy of the PHP license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003-2004 Michael Wallner <mike@iworks.at> |
// +----------------------------------------------------------------------+
// $Id: Config.php 304228 2010-10-10 03:05:12Z clockwerx $
* System_ProcWatch_Config
* Build a configuration array for System_ProcWatch
* $cf = System_ProcWatch_Config::fromXmlFile('/etc/procwatch.xml');
* $pw = &new System_ProcWatch($cf);
* @author Michael Wallner <mike@php.net>
* @package System_ProcWatch
* @version $Revision: 304228 $
* Get config array from XML file
* @param string $file path to XML file
return PEAR ::raiseError (" File '$file' doesn't exist" );
* Get config array from XML string
* @param string $xml XML string
include_once('System/ProcWatch/Config/Parser.php');
$result = $config->getConf ($xml);
* Get config array from INI file
* @param string $file path to INI file
return PEAR ::raiseError (" File '$file' doesn't exist" );
foreach ($jobs as $job => $c) {
$result[$job]['pattern'][$c['match']] = $c['pattern'];
$result[$job]['condition'][$c['condition']] = array ();
// set a refernce for easier use
if ($c['condition'] == 'attr') {
$result[$job]['condition']['attr'] = array ();
$reference = &$result[$job]['condition']['attr'][$c['attr']];
} elseif ($c['condition'] == 'presence') {
$reference = &$result[$job]['condition'][$c['condition']];
// (min|max|sum|is|isnot) conditions
$reference['min'] = $c['min'];
$reference['max'] = $c['max'];
$reference['sum'] = $c['sum'];
$reference['is'] = $c['is'];
if (isset ($c['isnot'])) {
$reference['isnot'] = $c['isnot'];
$result[$job]['execute'] = array ('shell' => array ($c['execute']));
* Get config array from an array :)
* This method in fact does a sanity check on the supplied config array
* and should only be used for testing purposes.
* @param array $array config array to check
foreach ($array as $job) {
!isset ($job['pattern']) OR
!isset ($job['condition']) OR
!isset ($job['execute']) OR
!isset ($job['execute']['shell']) AND
!isset ($job['execute']['php'])
!is_array(@$job['execute']['shell']) AND
!isset ($job['condition']['presence']) AND
!isset ($job['condition']['attr'])
!is_array(@$job['condition']['presence']) AND
return PEAR ::raiseError ('Invalid configuration array supplied');
Documentation generated on Mon, 11 Mar 2019 15:39:51 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|