[BETA] Friends Mod 0.1.0a

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
ctcentralinfo
Registered User
Posts: 191
Joined: Wed Jul 06, 2005 8:33 pm
Contact:

Post by ctcentralinfo »

Are you and hardworking comlpeting the blog mod project together? Figured it would speed things up. BTW great mod.
Image
kapengbarako
Registered User
Posts: 44
Joined: Thu Jun 30, 2005 7:26 am
Contact:

Re: some bug fixes

Post by kapengbarako »

Blitze wrote:
I noticed that to invite existing users, you have to go into their proifle, such as through the Forum's "Memberlist" icon. Then, click on the user's name to view their profile, and then you can add them to your friend list from their profile page.


Thanks alot vaninam. I didn't notice that.
Works great except for some bugs in the v0.1.0a.
database error

DEBUG MODE

SQL Error : 1146 Table 'xxxx_db.PHPBB_USERS' doesn't exist

select * FROM phpbb_friends_pending, PHPBB_USERS WHERE phpbb_friends_pending.to_id = 2 AND phpbb_friends_pending.from_id = 5 AND PHPBB_USERS.user_id = phpbb_friends_pending.from_id

Line : 53
File : snw_add.php


Could not query usernames

DEBUG MODE

SQL Error : 1146 Table 'xxxx_db.PHPBB_USERS' doesn't exist

SELECT * FROM PHPBB_USERS WHERE user_id = '2'

Line : 279
File : friends.php

Could not query usernames

DEBUG MODE

SQL Error : 1146 Table 'xxxx_db.PHPBB_USERS' doesn't exist

SELECT * FROM PHPBB_USERS, phpbb_friends_comments WHERE phpbb_friends_comments.id = '1' AND PHPBB_USERS.user_id = phpbb_friends_comments.from_id

Line : 392
File : friends.php


when you try to approve or add a friend. To fix this replace all occurrences of PHPBB_USERS with USERS_TABLE in friends.php and includes/snw_add.php.

Also, when click on the link to add comment in viewprofile, there is an additional "\" at the end of the link that causes an error "user does not exist". Changing

Code: Select all

		$friends_info = sprintf($lang['Are_friends'], $profiledata['username']) . "&nbsp;&nbsp;<a href=\"friends.php?mode=comment&u=" . $profiledata['user_id'] . '\">' . $lang['Add_comment'] . '</a><br>';
to

Code: Select all

		$friends_info = sprintf($lang['Are_friends'], $profiledata['username']) . "&nbsp;&nbsp;<a href=\"friends.php?mode=comment&u=" . $profiledata['user_id'] . '">' . $lang['Add_comment'] . '</a><br>';
on includes/usercp_viewprofile.php should do the trick.

Thanks



for PHPBB_USERS and USERS_TABLE, please change those entries into lowercase. if your server is running linux or unix, it will surely create an error because the operating system is case-sensitive.
phpBB Network :: Pinoy Sites :: Isulong Web Directory :: Viral Videos

Forums are made to bring people together, not to divide them - kapengbarako
kapengbarako
Registered User
Posts: 44
Joined: Thu Jun 30, 2005 7:26 am
Contact:

Re: Thanks for fix

Post by kapengbarako »

vaninam wrote: Thanks for posting the fix to those errors. If you find anymore, please post, since that is extremely helpful! :D

Does anyone else get the errors I posted above (like 3 posts ago)? If so, have you discovered any fixes? If anyone could help me out, that would be great. Also, when I put a bad email address, I get this error:

Failed sending email :: PHP ::

DEBUG MODE

Line : 234
File : emailer.php

Thanks for your help.

-Vanina


will look after that. but if you're using a local server for testing purposes, you'll surely get that error (and it's just normal). the mod emailer will function properly in a live environment
phpBB Network :: Pinoy Sites :: Isulong Web Directory :: Viral Videos

Forums are made to bring people together, not to divide them - kapengbarako
adiktd
Registered User
Posts: 80
Joined: Tue Apr 12, 2005 2:12 pm
Location: Hampton, GA
Contact:

Post by adiktd »

oops. nevermind. found the answer but I just got this trying to view a profile...

Code: Select all

Fatal error: Cannot redeclare load_bbcode_template() (previously declared in /home/.lantana/adiktd/forums.adiktd.com/includes/bbcode.php:45) in /home/.lantana/adiktd/forums.adiktd.com/includes/bbcode.php on line 43
I'm no pro at any of this really but if I can help I will. :)

my board -> http://www.sofreshforums.com
my site -> http://www.adiktd.com
new biz -> http://www.girladspace.com

get a free blog -> http://www.dopetype.com
jasonago
Registered User
Posts: 75
Joined: Fri Aug 05, 2005 6:47 am

hehe

Post by jasonago »

Adiktd wrote:

Code: Select all

Fatal error: Cannot redeclare load_bbcode_template() (previously declared in /home/.lantana/adiktd/forums.adiktd.com/includes/bbcode.php:45) in /home/.lantana/adiktd/forums.adiktd.com/includes/bbcode.php on line 43


what specific page are you viewing? Is there any other mod installed or have you modified how the includes in some of the page are placed?

Anyways, I have included the bbcode.php in some of the pages where friends mod works because this is needed for converting bbcoded messages (comments and invites) in the database. This part is an original implementation not found in the original SNW mod. I haven't yet tested the implementation rigorously although it hasn't cause any errors...until now that you have report it...

I'll check on to that...
jasonago
Registered User
Posts: 75
Joined: Fri Aug 05, 2005 6:47 am

Post by jasonago »

ctcentralinfo wrote: Are you and hardworking comlpeting the blog mod project together? Figured it would speed things up. BTW great mod.


No, I'm not working with them...

But as soon as I got time, I'll create an integration patch for the blogmod and friends mod...

My plans are:
-Friends block
-comments block
-Friends page in every blog (just like of the blogmod)

But we will not spoil so much on integrating every bit of code. I suggest that adding, inviting, putting comments, and others will still be linked to the friends page where in the cpanel for every user resides (to make it more centralized).
adiktd
Registered User
Posts: 80
Joined: Tue Apr 12, 2005 2:12 pm
Location: Hampton, GA
Contact:

Re: hehe

Post by adiktd »

jasonago wrote:
Adiktd wrote:

Code: Select all

Fatal error: Cannot redeclare load_bbcode_template() (previously declared in /home/.lantana/adiktd/forums.adiktd.com/includes/bbcode.php:45) in /home/.lantana/adiktd/forums.adiktd.com/includes/bbcode.php on line 43


what specific page are you viewing? Is there any other mod installed or have you modified how the includes in some of the page are placed?

Anyways, I have included the bbcode.php in some of the pages where friends mod works because this is needed for converting bbcoded messages (comments and invites) in the database. This part is an original implementation not found in the original SNW mod. I haven't yet tested the implementation rigorously although it hasn't cause any errors...until now that you have report it...

I'll check on to that...


it's in view profile. yea, I have mods but I don't know why this is happening though. I took out

Code: Select all

include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
and it went away but I guess now the bbcode won't work on this page. I think I'll try a fresh copy of the viewprofile file and start with the firends hack and add my other mods back in.
I'm no pro at any of this really but if I can help I will. :)

my board -> http://www.sofreshforums.com
my site -> http://www.adiktd.com
new biz -> http://www.girladspace.com

get a free blog -> http://www.dopetype.com
jasonago
Registered User
Posts: 75
Joined: Fri Aug 05, 2005 6:47 am

Re: hehe

Post by jasonago »

adiktd wrote: it's in view profile. yea, I have mods but I don't know why this is happening though. I took out

Code: Select all

include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
and it went away but I guess now the bbcode won't work on this page. I think I'll try a fresh copy of the viewprofile file and start with the firends hack and add my other mods back in.


Yes, the comments will not be bbcoded...

On my analysis, the other mods that you have are the ones who are in conflict with the friends mod. the bbcode.php is freely included without any hassle because it was not included in the common.php, and even with the page_header.php and page_tail.php - the two obligate includes in phpBB.

Just check for double occurence of bbcode.php in the usercp_viewprofile.php.
adiktd
Registered User
Posts: 80
Joined: Tue Apr 12, 2005 2:12 pm
Location: Hampton, GA
Contact:

Post by adiktd »

I found the prob. the xdata mod had the sam eline it way down in the file so I just deleted that one and put the one back for the friends mod. having it in there once should cover the xdata needs for it too yea? I hope so. :P
I'm no pro at any of this really but if I can help I will. :)

my board -> http://www.sofreshforums.com
my site -> http://www.adiktd.com
new biz -> http://www.girladspace.com

get a free blog -> http://www.dopetype.com
jasonago
Registered User
Posts: 75
Joined: Fri Aug 05, 2005 6:47 am

Post by jasonago »

adiktd wrote: I found the prob. the xdata mod had the same line it way down in the file so I just deleted that one and put the one back for the friends mod. having it in there once should cover the xdata needs for it too yea? I hope so. :P


So it is now solved.

But wait, the xdata mod is like the xuinfo component of the friends mod...

I think the friends mod is enough for adding extra user info. Obne advantage of this is that you can set the fields if it is searchable or not. If it is searchable then you can just click the word from the profiles page and voila! other people in the network with the same profile will appear!!!

But it is your choice :lol:

Thanks for using friends mod...
adiktd
Registered User
Posts: 80
Joined: Tue Apr 12, 2005 2:12 pm
Location: Hampton, GA
Contact:

Post by adiktd »

very true- i transferred the fields i want searchable to the friends mod now :)

I have the gender hack- is there a way to make that searchable on here? I like that the gender hack displays the little gender image on ppls posts so I want to keep it...
I'm no pro at any of this really but if I can help I will. :)

my board -> http://www.sofreshforums.com
my site -> http://www.adiktd.com
new biz -> http://www.girladspace.com

get a free blog -> http://www.dopetype.com
User avatar
vaivai
Registered User
Posts: 18
Joined: Sun Oct 03, 2004 2:49 pm
Location: Italy

Post by vaivai »

Hi everybody

in the install file very a query to do in usercp_viewprofile.php:

if($total_h_friends)
{
$sql = "SELECT *
FROM " . USERS_TABLE . "
WHERE user_id IN ( ";
for( $j=0; $j<$total_h_friends-1; $j++)


Is WHERE user_id IN ( "; correct??? 8O

Thanks for help
jasonago
Registered User
Posts: 75
Joined: Fri Aug 05, 2005 6:47 am

to vaivai

Post by jasonago »

This is an explanation about the question of vaivai in her posting.

First, here's a code in usercp_viewprofile.php

Code: Select all

//Get this guy's friends
$sql = "SELECT * 
	FROM " . FRIENDS_TABLE . " 
	WHERE user_a = " . $profiledata['user_id'] . "
	ORDER BY user_b";
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not query friends information', '', __LINE__, __FILE__, $sql);
}
while( $row = $db->sql_fetchrow($result) )
{
	$h_friends[] = $row;
}


if ( !($total_h_friends = count($h_friends)) )
{
	$total_h_friends=0;
}

if($total_h_friends)
{
	$sql = "SELECT * 
		FROM " . USERS_TABLE . " 
		WHERE user_id IN ( ";
	for( $j=0; $j<$total_h_friends-1; $j++)
	{
		$sql = $sql . $h_friends[$j]['user_b'] . ", ";
	}
	$sql = $sql . $h_friends[$j]['user_b'] . " ) ORDER by user_id";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not query forum h_friends information', '', __LINE__, __FILE__, $sql);
	}

	while( $row = $db->sql_fetchrow($result) )
	{
		$friendsdata[] = $row;
	}
	$db->sql_freeresult($result);
}
This block of code tries to get all the friends of a certain user then fetch all the data of their friends later.

Let's examine the code piece by piece.

The code above tries to get the friends of a certain user. The user is coined as user_a in the FRIENDS_TABLE. The result will be saved in an array called $h_friends
//Get this guy's friends
$sql = "SELECT *
FROM " . FRIENDS_TABLE . "
WHERE user_a = " . $profiledata['user_id'] . "
ORDER BY user_b";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query friends information', '', __LINE__, __FILE__, $sql);
}
while( $row = $db->sql_fetchrow($result) )
{
$h_friends[] = $row;
}



This block counts the number of friends by using count($h_friends)
if ( !($total_h_friends = count($h_friends)) )
{
$total_h_friends=0;
}



The codes in dark red is the starting sql statement. It wasn't finished because in the next statement, the for statement tries to fill in the array in the sql statement by appending the user_b user id inside the IN (" part of the previous sql. When this is finished, the resulting sql is SELECT * FROM phpbb_users WHERE user_id IN (2, 3, 45, 67, assuming the friends includes 2,3,45,67,and 100

So where's the 100? well, the next code finishes the sql template by adding the last friend (if you will examine, the for satatement's argument $j=0; $j<$total_h_friends-1; $j++ was off by one friend)

After the query was executed successfully, the $friendsdata array will contain all their information.
if($total_h_friends)
{
$sql = "SELECT *
FROM " . USERS_TABLE . "
WHERE user_id IN ( ";

for( $j=0; $j<$total_h_friends-1; $j++)
{
$sql = $sql . $h_friends[$j]['user_b'] . ", ";
}
$sql = $sql . $h_friends[$j]['user_b'] . " ) ORDER by user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query forum h_friends information', '', __LINE__, __FILE__, $sql);
}

while( $row = $db->sql_fetchrow($result) )
{
$friendsdata[] = $row;
}
$db->sql_freeresult($result);
}



Actually, there are many codes in the friends mod that is still unoptimized. This blocks of codes are one of them. In the next release of this mod, a major overhaul will be done to organize and optimize critical parts of the script.

As an exhibition, you can change this block of codes with this:

Code: Select all

//Get this guy's friends
$sql = "SELECT * 
	FROM " . FRIENDS_TABLE . " a, " . USERS_TABLE . " b   
	WHERE a.user_a = " . $profiledata['user_id'] . "
	AND b.user_id = a.user_b
	ORDER BY a.user_b";
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not query friends information', '', __LINE__, __FILE__, $sql);
}
while( $row = $db->sql_fetchrow($result) )
{
	$friendsdata[] = $row;
}


if ( !($total_h_friends = count($friendsdata)) )
{
	$total_h_friends=0;
}
And that's it...very optimized...as far as I know...
Last edited by jasonago on Sat Dec 03, 2005 12:24 pm, edited 2 times in total.
User avatar
vaivai
Registered User
Posts: 18
Joined: Sun Oct 03, 2004 2:49 pm
Location: Italy

Re: to vaivai

Post by vaivai »

jasonago wrote: This is an explanation about the question of vaivai in her posting.

First, here's a code in usercp_viewprofile.php

Code: Select all

//Get this guy's friends
$sql = "SELECT * 
	FROM " . FRIENDS_TABLE . " 
	WHERE user_a = " . $profiledata['user_id'] . "
	ORDER BY user_b";
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not query friends information', '', __LINE__, __FILE__, $sql);
}
while( $row = $db->sql_fetchrow($result) )
{
	$h_friends[] = $row;
}


if ( !($total_h_friends = count($h_friends)) )
{
	$total_h_friends=0;
}

if($total_h_friends)
{
	$sql = "SELECT * 
		FROM " . USERS_TABLE . " 
		WHERE user_id IN ( ";
	for( $j=0; $j<$total_h_friends-1; $j++)
	{
		$sql = $sql . $h_friends[$j]['user_b'] . ", ";
	}
	$sql = $sql . $h_friends[$j]['user_b'] . " ) ORDER by user_id";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not query forum h_friends information', '', __LINE__, __FILE__, $sql);
	}

	while( $row = $db->sql_fetchrow($result) )
	{
		$friendsdata[] = $row;
	}
	$db->sql_freeresult($result);
}
This block of code tries to get all the friends of a certain user then fetch all the data of their friends later.

Let's examine the code piece by piece.

Code: Select all

//Get this guy's friends
$sql = "SELECT * 
	FROM " . FRIENDS_TABLE . " 
	WHERE [b]user_a[/b] = " . $profiledata['user_id'] . "
	ORDER BY user_b";
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not query friends information', '', __LINE__, __FILE__, $sql);
}
while( $row = $db->sql_fetchrow($result) )
{
	[b]$h_friends[][/b] = $row;
}
The code above tries to get the friends of a certain user. The user is coined as user_a in the FRIENDS_TABLE. The result will be saved in an array called $h_friends

Code: Select all

if ( !($total_h_friends = [b]count($h_friends)[/b]) )
{
	$total_h_friends=0;
}
This block counts the number of friends by using count($h_friends)

Code: Select all

if($total_h_friends)
{
	[color=darkred]$sql = "SELECT * 
		FROM " . USERS_TABLE . " 
		WHERE user_id IN ( ";[/color]
	for( $j=0; $j<$total_h_friends-1; $j++)
	{
		[b]$sql = $sql . $h_friends[$j]['user_b'] . ", ";[/b]
	}
	[b]$sql = $sql . $h_friends[$j]['user_b'] . " ) ORDER by user_id";[/b]
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not query forum h_friends information', '', __LINE__, __FILE__, $sql);
	}

	while( $row = $db->sql_fetchrow($result) )
	{
		[b]$friendsdata[] = $row;[/b]
	}
	$db->sql_freeresult($result);
}



Thanks for this :wink:

But i have a very strange problem with this mod 8O

I use SNW from 2004. My board have the version of niwotata. Now i update my board with this version.

The problem:
All the old members that have friends in profile can't see the profile of new member. The page not load. Only if an old member delete all friend can see the profile of new member. Guest can see all profile (new and old)

This is a very strange problem 8O

I think this is a problem in the query of usercp_viewprofile.php or how the friends are insert in database??

Any solution???

Thanks!!! :D
jasonago
Registered User
Posts: 75
Joined: Fri Aug 05, 2005 6:47 am

reply again

Post by jasonago »

I can't really visualize it...

But here's my assessment. The database structure hasn't change from SNW to friends mod so it is not a db problem.

Have you uninstalled the SNW first before updating? Maybe we should start from scratch...

Can you give me your site url so that I can see it?
Post Reply

Return to “[2.0.x] MODs in Development”