function isPaid(Transaction $transaction) { $payments = new \Maniaplanet\WebServices\Payments(\ManiaLive\Features\WebServices\Config::getInstance()->username, \ManiaLive\Features\WebServices\Config::getInstance()->password); $isPaid = $transaction->cost ? $payments->isPaid($transaction->id) : true; if ($isPaid) { $this->db()->execute('INSERT INTO Incomes VALUES (%s,%d,1) ' . 'ON DUPLICATE KEY UPDATE revenue = revenue + VALUES(revenue), transactionCount = transactionCount + 1', $this->db()->quote(date('Y-m-d 00:00:00')), $transaction->cost); } return $isPaid; }
protected function __construct() { $this->enabled = extension_loaded('mysql') && Config::getInstance()->enabled; if ($this->enabled) { $this->setUpDatabase(); $this->setData('config', \ManiaLive\Config\Config::getInstance()); $this->setData('wsapi', \ManiaLive\Features\WebServices\Config::getInstance()); $this->setData('manialive', \ManiaLive\Application\Config::getInstance()); $this->setData('server', \ManiaLive\DedicatedApi\Config::getInstance()); $this->setData('threading', \ManiaLive\Threading\Config::getInstance()); } else { Logger::debug('Application started with threading disabled!', true, array('Process #' . getmypid())); $this->buffers[0] = array(); } Dispatcher::register(TickEvent::getClass(), $this); }
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; } } }