/Control/TournamentAccept.php
PHP | 80 lines | 56 code | 21 blank | 3 comment | 8 complexity | d7731de9ad0bdf26b3798070ef3ec5f0 MD5 | raw file
Possible License(s): LGPL-2.1
- <?php
- require '../Model/Connect.php';
- require 'SendNotification.php';
- $Notify = new Notification();
-
- $from = $_REQUEST['from'];
- $Trid=$_REQUEST['id'];
-
- if(isset($_REQUEST['from']) && isset($_REQUEST['id'])) {
-
-
- $SelectResult = mysql_query("SELECT * FROM tournamentaccept where ta_user='".$_REQUEST['from']."' and ta_tournamentid= '".$_REQUEST['id']."'");
-
- if (mysql_num_rows($SelectResult) == 1) {
- mysql_query("UPDATE `onlinechessgameportal`.`tournamentrequest` SET `tr_status` = 4 WHERE `tournamentrequest`.`tr_ID` ='".$_REQUEST['id']."' AND `tournamentrequest`.`tr_from` = '".$_REQUEST['from']."'");
- echo '<script language="javascript">alert("All Rady Accept")</script>';
- echo'<script type="text/javascript"> window.location = "Accept.php"</script>';
-
- }
- else{
- $sql = mysql_query("SELECT count(`ta_user`) FROM `tournamentaccept`where ta_tournamentid='".$_REQUEST['id']."' group by `ta_tournamentid` LIMIT 0, 30");
- $AcceptCount ="";
- $participants="";
- while($row = mysql_fetch_assoc($sql)){
-
- $AcceptCount=$row['count(`ta_user`)'];
-
- }
-
- $sql1 = mysql_query("SELECT `to_participants` FROM `tournament` WHERE `to_id`='".$_REQUEST['id']."' LIMIT 0, 30 ");
- while($row = mysql_fetch_assoc($sql1)){
-
- $participants=$row['to_participants'];
-
- }
- if($participants<=$AcceptCount){
-
- //send the msg about the reject
- $To = $_REQUEST['from'];
- $From = $_REQUEST['to'];
- $Message = "Please notice that your request to join this tournament is rejected because the limit is exeeded.";
- $Time = time();
-
- $sql = "SELECT max(no_ID)+1 AS x FROM notify ";
- $ResultSql = mysql_query($sql);
- if ($ResultSql) {
- $rows = mysql_num_rows($ResultSql);
- while($info = mysql_fetch_assoc( $ResultSql)) {
- $MsgID = $info['x'];
- }
- }
-
- $Result = $Notify->SendMessage($To,$From,$Message,$MsgID,$Time);
-
-
-
- if($Result) {
- echo '<script language="javascript">alert("Limit Exeed. Petitioner is notified")</script>';
- echo '<script type="text/javascript"> window.location = "Accept.php"</script>';
- } else {
- echo '<script language="javascript">alert("Limit Exeed.")</script>';
- echo '<script type="text/javascript"> window.location = "Accept.php"</script>';
- }
-
-
- mysql_query("UPDATE `onlinechessgameportal`.`tournamentrequest` SET `tr_status` = 3 WHERE `tournamentrequest`.`tr_ID` ='".$_REQUEST['id']."' AND `tournamentrequest`.`tr_from` = '".$_REQUEST['from']."'");
- }
-
- else{
- mysql_query("INSERT INTO tournamentaccept (ta_user,ta_tournamentid) VALUES('".$_REQUEST['from']."', '".$_REQUEST['id']."')");
- mysql_query("UPDATE `onlinechessgameportal`.`tournamentrequest` SET `tr_status` = 1 WHERE `tournamentrequest`.`tr_ID` ='".$_REQUEST['id']."' AND `tournamentrequest`.`tr_from` = '".$_REQUEST['from']."'");
-
- echo '<script language="javascript">alert("Request is Accepted")</script>';
- echo '<script type="text/javascript"> window.location = "Accept.php"</script>';
- }
- }
- //$sql = mysql_query("UPDATE `onlinechessgameportal`.`tournamentrequest` SET `tr_status` = 1 WHERE `tournamentrequest`.`tr_ID` ='".$_REQUEST['id']."' AND `tournamentrequest`.`tr_from` = '".$_REQUEST['from']."'");
- //$re = mysql_query($sql);
- }
- ?>