All pastes #174974 Raw Edit

Untitled

public php v1 · immutable
·published 2006-09-18 11:47 UTC
rendered paste body
<?phpfunction getfile($file){    if (!file_exists($file)) {        print 'Error loading file <strong>'.$file.'</strong> !';        return false;    }    $data = file_get_contents($file);    return $data;}function xml2array($text) {    $reg_exp = '/<(\w+)[^>]*>(.*?)<\/\\1>/s';    preg_match_all($reg_exp, $text, $match);    foreach ($match[1] as $key=>$val) {        if ( preg_match($reg_exp, $match[2][$key]) ) {            $array[$val] = xml2array($match[2][$key]);        } else {            $array[$val] = $match[2][$key];        }    }    return $array;}function loadcfg($file){ //Depends:utils.php[getfile xml2array]    global $CONF;    $file = $_SERVER['DOCUMENT_ROOT'].'/etc/'.$file; //EDIT TO CHANGE .CFG FOLDER    if (!($data = getfile($file))) return false;    $cfg = xml2array($data);    if(!empty($CONF)){        $CONF = array_merge($CONF, $cfg);    }else{        $CONF = $cfg;    }    return true;}?>