diff --git a/include/bootstrap.php b/include/bootstrap.php index 0e286a53..10f18225 100644 --- a/include/bootstrap.php +++ b/include/bootstrap.php @@ -14,6 +14,16 @@ $quickstartlink = "setConfig($config); - $this->table = $this->config['db']['shared']['name'] . '.' . $this->table; + $this->table = $this->config['db']['shared']['accounts'] . '.' . $this->table; } /** diff --git a/include/classes/news.class.php b/include/classes/news.class.php index b4de57e2..f0601f5b 100644 --- a/include/classes/news.class.php +++ b/include/classes/news.class.php @@ -4,6 +4,17 @@ $defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1; class News extends Base { protected $table = 'news'; + /** + * We allow changing the database for shared accounts across pools + * Load the config on construct so we can assign the DB name + * @param config array MPOS configuration + * @return none + **/ + public function __construct($config) { + $this->setConfig($config); + $this->table = $this->config['db']['shared']['news'] . '.' . $this->table; + } + /** * Get activation status of post * @param id int News ID @@ -96,7 +107,7 @@ class News extends Base { } } -$news = new News(); +$news = new News($config); $news->setDebug($debug); $news->setMysql($mysqli); $news->setUser($user); diff --git a/include/classes/user.class.php b/include/classes/user.class.php index c5ab0c34..b7b56da6 100644 --- a/include/classes/user.class.php +++ b/include/classes/user.class.php @@ -14,7 +14,7 @@ class User extends Base { **/ public function __construct($config) { $this->setConfig($config); - $this->table = $this->config['db']['shared']['name'] . '.' . $this->table; + $this->table = $this->config['db']['shared']['accounts'] . '.' . $this->table; } // get and set methods diff --git a/include/classes/worker.class.php b/include/classes/worker.class.php index 3f9569f9..fd0f2c9b 100644 --- a/include/classes/worker.class.php +++ b/include/classes/worker.class.php @@ -12,7 +12,7 @@ class Worker extends Base { **/ public function __construct($config) { $this->setConfig($config); - $this->table = $this->config['db']['shared']['name'] . '.' . $this->table; + $this->table = $this->config['db']['shared']['workers'] . '.' . $this->table; } /** diff --git a/include/config/global.inc.dist.php b/include/config/global.inc.dist.php index 464759a7..456e7791 100644 --- a/include/config/global.inc.dist.php +++ b/include/config/global.inc.dist.php @@ -54,7 +54,11 @@ $config['db']['user'] = 'someuser'; $config['db']['pass'] = 'somepass'; $config['db']['port'] = 3306; $config['db']['name'] = 'mpos'; -$config['db']['shared']['name'] = $config['db']['name']; +// Disabled by default and set in bootstrap if unset, but left in here so +// people know it exists +// $config['db']['shared']['accounts'] = $config['db']['name']; +// $config['db']['shared']['workers'] = $config['db']['name']; +// $config['db']['shared']['news'] = $config['db']['name']; /** * Local wallet RPC