#!/bin/sh
#
# Helper functions for command-line utilities that need to parse the
# PHP config files.
#
# (C) Copyright 2002 ModernMethod, Inc.

load_config_file() { 
	
	vars_file=""

    for file in site_vars.phtml ../site_vars.phtml ../../site_vars.phtml 
    do
    	if [ -f $file ]; then 
    		vars_file=$file
		break
    	fi
    done

    if [ "x$vars_file" = "x" ]; then
    	echo Could not find configuration file
    	exit 1
    fi

    if [ ! -f $vars_file ]; then
    	echo Can not locate configuration file $vars_file
    	exit 1
    fi

    # First, let's get only the db-related entries.
    cat $vars_file | grep db | grep '\$' | egrep -v '^.*//.*$' | sed -e 's/^.*\$//g' | \
    	sed -e 's/ = /=/g' > t
    . t
    rm t
}

