PageRenderTime 69ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/View/GuestBook.php

https://bitbucket.org/onlinechessportal/onlinechessgameportal
PHP | 215 lines | 178 code | 35 blank | 2 comment | 37 complexity | cc324a99a711b65655cca5866c21951a MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. require '../Model/Connect.php';
  3. require '../Control/RegisterLogic.php';
  4. require '../Control/LoginLogic.php';
  5. require '../Control/SendMail.php';
  6. ?>
  7. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  8. <html xmlns="http://www.w3.org/1999/xhtml">
  9. <head>
  10. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  11. <title>Online Chess Portal </title>
  12. <!-- CSS Files -->
  13. <link href="css/reset.css" rel="stylesheet" type="text/css" />
  14. <link href="css/Form.css" rel="stylesheet" type="text/css" />
  15. <link href="css/style.css" rel="stylesheet" type="text/css" />
  16. <link rel="stylesheet" type="text/css" href="css/superfish.css" media="screen" />
  17. <style type="text/css">
  18. .sf-sub-indicator {
  19. behavior: url(css/iepngfix.htc)
  20. }
  21. ;
  22. </style>
  23. <!-- End of CSS Files -->
  24. <!-- Javascript Files -->
  25. <!-- End of Javascript Files -->
  26. </head>
  27. <body>
  28. <!-- Wrapper -->
  29. <div id="wrapper">
  30. <div id="topbar">
  31. <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' />
  32. <div id="secnav">
  33. <ul>
  34. <li> <a href="#" onclick="popup_show('popup1', 'popup_drag1', 'popup_exit1', 'screen-center', 0, 0);">SIGN UP</a> </li>
  35. </ul>
  36. </div>
  37. <div class="menu">
  38. <ul class="sf-menu">
  39. <li> <a class="on" href="Home.php">HOME</a></li>
  40. <li> <a href="Contact.php">Contact</a> </li>
  41. </ul>
  42. </div> </div><!-- menu end-->
  43. <div id="content_guest">
  44. <div class="froms">
  45. <?php
  46. require_once '../Model/Connect.php';
  47. $time = time();//current timestamp
  48. if (isset($_POST['gb_name'],$_POST['gb_email'],$_POST['gb_message'])) {
  49. $gb_name = mysql_real_escape_string(htmlentities($_POST['gb_name']));
  50. $gb_email = mysql_real_escape_string(htmlentities($_POST['gb_email']));
  51. $gb_message = mysql_real_escape_string(htmlentities($_POST['gb_message']));
  52. //if (isset($_POST['post'])) {
  53. if (empty($gb_name) || empty($gb_email) || empty($gb_message)) {
  54. echo '<script language="javascript">alert("All Fields are required.")</script>';
  55. } else {
  56. if (strlen($gb_name)>30 || strlen($gb_email)>30 || strlen($gb_message)>255) {
  57. echo '<script language="javascript">alert("One or more fields exeeded the character limit.")</script>';
  58. } else {
  59. $insert = "INSERT INTO guestBook VALUES ('','$time','$gb_name','$gb_email','$gb_message')";
  60. if (mysql_query($insert)) {
  61. $entries = mysql_query("SELECT `gb_timestamp`,gb_name,gb_email,gb_message FROM guestbook ORDER BY `gb_timestamp` DESC ");
  62. if (mysql_num_rows($entries) == 0) {
  63. echo 'No entries';
  64. } else {
  65. while($entries_row = mysql_fetch_assoc($entries)) {
  66. $entries_timestamp = date('d-M-Y @ h:i:s',$entries_row['gb_timestamp']);
  67. $entries_name = $entries_row['gb_name'];
  68. $entries_email = $entries_row['gb_email'];
  69. $entries_message = $entries_row['gb_message'];
  70. echo '<p><strong><font color=#000 face=\"Calibri\">Posted by '.$entries_name.' on '.$entries_timestamp.'</strong><br/>'.$entries_message.'</p>';
  71. }
  72. }
  73. } else {
  74. echo '<script language="javascript">alert("Something is wrong.Please try again later.")</script>';
  75. }
  76. }
  77. }
  78. //}
  79. }
  80. ?>
  81. <hr />
  82. <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="POST">
  83. <strong>Post Something...</strong><br />
  84. Name:<br/><input type="text" name="gb_name" maxlength="30" /><br />
  85. Email:<br/><input type="text" name="gb_email" maxlength="255" /> <br />
  86. Message:<br/><textarea name="gb_message" rows="6" cols="30" ></textarea><br />
  87. <input type="submit" value="Post" id="Post" class="Buttonview"/>
  88. </form>
  89. </div></div>
  90. <!-- topbar-->
  91. <div class="clear"></div>
  92. <div id="footers">
  93. <div style="float:right"><div class="fotterlast">
  94. <a href="#" title="About Us">About Us</a>
  95. |
  96. <a href="#" title="Terms of Service">Terms of Service</a>
  97. |
  98. <a href="#" title="Privacy Statement">Privacy</a>
  99. |
  100. <a href="Contact.php" title="Contact Us">Contact Us</a>
  101. </div></div>
  102. <div style="float:Left"><div class="fotterlastdesing">Designed by SEP_WE_05 Team.</div></div>
  103. </div>
  104. </div>
  105. </div>
  106. </div>
  107. <!--Register-->
  108. <div class="sample_popup" id="popup1" style="display: none;">
  109. <div class="menu_form_header" id="popup_drag1">
  110. <img class="menu_form_exit" id="popup_exit1" src="images/form_exit.png" alt="" />
  111. &nbsp;&nbsp;&nbsp;Sign Up
  112. </div>
  113. <div class="menu_form_body">
  114. <form action="" method="post">
  115. <table>
  116. <tr><th>Username: &nbsp;&nbsp;&nbsp;</th><td colspan="2"><input class="field" type="text" onfocus="select();" name="username" id="usernameR" onBlur="EmailValidation(document.getElementById('usernameR'))" placeholder="Your Username Here"/></td></tr>
  117. <tr><th>Password: &nbsp;&nbsp;&nbsp;</th><td colspan="2"><input class="field" type="password" onfocus="select();" name="password" id="passwordR" id="password" onBlur="CheckLength(document.getElementById('passwordR'))" placeholder="Your Password Here"/></td></tr>
  118. <tr><th>Confirm Password:</th><td colspan="2"><input class="field" type="password" onfocus="select();" name="confirm_password" id="confirm_passwordR" onBlur="CheckIfEqual(document.getElementById('passwordR'),document.getElementById('confirm_passwordR'))" placeholder="Confirm Your Password Here"/></td></tr>
  119. <tr><th>Security Question: &nbsp;&nbsp;&nbsp;</th><td class="content" colspan="2"><select class="field" name="SecurityQuestion" onfocus="select();"><option class="field" value="nil" selected="selected">Select a question</option><option value="color">What is your favourite color?</option><option value="tpNo">What is your first telephone number?</option><option value="favTeacher">Who is your favourite teacher?</option></select></td></tr>
  120. <tr><th>Answer: &nbsp;&nbsp;&nbsp;</th><td colspan="2"><input class="field" type="text" onfocus="select();" name="SecQAns" placeholder="Your Answer Here"/></td></tr>
  121. <input type="hidden" name="step" value="3" />
  122. <tr><th></th><td><input class="Buttonview" type="submit" value="Submit" /></td><td><a href="../FbApi/index.php"><img src="images/fb_login.gif" /></a></td></tr>
  123. </table>
  124. </form>
  125. </div></div>
  126. </body>
  127. </html>
  128. <?php
  129. if(isset($_POST['step'])) {
  130. if($_POST['step'] == 3) {
  131. if (!LoggedIn()) {
  132. if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['confirm_password'])) {
  133. $Username = $_POST['username'];
  134. $Password = $_POST['password'];
  135. $ConfirmPassword = $_POST['confirm_password'];
  136. $SecurityQuestion = $_POST['SecurityQuestion'];
  137. $SecurityQAnswer = $_POST['SecQAns'];
  138. if (!empty($Username) && !empty($Password) && !empty($ConfirmPassword)) {
  139. if(preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $Username)) {
  140. if($Password != $ConfirmPassword) {
  141. echo '<script language="javascript">alert("Password does not match")</script>';
  142. echo '<script type="text/javascript"> window.location = "Home.php"</script>';
  143. } else {
  144. if (CheckExistance($Username, $Password)) {
  145. echo '<script language="javascript">alert("The Username '.$Username. ' already exists")</script>';
  146. echo '<script type="text/javascript"> window.location = "Home.php"</script>';
  147. } else {
  148. $ActivationKey = rand().rand().rand().rand().rand();
  149. if (Insert($Username, $Password, $ActivationKey, $SecurityQuestion, $SecurityQAnswer)) {
  150. $Subject = 'Welcome to Online Chess Portal';
  151. $Message = "Congratulations!\r<br/>\rYou, or someone using your email address( ".$Username." ), has completed registration at Online Chess Game Portal.\r<br/>\r You can authenticate your registration by clicking the following link:\r<br/><a href=\"http://localhost/OnlineChessGamePortal/Control/VerifyLogic.php?".$ActivationKey."\">\r Online Chess Game Portal - Activation \r\r</a><br/>\r\r<br/>\rIf this is an error, ignore this email and you will be removed from our mailing list.\r<br/>\rRegards,\r<br/>\rOnlineChessGamePortal.com Team";
  152. $ResultMail = SendMail($Username, $Subject, $Message);
  153. if($ResultMail) {
  154. echo '<script language="javascript">alert("Please do authenticate in order to proceed by clicking the link sent to you to the given email address")</script>';
  155. echo '<script type="text/javascript"> window.location = "Home.php"</script>';
  156. } else {
  157. echo '<script language="javascript">alert("Mail not sent")</script>';
  158. echo '<script type="text/javascript"> window.location = "Home.php"</script>';
  159. }
  160. } else {
  161. echo '<script language="javascript">alert("Registration unsuccessful. Try again later.")</script>';
  162. echo '<script type="text/javascript"> window.location = "Home.php"</script>';
  163. }
  164. }
  165. }
  166. } else {
  167. echo '<script language="javascript">alert("Invalid Username. Please enter a valid email address as the Username")</script>';
  168. }
  169. } else {
  170. echo '<script language="javascript">show_confirm()</script>';
  171. echo '<script type="text/javascript"> window.location = "Home.php"</script>';
  172. }
  173. }
  174. } else {
  175. echo '<script language="javascript">alert("You are already registered and logged in")</script>';
  176. echo '<script type="text/javascript"> window.location = "Home_login.php"</script>';
  177. }
  178. }
  179. }
  180. ?>