Jump to content

Recommended Posts

Hello my ladder Report dont scan in the wars. What i mean any clan can report a loss on any clan.

 

so that means i can report a loss to anyone with out making a war.

 

 

Can anyone help me

 

im a noob but im working my way with php :)

 

What i want is where your about to report a loss , i want it to scan the db and see that there is a war made between that clan. But if there isnt then you cant post a loss on a clan that you didnt war.

 

<?
include("./config.php");

check_login($login);

switch($action){

case "reportloss":
report_loss($login);
break;

case "reportlossb":
check_loss($login);
break;

default:
check_login($login);
break;
}

function check_login($login){
global $config;

if(!mysql_num_rows(mysql_query("SELECT id FROM teams WHERE id='$login[id]' AND password='$login[pass]' OR id='$login[id]' AND reportpass='$login[pass]'"))){
$out[body].="
<br>
<center>
<table width='300' border='0' cellspacing='1' cellpadding='1'>
<form method='post'>
<tr bgcolor='$config[altcolor]'>
<td background='$config[tablebg]' width='100%' valign='center' align='left' colspan='2'>
<strong><font color='ffffff'>Report a Loss</strong>";
if($login[failreport]){
$out[body].=" <font color='#FF0000' size='1'>(Incorrect Login)</font>";
}
$out[body].="
</td>
</tr>
<tr bgcolor='$config[altcolora]'>
<td background='$config[tablex]' width='40%' valign='center' align='left'>Account ID</td>
<td background='$config[tablex]' width='60%' valign='center' align='center'><input type='text' name='login[id]' value='$login[id]' size='25' maxlength='10'></td>
</tr>
<tr bgcolor='$config[altcolorb]'>
<td background='$config[tablex]' width='40%' valign='center' align='left'>Password</td>
<td background='$config[tablex]' width='60%' valign='center' align='center'><input type='password' name='login[pass]' value='' size='25' maxlength='10'></td>
</tr>
<tr bgcolor='$config[altcolora]'>
<td background='$config[tablex]' width='40%' valign='center' align='left'>Winner ID</td>
<td background='$config[tablex]' width='60%' valign='center' align='center'><input type='text' name='login[wid]' value='$login[wid]' size='25' maxlength='10'></td>
</tr>
<tr>
<td width='100%' valign='top' align='right' colspan='2'>
<br>
<input type='hidden' name='login[failreport]' value='1'>
<input type='hidden' name='action' value='reportloss'>
<input type='submit' name='submit' value='Report >>'></td>
</form>
</tr>
</table>
<br>
</center>";


include("$config[html]");
exit;
}
}


function report_loss($login){
global $config;

$losid="$login[id]";
$winid="$login[wid]";

if($login[id]=="$login[wid]"){
error("You cannot report losses to yourself.");
}

$winnerteam=mysql_query("SELECT ladderid FROM teams WHERE id='$login[wid]'");
$winnerteam=mysql_fetch_array($winnerteam);

if(!$winnerteam[ladderid]){
error("Unable to find the winning team.");
}

$ladder=mysql_query("SELECT * FROM ladders WHERE id='$winnerteam[ladderid]'");
$ladder=mysql_fetch_array($ladder);

if(!$ladder[name]){
error("Unable to load the ladder information.");
}

$loser=mysql_query("SELECT * FROM ladder_$ladder[id] WHERE teamid='$login[id]'");
$loser=mysql_fetch_array($loser);

$winner=mysql_query("SELECT * FROM ladder_$ladder[id] WHERE teamid='$login[wid]'");
$winner=mysql_fetch_array($winner);

if(!$loser[name]){
error("Unable to find the losing teams stats.");
}

if(!$winner[name]){
error("Unable to find the winning teams stats.");
}


if($ladder[isteam]){
$members=mysql_query("SELECT id,name FROM members WHERE teamid='$login[id]' ORDER by joined");
while(list($id,$name)=mysql_fetch_row($members)){
if($config[altcolorx]==$config[altcolora]){
$config[altcolorx]="$config[altcolorb]";
}else{
$config[altcolorx]="$config[altcolora]";
}
$losmembers.="
<tr bgcolor='$config[altcolorx]'>
<td background='$config[tablex]' width='60%' valign='center' align='left'><b>$name</b></td>
<td background='$config[tablex]' width='40%' valign='center' align='left'><b>Kills:</b> <input type='text' name='login[member][$losid][$id]' value='' size='25' maxlength='2'></td>
</tr>";
}
}else{
$losmembers.="
<tr bgcolor='$config[altcolora]'>
<td background='$config[tablex]' width='60%' valign='center' align='left'><b>Total Kills</b></td>
<td background='$config[tablex]' width='40%' valign='center' align='left'><b>Kills:</b> <input type='text' name='login[totalkills][$losid]' value='' size='25' maxlength='2'></td>
</tr>";
}

if($ladder[isteam]){
$members=mysql_query("SELECT id,name FROM members WHERE teamid='$login[wid]' ORDER by joined");
while(list($id,$name)=mysql_fetch_row($members)){
if($config[altcolorx]==$config[altcolora]){
$config[altcolorx]="$config[altcolorb]";
}else{
$config[altcolorx]="$config[altcolora]";
}
$winmembers.="
<tr bgcolor='$config[altcolorx]'>
<td background='$config[tablex]' width='60%' valign='center' align='left'><b>$name</b></td>
<td background='$config[tablex]' width='40%' valign='center' align='left'><b>Kills:</b> <input type='text' name='login[member][$winid][$id]' value='' size='25' maxlength='2'></td>
</tr>";
}
}else{
$winmembers.="
<tr bgcolor='$config[altcolora]'>
<td background='$config[tablex]' width='60%' valign='center' align='left'><b>Total Kills</b></td>
<td background='$config[tablex]' width='40%' valign='center' align='left'><b>Kills:</b> <input type='text' name='login[totalkills][$winid]' value='' size='25' maxlength='2'></td>
</tr>";
}

if($ladder[isteam]){
$footmessage.="Only put kills for members who played.<br>";
}
$footmessage.="<!--If you put inacurate kills you will be dropped 15 ranks.<br>-->";


$out[body].="
<br>
<center>
<table width='500' border='0' cellspacing='1' cellpadding='1'>
<form method='post'>
<tr bgcolor='$config[altcolor]'>
<td background='$config[tablebg]' width='100%' valign='center' align='left' colspan='2'><b>Reporting Loss: $ladder[name]</b></td>
</tr>

<tr bgcolor='$config[altcolor]'>
<td background='$config[tablex]' width='100%' valign='center' align='left' colspan='2'><b>$loser[name] Information</b> (Loser)</td>
</tr>

$losmembers

<tr bgcolor='$config[altcolor]'>
<td background='$config[tablex]' width='100%' valign='center' align='left' colspan='2'><b>$winner[name] Information</b> (Winner)</td>
</tr>

$winmembers

<tr>
<td width='100%' valign='top' align='right' colspan='2'>

<br>
<input type='hidden' name='action' value='reportlossb'>
<input type='hidden' name='login[ladderid]' value='$ladder[id]'>
<input type='hidden' name='login[wid]' value='$login[wid]'>
<input type='hidden' name='login[id]' value='$login[id]'>
<input type='hidden' name='login[pass]' value='$login[pass]'>
<input type='submit' name='submit' value='Report Match >>'></td>
</form>
</tr>
</table>
<br>
<b>$footmessage</b>
<br>
</center>";

include("$config[html]");
}


function check_loss($login){
global $config;

$losid="$login[id]";
$winid="$login[wid]";

if($login[id]=="$login[wid]"){
error("You cannot report losses to yourself.");
}

$ladder=mysql_query("SELECT * FROM ladders WHERE id='$login[ladderid]'");
$ladder=mysql_fetch_array($ladder);

if(!$ladder[name]){
error("Unable to load the ladder information.");
}

$loser=mysql_query("SELECT * FROM ladder_$ladder[id] WHERE teamid='$login[id]'");
$loser=mysql_fetch_array($loser);

$winner=mysql_query("SELECT * FROM ladder_$ladder[id] WHERE teamid='$login[wid]'");
$winner=mysql_fetch_array($winner);

if(!$loser[name]){
error("Unable to find the losing teams stats.");
}

if(!$winner[name]){
error("Unable to find the winning teams stats.");
}



//UPDATE LOSING TEAM

$new_loser_rank="$loser[rank]";
$new_loser_lrank="$loser[rank]";
$new_loser_wins="$loser[wins]";
$new_loser_loss=($loser[loss] + 1);
$new_loser_games=($loser[games] + 1);
$new_loser_percent=round($loser[wins] / $new_loser_games * 100);
$new_loser_streak=($loser[streak] - 1);

if($new_loser_streak >= 0){
$new_loser_streak="-1";
}

// Winners & Losers New Points & Level

$level_diff=($winner[level] - $loser[level]);

if ($level_diff <= "-1"){
	$level_diff=str_replace("-", "", "$level_diff");

if ($level_diff == 0){
$new_winner_points="100";
$new_loser_points="100";
}

if ($level_diff == 1){

if ($winner[level] > $loser[level]){
	$new_winner_points="90";
	$new_loser_points="90";
	}
		else	
{
$new_winner_points="120";
$new_loser_points="110";
  }		
}

if ($level_diff == 2){
if ($winner[level] > $loser[level]){
	$new_winner_points="80";
	$new_loser_points="80";
	}
		else	
{
$new_winner_points="140";
$new_loser_points="120";
  }	
}

if ($level_diff == 3){
if ($winner[level] > $loser[level]){
	$new_winner_points="70";
	$new_loser_points="70";
	}
		else	
{
$new_winner_points="160";
$new_loser_points="130";
  }
}

if ($level_diff == 4){
if ($winner[level] > $loser[level]){
	$new_winner_points="60";
	$new_loser_points="60";
	}
		else	
{
$new_winner_points="175";
$new_loser_points="140";
  }
}

if ($level_diff == 5){
if ($winner[level] > $loser[level]){
	$new_winner_points="50";
	$new_loser_points="50";
	}
		else	
{
$new_winner_points="190";
$new_loser_points="150";
  }
}

if ($level_diff == 6){
if ($winner[level] > $loser[level]){
	$new_winner_points="40";
	$new_loser_points="40";
	}
		else	
{
$new_winner_points="205";
$new_loser_points="160";
  }
}

if ($level_diff == 7){
if ($winner[level] > $loser[level]){
	$new_winner_points="30";
	$new_loser_points="30";
	}
		else	
{
$new_winner_points="215";
$new_loser_points="170";
  }
}

if ($level_diff == {
if ($winner[level] > $loser[level]){
	$new_winner_points="20";
	$new_loser_points="20";
	}
		else	
{
$new_winner_points="215";
$new_loser_points="170";
  }
}

if ($level_diff == 9){
if ($winner[level] > $loser[level]){
	$new_winner_points="10";
	$new_loser_points="10";
	}
		else	
{
$new_winner_points="215";
$new_loser_points="170";
  }
}

if ($level_diff >= 10){
if ($winner[level] > $loser[level]){
	$new_winner_points="5";
	$new_loser_points="5";
	}
		else	
{
$new_winner_points="215";
$new_loser_points="170";
  }
}		
}
	else
			{

if ($level_diff == 0){
$new_winner_points="100";
$new_loser_points="100";
}

if ($level_diff == 1){

if ($winner[level] > $loser[level]){
	$new_winner_points="90";
	$new_loser_points="90";
	}
		else	
{
$new_winner_points="120";
$new_loser_points="110";
  }		
}

if ($level_diff == 2){
if ($winner[level] > $loser[level]){
	$new_winner_points="80";
	$new_loser_points="80";
	}
		else	
{
$new_winner_points="140";
$new_loser_points="120";
  }	
}

if ($level_diff == 3){
if ($winner[level] > $loser[level]){
	$new_winner_points="70";
	$new_loser_points="70";
	}
		else	
{
$new_winner_points="160";
$new_loser_points="130";
  }
}

if ($level_diff == 4){
if ($winner[level] > $loser[level]){
	$new_winner_points="60";
	$new_loser_points="60";
	}
		else	
{
$new_winner_points="175";
$new_loser_points="140";
  }
}

if ($level_diff == 5){
if ($winner[level] > $loser[level]){
	$new_winner_points="50";
	$new_loser_points="50";
	}
		else	
{
$new_winner_points="190";
$new_loser_points="150";
  }
}

if ($level_diff == 6){
if ($winner[level] > $loser[level]){
	$new_winner_points="40";
	$new_loser_points="40";
	}
		else	
{
$new_winner_points="205";
$new_loser_points="160";
  }
}

if ($level_diff == 7){
if ($winner[level] > $loser[level]){
	$new_winner_points="30";
	$new_loser_points="30";
	}
		else	
{
$new_winner_points="215";
$new_loser_points="170";
  }
}

if ($level_diff == {
if ($winner[level] > $loser[level]){
	$new_winner_points="20";
	$new_loser_points="20";
	}
		else	
{
$new_winner_points="215";
$new_loser_points="170";
  }
}

if ($level_diff == 9){
if ($winner[level] > $loser[level]){
	$new_winner_points="10";
	$new_loser_points="10";
	}
		else	
{
$new_winner_points="215";
$new_loser_points="170";
  }
}

if ($level_diff >= 10){
if ($winner[level] > $loser[level]){
	$new_winner_points="5";
	$new_loser_points="5";
	}
		else	
{
$new_winner_points="215";
$new_loser_points="170";
  }
};
}

//UPDATE WINNING TEAM

$new_winner_lrank="$winner[rank]";
$new_winner_wins=($winner[wins] + 1);
$new_winner_loss="$winner[loss]";
$new_winner_games=($winner[games] + 1);
$new_winner_percent=round($new_winner_wins / $new_winner_games * 100);
$new_winner_streak=($winner[streak] + 1);

if($new_winner_streak < 1){
$new_winner_streak="1";
}

//FIND WINNERS NEW RANK

$totalranked=mysql_query("SELECT COUNT(*) FROM ladder_$ladder[id] WHERE rank > '0'");
$totalranked=mysql_fetch_array($totalranked);
$totalranked="$totalranked[0]";

$adjustranks="";

if($winner[rank] > 0){
if(($winner[rank] > $loser[rank]) && ($loser[rank] > 0)){
$middlerank=(($winner[rank] + $loser[rank]) - 0.5);
$new_winner_rank=round(($middlerank / 2) - 0.5);
$adjustranks=1;
}else{
$new_winner_rank="$winner[rank]";
}
}
else{
$new_winner_rank=($totalranked + 1);
$adjustranks=1;
}



//UPDATE LOSING TEAM

if ($loser[level] == 1){
$multi=".13";
}

if ($loser[level] == 2){
$multi=".16";
}

if ($loser[level] == 3){
$multi=".16";
}

if ($loser[level] == 4){
$multi=".25";
}

if ($loser[level] == 5){
$multi=".25";
}

if ($loser[level] == 6){
$multi=".43";
}

if ($loser[level] == 7){
$multi=".43";
}

if ($loser[level] == {
$multi=".67";
}

if ($loser[level] == 9){
$multi=".67";
}

if ($loser[level] >= 10){
$multi="1";
  }

$loser_p=round($new_loser_points * $multi);

if ($loser[points] > 2500){
$Loser_p=($new_loser_points + $loser_p);
}
elseif ($loser[points] < $Loser_p && $loser[points] < $new_loser_points){
	$Loser_p="$loser[points]";
}else if($loser[points] <= 0){
	$Loser_p="0";
}
else{
  $Loser_p="$loser_p";
}

mysql_query("UPDATE ladder_$ladder[id] SET 
rank='$new_loser_rank',
lrank='$new_loser_lrank',
wins='$new_loser_wins',
loss='$new_loser_loss',
games='$new_loser_games',
percent='$new_loser_percent',
streak='$new_loser_streak',
points=points-'$Loser_p',
level=level,
kills=kills+'$new_loser_kills',
king=king,
lastmatch=NULL 
WHERE teamid ='$login[id]'");

//UPDATE WINNIING TEAM

mysql_query("UPDATE ladder_$ladder[id] SET 
rank='$new_winner_rank',
lrank='$new_winner_lrank',
wins='$new_winner_wins',
loss='$new_winner_loss',
games='$new_winner_games',
percent='$new_winner_percent',
streak='$new_winner_streak',
points=points+'$new_winner_points',
level=level,
kills=kills+'$new_winner_kills',
king=king,
lastmatch=NULL 
WHERE teamid ='$login[wid]'");

// King Update/Change To New King

include("./report_inc_db.php");

//INSERT MATCH INTO DATABASE

mysql_query("INSERT INTO matchdb (ladderid, wid, lid, wname, lname, points, loser_new_points, wkills, lkills)
values('$ladder[id]','$winid','$losid','$winner[name]','$loser[name]','$new_winner_points','$Loser_p','$new_winner_kills','$new_loser_kills')");

//CLEAR CHALLENGE IF EXISTS

mysql_query("DELETE FROM challenges WHERE challgrid='$login[id]' && challgdid='$login[wid]' || challgrid='$login[wid]' && challgdid='$login[id]'");
mysql_query("DELETE FROM chall_chat WHERE challenger='$login[id]' && challenged='$login[wid]' || challenger='$login[wid]' && challenged='$login[id]'");

//ADJUST RANKS IF RANK WAS CHANGED

if($adjustranks){
include("./rankadjust.php");
$adjust[ladderid]="$ladder[id]";
$adjust[wid]="$login[wid]";
$adjust[newrank]="$new_winner_rank";
rank_adjust($adjust);
}


$out[body].="
<META HTTP-EQUIV='refresh' content='20;URL=$config[scripturl]/manager.php'> 
<br>
<center>
<b>
The match has been reported.
<br>
<br>
$winner[name] Defeated $loser[name]
<br>
<br>
<a href='$config[scripturl]/stats.php?account=$login[id]'>View Your Stats</a>
</b>
</center>
<br>";

include("$config[html]");


}

?>


Link to comment
https://forums.phpfreaks.com/topic/66794-problems-with-my-ladder-report/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.