Jump to the post that solved this thread.
Thread Rating:
  • 3 Vote(s) - 3.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solved: 11 Years, 1 Month, 2 Weeks ago PHP help
#1
Solved: 11 Years, 1 Month, 2 Weeks ago
How to make this work sorry have like 0 experience with PHP

function nofollowlink_changelink($message){

		$search = '<a';
		$replace = '<a rel="nofollow"';
	 $message = str_replace($search  , $replace  , $message);
	 return $message;
		}
		function nofollowlink_changelink_internal($message){

		$search = '<a rel="nofollow" href="http://letsforum.com';
		$replace = '<a href="http://letsforum.com';
	 $message = str_replace($search  , $replace  , $message);
	 return $message;
		}
#2
Solved: 11 Years, 1 Month, 2 Weeks ago
Both are correct php functions? Or did your question was to integrate it in MyBB ?
#3
Solved: 11 Years, 1 Month, 2 Weeks ago
I want to create a plugin that will add nofollow to all the links except letsforum.com

If url is mybb>url then do nothing else add nofollow

Please anybody help me to create a plugin that will add nofollow to all the outgoing links but not internal
#4
Solved: 11 Years, 1 Month, 2 Weeks ago
(2013-12-04, 01:13 AM)marcus123 Wrote: Please anybody help me to create a plugin that will add nofollow to all the outgoing links but not internal

For example, this is a basic plugin to add 'no follow' in posts for all links (except a certain website):
<?php
// access denied
if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.");
}

// add hook
$plugins->add_hook("postbit", "nofollowlink_postbit");

// _info
function nofollowlink_info()
{
	return array(
		"name"			=> "No follow link",
		"description"	=> "Add 'no follow' to all extern links in posts.",
		"website"		=> "http://mybb.com",
		"author"		=> "Flavius Popa",
		"authorsite"	=> "http://community.mybb.com/user-39767.html",
		"version"		=> "0.1",
		"guid" 			=> "",
		"compatibility" => "16*"
	);
}

// _postbit
function nofollowlink_postbit(&$post)
{
	// web address (without 'http')
	$my_site = "www.mysite.com";
	
	// add 'no follow' for all links from posts (except '$my_site')
	$search_1 = '<a href="http://';
	$replace_1 = '<a rel="nofollow" href="http://';
	$post['message'] = str_replace($search_1, $replace_1, $post['message']);
	
	// remove 'no follow' for '$my_site'
	$search_2 = '<a rel="nofollow" href="http://'.$my_site.'';
	$replace_2 = '<a href="http://'.$my_site.'';
	$post['message'] = str_replace($search_2, $replace_2, $post['message']);
}
?>

Copy this code in a blank file, adjust value of '$my_site' and save it in 'inc/plugins/' folder with 'nofollowlink.php' name.
Go in AdminCP and activate it.
Why is MyBB FREE? Because "Free never tasted so good"!
And what we (the users) can do is [...]
#5
Solved: 11 Years, 1 Month, 2 Weeks ago
@Flavius Popa I love you man you have just saved the day thanks bro I very appreciate this and not just me many will find your post useful
#6
Solved: 11 Years, 1 Month, 2 Weeks ago
I'm glad to help you.
Btw... to use '$my_site' with default forum web address, replace:
	// web address (without 'http')
	$my_site = "www.mysite.com";
with:
	global $mybb;
	// default board address (without 'http')
	$my_site = $mybb->settings['bburl'];
	$search = '#^https?://#';
	$my_site = preg_replace($search, '', $my_site);  

In this way, is not need to specify a certain web address.
Why is MyBB FREE? Because "Free never tasted so good"!
And what we (the users) can do is [...]
#7
Solved: 11 Years, 1 Month, 2 Weeks ago
Now its perfect
Jump to the post that solved this thread.


Forum Jump:


Users browsing this thread: 1 Guest(s)