MyBB Community Forums
Redirect Page for Every Link [NO PLUGIN] - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Resources (https://community.mybb.com/forum-8.html)
+--- Forum: Tutorials (https://community.mybb.com/forum-38.html)
+--- Thread: Redirect Page for Every Link [NO PLUGIN] (/thread-224179.html)



Redirect Page for Every Link [NO PLUGIN] - YASAKA - 08-07-2019

Tutorial for redirect page to another site

1, Create a PHP file named 'redirect.php'
<?php 
    define('IN_MYBB', 1);
    define('THIS_SCRIPT', 'redirect.php');

    require_once("global.php");

    add_breadcrumb("Redirect", $_SERVER['PHP_SELF']);

    eval("\$page = \"".$templates->get("redirect_page")."\";");

    output_page($page);
?>

2, Go to Admin CP >> Templates & Style >> Templates >> Your Templates >> Add Templates

3, Set new template name: redirect_page

4, Add this in the new template;
<html>
<head>
<title>Redirect - {$mybb->settings['bbname']}</title>
{$headerinclude}
</head>
<body>
{$header}
<script type="text/javascript">
var link=decodeURIComponent(location.search.substr(6));    
second = 5; //Wait time in seconds
function AutoRedirect(){
document.getElementById('time').innerHTML=second;
if(second==0){
location.href=link;
}
second--;
}
</script>
<br />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" id="fullwidth" style="width:50%;margin:auto">
<tr>
<td class="thead"><strong>Auto Redirect</strong></td>
</tr>
<tr>
<td class="trow1">You are now leaving <span style='color:#ff2f2f;font-weight:900'>Sinful Site</span> and being redirected to
<script type="text/javascript">
document.write("<span style='font-weight:900'>"+link+"</span>")
</script><br>Follow at your own risk! Auto redirect in <span id="time" style="font-weight:900;color:crimson"></span>.
<script type="text/javascript">
AutoRedirect(second);
setInterval("AutoRedirect(second)",1000);
</script>
</td>
</tr>
<tr>
<td class="tcat" align="center"><a class="button" href="{$mybb->settings['bburl']}">Cancel</a>&nbsp;
<script type="text/javascript">
document.write("<a class='button' href='"+link+"'>Get Link</a>")
</script>
</td>
</tr>
</table>
{$footer}
</body>
</html>

5, Upload anon.js file to root/jscripts.

6, Go to showthread and add this;
<script src="jscripts/anon.js" type="text/javascript"></script>
<script type="text/javascript"><!--
protected_links = "sinfulsite.com";
auto_anonymize();
//--></script>
NOTE: Change sinfulsite.com with your forum URL.

6.a, If you can't or won't to upload anon.js file, you can use this
change this;
<script src="jscripts/anon.js" type="text/javascript"></script>

to this;
<script src="https://sinfulsite.com/jscripts/anon.js" type="text/javascript"></script>


7, Done.

Result:
[Image: c3j9eem.png]


RE: Redirect Page for Every Link [NO PLUGIN] - Xyaena - 08-11-2019

Simpler Instructions:

Apply the file redirect.php to the ROOT of your domain. For example: public_html/yoursite/redirect.php. Insert the PHP code to it and save.

Select the theme you want a redirect to happen, enter it, Add Templates and set the title of the template redirect_page. Insert the HTML code to it and save.

Upload anon.js to public_html/yoursite/jscripts/anon.js. Change protected_link to your site.

Go to the same theme's templates, Show Thread Templates, showthread. Insert the script to the bottom above </body> and </html> (bottom area).

If you chose NOT to upload anon.js, replace the top area of the script with this.

<script src="https://sinfulsite.com/jscripts/anon.js" type="text/javascript"></script>

If done correctly, any link in a post or thread will give you the notification. It's possible you can move this script to other parts of your forum, such as your navigational links on your forum's header.

Include the script for any sources you'd like to include with the redirect.

<script src="jscripts/anon.js" type="text/javascript"></script>
<script type="text/javascript"><!--
protected_links = "yourdomain.ext";
auto_anonymize();
//--></script>

or

<script src="https://sinfulsite.com/jscripts/anon.js" type="text/javascript"></script>
<script type="text/javascript"><!--
protected_links = "yourdomain.ext";
auto_anonymize();
//--></script>



RE: Redirect Page for Every Link [NO PLUGIN] - Eldenroot - 08-13-2019

Thank you, good tutorial.

Anyway, it should redirects you back to the page when you were before when you click to "Cancel"