PageRenderTime 44ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/View/ViewReport1.php

https://bitbucket.org/onlinechessportal/onlinechessgameportal
PHP | 256 lines | 218 code | 22 blank | 16 comment | 21 complexity | cdec4b3e65f1408c1de99eddf1e1d954 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. require '../Control/RegisterLogic.php';
  3. ob_start();
  4. if(LoggedIn()) {
  5. $User = $_SESSION['username'] ;
  6. mysql_connect("localhost", "root", "") or die(mysql_error());
  7. mysql_select_db("OnlineChessGamePortal") or die(mysql_error());
  8. } else {
  9. echo '<script language="javascript">alert("You are not logged in")</script>';
  10. echo '<script type="text/javascript"> window.location = "../View/Home.php"</script>';
  11. }
  12. ?>
  13. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  14. <html xmlns="http://www.w3.org/1999/xhtml">
  15. <head>
  16. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  17. <title>Collapsible Message Panels</title>
  18. <script type="text/javascript" src="jquery.js"></script>
  19. <script type="text/javascript">
  20. $(document).ready(function(){
  21. //hide message_body after the first one
  22. $(".message_list .message_body:gt(0)").hide();
  23. //hide message li after the 5th
  24. $(".message_list li:gt(4)").hide();
  25. //toggle message_body
  26. $(".message_head").click(function(){
  27. $(this).next(".message_body").slideToggle(500)
  28. return false;
  29. });
  30. //collapse all messages
  31. $(".collpase_all_message").click(function(){
  32. $(".message_body").slideUp(500)
  33. return false;
  34. });
  35. //show all messages
  36. $(".show_all_message").click(function(){
  37. $(this).hide()
  38. $(".show_recent_only").show()
  39. $(".message_list li:gt(4)").slideDown()
  40. return false;
  41. });
  42. //show recent messages only
  43. $(".show_recent_only").click(function(){
  44. $(this).hide()
  45. $(".show_all_message").show()
  46. $(".message_list li:gt(4)").slideUp()
  47. return false;
  48. });
  49. });
  50. </script>
  51. <style type="text/css">
  52. * {
  53. margin: 0;
  54. padding: 0;
  55. }
  56. body {
  57. margin: 10px auto;
  58. width: 570px;
  59. font: 75%/120% Arial, Helvetica, sans-serif;
  60. }
  61. p {
  62. padding: 0 0 1em;
  63. }
  64. /* message display page */
  65. .message_list {
  66. list-style: none;
  67. margin: 0;
  68. padding: 0;
  69. width: 383px;
  70. }
  71. .message_list li {
  72. padding: 0;
  73. margin: 0;
  74. background: url(images/message-bar.gif) no-repeat;
  75. }
  76. .message_head {
  77. padding: 5px 10px;
  78. cursor: pointer;
  79. position: relative;
  80. }
  81. .message_head .timestamp {
  82. color: #666666;
  83. font-size: 95%;
  84. position: absolute;
  85. right: 10px;
  86. top: 5px;
  87. }
  88. .message_head cite {
  89. font-size: 100%;
  90. font-weight: bold;
  91. font-style: normal;
  92. }
  93. .message_body {
  94. padding: 5px 10px 15px;
  95. }
  96. .collapse_buttons {
  97. text-align: right;
  98. border-top: solid 1px #e4e4e4;
  99. padding: 5px 0;
  100. width: 383px;
  101. }
  102. .collapse_buttons a {
  103. margin-left: 15px;
  104. float: right;
  105. }
  106. .show_all_message {
  107. background: url(images/tall-down-arrow.gif) no-repeat right center;
  108. padding-right: 12px;
  109. }
  110. .show_recent_only {
  111. display: none;
  112. background: url(images/tall-up-arrow.gif) no-repeat right center;
  113. padding-right: 12px;
  114. }
  115. .collpase_all_message {
  116. background: url(images/collapse-all.gif) no-repeat right center;
  117. padding-right: 12px;
  118. color: #666666;
  119. }
  120. </style>
  121. <script type="text/javascript">
  122. function show_confirm(from,about,reason)
  123. {
  124. var answer = confirm("Delete entry ?")
  125. if (answer){
  126. alert("Entry Deleted")
  127. <!--window.location = "links.php?act=trackdelete&id="+ID;
  128. window.location = "../../Control/DeleteReport.php?from="+from+"&about="+about+"&reason="+reason;
  129. }
  130. else
  131. {
  132. alert("You pressed Cancel!");
  133. }
  134. }
  135. </script>
  136. </head>
  137. <body>
  138. <?php
  139. $Result = true;
  140. $About="";
  141. $From="";
  142. $Reason="";
  143. $sql = "SELECT * FROM report GROUP BY re_about ";
  144. if ($result = mysql_query($sql)) {
  145. $rows = mysql_num_rows($result);
  146. if ($rows > 0) {
  147. while($info = mysql_fetch_assoc( $result )) {
  148. $About = $info['re_about'];
  149. $From = $info['re_from'];
  150. $Reason = $info['re_reason'];
  151. //check for related clubs and forward it to club admin
  152. $id = GetClub($About);
  153. if($id) {
  154. //forward report
  155. $sqlGetClub = "SELECT cl_administrator FROM club WHERE cl_id=".$id."";
  156. $resultClub = mysql_query($sqlGetClub);
  157. $infoClub = mysql_fetch_assoc( $resultClub );
  158. $Admin = $infoClub['cl_administrator'];
  159. if ($resultClub) {
  160. $InsertSql = "INSERT INTO forwardreport VALUES ('".$From."','".$About."','".$Reason."','".$Admin."')";
  161. $resultInsert = mysql_query($InsertSql);
  162. if($resultInsert) {
  163. $DeleteSql = "DELETE FROM report WHERE re_about = '".$About."' AND re_from = '".$From."' AND re_reason = '".$Reason."'";
  164. $ResultDelete = mysql_query($DeleteSql);
  165. if($ResultDelete) {
  166. echo '<script language="javascript">alert("Forward and Deletion success")</script>';
  167. echo '<script type="text/javascript"> window.location = "../View/ViewReport.php"</script>';
  168. } else {
  169. echo '<script language="javascript">alert("Forward success. Deletion not success")</script>';
  170. echo '<script type="text/javascript"> window.location = "../View/ViewReport.php"</script>';
  171. }
  172. } else {
  173. echo '<script language="javascript">alert("Forward Failed")</script>';
  174. echo '<script type="text/javascript"> window.location = "../View/ViewReport.php"</script>';
  175. }
  176. } else {
  177. echo "UOOO";
  178. echo '<script language="javascript">alert("This member does not belong to any club")</script>';
  179. echo '<script type="text/javascript"> window.location = "../View/ViewReport.php"</script>';
  180. }
  181. //end of forwarding
  182. } else {
  183. //the member does not belong to any club
  184. $sqlNoReports = "SELECT COUNT(re_about) as x FROM report WHERE re_from = '".$From."' AND re_about = '".$About."'";
  185. $resultNoReports = mysql_query($sqlNoReports);
  186. if ($resultNoReports ) {
  187. $rowsNoReports = mysql_num_rows($resultNoReports);
  188. while($info = mysql_fetch_assoc( $resultNoReports )) {
  189. $NumofReports = $info['x'];
  190. }
  191. echo " <li>\n";
  192. echo " <div class=\"message_body\">\n";
  193. echo " <p><br />\n";
  194. echo $About." has been reported ". $NumofReports. " time/s by other users </";
  195. echo "<br/><br/>";
  196. if($NumofReports > 10) {
  197. //blacklist member permanently
  198. Print "<a href = ../Control/Backlist2.php?from=".$From."&about=".$About."&reason=".$Reason.">Blacklist</a>&nbsp; " ;
  199. } else if ($NumofReports > 1) {
  200. //blacklist member temperary
  201. Print "<a href = ../Control/BacklistTemp.php?from=".$From."&about=".$About."&reason=".$Reason.">Blacklist</a>&nbsp; " ;
  202. } /*else if($NumofReports > 1) {
  203. //send warning
  204. Print "<a href = ../../Control/SendWarning.php?from=".$From."&about=".$About."&reason=".$Reason.">Send Warning</a>&nbsp; " ;
  205. }*/ else {
  206. //take no action
  207. }
  208. }
  209. }
  210. Print "<a href = ../Control/DeleteReport.php?from=".$From."&about=".$About."&reason=".$Reason.">Delete </a>&nbsp;" ;
  211. echo "<a href = \"#\" onclick=\"show_confirm(".$From.".".$About.",".$Reason.")\">delete</a>\n";
  212. }//end of while
  213. } else {
  214. echo '<script language="javascript">alert("No reports to display")</script>';
  215. echo '<script type="text/javascript"> window.location = "SiteAdminProfile.php"</script>';
  216. }
  217. }
  218. function GetClub($About){
  219. $sql = "SELECT DISTINCT cm_clubid FROM clubmember WHERE cm_member=".$About." ";
  220. $Result = mysql_query($sql);
  221. if ($Result) {
  222. $rows = mysql_num_rows($Result);
  223. while($info = mysql_fetch_assoc( $Result )) {
  224. $ID = $info['cm_clubid'];
  225. }
  226. return $ID;
  227. } else {
  228. return false;
  229. }
  230. }
  231. ?>
  232. <p class="collapse_buttons"><a href="#" class="show_all_message">Show all message <?php (".$rows.") ?></a> <a href="#" class="show_recent_only">Show 5 only</a> <a href="#" class="collpase_all_message">Collapse all</a></p>
  233. </body>
  234. </html>