Skip to content

Commit

Permalink
Merge pull request #1470 from connortechnology/api_improvements
Browse files Browse the repository at this point in the history
Api improvements
  • Loading branch information
Andrew Bauer committed May 25, 2016
2 parents 575f8ec + e804cfb commit ceaacf9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
6 changes: 4 additions & 2 deletions web/api/app/Config/bootstrap.php.in
Expand Up @@ -134,8 +134,10 @@ function loadConfigFile() {
continue;
elseif ( preg_match( '/^\s*#/', $str ))
continue;
elseif ( preg_match( '/^\s*([^=\s]+)\s*=\s*(.*?)\s*$/', $str, $matches ))
Configure::write("$matches[1]", "$matches[2]");
elseif ( preg_match( '/^\s*([^=\s]+)\s*=\s*(.*?)\s*$/', $str, $matches )) {
Configure::write( $matches[1], $matches[2] );
define( $matches[1], $matches[2] );
}
}
fclose( $cfg );
}
Expand Down
21 changes: 17 additions & 4 deletions web/api/app/Config/database.php.default
Expand Up @@ -67,10 +67,9 @@ class DATABASE_CONFIG {
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => '@ZM_DB_HOST@',
'login' => '@ZM_DB_USER@',
'password' => '@ZM_DB_PASS@',
'database' => '@ZM_DB_NAME@',
'login' => ZM_DB_USER,
'password' => ZM_DB_PASS,
'database' => ZM_DB_NAME,
'prefix' => '',
//'encoding' => 'utf8',
);
Expand All @@ -85,4 +84,18 @@ class DATABASE_CONFIG {
'prefix' => '',
//'encoding' => 'utf8',
);

public function __construct() {
if (strpos(ZM_DB_HOST, ':')):
$array = explode(':', ZM_DB_HOST, 2);
if (is_numeric($array[1])):
$this->default['host'] = $array[0];
$this->default['port'] = $array[1];
else:
$this->default['unix_socket'] = $array[1];
endif;
else:
$this->default['host'] = ZM_DB_HOST;
endif;
}
}

0 comments on commit ceaacf9

Please sign in to comment.