PageRenderTime 33ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/Control/TournamentAccept.php

https://bitbucket.org/onlinechessportal/onlinechessgameportal
PHP | 80 lines | 56 code | 21 blank | 3 comment | 8 complexity | d7731de9ad0bdf26b3798070ef3ec5f0 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. require '../Model/Connect.php';
  3. require 'SendNotification.php';
  4. $Notify = new Notification();
  5. $from = $_REQUEST['from'];
  6. $Trid=$_REQUEST['id'];
  7. if(isset($_REQUEST['from']) && isset($_REQUEST['id'])) {
  8. $SelectResult = mysql_query("SELECT * FROM tournamentaccept where ta_user='".$_REQUEST['from']."' and ta_tournamentid= '".$_REQUEST['id']."'");
  9. if (mysql_num_rows($SelectResult) == 1) {
  10. mysql_query("UPDATE `onlinechessgameportal`.`tournamentrequest` SET `tr_status` = 4 WHERE `tournamentrequest`.`tr_ID` ='".$_REQUEST['id']."' AND `tournamentrequest`.`tr_from` = '".$_REQUEST['from']."'");
  11. echo '<script language="javascript">alert("All Rady Accept")</script>';
  12. echo'<script type="text/javascript"> window.location = "Accept.php"</script>';
  13. }
  14. else{
  15. $sql = mysql_query("SELECT count(`ta_user`) FROM `tournamentaccept`where ta_tournamentid='".$_REQUEST['id']."' group by `ta_tournamentid` LIMIT 0, 30");
  16. $AcceptCount ="";
  17. $participants="";
  18. while($row = mysql_fetch_assoc($sql)){
  19. $AcceptCount=$row['count(`ta_user`)'];
  20. }
  21. $sql1 = mysql_query("SELECT `to_participants` FROM `tournament` WHERE `to_id`='".$_REQUEST['id']."' LIMIT 0, 30 ");
  22. while($row = mysql_fetch_assoc($sql1)){
  23. $participants=$row['to_participants'];
  24. }
  25. if($participants<=$AcceptCount){
  26. //send the msg about the reject
  27. $To = $_REQUEST['from'];
  28. $From = $_REQUEST['to'];
  29. $Message = "Please notice that your request to join this tournament is rejected because the limit is exeeded.";
  30. $Time = time();
  31. $sql = "SELECT max(no_ID)+1 AS x FROM notify ";
  32. $ResultSql = mysql_query($sql);
  33. if ($ResultSql) {
  34. $rows = mysql_num_rows($ResultSql);
  35. while($info = mysql_fetch_assoc( $ResultSql)) {
  36. $MsgID = $info['x'];
  37. }
  38. }
  39. $Result = $Notify->SendMessage($To,$From,$Message,$MsgID,$Time);
  40. if($Result) {
  41. echo '<script language="javascript">alert("Limit Exeed. Petitioner is notified")</script>';
  42. echo '<script type="text/javascript"> window.location = "Accept.php"</script>';
  43. } else {
  44. echo '<script language="javascript">alert("Limit Exeed.")</script>';
  45. echo '<script type="text/javascript"> window.location = "Accept.php"</script>';
  46. }
  47. mysql_query("UPDATE `onlinechessgameportal`.`tournamentrequest` SET `tr_status` = 3 WHERE `tournamentrequest`.`tr_ID` ='".$_REQUEST['id']."' AND `tournamentrequest`.`tr_from` = '".$_REQUEST['from']."'");
  48. }
  49. else{
  50. mysql_query("INSERT INTO tournamentaccept (ta_user,ta_tournamentid) VALUES('".$_REQUEST['from']."', '".$_REQUEST['id']."')");
  51. mysql_query("UPDATE `onlinechessgameportal`.`tournamentrequest` SET `tr_status` = 1 WHERE `tournamentrequest`.`tr_ID` ='".$_REQUEST['id']."' AND `tournamentrequest`.`tr_from` = '".$_REQUEST['from']."'");
  52. echo '<script language="javascript">alert("Request is Accepted")</script>';
  53. echo '<script type="text/javascript"> window.location = "Accept.php"</script>';
  54. }
  55. }
  56. //$sql = mysql_query("UPDATE `onlinechessgameportal`.`tournamentrequest` SET `tr_status` = 1 WHERE `tournamentrequest`.`tr_ID` ='".$_REQUEST['id']."' AND `tournamentrequest`.`tr_from` = '".$_REQUEST['from']."'");
  57. //$re = mysql_query($sql);
  58. }
  59. ?>