Пример #1
0
/**
 * returns all of the parameters prefixed with $prefix. To do so - both command
 * line arguments and values in env (prefixed with bm_param_$prefix) are 
 * searched
 * @param string $prefix the prefix to search for
 * @return array
 */
function get_prefixed_params($prefix)
{
    $params = array();
    foreach (string_to_hash(shell_exec('env')) as $key => $val) {
        if (preg_match('/^bm_param_' . $prefix . '(.*)$/', $key, $m)) {
            $params[$m[1]] = trim($val) ? trim($val) : TRUE;
        }
    }
    foreach ($_SERVER['argv'] as $arg) {
        if (preg_match('/^\\-\\-' . $prefix . '(.*)$/', $arg, $m)) {
            $pieces = explode('=', $m[1]);
            $params[trim(strtolower($pieces[0]))] = isset($pieces[1]) ? trim($pieces[1]) : TRUE;
        }
    }
    return $params;
}
Пример #2
0
 /**
  * returns geo regions as a hash indexed by region code where the value is an
  * array of [state],[country] or [country] values
  * @return array
  */
 private function &getGeoRegions()
 {
     if (!isset($this->geoRegions)) {
         $this->geoRegions = string_to_hash(file_get_contents(dirname(__FILE__) . '/config/geo-regions.ini'));
         foreach (array_keys($this->geoRegions) as $region) {
             $this->geoRegions[$region] = explode('|', $this->geoRegions[$region]);
         }
     }
     return $this->geoRegions;
 }