[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.
Post Reply
jasonago
Registered User
Posts: 75
Joined: Fri Aug 05, 2005 6:47 am

thanks guys

Post by jasonago »

to thomherfs, ctcentralinfo, and shirleycaat thanks to all your suggestions...

Now I know what coppermine is! A wonderful image management with so much features that it becomes a bloatware...

Smartors album mod is great but my plans is that not only an image gallery but file gallery...You can upload even flash, powerpoint, or anything depending on what files the admin will allow...

I'll code that in a very simple way as possible so as not to complicate things...

But the only thing that bothers me now is that I want to create a php script that will scan the file for viruses...Sounds wonderful right? But it is actually easy to do...but this plan is far away from the real plan for fmod 0.2.0... maybe for 0.2.1 I guess...

By the way, fmod 0.2.0 will be released not later than first quarter of 2006. Sorry if it takes so long because I only have limited time. Most of my time is allotted for school and hospital...And I am recoding all parts of fmod...

Thanks thanks thanks guys!!!!
Kirsty1
Registered User
Posts: 237
Joined: Tue Aug 30, 2005 9:50 pm
Location: New Zealand
Contact:

Post by Kirsty1 »

This looks great, i'm going to keep watching and give it a go :)
jasonago
Registered User
Posts: 75
Joined: Fri Aug 05, 2005 6:47 am

Help me in testing my algorithms

Post by jasonago »

Hey guys, I need some help from all of you to try testing some algorithms. The following algorithms is used in finding friend connections. The current algorithm used in fmod 0.1.0a is the find_friend_connections() which is an implementation of Recursive Iterative deepening depth first search algorithm (recursive ITDDFS). Now I have come up with the other 3 algorithms namely breadth_first_search(), non-recursive ITDDFS, and a database union search.

You can learn more about these at http://en.wikipedia.org/wiki/Tree_traversal

In my own benchmark, the breadth_first_search and the non-recursive ITTDFS are both fast. The non-recursive ITDDFS uses a new implementation of Depth first search which is actually a depth limiting one (and is not recursive). The database union search uses sql query to get the connection and its performance is a little slower. The current implementation - the recursive ITDDFS is 3 times slower compared to the Breadth First Search algorithm.

Take note also that if you use simulated array of friends using php array variable, the breadth first search seems to be slow compared to the ITTDFS. But on real database implementation, this is not the case.

Just post a reply here in this forum and state your benchmark test with deatails such as how many friends in the database you have and if possible you website where fmod is installed.

Also if you like to program another algorithm, feel free to do so. The only requirement is that the function shopuld be in the format function_name($uid1, $uid2) and function_name will return comma delimited list of friend. Ex. 1,3,45,23 (1&3, 3&45, 45&23 are friends)

Now to implement one of this codes, just paste the selected code in front of usercp_viewprofile.php. Then FIND $friend_conn = find_friend_connections($userdata['user_id'],$profiledata['user_id']); and replace it with the selected algorithm. Ex. $friend_conn = breadth_first_search($userdata['user_id'],$profiledata['user_id']);

Code: Select all

function breadth_first_search($bfs_uid1, $bfs_uid2)
{
	global $db;

	$queue = array();
	$u1_friends = array();
	$scanned = array();
	$node = $bfs_uid1;

	$sql = "SELECT *
		FROM " . FRIENDS_TABLE . "
		WHERE user_a = " . $bfs_uid1;
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not query friends information', '', __LINE__, __FILE__, $sql);
	}
	while ( $row = $db->sql_fetchrow($result) )
	{
                $u1_friends[] = $row['user_b'];
                $queue[] = $node . ',' . $row['user_b'];
	}
	$db->sql_freeresult($result);

	if (in_array($bfs_uid2, $u1_friends)){
		return $node . ',' . $bfs_uid2;
		break;
	}

	$scanned[] = $bfs_uid1;

	while(!empty($queue))
	{
		$node = array_shift($queue); // get the first element in array (FIFO)
		$node2 = explode(',', $node); // the string is in format id1,id2,...idx we need idx so split first
		if (count($node2)>10)
		{
			return '';
		}
		$last_id = array_pop($node2); // then pop the last...
		
		if ($last_id==$bfs_uid2)
		{
			return $node;
		}
		
		$last_id_friends = array();
		
		$sql = "SELECT *
			FROM " . FRIENDS_TABLE . "
			WHERE user_a = " . $last_id;
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Could not query friends information', '', __LINE__, __FILE__, $sql);
		}
		while ( $row = $db->sql_fetchrow($result) )
		{
                	$last_id_friends[] = $row['user_b'];
                	if (!in_array($row['user_b'], $scanned))
                	{
                		$queue[] = $node . ',' . $row['user_b'];
			}
		}
		$db->sql_freeresult($result);

		if (in_array($bfs_uid2, $last_id_friends)){
			return $node . ',' . $bfs_uid2;
			break;
		}
		
		$scanned[] = $last_id;

	}
}

Code: Select all

function database_union_search($uid1, $uid2)
{
	global $db;
	for ($x=0; $x<10 ; $x++)
	{
		$left_join='';
		$selects="CONCAT_WS(',' ,f0.user_a ";

		for ($y=1; $y<=$x ; $y++)
		{
			$left_join .= "LEFT JOIN " . FRIENDS_TABLE . " f$y ON f" . strval($y-1) . ".user_b = f$y.user_a ";
			$selects .= ", f$y.user_a " ;

		}

		$selects .= ", f$x.user_b )";
		// Now, $selects will be like CONCAT_WS(',' , f0.user_, f1.user_a, f2.user_a, ... , fx.user_b)

		$sql = "SELECT $selects
			FROM ( " . FRIENDS_TABLE . " f0
			$left_join)
			WHERE f0.user_a = $uid1
			AND f$x.user_b = $uid2";

		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Could not query friends information', '', __LINE__, __FILE__, $sql);
		}
		while ( $row = $db->sql_fetchrow($result) )
		{
			return $row[$selects];
		}
		$db->sql_freeresult($result);
	}

}

Code: Select all

// The following two functions is needed to work together...

function nonrecursive_ITDDFS($uid1, $uid2){
         for ($x=1 ; $x<=10 ; $x++){
             $sr = $depth_limited_search($uid1, $uid2, $x);
             if ($sr!='') { return $sr; }
         }
}

function depth_limited_search($dfs_uid1, $dfs_uid2, $depth)
{
	global $db;

	$queue = array();
	$u1_friends = array();
	$scanned = array();
	$node = $dfs_uid1;

	$sql = "SELECT *
		FROM " . FRIENDS_TABLE . "
		WHERE user_a = " . $dfs_uid1;
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not query friends information', '', __LINE__, __FILE__, $sql);
	}
	while ( $row = $db->sql_fetchrow($result) )
	{
                $u1_friends[] = $row['user_b'];
                $queue[] = $node . ',' . $row['user_b'];
	}
	$db->sql_freeresult($result);

	if (in_array($dfs_uid2, $u1_friends)){
		return $node . ',' . $dfs_uid2;
		break;
	}

	$scanned[] = $dfs_uid1;

	while(!empty($queue))
	{
		$node = array_pop($queue); // get the last element in array (LIFO)
		$node2 = explode(',', $node); // the string is in format id1,id2,...idx we need idx so split first
		if (count($node2)>$depth)
		{
			return '';
		}
		$last_id = array_pop($node2); // then pop the last...

		if ($last_id==$dfs_uid2)
		{
			return $node;
		}

		$last_id_friends = array();

		$sql = "SELECT *
			FROM " . FRIENDS_TABLE . "
			WHERE user_a = " . $last_id;
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Could not query friends information', '', __LINE__, __FILE__, $sql);
		}
		while ( $row = $db->sql_fetchrow($result) )
		{
                	$last_id_friends[] = $row['user_b'];
                	if (!in_array($row['user_b'], $scanned))
                	{
                		$queue[] = $node . ',' . $row['user_b'];
			}
		}
		$db->sql_freeresult($result);

		if (in_array($dfs_uid2, $last_id_friends)){
			return $node . ',' . $dfs_uid2;
			break;
		}

		$scanned[] = $last_id;
	}
}
killa99
Registered User
Posts: 63
Joined: Wed Mar 23, 2005 1:26 am

Post by killa99 »

Is there a link to the new 2.0 friends mod to download?
jasonago
Registered User
Posts: 75
Joined: Fri Aug 05, 2005 6:47 am

reply

Post by jasonago »

Friends Mod 2 is still under development...
killa99
Registered User
Posts: 63
Joined: Wed Mar 23, 2005 1:26 am

Post by killa99 »

Ok...Well, I can't wait till its done but I say you make the friends mod be intergrated with Smartors album.
jasonago
Registered User
Posts: 75
Joined: Fri Aug 05, 2005 6:47 am

reply

Post by jasonago »

I know how beautiful smartor's album mod is but it can only manage pictures. The gallery component of my fmod 0.2 will allow users to share even documents and other files depending on what the admin will allow.
killa99
Registered User
Posts: 63
Joined: Wed Mar 23, 2005 1:26 am

Post by killa99 »

That might be nice. I realy don't need that feature but hey it sounds cool. If i know any php i'd help out!
jbrown
Registered User
Posts: 4
Joined: Sun Jan 15, 2006 9:05 pm

Friends MOD is very nice but NEED help..

Post by jbrown »

After EasyMOD seemed to shat all over itself a few times I finally got this installed.. Came out very nice! Thank you phpBB, EasyMOD and the Creator of Friends!! I have one problem though.. When I try to delete a friend from my friends list I encounter this error:

Warning: main(./includes/snw_delete.php): failed to open stream: No such file or directory in /var/www/html/phpBB2/friends.php on line 196

Warning: main(): Failed opening './includes/snw_delete.php' for inclusion (include_path='.:/usr/lib/php/:/usr/share/pear/') in /var/www/html/phpBB2/friends.php on line 196

It does not delete from the list.. ANy help would be greatly appreciated.

Thank
jbrown
Registered User
Posts: 4
Joined: Sun Jan 15, 2006 9:05 pm

Can someone help me with COMMENTS

Post by jbrown »

I have friends installed and is working fine but when you go to a profile of a user who has me as a friend, when I click on "Add Comment" I get this error:

General Error

No Such User

Any suggestions?

Thanks
Blitze
Registered User
Posts: 414
Joined: Tue Nov 29, 2005 5:06 pm

Post by Blitze »

It's cool what you're doing jasonago and I can't wait for friends mod 2.0.

If I may make a suggestion though, if at all it's not yet been implemented. Would you please add some kind of tracking system, maybe by cookies, so that when new non-member friends are invited and the email link takes them to the registration page, and should they decide to visit the site first before deciding to register, they will still be added as a friend of the member that invited them?

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

answers to questions...

Post by jasonago »

jbrown wrote: After EasyMOD seemed to shat all over itself a few times I finally got this installed.. Came out very nice! Thank you phpBB, EasyMOD and the Creator of Friends!! I have one problem though.. When I try to delete a friend from my friends list I encounter this error:

Warning: main(./includes/snw_delete.php): failed to open stream: No such file or directory in /var/www/html/phpBB2/friends.php on line 196

Warning: main(): Failed opening './includes/snw_delete.php' for inclusion (include_path='.:/usr/lib/php/:/usr/share/pear/') in /var/www/html/phpBB2/friends.php on line 196

This is rare...maybe while installing thru Easymod, the easymod failed to copy snw_delete.php into the includes folder. You can check this manually or re-install it again. As far as I know and tested, the fmod is compliant to easymod. But as always we have different systems and setups in our sites and that some problems like this can't be avoided...
jbrown wrote: I have friends installed and is working fine but when you go to a profile of a user who has me as a friend, when I click on "Add Comment" I get this error:

General Error

No Such User

um, are you sure it is the friends mod 0.1.0a that you have installed? When this error happens, are you logged in?

Blitze wrote: If I may make a suggestion though, if at all it's not yet been implemented. Would you please add some kind of tracking system, maybe by cookies, so that when new non-member friends are invited and the email link takes them to the registration page, and should they decide to visit the site first before deciding to register, they will still be added as a friend of the member that invited them?

So you are referring to the invite system of fmod...well my plans for the fmod 0.2 goes like this. First when you invite thru email, the email ads that you sent will be saved in a database queue. Then when the user registers and uses the email that is on queue, automatically they will have pending friends for approval. BUT if he use the link provided in the email invite, the email owner and the one who invite will automatically be friends. But these are just plans. As you can see, the two mechanism explained above makes the invite system to ideal and to ambigous. It will also spoil the simplicity of fmod 0.2 codes. So these plans are just plans...they may change depending on the suggestions that I will receive.
jasonago
Registered User
Posts: 75
Joined: Fri Aug 05, 2005 6:47 am

Youtube

Post by jasonago »

hehe, I was browsing youtube.com and it was wonderful...
Maybe I'll put some workaround in fmod to enable video posting...
User avatar
ManMan
Registered User
Posts: 19
Joined: Wed Nov 16, 2005 11:13 pm

Post by ManMan »

have friends installed and is working fine but when you go to a profile of a user who has me as a friend, when I click on "Add Comment" I get this error:

General Error

No Such User

Any suggestions?


Is it this?
#Notes1:
# snw_install.txt( FriendsMOD 0.1.0a ) have BUGs.
#
####
#1:COPY FILE (LINE_about_ 265)
# ADD.., 1files aren't contained.unnecessary
#
copy includes/snw_delete.php to includes/snw_invite.php
#
#2:1 backslashes are unnecessary.
# (snw_install.txt:The part of include/usercp_viewprofile.php)
#
#--LINE 930---------------------
$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
$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>';
####
#Notes2:
# When you try to approve or add a friend,
Quote:
database error
DEBUG MODE
SQL Error : 1146 **** PHPBB_USERS ****

You try to change PHPBB_USERS to USERS_TABLE.
include/snw_add.php:. 4 places.
friend.php:. 3 places

http://www.blogpoint.com/community/viewtopic.php?t=53
tempered007
Registered User
Posts: 218
Joined: Sun Jun 27, 2004 3:21 am

Post by tempered007 »

this is great!! thank you so much. Eat your heart out Yahoo360!
Post Reply

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