# Auto-converting friends' names into links # by annia Source: http://web.archive.org/web/20050223133044/http://cafelog.com/board/viewtopic.php?t=1145 A simple hack of the smiley converter script which makes it work as an auto converter for your friends' names. Just copy and past the codes below into the intended *.php files (you find them all in the b2-include folder). b2vars.php > the friends array.. customize it to your own friends: [Code] $friendstrans = array( 'daynah' => 'girl.daynah.net', 'dodo' => 'www.pure-essence.net', 'sigg3' => 'www.sigg3.net'); [/code] Please note that the last line does not have a comma afterwards. b2vars.php > copy and paste: [code] # generates friends' search & replace arrays foreach($friendstrans as $friend => $url) { $friendssearch[] = $friend; $friend_masked = ''; for ($ii = 0; $ii < strlen($friend); $ii = $ii + 1) { $friend_masked .= substr($friend, $ii, 1); } $b2_friendsreplace[] = "$friend_masked"; } [/code] In b2functions.php copy and paste: [code] function convert_friends($content) { global $friendssearch, $b2_friendsreplace; $content = str_replace($friendssearch, $b2_friendsreplace, $content); return ($content); } [/code] In b2template.functions.php search for the function the_content and simply add the line $content=convert_friends($content); .. it should look like this: [code] function the_content($more_link_text="(more...)",$stripteaser="0",$more_file="") { $content = get_the_content($more_link_text,$stripteaser,$more_file); $content = convert_bbcode($content); $content = convert_gmcode($content); $content = convert_smilies($content); $content=convert_friends($content); $content = convert_chars($content,"html"); echo $content; } [/code] And that's it! Source: http://web.archive.org/web/20050223133044/http://cafelog.com/board/viewtopic.php?t=1145