Friendlist/Blocklist + Msg URLs to Members - RMB Scripting
You appear not to have an account with us, Click HERE to register an account...
RMB Scripting
Navigation
  Home
  Contact
  FAQ
  Forum
  Topsites
  Members
  Affiliates
  Arcade <-- New!
  IoxHost
Downloads
  Templates
  Scripts
  Fonts
  Image Sets
  Software
  Other
 
Tutorials
  .htaccess
  Photoshop
  C/C++
  CSS
  Macromedia Flash
  MySQL
  PHP
  PHP - User System
  HTML
  Javascript
  Macintosh
  Macromedia Fireworks
  Visual Basic
  Visual C#
  Windows
  Python
  Other
 
Latest Tutorials
RMB User Commenting Sy...
Easy Navigation Integr...
Decorate Basic Icon
paragraph shortner
Convert Email address ...
Latest Comments
Badge System
Pet system
Pet system
Badge System
Report & Warn Script
Stats
Total Members: 597 [241]
Total Tutorials: 284
Newsest User: andrerds
Todays Unique Hits: 90
Users Online: 0
 
5 Guests
Poll
What do you look for in a web host?
Price
Uptime
Reviews
Customer Service
Size of Company
Main Content
Tutorial: Friendlist/Blocklist + Msg URLs to Members By UrbanTwitch
In this tutorial you will be able to keep track of your friends and ignore people.

This tutorial is quite long so bear with me.

First let's SQL the blocklist. You should have the tables `friends` and `friend_requests` from new2old's Friend System.

   
CODE:

CREATE TABLE `blocklist` (
`id` int(10) NOT NULL auto_increment,
`foe` varchar(225) NOT NULL default '',
`username` varchar(225) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM;


Ok, now its time to create your Friend list. Call this my_friends.php

   
PHP:
<?php
include ('config.php');
switch(
$_GET[page]){ //make some links ?page=case

case 'deleteall'// delete page
$delete mysql_query"DELETE FROM `friends` WHERE `username` = '$logged[username]' "); // deletes friend request
echo ( "You have deleted all your friends." ); // echos completion
break; //ends delete page

case 'delete'// delete page
if ($_GET[user]) { //get username
$delete mysql_query"DELETE FROM `friends` WHERE `friendname` = '$_GET[user]' "); // deletes friend request
echo ( "$_GET[user] has been deleted from your friendlist." ); // echos completion
}
break; 
//ends delete page

case 'msgto'// delete page
$getuser mysql_query("SELECT * FROM `members` WHERE `id` = '$_GET[user]'");
$suser mysql_fetch_array($getuser); 
if (
$_GET[user]) { //get username
if(!$_POST[send]){ //if the form was not submitted
echo "<style>
form#sendmsg
{
background:#DFF6FF;
border: 1px solid #4B9EBE;
padding: 8px;
width: 390px;
}
input
{
background:#F1F6F8;
border:1px solid #4B9EBE;
color: #397D97;
}
textarea
{
background:#F1F6F8;
border:1px solid #4B9EBE;
color: #397D97;
font-family: tahoma;
font-size:12px;
padding: 4px;
}
</style>
<form method=\\"
post\\" action=\\"\\" id=sendmsg>
<b>To User</b>:"
//echo some of the form and whatnot
if(isset($_GET[user])){ //check if there is a user in the address bar
echo "<input type=\\"text\\" name=\\"to\\" value=\\"$_GET[user]\\" size=\\"15\\" readonly=yes>
<br>Sending message to 
$suser[username]"//if there is
}else{ //or not..
echo "<input type=\\"text\\" name=\\"to\\" size=\\"15\\">"//echo the input box without the value of the user!
//end user check in address bar
echo "<br><b>Subject</b>:
<input type=text name=title value=Message size=15><br>
<br><b>Message</b>:<br>
<textarea name=message rows=7 cols=68></textarea><br><br>
<input type=submit name=send value=Send Message> - <a href=\\"
inbox.php\\">Go Back</a>
</form>"
//echo the rest of the form
}else{ //or if it was....
$to stripslashes(htmlspecialchars(strip_tags($suser[username]))); //who its to
$from $logged[username]; //who its from
$date date("F j, Y, g:i a"); //the date sent
$msg addslashes($_POST[message]); //the message variable
$subject addslashes($_POST[title]); //the subject
$do mysql_query("INSERT INTO `privates` (`to`,`from`,`date`,`subject`,`content`) VALUES ('" $to "','" $from "','" $date "','" $subject "','" $msg "')") or die(mysql_error()); //insert into the table!
echo "Message Sent! Returning back...<meta http-equiv=refresh content=1;url=http://sodadome.com/inbox.php>";
//end sent check
}
break; 
//end make new msg

default: //set up the default page upon going to inbox.php

$afed mysql_query("SELECT * FROM `friends` WHERE `username` = '$logged[username]' ORDER BY `id` ASC") or die(mysql_error()); 
//loops there name out 
echo "<div id='title'>My Friends</div>

<br><a href='?page=deleteall'>Delete All Friends</a><br> <style>
table {
background: #D1E8F7;
padding: 4px;
width: 400px;
border: 1px solid #2694DC;
color: #3C769C;
}
tr#top {
background: #B4DBF5;
}
</style><br><center>
<table align=center><tr align='center' id='top'><td>Username</td><td>Send Message</td><td>Remove</td></tr>"
;
while (
$fr mysql_fetch_array($afed)) { 
    
$fid mysql_query("SELECT * FROM `members` WHERE `username` = '$fr[friendname]'") or die(mysql_error()); 
$fri mysql_fetch_array($fid);
echo 
"<tr align='center'><td><a href='http://sodadome.com/members.php?user=$fri[id]'>$fr[friendname]</a></td><td><a href='http://sodadome.com/members.php?page=msgto&amp;user=$fri[id]'><img src='http://sodadome.com/scp/email_go.png' border='0' title='Send Message'></a></td><td><a href='?page=delete&amp;user=$fr[friendname]'><img src='http://sodadome.com/phpimgs/cross.png' border='0' title='Remove Friend?'></a></td></tr>";
}
echo 
"</table></center>";
break;
}


?>


If you have at least one friend, it will show up. If not it will say "You have no friends."

From there you have two options - Message them or Remove from friendlist.

Now onto the Blocklist. Lets name this file blocklist.php

   
PHP:
<?php 
include ('config.php');
switch(
$_GET[page]){ //make some links ?page=case

case 'deleteall'// delete page
$delete mysql_query"DELETE FROM `blocklist` WHERE `username` = '$logged[username]' "); // deletes friend request
echo ( "You have unblocked all your foes." ); // echos completion
break; //ends delete page

case 'block'// delete page
if ($_GET[user]){ //gets username
$thefoe htmlspecialchars($_GET[user]); //friend
$query mysql_query("INSERT INTO `blocklist` ( `username` , `foe` ) VALUES ( '$logged[username]' , '$thefoe' )"); //inserts the request
echo ( "You have blocked $thefoe. They cannot send you PMs anymore." ); // echos completion
}
break;

case 
'delete'// delete page
if ($_GET[user]) { //get username
$delete mysql_query"DELETE FROM `blocklist` WHERE `foe` = '$_GET[user]' "); // deletes friend request
echo ( "$_GET[user] has been unblocked." ); // echos completion
}
break; 
//ends delete page

default: //set up the default page upon going to inbox.php
$afed mysql_query("SELECT * FROM `blocklist` WHERE `username` = '$logged[username]' ORDER BY `id` ASC") or die(mysql_error()); 
//loops there name out 
echo "<div id='title'>Blocklist</div>

<br><a href='?page=deleteall'>Delete All Foes</a><br> <style>
table {
background: #D1E8F7;
padding: 4px;
width: 400px;
border: 1px solid #2694DC;
color: #3C769C;
}
tr#top {
background: #B4DBF5;
}
</style><br><center>
<table align=center><tr align='center' id='top'><td>Username</td><td>Remove</td></tr>"
;
$get mysql_query("SELECT * FROM `blocklist` WHERE `username` = '" $logged[username] . "'"); //get the private messages
$enemys mysql_query("SELECT * FROM `blocklist` WHERE `username` = '$logged[username]' ORDER BY `id` ASC") or die(mysql_error()); 
if(
mysql_num_rows($get) == "0"){
    echo 
"<tr align='center'><td colspan='2'>You Have No Enemies!</td></tr></table>";
}else{
while (
$e mysql_fetch_array($enemys)) { 
    
$fid mysql_query("SELECT * FROM `members` WHERE `username` = '$e[foe]'") or die(mysql_error()); 
$fri mysql_fetch_array($fid);
echo 
"<tr align='center'><td><a href='http://sodadome.com/members.php?user=$fri[id]'>$e[foe]</a></td><td><a href='?page=delete&amp;user=$e[foe]'><img src='http://sodadome.com/phpimgs/cross.png' border='0' title='Unblock User'></a></td></tr>";
}
echo 
"</table></center>";
}
break;
}

?>


Now for go to where you show your member's profile (usually members.php) and find

   
PHP:
//if it does exist then show there profile
$user = mysql_fetch_array($getuser); 


and below it add:

   
PHP:
$getfoe = mysql_query("SELECT * FROM `blocklist` WHERE `foe` = '$user[username]'");
$en = mysql_fetch_array($getfoe); 
$getfriend = mysql_query("SELECT * FROM `friends` WHERE `friendname` = '$user[username]'");
$fa = mysql_fetch_array($getfriend);

then in the same file find: where it has like Age, Location, email, etc.

and add:

   
PHP:
";
if ($user[username] == $fa[friendname]){
    echo "<a href='http://sodadome.com/my_friends.php?page=delete&amp;user=$user[username]'><img src='http://sodadome.com/scp/user_add.png' border='0' title='Remove from friendlist'></a>";
    }else{
        echo "<a href='friendrequest.php?user=$user[username]'><img src='http://sodadome.com/scp/user_add.png' border='0' title='Add as friend'></a>";
    }
if ($user[username] == $en[foe]){
    echo "<a href='blocklist.php?page=delete&amp;user=$user[username]'><img src='http://sodadome.com/scp/user_block.png' border='0' title='Unblock user'></a>";
    }else{
        echo "<a href='members.php?page=block&amp;user=$user[username]'><img src='http://sodadome.com/scp/user_block.png' border='0' title='Block user'></a>";
    }
echo "<a href='members.php?page=msgto&amp;user=$user[id]'><img src='http://sodadome.com/scp/email_go.png' border='0' title='Send Message'></a></td></tr></table>";
echo "


Then upload it. Right-click the 3 images (add, ignore, message) and save as own and edit the image files in the php file above.

Ok now stay on same file (members.php) and find:

   
PHP:
echo "$user[username]'s Profile


and add above it:

   
PHP:

if ($logged[username] == $en[foe]){
    echo "<b>Error:</b> This user has blocked you.";
    }else{


then at the end of your PHP script where it says ?> add an extra }

Ok now to pms.php (or where you have your PM inbox stored)

Find

   
PHP:
$to = stripslashes(htmlspecialchars(strip_tags($_POST[to]))); //who its to
$from = $logged[username]; //who its from


and add above it:

   
PHP:
$getfoe = mysql_query("SELECT * FROM `blocklist` WHERE `foe` = '$logged[username]'");
$en = mysql_fetch_array($getfoe); 


Now find... in case 'compose':
   
PHP:
$do = mysql_query("INSERT INTO `privates` (`to`,`from`,`date`,`subject`,`content`,`sendself`) VALUES ('" . $to . "','" . $from . "','" . $date . "','" . $subject . "','" . $msg . "','" . $cc . "');") or die(mysql_error()); //insert into the table!


and above it add:

   
PHP:
if ($_POST[send] && $_POST[to] == $en[username]){
    echo "<b>Error:</b> This user has blocked you from sending any PMs to you.";
    }else{


Now in the break; of case 'compose' add an extra } before it to close the else tag.

Now repeat the steps started from where it says 'find pms.php' and add the same thing to case 'view':.

now find:    
PHP:
</form>"; //echo the rest of the form


So yeah, thats about it. Post your errors, if any. You get.

Thanks for your time.
Difficulty: Moderate
Views: 1559
Rating:
Comments
Posted on Sunday 17th August 2008 at 02:53 PM
Dava
you have a few bugs in this script i will post you the fixed version soon
Posted on Sunday 17th August 2008 at 06:07 PM
jambomb
gota change loads of stuff coz its all for his site quite annoying
Posted on Sunday 17th August 2008 at 06:31 PM
UrbanTwitch
Actually my base script is RMB's... :S
Posted on Monday 18th August 2008 at 12:16 AM
Dava
its not the changing of code its the fact it didnt work yeah it was coded 95% right but still accounted a few errors
Posted on Monday 18th August 2008 at 01:17 AM
UrbanTwitch
such as?
Posted on Tuesday 19th August 2008 at 01:08 AM
Dava
well for 1 why use so many else functions in this scipt why not just use a simple

   
CODE:


if ($_POST[send] && $_POST[to] == $en[username]){
echo "<b>Error:</b> This user has blocked you from sending any PMs to you.";
}
{
}


that way ya dont get the telse error
Posted on Tuesday 19th August 2008 at 01:48 AM
Dava
and you need to change the following or it will block youself from viewing your own profile and let you view people who have blocked you's profiles

   
CODE:
$getfoe = mysql_query("SELECT * FROM `blocklist` WHERE `foe` = '$user[username]'");


to

   
CODE:
$getfoe = mysql_query("SELECT * FROM `blocklist` WHERE `username` = '$user[username]'");
Posted on Tuesday 19th August 2008 at 01:51 AM
UrbanTwitch
yeah xD ooppppssss
Posted on Thursday 21st August 2008 at 03:23 PM
saintpaulos
Also shouldn't it be?

[Code]
";
if ($user[username] == $fa[friendname]){
echo "<a href='my_friends.php?page=delete&amp;user=$user[username]'><img src='http://sodadome.com/scp/user_add.png' border='0' title='Remove from friendlist'></a>";
}else{
echo "<a href='friendrequest.php?user=$user[username]'><img src='http://sodadome.com/scp/user_add.png' border='0' title='Add as friend'></a>";
}
if ($user[username] == $en[foe]){
echo "<a href='blocklist.php?page=delete&amp;user=$user[username]'><img src='http://sodadome.com/scp/user_block.png' border='0' title='Unblock user'></a>";
}else{
echo "<a href='blocklist.php?page=block&amp;user=$user[username]'><img src='http://sodadome.com/scp/user_block.png' border='0' title='Block user'></a>";
}
echo "<a href='myfriends.php?page=msgto&amp;user=$user[id]'><img src='http://sodadome.com/scp/email_go.png' border='0' title='Send Message'></a></td></tr></table>";
echo "
[/Code]

I can't seem to get the myfriends.php to work at all. All I get is:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in myfriends.php on line 46

Any help would be great! :)
Posted on Thursday 21st August 2008 at 03:24 PM
saintpaulos
thats not the bbcode then lol
Post A Comment
1 2
Notice:
Remember to post long codes on our pastbin! - (http://rmb.pastebin.com/)
Add Comment
You must be logged in to post a comment.
Good Afternoon Guest
Username: 
Password: 
Remember Username
Links
RMB Arcade
$2.50 Resellers
Free Domains
Free Games
Affiliates