Пример #1
0
 protected function getNewUser($username = "******", $role = Player::PLAYER)
 {
     // Try to find a valid bzid
     $bzid = 300;
     while (Player::getFromBZID($bzid)->isValid()) {
         ++$bzid;
         if ($bzid > 15000) {
             throw new Exception("bzid too big");
         }
     }
     return Player::newPlayer($bzid, $username, null, "test", $role);
 }
Пример #2
0
 public function loginAction(Request $request, Player $me)
 {
     if ($me->isValid()) {
         throw new ForbiddenException("You are already logged in!");
     }
     $query = $request->query;
     $session = $request->getSession();
     $token = $query->get("token");
     $username = $query->get("username");
     if (!$token || !$username) {
         throw new BadRequestException();
     }
     // Don't check whether IPs match if we're on a development environment
     $checkIP = !$this->isDebug();
     $info = validate_token($token, $username, array(), $checkIP);
     if (!isset($info)) {
         throw new ForbiddenException("There was an error processing your login. Please go back and try again.");
     }
     $session->set("username", $info['username']);
     $session->set("groups", $info['groups']);
     $redirectToProfile = false;
     if (!Player::playerBZIDExists($info['bzid'])) {
         // If they're new, redirect to their profile page so they can add some info
         $player = Player::newPlayer($info['bzid'], $info['username']);
         $redirectToProfile = true;
     } else {
         $player = Player::getFromBZID($info['bzid']);
         if ($player->isDeleted()) {
             $player->setStatus('active');
         }
     }
     $session->set("playerId", $player->getId());
     $player->updateLastLogin();
     $player->setUsername($info['username']);
     Visit::enterVisit($player->getId(), $request->getClientIp(), gethostbyaddr($request->getClientIp()), $request->server->get('HTTP_USER_AGENT'), $request->server->get('HTTP_REFERER'));
     $this->configPromoteAdmin($player);
     if ($redirectToProfile) {
         $profile = Service::getGenerator()->generate('profile_show');
         return new RedirectResponse($profile);
     } else {
         return $this->goBack();
     }
 }
Пример #3
0
    die("Please clear your current data in the database or you'll end up with duplicate entries.\n");
}
echo "Adding players...";
$alezakos = Player::newPlayer(49434, "alezakos", null, "active", Player::DEVELOPER, "", "Sample description", 84);
$allejo = Player::newPlayer(31098, "allejo", null, "active", Player::DEVELOPER, "", "I'm the one who breaks the build", 227);
$ashvala = Player::newPlayer(34353, "ashvala", null, "active", Player::DEVELOPER, "", "", 100);
$autoreport = Player::newPlayer(55976, "AutoReport", null, "test");
$blast = Player::newPlayer(180, "blast", null, "active", Player::S_ADMIN);
$kierra = Player::newPlayer(2229, "kierra", null, "active", Player::ADMIN, "", "", 174);
$mdskpr = Player::newPlayer(8312, "mdskpr");
$snake = Player::newPlayer(54497, "Snake12534");
$tw1sted = Player::newPlayer(9736, "tw1sted", null, "active", Player::DEVELOPER);
$brad = Player::newPlayer(3030, "brad", null, "active", Player::S_ADMIN, "", "I keep nagging about when this project will be done");
$constitution = Player::newPlayer(9972, "Constitution", null, "active", Player::S_ADMIN);
$themap = Player::newPlayer(57422, "the map", null, "active", Player::COP);
$oldSnake = Player::newPlayer(54498, "Snake12534");
$oldSnake->setOutdated(true);
$allPlayers = array($alezakos, $allejo, $ashvala, $autoreport, $blast, $kierra, $mdskpr, $snake, $tw1sted, $brad, $constitution, $themap);
echo " done!";
echo "\nSending notifications...";
foreach (Player::getPlayers() as $player) {
    $event = new WelcomeEvent('Welcome to ' . Service::getParameter('bzion.site.name') . '!', $player);
    Notification::newNotification($player->getId(), 'welcome', $event);
}
echo " done!";
echo "\nAdding deleted objects...";
Team::createTeam("Amphibians", $snake->getId(), "", "")->delete();
$snake->refresh();
Team::createTeam("Serpents", $snake->getId(), "", "")->delete();
$snake->refresh();
Page::addPage("Test", "<p>This is a deleted page</p>", $tw1sted->getId())->delete();
Пример #4
0
 /**
  * Create a new sample player
  *
  * @return Player
  */
 protected function getNewPlayer()
 {
     ++$this->lastBzid;
     $player = Player::newPlayer($this->lastBzid, "Sample player" . $this->lastBzid - 1);
     $this->playersCreated[] = $player->getId();
     return $player;
 }
Пример #5
0
$kernel->boot();
$testPlayer = Player::getFromBZID(3030);
if ($testPlayer->isValid()) {
    die("Please clear your current data in the database or you'll end up with duplicate entries.\n");
}
echo "Adding players...";
$alezakos = Player::newPlayer(49434, "alezakos", null, "active", Player::DEVELOPER, "", "Sample description", 84);
$allejo = Player::newPlayer(31098, "allejo", null, "active", Player::DEVELOPER, "", "I'm the one who breaks the build", 227);
$ashvala = Player::newPlayer(34353, "ashvala", null, "active", Player::DEVELOPER, "", "", 100);
$autoreport = Player::newPlayer(55976, "AutoReport", null, "test");
$blast = Player::newPlayer(180, "blast", null, "active", Player::S_ADMIN);
$kierra = Player::newPlayer(2229, "kierra", null, "active", Player::ADMIN, "", "", 174);
$mdskpr = Player::newPlayer(8312, "mdskpr");
$snake = Player::newPlayer(54497, "Snake12534");
$tw1sted = Player::newPlayer(9736, "tw1sted", null, "active", Player::DEVELOPER);
$brad = Player::newPlayer(3030, "brad", null, "active", Player::S_ADMIN, "", "I keep nagging about when this project will be done");
echo " done!";
echo "\nSending notifications...";
foreach (Player::getPlayers() as $player) {
    $event = new WelcomeEvent('Welcome to ' . Service::getParameter('bzion.site.name') . '!', $player);
    Notification::newNotification($player->getId(), 'welcome', $event);
}
echo " done!";
echo "\nAdding deleted objects...";
Team::createTeam("Amphibians", $snake->getId(), "", "")->delete();
$snake->refresh();
Team::createTeam("Serpents", $snake->getId(), "", "")->delete();
$snake->refresh();
Page::addPage("Test", "<p>This is a deleted page</p>", $tw1sted->getId())->delete();
echo " done!";
echo "\nAdding teams...";