[Openfirst-cvscommit] messenger viewmsg.php,1.3,1.4 newmsg.php,1.3,1.4 messenger.php,1.4,1.5 index.p
Brought to you by:
xtimg
From: <dav...@us...> - 2003-08-20 03:02:44
|
Update of /cvsroot/openfirst/messenger In directory sc8-pr-cvs1:/tmp/cvs-serv22473 Modified Files: viewmsg.php newmsg.php messenger.php index.php inbox.php Log Message: Module has been changed to allow only members to send and receive messages. A lot of the design has been edited to look and perform better. Index: viewmsg.php =================================================================== RCS file: /cvsroot/openfirst/messenger/viewmsg.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** viewmsg.php 28 Jun 2003 16:09:19 -0000 1.3 --- viewmsg.php 20 Aug 2003 00:40:28 -0000 1.4 *************** *** 29,59 **** include($header); // Retrieve recordset based on querystring ID data, then preview the information ! $query = mysql_query("SELECT * FROM ofirst_messages WHERE ID='".$_GET['ID']."'") or die("SELECT: ".mysql_error()); $msg = mysql_fetch_object($query); // Retrieve user information based Message information ! $qsend = mysql_query("SELECT * FROM ofirst_usersonline WHERE IPAddress='".$msg->Sender."'") or die("SELECT: ".mysql_error()); $sender = mysql_fetch_object($qsend); ?> <h1>Viewing Message</h1> ! <table> <tr> ! <th> </th> ! <th>Current Message</th> </tr> <tr> <th>Sender</th> ! <td>Visitor <?php echo $sender->ID; ?></td> </tr> <tr> <th>Subject</th> ! <td><?php echo $msg->Subject; ?></td> </tr> <tr> <th>Body</th> ! <td><?php echo $msg->Body; ?></td> </tr> </table> --- 29,66 ---- include($header); + if(! isset($user->user)){ + showlogin(); + die(include($footer)); + } + // Retrieve recordset based on querystring ID data, then preview the information ! $query = mysql_query("SELECT * FROM ofirst_messenger_messages WHERE ID='".$_GET['ID']."'") or die("SELECT: ".mysql_error()); $msg = mysql_fetch_object($query); // Retrieve user information based Message information ! $qsend = mysql_query("SELECT * FROM ofirst_messenger_usersonline WHERE IPAddress='".$msg->Sender."'") or die("SELECT: ".mysql_error()); $sender = mysql_fetch_object($qsend); ?> <h1>Viewing Message</h1> ! <p>If this message contains profanity or abusive material then please contact ! the webmaster!</p> ! <table width="597"> <tr> ! <th width="127"> </th> ! <th width="458">Current Message</th> </tr> <tr> <th>Sender</th> ! <td><a href='profiles.php?ID=<?php echo $msg->Sender ?>'><?php echo $msg->Sender ?></a></td> </tr> <tr> <th>Subject</th> ! <td><?php echo slur_block(emoticon_translate($msg->Subject)); ?></td> </tr> <tr> <th>Body</th> ! <td><?php echo slur_block(emoticon_translate($msg->Body)); ?></td> </tr> </table> Index: newmsg.php =================================================================== RCS file: /cvsroot/openfirst/messenger/newmsg.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** newmsg.php 28 Jun 2003 16:09:19 -0000 1.3 --- newmsg.php 20 Aug 2003 00:40:28 -0000 1.4 *************** *** 29,37 **** include($header); // If the user has posted a send command then insert the Message into the database if (isset($_POST['send'])) { ! mysql_query("INSERT INTO ofirst_messages (Sender,Receiver,Subject,Body, Status, Date) values( ! '".$IP."' ,'".$_POST['recip']."' ,'".$_POST['subject']."' --- 29,42 ---- include($header); + if(! isset($user->user)){ + showlogin(); + die(include($footer)); + } + // If the user has posted a send command then insert the Message into the database if (isset($_POST['send'])) { ! mysql_query("INSERT INTO ofirst_messenger_messages (Sender,Receiver,Subject,Body, Status, Date) values( ! '".$user->user."' ,'".$_POST['recip']."' ,'".$_POST['subject']."' *************** *** 40,94 **** ,'".time()."')") or die("INSERT ERROR: ".mysql_error()); ! echo("<br><br><br><center>Message has been sent! [ <a href='inbox.php'>Inbox</a> ]"); die(include($footer)); } ?> <form method="POST" action="newmsg.php"> ! <h1>Visitor Inbox for Messaging</h1> ! <table> ! <tr> ! <th>Recipient</th> ! <td> ! <select name="recip" id="recip"> <?php ! // Set the reply based on a regular member or visitor (David Notes: Coding to be changed later) ! if (ISSET($_GET['REPLY'])){ ! $query = mysql_query("SELECT * FROM ofirst_usersonline WHERE ID = '".$_GET['REPLY']."'"); ! $replyuser = mysql_fetch_object($query); ! if (! $replyuser->Member = "None"){ ! echo "<option value='".$replyuser->IPAddress."'>".$replyuser->Member." (REPLY MSG)</option>"; ! } else { ! echo "<option value='".$replyuser->IPAddress."'>Visitor #".$replyuser->ID." (REPLY MSG)</option>"; ! } ! } else { ! $query = mysql_query("SELECT * FROM ofirst_usersonline"); ! while($user = mysql_fetch_object($query)){ ! if (! $user->Member = "None"){ ! echo "<option value='".$user->IPAddress."'>".$user->Member."</option>"; ! } else { ! echo "<option value='".$user->IPAddress."'>Visitor #".$user->ID."</option>"; ! } ! } } ?> ! </select></td> ! </tr> ! <tr> ! <th>Subject</th> ! <td><input name="subject" type="text" id="subject" size="50" value="<?php if (isset($_GET['SUBJECT'])) { echo $_GET['SUBJECT']; } ?>"></td> ! </tr> ! <tr> ! <th>Body</th> ! <td> ! <textarea name="body" cols="50" rows="10" id="body"></textarea> ! <br> ! <font size="2">(HTML Messages enabled)</font></td> ! </tr> ! <tr> ! <td></td> ! <td><input name="send" type="submit" value="Send Message"></td> ! </tr> ! </table> </form> <?php --- 45,102 ---- ,'".time()."')") or die("INSERT ERROR: ".mysql_error()); ! echo("<br><br><br><center>Message has been sent! [ <a href='inbox.php'>Inbox</a> ]<br><br>"); die(include($footer)); } ?> <form method="POST" action="newmsg.php"> ! <h1>Visitor Inbox for Messaging</h1> ! <p>Please make sure that your messeges do not contain profanity or abusive comments.</p> ! <table width="66%"> ! <th></th><th>Send New Messege</th> ! <tr> ! <td width="34%"><?php emoticon_preview(); ?></td> ! <td width="66%"> ! <table> ! <tr> ! <th>Recipient</th> ! <td> <?php ! // Set the reply based on querystring or list members ! if (ISSET($_GET['RECIP'])){ ! $query = mysql_query("SELECT * FROM ofirst_messenger_usersonline WHERE ID = '".$_GET['RECIP']."'"); ! $recipient = mysql_fetch_object($query); ! echo $recipient->Member; ! echo "<input type='hidden' name='recip' value='".$recipient->Member."'>"; ! }else{ ! echo "<select name='recip'id='recip'>"; ! $query = mysql_query("SELECT * FROM ofirst_messenger_usersonline"); ! while($recipient = mysql_fetch_object($query)){ ! if(! $recipient->Member == "none"){ ! echo "<option>".$recipient->Member."<option>"; ! } ! } ! echo "</select>"; } ?> ! </td> ! </tr> ! <tr> ! <th>Subject</th> ! <td><input name="subject" type="text" id="subject" size="50" value="<?php if (isset($_GET['SUBJECT'])) { echo $_GET['SUBJECT']; } ?>"></td> ! </tr> ! <tr> ! <th>Body</th> ! <td> <textarea name="body" cols="50" rows="10" id="body"></textarea> ! <br> ! <font size="2">(HTML and emoticon options enabled)</font></td> ! </tr> ! <tr> ! <td></td> ! <td><input name="send" type="submit" value="Send Message"></td> ! </tr> ! </table></td> ! </tr> ! </table> </form> <?php Index: messenger.php =================================================================== RCS file: /cvsroot/openfirst/messenger/messenger.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** messenger.php 29 Jun 2003 03:37:02 -0000 1.4 --- messenger.php 20 Aug 2003 00:40:28 -0000 1.5 *************** *** 26,29 **** --- 26,30 ---- * */ + // Declare information to be used in all messenger files $IP = $_SERVER['REMOTE_ADDR']; *************** *** 32,88 **** // Check if a record for the persons IP is made if not then create it or else update current record info ! $query = mysql_query("SELECT * FROM ofirst_usersonline WHERE IPAddress = '".$IP."'"); if (mysql_num_rows($query) == 0){ $timeout = $TIME+30; ! mysql_query("INSERT INTO ofirst_usersonline (IPAddress,Location,Timestamp,Member) values( '".$IP."' ,'".$SCRIPT."' ,'".$timeout."' ! ,'none')") or die("INSERT: ".mysql_error()); } else { $timeout = $TIME + 480; ! mysql_query("UPDATE ofirst_usersonline SET Timestamp = '".$timeout."', Location = '".$SCRIPT."' WHERE IPAddress = '".$IP."'") or die("UPDATE: ".mysql_error()); } // Delete all records that are overdue the Timestamp expiry amount based on current time ! mysql_query("DELETE FROM ofirst_usersonline WHERE Timestamp < '".$TIME."'") or die("DELETE: ".mysql_error()); // Check how many records of users are available and put in user usable variable ! $query = mysql_query("SELECT * FROM ofirst_usersonline"); $usersonline = "There are currently <b>".mysql_num_rows($query)."</b> persons on this website! [ <a href='./'>View List</a> ]"; // Check how many people are previewing the same exact script location and put in user usable variable ! $page_query = mysql_query("SELECT * FROM ofirst_usersonline WHERE Location = '".$SCRIPT."'"); $usersonpage = "There are currently <b>".mysql_num_rows($page_query)."</b> viewing this page!"; // Check if the user has any new Messages ! $query = mysql_query("SELECT * FROM ofirst_messages WHERE Status = 'New' AND Receiver = '".$IP."'") or die(mysql_error()); ! $Messages = mysql_num_rows($query); // Update Message status so they don't show after the person requests the next page ! mysql_query("UPDATE ofirst_messages SET Status = 'Read' WHERE Receiver = '".$IP."'") or die(mysql_error()); // If there are one ore more then one Messages then preview the Message box ! if ($Messages >= 1) { ?> ! <table style="position: absolute; left: 306px; top: 64px; width: 384px; height: 19px" width="400"> <tr> <th>Private Messaging System Alert</th> </tr> <tr> ! <td height="25"><img src="<?php echo $basepath; ?>/messenger/msg.png" alt="New Message"> <br> ! You have <b><?php echo $Messages; ?></b> new Messages(s) in your visitor ! inbox!<br> ! <br> ! [ <a href="<?php echo $basepath; ?>/messenger/inbox.php">Visitor Inbox</a> ]<br> ! <br> ! </p></td> </tr> </table> ! <?php } ?> --- 33,98 ---- // Check if a record for the persons IP is made if not then create it or else update current record info ! $query = mysql_query("SELECT * FROM ofirst_messenger_usersonline WHERE IPAddress = '".$IP."'"); ! ! if(ISSET($user->user)){ ! $memberinf = $user->user; ! }else{ ! $memberinf = "none"; ! } if (mysql_num_rows($query) == 0){ $timeout = $TIME+30; ! ! mysql_query("INSERT INTO ofirst_messenger_usersonline (IPAddress,Location,Timestamp,Member) values( '".$IP."' ,'".$SCRIPT."' ,'".$timeout."' ! ,'".$memberinf."')") or die("INSERT: ".mysql_error()); } else { $timeout = $TIME + 480; ! mysql_query("UPDATE ofirst_messenger_usersonline SET Timestamp = '".$timeout."', Member = '".$memberinf."', Location = '".$SCRIPT."' WHERE IPAddress = '".$IP."'") or die("UPDATE: ".mysql_error()); } // Delete all records that are overdue the Timestamp expiry amount based on current time ! mysql_query("DELETE FROM ofirst_messenger_usersonline WHERE Timestamp < '".$TIME."'") or die("DELETE: ".mysql_error()); // Check how many records of users are available and put in user usable variable ! $query = mysql_query("SELECT * FROM ofirst_messenger_usersonline"); $usersonline = "There are currently <b>".mysql_num_rows($query)."</b> persons on this website! [ <a href='./'>View List</a> ]"; // Check how many people are previewing the same exact script location and put in user usable variable ! $page_query = mysql_query("SELECT * FROM ofirst_messenger_usersonline WHERE Location = '".$SCRIPT."'"); $usersonpage = "There are currently <b>".mysql_num_rows($page_query)."</b> viewing this page!"; + if(isset($user->user)){ + // Check if the user has any new Messages ! $query = mysql_query("SELECT * FROM ofirst_messenger_messages WHERE Status = 'New' AND Receiver = '".$user->user."'") or die(mysql_error()); ! $messages = mysql_num_rows($query); // Update Message status so they don't show after the person requests the next page ! mysql_query("UPDATE ofirst_messenger_messages SET Status = 'Read' WHERE Receiver = '".$user->user."'") or die(mysql_error()); // If there are one ore more then one Messages then preview the Message box ! if ($messages >= 1) { ?> ! <table style="position: absolute; left: 32px; top: 163px; width: 384px; height: 19px" width="400"> <tr> <th>Private Messaging System Alert</th> </tr> <tr> ! <td height="25" bgcolor="#FFFFFF"><img src="<?php echo $basepath; ?>/messenger/msg.png" alt="New Message"> ! <br> ! <center>You have <b><?php echo $messages; ?></b> new Messages(s) in your visitor ! inbox!<br><br>[ <a href="<?php echo $basepath; ?>/messenger/inbox.php">Visitor Inbox</a> ]<br><br></p></center></td> </tr> </table> ! <?php ! } ! } ! ?> \ No newline at end of file Index: index.php =================================================================== RCS file: /cvsroot/openfirst/messenger/index.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** index.php 28 Jun 2003 16:09:19 -0000 1.3 --- index.php 20 Aug 2003 00:40:28 -0000 1.4 *************** *** 30,34 **** ?> <h1>Current Online Users</h1> ! <table> <tr> <th></th> --- 30,34 ---- ?> <h1>Current Online Users</h1> ! <table width="538"> <tr> <th></th> *************** *** 40,58 **** // Find user online records in the database ! $query = mysql_query("SELECT * FROM ofirst_usersonline"); ! while($user = mysql_fetch_object($query)){ ?> <tr> <td><img src="visitors.png" alt="Visitor"></td> <td><?php ! if ($user->Member = "none") { ! echo "Visiting Guest #".$user->ID; } else { ! echo $user->Member; } ?></td> ! <td><?php echo $user->Location; ?></td> ! <td>[ <a href="newmsg.php?REPLY=<?php echo $user->ID; ?>"> Message User</a> ! ]</td> </tr> <?php --- 40,65 ---- // Find user online records in the database ! $query = mysql_query("SELECT * FROM ofirst_messenger_usersonline"); ! while($userinf = mysql_fetch_object($query)){ ?> <tr> <td><img src="visitors.png" alt="Visitor"></td> <td><?php ! if ($userinf->Member == "none") { ! echo "Visiting Guest"; } else { ! echo $userinf->Member; } ?></td> ! <td><?php echo $userinf->Location; ?></td> ! <td> ! <?php ! if ($userinf->Member == "none") { ! echo "<center>--</center>"; ! }else{ ! echo "[ <a href='newmsg.php?RECIP=".$userinf->ID."'> Message User</a> ]"; ! } ! ?> ! </td> </tr> <?php Index: inbox.php =================================================================== RCS file: /cvsroot/openfirst/messenger/inbox.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** inbox.php 28 Jun 2003 16:09:19 -0000 1.3 --- inbox.php 20 Aug 2003 00:40:28 -0000 1.4 *************** *** 29,77 **** include($header); // If querystring delete is set with a value then delete the specified recordset if (isset($_GET['DELETE'])) { ! mysql_query("DELETE FROM ofirst_messages WHERE ID='".$_GET['DELETE']."'") or die(mysql_error()); ! ! die("<p>Message has been removed, thank you! [ <a href='inbox.php'>Inbox</a> ]</p>"); } ?> <h1>Visitor Inbox for Messaging</h1> ! <table> <tr> ! <th></th> ! <th>Subject</th> ! <th>Date</th> ! <th>Sender</th> ! <th>Option</th> </tr> <?php ! // Retrieve Messages relating to the users IP address then loop through them ! $query = mysql_query("SELECT * FROM ofirst_messages WHERE Receiver = '$IP'"); ! ! while($Messages = mysql_fetch_object($query)){ ! $queryuser = mysql_query("SELECT * FROM ofirst_usersonline WHERE IPAddress = '".$Messages->Sender."'"); ! $senderinfo = mysql_fetch_object($queryuser); ?> <tr> <td><img src="msg.png" alt="Message"></td> ! <td><a href='viewmsg.php?ID=<?php echo $Messages->ID; ?>'> <?php ! if (empty($Messages->Subject)){ echo "< No Subject >"; } else { ! echo $Messages->Subject; } ?> </a></td> ! <td><?php echo date("F j, Y, g:i a",$Messages->Date); ?></td> ! <td>Visitor #<?php echo $senderinfo->ID; ?></td> ! <td>[ <a href='inbox.php?DELETE=<?php echo $Messages->ID; ?>'> Delete </a> ] ! [ <a href="newmsg.php?REPLY=<?php echo $senderinfo->ID; ?>&SUBJECT=Re: <?php echo $Messages->Subject; ?>">Reply</a> ]</td> </tr> - <?php } ?> - </table> <?php include($footer); ! ?> \ No newline at end of file --- 29,97 ---- include($header); + if(! isset($user->user)){ + showlogin(); + die(include($footer)); + } + // If querystring delete is set with a value then delete the specified recordset if (isset($_GET['DELETE'])) { ! mysql_query("DELETE FROM ofirst_messenger_messages WHERE ID = '".$_GET['DELETE']."'") or die(mysql_error()); ! echo "<br><p>Message has been removed, thank you! [ <a href='inbox.php'>Inbox</a> ]</p><br>"; ! die(include($footer)); ! } ! ! // If user specifies to delete all messesges then delete them ! if (isset($_POST['deleteall'])) { ! mysql_query("DELETE FROM ofirst_messenger_messages WHERE Receiver = '".$user->user."'") or die(mysql_error()); ! echo "<br><p>All messages have been deleted, thank you! [ <a href='inbox.php'>Inbox</a> ]</p><br>"; ! die(include($footer)); } + + // Retrieve Messages relating to the users IP address then loop through them + $query = mysql_query("SELECT * FROM ofirst_messenger_messages WHERE Receiver = '".$user->user."'"); ?> <h1>Visitor Inbox for Messaging</h1> ! <p>You have (<?php echo mysql_num_rows($query); ?>) messages within your inbox.</p> ! <table width="661"> <tr> ! <th width="28"></th> ! <th width="194">Subject</th> ! <th width="171">Date</th> ! <th width="128">Sender</th> ! <th width="116">Option</th> </tr> <?php ! while($messages = mysql_fetch_object($query)){ ?> <tr> <td><img src="msg.png" alt="Message"></td> ! <td><a href='viewmsg.php?ID=<?php echo $messages->ID; ?>'> <?php ! if (empty($messages->Subject)){ echo "< No Subject >"; } else { ! echo slur_block(emoticon_translate($messages->Subject)); } ?> </a></td> ! <td><?php echo date("F j, Y, g:i a",$messages->Date); ?></td> ! <td><?php echo $messages->Sender; ?></td> ! <td>[ <a href='inbox.php?DELETE=<?php echo $messages->ID; ?>'> Delete </a> ] ! [ <a href="newmsg.php?SUBJECT=Re: <?php echo $messages->Subject; ?>">Reply</a> ]</td> </tr> <?php + } + if(mysql_num_rows($query) == 0){ + echo "<tr><td>--</td><td>--</td><td>No new messages!</td><td>--</td><td>--</td></tr>"; + } + ?> + </table> + <p><br><form action='inbox.php' method='POST'><input name="deleteall" type="submit" id="deleteall" value="Delete All Messages"></form> + </p> + <p><br> + <?php include($footer); ! ?> ! </p> |