Exemple #1
0
$t->alliance = new Alliance();

try {
	if ($filtered['alliance-submit']) {
		$name     = $filtered['alliance-name'        ];
		$password = md5($filtered['alliance-password']);
		$tag      = $filtered['alliance-tag'         ];
		$url      = $filtered['alliance-url'         ];
		$server   = $filtered['alliance-ircserver'   ];
		$channel  = $filtered['alliance-ircchannel'  ];
		$status   = $filtered['alliance-status'      ];
		$status   = max(min($status, 1), 0);
		$message  = htmlentities($filtered['alliance-message'], ENT_QUOTES, 'UTF-8');
		$news     = htmlentities($filtered['alliance-news'   ], ENT_QUOTES, 'UTF-8');
		
		if ($alliances = Alliance::queryNameTag($name, $tag)) {
			// They might be trying to resurrect an alliance, check for dead alliances
			
			foreach ($alliances as $a) {
				if ($name == $a->name and $a->isDead($user)) {
					// Okay, try to resurrect
					if ($password == $a->password) {
						// Okay, they have the name and password right
						// Check if the leaders are null
						if ($a->hasNullLeaders()) {
							// Make the user the leader
							$t->alliance = $a;
							$a->status = 0;
							$a->addLeader($user);
							$a->save();
							header('Location: alliance-home.php');