Link shortener in PHPBB?

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
User avatar
DockPro
Registered User
Posts: 5
Joined: Sun Mar 25, 2018 10:59 pm

Link shortener in PHPBB?

Post by DockPro » Thu Jun 07, 2018 6:57 pm

Hello, I'm implementing a shortening of links to my forum, I've already installed it, but I want the links to be automatically shortened, for this the creator has provided a code, but I do not know exactly where to place it, they could help me. 8-)

- To programmatically shorten URLs with PHP use the following code:

Code: Select all

    $shortenedurl = file_get_contents('http://yourdomain.com/shorten.php?longurl=' . urlencode('http://' . $_SERVER['HTTP_HOST']  . '/' . $_SERVER['REQUEST_URI']));

Souce: https://github.com/briancray/PHP-URL-Shortener

User avatar
AmigoJack
Registered User
Posts: 5361
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Link shortener in PHPBB?

Post by AmigoJack » Mon Jun 11, 2018 7:33 am

Don't do that - you hand over every URI to a third party, which can easily log everything everyone links. And on top of that when the service dies you're sitting there with dead links.

As for your question: you'd have to modify multiple files and adapt that example - different things (posts, forum descriptions, signatures, PMs...) are saved at different places.
The worst thing about censorship is ███████████

User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 2801
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.
Contact:

Re: Link shortener in PHPBB?

Post by thecoalman » Mon Jun 11, 2018 11:41 am

AmigoJack wrote:
Mon Jun 11, 2018 7:33 am
Don't do that - you hand over every URI to a third party, which can easily log everything everyone links. And on top of that when the service dies you're sitting there with dead links.
This is a local script and the redirection is performed locally, see the link.

@OP Similar to AmigoJacks's warning one thing to keep in mind is you need to maintain this forever.

If I was going to implement something like this I'd just put it at the bottom of viewtopic.php, viewforum.php and perhaps downloads/file.php

Use validated phpBB variables, if in viewtopic.php this should work.

Code: Select all

$shortenedurl = file_get_contents('http://yourdomain.com/shorten.php?longurl=' . urlencode('http://yourdomian.com/viewtopic.php?f=' . $forum_id . '&t=' . $topic_id . ($start ? '&start=' . $start : '')));
As far as the security of the third party script I'm no expert but I see it will block based on IP and I would be sure to use that.

User avatar
Lumpy Burgertushie
Registered User
Posts: 65202
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Link shortener in PHPBB?

Post by Lumpy Burgertushie » Mon Jun 11, 2018 1:55 pm

if it was me, just based on those two responses, I would not do it.

besides, why are you wanting to do this? nobody cares how long a link is, they just click on it.
by the way, phpbb already shortens local links in a post.


robert
I am available for custom work on a donation basis. Please send me a PM with your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

OK, so what's the speed of dark?

User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 2801
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.
Contact:

Re: Link shortener in PHPBB?

Post by thecoalman » Tue Jun 12, 2018 2:43 pm

Lumpy Burgertushie wrote:
Mon Jun 11, 2018 1:55 pm

besides, why are you wanting to do this? nobody cares how long a link is, they just click on it.
by the way, phpbb already shortens local links in a post.
phpBB only shortens the displayed link text, this shortens the url itself.

Code: Select all

https://www.phpbb.com/community/viewtopic.php?f=641&t=2474926
Becomes:

Code: Select all

https://www.phpbb.com/xyz123
xyz123 is just a random string and the script will redirect to the correct URL. It's cleaner especially if there is very long URL but overall never found it very useful.

User avatar
Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 24747
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: Link shortener in PHPBB?

Post by Paul » Tue Jun 12, 2018 2:49 pm

It is also a potential security risk as you have no idea where you are going to. And as such it is a favourite function for phishing.
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

User avatar
Toxyy
Registered User
Posts: 564
Joined: Mon Oct 24, 2016 3:22 pm
Contact:

Re: Link shortener in PHPBB?

Post by Toxyy » Thu Jun 14, 2018 11:35 pm

thecoalman wrote:
Tue Jun 12, 2018 2:43 pm
Lumpy Burgertushie wrote:
Mon Jun 11, 2018 1:55 pm

besides, why are you wanting to do this? nobody cares how long a link is, they just click on it.
by the way, phpbb already shortens local links in a post.
phpBB only shortens the displayed link text, this shortens the url itself.

Code: Select all

https://www.phpbb.com/community/viewtopic.php?f=641&t=2474926
Becomes:

Code: Select all

https://www.phpbb.com/xyz123
xyz123 is just a random string and the script will redirect to the correct URL. It's cleaner especially if there is very long URL but overall never found it very useful.
There are a couple of extensions that do something pretty similar to that, unless hes wanting a local url shortener like goo.gl or something for his boards sake.
I am a web developer/administrator, specializing in forums. If you have work you need done or are too lazy to do, pm me!

My extensions:
[3.2][BETA] Anonymous Posts || [3.2][RC] Show User Activity

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: No registered users and 24 guests