protected function __construct() { $config = \ManiaLive\Database\Config::getInstance(); $this->host = $config->host; $this->username = $config->username; $this->password = $config->password; $this->database = $config->database; }
protected function __construct($lobbyLogin, $scriptName, $titleIdString) { $config = \ManiaLive\Database\Config::getInstance(); $this->db = Connection::getConnection($config->host, $config->username, $config->password, $config->database, $config->type, $config->port); Dispatcher::register(Event::getClass(), $this, Event::ON_PLAYER_ALLIES_CHANGED | Event::ON_PLAYER_CONNECT | Event::ON_PLAYER_DISCONNECT); $this->lobbyLogin = $lobbyLogin; $this->scriptName = $scriptName; $this->titleIdString = $titleIdString; $this->createTable(); }
private function initDatabase() { $options = getopt(null, array('dbHost::', 'dbPort::', 'dbUsername::', 'dbPassword::', 'dbDatabase::')); $dbConfig = \ManiaLive\Database\Config::getInstance(); foreach ($options as $key => $value) { $dbConfig->{lcfirst(substr($key, 2))} = $value; } $this->database = Connection::getConnection($dbConfig->host, $dbConfig->username, $dbConfig->password, $dbConfig->database, 'MySQL', $dbConfig->port); // load configs from DB $configs = array('config' => \ManiaLive\Config\Config::getInstance(), 'wsapi' => \ManiaLive\Features\WebServices\Config::getInstance(), 'manialive' => \ManiaLive\Application\Config::getInstance(), 'server' => \ManiaLive\DedicatedApi\Config::getInstance(), 'threading' => Config::getInstance()); foreach ($configs as $dbName => $instance) { $data = $this->getData($dbName, array()); foreach ((array) $data as $key => $value) { $instance->{$key} = $value; } } }
private function spawnThread($threadId) { $config = \ManiaLive\Config\Config::getInstance(); $dbConfig = \ManiaLive\Database\Config::getInstance(); $outputFile = $config->logsPath . '/' . ($config->logsPrefix ? $config->logsPrefix . '-' : '') . 'threading-error.txt'; $descriptors = array(1 => array('file', $outputFile, 'a'), 2 => array('file', $outputFile, 'a')); $args = array('threadId' => $threadId, 'parentId' => getmypid(), 'dbHost' => $dbConfig->host, 'dbPort' => $dbConfig->port, 'dbUsername' => $dbConfig->username, 'dbPassword' => $dbConfig->password, 'dbDatabase' => $dbConfig->database); $command = '"' . Config::getInstance()->phpPath . '" "' . __DIR__ . DIRECTORY_SEPARATOR . 'thread_ignitor.php"'; foreach ($args as $key => $value) { $command .= ' --' . $key . '=' . escapeshellarg($value); } Console::printDebug('Trying to spawn Thread #' . $threadId . ' using command: ' . PHP_EOL . $command); return proc_open($command, $descriptors, $pipes, null, null, array('bypass_shell' => true)); }
function __construct() { $config = \ManiaLive\Database\Config::getInstance(); $this->db = Connection::getConnection($config->host, $config->username, $config->password, $config->database, $config->type, $config->port); }
protected final function enableDatabase() { $config = \ManiaLive\Database\Config::getInstance(); $this->db = DbConnection::getConnection($config->host, $config->username, $config->password, $config->database, $config->type, $config->port); }