/View/Requests.php

https://bitbucket.org/onlinechessportal/onlinechessgameportal · PHP · 273 lines · 248 code · 25 blank · 0 comment · 44 complexity · f2665c3d9cf30405567434cb5aae212d MD5 · raw file

  1. <?php
  2. require '../Model/Connect.php';
  3. require '../Control/RegisterLogic.php';
  4. require '../Control/LoginLogic.php';
  5. require '../Control/SendNotification.php';
  6. require '../Control/CreateClubLogic.php';
  7. ob_start();
  8. $UserNm=$_SESSION['username'];
  9. $Role = $_SESSION['role'];
  10. ?>
  11. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  12. <html xmlns="http://www.w3.org/1999/xhtml">
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  15. <title>Online Chess Portal </title>
  16. <!-- CSS Files -->
  17. <link href="css/reset.css" rel="stylesheet" type="text/css" />
  18. <link href="css/Form.css" rel="stylesheet" type="text/css" />
  19. <link href="css/screen.css" rel="stylesheet" type="text/css" />
  20. <link href="css/style.css" rel="stylesheet" type="text/css" />
  21. <link rel="stylesheet" type="text/css" href="css/superfish.css" media="screen" />
  22. <link rel="stylesheet" type="text/css" href="css/jquery.gritter.css" />
  23. <!-- End of CSS Files -->
  24. <!-- Javascript Files -->
  25. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
  26. <script type="text/javascript" src="javascript/jquery.cycle.all.js"></script>
  27. <script type="text/javascript" src="javascript/superfish.js"></script>
  28. <script type="text/javascript" src="javascript/dd.min.js"></script>
  29. <script type="text/javascript" src="javascript/popup-window.js"></script>
  30. <script type="text/javascript" src="javascript/wufoo.js"></script>
  31. <script type="text/javascript" src="http://www.google.com/jsapi"></script>
  32. <script type="text/javascript">google.load('jquery', '1.5');</script>
  33. <script type="text/javascript" src="js/jquery.gritter.js"></script>
  34. <script type="text/javascript">
  35. <!--popup-->
  36. var time_interval = setInterval(
  37. function ()
  38. {
  39. $('#popup').load('../Control/Notification.php').fadeIn("slow");
  40. }, 5000); // refresh every 5000 milliseconds
  41. </script>>
  42. <!-- End of Javascript Files -->
  43. </head>
  44. <body>
  45. <!-- Wrapper -->
  46. <div id="wrapper">
  47. <div id="topbar">
  48. <img src="images/icon1.png" alt="logo" width="42" height="41" class="logo" id='test' /><img src="images/logo.gif" alt="logo" width="322" height="41" class="logo1" id='test' />
  49. <div id="secnav">
  50. <ul>
  51. <li> <a href="../Control/LogoutLogic.php?Reason=Normal">SIGN OUT</a> </li>
  52. <li class="noimg"></li>
  53. </ul>
  54. </div>
  55. <div class="menu">
  56. <ul class="sf-menu">
  57. <li> <a class="on" href="Home.php">HOME</a></li>
  58. <li> <?php if($_SESSION['role'] == 'SiteAdmin') {
  59. ?> <a href="SiteAdminProfile.php">
  60. <?php } else { ?>
  61. <a href="MemberProfile.php">
  62. <?php }
  63. $result = mysql_query("SELECT mp_fullname FROM memberprofile WHERE mp_username='".$_SESSION['username']."' ");
  64. $row = mysql_fetch_array($result);
  65. if($_SESSION['role'] == 'SiteAdmin') {
  66. echo 'Profile';
  67. } else {
  68. echo $row['mp_fullname'];
  69. }?></a>
  70. </li>
  71. <li> <a href="SearchClub.php">Clubs</a> </li>
  72. <li> <a href="Inbox.php">Messages</a> </li>
  73. </ul>
  74. </div> </div><!-- menu end-->
  75. <div id="content">
  76. <div class="froms">
  77. <span id="popup"></span>
  78. <form method="post" action="">
  79. <input type="submit" class="Buttonview" value="Club Creation Requests" name="CCR" style="visibility:hidden"/>
  80. <input type="hidden" name="step" value="1"/>
  81. </form>
  82. <form method="post" action="">
  83. <input type="submit" class="Buttonview" value="Private Tournament Creation Requests" name="TCR" style="visibility:hidden"/>
  84. <input type="hidden" name="step" value="2"/>
  85. </form>
  86. <form method="post" action="">
  87. <input type="submit" class="Buttonview" value="Club Reqs" name="CR" style="visibility:hidden"/>
  88. <input type="hidden" name="step" value="3"/>
  89. </form>
  90. <?php
  91. if(isset($_POST['step']) || isset($_POST['CCR']) || isset($_POST['TCR']) || isset($_POST['CR'])) {
  92. if($_POST['step'] == 1) {
  93. $result = mysql_query("SELECT * FROM clubcreaterequest WHERE ccr_status=1");
  94. echo "<table width='100%' id='ClubCreationReqTab' table border='2' style='border:#999999' style='visibility:hidden'>";
  95. $QueryNumRows = mysql_num_rows ($result);
  96. if ($QueryNumRows == 0) {
  97. echo '<script language="javascript">alert("No Requests has been recieved")</script>';
  98. } else {
  99. while($row = mysql_fetch_array($result))
  100. {
  101. $From = $row['ccr_from'];
  102. $ClubName = $row['ccr_name'];
  103. $ClubType = $row['ccr_type'];
  104. $Status = $row['ccr_status'];
  105. echo "<tr> ";
  106. echo "<td><strong>".$From." </td>
  107. <td>".$ClubName."</td>
  108. <td>".$ClubType."</td>
  109. <td> ".$Status."</td>
  110. <td><form method=\"post\">
  111. <input type=\"submit\" value=\"Accept\"/>
  112. <input type=\"hidden\" value=\"12\" name=\"step\"/>
  113. <input type=\"hidden\" value=$From name=\"Creator\"/>
  114. <input type=\"hidden\" value=$ClubName name=\"ClubName\"/>
  115. <input type=\"hidden\" value=$ClubType name=\"ClubType\"/>
  116. <input type=\"hidden\" value=$Status name=\"Status\"/>
  117. </form> </td></tr>";
  118. }
  119. }
  120. } else if($_POST['step'] == 2) {
  121. $result = mysql_query("SELECT * FROM tourcreaterequest WHERE tcr_status=1");
  122. echo "<table width='100%' id='ClubCreationReqTab' table border='2' style='border:#999999' style='visibility:hidden'>";
  123. $QueryNumRows = mysql_num_rows ($result);
  124. if ($QueryNumRows == 0) {
  125. echo '<script language="javascript">alert("No Requests has been recieved")</script>';
  126. } else {
  127. while($row = mysql_fetch_array($result))
  128. {
  129. $From = $row['tcr_from'];
  130. $TourName = $row['tcr_name'];
  131. $Status = $row['tcr_status'];
  132. echo "<tr> ";
  133. echo "<td><strong>".$From." </td>
  134. <td>".$TourName."</td>
  135. <td> ".$Status."</td>
  136. <td><form method=\"post\">
  137. <input type=\"submit\" value=\"Accept\"/>
  138. <input type=\"hidden\" value=\"22\" name=\"step\"/>
  139. <input type=\"hidden\" value=$From name=\"Creator\"/>
  140. <input type=\"hidden\" value=$TourName name=\"ClubName\"/>
  141. <input type=\"hidden\" value=$Status name=\"Status\"/>
  142. </form> </td></tr>";
  143. }
  144. }
  145. } else if($_POST['step'] == 3) {
  146. $result = mysql_query("SELECT * FROM clubcreaterequest WHERE ccr_status=1");
  147. echo "<table width='100%' id='ClubCreationReqTab' table border='2' style='border:#999999' style='visibility:hidden'>";
  148. $QueryNumRows = mysql_num_rows ($result);
  149. if ($QueryNumRows == 0) {
  150. echo '<script language="javascript">alert("No Requests has been recieved")</script>';
  151. } else {
  152. while($row = mysql_fetch_array($result))
  153. {
  154. $To = $row['ccr_from'];
  155. $From = $row['ccr_name'];
  156. $Message = $row['ccr_type'];
  157. $MID = $row['ccr_status'];
  158. }
  159. }
  160. } else if($_POST['step'] == 12) {
  161. if(isset($_POST['ClubName']) && isset($_POST['ClubType']) && isset($_POST['Creator']) && isset($_POST['Status'] )) {
  162. $ClubID = InsertClub($_POST['ClubName'],$_POST['ClubType'],$_POST['Creator'],'DefaultClub.jpg');
  163. if($ClubID) {
  164. $Message = 'Dear Member, Please notify that the requset to creat the new Paying club have been rejected because there is a similar club within this site.';
  165. echo '<script language="javascript">alert("the club is already exsting")</script>';
  166. } else {
  167. $Message = 'Dear Member, Please notify that the requset to creat the new Playing club have been Authenticated. <a href="ClubProfile.php"?ClubNo='.$ClubID.'&Admin='.$_POST['Creator'].'> Go to Club </a>';
  168. }
  169. DeleteClubReq($_POST['ClubName'],$_POST['ClubType'],$_POST['Creator']);
  170. $Notify = new Notification();
  171. $To = $_POST['Creator'];
  172. $User = $_SESSION['username'];
  173. $time = time();
  174. $From = GetFullName($User);
  175. $MsgID = GetMaxMsgID();
  176. $Result = $Notify->SendMessage($To,$From,$Message,$MsgID,$time);
  177. }
  178. } else if($_POST['step'] == 22) {
  179. if(isset($_POST['TourName']) && isset($_POST['Creator']) && isset($_POST['Status'] )) {
  180. InsertTournament($_POST['TourName'],$_POST['Creator'],'DefaultClub.gif');
  181. DeleteTourReq($_POST['TourName'],$_POST['Creator']);
  182. $Notify = new Notification();
  183. $To = $_POST['Creator'];
  184. $Message = 'Dear Member, Please notify that the requset to creat the new Paying club have been Authenticated.';
  185. $User = $_SESSION['username'];
  186. $time = time();
  187. $From = GetFullName($User);
  188. $MsgID = GetMaxMsgID();
  189. $Result = $Notify->SendMessage($To,$From,$Message,$MsgID,$time);
  190. }
  191. }
  192. }
  193. ?>
  194. </table>
  195. </div></div>
  196. <div id="sidebar">
  197. <li class="content">
  198. <!--------------------------------------------------------------->
  199. <h2>Requests</h2>
  200. <ul>
  201. <li><a href="ClubCreationReq.php">Club Creation</a></li>
  202. <li><a href="TourCreationReq.php">Tournament Creation</a></li>
  203. </ul>
  204. </li>
  205. </div>
  206. <!-- topbar-->
  207. <div class="clear"></div>
  208. <div id="footers">
  209. <div style="float:right"><div class="fotterlast">
  210. <a href="#" title="About Us">About Us</a>
  211. |
  212. <a href="#" title="Terms of Service">Terms of Service</a>
  213. |
  214. <a href="#" title="Privacy Statement">Privacy</a>
  215. |
  216. <a href="Contact.php" title="Contact Us">Contact Us</a>
  217. </div></div>
  218. <div style="float:Left"><div class="fotterlastdesing">Designed by SEP_WE_05 Team.</div></div>
  219. </div>
  220. </div>
  221. </div>
  222. </div>
  223. </body>
  224. </html>
  225. <?php
  226. function GetFullName($User) {
  227. $GetNameFrom = "SELECT mp_fullname FROM memberprofile WHERE mp_username = '".$User."' ";
  228. $ResultNameFrom = mysql_query($GetNameFrom);
  229. if ($ResultNameFrom) {
  230. $rows = mysql_num_rows($ResultNameFrom);
  231. while($info = mysql_fetch_assoc( $ResultNameFrom)) {
  232. $From = $info['mp_fullname'];
  233. }
  234. return $From;
  235. }
  236. }
  237. function GetMaxMsgID() {
  238. $sql = "SELECT max(no_ID)+1 AS x FROM notify ";
  239. $ResultSql = mysql_query($sql);
  240. if ($ResultSql) {
  241. $rows = mysql_num_rows($ResultSql);
  242. while($info = mysql_fetch_assoc( $ResultSql)) {
  243. $MsgID = $info['x'];
  244. }
  245. return $MsgID;
  246. }
  247. }
  248. ?>