tablerender("Error","".ARCADE_158.""); require_once(FOOTERF); exit; } // Print navigation menu $nav = ""; $nav .= "".ARCADE_1.""; $nav .= " ► Challenges"; if (isset($_GET['sentdetails'])) { $nav .= " ► Details"; } elseif (isset($_GET['deatils'])) { $nav .= " ► Details"; } elseif (isset($_GET['ended'])) { $nav .= " ► Ended Challenge Details"; } $title = "".ARCADE_38.""; $ns -> tablerender($title, $nav.""); // END NAVIGATION MENU $blank = ""; if ($pref['plushours'] != '') { $offset = $pref['plushours']; } else { $offset = +0; //No of hours to add or subtract on the time } $now = time() + ($offset * 60 * 60); // CHECK FOR WINNERS / UPDATE DB / ADD GOLD $sql->mySQLresult = @mysql_query("SELECT c.id, c.chalby, c.chalto, c.game, c.bet, c.end_date, c.comments, u.user_name, g.game_title FROM ".MPREFIX."archallenges c, ".MPREFIX."user u, ".MPREFIX."argames g WHERE u.user_id=c.chalby and g.game_id=c.game and c.status=2 and c.finished=0 and c.end_date <= ".$now." ORDER BY c.id DESC"); $rows = $sql->db_Rows(); if ($rows > 0) { for ($i = 0; $i < $rows; $i++) { $row = $sql->db_Fetch(); $id = mysql_query("SELECT score FROM ".MPREFIX."arscores WHERE game_id=".$row['game']." and user_id=".$row['chalto']." ORDER BY score DESC LIMIT 0,1"); $idrows = mysql_num_rows($id); if ($idrows == 0) { $player1 = 0; } else { while ($rowid = mysql_fetch_assoc($id)) { $player1 = $rowid['score']; } } $id2 = mysql_query("SELECT score FROM ".MPREFIX."arscores WHERE game_id=".$row['game']." and user_id=".$row['chalby']." ORDER BY score DESC LIMIT 0,1"); $idrows1 = mysql_num_rows($id2); if ($idrows1 == 0) { $player2 = 0; } else { while ($rowid2 = mysql_fetch_assoc($id2)) { $player2 = $rowid2['score']; } } if ($pref['arcade_goldactive'] == Yes) { $g = mysql_query("SELECT gold FROM ".MPREFIX."gold_system WHERE id=".$row['chalto'].""); while ($p1 = mysql_fetch_assoc($g)) { $gold1 = $p1['gold']; } $g2 = mysql_query("SELECT gold FROM ".MPREFIX."gold_system WHERE id=".$row['chalby'].""); while ($p2 = mysql_fetch_assoc($g2)) { $gold2 = $p2['gold']; } } $top .= "".$player1."

".$player2."

"; if ($player1 > $player2) { if ($pref['arcade_goldactive'] == Yes) { $new_goldp1 = $gold1 + $row['bet']; $new_goldp2 = $gold2 - $row['bet']; $updategold = mysql_query("UPDATE ".MPREFIX."gold_system SET gold='".$new_goldp1."' WHERE id='".$row['chalto']."'"); $updategold2 = mysql_query("UPDATE ".MPREFIX."gold_system SET gold='".$new_goldp2."' WHERE id='".$row['chalby']."'"); } $updatechal = mysql_query("UPDATE ".MPREFIX."archallenges SET won='".$row['chalto']."' WHERE id='".$row['id']."'"); $updatechalfin = mysql_query("UPDATE ".MPREFIX."archallenges SET finished='1' WHERE id='".$row['id']."'"); if ($pref['arcade_goldactive'] == Yes) { $msg1 = "Congratulations you have won the Arcade Challenge on ".$row['game_title'].". ".$row['bet']."g has been added to your account and taken away from your opponents! Well Done!"; } else { $msg1 = "Congratulations you have won the Arcade Challenge on ".$row['game_title'].". Well Done!"; } $size = strlen($msg1); if ($pref['arcade_goldactive'] == Yes) { $msg2 = "OH NO! you have lost the Arcade Challenge on ".$row['game_title'].". ".$row['bet']."g has been taken from your account and added to your opponents! Better luck next time!"; } else { $msg2 = "OH NO! you have lost the Arcade Challenge on ".$row['game_title'].". Better luck next time!"; } $size2 = strlen($msg2); $sendpm = mysql_query("INSERT INTO ".MPREFIX."private_msg (pm_id, pm_from, pm_to, pm_sent, pm_read, pm_subject, pm_text, pm_sent_del, pm_read_del, pm_attachments, pm_option, pm_size) VALUES('0', '".$row['chalby']."', '".$row['chalto']."', '".intval(time())."', '0', 'Arcade Challenge Ended!', '".$msg1."', '1', '0', '', '', '".intval($size)."' ) "); $sendpm2 = mysql_query("INSERT INTO ".MPREFIX."private_msg (pm_id, pm_from, pm_to, pm_sent, pm_read, pm_subject, pm_text, pm_sent_del, pm_read_del, pm_attachments, pm_option, pm_size) VALUES('0', '".$row['chalto']."', '".$row['chalby']."', '".intval(time())."', '0', 'Arcade Challenge Ended!', '".$msg2."', '1', '0', '', '', '".intval($size2)."' ) "); } elseif ($player1 < $player2) { if ($pref['arcade_goldactive'] == Yes) { $new_goldp1 = $gold1 - $row['bet']; $new_goldp2 = $gold2 + $row['bet']; $updategold = mysql_query("UPDATE ".MPREFIX."gold_system SET gold='".$new_goldp1."' WHERE id='".$row['chalto']."'"); $updategold2 = mysql_query("UPDATE ".MPREFIX."gold_system SET gold='".$new_goldp2."' WHERE id='".$row['chalby']."'"); } $updatechal = mysql_query("UPDATE ".MPREFIX."archallenges SET won='".$row['chalby']."' WHERE id='".$row['id']."'"); $updatechalfin = mysql_query("UPDATE ".MPREFIX."archallenges SET finished='1' WHERE id='".$row['id']."'"); if ($pref['arcade_goldactive'] == Yes) { $msg1 = "Congratulations you have won the Arcade Challenge on ".$row['game_title'].". ".$row['bet']."g has been added to your account and taken away from your opponents! Well Done!"; } else { $msg1 = "Congratulations you have won the Arcade Challenge on ".$row['game_title'].". Well Done!"; } $size = strlen($msg1); if ($pref['arcade_goldactive'] == Yes) { $msg2 = "OH NO! you have lost the Arcade Challenge on ".$row['game_title'].". ".$row['bet']."g has been taken from your account and added to your opponents! Better luck next time!"; } else { $msg2 = "OH NO! you have lost the Arcade Challenge on ".$row['game_title'].". Better luck next time!"; } $size2 = strlen($msg2); $sendpm = mysql_query("INSERT INTO ".MPREFIX."private_msg (pm_id, pm_from, pm_to, pm_sent, pm_read, pm_subject, pm_text, pm_sent_del, pm_read_del, pm_attachments, pm_option, pm_size) VALUES('0', '".$row['chalto']."', '".$row['chalby']."', '".intval(time())."', '0', 'Arcade Challenge Ended!', '".$msg1."', '1', '0', '', '', '".intval($size)."' ) "); $sendpm2 = mysql_query("INSERT INTO ".MPREFIX."private_msg (pm_id, pm_from, pm_to, pm_sent, pm_read, pm_subject, pm_text, pm_sent_del, pm_read_del, pm_attachments, pm_option, pm_size) VALUES('0', '".$row['chalby']."', '".$row['chalto']."', '".intval(time())."', '0', 'Arcade Challenge Ended!', '".$msg2."', '1', '0', '', '', '".intval($size2)."' ) "); } else { $halfbet = round($row['bet'] / 2); if ($pref['arcade_goldactive'] == Yes) { $new_goldp1 = $gold1 + $halfbet; $new_goldp2 = $gold2 + $halfbet; $updategold = mysql_query("UPDATE ".MPREFIX."gold_system SET gold='".$new_goldp1."' WHERE id='".$row['chalto']."'"); $updategold2 = mysql_query("UPDATE ".MPREFIX."gold_system SET gold='".$new_goldp2."' WHERE id='".$row['chalby']."'"); } $updatechal = mysql_query("UPDATE ".MPREFIX."archallenges SET won='DR' WHERE id='".$row['id']."'"); $updatechalfin = mysql_query("UPDATE ".MPREFIX."archallenges SET finished='1' WHERE id='".$row['id']."'"); if ($pref['arcade_goldactive'] == Yes) { $msg1 = "The arcade challenge on ".$row['game_title']." ended in a DRAW!. This means you both split the bet between you and ".$halfbet."g has been added to your account as well as your opponents!"; } else { $msg1 = "The arcade challenge on ".$row['game_title']." ended in a DRAW!. Well Done."; } $size = strlen($msg1); $sendpm = mysql_query("INSERT INTO ".MPREFIX."private_msg (pm_id, pm_from, pm_to, pm_sent, pm_read, pm_subject, pm_text, pm_sent_del, pm_read_del, pm_attachments, pm_option, pm_size) VALUES('0', '".$row['chalto']."', '".$row['chalby']."', '".intval(time())."', '0', 'Arcade Challenge Ended!', '".$msg1."', '1', '0', '', '', '".intval($size)."' ) "); $sendpm2 = mysql_query("INSERT INTO ".MPREFIX."private_msg (pm_id, pm_from, pm_to, pm_sent, pm_read, pm_subject, pm_text, pm_sent_del, pm_read_del, pm_attachments, pm_option, pm_size) VALUES('0', '".$row['chalby']."', '".$row['chalto']."', '".intval(time())."', '0', 'Arcade Challenge Ended!', '".$msg1."', '1', '0', '', '', '".intval($size)."' ) "); } } } // DELETE ENDED CHALLENGES - THAT WERE NEVER ANSWERED $sql->mySQLresult = @mysql_query("SELECT id FROM ".MPREFIX."archallenges WHERE status=1 and finished=0 and end_date <= ".$now." ORDER BY id DESC"); $del = $sql->db_Rows(); if ($del > 0) { for ($i = 0; $i < $del; $i++) { $delete = $sql->db_Fetch(); $sql->db_Delete("archallenges", "id='".$delete['id']."'"); } } // ISSETS if (isset($_GET['delete'])) { $sql->db_Delete("archallenges", "id='".$_GET['delete']."'"); $ns->tablerender("Current Challenges","Thank you, The Rejeced Arcade Challenge has been deleted!

<< Back"); require_once(FOOTERF); exit; } if (isset($_GET['accept'])) { if ($_GET['accept'] == true) { if ($pref['arcade_goldactive'] == Yes) { $gold = gold(USERID); } else { $gold = 0; } if ($_GET['bet'] > $gold) { $ns->tablerender("Error","You cannot accept this challenge because the bet set is greater than the current amount of gold you have. Please earn some more gold first or reject the challenge.

<< Back"); require_once(FOOTERF); exit; } else { $sql -> db_Update("archallenges", "status='2' WHERE id='".$_GET['challengeid']."' "); $ns->tablerender("Recieved Challenges","Thank you, Your Challenge has begun

<< Back"); $sql -> db_Select("user", "user_id", "user_name='".$_GET['from']."'"); $userfrom = $sql -> db_Fetch(); $msg = "".USERNAME." has accepted your Arcade Challenge on the game ".$_GET['game'].". Please keep checking the Arcade Challenges page for an update on their progress."; $size = strlen($msg); $sql->db_Insert("private_msg", "0, '".USERID."', '".$userfrom['user_id']."', '".intval(time())."', '0', 'Arcade Challenge Accepted!', '".$msg."', '1', '0', '', '', '".intval($size)."' "); require_once(FOOTERF); exit; } } $ns->tablerender("Recieved Challenges","Challenge From: ".$_GET['from']."
Challenge On: ".$_GET['game']."

Are you sure you want to ACCEPT this challenge?

 "); require_once(FOOTERF); exit; } if (isset($_GET['reject'])) { if ($_GET['reject'] == true) { $sql -> db_Update("archallenges", "status='0' WHERE id='".$_GET['challengeid']."' "); $ns->tablerender("Recieved Challenges","You have chosen to reject the challenge, ".$_GET['from']." has been notified of this.

<< Back"); $sql -> db_Select("user", "user_id", "user_name='".$_GET['from']."'"); $userfrom = $sql -> db_Fetch(); $msg = "We are sorry to say that ".USERNAME." has rejected your Arcade Challenge on the game ".$_GET['game']."."; $size = strlen($msg); $sql->db_Insert("private_msg", "0, '".USERID."', '".$userfrom['user_id']."', '".intval(time())."', '0', 'Arcade Challenge Rejected!', '".$msg."', '1', '0', '', '', '".intval($size)."' "); require_once(FOOTERF); exit; } $ns->tablerender("Recieved Challenges","Challenge From: ".$_GET['from']."
Challenge On: ".$_GET['game']."

Are you sure you want to REJECT this challenge?

 "); require_once(FOOTERF); exit; } if (isset($_GET['details'])) { $sql->mySQLresult = @mysql_query("SELECT c.id, c.chalby, c.game, c.bet, c.end_date, c.comments, u.user_name, g.game_title FROM ".MPREFIX."archallenges c, ".MPREFIX."user u, ".MPREFIX."argames g WHERE c.id=".$_GET['details']." and u.user_id=c.chalby and g.game_id=c.game and c.status=2 ORDER BY c.id DESC"); $row = $sql -> db_Fetch(); $sql->mySQLresult = @mysql_query("SELECT score FROM ".MPREFIX."arscores WHERE game_id=".$row['game']." and user_id=".USERID." ORDER BY score DESC LIMIT 0,1"); $game = $sql -> db_Fetch(); $sql->mySQLresult = @mysql_query("SELECT score FROM ".MPREFIX."arscores WHERE game_id=".$row['game']." and user_id=".$row['chalby']." ORDER BY score DESC LIMIT 0,1"); $game2 = $sql -> db_Fetch(); $date = $row['end_date']; $enddate = date("d/m/y \\a\\t ga", $date); $text .= "Challenge Sent By: ".$row['user_name']."
Challange On Game: ".$row['game_title']."
End Date: ".$enddate."
"; if ($pref['arcade_goldactive'] == Yes) { $text .= "Bet (g): ".$row['bet']."
"; } if ($row['comments'] == $blank) { $comments = 'None'; } else { $comments = $row['comments']; } $text .="
Senders Comments: ".$comments."
"; if ($game['score'] == $blank) { $score = '0'; } else { $score = $game['score']; } $text.="
Your Current Score: ".$score.""; if ($game2['score'] == $blank) { $score2 = '0'; } else { $score2 = $game2['score']; } $text.="
Opponents Current Score: ".$score2."

Current Challenge Status: "; if ($game['score'] > $game2['score']) { $text .="You are currently winning the challenge! Keep up the good work!"; } elseif ($game['score'] == $game2['score']) { $text .="You are currently drawing! A draw will only win you half of the bet!"; } else { $text .="You are currently loosing the challenge!! YOU DINGUS! GET PLAYING THE GAME NOW!"; } $text .= "

NOTE: The scores shown above are your/their all time highest score on that game, therefore when you view the games page, the score may not be in the highscore board as this only accounts for scores made this month!"; $text .="

<< Back"; $ns->tablerender("Current Challenges","".$text.""); require_once(FOOTERF); exit; } if (isset($_GET['sentdetails'])) { $sql->mySQLresult = @mysql_query("SELECT c.id, c.chalto, c.game, c.bet, c.end_date, c.comments, u.user_name, g.game_title FROM ".MPREFIX."archallenges c, ".MPREFIX."user u, ".MPREFIX."argames g WHERE c.id=".$_GET['sentdetails']." and u.user_id=c.chalto and g.game_id=c.game and c.status=2 ORDER BY c.id DESC"); $row = $sql -> db_Fetch(); $sql->mySQLresult = @mysql_query("SELECT score FROM ".MPREFIX."arscores WHERE game_id=".$row['game']." and user_id=".USERID." ORDER BY score DESC LIMIT 0,1"); $game = $sql -> db_Fetch(); $sql->mySQLresult = @mysql_query("SELECT score FROM ".MPREFIX."arscores WHERE game_id=".$row['game']." and user_id=".$row['chalto']." ORDER BY score DESC LIMIT 0,1"); $game2 = $sql -> db_Fetch(); $date = $row['end_date']; $enddate = date("d/m/y \\a\\t ga", $date); $text .= "Challenge Sent To: ".$row['user_name']."
Challange On Game: ".$row['game_title']."
End Date: ".$enddate."
"; if ($pref['arcade_goldactive'] == Yes) { $text .= "Bet (g): ".$row['bet']."
"; } if ($row['comments'] == $blank) { $comments = 'None'; } else { $comments = $row['comments']; } $text .="
Senders Comments: ".$comments."
"; if ($game['score'] == $blank) { $score = '0'; } else { $score = $game['score']; } $text.="
Your Current Score: ".$score.""; if ($game2['score'] == $blank) { $score2 = '0'; } else { $score2 = $game2['score']; } $text.="
Opponents Current Score: ".$score2."

Current Challenge Status: "; if ($game['score'] > $game2['score']) { $text .="You are currently winning the challenge! Keep up the good work!"; } elseif ($game['score'] == $game2['score']) { $text .="You are currently drawing! A draw will only win you half of the bet!"; } else { $text .="You are currently loosing the challenge!! YOU DINGUS! GET PLAYING THE GAME NOW!"; } $text .= "

NOTE: The scores shown above are your/their all time highest score on that game, therefore when you view the games page, the score may not be in the highscore board as this only accounts for scores made this month!"; $text .="

<< Back"; $ns->tablerender("Current Challenges","".$text.""); require_once(FOOTERF); exit; } if (isset($_GET['ended'])) { $sql->mySQLresult = @mysql_query("SELECT c.id, c.chalto, c.chalby, c.game, c.bet, c.won, c.end_date, c.comments, u.user_name, g.game_title FROM ".MPREFIX."archallenges c, ".MPREFIX."user u, ".MPREFIX."argames g WHERE c.id=".$_GET['ended']." and g.game_id=c.game ORDER BY c.id DESC"); $row = $sql -> db_Fetch(); $sql->mySQLresult = @mysql_query("SELECT user_name FROM ".MPREFIX."user WHERE user_id=".$row['chalby'].""); $username1 = $sql -> db_Fetch(); $sql->mySQLresult = @mysql_query("SELECT user_name FROM ".MPREFIX."user WHERE user_id=".$row['chalto'].""); $username2 = $sql -> db_Fetch(); if (USERID != $row['chalto'] and USERID != $row['chalby']) { $ns->tablerender("Error","You do not have permission to view this page!"); require_once(FOOTERF); exit; } $date = $row['end_date']; $enddate = date("d/m/y \\a\\t ga", $date); $text .= "Challenge Sent By:"; if ($row['chalby'] == USERID) { $sentby = "You (".$username1['user_name'].")"; } else { $sentby = $username1['user_name']; } $text .= " ".$sentby.""; if ($row['chalto'] == USERID) { $sentto = "You (".$username2['user_name'].")"; } else { $sentto = $username2['user_name']; } $text .= "
Challenge Sent To: ".$sentto."
Challenge On Game: ".$row['game_title']."
Challenge Ended On: ".$enddate."
"; if ($pref['arcade_goldactive'] == Yes) { $text .= "Bet Was (g): ".$row['bet']."
"; } if ($row['comments'] == $blank) { $comments = 'None'; } else { $comments = $row['comments']; } $text .="
Senders Comments: ".$comments."

"; $half = round($row['bet'] / 2); if ($row['won'] == USERID) { $text .="You won this challenge and the bet of ".$row['bet']."g"; } elseif ($row['won'] == DR) { $text .="This challenge ended in a draw, which meant you got half of the bet which was ".$half."g!"; } else { $text .="You lost this challenge! and lost the bet of ".$row['bet']."g! YOU SPANNER!"; } $text .="

<< Back"; $ns->tablerender("Current Challenges","".$text.""); require_once(FOOTERF); exit; } // CURRENT CHALLENGES $sql->mySQLresult = @mysql_query("SELECT c.id, c.chalby, c.game, c.bet, c.status, c.end_date, u.user_name, g.game_title FROM ".MPREFIX."archallenges c, ".MPREFIX."user u, ".MPREFIX."argames g WHERE c.chalto=".USERID." and u.user_id=c.chalby and g.game_id=c.game and c.status=2 and c.finished=0 ORDER BY c.id DESC"); $rows = $sql->db_Rows(); $blank = ""; $text1 .= ""; $text1 .= ""; if ($rows == 0) { $text1 .= ""; } else { for ($i = 0; $i < $rows; $i++) { $row = $sql->db_Fetch(); $date = $row['end_date']; $enddate = date("d/m/y", $date); $text1 .=""; if ($row['status'] == 2) { $text1 .=""; } else { $text1 .=""; } $text1 .=""; } } $sql->mySQLresult = @mysql_query("SELECT c.id, c.chalto, c.game, c.bet, c.end_date, c.status, u.user_name, g.game_title FROM ".MPREFIX."archallenges c, ".MPREFIX."user u, ".MPREFIX."argames g WHERE c.chalby=".USERID." and u.user_id=c.chalto and g.game_id=c.game and c.finished=0 ORDER BY c.status DESC"); $rows = $sql->db_Rows(); $blank = ""; $text1 .= ""; if ($rows == 0) { $text1 .= ""; } else { for ($i = 0; $i < $rows; $i++) { $row = $sql->db_Fetch(); $date = $row['end_date']; $enddate = date("d/m/y", $date); $text1 .=""; if ($row['status'] == 1) { $text1 .=""; $text1 .=""; } elseif ($row['status'] == 2) { $text1 .=""; $text1 .=""; } elseif ($row['status'] == 0) { $text1 .=""; $text1 .=""; //$sql->db_Delete("archallenges", "id='".$row['id']."'"); } $text1 .=""; } } $text1 .= "
From Game Current Status    
Recieved
There are currently no active challenges

".$row['user_name']." ".$row['game_title']."Challenge in Play!Challenge Pending[View Details]
Sent
You have not sent any new challenges
".$row['user_name']." ".$row['game_title']."Pending Acception! Challenge In Play![View Details]Challenge Rejected![Delete]
"; $text1 .= "
-----
[Send New Challenge]"; $ns->tablerender("Current Challenges","".$text1.""); // RECIEVED CHALLENGES $sql->mySQLresult = @mysql_query("SELECT c.id, c.chalby, c.game, c.bet, c.end_date, u.user_name, g.game_title FROM ".MPREFIX."archallenges c, ".MPREFIX."user u, ".MPREFIX."argames g WHERE c.chalto=".USERID." and u.user_id=c.chalby and g.game_id=c.game and c.status=1 ORDER BY c.id DESC"); $rows = $sql->db_Rows(); $blank = ""; if ($rows == 0) { $text .= "You have not recieved any new Arcade Challenges"; } else { $text .= ""; if ($pref['arcade_goldactive'] == Yes) { $text .= ""; } $text .= ""; for ($i = 0; $i < $rows; $i++) { $row = $sql->db_Fetch(); $date = $row['end_date']; $enddate = date("d/m/y", $date); $text .=""; if ($pref['arcade_goldactive'] == Yes) { $text .= ""; } $text .= ""; } $text .= "
FromGameBetEnd Date 
".$row['user_name']." ".$row['game_title']."".$row['bet']."g".$enddate."  
"; } $ns->tablerender("Recieved Challenges","".$text.""); // ENDED CHALLENGES $text3 .= ""; $sql->mySQLresult = @mysql_query("SELECT won FROM ".MPREFIX."archallenges WHERE finished=1 and chalto=".USERID.""); $count1 = $sql->db_Rows(); $sql->mySQLresult = @mysql_query("SELECT won FROM ".MPREFIX."archallenges WHERE finished=1 and chalby=".USERID.""); $count2 = $sql->db_Rows(); if ($count1 == 0 && $count2 == 0) { $text3 .= ""; } else { $sql->mySQLresult = @mysql_query("SELECT c.id, c.chalby, c.game, c.bet, c.status, c.won, c.end_date, u.user_name, g.game_title FROM ".MPREFIX."archallenges c, ".MPREFIX."user u, ".MPREFIX."argames g WHERE c.chalto=".USERID." and u.user_id=c.chalby and g.game_id=c.game and c.finished=1 and c.chalto=".USERID." ORDER BY c.id DESC LIMIT 0,12"); $rows = $sql->db_Rows(); $blank = ""; //$text3 .= ""; for ($i = 0; $i < $rows; $i++) { $row = $sql->db_Fetch(); $date = $row['end_date']; $enddate = date("d/m/y", $date); $text3 .=""; if ($row['won'] == USERID) { $text3 .=""; } elseif ($row['won'] == DR) { $text3 .=""; } else { $text3 .=""; } $text3 .=""; //$text3 .=""; } $sql->mySQLresult = @mysql_query("SELECT c.id, c.chalto, c.game, c.bet, c.end_date, c.status, c.won, u.user_name, g.game_title FROM ".MPREFIX."archallenges c, ".MPREFIX."user u, ".MPREFIX."argames g WHERE c.chalby=".USERID." and u.user_id=c.chalto and g.game_id=c.game and c.finished=1 and c.chalby=".USERID." ORDER BY c.id DESC LIMIT 0,12"); $rows = $sql->db_Rows(); $blank = ""; //$text3 .= ""; for ($i = 0; $i < $rows; $i++) { $row = $sql->db_Fetch(); $date = $row['end_date']; $enddate = date("d/m/y", $date); $text3 .=""; if ($row['won'] == USERID) { $text3 .=""; } elseif ($row['won'] == DR) { $text3 .=""; } else { $text3 .=""; } $text3 .=""; $text .= ""; //$text3 .=""; } } $text3 .= "
Ended On Game Status    
No challenges have ended yet!
- RECIEVED CHALLENGES
".$enddate." ".$row['game_title']."You Won!Ended as Draw!You Lost![View Details]

Sent
".$enddate." ".$row['game_title']."You Won!Ended as Draw!You Lost![View Details]

"; $ns->tablerender("Ended Challenges","".$text3.""); require_once(FOOTERF); ?>