Announcement

Collapse
No announcement yet.

How to change external links to internal links to do something before redirecting to the destination

Collapse
This is a sticky topic.
X
X
Collapse
First Prev Next Last
 
  • Filter
  • Time
  • Show
Clear All
new posts
    HaMooooDi
    Junior Member

  • HaMooooDi
    replied
    Any update to make this Mod works

    Leave a comment:

  • HaMooooDi
    Junior Member

  • HaMooooDi
    replied
    all PHP modules stopped by design after the latest security update

    The PHP module will no longer work after applying the latest security patch. This is by design. This redirect would have to be reworked using a custom API extension or Javascript. See: https://forum.vbulletin.com/articles...php-in-modules

    Leave a comment:

  • HaMooooDi
    Junior Member

  • HaMooooDi
    replied
    Hi

    it seams it is not working for in RSS feeds, is their any way to enable it there also ?

    Leave a comment:

  • HaMooooDi
    Junior Member

  • HaMooooDi
    replied
    I used the same method you described, however I discovered the issue in the code the below code with small adjustment worked for me perfectly

    PHP Code:
    $rightlink_host parse_url($rightlinkPHP_URL_HOST);
    $forum_baseurl vB::getDatastore()->getOption('frontendurl');
    $forum_host parse_url($forum_baseurlPHP_URL_HOST);        

    // if same host, then use the link directly
    if (vB5_String::stripos($rightlink_host$forum_host) !== false) {
        return 
    "<a href="$rightlink" target="_blank"" . ($is_external ' rel="nofollow"' '') . ">$text</a>";  
    }
    else { 
    // link to your redirect page and pass the encoded external link

        // specify path of the redirect URL (exclude forum base url) including the querystring parameter name
        // this is the path you used when you created the redirect page in Sitebuilder
        
    $redirect_path "/redirect?url=";

        return 
    '<a href="' $forum_baseurl $redirect_path urlencode($rightlink) . '" target="_blank"' . ($is_external ' rel="nofollow"' '') . ">$text</a>";

    thanks alot

    Leave a comment:

  • HaMooooDi
    Junior Member

  • HaMooooDi
    replied
    hi thanks for the mod however I noticed some issues, it will be grateful if you can help me with

    once applying the above the forum base links is redirecting to invalid link please see the attached screenshots

    it is directing to
    /vb/$rightlink

    instead of
    /vb/node/224397

    also I have file upload script in the same domain of my forum the same issue noticed with the links added to my forum

    it is directing to
    /vb/$rightlink

    instead of
    /up/do.php?id=1501


    Attached Files

    Leave a comment:

  • glennrocksvb
    Founder/Coder

  • glennrocksvb
    replied
    I updated the code in the first post. Could you try again?

    There's a bug in vB where backslash "\" in posts are stripped off. The code has "\" that were stripped off which would cause syntax error. This could explain why the mod stopped working.

    I found a workaround to prevent a backlash from being removed from posts by using double backslashes.

    Leave a comment:

  • glennrocksvb
    Founder/Coder

  • glennrocksvb
    replied
    Theoretically it should be compatible as there's nothing special being done that would break in future PHP versions. But I'd have to check to verify.

    Leave a comment:

  • germaninfl
    Junior Member

  • germaninfl
    replied
    is this compatible with php 7.3.7 ?

    Leave a comment:

  • germaninfl
    Junior Member

  • germaninfl
    replied
    I just re-applied this mod after upgrading to V5.5.3 but it doesn't seem to work any longer ?

    Leave a comment:

  • c00lfr3sh
    Junior Member

  • c00lfr3sh
    replied
    Thanks for this modification. It works perfect for me.

    Leave a comment:

  • glennrocksvb
    Founder/Coder

  • glennrocksvb
    commented on 's reply
    Hmm, I don't know why it doesn't work. I'll have to take a deeper look.
  • germaninfl
    Junior Member

  • germaninfl
    replied
    I got the error figured out. For some reason I was suddenly missing some backslashes when copy&pasting the code
    So the error is gone.

    However, the redirect still does not apply to links in signatures


    Here is a sample signature code from one of my users:
    PHP Code:
    [URL="http://goo.gl/xxxxxjQkx"][SIZE=4][COLOR=#008000][B]Blah blag[/B][/COLOR][/SIZE][/URL] 
    Should the redirect work with that?

    Leave a comment:

  • glennrocksvb
    Founder/Coder

  • glennrocksvb
    commented on 's reply
    You made a syntax error in the code. Can you post the before and after code?
  • germaninfl
    Junior Member

  • germaninfl
    commented on 's reply
    I checked and the signatures do use the [url] BBCodes but it doesn't do anything for me in signatures. It works in posts though.
    I tried editing /core/vb/library/bbcode.php the same way and I'm getting this error:
    Parse error: syntax error, unexpected '$rightlink' (T_VARIABLE) in /home/kasinofo/public_html/core/vb/library/bbcode.php on line 2488
  • glennrocksvb
    Founder/Coder

  • glennrocksvb
    replied
    Originally posted by germaninfl View Post
    is there any way to apply to the signatures?
    The suggested PHP changes for this mod should apply to any [url] BBCodes in the posts including those in signatures. Can you double check the signature is using [url][/url] BBCode tags?

    If it is and still doesn't work, then try doing the exact same changes in /core/vb/library/bbcode.php.

    Leave a comment:

Working...
X