function section_news_displayNews($adm, $lnk, $num) { section_news_doSelectForm($lnk, $num); if ($adm) { echo '<center><BR>' . htmlURLbutton('ADD News', 'newsadmin', 'id=0', ADMBUT); } $res = sqlQuery('select *, unix_timestamp(newsdate) as utime from ' . TBL_NEWS . " order by newsdate desc limit {$num}"); echo "<table align=center border=0 cellspacing=0 cellpadding=1>"; while ($obj = mysql_fetch_object($res)) { if ($obj->utime > $_SESSION['last_login']) { echo '<TR class=new>'; } else { echo '<TR>'; } echo '<td><i>' . $obj->newsdate . '</i></td><td align=right>'; if ($adm) { htmlMiniTable(array("<i>By:</i>{$obj->authorname}", htmlURLbutSmall('Edit', 'newsadmin', "id={$obj->id}", ADMBUT))); } else { echo "<i>By:</i> {$obj->authorname}"; } echo '</td></tr><TR><TD colspan=2>' . text_disp($obj->text) . '</td></tr> <tr><td colspan=2 align=center><hr></td></tr>'; } echo "</table>"; }
function section_links_displayLinks($adm) { if ($adm) { echo '<center>' . htmlURLbutton('ADD New Link', 'linkadmin', 'id=0', ADMBUT) . '</center><BR>'; } $res = mysql_query('select * from ' . TBL_LINKS . ' order by ord, name'); echo "<table align=center width=95% border=0 cellspacing=0 cellpadding=4>"; $row = 0; while ($obj = mysql_fetch_object($res)) { $c = $row++ % 2 ? 'rowodd' : 'roweven'; echo "<tr class={$c}><td width=25%><a href=\"{$obj->url}\" target=\"_blank\">{$obj->name}</a></td>\n <td>" . text_disp($obj->comment) . '</td>'; if ($adm) { echo "<TD>[{$obj->ord}]</td><TD>" . htmlURLbutSmall('Edit', 'linkadmin', "id={$obj->id}", ADMBUT) . '</td>'; } echo '</tr>'; } echo "</table>"; }
function section_teaminfo() { require_once 'lib/common.php'; $s_teamid = $_SESSION['teamid']; $s_logedin = isAuthenticated(); $s_level = $_SESSION['level']; $s_playerid = $_SESSION['playerid']; $id = addslashes($_GET['id']); $res = mysql_query("SELECT name, comment, leader, logo, status, score, \n unix_timestamp(status_changed) as status_changed, unix_timestamp(created) as ucreated\n FROM l_team WHERE id='{$id}'"); $team = mysql_fetch_object($res); if (!$team) { echo '<BR><CENTER>Specified team does not exist<BR>'; return; } echo '<TABLE align=center><TR><TD>' . htmlURLbutton('Opponent summary', 'oppsumm', "id={$id}") . '</td>'; // Join this team if opened, and if we are logged and not belonging to any team if ($s_logedin && !$s_teamid && $members < 20 && $team->status == "opened") { echo '<TD>' . htmlURLbutton('Join Team', 'jointhisteam', "id={$id}") . '</td>'; } // Send a message to all the team members if ($s_logedin && $team->status != 'deleted') { echo '<TD>' . htmlURLbutton('Send BZmessage', 'sendmessage', "tid={$id}") . '</td>'; } echo '</tr></table>'; if ($team->status == 'deleted') { echo '<div class=feedback>'; if ($team->status_changed) { echo "<br><center>This team was deleted on " . gmdate('Y-m-d', $team->status_changed) . "</center>"; } else { echo "<br><center>This team is deleted.</center>"; } echo '</div>'; } echo '<BR><table align=center border=0 cellspacing=0 cellpadding=1> <tr><td class=teamName align=center>' . $team->name . '<BR></td></tr>'; // Logo if any if ($team->logo != "") { echo '<tr><td align=center> <table><TR><TD bgcolor=white><img src="' . $team->logo . '"></td></tr></table> <hr></td></tr>'; } // Ratings $act45 = teamActivity($id, 45); $act90 = teamActivity($id, 90); echo '<tr><td> <TABLE align=center> <TR><TD width=50% align=right>Created:</td><td width=10></td><td width=50%>' . gmdate('Y-m-d', $team->ucreated) . '</td></tr> <TR><TD align=right>Rating:</td><td></td><td>' . displayRating($id) . '</td></tr> <TR><TD align=right>Activity:</td><TD></td><td>' . sprintf('%1.2f / %1.2f', $act45, $act90) . '</td></tr> <TR><TD colspan=3 align=center> Average number of games played per day<BR> <NOBR>(exponential moving average over last 45 / 90 days)</nobr></td></tr>'; echo '</td></td></table></td></tr>'; // Matches statistics $sta1 = mysql_fetch_object(mysql_query("select ifnull(sum(if(score1>score2,1,0)),0) win,\n ifnull(sum(if(score1=score2,1,0)),0) draw,\n ifnull(sum(if(score1<score2,1,0)),0) loss\n from " . TBL_MATCH . " where team1={$id}")); $sta2 = mysql_fetch_object(mysql_query("select ifnull(sum(if(score2>score1,1,0)),0) win,\n ifnull(sum(if(score2=score1,1,0)),0) draw,\n ifnull(sum(if(score2<score1,1,0)),0) loss\n from " . TBL_MATCH . " where team2={$id}")); $win = $sta1->win + $sta2->win; $draw = $sta1->draw + $sta2->draw; $loss = $sta1->loss + $sta2->loss; echo "<tr><td align=center><hr>\n <table border=0 cellspacing=0 cellpadding=0 align=center><tr>\n <td align=center>Wins</td><td align=center> Draws </td><td align=center>Losses</td></tr><tr>\n <td align=center>{$win}</td><td align=center>{$draw}</td><td align=center>{$loss}</td>\n </tr></table>\n <hr></td></tr>"; // Comment if any if ($team->comment != "") { echo '<tr><td><ul>' . nl2br($team->comment) . '</ul><hr></td></tr>'; } // Players list $i = 0; if (SHOW_PLAYER_ACTIVE > 0) { $activeDays = SHOW_PLAYER_ACTIVE; } else { $activeDays = 0; } $res = mysql_query("select id, callsign, comment, status, C.flagname, \n last_login > subdate(now(), INTERVAL {$activeDays} DAY) as active\n from l_player\n left join bzl_countries C on country = C.numcode\n where team=" . $id . "\n order by active desc,callsign"); $members = 0; echo '<TR><TD><table border=0 cellspacing=0 cellpadding=0 align=center>'; while ($obj = mysql_fetch_object($res)) { $members++; if (++$i & 1) { $cl = "rowEven"; } else { $cl = "rowOdd"; } echo "<tr class='{$cl}' valign=middle>"; echo "<TD align=right><a href='index.php?link=playerinfo&id={$obj->id}'>{$obj->callsign}</a></td><TD>"; if ($obj->id == $team->leader) { echo ' <img TITLE="Team Leader" src="' . THEME_DIR . 'leader.gif">'; } echo '</td><TD>'; if ($obj->active) { echo ' <img TITLE="Active player (has logged into this site recently)" src="' . THEME_DIR . 'active.gif">'; } echo '</td><TD width=10></td>'; echo '<TD>' . smallflag($obj->flagname) . '</td>'; if ($s_logedin && (isFuncAllowed('teamadmin::edit_any_team') || $s_playerid == $team->leader)) { if ($obj->id != $team->leader) { // Link to ban a player from a team echo '<td align=center>' . htmlURLbutSmall('BAN', 'banplayer', "playerid={$obj->id}&teamid={$id}&f_ok_x=2", ADMBUT) . '</form></td></tr>'; } else { echo '<td> </td></tr>'; } } else { echo '<td> </td></tr>'; } echo "\n"; } echo '</td></tr></table>'; // Show last fights $sql = "SELECT t1.id, t1.name, f.score1, t2.id, t2.name, f.score2, f.tsactual, unix_timestamp(f.tsactual) tstamp_ts \n" . "FROM " . TBL_MATCH . " f, l_team t1, l_team t2 " . "WHERE (f.team1 = '{$id}' OR f.team2 = '{$id}') " . " AND f.team1 = t1.id " . " AND f.team2 = t2.id " . "ORDER BY f.tsactual DESC " . "LIMIT 11 "; $res = sqlQuery($sql); $tmp = ''; $count = 0; while ($row = mysql_fetch_array($res)) { $count++; if ($count < 11) { if (isset($_SESSION['last_login']) && $_SESSION['last_login'] < $row[7]) { $new1 = "<font color=\"red\">"; $new2 = "</font>"; } else { $new1 = ''; $new2 = ''; } if ($count % 2) { $cl = "rowEven"; } else { $cl = "rowOdd"; } $tmp .= "<tr class=\"{$cl}\">"; $tmp .= '<td align="right">' . $new1 . $row[6] . $new2 . '</td>'; if ($row[0] != $id) { $oppid = $row[0]; $oppname = stripslashes($row[1]); $oppscore = $row[2]; $teamscore = $row[5]; } else { $oppid = $row[3]; $oppname = stripslashes($row[4]); $oppscore = $row[5]; $teamscore = $row[2]; } $tmp .= "<td>{$new1}"; $oppname = '<a href="index.php?link=teaminfo&id=' . $oppid . '&' . SID . '">' . $new1 . $oppname . $new2 . '</a>'; if ($oppscore < $teamscore) { $tmp .= "<b>Won</b> against {$oppname}"; } elseif ($oppscore > $teamscore) { $tmp .= "<b>Lost</b> against {$oppname}"; } else { $tmp .= "<b>Tie</b> against {$oppname}"; } $tmp .= " ({$row[2]} - {$row[5]})"; $tmp .= "{$new2}</td>"; $tmp .= "</tr>\n"; } } echo '<tr>'; echo '<td align=center> <br><b>'; if ($count == 1) { echo 'Last match'; } else { if ($count == 11) { echo 'Last 10 matches, view them all <a href="index.php?link=fights&id=' . $id . '&' . SID . '">here</a>'; } elseif ($count == 0) { echo "No matches played"; } else { echo "Last {$count} matches"; } } echo '</b><BR><BR></td></tr><TR><TD>'; echo "<table align=center border=0>{$tmp}</table>"; // Or... edit your team if you are a leader or ad admin, or with a password if you are a member // Team members can't change the password, though... // Unless ofcause the team is deleted if ($team->status == 'deleted') { if ($team->status_changed) { echo "<br><center>This team is deleted as of " . gmdate('Y-m-d', $team->status_changed) . "</center>"; } else { echo "<br><center>This team is deleted.</center>"; } } else { if ($s_logedin && (isFuncAllowed('teamadmin::edit_any_team') || $s_teamid == $id)) { if (!isFuncAllowed('teamadmin::edit_any_team') && $s_playerid != $team->leader) { // Team member, need password echo '<form method=post> <input type=hidden name=link value=teamadmin> <input type=hidden name=id value=' . $id . '> <br><center>Enter team password <input type=password size=8 maxlength=8 name=f_password> and ' . htmlFormButton('Edit Team', 'f_edit_x') . ' </center></form>'; } else { $invites = sqlQuery("SELECT *, l_player.callsign FROM bzl_invites, l_player\n WHERE teamid={$id} AND expires > NOW() AND bzl_invites.playerid = l_player.id"); if (mysql_num_rows($invites) > 0) { echo '<BR><HR>Invitations currently active:<BR><TABLE>'; while ($row = mysql_fetch_object($invites)) { echo '<TR><TD width=25></td><TD>' . playerLink($row->playerid, $row->callsign) . "</td><TD width=10></td><TD>(expires: {$row->expires})</td></tr>"; } echo '</table><HR>'; } // Team leader or admin, let's go echo '<center><BR> ' . htmlURLbutton('Edit Team', 'teamadmin', "id={$id}", ADMBUT) . ' <BR> ' . htmlURLbutton('Dismiss Team', 'dismissteam', "id={$id}", ADMBUT); } } } }
function section_teams() { require_once "lib/common.php"; $s_logedin = isAuthenticated(); $s_teamid = $_SESSION['teamid']; $tacts = teamActivity(null, 45); echo '<BR>'; $res = sqlQuery("\n SELECT l_team.id, l_team.name, l_team.logo, l_team.score, \n player2.callsign leader, player2.id leaderid, \n l_team.status, count(distinct l_player.callsign) numplayers,\n l_team.active = 'yes' activeteam, l_team.matches, l_team.matches > 0 sorter\n FROM l_team, l_player player2, l_player\n WHERE player2.id = l_team.leader \n AND l_team.status != 'deleted' \n AND l_player.team = l_team.id\n GROUP BY l_team.name, l_team.leader, l_team.status, l_team.score\n ORDER BY sorter desc, activeteam desc, l_team.score desc, l_team.name"); echo "<table align=center border=0 cellspacing=0 cellpadding=2>\n <tr class=tabhead align=center>\n <td>Name</td><td>Leader</td><td colspan=2>Members</td>\n <td colspan=2>Rating</td><td>Join</td><TD>Activity</td></tr>"; $separated = 0; $rownum = 0; while ($obj = mysql_fetch_object($res)) { ++$rownum; if ($obj->activeteam == 0 && $separated == 0) { $separated = 1; echo '<tr><td align=center colspan=10><hr><b>Inactive Teams</b></td></tr>'; $rownum = 1; } if ($obj->sorter == 0 && $separated == 1) { $separated = 2; echo '<tr><td align=center colspan=10><hr><b>Did not play any match</b></td></tr>'; $rownum = 1; } if ($obj->logo != '') { $logo = '<img src="' . THEME_DIR . 'islogo.gif">'; } else { $logo = ' '; } if ($s_teamid == $obj->id) { $c = 'myteam'; } elseif ($obj->status == 'deleted') { $c = 'deletedteam'; } else { if ($rownum % 2) { $c = 'rowOdd'; } else { $c = 'rowEven'; } } echo "<TR class='{$c}' valign=middle>"; $teamname = substr($obj->name, 0, 35); $act = $tacts[$obj->id]; echo '<td><a href="index.php?link=teaminfo&id=' . $obj->id . '">' . $teamname . '</a></td> <td><a href="index.php?link=playerinfo&id=' . $obj->leaderid . '&' . SID . '">' . $obj->leader . '</a></td> <td align=center>' . $obj->numplayers . '</td><td>' . $logo . '</td> <td align=left>' . displayRating($obj->id) . '</td>'; if ($separated) { echo '<td> </td>'; } else { echo '<td align=center>(' . $obj->matches . ')</td>'; } // Print join or joinnot, not forgetting we may already belong to a team echo '<TD align=left>'; if ($s_logedin) { if (!$s_teamid) { switch ($obj->status) { case 'opened': if ($obj->numplayers < 20) { echo htmlURLbutSmall('JOIN', 'jointeam', "id={$obj->id}") . '</td>'; } else { echo ' [Closed]</td>'; } break; case 'closed': echo ' [Closed]</td>'; break; default: echo 'Deleted.</td>'; break; } } else { if ($s_teamid == $obj->id) { // if( $_SESSION['playerid'] != 2074 ) // Dont allow Admir to leave (SC request) echo htmlURLbutSmall('Abandon', 'leaveteam', "id={$obj->id}&leader={$obj->leaderid}") . '</td>'; } elseif ($obj->status == 'closed') { echo ' [Closed]</td>'; } elseif ($obj->status == 'deleted') { echo 'deleted.</td>'; } else { echo '</td>'; } } } elseif ($obj->status == 'closed') { echo ' [Closed]</td>'; } else { echo '</td>'; } $act = sprintf('%1.2f', $tacts[$obj->id]); echo "<TD align=center>{$act}</td>"; echo "</tr>"; } echo "</table>"; // Create a new team, if logged in and not a team member if ($s_logedin && !$s_teamid) { echo '<br><center> ' . htmlURLbutton('Create New Team', 'createteam', null) . '</center>'; } }
function section_bzforums() { require_once 'lib/common.php'; $allowDelete = isFuncAllowed('post_delete'); $allowNew = isFuncAllowed('post_new'); $allowReply = isFuncAllowed('post_reply'); $allowEdit = isFuncAllowed('post_edit'); $allowLock = isFuncAllowed('topic_lock'); $allowSticky = isFuncAllowed('topic_sticky'); $allowTDelete = isFuncAllowed('topic_delete'); $allowViewDeleted = isFuncAllowed('topic_view_deleted'); $showRoles = isFuncAllowed('show_roles'); $POSTSPERPAGE = 10; $link = 'bzforums'; $utcNOW = gmdate("Y-m-d H:i:s"); // Variables: // top = which post is first on the page i think $vars = array('top', 'threadid', 'forumid', 'id', 'action'); foreach ($vars as $var) { ${$var} = $_REQUEST[$var]; } // Get and print the forum title if (isset($forumid)) { $row = mysql_fetch_object(mysql_query("select title, status from l_forum where id={$forumid}")); echo 'Forum: <a href="index.php?link=' . $link . '&' . SID . '"> <font size=+1>BZforums</font></a><font size=+1><i> / </i></font> <a href="index.php?link=' . $link . '&forumid=' . $forumid . '&' . SID . '"> <font size=+1>' . $row->title . '</font></a><hr>'; if ($row->status != 'Open') { print "This forum is not accessible. Sorry"; return; } } // check if we need to change permissions (eg, disallow reply/post for locked topics) if (isset($threadid)) { $threadid = intval($threadid); $row = mysql_fetch_object(mysql_query("select status, is_sticky from l_forumthread where id={$threadid}")); if ($row->status == 'locked' && !isAdmin()) { $allowNew = false; $allowReply = false; } elseif ($row->status == 'deleted' && !$allowViewDeleted) { errorPage('This topic is deleted'); return; } $threadstatus = $row->status; $threadsticky = $row->is_sticky; } // Perform deletion if ($allowDelete && $action == 'delete2' && $id != '') { $id = intval($id); mysql_query("DELETE FROM l_forummsg WHERE msgid = '{$id}' LIMIT 1") or die(mysql_error()); // Check if there is any message left for that thread $threadid = intval($threadid); $res = mysql_query("SELECT count(1) FROM l_forummsg WHERE threadid = '{$threadid}'") or die(mysql_error()); $row = mysql_fetch_row($res); if ($row[0] == 0) { // No messages in thread: deleting thread - jumo to threadlist mysql_query("DELETE FROM l_forumthread WHERE id = '{$threadid}' LIMIT 1") or die(mysql_error()); header("Location: index.php?link=bzforums&forumid={$forumid}"); exit; } $action = ''; } elseif ($action == 'lock') { $threadid = intval($threadid); if (!$allowLock) { errorPage("You are not allowed to lock topics"); return; } mysql_query("UPDATE l_forumthread SET status = 'locked', status_by = {$_SESSION['playerid']}, \n status_at = '{$utcNOW}' WHERE id = '{$threadid}' and status != 'locked' LIMIT 1") or die(mysql_error()); $action = ''; $threadstatus = 'locked'; } elseif ($action == 'revive') { $threadid = intval($threadid); if (!$allowLock && $threadstatus == 'locked') { errorPage("You are not allowed to unlock topics"); return; } if (!$allowTDelete && $threadstatus == 'deleted') { errorPage("You are not allowed to undelete topics"); return; } mysql_query("UPDATE l_forumthread SET status = 'normal', \n status_by = {$_SESSION['playerid']}, status_at = '{$utcNOW}' WHERE id = '{$threadid}' LIMIT 1") or die(mysql_error()); $action = ''; $threadstatus = 'normal'; } elseif ($action == 'deletetopic') { $threadid = intval($threadid); if (!$allowTDelete) { errorPage("You are not allowed to delete topics"); return; } mysql_query("UPDATE l_forumthread SET status = 'deleted', status_by = {$_SESSION['playerid']}, \n status_at = '{$utcNOW}' WHERE id = '{$threadid}' and status != 'deleted' LIMIT 1") or die(mysql_error()); $action = ''; $threadstatus = 'deleted'; } elseif ($action == 'sticky') { $threadid = intval($threadid); if (!$allowSticky) { errorPage("You are not allowed to use sticky"); return; } mysql_query("UPDATE l_forumthread SET is_sticky = 1 WHERE id = '{$threadid}' LIMIT 1") or die(mysql_error()); $action = ''; $threadsticky = 1; } elseif ($action == 'unsticky') { $threadid = intval($threadid); if (!$allowSticky) { errorPage("You are not allowed to use sticky"); return; } mysql_query("UPDATE l_forumthread SET is_sticky = 0 WHERE id = '{$threadid}' LIMIT 1") or die(mysql_error()); $action = ''; $threadsticky = 0; } elseif ($action == 'new' || $action == 'reply' || $action == 'edit') { if ($action == 'new' && !$allowNew) { errorPage("You are not allowed to post new topics"); return; } elseif ($action == 'reply' && !$allowReply) { errorPage("You are not allowed to reply"); return; } elseif ($action == 'edit' && !$allowEdit) { errorPage("You are not allowed to edit"); return; } echo '<form method=post name="post" action="index.php">' . SID_FORM; echo '<input type=hidden name=threadid value=' . $threadid . '>'; echo '<input type=hidden name=link value="' . $link . '">'; echo '<input type=hidden name=forumid value=' . $forumid . '>'; echo '<input type=hidden name=id value=' . $id . '>'; echo '<input type=hidden name=top value=' . $top . '>' . snFormInit(); echo '<table border=0 align=center cellspacing=0 cellpadding=0>'; echo '<tr class=tablehead><td colspan=2 align=center>'; if ($action == 'new') { echo 'New Topic'; } elseif ($action == 'reply') { echo 'New Reply'; } else { echo "Edit message"; } echo '</td></tr>'; echo '<tr><td>Subject: </td><td>'; if ($action == 'new') { print '<input type=text name=subject size=50 maxlength=80>'; } else { $row = mysql_fetch_object(mysql_query("select subject from l_forumthread where id={$threadid}")); echo '<i>' . $row->subject . '</i>'; } print '</td></tr>'; echo '<tr><td valign="top">Message</td><td>'; if ($action == 'edit') { $id = intval($id); $row = mysql_fetch_object(mysql_query("select msg from l_forummsg where msgid={$id}")); print '<textarea cols=50 rows=10 name=forummsg>' . htmlspecialchars($row->msg) . '</textarea>'; } else { print '<textarea cols=50 rows=10 name=forummsg></textarea>'; } print '</td></tr>'; // Form buttons echo '<tr><td colspan=2 align=center>' . htmlFormButton('OK', 'save_' . $action) . ' ' . htmlFormButton('Cancel', 'cancel', CLRBUT) . '</td></tr>'; print '<tr><td>Smiley:</td><td align="middle">'; $res = mysql_query("select image, code from l_smiley GROUP BY image") or die(mysql_error()); while ($row = mysql_fetch_object($res)) { print '<a href="#" onclick="javascript:document.post.forummsg.value += \' ' . $row->code . '\'"><img border=0 src="' . THEME_DIR . 'smilies/' . $row->image . '" border=0/></a> '; } print "</tr>"; echo '</table></form>'; } elseif (isset($_POST['save_new'])) { $forummsg = section_bzforums_stripExtraLF($_POST['forummsg']); $subject = $_POST['subject']; // New topic if ($allowNew) { mysql_query("INSERT INTO l_forumthread (id,forumid,creatorid,subject) VALUES(0, {$forumid}, {$_SESSION['playerid']}, '" . $subject . "')") or die(mysql_error()); $threadid = mysql_insert_id(); mysql_query("insert into l_forummsg(msgid,threadid,fromid,msg,datesent) \n values(0, {$threadid}, {$_SESSION['playerid']}, '" . $forummsg . "', '{$utcNOW}')") or die(mysql_error()); session_refresh_all(); } else { errorPage("You are not allowed to post new topics"); return; } } elseif (isset($_POST['save_reply'])) { $forummsg = section_bzforums_stripExtraLF($_POST['forummsg']); if ($allowReply) { snCheck('bzforums', "forumid={$forumid}&threadid={$threadid}"); mysql_query("insert into l_forummsg(msgid,threadid,fromid,msg,datesent) \n values(0, {$threadid}, {$_SESSION['playerid']}, '" . $forummsg . "', '{$utcNOW}')"); session_refresh_all(); } else { errorPage("You are not allowed to reply"); return; } } elseif (isset($_POST['save_edit'])) { $forummsg = section_bzforums_stripExtraLF($_POST['forummsg']); if ($allowReply) { $id = intval($id); snCheck('bzforums', "forumid={$forumid}&threadid={$threadid}"); // mysql_query("UPDATE l_forummsg SET msg = '$forummsg' WHERE msgid = '$id'"); mysql_query("UPDATE l_forummsg SET msg = '{$forummsg}', status = 'edited', \n status_by = {$_SESSION['playerid']}, status_at = '{$utcNOW}' WHERE msgid = '{$id}'"); session_refresh_all(); } else { errorPage("You are not allowed to edit"); return; } } if (isset($threadid)) { // Display a thread // Control buttons // 06/28/2002: $POSTSPERPAGE posts/page max. if (!isset($top)) { $top = 0; $newtop = 0; } if ($top == "") { $top = 0; $newtop = 0; } if ($action == '') { echo '<TABLE align=right><TR>'; if ($allowReply && $threadstatus != 'deleted') { echo '<td>' . htmlURLbutton('Add Reply', $link, "forumid={$forumid}&threadid={$threadid}&action=reply&top={$top}") . '</td>'; } if ($allowLock && $threadstatus != 'locked') { echo '<td>' . htmlURLbutton('Lock topic', $link, "forumid={$forumid}&threadid={$threadid}&action=lock&top={$top}", ADMBUT) . '</td>'; } if ($allowTDelete && $threadstatus != 'deleted') { echo '<td>' . htmlURLbutton('Delete topic', $link, "forumid={$forumid}&threadid={$threadid}&action=deletetopic&top={$top}", ADMBUT) . '</td>'; } if ($allowLock && $threadstatus == 'locked' || $allowTDelete && $threadstatus == 'deleted') { echo '<td>' . htmlURLbutton('Revive topic', $link, "forumid={$forumid}&threadid={$threadid}&action=revive&top={$top}", ADMBUT) . '</td>'; } if ($allowSticky) { if ($threadsticky) { echo '<td>' . htmlURLbutton('Remove sticky', $link, "forumid={$forumid}&threadid={$threadid}&action=unsticky&top={$top}", ADMBUT) . '</td>'; } else { echo '<td>' . htmlURLbutton('Make sticky', $link, "forumid={$forumid}&threadid={$threadid}&action=sticky&top={$top}", ADMBUT) . '</td>'; } } echo '</tr></table><BR clear=all>'; } $temp = mysql_fetch_object(mysql_query("select count(msgid) num from l_forummsg where threadid={$threadid}")); $numpost = $temp->num; $numpages = floor(($numpost + $POSTSPERPAGE - 1) / $POSTSPERPAGE); $curpage = $top / $POSTSPERPAGE + 1; $res = sqlQuery("select msgid, msg, datesent, l_forummsg.status, status_at, l_player.id pid, \n player2.callsign as editedby, l_player.callsign, r.name as role\n from (l_forummsg, l_player, bzl_roles r)\n LEFT JOIN l_player player2 ON player2.id = status_by\n where threadid={$threadid}\n and fromid = l_player.id\n and l_player.role_id = r.id\n order by datesent\n limit {$top}, {$POSTSPERPAGE}"); // Table header $sub = mysql_fetch_object(mysql_query("select subject, status from l_forumthread where id={$threadid}")); echo '<table align=center border=1 cellspacing=0 cellpadding=1>'; if ($threadsticky) { $status = '<b>Sticky</b> '; } else { $status = ''; } if ($sub->status == 'locked') { $status .= '<b>Locked</b> '; } elseif ($sub->status == 'deleted') { $status .= '<b>Deleted</b> '; } echo '<tr class=tabhead><td colspan=3><font size=+1>' . $status . '<i>' . smileys($sub->subject) . '</i></font>'; // Display pages if multiple pages and not adding a post if ($numpages > 1 && !isset($addpost)) { echo '<div align=right>'; for ($i = 1; $i <= $numpages; $i++) { if ($i == $curpage) { echo $i . ' '; } else { $newtop = ($i - 1) * $POSTSPERPAGE; echo '<a href="index.php?link=' . $link . '&forumid=' . $forumid . '&threadid=' . $threadid . '&top=' . $newtop . '&' . SID . '">' . $i . '</a> '; } } echo '</div>'; } echo '</td></tr>'; echo '<tr class=tablehead><td>Author</td><td>Message</td></tr>'; $cf = 1; while ($row = mysql_fetch_object($res)) { echo '<tr class=forum' . $cf . '>'; echo '<td valign=top rowspan="' . ($allowDelete ? 2 : 1) . '"><a href="index.php?link=playerinfo&id=' . $row->pid . '&' . SID . '">' . $row->callsign . '</a>'; if ($showRoles) { print " <small>({$row->role})</small>"; } echo '<br><font size=-2>(' . $row->datesent . ')</font></td>'; $msgbody = smileys(wordwrap(nl2br(htmlspecialchars($row->msg)), 75, " ", true)); // DMP 19oct2007: Added wordwrap to break annoyingly long lines $highlight = false; // Setup available commands // Comamnds: If a ALL key exists, it will be the only one showed, otherwise all elements is shown $commands = array(); if ($allowDelete) { if ($action == 'delete' && $id == $row->msgid) { $highlight = true; $commands['ALL'] = 'Confirmation: ' . htmlLink('Delete', 'bzforums', 'action=delete2&id=' . $row->msgid . '&forumid=' . $forumid . '&threadid=' . $threadid . '&top=' . $top) . ' OR ' . htmlLink('Cancel?', 'bzforums', 'id=' . $row->msgid . '&forumid=' . $forumid . '&threadid=' . $threadid . '&top=' . $top); } else { $commands[] = htmlLink('[delete]', 'bzforums', 'action=delete&id=' . $row->msgid . '&forumid=' . $forumid . '&threadid=' . $threadid . '&top=' . $top); } } if ($allowEdit) { $commands[] = htmlLink('[edit]', 'bzforums', 'action=edit&id=' . $row->msgid . '&forumid=' . $forumid . '&threadid=' . $threadid . '&top=' . $top); } if ($highlight) { echo '<td valign=top><font color=red>' . $msgbody . '</font>'; } else { echo '<td valign=top>' . $msgbody; } if ($row->status == 'edited') { echo "<BR><small>(Message edited by {$row->editedby} at: {$row->status_at})</small>"; } echo '</td></tr>'; // Show commands if any if (count($commands)) { // if action is set dont show i$commands unless it contains 'ALL' if ($action != '' && isset($commands['ALL']) || $action == '') { echo '<tr><td align="right" colspan="2" valign=top><small>' . (isset($commands['ALL']) ? $commands['ALL'] : join(' ', $commands)) . '</small></td></tr>'; } else { echo '<tr></tr>'; } } $cf = 3 - $cf; } echo '</table>'; if ($curpage < $numpages) { echo '<CENTER><BR>' . htmlURLbutSmall("NEXT Page", $link, "forumid={$forumid}&threadid={$threadid}&top=" . $curpage * $POSTSPERPAGE); } } else { if (isset($forumid) && !isset($addpost)) { // Display specific forum // Control buttons if ($allowNew) { echo '<div align=right>' . htmlURLbutton('New Topic', $link, "forumid={$forumid}&action=new&top={$top}") . '</div>'; } if ($allowViewDeleted) { $viewClause = ''; } else { $viewClause = "AND l_forumthread.status != 'deleted' "; } $res = mysql_query("select l_forumthread.id,l_forumthread.subject, l_player.id pid, \n l_player.callsign, max(l_forummsg.datesent) ds, \n unix_timestamp(max(l_forummsg.datesent)) datesent_ts,\n l_forumthread.status, \n l_forumthread.status_at,\n splayer.callsign as status_by, l_forumthread.is_sticky\n from (l_forumthread, l_forummsg, l_player, l_player l_player2)\n left join l_player splayer ON (splayer.id = l_forumthread.status_by)\n where l_forumthread.forumid={$forumid}\n and l_forumthread.creatorid = l_player.id\n {$viewClause}\n and l_forumthread.id = l_forummsg.threadid\n and l_player2.id = l_forummsg.fromid\n group by l_forumthread.id, l_forumthread.subject, l_player.id, l_player.callsign\n order by l_forumthread.is_sticky DESC, ds desc") or die(mysql_error()); // Table header echo '<table align=center border=1 cellspacing=0 cellpadding=1>'; echo '<tr class=tabhead><td width=50%>Topic</td><td align=center>Replies</td><td align=center>Last Comment</td><td align=center>Started by</td></tr>'; while ($row = mysql_fetch_object($res)) { // Get the last author for this topic $la = mysql_fetch_object(mysql_query("select l_player.id pid, l_player.callsign\n from l_player, l_forummsg\n where threadid = {$row->id}\n and fromid = l_player.id\n order by datesent desc\n limit 0, 1")); $nr = mysql_fetch_object(mysql_query("select count(*)-1 num\n from l_forummsg\n where threadid = " . $row->id)); echo '<tr><td>'; if ($row->is_sticky == 1) { print '<b>STICKY</b> '; } if ($row->status == 'locked') { echo '<b>LOCKED</b>; '; } elseif ($row->status == 'deleted') { echo '<b>DELETED</b>; '; } echo '<a href="index.php?link=' . $link . '&forumid=' . $forumid . '&threadid=' . $row->id . '&' . SID . '">'; if (empty($row->subject)) { $row->subject = '(no subject)'; } if (isset($_SESSION['last_login']) && $_SESSION['last_login'] < $row->datesent_ts) { echo '<font color="red"><b>' . smileys($row->subject) . '</b></font></a>'; } else { echo smileys($row->subject) . '</a>'; } $numpages = floor(($nr->num + 1 + $POSTSPERPAGE - 1) / $POSTSPERPAGE); if ($numpages > 1) { echo ' (<img src="' . THEME_DIR . '/multipage.gif"> '; for ($i = 2; $i <= $numpages; $i++) { $t = ($i - 1) * 10; echo '<a href="index.php?link=' . $link . '&top=' . $t . '&forumid=' . $forumid . '&threadid=' . $row->id . '&' . SID . '">' . $i . '</a> '; } echo ')'; } if ($row->status != 'normal') { if (!$row->status_by) { $row->status_by = 'SYSTEM'; } echo "<br /><small>by {$row->status_by} at {$row->status_at}</small>"; } echo '</td> <td align=center>' . $nr->num; echo '</td> <td align=center>' . $row->ds . '<br>by <a href="index.php?link=playerinfo&id=' . $la->pid . '&' . SID . '">' . $la->callsign . '</a></td> <td align=center><a href="index.php?link=playerinfo&id=' . $row->pid . '&' . SID . '">' . $row->callsign . '</a></td> </tr>'; } echo '</table>'; } elseif ($action == '') { // Display forums list $res = mysql_query("select l_forum.id, l_forum.title, ifnull(max(l_forummsg.datesent),'n/a') md, count(l_forummsg.msgid) num,\n unix_timestamp(max(l_forummsg.datesent)) as datesent_ts\n from l_forum \n left join l_forumthread on (l_forum.id = l_forumthread.forumid AND l_forumthread.status != 'deleted')\n left join l_forummsg on l_forumthread.id = l_forummsg.threadid\n where l_forum.status = 'open'\n group by l_forum.id, l_forum.title\n order by title") or die(mysql_error()); echo '<table align=center border=0 cellspacing=0 cellpadding=1> <tr class=tabhead><td>Forums</td><td align=right># Posts</td><td align=center>Last Comment</td></tr>'; while ($row = mysql_fetch_object($res)) { echo '<tr><td><a href="index.php?link=' . $link . '&forumid=' . $row->id . '&' . SID . '">'; if (isset($_SESSION['last_login']) && $_SESSION['last_login'] < $row->datesent_ts) { echo "<font color=\"red\">" . $row->title . "</font>"; } else { echo $row->title; } echo '</a></td><td align=center>' . $row->num . '</td><td align=center>' . $row->md . '</td></tr>'; } echo '</table>'; } } }
function section_fights() { //$_SESSION['new_match'] = 0; if (isset($_GET['days'])) { $numdays = $_GET['days']; } else { $numdays = DEFAULTDAYS; } if (isset($_GET['id'])) { $teamid = $_GET['id']; } else { $teamid = -1; } if (isset($_GET['season_id']) && ENABLE_SEASONS) { $season_id = $_GET['season_id']; $numdays = null; } else { $season_id = -1; } if (isFuncAllowed('entermatch::edit_match') || isFuncAllowed('entermatch::delete_match')) { $admin = true; } if (isset($_GET['det'])) { $detail = $_GET['det']; } if (!isFuncAllowed('match_detail')) { $detail = 0; } if ($admin) { $utFreeze = section_fights_queryGetFreezeDate(); } $qwhere = ''; if ($teamid >= 0 || $numdays != 0 || $season_id > -1) { $qwhere = "WHERE "; $and = false; if ($teamid >= 0) { $qwhere = 'WHERE (l_team1.id = \'' . intval($_GET['id']) . '\' OR l_team2.id = \'' . intval($_GET['id']) . '\') '; } else { $qwhere = "WHERE "; } if ($numdays != 0) { if ($teamid >= 0) { $qwhere = $qwhere . "\nAND "; } $qwhere = $qwhere . "tsactual > DATE_SUB(NOW(), INTERVAL {$numdays} day)"; } if ($season_id > -1) { $qwhere = $qwhere . ($and ? "\nAND " : " ") . "season = {$season_id}"; $and = true; } } if ($detail == 0) { $res = sqlQuery($sql = "SELECT matchtab.id, tsactual, team1, l_team1.name name1, score1, team2, \n l_team2.name name2, score2, unix_timestamp(tsenter) as tsenter_unix,\n matchtab.id as matchid, l_team1.status stat1, l_team2.status stat2, season, matchtab.mlength\n FROM " . TBL_MATCH . " matchtab\n left join l_team l_team1 on l_team1.id = team1\n left join l_team l_team2 on l_team2.id = team2\n {$qwhere} ORDER BY tsactual desc"); } else { $res = sqlQuery("SELECT matchtab.id, tsactual, team1, l_team1.name name1, score1, team2, \n l_team2.name name2, score2, unix_timestamp(tsenter) as tsenter_unix,\n player1.callsign enteredby, tsenter, identer,\n player2.callsign editedby, tsedit, idedit, matchtab.id as matchid,\n oldrankt1, oldrankt2, newrankt1, newrankt2, l_team1.status stat1, l_team2.status stat2,\n\tmatchtab.mlength, season\n FROM " . TBL_MATCH . " matchtab\n left join l_team l_team1 on l_team1.id = team1\n left join l_team l_team2 on l_team2.id = team2\n left join l_player player1 on player1.id = identer\n left join l_player player2 on player2.id = idedit\n {$qwhere} ORDER BY tsactual desc"); } if ($season_id < 1) { section_fights_pageStartRegular($teamid, $numdays, $detail); } else { section_fights_pageStartSeasonal($season_id); } $show_mlength = count(explode(',', VALID_MLENGTH)) > 1; $numGames = 0; $last_season = -1; while ($obj = mysql_fetch_object($res)) { if (++$numGames % 2) { $cl = "rowOdd"; } else { $cl = "rowEven"; } $style = null; if (isset($_SESSION['last_login']) && $_SESSION['last_login'] < $obj->tsenter_unix) { $style = LINK_NEW; } if (ENABLE_SEASONS && $season_id < 1 && $last_season != $obj->season) { $season = sqlQuerySingle("SELECT startdate,enddate FROM l_season WHERE id = {$obj->season} AND id > 1"); if ($season) { echo "<tr style='background-color:darkred;color:white;'><td>Season: </td><td colspan=7>{$season->startdate} - {$season->enddate}</td></tr>"; } else { echo "<tr style='background-color:darkred;color:white;'><td colspan=8 align=\"center\">Off season</td></tr>"; } $last_season = $obj->season; } echo "<tr class=\"{$cl}\"><td><a name=\"{$obj->id}\" href=\"#{$obj->id}\">" . substr($obj->tsactual, 0, -3) . '</a>'; if ($show_mlength) { print " [{$obj->mlength}] "; } print '<td align=right><nobr> '; echo teamLink($obj->name1, "{$obj->team1}", $obj->stat1, $style); echo '</td><TD> <b>vs.</b> </td><TD>'; echo teamLink($obj->name2, "{$obj->team2}", $obj->stat2, $style); print ' </nobr><td align=center>' . $obj->score1 . '</td><td>-</td><td align=center>' . $obj->score2 . ' </td>'; print '<td>'; if ($admin && strtotime($obj->tsactual) > $utFreeze) { echo htmlURLbutSmall('EDIT', 'editmatch', "mid={$obj->matchid}", ADMBUT); } print "</td></tr>\n"; if ($detail != 0) { $enteredBy = '?'; if ($obj->identer != 0) { $enteredBy = $obj->enteredby; } echo "<TR class=\"{$cl}\"><td></td><td class=\"dim\" colspan=5 align=left>\n * Entered AT: {$obj->tsenter}, BY: {$enteredBy}</td></tr>\n"; if ($detail > 1 && $obj->idedit != 0) { echo "<TR class=\"{$cl}\"><td></td><td colspan=5 class=\"dim\" align=left>\n * Edited AT: {$obj->tsedit}, BY: {$obj->editedby}</td></tr>\n"; } if ($detail > 2 && $obj->oldrankt1 != 0) { echo "<TR class=\"{$cl}\"><td></td><td class=\"dim\" colspan=5 align=left>\n * {$obj->name1} rank changed from {$obj->oldrankt1} to {$obj->newrankt1}</td></tr>\n\n <TR class=\"{$cl}\"><td></td><td class=\"dim\" colspan=5 align=left>\n * {$obj->name2} rank changed from {$obj->oldrankt2} to {$obj->newrankt2}</td></tr>\n"; } } } echo "<TR><TD colspan=8><HR></td></tr>\n <TR><td></td><TD colspan=2>Number of matches shown:</td><td>{$numGames}</td><td colspan=4></td></tr>\n <TR><TD colspan=8><HR></td></tr>\n </td></tr></table>"; section_fights_pageEnd(); }