View Single Post
  #15  
Old 05-20-2009, 03:29 PM
SJC SJC is offline
Member
 
Join Date: Apr 2009
Posts: 118
Credits: 8,758
SJC
Default RE: A Enhanced PM System.

Here's my messages.php page:
PHP Code:
<?php

// **********************************************************************
// Rusnak PHP Adoptables Script
// Copyright 2009 Brandon Rusnak
// For help and support: http://www.rusnakweb.com/forum/
//
// Redistribution prohibited without written permission
// **********************************************************************

// Wake the sleeping giant

// **********************************************************************
// Basic Configuration Info
// **********************************************************************

include("inc/functions.php");
include(
"inc/config.php");
include(
"lang/lang.php");

$themeurl grabanysetting("themeurl");

// **********************************************************************
// Define our top links by calling getlinks()
// **********************************************************************

$links getlinks();

// **********************************************************************
// Define our ads by calling getads()
// **********************************************************************

$ads getads("any");

// **********************************************************************
// Grab any dynamic article content from the content table
// **********************************************************************

$pagecontent getsitecontent("index");
$article_title $pagecontent[title];
$article_content $pagecontent[content];
$article_content nl2br($article_content);

// **********************************************************************
// Grab any settings that we will need for the current page from the DB
// **********************************************************************

$browsertitle grabanysetting("browsertitle");
$sitename grabanysetting("sitename");
$slogan grabanysetting("slogan");

// **********************************************************************
// Check and see if the user is logged in to the site
// **********************************************************************

$loginstatus logincheck();
$isloggedin $loginstatus[loginstatus];
$loggedinname $loginstatus[username];

// **********************************************************************
// End Prepwork - Output the page to the user
// **********************************************************************



$ugroup getgroup();
$canpm cando($ugroup"canpm");

if(
$isloggedin == "yes" and $canpm == "yes"){

// Get our actions...

$act $_GET["act"];
$act preg_replace("/[^a-zA-Z0-9\\040.]/"""$act);
$act secure($act);

$user $_GET["user"];
$user preg_replace("/[^a-zA-Z0-9\\040.]/"""$user);
$user secure($user);

$id $_GET["id"];
$id preg_replace("/[^a-zA-Z0-9\\040.]/"""$id);
$id secure($id);



if(
$act == "" or $act == "list"){



$article_content "".$msg."<br>".$article_content."";


// We are showing the users all of their PMs...

$article_title $lang_mypms_title;
$article_content $lang_mypms."";

// Select all of the messages from the database...

$query "SELECT * FROM ".$prefix."messages WHERE touser='".$loggedinname."' ORDER BY id DESC";
$result mysql_query($query);
$num mysql_numrows($result);

if(
$num 0){

$article_content $article_content."<br><b><a href='messages.php?act=send'><img src='templates/icons/fans.gif' border=0> ".$lang_sendnewpm."</a></b><br><br><table width='450' border='1'>
  <tr>
    <td width='155'><strong>Message Title:</strong></td>
    <td width='98'><strong>From:</strong></td>
    <td width='68'><strong>Status:</strong></td>
    <td width='118'><strong>Date Received:</strong></td>
    <td width='77'><strong>Delete:</strong></td>
  </tr>"
;

//Loop out code
$i=0;
while (
$i $num) {

$nid=@mysql_result($result,$i,"id"); 
$status=@mysql_result($result,$i,"status"); 
$datesent=@mysql_result($result,$i,"datesent"); 
$fromuser=@mysql_result($result,$i,"fromuser"); 
$messagetitle=@mysql_result($result,$i,"messagetitle"); 

$messagetitle stripslashes($messagetitle);

if(
$fromuser != "SYSTEM"){
$fromuser "<a href='profile2.php?user=".$fromuser."' target='_blank'>".$fromuser."</a>";
}

if(
$status == "unread"){
$status "<b>unread</b>";
}


$article_content $article_content."<tr>
    <td><b><a href='messages.php?act=read&id="
.$nid."'>".$messagetitle."</a></b></td>
    <td>"
.$fromuser."</td>
    <td><center>"
.$status."</center></td>
    <td><center>"
.$datesent."</center></td>
    <td><center><a href='messages.php?act=delete&id="
.$nid."'><img src='templates/icons/delete.gif' border=0></a></center></td>
  </tr>"
;

$i++;
}

$article_content $article_content."</table><br>";

}
else{

$article_content $article_content."".$lang_nopms."";

}

}
else if(
$act == "read"){

// We are reading a PM...

// We have specified a specific user who we are showing a profile for...
// See if the user exists...








$query "SELECT * FROM ".$prefix."messages WHERE touser='".$loggedinname."' AND id='".$id."'";
$result mysql_query($query);
$num mysql_numrows($result);



if(
$num 0){

//Loop out code
$i=0;
while (
$i 1) {

$nid=@mysql_result($result,$i,"id"); 
$status=@mysql_result($result,$i,"status"); 
$datesent=@mysql_result($result,$i,"datesent"); 
$fromuser=@mysql_result($result,$i,"fromuser"); 
$touser=@mysql_result($result,$i,"touser"); 
$messagetitle=@mysql_result($result,$i,"messagetitle"); 
$messagetext=@mysql_result($result,$i,"messagetext");


$messagetitle stripslashes($messagetitle);
$messagetext stripslashes($messagetext);

$i++;
}

$postbar getpostbar($fromuser);
if(
$isloggedin == "yes") {

$query "SELECT * FROM ".$prefix."messages WHERE touser='".$loggedinname."' and status='unread'";
$result mysql_query($query);
$num mysql_numrows($result);

if(
$num 0){
$msg "<table width='450' border='1' cellpadding='3' cellspacing='1' bordercolor='1' bgcolor='#F9AE00'>
<td>
<table width='450' border='1' cellpadding='3' cellspacing='1' bordercolor='1' bgcolor='#FECF61'>
<tr>
<td><center>You a new message(s): <a href='messages.php'>Visit Message Center</a>(<b>"
.$num."</b>)<br></center></td>
</tr>
</table>
</table>"
;
}

$article_title "Reading Message From ".$fromuser."";
$article_content "

<table width='450' border='1' cellpadding='3' cellspacing='0' bordercolor='1' bgcolor='#DBA8A8'>
<td>
<table width='450' border='1' cellpadding='3' cellspacing='0' bordercolor='1' bgcolor='#424242'>
  <tr>
    <td width='100%'><strong>Date Received: "
.$datesent."</strong></td>
  </tr>
</table>
<table width='450' border='1' cellpadding='3' cellspacing='0' bordercolor='1'>
  <tr>
    <td bgcolor='#838282'><center><a href='profile2.php?user="
.$fromuser."' target='_blank'>".$fromuser."</a>:</center><br>".$postbar."</td>
    <td bgcolor='#ACA9A9'><center><strong>"
.$messagetitle."<br>_______________________________</strong></center><br><strong><center>".$messagetext."</strong></center></td>
  </tr>
</table>
<table width='450' border='1' cellpadding='3' cellspacing='0' bordercolor='1' bgcolor='#424242'>
  <tr>
    <td width='100%' colspan='2'><strong><b><a href='messages.php'><img src='templates/icons/next.gif' border=0> Return to Inbox</a> | <a href='messages.php?act=send&user="
.$fromuser."&messagetitle=".$messagetitle."&id=".$id."'><img src='templates/icons/comment.gif' border=0> Reply to this Message</a> | <a href='messages.php?act=report&user=".$fromuser."'><img src='templates/icons/next.gif' border=0> Report this member</a></b></strong></td>
  </tr>
</table>
</td>
</table><br>"
;

// Set the message as read...

    
$query "UPDATE ".$prefix."messages SET status='read' WHERE id='".$nid."'";
    
mysql_query($query);

}
else{

// Message Does Not Exist...

$article_title $lang_messagenoexist_title;
$article_content $lang_messagenoexist;

}



}
else if(
$act == "send" or $act == "newpm"){



$messagetitle=$_GET['messagetitle'];
$id=$_GET['id'];




// Send a new message to someone else...

$article_title $lang_sendnew_title;
$article_content $lang_sendnew."<br><form name='form1' method='post' action='pmpost.php'>
  <p>Message Recipient: 
    <input name='pmto' type='text' id='pmto' maxlength='50' value='"
.$user."'>
</p>
  <p>Message Title: 
    <input name='mtitle' type='text' id='mtitle' maxlength='25' value='"
.$messagetitle."'>
</p>
  <p>
    <input name='id' type='hidden' id='id' maxlength='25' value='"
.$id."'>
</p>
  <p>Message Text:  </p>
  <p>
    <textarea name='mtext' cols='45' id='mtext' /></textarea>
</p>
  <p>
    <input type='submit' name='Submit' value='Send Private Message'>
</p>
</form>"



}

else if(
$act == "report"){




// Send a new message to someone else...

$article_title "Reporting a Member";
$article_content "You may report a member here, by providing a reason. Please only report a member if he/she is harassing you, or constantly spamming your inbox. This isn't a toy, and shouldn't be treated as such.<br><form name='form1' method='post' action='reportpost.php'>
  <p>
    <input name='member' type='hidden' id='member' maxlength='50' value='"
.$user."'>
</p>
  <p>
    <input name='fromuser' type='hidden' id='fromuser' maxlength='50' value='"
.$loggedinname."'>
</p>
  <p>Reason:  </p>
  <p>
    <textarea name='reason' cols='45' id='reason'></textarea>
</p>
  <p>
    <input type='submit' name='Submit' value='Send Report'>
</p>
</form>"


}
else if(
$act == "delete"){

// We are deleting a message...

$query "DELETE FROM ".$prefix."messages WHERE touser='".$loggedinname."' and id='".$id."'";
mysql_query($query);

$article_title $lang_delete_successful_t;
$article_content $lang_delete_successful;

}
else if(
$act == "sentitems"){

}
else{

// No valid action...

$article_title $lang_invalidact_title;
$article_content $lang_invalidact;

}
}
else{

// User is either not logged in or does not have the proper privledges to send messages...

$article_title $lang_title_pmdenied;
$article_content $lang_pmdenied;

}




// **********************************************************************
// Begin Template Definition
// **********************************************************************

//Define our current theme
$file $themeurl;

// Do the template changes and echo the ready template
$template file_get_contents($file);

$template replace(':ARTICLETITLE:',$article_title,$template);
$template replace(':ARTICLECONTENT:',$article_content,$template);
$template replace(':ARTICLEDATE:',$article_date,$template);

$template replace(':BROWSERTITLE:',$browsertitle,$template);
$template replace(':SITENAME:',$sitename,$template);

//Define our links
$template replace(':LINKSBAR:',$links,$template);

//Get the content for the side bar...

$sidebar getsidebar();
$template replace(':SIDEFEED:',$sidebar,$template);

//Get the ad content...
$template replace(':ADS:',$ads,$template);

//Get the slogan info
$template replace(':SLOGAN:',$slogan,$template);


echo 
$template;

// **********************************************************************
// End Template Definition
// **********************************************************************



?>
Reply With Quote