diff --git a/CHANGELOG.md b/CHANGELOG.md index a9ee5e71..8cbeab09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,11 @@ --------------------- * Allow SSO accross MPOS pools - * Added a new config option `$config['db']['shared']['name']`, defaults to `$config['db']['name']` - * Will access `accounts` and `pool_workers` on shared table + * Added a new config options + * `$config['db']['shared']['acounts']`, defaults to `$config['db']['name']` + * `$config['db']['shared']['workers']`, defaults to `$config['db']['name']` + * `$config['db']['shared']['news']`, defaults to `$config['db']['name']` + * Will access `accounts`, `pool_workers` and `news` on shared table * Does not allow splitting `accounts` and `pool_woker` across database hosts * Required `$config['cookie']['domain']` to be set * You need to use the top domain shared between hosts as the setting diff --git a/include/bootstrap.php b/include/bootstrap.php index 5225a96e..81a361d1 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 d98fdec8..ddb24104 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 5d6cfb52..cb13387f 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 5d240a7e..af61b1f3 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