Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Addons and Modifications > Addons/Mods Graveyard

Notices

Reply
 
Thread Tools Display Modes
  #11  
Old 05-19-2009, 09:32 PM
SJC SJC is offline
Member
 
Join Date: Apr 2009
Posts: 118
Credits: 8,733
SJC
Default RE: A Enhanced PM System.

Thank you for all of your time and help :)
PHP Code:
<?php

// File ID: functions.php
// Purpose: Provides basic sitewide functions

//Connect to the database first
connect();

//This function simply connects us to the database
function connect(){

    include(
"config.php");
    
$conn mysql_connect($dbhost$dbuser$dbpass) or die ('Error connecting to MySQL');
    
mysql_select_db($dbname);

}

//This function performs security checks on all incoming form data
function secure($data){

if(
is_array($data)){
die(
"Hacking Attempt!");
}


//MySQL Real Escape String
$data mysql_real_escape_string($data);

//Strip HTML tags
$data strip_tags($data'');

return 
$data;

}

function 
getsitecontent($page){

include(
"config.php");


$query "SELECT * FROM ".$prefix."content WHERE page = '$page'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);


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

$title=@mysql_result($result,$i,"title");
$content=@mysql_result($result,$i,"content");

$title stripslashes($title);
$content stripslashes($content);

$i++;
}

$value[content] = $content;
$value[title] = $title;

return 
$value;
}

//This function replaces template values
function replace($old,$new,$template)
    {
    
$template str_replace($old$new$template);
    return 
$template;
    }

function 
logincheck(){

include(
"config.php");

//Function to determine if user is logged in.

//Set up our login info...
$username "";
$password "";

//Check for cookie

if (isset($_COOKIE['auser']) and isset($_COOKIE['apass'])){

$username $_COOKIE['auser'];
$password $_COOKIE['apass'];

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

//Run login operation
$query "SELECT * FROM ".$prefix."users WHERE username = '$username'";
$result mysql_query($query);
$num mysql_numrows($result);

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

$luser=@mysql_result($result,$i,"username");
$lpass=@mysql_result($result,$i,"password");

$i++;
}

    if(
$username == $luser and $password == $lpass){
        
$isloggedin "yes";
    }
    else{
    if (isset(
$_COOKIE['auser'])){
    
$past time() - 10
    
setcookie("auser",$username,$past);
    }

    if (isset(
$_COOKIE['apass'])){
    
$past time() - 10
    
setcookie("apass",$password,$past);
    }
    
$isloggedin "no";
    }

}
else
{
//User is not logged in
$isloggedin "no";



//Return our user data
$userdata[loginstatus] = $isloggedin;
$userdata[username] = $username;

return 
$userdata;

}

function 
grabanysetting($where){

include(
"config.php");

$query "SELECT * FROM ".$prefix."settings WHERE name = '".$where."'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

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

$value=@mysql_result($result,$i,"value");
$value stripslashes($value);
$i++;
}
return 
$value;
}

function 
getlinks(){

include(
"config.php");

//This function gets the links for the top bar from the database 

/*

$links = "<li><a href='index.php'>Home</a></li>
<li><a href='adopt.php'>Adopt</a></li>
<li><a href='myadopts.php'>My Adopts</a></li>
<li><a href='account.php'>My Account</a></li>
<li><a href='messages.php'>Message Center</a></li>
<li><a href='trade.php'>Trade Adopts</a></li>
<li><a href='featured.php'>Popular</a></li>";

*/

// We will be getting our links from the database...

$links "";

    
$query "SELECT * FROM ".$prefix."links ORDER BY id ASC";
    
$result mysql_query($query);
    
$num mysql_numrows($result);

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

    
$linktext=@mysql_result($result,$i,"linktext");
    
$linkurl=@mysql_result($result,$i,"linkurl");

    
$linktext stripslashes($linktext);

    
$links $links."<li><a href='".$linkurl."'>".$linktext."</a></li>";

    
$i++;
    }


return 
$links;

}

function 
getsidebar(){

include(
"config.php");

//This function determines what shows in the side bar of the template
//This will most likely be either a login prompt, quick account access, or something else

//First we see if we are logged in or not

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

if(
$isloggedin == "yes"){

$msgctr "<a href='messages.php'>Visit Message Center</a>(Unread: 0 | Total: 0)<br>";

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

if(
$num2 0){
$msgctr "<a href='messages.php'>Visit Message Center</a>(Unread: 0 | Total: ".$num2.")<br>";
}

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

if(
$num 0){
$msgctr "<a href='messages.php'>Visit Message Center</a>(Unread: <b>".$num."</b> | Total: ".$num2.")<br>"
}


$sidebar "<li><a href='profile.php?user=".$loggedinname."'>Profile</a></li>
<li><a href='account.php?act=changesettings'>Settings</a></li>
<li><a href='account.php'>My Account</a></li>
<li><a href='messages.php'>PM(s)(Unread: <b>"
.$num."</b> | Total: ".$num2.")</a></li>
<li><a href='profile.php'>Members</a></li>
<li><a href='logout.php'>Log Out</a></li>"
;
}
function 
getpostbar($name){

include(
"config.php");

    
$query "SELECT * FROM ".$prefix."users WHERE username = '".$name."'";
    
$result mysql_query($query);
    
$num mysql_numrows($result);

    
$membersince=@mysql_result($result,$i,"membersince");
    
$displayquote=@mysql_result($result,$i,"displayquote");
    
$profilepic=@mysql_result($result,$i,"profilepic");

$postbar "
<span class='smalltext'>
<img src='"
.$profilepic."'><br>
<b>Member Since: </b><br>"
.$membersince."<br>
<b>Quote:</b><br>
"
.$displayquote."<br>
</span>
"
;
}


else{

$sidebar "<li><a href='login.php'>Login</a></li><li><a href='register.php'>Register Free</a></li><li><a href='forgotpass.php'>Forgot Password?</a></li>";

}




return 
$sidebar;

}

function 
dologin($username$password){

//This function logs a user in...

include("config.php");

$query "SELECT * FROM ".$prefix."users WHERE username = '$username'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

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

$luser=@mysql_result($result,$i,"username");
$lpass=@mysql_result($result,$i,"password");

$i++;
}

if(
$username == $luser and $password == $lpass){
$status "success";

//If the cookie already exists for some reason, delete it

if (isset($_COOKIE['auser']) and isset($_COOKIE['apass'])){

$past time() - 10
setcookie("auser",$username,$past);
setcookie("apass",$password,$past);

}



// Set the cookie
$Month 2592000 time();
setcookie("auser",$username,$Month);
setcookie("apass",$password,$Month);

}
else{
$status "error";
}



return 
$status;

}

function 
getgroup(){

//This function gets the numerical usergroup ID of a user, or returns 0 if is a guest

include("config.php");

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

if(
$isloggedin == "yes"){

$query "SELECT * FROM ".$prefix."users WHERE username = '$loggedinname'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

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

$group=@mysql_result($result,$i,"usergroup");

$i++;
}

return 
$group;

}
else{
return 
0;
}

}

function 
cancp($usergroup){

include(
"config.php");

//This function determines if a usergroup is allowed to access the Admin CP

$query "SELECT * FROM ".$prefix."groups WHERE gid = '$usergroup'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

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

$cancp=@mysql_result($result,$i,"cancp");

$i++;
}

if(
$cancp == "" or $usergroup == 0){
$cancp "no";
}

return 
$cancp;

}

function 
getadmlinks(){

include(
"config.php");

//This function shows special links to the site admin

$links "<li><a href='index.php'>Home</a></li>
<li><a href='admin.php?set=adopts'>Change Adoptables</a></li>
<li><a href='admin.php?set=content'>Change Content</a></li>
<li><a href='admin.php?set=users'>Change Users</a></li>
<li><a href='admin.php?set=settings'>Site Settings</a></li>
<li><a href='admin.php?set=ads'>Manage Ads</a></li>"
;



return 
$links;

}

function 
cando($usergroup$do){

include(
"config.php");

//This function determines if a usergroup is allowed to do a specific task

$query "SELECT * FROM ".$prefix."groups WHERE gid = '$usergroup'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

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

$cando=@mysql_result($result,$i,$do);

$i++;
}

if(
$cando == "" or $usergroup == 0){
$cando "no";
}

return 
$cando;

}

function 
canadopt($aid$cond$promocode){

include(
"config.php");

// This function determines if a user can adopt a specific adoptable...

$canadopt "yes"// The default status is that we CAN adopt, unless proven false...

// The first thing we check is that we are logged in

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

if(
$isloggedin != "yes" and $cond != "showing"){
$canadopt "no";
}

// Now we check if our usergroup has permission to adopt the adoptable...

$group getgroup();
$dbcanadpt cando($group"canadopt");

if(
$dbcanadpt != "yes" and $cond != "showing"){
$canadopt "no";
}

// We need to pull a lot of junk from the database for these next few checks


$query "SELECT * FROM ".$prefix."adoptables WHERE id='$aid'";
$result mysql_query($query);
$num mysql_numrows($result);

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

$whenisavail=@mysql_result($result,$i,"whenisavail"); 
$correctpromocode=@mysql_result($result,$i,"promocode"); 
$freqcond=@mysql_result($result,$i,"freqcond"); 
$number=@mysql_result($result,$i,"number"); 
$date=@mysql_result($result,$i,"date"); 
$datecond=@mysql_result($result,$i,"datecond");
$adoptscond=@mysql_result($result,$i,"adoptscond"); 




$morethannumberen=@mysql_result($result,$i,"moreless"); 
$morethannumber=@mysql_result($result,$i,"morelessnum"); 
$usergroupsen=@mysql_result($result,$i,"levelgrle"); 
$usergroupid=@mysql_result($result,$i,"grlelevel"); 

$type=@mysql_result($result,$i,"type");

$i++;
}

// Now we check if the adoptable requires a promo code and if the promo code submitted is correct...

if($whenisavail == "promo" and $promocode != $correctpromocode){

// A promo code is required but the submitted promo code is not the correct code
$canadopt "no";

}

// Now we check those three conditions we have in the Admin CP
// If ANY of them fails, this check fails!

if($whenisavail == "conditions"){

    
// If we have a restriction on the number of times this can be adopted...

    
if($freqcond == "enabled"){

    
// We have a frequency based condition
    // Select from the database and determine how many times this adoptable type has been adopted

    
$num 0;

    
$query "SELECT * FROM ".$prefix."owned_adoptables WHERE type='$type'";
    
$result mysql_query($query);
    
$num mysql_numrows($result);

        if(
$num $number){
        
        
// Not Available
        
$canadopt "no";
    
        }


    } 
// End the frequency condition IF statement

    // Begin the date restriction check

    
$today date('Y-m-d');

    if(
$datecond == "enabled" and $date != $today){
    
    
$canadopt "no";
    
    }

    
// We are checking to see how many of this adoptable a user owns
    // If they own more than the specifed number, they cannot adopt...

    

    
if($morethannumberen == "enabled"){

    
$num 0;

    
$query "SELECT * FROM ".$prefix."owned_adoptables WHERE owner='$loggedinname' and type='$type'";
    
$result mysql_query($query);
    
$num mysql_numrows($result);

    if(
$num $morethannumber){

    
$canadopt "no";


    }


    } 
// End morethannumberen check

    
    

    // Check if the user is of a specified usergroup...

    
if($usergroupsen == "enabled"){

    
$ourgid getgroup();

    
// If the two numbers do not match, do not allow the adoption...

        
if($ourgid != $usergroupid){

        
$canadopt "no";

        }    


    }
    
    
    

// End the is there conditions if statement


return $canadopt;

}

function 
getaltstatus($parentid$childid$childlevel){

include(
"config.php");

// This function determines if we will use alternate images...
// All this does is give us a yes or no
// This does NOT actually assign the alternate images in the DB.....

$altstatus "no";
$run "no";

// First we need to see if this adoptable type has alternate images enabled...

$query "SELECT * FROM ".$prefix."adoptables WHERE id='$parentid'";
$result mysql_query($query);
$num mysql_numrows($result);

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

$alternates=@mysql_result($result,$i,"alternates"); 
$altoutlevel=@mysql_result($result,$i,"altoutlevel");
$altchance=@mysql_result($result,$i,"altchance");

$i++;
}

// If alternate images are enabled, we must run some checks to see if we use them...

if($alternates == "enabled"){


// Let's see if the level we are on is the level that requires alternates
// If we're not on a level that requires to check alternates, why bother?

    
if($childlevel == $altoutlevel){
    
    
    
$run "yes";
    
    }



}

if(
$run == "yes"){

// This is where we actually determine if we use alternate images...

$randnum rand(1$altchance);

    if(
$randnum == 1){
    
$altstatus "yes"// If we pull a 1 as the random number, we use the alternate images :)
    
}

}


return 
$altstatus;

}

function 
getcurrentimage($id){

// This function determines which image we should use for a given adoptable...

include("config.php"); // This is so we can use the table prefix

$image "";

// First we select the adoptable from the database and get some basic information...

$query "SELECT * FROM ".$prefix."owned_adoptables WHERE aid='$id'";
$result mysql_query($query);
$num mysql_numrows($result);

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

$type=@mysql_result($result,$i,"type"); 
$currentlevel=@mysql_result($result,$i,"currentlevel"); 
$imageurl=@mysql_result($result,$i,"imageurl");
$usealternates=@mysql_result($result,$i,"usealternates");


$i++;
}

if(
$imageurl != ""){

// If we are using a custom image for this adoptable, use that
$image $imageurl;

}
else{

// We have to dig this up ourselves...
// Check if we are using an egg image or a level image...

    
if($currentlevel == or $currentlevel == "0"){

    
// Let's see what the egg image is...    

    
$query "SELECT * FROM ".$prefix."adoptables WHERE type='$type'";
    
$result mysql_query($query);
    
$num mysql_numrows($result);

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

    
$eggimage=@mysql_result($result,$i,"eggimage"); 


    
$i++;
    }

    
$image $eggimage// Set the image URL equal to the egg image...

    
}
    else{

    
// We have to find out what level we are using...
    // Then we can choose the appropriate image for what we are using...

        
$query "SELECT * FROM ".$prefix."levels WHERE adoptiename='$type' and thisislevel='$currentlevel'";
        
$result mysql_query($query);
        
$num mysql_numrows($result);

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

        
$primaryimage=@mysql_result($result,$i,"primaryimage"); 
        
$alternateimage=@mysql_result($result,$i,"alternateimage");


        
$i++;
        }

        
// If alternate images are enabled and an alternate image exists, use it

        
if($usealternates == "yes" and $alternateimage != ""){

        
$image $alternateimage// Use the alternate image

        
}
        else{

        
$image $primaryimage// Set the image equal to the primary image for the level

        
}
    


    }

}

if(
$type == "" or $image == ""){

// We did not settle on an image, so we show an error image...

$image "http://www.".$domain."".$scriptpath."/templates/icons/delete.gif";

}


return 
$image;

}

function 
getcurrentlevel($id){

// This function gets the current level of an adoptable...

include("config.php");

$query "SELECT * FROM ".$prefix."owned_adoptables WHERE aid='$id'";
$result mysql_query($query);
$num mysql_numrows($result);

//Loop out code
$i=0;
while (
$i 1) {
 
$currentlevel=@mysql_result($result,$i,"currentlevel"); 


$i++;
}

if(
$currentlevel == ""){

$currentlevel "error"// If the adoptable does not have a current level or does not exist, we return an error...

}

// Return the level

return $currentlevel;


}

function 
getnextlevelexists($type$currentlevel){

include(
"config.php");

// This function determines if a higher level exists for an adopt, or if it is at max level.

$query "SELECT * FROM ".$prefix."levels WHERE adoptiename='$type' and thisislevel > '$currentlevel'";
$result mysql_query($query);
$num mysql_numrows($result);

$exists "false";

if(
$num 0){

$exists "true"// A higher level exists

}

return 
$exists;

}

function 
convertidtotype($id){

// This function takes in an adoptable's ID and returns the type of adoptable it is...

include("config.php"); 

$query "SELECT * FROM ".$prefix."owned_adoptables WHERE aid='$id'";
$result mysql_query($query);
$num mysql_numrows($result);

//Loop out code
$i=0;
while (
$i 1) {
 
$type=@mysql_result($result,$i,"type"); 


$i++;
}

if(
$type == ""){

$type "error";

}

return 
$type;

}

function 
converttypetoparentid($type){

// This function takes in an adoptable type and returns the ID of the parent

include("config.php");

$query "SELECT * FROM ".$prefix."adoptables WHERE type='$type'";
$result mysql_query($query);
$num mysql_numrows($result);

//Loop out code
$i=0;
while (
$i 1) {
 
$id=@mysql_result($result,$i,"id"); 


$i++;
}

if(
$id == ""){
$id "error";
}

return 
$id;

}

function 
reward($id$type$currentlevel$owner){

include(
"config.php");

// This function determines if we are giving the user a reward or not...

$query "SELECT * FROM ".$prefix."levels WHERE adoptiename='$type' and thisislevel='$currentlevel'";
$result mysql_query($query);
$num mysql_numrows($result);

//Loop out code
$i=0;
while (
$i 1) {
 
$rewarduser=@mysql_result($result,$i,"rewarduser"); 
$promocode=@mysql_result($result,$i,"promocode");


$i++;
}

if(
$rewarduser == "yes" and $promocode != ""){

// We are sending out a reward...

$mtitle "You have received a reward!";
$mtext "Congratulations!  You have received a reward because one of your adoptables leveled up and the site admin has chosen to reward you for this.<br><br>
<b><u>Your reward is the following promo code:</u></b> "
.$promocode."<br><br>
You may use this promo code on the <a href='promo.php?promocode="
.$promocode."'>Promo Code Page</a> to receive a special exclusive or limited edition adoptable!<br><br>
Congratulations on your reward!"
;

$mtext mysql_real_escape_string($mtext);

$date date('Y-m-d');
$query "INSERT INTO ".$prefix."messages VALUES ('', 'SYSTEM', '$owner','unread','$date','$mtitle', '$mtext')";
mysql_query($query);

// Now we check if we are sending out an email to the user alerting them of the message...

$query "SELECT * FROM ".$prefix."users WHERE username='".$owner."'";
$result mysql_query($query);
$num mysql_numrows($result);

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

$newmessagenotify=@mysql_result($result,$i,"newmessagenotify");
$email=@mysql_result($result,$i,"email"); 

$i++;
}

if(
$newmessagenotify == 1){

// We are sending this user an email about the new message...

    
$systememail grabanysetting("systememail");
    
    
$headers "From: ".$systememail."";

    
$site_name grabanysetting("sitename");

    
$message "Hello ".$owner.";\n\nYou have received a new Private Message from SYSTEM at ".$site_name." with the title ".$mtitle.".\n
    You can read this message at: http://www."
.$domain."".$scriptpath."/messages.php\n
    Thank You.  The "
.$site_name." team.";

    
mail($email$site_name." - You Have Received a Reward"$message$headers);

}



}

return 
$rewardstatus;

}

function 
getadmimages(){

include(
"config.php");

$formcontent "";

$query "SELECT * FROM ".$prefix."filesmap";
$result mysql_query($query);
$num mysql_numrows($result);

//Loop out code
$i=0;
while (
$i $num) {
 
$wwwpath=@mysql_result($result,$i,"wwwpath");
$friendlyname=@mysql_result($result,$i,"friendlyname");

$formcontent $formcontent."<option value='".$wwwpath."'>".$friendlyname."</option>";


$i++;
}

return 
$formcontent;

}

function 
deleteuser($user){

include(
"config.php");

//This function deletes a user from the system...

$user secure($user);

$query "DELETE FROM ".$prefix."users WHERE username = '".$user."'";
$result mysql_query($query);

$query "DELETE FROM ".$prefix."owned_adoptables WHERE owner = '".$user."'";
$result mysql_query($query);

}

function 
getads($page){

// Function to display site advertisements

include("config.php");

if(
$page == "any"){
$page "";
}

$query "SELECT * FROM ".$prefix."ads WHERE page = '".$page."' and status = 'active' ORDER BY RAND() LIMIT 1";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

if(
$num 0){

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

$value=@mysql_result($result,$i,"text");
$value stripslashes($value);
$aid=@mysql_result($result,$i,"id");
$actualimpressions=@mysql_result($result,$i,"actualimpressions");
$impressions=@mysql_result($result,$i,"impressions");
$i++;
}

if(
$impressions == ""){
$impressions 0;
}

$actualimpressions $actualimpressions 1;

//Update the impressions count
$query "UPDATE ".$prefix."ads SET actualimpressions='".$actualimpressions."' WHERE id='".$aid."'";
mysql_query($query);

//Check that ad is not over max impressions...
if ($actualimpressions >= $impressions and $impressions != 0){
$query "UPDATE ".$prefix."ads SET status='inactive' WHERE id='".$aid."'";
mysql_query($query);
}


}
else{
$value "";
}

return 
$value;

}


?>
Reply With Quote
  #12  
Old 05-19-2009, 09:48 PM
Bloodrun's Avatar
Bloodrun Bloodrun is offline
I am, who I am.
 
Join Date: Apr 2009
Posts: 532
Gender: Male
Credits: 27,934
Bloodrun
Send a message via Yahoo to Bloodrun
Default RE: A Enhanced PM System.

PHP Code:
<?php

// File ID: functions.php
// Purpose: Provides basic sitewide functions

//Connect to the database first
connect();

//This function simply connects us to the database
function connect(){

    include(
"config.php");
    
$conn mysql_connect($dbhost$dbuser$dbpass) or die ('Error connecting to MySQL');
    
mysql_select_db($dbname);

}

//This function performs security checks on all incoming form data
function secure($data){

if(
is_array($data)){
die(
"Hacking Attempt!");
}


//MySQL Real Escape String
$data mysql_real_escape_string($data);

//Strip HTML tags
$data strip_tags($data'');

return 
$data;

}

function 
getsitecontent($page){

include(
"config.php");


$query "SELECT * FROM ".$prefix."content WHERE page = '$page'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);


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

$title=@mysql_result($result,$i,"title");
$content=@mysql_result($result,$i,"content");

$title stripslashes($title);
$content stripslashes($content);

$i++;
}

$value[content] = $content;
$value[title] = $title;

return 
$value;
}

//This function replaces template values
function replace($old,$new,$template)
    {
    
$template str_replace($old$new$template);
    return 
$template;
    }

function 
logincheck(){

include(
"config.php");

//Function to determine if user is logged in.

//Set up our login info...
$username "";
$password "";

//Check for cookie

if (isset($_COOKIE['auser']) and isset($_COOKIE['apass'])){

$username $_COOKIE['auser'];
$password $_COOKIE['apass'];

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

//Run login operation
$query "SELECT * FROM ".$prefix."users WHERE username = '$username'";
$result mysql_query($query);
$num mysql_numrows($result);

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

$luser=@mysql_result($result,$i,"username");
$lpass=@mysql_result($result,$i,"password");

$i++;
}

    if(
$username == $luser and $password == $lpass){
        
$isloggedin "yes";
    }
    else{
    if (isset(
$_COOKIE['auser'])){
    
$past time() - 10
    
setcookie("auser",$username,$past);
    }

    if (isset(
$_COOKIE['apass'])){
    
$past time() - 10
    
setcookie("apass",$password,$past);
    }
    
$isloggedin "no";
    }

}
else
{
//User is not logged in
$isloggedin "no";



//Return our user data
$userdata[loginstatus] = $isloggedin;
$userdata[username] = $username;

return 
$userdata;

}

function 
grabanysetting($where){

include(
"config.php");

$query "SELECT * FROM ".$prefix."settings WHERE name = '".$where."'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

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

$value=@mysql_result($result,$i,"value");
$value stripslashes($value);
$i++;
}
return 
$value;
}

function 
getlinks(){

include(
"config.php");

//This function gets the links for the top bar from the database 

/*

$links = "<li><a href='index.php'>Home</a></li>
<li><a href='adopt.php'>Adopt</a></li>
<li><a href='myadopts.php'>My Adopts</a></li>
<li><a href='account.php'>My Account</a></li>
<li><a href='messages.php'>Message Center</a></li>
<li><a href='trade.php'>Trade Adopts</a></li>
<li><a href='featured.php'>Popular</a></li>";

*/

// We will be getting our links from the database...

$links "";

    
$query "SELECT * FROM ".$prefix."links ORDER BY id ASC";
    
$result mysql_query($query);
    
$num mysql_numrows($result);

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

    
$linktext=@mysql_result($result,$i,"linktext");
    
$linkurl=@mysql_result($result,$i,"linkurl");

    
$linktext stripslashes($linktext);

    
$links $links."<li><a href='".$linkurl."'>".$linktext."</a></li>";

    
$i++;
    }


return 
$links;

}

function 
getsidebar(){

include(
"config.php");

//This function determines what shows in the side bar of the template
//This will most likely be either a login prompt, quick account access, or something else

//First we see if we are logged in or not

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

if(
$isloggedin == "yes"){

$msgctr "<a href='messages.php'>Visit Message Center</a>(Unread: 0 | Total: 0)<br>";

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

if(
$num2 0){
$msgctr "<a href='messages.php'>Visit Message Center</a>(Unread: 0 | Total: ".$num2.")<br>";
}

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

if(
$num 0){
$msgctr "<a href='messages.php'>Visit Message Center</a>(Unread: <b>".$num."</b> | Total: ".$num2.")<br>"
}


$sidebar "<li><a href='profile.php?user=".$loggedinname."'>Profile</a></li>
<li><a href='account.php?act=changesettings'>Settings</a></li>
<li><a href='account.php'>My Account</a></li>
<li><a href='messages.php'>PM(s)(Unread: <b>"
.$num."</b> | Total: ".$num2.")</a></li>
<li><a href='profile.php'>Members</a></li>
<li><a href='logout.php'>Log Out</a></li>"
;
}
else{

$sidebar "<li><a href='login.php'>Login</a></li><li><a href='register.php'>Register Free</a></li><li><a href='forgotpass.php'>Forgot Password?</a></li>";

}




return 
$sidebar;

}
function 
getpostbar($name){

include(
"config.php");

    
$query "SELECT * FROM ".$prefix."users WHERE username = '".$name."'";
    
$result mysql_query($query);
    
$num mysql_numrows($result);

    
$membersince=@mysql_result($result,$i,"membersince");
    
$displayquote=@mysql_result($result,$i,"displayquote");
    
$profilepic=@mysql_result($result,$i,"profilepic");

$postbar "
<span class='smalltext'>
<img src='"
.$profilepic."'><br>
<b>Member Since: </b><br>"
.$membersince."<br>
<b>Quote:</b><br>
"
.$displayquote."<br>
</span>
"
;

return 
$postbar;

}

function 
dologin($username$password){

//This function logs a user in...

include("config.php");

$query "SELECT * FROM ".$prefix."users WHERE username = '$username'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

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

$luser=@mysql_result($result,$i,"username");
$lpass=@mysql_result($result,$i,"password");

$i++;
}

if(
$username == $luser and $password == $lpass){
$status "success";

//If the cookie already exists for some reason, delete it

if (isset($_COOKIE['auser']) and isset($_COOKIE['apass'])){

$past time() - 10
setcookie("auser",$username,$past);
setcookie("apass",$password,$past);

}



// Set the cookie
$Month 2592000 time();
setcookie("auser",$username,$Month);
setcookie("apass",$password,$Month);

}
else{
$status "error";
}



return 
$status;

}

function 
getgroup(){

//This function gets the numerical usergroup ID of a user, or returns 0 if is a guest

include("config.php");

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

if(
$isloggedin == "yes"){

$query "SELECT * FROM ".$prefix."users WHERE username = '$loggedinname'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

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

$group=@mysql_result($result,$i,"usergroup");

$i++;
}

return 
$group;

}
else{
return 
0;
}

}

function 
cancp($usergroup){

include(
"config.php");

//This function determines if a usergroup is allowed to access the Admin CP

$query "SELECT * FROM ".$prefix."groups WHERE gid = '$usergroup'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

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

$cancp=@mysql_result($result,$i,"cancp");

$i++;
}

if(
$cancp == "" or $usergroup == 0){
$cancp "no";
}

return 
$cancp;

}

function 
getadmlinks(){

include(
"config.php");

//This function shows special links to the site admin

$links "<li><a href='index.php'>Home</a></li>
<li><a href='admin.php?set=adopts'>Change Adoptables</a></li>
<li><a href='admin.php?set=content'>Change Content</a></li>
<li><a href='admin.php?set=users'>Change Users</a></li>
<li><a href='admin.php?set=settings'>Site Settings</a></li>
<li><a href='admin.php?set=ads'>Manage Ads</a></li>"
;



return 
$links;

}

function 
cando($usergroup$do){

include(
"config.php");

//This function determines if a usergroup is allowed to do a specific task

$query "SELECT * FROM ".$prefix."groups WHERE gid = '$usergroup'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

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

$cando=@mysql_result($result,$i,$do);

$i++;
}

if(
$cando == "" or $usergroup == 0){
$cando "no";
}

return 
$cando;

}

function 
canadopt($aid$cond$promocode){

include(
"config.php");

// This function determines if a user can adopt a specific adoptable...

$canadopt "yes"// The default status is that we CAN adopt, unless proven false...

// The first thing we check is that we are logged in

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

if(
$isloggedin != "yes" and $cond != "showing"){
$canadopt "no";
}

// Now we check if our usergroup has permission to adopt the adoptable...

$group getgroup();
$dbcanadpt cando($group"canadopt");

if(
$dbcanadpt != "yes" and $cond != "showing"){
$canadopt "no";
}

// We need to pull a lot of junk from the database for these next few checks


$query "SELECT * FROM ".$prefix."adoptables WHERE id='$aid'";
$result mysql_query($query);
$num mysql_numrows($result);

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

$whenisavail=@mysql_result($result,$i,"whenisavail"); 
$correctpromocode=@mysql_result($result,$i,"promocode"); 
$freqcond=@mysql_result($result,$i,"freqcond"); 
$number=@mysql_result($result,$i,"number"); 
$date=@mysql_result($result,$i,"date"); 
$datecond=@mysql_result($result,$i,"datecond");
$adoptscond=@mysql_result($result,$i,"adoptscond"); 




$morethannumberen=@mysql_result($result,$i,"moreless"); 
$morethannumber=@mysql_result($result,$i,"morelessnum"); 
$usergroupsen=@mysql_result($result,$i,"levelgrle"); 
$usergroupid=@mysql_result($result,$i,"grlelevel"); 

$type=@mysql_result($result,$i,"type");

$i++;
}

// Now we check if the adoptable requires a promo code and if the promo code submitted is correct...

if($whenisavail == "promo" and $promocode != $correctpromocode){

// A promo code is required but the submitted promo code is not the correct code
$canadopt "no";

}

// Now we check those three conditions we have in the Admin CP
// If ANY of them fails, this check fails!

if($whenisavail == "conditions"){

    
// If we have a restriction on the number of times this can be adopted...

    
if($freqcond == "enabled"){

    
// We have a frequency based condition
    // Select from the database and determine how many times this adoptable type has been adopted

    
$num 0;

    
$query "SELECT * FROM ".$prefix."owned_adoptables WHERE type='$type'";
    
$result mysql_query($query);
    
$num mysql_numrows($result);

        if(
$num $number){
        
        
// Not Available
        
$canadopt "no";
    
        }


    } 
// End the frequency condition IF statement

    // Begin the date restriction check

    
$today date('Y-m-d');

    if(
$datecond == "enabled" and $date != $today){
    
    
$canadopt "no";
    
    }

    
// We are checking to see how many of this adoptable a user owns
    // If they own more than the specifed number, they cannot adopt...

    

    
if($morethannumberen == "enabled"){

    
$num 0;

    
$query "SELECT * FROM ".$prefix."owned_adoptables WHERE owner='$loggedinname' and type='$type'";
    
$result mysql_query($query);
    
$num mysql_numrows($result);

    if(
$num $morethannumber){

    
$canadopt "no";


    }


    } 
// End morethannumberen check

    
    

    // Check if the user is of a specified usergroup...

    
if($usergroupsen == "enabled"){

    
$ourgid getgroup();

    
// If the two numbers do not match, do not allow the adoption...

        
if($ourgid != $usergroupid){

        
$canadopt "no";

        }    


    }
    
    
    

// End the is there conditions if statement


return $canadopt;

}

function 
getaltstatus($parentid$childid$childlevel){

include(
"config.php");

// This function determines if we will use alternate images...
// All this does is give us a yes or no
// This does NOT actually assign the alternate images in the DB.....

$altstatus "no";
$run "no";

// First we need to see if this adoptable type has alternate images enabled...

$query "SELECT * FROM ".$prefix."adoptables WHERE id='$parentid'";
$result mysql_query($query);
$num mysql_numrows($result);

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

$alternates=@mysql_result($result,$i,"alternates"); 
$altoutlevel=@mysql_result($result,$i,"altoutlevel");
$altchance=@mysql_result($result,$i,"altchance");

$i++;
}

// If alternate images are enabled, we must run some checks to see if we use them...

if($alternates == "enabled"){


// Let's see if the level we are on is the level that requires alternates
// If we're not on a level that requires to check alternates, why bother?

    
if($childlevel == $altoutlevel){
    
    
    
$run "yes";
    
    }



}

if(
$run == "yes"){

// This is where we actually determine if we use alternate images...

$randnum rand(1$altchance);

    if(
$randnum == 1){
    
$altstatus "yes"// If we pull a 1 as the random number, we use the alternate images :)
    
}

}


return 
$altstatus;

}

function 
getcurrentimage($id){

// This function determines which image we should use for a given adoptable...

include("config.php"); // This is so we can use the table prefix

$image "";

// First we select the adoptable from the database and get some basic information...

$query "SELECT * FROM ".$prefix."owned_adoptables WHERE aid='$id'";
$result mysql_query($query);
$num mysql_numrows($result);

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

$type=@mysql_result($result,$i,"type"); 
$currentlevel=@mysql_result($result,$i,"currentlevel"); 
$imageurl=@mysql_result($result,$i,"imageurl");
$usealternates=@mysql_result($result,$i,"usealternates");


$i++;
}

if(
$imageurl != ""){

// If we are using a custom image for this adoptable, use that
$image $imageurl;

}
else{

// We have to dig this up ourselves...
// Check if we are using an egg image or a level image...

    
if($currentlevel == or $currentlevel == "0"){

    
// Let's see what the egg image is...    

    
$query "SELECT * FROM ".$prefix."adoptables WHERE type='$type'";
    
$result mysql_query($query);
    
$num mysql_numrows($result);

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

    
$eggimage=@mysql_result($result,$i,"eggimage"); 


    
$i++;
    }

    
$image $eggimage// Set the image URL equal to the egg image...

    
}
    else{

    
// We have to find out what level we are using...
    // Then we can choose the appropriate image for what we are using...

        
$query "SELECT * FROM ".$prefix."levels WHERE adoptiename='$type' and thisislevel='$currentlevel'";
        
$result mysql_query($query);
        
$num mysql_numrows($result);

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

        
$primaryimage=@mysql_result($result,$i,"primaryimage"); 
        
$alternateimage=@mysql_result($result,$i,"alternateimage");


        
$i++;
        }

        
// If alternate images are enabled and an alternate image exists, use it

        
if($usealternates == "yes" and $alternateimage != ""){

        
$image $alternateimage// Use the alternate image

        
}
        else{

        
$image $primaryimage// Set the image equal to the primary image for the level

        
}
    


    }

}

if(
$type == "" or $image == ""){

// We did not settle on an image, so we show an error image...

$image "http://www.".$domain."".$scriptpath."/templates/icons/delete.gif";

}


return 
$image;

}

function 
getcurrentlevel($id){

// This function gets the current level of an adoptable...

include("config.php");

$query "SELECT * FROM ".$prefix."owned_adoptables WHERE aid='$id'";
$result mysql_query($query);
$num mysql_numrows($result);

//Loop out code
$i=0;
while (
$i 1) {
 
$currentlevel=@mysql_result($result,$i,"currentlevel"); 


$i++;
}

if(
$currentlevel == ""){

$currentlevel "error"// If the adoptable does not have a current level or does not exist, we return an error...

}

// Return the level

return $currentlevel;


}

function 
getnextlevelexists($type$currentlevel){

include(
"config.php");

// This function determines if a higher level exists for an adopt, or if it is at max level.

$query "SELECT * FROM ".$prefix."levels WHERE adoptiename='$type' and thisislevel > '$currentlevel'";
$result mysql_query($query);
$num mysql_numrows($result);

$exists "false";

if(
$num 0){

$exists "true"// A higher level exists

}

return 
$exists;

}

function 
convertidtotype($id){

// This function takes in an adoptable's ID and returns the type of adoptable it is...

include("config.php"); 

$query "SELECT * FROM ".$prefix."owned_adoptables WHERE aid='$id'";
$result mysql_query($query);
$num mysql_numrows($result);

//Loop out code
$i=0;
while (
$i 1) {
 
$type=@mysql_result($result,$i,"type"); 


$i++;
}

if(
$type == ""){

$type "error";

}

return 
$type;

}

function 
converttypetoparentid($type){

// This function takes in an adoptable type and returns the ID of the parent

include("config.php");

$query "SELECT * FROM ".$prefix."adoptables WHERE type='$type'";
$result mysql_query($query);
$num mysql_numrows($result);

//Loop out code
$i=0;
while (
$i 1) {
 
$id=@mysql_result($result,$i,"id"); 


$i++;
}

if(
$id == ""){
$id "error";
}

return 
$id;

}

function 
reward($id$type$currentlevel$owner){

include(
"config.php");

// This function determines if we are giving the user a reward or not...

$query "SELECT * FROM ".$prefix."levels WHERE adoptiename='$type' and thisislevel='$currentlevel'";
$result mysql_query($query);
$num mysql_numrows($result);

//Loop out code
$i=0;
while (
$i 1) {
 
$rewarduser=@mysql_result($result,$i,"rewarduser"); 
$promocode=@mysql_result($result,$i,"promocode");


$i++;
}

if(
$rewarduser == "yes" and $promocode != ""){

// We are sending out a reward...

$mtitle "You have received a reward!";
$mtext "Congratulations!  You have received a reward because one of your adoptables leveled up and the site admin has chosen to reward you for this.<br><br>
<b><u>Your reward is the following promo code:</u></b> "
.$promocode."<br><br>
You may use this promo code on the <a href='promo.php?promocode="
.$promocode."'>Promo Code Page</a> to receive a special exclusive or limited edition adoptable!<br><br>
Congratulations on your reward!"
;

$mtext mysql_real_escape_string($mtext);

$date date('Y-m-d');
$query "INSERT INTO ".$prefix."messages VALUES ('', 'SYSTEM', '$owner','unread','$date','$mtitle', '$mtext')";
mysql_query($query);

// Now we check if we are sending out an email to the user alerting them of the message...

$query "SELECT * FROM ".$prefix."users WHERE username='".$owner."'";
$result mysql_query($query);
$num mysql_numrows($result);

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

$newmessagenotify=@mysql_result($result,$i,"newmessagenotify");
$email=@mysql_result($result,$i,"email"); 

$i++;
}

if(
$newmessagenotify == 1){

// We are sending this user an email about the new message...

    
$systememail grabanysetting("systememail");
    
    
$headers "From: ".$systememail."";

    
$site_name grabanysetting("sitename");

    
$message "Hello ".$owner.";\n\nYou have received a new Private Message from SYSTEM at ".$site_name." with the title ".$mtitle.".\n
    You can read this message at: http://www."
.$domain."".$scriptpath."/messages.php\n
    Thank You.  The "
.$site_name." team.";

    
mail($email$site_name." - You Have Received a Reward"$message$headers);

}



}

return 
$rewardstatus;

}

function 
getadmimages(){

include(
"config.php");

$formcontent "";

$query "SELECT * FROM ".$prefix."filesmap";
$result mysql_query($query);
$num mysql_numrows($result);

//Loop out code
$i=0;
while (
$i $num) {
 
$wwwpath=@mysql_result($result,$i,"wwwpath");
$friendlyname=@mysql_result($result,$i,"friendlyname");

$formcontent $formcontent."<option value='".$wwwpath."'>".$friendlyname."</option>";


$i++;
}

return 
$formcontent;

}

function 
deleteuser($user){

include(
"config.php");

//This function deletes a user from the system...

$user secure($user);

$query "DELETE FROM ".$prefix."users WHERE username = '".$user."'";
$result mysql_query($query);

$query "DELETE FROM ".$prefix."owned_adoptables WHERE owner = '".$user."'";
$result mysql_query($query);

}

function 
getads($page){

// Function to display site advertisements

include("config.php");

if(
$page == "any"){
$page "";
}

$query "SELECT * FROM ".$prefix."ads WHERE page = '".$page."' and status = 'active' ORDER BY RAND() LIMIT 1";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

if(
$num 0){

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

$value=@mysql_result($result,$i,"text");
$value stripslashes($value);
$aid=@mysql_result($result,$i,"id");
$actualimpressions=@mysql_result($result,$i,"actualimpressions");
$impressions=@mysql_result($result,$i,"impressions");
$i++;
}

if(
$impressions == ""){
$impressions 0;
}

$actualimpressions $actualimpressions 1;

//Update the impressions count
$query "UPDATE ".$prefix."ads SET actualimpressions='".$actualimpressions."' WHERE id='".$aid."'";
mysql_query($query);

//Check that ad is not over max impressions...
if ($actualimpressions >= $impressions and $impressions != 0){
$query "UPDATE ".$prefix."ads SET status='inactive' WHERE id='".$aid."'";
mysql_query($query);
}


}
else{
$value "";
}

return 
$value;

}


?>
Alright the reason it wouldnt work, is because you had the postbar function within the sidebar function lol. But now everything should work.
Reply With Quote
  #13  
Old 05-20-2009, 06:09 AM
SJC SJC is offline
Member
 
Join Date: Apr 2009
Posts: 118
Credits: 8,733
SJC
Default RE: A Enhanced PM System.

Woops, :), thanks...
Okay it works but when I click on a message, it just brings me back to messages.php.
Reply With Quote
  #14  
Old 05-20-2009, 07:18 AM
Bloodrun's Avatar
Bloodrun Bloodrun is offline
I am, who I am.
 
Join Date: Apr 2009
Posts: 532
Gender: Male
Credits: 27,934
Bloodrun
Send a message via Yahoo to Bloodrun
Default RE: A Enhanced PM System.

Quote:
Originally Posted by SJC
Woops, :), thanks...
Okay it works but when I click on a message, it just brings me back to messages.php.
okay copy and paste your message.php file here.

Because your link has to say something like:
http://youriste.com/messages.php?act=read&id=23
Reply With Quote
  #15  
Old 05-20-2009, 03:29 PM
SJC SJC is offline
Member
 
Join Date: Apr 2009
Posts: 118
Credits: 8,733
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
  #16  
Old 05-20-2009, 07:29 PM
Bloodrun's Avatar
Bloodrun Bloodrun is offline
I am, who I am.
 
Join Date: Apr 2009
Posts: 532
Gender: Male
Credits: 27,934
Bloodrun
Send a message via Yahoo to Bloodrun
Default RE: A Enhanced PM System.

Okay, well I couldn't for the live of me, figure out why it wasn't showing, so here just use my messages.php file:

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);

$status2 "".grabanysetting("status")."";
$reason2 "".grabanysetting("reason")."";

if(
$status2 == "1") {


$article_content "
<table>
<table width='100%' border='1'>
  <tr>
    <td width='100' align='center'><strong>Your Administrator has turned the board offline. If your administrator has listed a reason, it is given below:</strong></td>
  </tr>
  <tr>
    <td width='100' align='center'><strong>"
.$reason2."</strong></td>

  </tr></table></table><br>"
;


}
else {

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

// 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);

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

<table width='100%' border='1' cellpadding='3' cellspacing='0' bordercolor='1' class='ftable'>
<td>
<table width='100%' border='0' cellpadding='3' cellspacing='0' bordercolor='1' class='ftable'>
  <tr>
    <td width='100%' class='tr><strong>Date Received: "
.$datesent."</strong></td>
  </tr>
</table>
<table width='100%' border='0' cellpadding='3' cellspacing='0' bordercolor='1' class='ftable'>
  <tr>
    <td class='trow'><center><strong>"
.$messagetitle."<br>_______________________________</strong></center><br><strong><center>".$messagetext."</strong></center></td>
    <td class='trow'><center><a href='profile2.php?user="
.$fromuser."' target='_blank'>".$fromuser."</a>:</center><br>".$postbar."</td>
  </tr>
</table>
<table width='100%' border='0' cellpadding='3' cellspacing='0' bordercolor='1' class='ftable'>
  <tr>
    <td width='100%' colspan='2' class='tr'><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
  #17  
Old 05-20-2009, 07:32 PM
SJC SJC is offline
Member
 
Join Date: Apr 2009
Posts: 118
Credits: 8,733
SJC
Default RE: A Enhanced PM System.

Okay, thank :). And for all of the help, I will rep you.
Reply With Quote
  #18  
Old 05-20-2009, 07:34 PM
Bloodrun's Avatar
Bloodrun Bloodrun is offline
I am, who I am.
 
Join Date: Apr 2009
Posts: 532
Gender: Male
Credits: 27,934
Bloodrun
Send a message via Yahoo to Bloodrun
Default RE: A Enhanced PM System.

Quote:
Originally Posted by SJC
Okay, thank :). And for all of the help, I will rep you.
Your welcome, and why.. thank you =D
Reply With Quote
  #19  
Old 05-26-2009, 03:54 PM
rosepose rosepose is offline
Member
 
Join Date: Jan 2009
Posts: 127
Credits: 10,459
rosepose
Default RE: A Enhanced PM System.

I got to about step... 1, and then I got this error:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/solaeria/public_html/alearith/adoptables/inc/functions.php on line 219

Sorry for being such a pest. Do I have to have the forum script in to get this to work?
Reply With Quote
  #20  
Old 05-26-2009, 07:30 PM
Bloodrun's Avatar
Bloodrun Bloodrun is offline
I am, who I am.
 
Join Date: Apr 2009
Posts: 532
Gender: Male
Credits: 27,934
Bloodrun
Send a message via Yahoo to Bloodrun
Default RE: A Enhanced PM System.

Quote:
Originally Posted by rosepose
I got to about step... 1, and then I got this error:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/solaeria/public_html/alearith/adoptables/inc/functions.php on line 219

Sorry for being such a pest. Do I have to have the forum script in to get this to work?
Nope you don't need the forum script to make this work.
If you would just copy and paste your code here, I'll see what is wrong with it.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mys v1.3.3 Personality System Hwona Mys v1.3.x Mods 15 12-18-2016 09:13 PM
System Shop sensacion Questions and Supports 0 05-08-2011 06:40 PM
Enhanced PM Bloodrun Mys v1.1.x Mods 7 02-15-2011 06:04 PM
Abandon system bokkun Mys v1.1.x Mods 30 11-16-2010 10:19 PM
Trade System? SieghartZeke Questions and Supports 1 12-28-2009 07:06 AM


All times are GMT -5. The time now is 04:16 AM.

Currently Active Users: 262 (0 members and 262 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636