MyBB Community Forums

Full Version: Ok...default URL?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Can someone tell me how to make a default URL when posting thing? If you don't know what I mean, let me explain.
You know how you when you press the "Insert Hyperlink thingy, there's already a Http://? Well, I'd like to change it to:
http://www.spiritninja.uni.cc/linkout/o....//(Replace URL Here)
Do you think that's possible?
It'd be a LOT better if it only shows:
http://
But the link really goes to:
http://www.spiritninja.uni.cc/linkout/o.php?out=(The Link Here)
Is that possible? Thanks!
Open jscripts/editor.js and find following line:
url = prompt(this.options.lang.enter_url, "http://");

Replace http:// part with your wish.
But still people could replace that, plus it won't replace the existing links ... might be best to parse posts and set the url in settings, u wanna plugin ?

<?php
/**
	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
**/
function outbound_redirect_info()
{
	global $db ;
	
	return array
	(
		"name"	=> 		"Outbound Link Redirection",
		"description" => 	"A plugin that redirects outbound links through another location on your site",
		"website" => 		"http://spacesocket.com",
		"author" => 		"Joe Watkins",
		"authorsite" => 	"http://interviolet.com",
		"version" => 		"0.1",
		"guid" =>		"66090841a16e5e6f97559735780fe016"
	);

}
function outbound_redirect_activate()
{
	global $db;
	
	if( $db->insert_query( TABLE_PREFIX . "settinggroups", array( 
		'name' => 'oredirect',
		'title' => 'Outbound Redirections',
		'description' => 'Setup outbound redirections',
		'disporder' => 99,
		'isdefault' => 'no'
	) ) )
	{
		if( ( $gid = $db->insert_id( ) ) )
		{
			$settings = array
			(
				array
				(
					'gid' => $gid,
					'name' => 'orenable',
					'title' => 'Enable Outbound Link Redirection',
					'description' => 'Set to no to disable redirections',
					'optionscode' => 'yesno',
					'value' => 'yes',
					'disporder' => 1
				),
				array
				(
					'gid' => $gid,
					'name' => 'orscript',
					'title' => 'Redirection Script',
					'description' => 'The url of your redirection script',
					'optionscode' => 'text',
					'value' => "",
					'disporder' => 2
				)
			);
			foreach( $settings as $setting )
			{
				$db->insert_query( TABLE_PREFIX."settings", $setting );
			}
		}
	}

}
function outbound_redirect_deactivate()
{
	global $db ;

	if( ( $result = $db->query( "SELECT gid FROM " . TABLE_PREFIX . "settinggroups WHERE name = 'oredirect' LIMIT 1" ) ) )
	{
		if( ( $gid = $db->fetch_field( $result, 'gid' ) ) )
		{
			$db->query( "DELETE FROM " . TABLE_PREFIX . "settinggroups WHERE gid = '{$gid}' LIMIT 1" );
			$db->query( "DELETE FROM " . TABLE_PREFIX . "settings WHERE gid = '{$gid}'" );
		}
	}	
}
function outbound_redirect( $message )
{
	global $mybb ;
	
	if( $mybb->settings['orenable'] == 'yes' )
	{
		if( preg_match_all( "~href=\"((ftp|https?)://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)\"~", $message, $links ) )
		{
			for( $link = 0; $link < count( $links[1] ); $link++ )
			{
				$message = str_replace( "href=\"{$links[1][$link]}\"", sprintf
				( 
					"href=\"%s%s\"", $mybb->settings['orscript'], urlencode( $links[1][$link] )
				), $message );
			}
		}
	}
	
	return $message ;
}
$plugins->add_hook( "parse_message", "outbound_redirect" );
?>

Save as ./inc/plugins/outbound_redirect.php
Goto mybb plugin manager and enable
Goto mybb settings and setup

Bear in mind that links from signatures will also be rewritten to the new location ...