/View/GuestBook.php
PHP | 215 lines | 178 code | 35 blank | 2 comment | 37 complexity | cc324a99a711b65655cca5866c21951a MD5 | raw file
Possible License(s): LGPL-2.1
- <?php
- require '../Model/Connect.php';
- require '../Control/RegisterLogic.php';
- require '../Control/LoginLogic.php';
- require '../Control/SendMail.php';
- ?>
-
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Online Chess Portal </title>
- <!-- CSS Files -->
- <link href="css/reset.css" rel="stylesheet" type="text/css" />
- <link href="css/Form.css" rel="stylesheet" type="text/css" />
- <link href="css/style.css" rel="stylesheet" type="text/css" />
- <link rel="stylesheet" type="text/css" href="css/superfish.css" media="screen" />
- <style type="text/css">
- .sf-sub-indicator {
- behavior: url(css/iepngfix.htc)
- }
- ;
- </style>
- <!-- End of CSS Files -->
- <!-- Javascript Files -->
-
-
- <!-- End of Javascript Files -->
- </head>
- <body>
- <!-- Wrapper -->
- <div id="wrapper">
- <div id="topbar">
- <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' />
-
- <div id="secnav">
- <ul>
- <li> <a href="#" onclick="popup_show('popup1', 'popup_drag1', 'popup_exit1', 'screen-center', 0, 0);">SIGN UP</a> </li>
-
- </ul>
- </div>
-
- <div class="menu">
- <ul class="sf-menu">
-
- <li> <a class="on" href="Home.php">HOME</a></li>
- <li> <a href="Contact.php">Contact</a> </li>
-
-
- </ul>
-
- </div> </div><!-- menu end-->
-
-
- <div id="content_guest">
- <div class="froms">
-
-
- <?php
- require_once '../Model/Connect.php';
-
- $time = time();//current timestamp
-
- if (isset($_POST['gb_name'],$_POST['gb_email'],$_POST['gb_message'])) {
- $gb_name = mysql_real_escape_string(htmlentities($_POST['gb_name']));
- $gb_email = mysql_real_escape_string(htmlentities($_POST['gb_email']));
- $gb_message = mysql_real_escape_string(htmlentities($_POST['gb_message']));
-
- //if (isset($_POST['post'])) {
- if (empty($gb_name) || empty($gb_email) || empty($gb_message)) {
- echo '<script language="javascript">alert("All Fields are required.")</script>';
- } else {
- if (strlen($gb_name)>30 || strlen($gb_email)>30 || strlen($gb_message)>255) {
- echo '<script language="javascript">alert("One or more fields exeeded the character limit.")</script>';
- } else {
- $insert = "INSERT INTO guestBook VALUES ('','$time','$gb_name','$gb_email','$gb_message')";
- if (mysql_query($insert)) {
- $entries = mysql_query("SELECT `gb_timestamp`,gb_name,gb_email,gb_message FROM guestbook ORDER BY `gb_timestamp` DESC ");
- if (mysql_num_rows($entries) == 0) {
- echo 'No entries';
- } else {
- while($entries_row = mysql_fetch_assoc($entries)) {
- $entries_timestamp = date('d-M-Y @ h:i:s',$entries_row['gb_timestamp']);
- $entries_name = $entries_row['gb_name'];
- $entries_email = $entries_row['gb_email'];
- $entries_message = $entries_row['gb_message'];
-
- echo '<p><strong><font color=#000 face=\"Calibri\">Posted by '.$entries_name.' on '.$entries_timestamp.'</strong><br/>'.$entries_message.'</p>';
- }
- }
- } else {
- echo '<script language="javascript">alert("Something is wrong.Please try again later.")</script>';
- }
- }
- }
- //}
- }
-
-
- ?>
-
-
- <hr />
- <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="POST">
- <strong>Post Something...</strong><br />
- Name:<br/><input type="text" name="gb_name" maxlength="30" /><br />
- Email:<br/><input type="text" name="gb_email" maxlength="255" /> <br />
- Message:<br/><textarea name="gb_message" rows="6" cols="30" ></textarea><br />
- <input type="submit" value="Post" id="Post" class="Buttonview"/>
- </form>
-
- </div></div>
-
- <!-- topbar-->
- <div class="clear"></div>
- <div id="footers">
-
-
- <div style="float:right"><div class="fotterlast">
- <a href="#" title="About Us">About Us</a>
- |
- <a href="#" title="Terms of Service">Terms of Service</a>
- |
- <a href="#" title="Privacy Statement">Privacy</a>
- |
- <a href="Contact.php" title="Contact Us">Contact Us</a>
- </div></div>
-
- <div style="float:Left"><div class="fotterlastdesing">Designed by SEP_WE_05 Team.</div></div>
-
- </div>
- </div>
- </div>
- </div>
-
- <!--Register-->
- <div class="sample_popup" id="popup1" style="display: none;">
-
- <div class="menu_form_header" id="popup_drag1">
- <img class="menu_form_exit" id="popup_exit1" src="images/form_exit.png" alt="" />
- Sign Up
- </div>
-
- <div class="menu_form_body">
- <form action="" method="post">
-
- <table>
- <tr><th>Username: </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>
- <tr><th>Password: </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>
- <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>
- <tr><th>Security Question: </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>
- <tr><th>Answer: </th><td colspan="2"><input class="field" type="text" onfocus="select();" name="SecQAns" placeholder="Your Answer Here"/></td></tr>
- <input type="hidden" name="step" value="3" />
- <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>
- </table>
- </form>
- </div></div>
-
- </body>
- </html>
-
- <?php
- if(isset($_POST['step'])) {
- if($_POST['step'] == 3) {
- if (!LoggedIn()) {
- if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['confirm_password'])) {
- $Username = $_POST['username'];
- $Password = $_POST['password'];
- $ConfirmPassword = $_POST['confirm_password'];
- $SecurityQuestion = $_POST['SecurityQuestion'];
- $SecurityQAnswer = $_POST['SecQAns'];
-
- if (!empty($Username) && !empty($Password) && !empty($ConfirmPassword)) {
- if(preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $Username)) {
- if($Password != $ConfirmPassword) {
- echo '<script language="javascript">alert("Password does not match")</script>';
- echo '<script type="text/javascript"> window.location = "Home.php"</script>';
- } else {
- if (CheckExistance($Username, $Password)) {
- echo '<script language="javascript">alert("The Username '.$Username. ' already exists")</script>';
- echo '<script type="text/javascript"> window.location = "Home.php"</script>';
- } else {
- $ActivationKey = rand().rand().rand().rand().rand();
- if (Insert($Username, $Password, $ActivationKey, $SecurityQuestion, $SecurityQAnswer)) {
- $Subject = 'Welcome to Online Chess Portal';
- $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";
- $ResultMail = SendMail($Username, $Subject, $Message);
- if($ResultMail) {
- 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>';
- echo '<script type="text/javascript"> window.location = "Home.php"</script>';
- } else {
- echo '<script language="javascript">alert("Mail not sent")</script>';
- echo '<script type="text/javascript"> window.location = "Home.php"</script>';
- }
- } else {
- echo '<script language="javascript">alert("Registration unsuccessful. Try again later.")</script>';
- echo '<script type="text/javascript"> window.location = "Home.php"</script>';
- }
- }
- }
- } else {
- echo '<script language="javascript">alert("Invalid Username. Please enter a valid email address as the Username")</script>';
- }
- } else {
- echo '<script language="javascript">show_confirm()</script>';
- echo '<script type="text/javascript"> window.location = "Home.php"</script>';
- }
- }
- } else {
- echo '<script language="javascript">alert("You are already registered and logged in")</script>';
- echo '<script type="text/javascript"> window.location = "Home_login.php"</script>';
- }
- }
- }
- ?>