/View/Inbox.php
PHP | 503 lines | 428 code | 62 blank | 13 comment | 69 complexity | 43e98444494655a8870b0a008f203ea1 MD5 | raw file
Possible License(s): LGPL-2.1
- <?php
- require '../Model/Connect.php';
- require '../Control/RegisterLogic.php';
- require '../Control/LoginLogic.php';
- require '../Control/SendNotification.php';
- require '../Control/CreateClubLogic.php';
- require '../Control/DBCreate.php';
- ob_start();
- $UserNm=$_SESSION['username'];
- $Role = $_SESSION['role'];
- if(isset($_GET['id'])) {
- $SearchName = $_GET['id'];
- $SearchID = GetSearchID($SearchName);
- } else {
- $SearchID = $UserNm;
- }
-
- function GetSearchID($SearchName) {
- $GetID = "SELECT mp_username FROM memberprofile WHERE mp_fullname = '".$SearchName."' ";
- $ResultID = mysql_query($GetID);
- if ($ResultID) {
- $rows = mysql_num_rows($ResultID);
- while($info = mysql_fetch_assoc( $ResultID)) {
- return $info['mp_username'];
- }
- }
- }
-
- ?>
- <!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/screen.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" />
- <link rel="stylesheet" href="css/ToolTip.css" type="text/css" />
- <link rel="stylesheet" type="text/css" href="css/jquery.gritter.css" />
- <!-- End of CSS Files -->
- <!-- Javascript Files -->
- <script type="text/javascript" src="javascript/jquery1.3.2.js"></script>
- <script type="text/javascript" src="javascript/jquery.cycle.all.js"></script>
- <script type="text/javascript" src="javascript/popup-window.js"></script>
- <script type="text/javascript" src="javascript/jquery.js"></script>
- <script type="text/javascript" src="http://www.google.com/jsapi"></script>
- <script type="text/javascript">google.load('jquery', '1.5');</script>
- <script type="text/javascript" src="js/jquery.gritter.js"></script>
-
- <script type="text/javascript">
- $(document).ready(function(){
-
- $(".menu2 a").append("<em></em>");
-
- $(".menu2 a").hover(function() {
- $(this).find("em").animate({opacity: "show", top: "-75"}, "slow");
- var hoverText = $(this).attr("title");
- $(this).find("em").text(hoverText);
- }, function() {
- $(this).find("em").animate({opacity: "hide", top: "-85"}, "fast");
- });
-
-
- });
-
- <!--popup-->
- var time_interval = setInterval(
- function ()
- {
- $('#popup').load('../Control/Notification.php').fadeIn("slow");
- }, 5000); // refresh every 5000 milliseconds
- </script>
-
- <script type="text/javascript">
- function CheckMessage() {
- MID=document.forms[0].MessageID
- //if(MID.length == undefined) {
- //MID.length = 1;
- //}
- //alert(MID.length);
- AlertFlag = 0
- for (i=0;i<MID.length;++i){
- //alert('i is '+i);
- //alert(MID[i].checked);
- if (MID[i].checked){
- //alert(MID[i].value);
- if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- } else {// code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function() {
- if (xmlhttp.readyState==4 && xmlhttp.status==200) {
- //document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
- //alert(xmlhttp.responseText);
- location.href = "Inbox.php";
- }
- }
- var s = confirm('delete this message ?');
- if(s) {
- xmlhttp.open("GET","../Control/DeleteMessage.php?q="+MID[i].value,true);
- xmlhttp.send();
- //location.href = "Inbox.php";
- } else {
- alert ('deletion canceled');
- }
- AlertFlag = 1;
- }
- }
- if(AlertFlag != 1) {
- alert("You must select at least one message to Delete");
- }
- }
- </script>
- <!--popup-->
- <style type="text/css">
- table{
-
- border:1px solid white;
- }
- th
- {
- background-color:#CCCCCC;
- color:Black;
- background-image: url(images/dropdowntop.jpg);
- }
- td {
- font-family: Calibri;
- border: thin #CCCCCC;
-
- }
- #footer {
- background-color: #CCCCCC;
- color: #000000;
- font-family: Arial,Helvetica,sans-serif;
- font-size: 10px;
- height: 50px;
- margin-top: 0;
- text-transform: capitalize;
- width: 100%;
- }
- </style>
- <!-- End of Javascript Files -->
- </head>
- <body>
- <!-- Wrapper --><div id="mainPage" >
- <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="../Control/LogoutLogic.php">Logout</a> </li>
- <li class="noimg"></li>
- </ul>
- </div>
-
- <div class="menu">
- <ul class="sf-menu">
-
- <li> <a class="on" href="Home_Login.php">HOME</a></li>
-
- <li> <?php if($_SESSION['role'] == 'SiteAdmin') {
- ?> <a href="SiteAdminProfile.php">
- <?php } else { ?>
- <a href="MemberProfile.php">
- <?php }
- $result = mysql_query("SELECT mp_fullname FROM memberprofile WHERE mp_username='".$_SESSION['username']."' ");
- $row = mysql_fetch_array($result);
- $Rows = mysql_num_rows($result);
- if($_SESSION['role'] == 'SiteAdmin' || $Rows == 0) {
- echo 'Profile';
- } else {
- echo $row['mp_fullname'];
- }?></a>
- </li>
-
-
- <li> <a href="SearchClub.php">Clubs</a> </li>
-
- <li> <a href="Inbox.php">Messages</a> </li>
- </ul>
-
- </div> </div><!-- menu end-->
-
- <div id="content">
- <div class="froms">
- <span id="popup"></span><form >
- <?php
- $result = mysql_query("SELECT * FROM notify WHERE no_to='".$UserNm."' GROUP BY no_ID ORDER BY `no_timestamp` DESC ");
- echo "<table width='100%' table border='2' style='border:#999999'>";
-
- $QueryNumRows = mysql_num_rows ($result);
- if ($QueryNumRows == 0) {
- echo '<script language="javascript">alert("No messages to display")</script>';
- } else {
- while($row = mysql_fetch_array($result))
- {
- $To = $row['no_to'];
- $FromEmail = $row['no_from'];
- $Message = $row['no_message'];
- $MID = $row['no_id'];
- $Inbox_Timestamp = date('d-M-Y @ h:i:s',$row['no_timestamp']);
- $From = '';
-
- $GetNameFrom = "SELECT mp_fullname FROM memberprofile WHERE mp_username = '".$FromEmail."' ";
- $ResultNameFrom = mysql_query($GetNameFrom);
- if ($ResultNameFrom) {
- $rows = mysql_num_rows($ResultNameFrom);
- while($info = mysql_fetch_assoc( $ResultNameFrom)) {
- $From = $info['mp_fullname'];
- }
- }?>
- <div><?php
- echo "<tr> ";?>
- <td><input type="checkbox" name="MessageID" value="<?php echo $MID ?>"/>
- <?php
- //get the profile picture , name, home town
- $GetDetails = mysql_query("SELECT mp_currentcity, mp_imagename FROM memberprofile WHERE mp_fullname = '".$From."' ");
- $HomeTown = mysql_result($GetDetails, 0, 'mp_currentcity');
- $ImgName = mysql_result($GetDetails, 0, 'mp_imagename');
- ?>
- <strong><a href="MemberProfile.php?id=<?php echo $From?>" class="tooltip"><?php echo $From?><span class="help"><br/> <img src="UserImages/<?php echo $ImgName?>" height="48" width="48" /><em> <?php echo $From?></em><?php echo $HomeTown?></span></a></strong> <?php echo " ".$Inbox_Timestamp?><br/><?php echo $Message ?><hr/>
- <?php
- echo "</td><td><a href=\"InboxDetails.php?mid=$MID\" >Read More...</a></td></tr>";
-
- echo "</tr></div>";
- }
- }
- echo "</table>";
- ?>
- </form>
- <form method="post">
- <input type="hidden" name="step1" value="3"/>
- <?php if($QueryNumRows > 0) {?>
- <input type="button" value="Delete" name="Delete" onclick="CheckMessage()" class="Buttonview" />
- <?php } ?>
- </form>
- </div>
- </div>
-
-
-
- <div id="sidebar">
- <li>
- <!--------------------------------------------------------------->
- <h2>Up Coming Events </h2>
- <ul>
- <li class="noimg"> <a href="#" class="content" onclick="popup_show('popup_messageMember', 'popup_drag_messageMember', 'popup_exit_messageMember', 'screen-center', 0, 0);">New Message</a> </li>
- <li class="noimg"> <a href="#" class="content" onclick="popup_show('popup_messageClub', 'popup_drag', 'popup_exit', 'screen-center', 0, 0);">New Message-Club</a> </li>
-
- </ul>
- </li>
-
-
- </div>
-
-
- <!-- topbar-->
- <layer>
- <ul id="navigation">
- <li class="home"><a href="Home_Login.php" title="Home"></a></li>
- <li class="play"><a href="Play.php" title="Play Chess"></a></li>
- <li class="photos"><a href="Inbox.php" title="Inbox"></a></li>
- <li class="club"><a href="SearchClub.php" title="Clubs"></a></li>
- <li class="settings"><a href="Settings.php" title="Settings"></a></li>
-
- </ul>
-
- </layer>
-
- <script type="text/javascript">
- $(function() {
- $('#navigation a').stop().animate({'marginLeft':'-90px'},100);
-
- $('#navigation > li').hover(
- function () {
- $('a',$(this)).stop().animate({'marginLeft':'-70px'},100);
- },
- function () {
- $('a',$(this)).stop().animate({'marginLeft':'-90px'},100);
- }
- );
- });
- </script>
- <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 class="sample_popup" id="popup_messageClub" style="display: none;">
-
- <div class="menu_form_header" id="popup_drag">
- <img class="menu_form_exit" id="popup_exit" src="images/form_exit.png" alt="exit" />
- New Message Club
- </div>
-
- <div class="menu_form_body">
- <form action="" method="post">
- <table>
- <tr>To:</tr><br />
- <tr><input type="text" class="" name="to" id="to" placeholder="Type the club name here"/>
- <div class="">
- <ul class="">
- </ul>
- </div>
- <script src="js/primary1.js"></script>
- <script src="js/primaryClub.js"></script>
- </tr><br />
- <tr>Message:</tr><br />
- <tr><textarea rows="5" cols="40" class="fillmessage" placeholder="Type the message here" name="message" id="message"></textarea></tr><br /><br />
- <tr>
-
-
- <input type="submit" id="send" name="send" value="Send" class="Buttonview" />
- <a href="Inbox.php" class="Buttonview">Cancel</a><input type="hidden" id="step" name="step" value="2" /></tr>
- </table>
- </form>
- </div> </div>
-
- <div class="sample_popup" id="popup_messageMember" style="display: none;">
-
- <div class="menu_form_header" id="popup_drag_messageMember">
- <img class="menu_form_exit" id="popup_exit_messageMember" src="images/form_exit.png" alt="exit" />
- New Message
- </div>
-
- <div class="menu_form_body">
- <form action="" method="post">
- <table>
- <tr><label class="contentHeading">To:</tr><br />
- <tr><input type="text" class="autosuggest" name="to" id="to" placeholder="Type the name here" onblur="this.value=removeSpaces(this.value);/>
- <div class="dropdown">
- <ul class="result">
- </ul>
- </div>
- <script src="js/primary1.js"></script>
- <script src="js/primary.js"></script>
- </tr><br />
- <tr><label class="contentHeading">Message:</tr><br />
- <tr><textarea rows="5" cols="40" class="fillmessage" placeholder="Type the message here" name="message" id="message"></textarea></tr><br /><br />
- <tr>
-
-
- <input type="submit" id="send" name="send" value="Send" class="Buttonview" />
- <a href="Inbox.php" class="Buttonview">Cancel</a>
- <input type="hidden" id="step" name="step" value="1" /></tr>
- </table>
- </form>
-
- </div> </div>
-
- </body>
- </html>
-
- <?php
-
- if(isset($_POST['step'])) {
- if($_POST['step'] == 1) {
- $Notify = new Notification();
- $MsgTo1 = $_POST['to'];
- $MsgTo = substr($MsgTo1,8);
- echo $Message = $_POST['message'];
- echo $User = $_SESSION['username'];
- echo $time = time();
- if(isset($_POST['club'])) {
- $Club = $_POST['club'];
- }
-
- $GetUsernameTo = "SELECT mp_username FROM memberprofile WHERE mp_fullname = '".$MsgTo."' ";
- $ResultUsernameTo = mysql_query($GetUsernameTo);
- if ($ResultUsernameTo) {
- $rows = mysql_num_rows($ResultUsernameTo);
- while($info = mysql_fetch_assoc( $ResultUsernameTo)) {
- echo $To = $info['mp_username'];
- }
- }
-
- $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)) {
- echo $MsgID = $info['x'];
- }
- } else {
- echo $MsgID = 1;
- }
-
- if(!$To || !$Message ) {
- echo 'Please enter the required details';
- } else {
- $Result = $Notify->SendMessage($To,$User,$Message,$MsgID,$time);
- if($Result) {
- echo '<script language="javascript">alert("Message sent successfully")</script>';
- if($QueryNumRows > 0) {
- echo '<script type="text/javascript"> window.location = "Inbox.php"</script>';
- } else {
- echo '<script type="text/javascript"> window.location = "MemberProfile.php"</script>';
- }
- } else {
- echo '<script language="javascript">alert("Message sending error. Try again later")</script>';
- if($QueryNumRows > 0) {
- echo '<script type="text/javascript"> window.location = "Inbox.php"</script>';
- } else {
- echo '<script type="text/javascript"> window.location = "MemberProfile.php"</script>';
- }
- }
- }
- }
-
- if($_POST['step'] == 2) {
- $Notify = new Notification();
- $Message = $_POST['message'];
- $User = $_SESSION['username'];
- $time = time();
-
- $GetNameFrom = "SELECT mp_fullname FROM memberprofile WHERE mp_username = '".$User."' ";
- $ResultNameFrom = mysql_query($GetNameFrom);
- if ($ResultNameFrom) {
- $rows = mysql_num_rows($ResultNameFrom);
- while($info = mysql_fetch_assoc( $ResultNameFrom)) {
- $From = $info['mp_fullname'];
- }
- }
- $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'];
- }
- }
-
- $Club = $_POST['to'];
-
- if(!$Club || !$Message ) {
- echo 'Please enter the required details';
- } else {
- //send message to the club members
- $ClubId = GetClubId($Club);
- $sql = "SELECT cm_member FROM clubmember WHERE cm_clubid = '".$ClubId."'";
- if ($result = mysql_query($sql)) {
- $rows = mysql_num_rows($result);
- $storeArray = Array();
- while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
- $storeArray[] = $row['cm_member'];
- }
- for ( $i=0 ; $i<$rows ; $i++ )
- {
- $To = $storeArray[$i];
- $send = $Notify->SendMessage($To,$From,$Message,$MsgID,$time);
- if ($send) {
- $done = 1;
- }
- }
- } else {
- echo 'OOOPPPSSS';
- }
- if ($done == 1) {
- echo '<script language="javascript">alert("Message sent successfully")</script>';
- if($_SESSION['role'] == 'member' || $_SESSION['role'] == 'clubAdmin') {
- echo '<script type="text/javascript"> window.location = "../View/MemberProfile.php"</script>';
- } else {
- echo '<script type="text/javascript"> window.location = "../View/SiteAdminProfile.php"</script>';
- }
- } else {
- echo '<script language="javascript">alert("Message sending error. Try again later")</script>';
- if($_SESSION['role'] == 'member' || $_SESSION['role'] == 'clubAdmin') {
- echo '<script type="text/javascript"> window.location = "../View/MemberProfile.php"</script>';
- } else {
- echo '<script type="text/javascript"> window.location = "../View/SiteAdminProfile.php"</script>';
- }
- }
- }
- }
- }
-
- if(isset($_POST['Delete'])) {
- if(isset($_POST['step1'])) {
-
- }
- }
-
-
- ?>