[RC1] Prime Links - Classify Locals & Target Externals

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!
Get Involved
Locked
User avatar
IPB_Refugee
Registered User
Posts: 1290
Joined: Fri Jul 07, 2006 2:25 pm
Location: Austria
Name: Wolfgang Weber

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by IPB_Refugee »

Thanks a lot for fulfilling my request, Ken! Everything seems to work perfectly. :)

Regards
Wolfgang
User avatar
primehalo
Former Team Member
Posts: 2910
Joined: Fri May 06, 2005 5:58 pm
Location: Redding, CA
Contact:

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by primehalo »

updown wrote:Thanks Prime - sounds great as usual!

I just came up with the idea of a possible extra-feature with your mod, that would be a solution for the much wanted "URL-FILTERING" or "URL-BLOCKING"!

Some guys came up with the idea doing this with censorship, but that's not possible:
http://www.phpbb.com/community/viewtopi ... 5#p5546085
http://www.phpbb.com/community/viewtopi ... 5#p5526045

If your mod can handle special domains, wouldn't it then be also possible to block some domains (or better: specific URLs) completely?
Okay, done.
Ken F. Innes IV
My Extensions | My MODs | My Topics | My Site: Absolute Anime
Experience the wonder of Japanese Animation!
updown
Registered User
Posts: 542
Joined: Sat Jan 05, 2008 6:53 am

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by updown »

Genious, Thanks!!!!!!!!!!!!!!!! :D

Works wonderfully! 8-)

If you manage to make all this configurable in ACP, I will keep telling everybody that you're the best modder out there :mrgreen:
User avatar
IPB_Refugee
Registered User
Posts: 1290
Joined: Fri Jul 07, 2006 2:25 pm
Location: Austria
Name: Wolfgang Weber

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by IPB_Refugee »

updown wrote:If you manage to make all this configurable in ACP,
Not a very good idea. primehalo's way of managing links is faster.
updown wrote:I will keep telling everybody that you're the best modder out there :mrgreen:
That's probably true. (You could consider a Paypal donation to his email account.) ;)

Regards
Wolfgang
updown
Registered User
Posts: 542
Joined: Sat Jan 05, 2008 6:53 am

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by updown »

IPB_Refugee wrote:
updown wrote:If you manage to make all this configurable in ACP,
Not a very good idea. primehalo's way of managing links is faster.
Good point, but putting most of the variables in the config-table wouldn't be much slower.

For managing the domain-exclusions (especially for domain-filtering), probably an extra table would be necessary. Since I can't exactly estimate how much extra-time a cached db-query for building an array will cost, I'll leave this evaluation to primehalo.
stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by stokerpiller »

Very nice job with the url filtering Prime.
Thanks 8-)
I am done with phpBB
User avatar
spacefish
Registered User
Posts: 173
Joined: Mon Oct 09, 2006 8:48 am

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by spacefish »

Prime, we're still using v1.0.4 of your mod (yet to update) and got a parse error earlier when someone accidently posted an incorrect external url. They posted a url in the format of: http://subdomain.domain.tld:file.ext
So they posted a : instead of a /

Code: Select all

[phpBB Debug] PHP Notice: in file /includes/prime_links.php on line 82: parse_url(http://subdomain.domain.tld:file.ext) [function.parse-url]: Unable to parse URL
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3542: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2965)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3544: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2965)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3545: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2965)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3546: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2965)
The code from around line 82 is:

Code: Select all

* Removes subdomains from a URL. If no subdomains are provided
		* as an input parameter, all subdomains will be removed.
		*/
		function remove_subdomains($url, $remove_subdomains = true)
		{
			$stripped_url = $url;
			if ($remove_subdomains !== false)
			{
				$url_parts = parse_url($url);
				if ($remove_subdomains && is_string($remove_subdomains))
				{
					str_replace(';', '|', $remove_subdomains);
					str_replace('.', '\\.', $remove_subdomains);
					$stripped_url = preg_replace('#^(http|https)://(?:' . $remove_subdomains . '\.)([^/]+)#i', '$1://$2', $url);
				}
				else if (!empty($url_parts['host']) && substr($url_parts['host'], -9) == 'localhost') // Domain could have a port number, but it's too rare a case with localhost
				{
					$stripped_url = preg_replace('#^(http|https)://[^/]+\.localhost#i', '$1://localhost', $url);
				}
				else
				{
					$stripped_url = preg_replace('#^(http|https)://[^/]+\.([a-z0-9-]+\.(?:aero|biz|com|coop|info|jobs|museum|name|net|org|pro|travel|gov|edu|mil|int))#i', '$1://$2', $url);
					if ($stripped_url == $url)
					{
						$stripped_url = preg_replace('#^(http|https)://[^/]+\.([a-z0-9-]+(?:\.[a-z]{2})?\.(?:ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bl|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mf|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw))#i', '$1://$2', $url);
					}
				}
			}
			return($stripped_url);
		}
They realised their mistake (and it's affect) and corrected it, and everything is good again. I know the chances of something like this happening again are slim, but is there a way to avoid it from happening again at all - or are there changes in the latest version of this mod which would take care of this?


Thanks! :)
User avatar
primehalo
Former Team Member
Posts: 2910
Joined: Fri May 06, 2005 5:58 pm
Location: Redding, CA
Contact:

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by primehalo »

Latest version fixes that. I put the @ on front of the parse_url() function so no error message will be displayed if it fails.
Ken F. Innes IV
My Extensions | My MODs | My Topics | My Site: Absolute Anime
Experience the wonder of Japanese Animation!
User avatar
spacefish
Registered User
Posts: 173
Joined: Mon Oct 09, 2006 8:48 am

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by spacefish »

Terrific - thanks Prime. :)
User avatar
3Di
Former Team Member
Posts: 16088
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano 🇮🇹 Frankfurt 🇩🇪
Name: Marco
Contact:

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by 3Di »

primehalo wrote:Latest version fixes that. I put the @ on front of the parse_url() function so no error message will be displayed if it fails.
Sometimes it is a simple work-around though, I can say.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
spacefish
Registered User
Posts: 173
Joined: Mon Oct 09, 2006 8:48 am

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by spacefish »

Prime, we direct all external links through anonym.to but we have 1 external domain we wish to be treated as an internal link ... but it's https. It works with http but for some reason anonym.to gets prefixed to the https variant.
User avatar
primehalo
Former Team Member
Posts: 2910
Joined: Fri May 06, 2005 5:58 pm
Location: Redding, CA
Contact:

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by primehalo »

Can you show me what your options section looks like?
Ken F. Innes IV
My Extensions | My MODs | My Topics | My Site: Absolute Anime
Experience the wonder of Japanese Animation!
User avatar
spacefish
Registered User
Posts: 173
Joined: Mon Oct 09, 2006 8:48 am

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by spacefish »

Sure:

Code: Select all

	// Options
	define('PRIME_LINKS_ENABLE', true);			// Enable this MOD?
	define('REMOVE_SUBDOMAINS', true);			// Specify subdomains to be removed before checking the link, separated by semicolons (setting TRUE will remove all subdomains)
	define('USE_TARGET_ATTRIBUTE', false);		// The attribute "target" is not valid for STRICT doctypes.
	define('EXTERNAL_LINK_PREFIX', 'http://anonym.to?');	// Example: 'http://anonym.to?'
	define('INTERNAL_LINK_DOMAINS', 'https://tipit.to');	// List of domains to be considered local, separated by semicolons. Example: 'http://www.alternate-domain.com/'
	define('FORBIDDEN_DOMAINS', '');			// List of domains for which links should be removed, separated by semicolons. Example: 'http://www.porn.com/'
	define('FORBIDDEN_NEW_URL', '#');			// URL to insert in place of any removed links. Example: 'http://www.google.com/' or '#top'
Those are the only changes I've made.
User avatar
primehalo
Former Team Member
Posts: 2910
Joined: Fri May 06, 2005 5:58 pm
Location: Redding, CA
Contact:

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by primehalo »

Try changing 'https://tipit.to' to 'http://tipit.to', as I think my script changes https to http when I parse links to help with comparisons (or try removing the https://, as I think that my script will automatically add the http:// if one isn't detected.
Ken F. Innes IV
My Extensions | My MODs | My Topics | My Site: Absolute Anime
Experience the wonder of Japanese Animation!
User avatar
spacefish
Registered User
Posts: 173
Joined: Mon Oct 09, 2006 8:48 am

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by spacefish »

Changing https to http worked - thanks again. ;)
Locked

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