<?php
/*
    'hostname' => '10.10.33.21',
        'username' => 'savvy',
        'password' => 'savvy001!',
        'database' => 'savvy',
        'DBDriver' => 'Postgre',
        'DBPrefix' => '',


*/

class savvyext_api_savvy{
 var $database=
  [
    "host" => "10.10.33.21",
    "name" => "savvy",
    "user" => "savvy",
    "pass" => "savvy001!",
    "port" => "5432"
  ];
  
  var $gpsdatabase=
  [
    "host" => "172.31.12.248",
    "name" => "savvy_gps",
    "user" => "savvy",
    "pass" => "savvy001!",
    "port" => "5432"
  ];

  var $google=
[
	"api_key" => "AIzaSyBMNecOHz0OHbJti5P9foh_PVPYZntr18I",
	"api_key_old" => "AIzaSyDvjiRTxngOQyBP4zpqFlZuiquc0ROvo9c",
	"drive_client_id" => "343605975098-frdrsttkgkih8dm19js6itgs6ps261ea.apps.googleusercontent.com",
	"drive_client_secret" => "XbUr5SW9Y1CaEjO_3fvglRna",
	"drive_card_images" => "1NjftJBnFj9zTqWX7GLDhvlh28JOMeqv3",
	"storage_project_id" => "float-app-224118";
	"storage_auth_file" => "/home/savvy/savvy/savvyext/etc/float-app-224118-52ef1783d2c5.json",
	"kms_project_id" => "float-app-224118",
	"kms_auth_file" => "/home/savvy/savvy/savvyext/etc/float-app-224118-52ef1783d2c5.json",
	"kms_keyring_id" => "development",
	"kms_key_id" => "oauth2_tokens"
];
  
  public function cfgReadChar($varname){
    $pieces = explode(".", $varname);
    if ( $pieces[0] == 'database'){
       return $this->database[$pieces[1]];
    }

    if ( $pieces[0] == 'gpsdatabase'){
        return $this->gpsdatabase[$pieces[1]];
    }
    
    return $this=>$pieces[0][$pieces[1]]; // piece1
  }

  public function cfgReadLong($varname){
    return $this->cfgReadChar($varname);
  }

}

if (!array_key_exists('savvyext', $GLOBALS)) {
	$savvyext = new savvyext_api_savvy();
	/*
    $USER = $_SERVER['SCRIPT_FILENAME'];
    $USER = str_replace('/home', '', $USER);
    $USER = strtok($USER, '/');
    if ($USER=='opt') $USER = 'root';
    // Load API class
    $USER="savvy";
    $savvyext_class = 'savvyext_api_' . $USER . '\\SavvyExt';
    $savvyext = new $savvyext_class();
  */
}
