public function getSectorLink($x, $y, &$i) { if (isset($this->data[$i]) && $this->data[$i]['x'] == $x && $this->data[$i]['y'] == $y) { if ($this->data[$i]['type'] != 2) { $output = 'href="javascript: fetch(\'getGrid.php\', \'x=' . $x . '&y=' . $y . '\')" onMouseOver="setSectorData(labels[' . $this->data[$i]['type'] . '], \'-\', \'-\')" onMouseOut="setSectorData(\'-\', \'-\', \'-\')"'; } else { $node = new node(); $node->get('id', $this->data[$i]['id']); $user = new user(); $user->get('id', $node->data['user']); $alliancename = '-'; if ($user->data['alliance']) { $alliance = new alliance(); $alliance->get('user', $user->data['id']); $alliancename = $alliance->data['name']; } $output = 'href="javascript: fetch(\'getGrid.php\', \'x=' . $x . '&y=' . $y . '\')" onMouseOver="setSectorData(\'' . $node->data['name'] . '\', \'' . $user->data['name'] . '\', \'' . $alliancename . '\')" onMouseOut="setSectorData(\'-\', \'-\', \'-\')"'; } if ($i < count($this->data) - 1) { $i++; } } else { $output = 'href="javascript: fetch(\'getGrid.php\', \'x=' . $x . '&y=' . $y . '\')"'; } return $output; }
public static function select($con, $id) { base::checkcon($con, __FUNCTION__); $sql = "select matches.*, alliances.* from alliances\n INNER JOIN matches\n ON (matches.ID = " . $id . " and \n alliances.MatchID = " . $id . ")\n order by alliances.Color"; // print "$sql\n"; $result = mysqli_query($con, $sql); if (!$result) { die('Error: ' . mysqli_error($con)); } $row = mysqli_fetch_array($result); if (!$row) { return null; } else { $match = new match(); $match->ID = $row['MatchID']; $match->Time = $row['Time']; $match->Number = $row['Number']; $match->Round = $row['Round']; $a1 = new alliance($row->Color == 'red'); $a1->set($row); $row = mysqli_fetch_array($result); $a2 = new alliance($row->Color == 'red'); $a2->set($row); if ($a1->Color == 'red') { $match->RedAlliance = $a1; $match->BlueAlliance = $a2; } else { $match->RedAlliance = $a2; $match->BlueAlliance = $a1; } mysqli_free_result($result); return $match; } }
public static function selectAlliance($con, $id) { if (!$con) { die('selectTeam error: no connection.'); } $query = "SELECT * FROM alliances where ID = " . $id; $result = mysqli_query($con, $query); $row = mysqli_fetch_assoc($result); if (!$row) { return null; } else { $a = new alliance(); $a->set($alliance); return $a; } }
public static function remove($id) { global $db; $user = new user(); if ($user->get('id', $id) == 'done') { $result = $db->query('select id from alliances where user="******"'); while ($row = db::fetch($result)) { alliance::remove($row['id']); } $result = $db->query('select id from nodes where user="******"'); while ($row = db::fetch($result)) { node::remove($row['id']); } $ok = 1; $db->query('delete from activations where user="******"'); $db->query('delete from preferences where user="******"'); $db->query('delete from blocklist where to="' . $id . '" or from="' . $id . '"'); $messagesResult = $db->query('select id from messages where recipient="' . $id . '" or sender="' . $id . '"'); while ($row = db::fetch($messagesResult)) { $db->query('insert into free_ids (id, type) values ("' . $row['id'] . '", "messages")'); if ($db->affected_rows() == -1) { $ok = 0; } $db->query('delete from messages where id="' . $row['id'] . '"'); if ($db->affected_rows() == -1) { $ok = 0; } } $db->query('insert into free_ids (id, type) values ("' . $id . '", "users")'); if ($db->affected_rows() == -1) { $ok = 0; } $db->query('delete from users where id="' . $id . '"'); if ($db->affected_rows() == -1) { $ok = 0; } if ($ok) { $status = 'done'; } else { $status = 'error'; } } else { $status = 'noUser'; } return $status; }
if (!in_array($key, array('name', 'attackerFocus'))) { $nr = count($_POST[$key]); for ($i = 0; $i < $nr; $i++) { $_POST[$key][$i] = misc::clean($_POST[$key][$i], 'numeric'); } } else { $_POST[$key] = misc::clean($value); } } } $target = new node(); if ($target->get('name', $_POST['name']) == 'done') { $targetUser = new user(); if ($targetUser->get('id', $target->data['user']) == 'done') { $alliance = new alliance(); $targetAlliance = new alliance(); if ($targetAlliance->get('id', $targetUser->data['alliance']) == 'done' && $alliance->get('id', $_SESSION[$shortTitle . 'User']['alliance']) == 'done') { $war = $alliance->getWar($targetAlliance->data['id']); if (isset($war['type'])) { $gotStatic = false; $data = array(); $data['input']['attacker']['focus'] = $_POST['attackerFocus']; $data['input']['attacker']['faction'] = $node->data['faction']; foreach ($_POST['attackerGroupUnitIds'] as $key => $unitId) { $data['input']['attacker']['groups'][$key] = array('unitId' => $unitId, 'quantity' => $_POST['attackerGroups'][$key]); if (!$game['units'][$node->data['faction']][$unitId]['speed']) { $gotStatic = true; } } if (!$gotStatic) { $status = $node->addCombat($target->data['id'], $data);
$action = $_REQUEST['action']; include_once MODELS_ADMIN . "/" . $model . "_model.php"; switch (strtoupper($action)) { case 'ADD': break; case 'SAVE': $objAll = new alliance(); $objAll->setAlliances($_REQUEST); $objComm->redirect('index.php?model=' . $model); break; case 'VIEW': case 'EDIT': $objAll = new alliance(); $row = $objAll->getAlliance($_REQUEST['id']); $rowLocation = $objAll->getAllianceLocationDetails($_REQUEST['id']); break; case 'UPDATE': $objAll = new alliance(); $objAll->setAlliances($_REQUEST); $objComm->redirect('index.php?model=' . $model . '&action=edit&id=' . $_REQUEST['pk_id']); break; case 'DELETE': $objAll = new alliance(); $objAll->delAlliance($_REQUEST['id']); $objComm->redirect('index.php?model=' . $model); break; default: $objAll = new alliance(); $Records = $objAll->getAllAlliance(); break; }
} } else { $message = $ui['accessDenied']; } } else { $message = $ui['noAlliance']; } } else { $message = $ui['insufficientData']; } break; case 'acceptPeace': if (isset($_GET['sender'], $_GET['recipient'])) { if ($status == 'done') { if ($alliance->data['user'] == $_SESSION[$shortTitle . 'User']['id'] && $alliance->data['id'] == $_GET['recipient']) { $senderAlliance = new alliance(); if ($senderAlliance->get('id', $_GET['sender']) == 'done') { $status = $alliance->acceptPeace($senderAlliance->data['id']); if ($status == 'done') { $user = new user(); if ($user->get('id', $senderAlliance->data['user']) == 'done') { $user->getPreferences('name'); if ($user->preferences['allianceReports']) { $msg = new message(); $msg->data['sender'] = $_SESSION[$shortTitle . 'User']['name']; $msg->data['recipient'] = $user->data['name']; $msg->data['subject'] = $ui['peaceAccepted']; $msg->data['body'] = $ui['sender'] . ': ' . $alliance->data['name'] . ' ' . $ui['alliance']; $msg->data['viewed'] = 0; $status = $msg->add(); if ($status == 'done') {
public function selectMatches($con) { base::checkcon($con, __FUNCTION__); $sql = "select matches.*, alliances.* from alliances\n INNER JOIN matches\n ON (matches.CompetitionID = " . $this->ID . " and \n alliances.MatchID = matches.ID)\n order by matches.Number, alliances.Color"; // print $sql; $result = mysqli_query($con, $sql); if (!$result) { die('Error: ' . mysqli_error($con)); } $matches = array(); while ($row = mysqli_fetch_array($result)) { $match = new match(); $match->Competition = this; $match->Time = $row['Time']; $match->Number = $row['Number']; $match->Round = $row['Round']; $match->ID = $row['MatchID']; $a1 = new alliance($row->Color == 'red'); $a1->set($row); $row = mysqli_fetch_array($result); $a2 = new alliance($row->Color == 'red'); $a2->set($row); if ($a1->Color == 'red') { $match->RedAlliance = $a1; $match->BlueAlliance = $a2; } else { $match->RedAlliance = $a2; $match->BlueAlliance = $a1; } array_push($matches, $match); } mysqli_free_result($result); return $matches; }
$user = new user(); if ($user->get('id', $invitation['user']) == 'done') { $accept = ''; $removeLabel = 'x'; if ($user->data['id'] == $_SESSION[$shortTitle . 'User']['id']) { $accept = '<a class="link" href="?action=acceptInvitation&alliance=' . $invitation['alliance'] . '&user='******'user'] . '">' . $ui['accept'] . '</a> | '; $removeLabel = $ui['decline']; } echo '<div class="right"> ' . $user->data['name'] . ' | ' . $accept . '<a class="link" href="?action=removeInvitation&alliance=' . $invitation['alliance'] . '&user='******'user'] . '">' . $removeLabel . '</a></div>'; } } if ($alliance->data['user'] == $_SESSION[$shortTitle . 'User']['id']) { echo '<div class="section" style="margin-top: 5px;"> -> ' . $ui['wars'] . ' | <a class="link" href="?action=addWar">' . $ui['goToWar'] . '</a></div>'; } foreach ($alliance->wars as $war) { $otherAlliance = new alliance(); if ($alliance->data['id'] == $war['sender']) { $otherAllianceId = $war['recipient']; } else { $otherAllianceId = $war['sender']; } if ($otherAlliance->get('id', $otherAllianceId) == 'done') { if ($war['type']) { echo '<div class="right">' . $otherAlliance->data['name'] . ' | <a class="link" href="?action=proposePeace&recipient=' . $otherAlliance->data['id'] . '">' . $ui['peace'] . '</a></div>'; } else { if ($alliance->data['id'] == $war['recipient']) { $ad = '<a class="link" href="?action=acceptPeace&sender=' . $war['sender'] . '&recipient=' . $war['recipient'] . '">' . $ui['accept'] . '</a> / <a class="link" href="?action=removePeace&recipient=' . $otherAlliance->data['id'] . '">' . $ui['decline'] . '</a>'; } else { $ad = '<a class="link" href="?action=removePeace&recipient=' . $otherAlliance->data['id'] . '">x</a>'; } echo '<div class="right">' . $otherAlliance->data['name'] . ' ' . $ui['peace'] . ' | ' . $ad . '</div>';
public function getAll() { $this->getMembers(); $this->invitations = alliance::getInvitations('alliance', $this->data['id']); $this->getWars(); }