3 function ServiceFactory() {
6 function &getServiceInstance($name, $servicedir = NULL) {
7 global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype;
10 require_once dirname(__FILE__) .'/../includes/db/'. $dbtype .'.php';
12 $db->sql_connect($dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist);
13 if(!$db->db_connect_id) {
14 message_die(CRITICAL_ERROR, "Could not connect to the database", $db);
18 static $instances = array();
19 if (!isset($instances[$name])) {
20 if (isset($serviceoverrules[$name])) {
21 $name = $serviceoverrules[$name];
23 if (!class_exists($name)) {
24 if (!isset($servicedir)) {
25 $servicedir = dirname(__FILE__) .'/';
27 require_once $servicedir . strtolower($name) .'.php';
29 $instances[$name] = (new $name($db))->getInstance($db);
31 return $instances[$name];