function clanwars() { global $db, $countries; ob_start(); $tpl = new smarty(); $tpl->assign('win', 0); $tpl->assign('draw', 0); $tpl->assign('loss', 0); $tpl->assign('games', get_games_form((int) @$_GET['gameID'])); $tpl->assign('teams', get_teams_form((int) @$_GET['teamID'])); $tpl->assign('matchtypes', get_matchtype_form((int) @$_GET['matchtypeID'])); $tpl->assign('xonx', get_xonx_form(@$_GET['xonx'])); if (@$_GET['gameID']) { $where = ' AND gID = ' . (int) $_GET['gameID']; } else { $_GET['gameID'] = 0; } if (@$_GET['teamID']) { @($where .= ' AND ' . DB_PRE . 'ecp_wars.tID = ' . (int) $_GET['teamID']); } else { $_GET['teamID'] = 0; } if (@$_GET['matchtypeID']) { @($where .= ' AND mID = ' . (int) $_GET['matchtypeID']); } else { $_GET['matchtypeID'] = 0; } if (@$_GET['xonx']) { @($where .= ' AND xonx = \'' . strsave($_GET['xonx']) . '\''); } switch (@$_GET['sortby']) { case 'opp': $orderby = ' oppname '; break; case 'matchtype': $orderby = ' matchtypename '; break; case 'team': $orderby = ' tname '; break; default: $orderby = DB_PRE . 'ecp_wars.datum '; } switch (@$_GET['art']) { case 'asc': $orderby .= 'ASC '; break; default: $orderby .= 'DESC '; } $db->query('SELECT COUNT(result) as val, result FROM ' . DB_PRE . 'ecp_wars WHERE status = 1 ' . @$where . ' GROUP BY result'); while ($row = $db->fetch_assoc()) { $tpl->assign($row['result'], $row['val']); @($gesamt += $row['val']); } $tpl->assign('anzahl', (int) @$gesamt); if ((int) @$gesamt) { ob_start(); $limit = get_sql_limit($gesamt, LIMIT_CLANWARS); $db->query('SELECT `warID`, ' . DB_PRE . 'ecp_wars.datum, `result`, `resultscore`, `tname`, `oppname`, `country`, ' . DB_PRE . 'ecp_wars_opp.homepage, `icon`, `gamename`, `matchtypename`, COUNT(comID) as comments FROM ' . DB_PRE . 'ecp_wars LEFT JOIN ' . DB_PRE . 'ecp_teams ON ' . DB_PRE . 'ecp_teams.tID = ' . DB_PRE . 'ecp_wars.tID LEFT JOIN ' . DB_PRE . 'ecp_wars_games ON gID = gameID LEFT JOIN ' . DB_PRE . 'ecp_wars_opp ON oID = oppID LEFT JOIN ' . DB_PRE . 'ecp_wars_matchtype ON mID = matchtypeID LEFT JOIN ' . DB_PRE . 'ecp_comments ON (subID = warID AND bereich = "clanwars") WHERE status = 1 ' . @$where . ' GROUP BY warID ORDER BY ' . $orderby . ' LIMIT ' . $limit[1] . ',' . LIMIT_CLANWARS); $clanwars = array(); while ($row = $db->fetch_assoc()) { $row['datum'] = date('d.m.y', $row['datum']); $row['countryname'] = $countries[$row['country']]; $clanwars[] = $row; } $tplcw = new smarty(); if ($limit[0] > 1) { $tplcw->assign('seiten', makepagelink_ajax('?section=clanwars&gameID=' . $_GET['gameID'] . '&teamID=' . $_GET['teamID'] . '&matchtypeID=' . $_GET['matchtypeID'] . '&xonx=' . $_GET['xonx'] . '&sortby=' . $_GET['sortby'] . '&art=' . $_GET['art'] . '', 'return load_wars(' . $_GET['gameID'] . ', ' . $_GET['teamID'] . ', ' . $_GET['matchtypeID'] . ', \'' . $_GET['xonx'] . '\', \'' . $_GET['sortby'] . '\', \'' . $_GET['art'] . '\', {nr});', @$_GET['page'], $limit[0])); } $tplcw->assign('clanwars', $clanwars); $tplcw->display(DESIGN . '/tpl/clanwars/overview.html'); $content = ob_get_contents(); ob_end_clean(); $tpl->assign('clanwars', @$content); } $tpl->display(DESIGN . '/tpl/clanwars/head.html'); $content = ob_get_contents(); ob_end_clean(); main_content(CLANWARS, $content, '', 1); }
function admin_clanwars_editnext($id) { if (@$_SESSION['rights']['admin']['clanwars']['edit_next'] or @$_SESSION['rights']['superadmin']) { global $db; if (isset($_POST['datum'])) { if (!$_POST['oppID']) { $sql = sprintf('INSERT INTO ' . DB_PRE . 'ecp_wars_opp (`oppname`, `oppshort`, `homepage`, `country`) VALUES (\'%s\', \'%s\',\'%s\',\'%s\')', strsave($_POST['oppname']), strsave($_POST['oppshort']), strsave($_POST['homepage']), strsave($_POST['country'])); } else { $sql = sprintf('UPDATE ' . DB_PRE . 'ecp_wars_opp SET `oppname` = \'%s\', `oppshort` = \'%s\', `homepage` = \'%s\', `country` = \'%s\' WHERE oppID = %d', strsave($_POST['oppname']), strsave($_POST['oppshort']), strsave(check_url($_POST['homepage'])), strsave($_POST['country']), @$_POST['oppID']); } if ($db->query($sql)) { !$_POST['oppID'] ? $oppid = $db->last_id() : ($oppid = (int) $_POST['oppID']); $lang = array(); foreach ($_POST as $key => $value) { if (strpos($key, 'cription_')) { $lang[substr($key, strpos($key, '_') + 1)] = $value; } } $players = array(); foreach ($_POST['players'] as $value) { $value = trim($value); if (strpos($value, 'team_') !== false) { $db->query('SELECT userID FROM ' . DB_PRE . 'ecp_members WHERE teamID = ' . (int) substr($value, strpos($value, '_') + 1)); while ($row = $db->fetch_assoc()) { if (!in_array($row['userID'], $players)) { $players[] = $row['userID']; } } } elseif (strpos($value, 'member_') !== false) { $ids = substr($value, strpos($value, '_') + 1); if (!in_array($ids, $players)) { $players[] = $ids; } } } $sql = sprintf('UPDATE ' . DB_PRE . 'ecp_wars SET `tID` = %d, `mID` = %d, `gID` = %d, `datum` = %d, `xonx` = \'%s\', hinweise = \'%s\', `oID` = %d, `matchlink` = \'%s\', `resultbylocations` = %d, `server` = \'%s\', `livestream` = \'%s\', `pw` = \'%s\', `meldefrist` = %d WHERE warID = %d', (int) $_POST['teamID'], (int) $_POST['matchtypeID'], (int) $_POST['gameID'], strtotime($_POST['datum']), (int) $_POST['xonx1'] . 'on' . (int) $_POST['xonx2'], strsave(json_encode($lang)), $oppid, strsave(check_url($_POST['matchlink'])), (int) @$_POST['winbymaps'], strsave($_POST['server']), strsave($_POST['livestream']), strsave($_POST['pw']), strtotime($_POST['meldefrist']), $id); if ($db->query($sql)) { //$db->query('DELETE FROM '.DB_PRE.'ecp_wars_teilnehmer WHERE warID = '.$id); $aktive = array(); $db->query('SELECT userID FROM ' . DB_PRE . 'ecp_wars_teilnehmer WHERE warID = ' . $id); while ($row = $db->fetch_assoc()) { $aktive[$row['userID']] = true; } $db->query('SELECT scoreID FROM ' . DB_PRE . 'ecp_wars_scores WHERE wID = ' . $id . ' ORDER BY scoreID ASC'); $ids = array(); while ($row = $db->fetch_assoc()) { $ids[] = $row['scoreID']; } $own = 0; $opp = 0; foreach ($_POST as $key => $value) { if (strpos($key, 'map_') !== false) { @$i++; if ((int) @$_POST['winbymaps']) { if ((int) $_POST['score_' . $i . '_own'] > (int) $_POST['score_' . $i . '_opp']) { $own++; } elseif ((int) $_POST['score_' . $i . '_own'] < (int) $_POST['score_' . $i . '_opp']) { $opp++; } else { $opp++; $own++; } } else { $own += (int) $_POST['score_' . $i . '_own']; $opp += (int) $_POST['score_' . $i . '_opp']; } if (isset($ids[$i - 1])) { $db->query(sprintf('UPDATE ' . DB_PRE . 'ecp_wars_scores SET `lID` = %d, `ownscore` = %d, `oppscore` = %d WHERE scoreID = %d', (int) $value, (int) $_POST['score_' . $i . '_own'], (int) $_POST['score_' . $i . '_opp'], $ids[$i - 1])); } else { $db->query(sprintf('INSERT INTO ' . DB_PRE . 'ecp_wars_scores (`wID`, `lID`, `ownscore`, `oppscore`) VALUES (%d, %d, %d, %d)', $id, (int) $value, (int) $_POST['score_' . $i . '_own'], (int) $_POST['score_' . $i . '_opp'])); } } } if (count($players)) { $text = $db->fetch_assoc('SELECT `content`, `content2` FROM ' . DB_PRE . 'ecp_texte WHERE name = "NEXT_WAR_MSG" AND lang = "' . DEFAULT_LANG . '"'); if ($_POST['messagemode'] == 1) { foreach ($players as $value) { if (!isset($aktive[(int) $value])) { $db->query('INSERT INTO ' . DB_PRE . 'ecp_wars_teilnehmer (warID, userID) VALUES (' . $id . ', ' . (int) $value . ')'); message_send($value, 0, $text['content2'], str_replace('{link}', '<a href="' . SITE_URL . '?section=clanwars&action=nextwar&id=' . $id . '">' . SITE_URL . '?section=clanwars&action=nextwar&id=' . $id . '</a>', $text['content']), 0, 1); } else { $aktive[(int) $value] = false; } } } elseif ($_POST['messagemode'] == 2) { foreach ($players as $value) { if (!isset($aktive[(int) $value])) { $db->query('INSERT INTO ' . DB_PRE . 'ecp_wars_teilnehmer (warID, userID) VALUES (' . $id . ', ' . (int) $value . ')'); send_email($db->result(DB_PRE . 'ecp_user', 'email', 'ID = ' . (int) $value), $text['content2'], str_replace('{link}', SITE_URL . '?section=clanwars&action=nextwar&id=' . $id, $text['content']), 1); } else { $aktive[(int) $value] = false; } } } elseif ($_POST['messagemode'] == 3) { foreach ($players as $value) { if (!isset($aktive[(int) $value])) { $db->query('INSERT INTO ' . DB_PRE . 'ecp_wars_teilnehmer (warID, userID) VALUES (' . $id . ', ' . (int) $value . ')'); message_send($value, 0, $text['content2'], str_replace('{link}', '<a href="' . SITE_URL . '?section=clanwars&action=nextwar&id=' . $id . '">' . SITE_URL . '?section=clanwars&action=nextwar&id=' . $id . '</a>', $text['content']), 0, 1); send_email($db->result(DB_PRE . 'ecp_user', 'email', 'ID = ' . (int) $value), $text['content2'], str_replace('{link}', SITE_URL . '?section=clanwars&action=nextwar&id=' . $id, $text['content']), 1); } else { $aktive[(int) $value] = false; } } } else { foreach ($players as $value) { if (!isset($aktive[(int) $value])) { $db->query('INSERT INTO ' . DB_PRE . 'ecp_wars_teilnehmer (warID, userID) VALUES (' . $id . ', ' . (int) $value . ')'); } else { $aktive[(int) $value] = false; } } } } foreach ($aktive as $key => $value) { if ($value == true) { $db->query('DELETE FROM ' . DB_PRE . 'ecp_wars_teilnehmer WHERE userID = ' . $key . ' AND warID = ' . $id); } } header1('?section=admin&site=clanwars'); } } } else { $data = $db->fetch_assoc('SELECT `tID`, `mID`, `gID`, `datum`, `xonx`, `hinweise`, `server`, `pw`, meldefrist, livestream, `oID`, `matchlink`, `resultbylocations`, `oppname`, `oppshort`, `homepage`, `country` FROM ' . DB_PRE . 'ecp_wars LEFT JOIN ' . DB_PRE . 'ecp_wars_opp ON (oppID = oID) WHERE warID = ' . $id); $tpl = new smarty(); foreach ($data as $key => $value) { $tpl->assign($key, $value); } $tpl->assign('opps', get_opps($data['oID'])); $tpl->assign('countries', form_country($data['country'])); $tpl->assign('games', get_games_form($data['gID'])); $tpl->assign('teams', get_teams_form($data['tID'])); $tpl->assign('matchtype', get_matchtype_form($data['mID'])); $tpl->assign('lang', get_languages(json_decode($data['hinweise'], true))); $tpl->assign('func', 'editnext&id=' . $id); $tpl->assign('datum', date('Y-m-d H:i:s', $data['datum'])); $tpl->assign('meldefrist', date('Y-m-d H:i:s', $data['meldefrist'])); $xonx = explode('on', $data['xonx']); $tpl->assign('xonx1', $xonx[0]); $tpl->assign('xonx2', $xonx[1]); $result = $db->query('SELECT `scoreID`, `lID`, `ownscore`, `oppscore` FROM ' . DB_PRE . 'ecp_wars_scores WHERE wID = ' . $id . ' ORDER BY scoreID ASC'); $maps = array(); while ($row = mysql_fetch_assoc($result)) { $row['i'] = @++$i; $db->query('SELECT locationID, locationname FROM ' . DB_PRE . 'ecp_wars_locations WHERE gID = ' . $data['gID']); while ($subrow = $db->fetch_assoc()) { $subrow['locationID'] == $row['lID'] ? $sub = 'selected="selected"' : ($sub = ''); @($row['maps'] .= '<option ' . $sub . ' value="' . $subrow['locationID'] . '">' . htmlspecialchars($subrow['locationname']) . '</option>'); } $maps[] = $row; } $tpl->assign('maps', $maps); $db->query('SELECT userID FROM ' . DB_PRE . 'ecp_wars_teilnehmer WHERE warID = ' . $id); $players = array(); while ($row = $db->fetch_assoc()) { $players[] = $row['userID']; } $tpl->assign('members', get_cw_members($players)); ob_start(); $tpl->display(DESIGN . '/tpl/admin/clanwars_next.html'); $content = ob_get_contents(); ob_end_clean(); main_content(CLANWARS_EDIT, $content, '', 1); } } else { table(ERROR, NO_ADMIN_RIGHTS); } }
$db->query('SELECT * FROM ' . DB_PRE . 'ecp_texte WHERE name = "NEW_FIGHTUS"'); $text = array(); while ($row = $db->fetch_assoc()) { $text[$row['lang']] = $row; } while ($row = mysql_fetch_assoc($result)) { $search = array('{username}', '{from_clan}', '{id}'); $replace = array(strsave($row['username']), strsave(htmlspecialchars($_POST['clanname'])), $id); if (!isset($text[$row['country']])) { $row['country'] = DEFAULT_LANG; } message_send($row['userID'], 0, $text[$row['country']]['content2'], str_replace($search, $replace, $text[$row['country']]['content']), 0, 1); } unset($_SESSION['captcha']); table(INFO, FIGHTUS_REQUEST_SEND); } } } else { $tpl = new smarty(); $tpl->assign('games', get_games_form('', 0)); $tpl->assign('teams', get_teams_form('', 0)); $tpl->assign('liggen', get_matchtype_form('', 0)); ob_start(); $tpl->display(DESIGN . '/tpl/fightus/fightus.html'); $content = ob_get_contents(); ob_end_clean(); main_content(FIGHTUS, $content, '', 1); } } else { echo table(ACCESS_DENIED, NO_ACCESS_RIGHTS); }