Hier der Link: The Kliq - Powered By EGL v3.0
Momentan sind alle Seiten innerhalb der Leaderboards für jeden sichtbar. Kann mir jemand sagen wie ich das ändern kann. Zum Beispiel wenn man als nicht eingelogter Benutzer auf den folgenden link The Kliq - Powered By EGL v3.0 sollte diser automatisch zu The Kliq - Powered By EGL v3.0 weitergeleitet werden.
Bei einem anderen Forum gab man mir folgenden Code aber ich habe kein blassen Schimmer wo ich den integrieren soll. Bin Anfänger auf dem Gebiet.
Code: Alles auswählen
<?php
if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true) {
header('Location: http://www.the-kliq.com/leaderboards/register.php');
exit();
}
?>
EDIT:
Ich habe leider absolut keine Ahnung von PHP bzw. wie man mit Sessions umgeht.
Ich poste jetzt einfach mal eine Datei die für Gäste nicht sichtbar sein soll. Das würde mir eventuell weiterhelfen wenn mir einer von euch den Code dort integriert. Dann weiss ich wie ich es bei den restlichen Dateien machen soll.
Link: The Kliq - Powered By EGL v3.0
Datei: tournament.php
Code: Alles auswählen
<?
/*=======================================================================================================================================*\
|| ##################################################################################################################################### ||
|| # Elite Gaming Ladder v3.x.x # ||
|| # --------------------------------------------------------------------------------------------------------------------------------- # ||
|| # Elite Ladders - Copyright ©2007-2009 XLed Limited. # ||
|| # Protected by International Copyright Law accross 163 countries. # ||
|| # # ||
|| # Pursuant to Title 17, United States Code, the owner of this copyright has filed a valid Certificate of Registration # ||
|| # with the United States Copyright Office. # ||
|| # # ||
|| # A copyrighted work may not be copied, reproduced, distributed or publicly displayed without the consent of the author # ||
|| # or copyright owner. Any unauthorized use of this code or any of its contents, in whole or in part, shall be considered # ||
|| # copyright infringement. It is illegal for anyone to violate any of the rights provided by the copyright laws to the # ||
|| # owner of this copyright. # ||
|| # # ||
|| # Should you infringe this copyright, you may be liable to the owner for relief such as injunction, impounding and disposition # ||
|| # of infringing articles, attorney’s fees, actual damages and any profits resulting from the infringement, or statutory damages # ||
|| # up to $150,000 if the infringement was committed willfully. # ||
|| # # ||
|| # For information regarding the authorized use of any of the contents of this website and code, contact the website owner directly. # ||
|| # # ||
|| # --------------------------------------- Elite Ladders IS NOT FREE SOFTWARE ------------------------------------------------------ # ||
|| # http://www.eliteladders.com # ||
|| # # ||
|| # Full terms and conditions can be found at http://www.eliteladders.com/terms # ||
|| # # ||
|| ##################################################################################################################################### ||
\*=======================================================================================================================================*/
include_once("./includes/incglobal.php");
include_once("./includes/timezone.php");
if($tourney[id]){
$thistourney=mysql_query("SELECT `id`,`name`,`news`,`isteam`,`maxTeams`,`numRounds`,`roundTimestamps`,`prize`,DATE_FORMAT(DATE_ADD(`openTimestamp`, INTERVAL ".gettzoffset()." HOUR), '%W %M %D, %Y at %l:%i %p') as open, DATE_FORMAT(DATE_ADD(`beginTimestamp`, INTERVAL ".gettzoffset()." HOUR), '%W %M %D, %Y at %l:%i %p') as begin FROM tournaments WHERE id=".intval($tourney[id])."");
$thistourney=mysql_fetch_array($thistourney);
}
if($thistourney[id]){
show_tourney($tourney,$thistourney);
}else{
list_tourneys();
}
function list_tourneys(){
global $config;
$totaltour=mysql_query("SELECT COUNT(*) FROM tournaments");
$totaltour=mysql_fetch_array($totaltour);
$totaltour="$totaltour[0]";
$groups=mysql_query("SELECT id,name,logo,ann,active,priority,created FROM groups WHERE active='1' ORDER BY priority");
while(list($gid,$gname,$glogo,$gann,$gactive,$gpriority,$gcreated)=mysql_fetch_row($groups)){
if(!$glogo){
$headlogo="";
}else{
$headlogo="<img src='$glogo' width='570' border='0'><br />";
}
if(!$gann){
$headann="";
}else{
$headann="<center>$gann</center>";
}
$out[body].="<br /><center><div style='background-color:$config[altcolora];padding:5px;width:95%;border-top: 1px solid #000000;border-left: 1px solid #000000;border-right: 1px solid #000000;' >$headlogo$headann</div></center>";
$tournaments=mysql_query("SELECT `id`,`name`,`news`,`isteam`,`maxTeams`,`prize`,DATE_FORMAT(DATE_ADD(`openTimestamp`, INTERVAL ".gettzoffset()." HOUR), '%W %M %D, %Y at %l:%i %p'), `openTimestamp`, DATE_FORMAT(DATE_ADD(`beginTimestamp`, INTERVAL ".gettzoffset()." HOUR), '%W %M %D, %Y at %l:%i %p'),`beginTimestamp`, `roundTimestamps` FROM tournaments WHERE `active`=1 AND `grid`=$gid ORDER BY `id`");
if(mysql_num_rows($tournaments) > 0){
while(list($tid,$name,$news,$isteam,$maxteams,$prize,$open,$openTimestamp,$start,$beginTimestamp,$roundTimestamps)=mysql_fetch_row($tournaments)){
//add regional flags
if(preg_match('/US/', $name))
$name = "<img src='./images/flags/US_small.gif' border='0' style='display:inline;'> ".$name;
elseif(preg_match('/EU/', $name))
$name = "<img src='./images/flags/EU_small.gif' border='0' style='display:inline;'> ".$name;
elseif(preg_match('/All/i', $name))
$name = "<img src='./images/flags/globe_small.gif' border='0' style='display:inline'> ".$name;
$spotsleft = ( mysql_num_rows(mysql_query("SELECT * FROM tournament_$tid")) );
if($spotsleft >= $maxteams){
$spots="FULL";
}else{
$spots="$spotsleft/$maxteams";
}
$out[body].="<center>
<table bgcolor='#000000' cellspacing='1' cellpadding='1' width='97%'>
<tr bgcolor='$config[altcolora]'>
<td width='100%' background='$config[bg]' nowrap><b>$name - <a href='./tournaments.php?tourney[id]=$tid'><font color='#e4b214'>View Brackets</font></a>";
if( ($openTimestamp < gmdate('Y-m-d 00:00:00')) && ($beginTimestamp > gmdate('Y-m-d 00:00:00')) )
$out[body].=" - <a href='./join.php?action=jointourney&tid=$tid'>Signup</a>";
elseif(!empty($roundTimestamps))
$out[body].=" - <a href='./report.php?action=reporttourney&tid=$tid'><font color='red'>Report Result</font></a>";
$out[body].="</b></td></tr>
<tr bgcolor='$config[altcolora]'>
<td width=100%'>
<table width='100%' bgcolor='#000000' cellspacing='1' cellpadding='1'>
<tr bgcolor='$config[altcolorb]'><td align='left' background='$config[cellbg2]'><b>Spots Filled / Size:</b></td><td align='left' background='$config[cellbg2]'>$spots</td></tr>
<tr bgcolor='$config[altcolora]'><td align='left' background='$config[cellbg]'><b>Signups Start:</b></td><td align='left' background='$config[cellbg]'>$open ".printTimezone()."</td></tr>
<tr bgcolor='$config[altcolorb]'><td align='left' background='$config[cellbg2]'><b>Tournament Starts:</b></td><td align='left' background='$config[cellbg2]'>$start ".printTimezone()."</td></tr>";
$usergroup = @mysql_fetch_assoc(mysql_query("SELECT cost FROM groupstable WHERE tourneyon=".$tid));
if(!empty($usergroup['cost'])){
$out[body].="<tr bgcolor='$config[altcolorb]'><td align='left' background='$config[cellbg2]'><b>Cost:</b></td><td align='left' background='$config[cellbg2]'>$".$usergroup['cost']."</td></tr>";
}
$out[body].="
<tr bgcolor='$config[altcolora]'><td align='left' background='$config[cellbg]'><b><font color='#e4b214'>Prize</font>:</b></td><td align='left' background='$config[cellbg]'>$prize</td></tr>
<tr bgcolor='$config[altcolora]'><td colspan='2' align='center'>$news</td></tr>
</table></center></td></tr></table><br /><br />
";
}
}else{
$out[body].="
<center>
<table width='600' border='0' cellspacing='1' cellpadding='1' bgcolor='#00000' style='padding-top:15px;'>
<tr bgcolor='$config[altcolorb]'>
<td width='100%' valign='center' align='left'><center>
<b>There are currently no tournaments in this group.</b></center></td></tr>
</table>
</center><br /><br />";
}
}
if($totaltour == 0){
$out[body].="<br />
<center>
<table width='90%' border='0' cellspacing='1' cellpadding='1' bgcolor='#00000'>
<tr bgcolor='$config[altcolora]'>
<td width='100%' valign='center' align='left' colspan='2' background='$config[bg]'>
<strong>Tournament</strong>
</td>
</tr>
<tr bgcolor='$config[altcolorb]'>
<td width='100%' valign='center' align='left'><center>
<b>There are currently no tournaments.</b></center></td></tr>
</table>
</center><br /><br /><br /><br />";
}
$out[body].="<br /><br /><br /><br />";
include("$config[html]");
}
function show_tourney($tourney,$thistourney){
global $config,$out,$team,$binfo;
checkExpireRound($thistourney['id']);
checkTournamentBegin($thistourney['id']);
$bracketinfo = mysql_query("SELECT * FROM tournament_".$thistourney['id']."");
$binfo = mysql_fetch_array($bracketinfo);
$numteams = mysql_num_rows($bracketinfo);
$spotsleft = $thistourney['maxTeams']-$numteams;
//get round play by dates
$count = 1;
$pieces = explode("|", $thistourney['roundTimestamps']);
foreach($pieces as $rounddate){
$result = mysql_fetch_row(mysql_query("SELECT DATE_FORMAT(DATE_ADD('{$rounddate}', INTERVAL ".gettzoffset()." HOUR), '%b. %D at %l:%i %p')"));
$roundDates[$count] = $result[0]." ".(empty($result[0])?"":printTimezone());
$count ++;
}
$out[body].="
<center><br />
<a href='./join.php?action=jointourney&tid=$thistourney[id]'><font color='#e4b214'>Join Tournament</font></a> - <a href='./report.php?action=reporttourney&tid=$thistourney[id]'><font color='red'>Report a Result</font></a> - <a href='./rules.php?rules[tournamentid]=".$thistourney['id']."'>Rules</a><br><br />
<table width='98%' border='0' cellspacing='1' cellpadding='2' bgcolor='#000000'>
<tr bgcolor='$config[altcolora]'>
<td width='100%' valign='center' align='left' colspan='2' background='$config[bg]'>
<strong>Tournament Details</strong>
</td>
</tr>
<tr bgcolor='$config[altcolora]'>
<td width='100%' valign='center' align='center' background='$config[cellbg2]' colspan='2'><b>Tournament: $thistourney[name]</b></td></tr>
<tr bgcolor='$config[altcolora]'>
<td width='40%' valign='center' align='left' background='$config[cellbg2]'><b>Total Players: $thistourney[maxTeams]</b></td>
<td width='40%' valign='center' align='left' background='$config[cellbg2]'><b>Places Remaining: $spotsleft</b></td></tr>
<tr bgcolor='$config[altcolorb]'>
<td width='40%' valign='center' align='left' background='$config[cellbg2]'><b><font color='yellow'>Signups Start on</font>:<br />$thistourney[open]</b></td>
<td width='40%' valign='center' align='left' background='$config[cellbg2]'><b><font color='green'>Tournament Starts on</font>:<br />$thistourney[begin]</b></td>
</tr>
<tr bgcolor='$config[altcolora]'>
<td width='100%' valign='center' align='center' colspan='2'>$thistourney[details]</td>
</tr>
</table>
<br><br />
";
//
//--------------
//
$tid = $thistourney['id'];
if( mysql_num_rows(mysql_query("SELECT * FROM tournament_$tid WHERE round1pos != 0")) == 0 ){
$out[body].= "<center><div style='background-color:$config[altcolora];padding:5px;width:95%;border: 1px solid #000000;'><i>The admin has not yet created the brackets for this tournament.</i><br><br>Here are the teams registered for this tournament so far:<br /></center>";
$sql = mysql_query("SELECT * FROM tournament_$tid WHERE teamid != 0");
$totalteams = mysql_num_rows($sql);
if($totalteams == 0){
$out[body].= '<i>No teams have registered for this tournament yet!</i>';
}else{
$maxrows = ceil($totalteams/3);
$currrow = 0;
$out[body].= '<table border="0" style="width:80%; margin-left:auto; margin-right:auto; margin-bottom:10px;border-left: 1px solid #000000;border-right: 1px solid #000000;border-bottom: 1px solid #000000;"><tr><td valign="top">';
$out[body].= '<table border="0">';
while($team = mysql_fetch_assoc($sql)){
if($thistourney['isteam'] == 1){
$out[body].= "<tr><td background='$config[altcolora]'><a href='stats.php?account=".$team['teamid']."'>".$team['name']."</a></td></tr>";
}else{
$out[body].= "<tr><td><a href='profile.php?account=".$team['teamid']."'>".$team['name']."</a></td></tr>";
}
$currrow++;
if($currrow == $maxrows){
$out[body].= '</table></td><td valign="top"><table border="0">';
$currrow = 0;
}
}
$out[body].= '</table></td></tr></table>';
}
$out[body].= '</div>';
}
// Output brackets
///////////////////
$totalplayers = 2;
while($thistourney['maxTeams'] > $totalplayers){
$totalplayers = $totalplayers * 2;
}
$count=$thistourney['numRounds'];
//print bracket
//$out[body].= "count=".$count;
$lead=0;
$out[body].= "<div style='width:97%; overflow-y:auto;'>";
$out[body].= "<table width='100%' align=center border=0 cellspacing=0 cellpadding=1>";
$out[body].= "<tr valign=top>";
for ($table=1;$table<=$count;$table++) {
$out[body].= "<td>";
$out[body].= "<table border=0 cellspacing=0 cellpadding=0 width='100%'>";
$out[body].= "<tr height='50'><td width='100' align='center' background='$config[cellbg]'><b>";
if($table==$count)
$out[body].= "<span style='color:#FFA50E'>Winner</span> <img src='./images/trophysmall.gif'>";
elseif($table==$count-1)
$out[body].= "<span style='color:#009933'>Finals</span>";
elseif($table==$count-2)
$out[body].= "<span style='color:#ffff66'>Semi-Finals</span>";
else
$out[body].= "Round $table";
$out[body].= "</b><br />$roundDates[$table]</td></tr>";
$out[body].= "<tr height='10'><td> </td></tr>";
for ($y=0;$y<$lead;$y++) {
$out[body].= "<tr><td> </td></tr>";
}
$front=$lead;
$lead=(2*$lead)+1;
for ($x=1;$x<=$totalplayers;$x++){
if($x!=1){
for ($y=0;$y<$lead;$y++) {
$out[body].= "<tr><td> </td></tr>";
}
}
$out[body].= "<tr>";
$team_info = @mysql_fetch_array(mysql_query("SELECT * FROM `tournament_$tid` WHERE `round".$table."pos` = $x"));
if ($team_info['teamid']==0 && $team_info['name']=="bye"){
$out[body].= "<td background='$config[cellbg]' align='center'> <span style='color:grey;'><i>Knocked Out</i></span> ";
}elseif ($team_info['teamid']==""){
$out[body].= "<td background='$config[cellbg]' align='center'> ";
}else{
if($thistourney['isteam']==1){
$out[body].= "<td background='$config[cellbg]' onMouseOver=\"this.style.backgroundImage='url($config[cellbg2])';\" onMouseOut=\"this.style.backgroundImage='url($config[cellbg])';\" style='cursor:hand;cursor:pointer;' onclick=javascript:window.location=\"stats.php?account=".$team_info['teamid']."\" align='center'> {$team_info[name]} ";
}else{
$out[body].= "<td background='$config[cellbg]' onMouseOver=\"this.style.backgroundImage='url($config[cellbg2])';\" onMouseOut=\"this.style.backgroundImage='url($config[cellbg])';\" style='cursor:hand;cursor:pointer;' onclick=javascript:window.location=\"profile.php?account=".$team_info['teamid']."\" align='center'> {$team_info[name]} ";
}
}
//$out[body].= "player".$x,"round".$table;
if(!empty($team_info['round'.$table.'score']))
$out[body].= "[".$team_info['round'.$table.'score']."]";
$out[body].= "</td></tr>";
$middle=$lead+2;
}
$totalplayers=$totalplayers/2;
$out[body].= "</table>";
$out[body].= "</td>";
if($table != $count){
$out[body].= "<td>";
$out[body].= "<table border=0 cellspacing=0 cellpadding=0>\n";
$out[body].= "<tr height='50'><td> </td></tr>";
$out[body].= "<tr height='10'><td> </td></tr>";
for ($w=1;$w<=$totalplayers;$w++) {
for ($t=0;$t<$front;$t++)
$out[body].= "<tr><td> </td></tr>";
for ($t=0;$t<$middle;$t++)
$out[body].= "<tr><td bgcolor='#CCCCCC'> </td></tr>";
for ($t=0;$t<$front;$t++)
$out[body].= "<tr><td> </td></tr>";
$out[body].= "<tr><td> </td></tr>";
}
$out[body].= "</table>\n";
$out[body].= "</td>";
}
}
$out[body].= "</tr>";
$out[body].= "</table>";
$out[body].= "</div>";
//
//--------------
//
include("$config[html]");
}
// this function promotes teams as the round date ends
//////////////////////////////////////////////////////
function checkExpireRound($tournamentid){
$tour = @mysql_fetch_assoc(mysql_query("SELECT roundTimestamps,numRounds FROM tournaments WHERE id=".$tournamentid.""));
if(empty($tour['roundTimestamps'])) return;
$roundDates = explode("|", $tour['roundTimestamps']);
$sql = mysql_query("SELECT * FROM matchreports WHERE status='pending' AND tournamentid=".$tournamentid."");
if(mysql_num_rows($sql) == 0) return;
while($report = mysql_fetch_assoc($sql)){
// get team info
////////////////
$team = mysql_fetch_assoc(mysql_query("SELECT * FROM tournament_{$tournamentid} WHERE teamid={$report['team1id']}"));
if(empty($team)) return;
// get current round
///////////////////////
for( $round = ($tour['numRounds']-1) ; $round > 0 ; $round-- ){
if(!empty($team['round'.$round.'pos'])){
$teampos = $team['round'.$round.'pos'];
$curround = $round;
$round = 0; //break
}
}
$newpos = ceil( (float)$teampos / 2.0 );
$newround = $curround + 1;
$roundDate = @mysql_fetch_row(mysql_query("SELECT UNIX_TIMESTAMP('".$roundDates[$curround - 1]."')"));
if(empty($roundDate[0])) continue;
// finalize match from report
/////////////////////////////
if($roundDate[0] < time()){
finalize_matchreport($tournamentid, $report, $newround, $newpos);
}
}
}
// if report exists then finalize
// Input: $reportid
// WARNING: IF THIS FUNCTION IS MODIFIED ALSO MODIFY TOURNAMENTS.PHP
//////////////////////
function finalize_matchreport($tournamentid, $report, $newround, $newpos){
mysql_query("UPDATE matchreports SET `status`='finalized' WHERE `id`=".intval($report['id']));
mysql_query("UPDATE tournament_".$tournamentid." SET round".$newround."pos = ".$newpos." WHERE teamid=".($report['team1score']>$report['team2score']?$report['team1id']:$report['team2id'])."");
mysql_query("UPDATE tournament_".$tournamentid." SET round".($newround-1)."score = ".$report['team1score']." WHERE teamid=".$report['team1id']."");
mysql_query("UPDATE tournament_".$tournamentid." SET round".($newround-1)."score = ".$report['team2score']." WHERE teamid=".$report['team2id']."");
return "The match has been finalized and the bracket has been updated.";
}
function checkTournamentBegin($tournamentid){
$tour = @mysql_fetch_assoc(mysql_query("SELECT beginTimestamp FROM tournaments WHERE id=".$tournamentid.""));
if(!empty($tour['beginTimestamp'])) return;
$beginDate = @mysql_fetch_row(mysql_query("SELECT UNIX_TIMESTAMP('".$tour['beginTimestamp']."')"));
if(empty($beginDate[0])) return;
if($beginDate[0] < time()){
FillBrackets( array('tid'=>$tournamentid) );
}
}
//
// Input: $form[tid] = tournament id
//
//////////////////////
// WARNING: IF THIS FUNCTION IS MODIFIED ALSO MODIFY ADMINCP->TOURNAMENTS.PHP
//////////////////////
function FillBrackets($form){
global $config;
$result = mysql_query("SELECT * FROM tournaments WHERE `id`=".intval($form['tid'])." LIMIT 1");
if(mysql_num_rows($result) == 0){
return;
}
$tournament = mysql_fetch_assoc($result);
$result = mysql_query("SELECT `teamid`,`name` FROM tournament_{$tournament[id]}");
$numTeams = mysql_num_rows($result);
if($numTeams < 2) return;
unset($teams, $ids);
while($row = mysql_fetch_assoc($result)){
$teams[$row['teamid']]=$row['name'];
$ids[] = $row['teamid'];
}
mysql_query("TRUNCATE TABLE tournament_{$tournament[id]}");
shuffle($ids);
for($x=0 ; $x<count($ids) ; $x++){
mysql_query("INSERT INTO tournament_{$tournament[id]} (teamid, name, round1pos) VALUES (".$ids[$x].",'".$teams[$ids[$x]]."', ".($x+1).")");
}
// find next power of 2 ($bracketSize)
//////////////////////////////////////
$bracketSize = 2;
$numrounds = 2;
while($numTeams > $bracketSize){
$numrounds++;
$bracketSize = $bracketSize * 2;
}
$numByes = $bracketSize - $numTeams;
if($bracketSize < $tournament['maxTeams']){
mysql_query("UPDATE `tournaments` SET `maxTeams`='".intval($bracketSize)."' , `numRounds`='".intval($numrounds)."' WHERE `id`=".$tournament['id']);
}
// close tournament and generate round dates
////////////////////////////////////////////
$matches = "";
for($q=1 ; $q<$numrounds ; $q++){
$matches .= gmdate('Y-m-d 00:00:00', (time() + ($q * $tournament['daysPerRound'] * 86400) ) ) . "|";
}
mysql_query("UPDATE tournaments SET beginTimestamp=CURRENT_TIMESTAMP, roundTimestamps='".substr($matches,0,-1)."' WHERE id=".$tournament['id']);
// insert byes into database
/////////////////////////////
for( $x=(count($ids)+1) ; $x<(count($ids)+1)+$numByes ; $x++ ){
mysql_query("INSERT INTO tournament_{$tournament[id]} (teamid, name, round1pos) VALUES (0,'bye', ".$x.")");
}
// promote byes through bracket
///////////////////////////////
for( $round=1 ; $round < $tournament['numRounds'] ; $round++ ){
for( $y=0 ; $y<=$bracketSize ; $y++ ){
$team1 = mysql_fetch_assoc(mysql_query("SELECT * FROM tournament_{$tournament[id]} WHERE round".$round."pos = ".$y));
if($team1['name'] == "bye" && $team1['teamid'] == 0){
// get winning team info
////////////////////////
if($y&1){ //is odd
$team2 = mysql_fetch_assoc(mysql_query("SELECT * FROM tournament_{$tournament[id]} WHERE round".$round."pos=".($y+1).""));
$y++;
}else{//is even
$team2 = mysql_fetch_assoc(mysql_query("SELECT * FROM tournament_{$tournament[id]} WHERE round".$round."pos=".($y-1).""));
}
// update database with winner
//////////////////////////////
mysql_query("UPDATE tournament_{$tournament[id]} SET round".($round+1)."pos = ".ceil( (float)$y / 2.0 )." WHERE teamid=".$team2['teamid']);
}
}
}
}
// send reminders out 3 days before round end
/////////////////////////////////////////////
function checkRoundEnd($tournamentid){
global $config;
$tour = @mysql_fetch_assoc(mysql_query("SELECT * FROM tournaments WHERE id=".$tournamentid.""));
if(empty($tour['beginTimestamp'])) return;
if(empty($tour['roundTimestamps'])) return;
if($tour['numRounds'] == 2) return;
$beginDate = @mysql_fetch_row(mysql_query("SELECT UNIX_TIMESTAMP('".$tour['beginTimestamp']."')"));
if(empty($beginDate[0])) return;
if($beginDate[0] < time()){
$roundDates = explode("|", $tour['roundTimestamps']);
// convert round dates to UNIX TIMESTAMP
////////////////////////////////////////
$count = 2;
foreach($roundDates as $datetime){
$roundStart[$count] = @mysql_fetch_row(mysql_query("SELECT UNIX_TIMESTAMP('".$datetime."')"));
$count++;
}
$roundStart[$count] = 2147234400;
// find what round we're in
///////////////////////////
$curround = 1;
while( time() > $roundStart[$curround+1] ){
$curround++;
}
if($curround >= $tour['numRounds']) return;
// check if it's in 3 days of next round
////////////////////////////////////////
if($tour['daysPerRound'] > 3) $tour['daysPerRound'] = 3;
if( time() < ( $roundStart[$curround+1] - (86400*$tour['daysPerRound']) ) ) return;
// check if reminders have been sent
////////////////////////////////////
$sql = mysql_query("SELECT teamid,round".$curround."reminder FROM tournamnet_".$tournamentid." WHERE round".$curround."reminder != 1 AND teamid != 0");
if( mysql_num_rows($sql) == 0 ) return;
while($team = mysql_fetch_assoc($sql)){
// find team leader
///////////////////
if($tour['isteam'] == 1){
$memberlink = @mysql_fetch_assoc(mysql_query("SELECT memberid FROM memberteams WHERE position < '4' AND tournamentid='".$tournamentid."' ORDER BY position ASC LIMIT 1"));
if(empty($memberlink['memberid'])) return;
$team['leaderid'] = $memberlink['memberid'];
}else{
$team['leaderid'] = $team['teamid'];
}
// build message
////////////////
$message = "
This is a automatted message. Do not reply.
You are in the tournament, ".$tour['name'].". The next round is scheduled to start
in less than ".$tour['daysPerRound']." days! Make sure you have completed your last
round's matches and have reported the results or you will forfeit your match! Click
the following link to take you directly to the tournament brackets:
<a href='".$config['scripturl']."/tournaments.php?tourney[id]=".$tournamentid."'>".$config['scripturl']."/tournaments.php?tourney[id]=".$tournamentid."</a>
-".$config['sitename']."";
// send reminder message
////////////////////////
mysql_query("INSERT INTO messages (toid, subject, body, active, grid) VALUES ('".$team['leaderid']."', 'Tournament Round End Approaching!', '".$message."', '1', '1')");
// send reminder email
//////////////////////
$user = @mysql_fetch_assoc(mysql_query("SELECT email FROM members WHERE id = ".$team['leaderid']." LIMIT 1"));
if(!empty($user['email'])){
$headers = 'From: ' . $config['sitemail'] . "\r\n" .
'Reply-To: ' . $config['sitemail'] . "\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n";
'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($user['email'], "Tournament Round End Approaching!", $message, $headers);
}
// update database
//////////////////
mysql_query("UPDATE tournamnet_".$tournamentid." SET round".$curround."reminder = 1 WHERE teamid = ".$team['teamid']."");
}
}
$tour = @mysql_fetch_assoc(mysql_query("SELECT roundTimestamps,numRounds FROM tournaments WHERE id=".$tournamentid.""));
}
?>
Link: http://www.jerichool.com/tournament.txt