NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page phpBB SEO Virtual Folder Links Fix

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
6 members in live chat ~  


Reply
 
LinkBack Thread Tools
Old 04-08-2011, 08:07 AM THREAD STARTER               #1 (permalink)
 
BillyConnite's Avatar
Join Date: Jul 2005
Location: Coffs H, Australia
Posts: 3,456
BillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond reputeBillyConnite has a reputation beyond repute
 


Wildlife Parkinson's Disease Parkinson's Disease

Smile phpBB SEO Virtual Folder Links Fix


Hey all,

For those of you who use phpBB and the common seo mod (phpbb-seo.com), you may have noticed that many links in non-prosilver and non-subsilver templates are broken due to the virtual topic folders.

This mod will save you editing your template files to correct those broken links.

You'll find this particularly useful if you have multiple styles running off the same forum, or have a styles demo forum running. Given i have 130 styles added to my forum host, editing the styles 1 by 1 was simply not an option.

Here's a fix i just coded up, it's easy to do and only takes a few minutes.

WARNING: This has been tested in a phpBB root install(/), and sub-folder(/subfolder/) install only, NOT a sub-subfolder (/subfolder/subfolder/) install. Good luck!

OPEN:
Code:
includes/template.php
FIND:
Code:
	function assign_vars($vararray)
	{
ADD AFTER:
Code:
	// get config
	global $config;
FIND:
Code:
		foreach ($vararray as $key => $val)
		{
ADD AFTER:
????: NamePros.com http://www.namepros.com/code/710172-phpbb-search-engine-optimization-virtual-folder.html
Code:
		// START: MOD by http://forums.do/
		$linkNames=array('S_LOGIN_ACTION','S_LOGIN_ACTION','S_SEARCHBOX_ACTION'); // Names of uncommon links
			if(substr($key,0,2)=='U_'||in_array($key,$linkNames)) // Check if this is a link
			{
				if(substr($val,0,7)!='http://'&&substr($val,0,3)!='../') // Make sure the link isn't already good
				{
				$instFolderName=$config['script_path']; // Get the install path of phpBB
				// The following is to remove slashes carefully, incase phpBB is installed in a consecutive sub-folder
					if(substr($instFolderName,0,1)=='/')
					{
					$instFolderName=substr($instFolderName,1); // Remove the first slash, if there is one
					}
					if(substr($instFolderName,-1,1)=='/')
					{
					$instFolderName=substr($instFolderName,0,-1); // Remove the last slash, if there is one
					}
				$allowedFolders=array('adm','ucp',$instFolderName); // Define allowed folder; admin panel, user control panel, install folder
				$strURIx=explode("/",$_SERVER['REQUEST_URI']); // Split up the URI to find the first folder
					if(!in_array($strURIx[count($strURIx)-2],$allowedFolders)&&count($strURIx)>2) // Check to see we are in a folder that is not normal
					{
						if(substr($val,0,2)=='./') // Some links begin with ./ and some with just /
						{
						$val='.'.$val; // Adda period to go up one level.
						}
					}
				}
			}
		// END: MOD by http://forums.do/
FIND:
????: NamePros.com http://www.namepros.com/showthread.php?t=710172
Code:
	function assign_var($varname, $varval)
	{
ADD AFTER:
Code:
	// get config
	global $config;
	// START: MOD by http://forums.do/
	$linkNames=array('S_LOGIN_ACTION','S_LOGIN_ACTION','S_SEARCHBOX_ACTION'); // Names of uncommon links
		if(substr($varname,0,2)=='U_'||in_array($varname,$linkNames)) // Check if this is a link
		{
			if(substr($varval,0,7)!='http://'&&substr($varval,0,3)!='../') // Make sure the link isn't already good
			{
			$instFolderName=$config['script_path']; // Get the install path of phpBB
			// The following is to remove slashes carefully, incase phpBB is installed in a consecutive sub-folder
				if(substr($instFolderName,0,1)=='/')
				{
				$instFolderName=substr($instFolderName,1); // Remove the first slash, if there is one
				}
				if(substr($instFolderName,-1,1)=='/')
				{
				$instFolderName=substr($instFolderName,0,-1); // Remove the last slash, if there is one
				}
			$allowedFolders=array('adm','ucp',$instFolderName); // Define allowed folder; admin panel, user control panel, install folder
			$strURIx=explode("/",$_SERVER['REQUEST_URI']); // Split up the URI to find the first folder
				if(!in_array($strURIx[count($strURIx)-2],$allowedFolders)&&count($strURIx)>2) // Check to see we are in a folder that is not normal
				{
					if(substr($varval,0,2)=='./') // Some links begin with ./ and some with just /
					{
					$varval='.'.$varval; // Adda period to go up one level.
					}
				}
			}
		}
	// END: MOD by http://forums.do/
I'll update this as i find any glitches.

Enjoy!

-Rhett
BillyConnite is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Full SEO Services - On-Page and Link Building [Monthly Based] Mr_Kumar Advertising & SEO Services 0 01-20-2009 12:17 AM
Links sale many sites -Nick- For Sale / Advertising Board 0 02-11-2007 06:28 AM
Seo news ashu@webnewtons Search Engines 5 11-09-2006 02:29 AM
Deleted Domain List Site FREE dropscripts For Sale / Advertising Board 12 09-24-2003 07:16 AM

 
All times are GMT -7. The time now is 07:39 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger