function __construct() { $sa = LG_STANDALONE ? ' (standalone)' : ''; $ip = $_SERVER['REMOTE_ADDR']; lgDebug("Request started for {$ip}{$sa}: " . join(',', array_keys($_REQUEST))); // Make singleton available if we need it self::$instance = $this; // Check that the local distributed database table exists and has a matching structure $this->checkTable(); // Delete any objects that have reached their expiry time $this->expire(); // Instantiate the main global objects LigminchaGlobalServer::getMaster(); $server = LigminchaGlobalServer::getCurrent(); LigminchaGlobalUser::checkAll(); LigminchaGlobalSSO::makeSessionFromCookie(); // If this is a changes request, if (array_key_exists(self::$cmd, $_REQUEST)) { // Commit the data (and re-route if master) $data = $_REQUEST[self::$cmd]; if ($data) { print self::recvQueue($data); } elseif ($server->isMaster) { print self::encodeData($this->initialTableData()); } // If we're the master, always send queue incase any re-routing if ($server->isMaster) { self::sendQueue(); } exit; } elseif ($server->isMaster && array_key_exists('fakeinfo', $_REQUEST)) { $actions = array('edited', 'created', 'booked', 'posted'); $titles = array('Alguma Coisa', 'Outra Coisa', 'Muitas Coisas', 'Mais ou Menos'); $users = LigminchaGlobalUser::select(); $user = $users[rand(0, count($users) - 1)]->data['realname']; $action = $actions[rand(0, count($actions) - 1)]; $title = $titles[rand(0, count($titles) - 1)]; new LigminchaGlobalLog("{$user} {$action} {$title}", 'Info', time() + 1000); self::sendToWebSocket(array(0, $server->id, 0, LigminchaGlobalSync::select()[0]), 0); self::sendQueue(); exit; } }