Change a URL
#1
So Yes I am editing my first plugin atm, and I got stuck on the final thing.

Here is what I have for this setting so far in the ACP:

            'name'        => 'tor_block_url',
            'title'       => 'Url To Be Redirected to',
            'description' => 'The url that Tor Users will be redirected to',
            'optionscode' => 'text',
            'value'       => '0',
        

Everything is in the same file basically and what I need it to do is whatever url or filename is entered in there I need it to update in the file at a location

Basically
Whatever url is entered in the setting, I need it to update this:
 die('<script>window.location.href="URL HERE";</script>'); // Redirect Page

Sorry for the noobish questions. Just needed to ask this one thing
Reply
#2
In your plugin, do:
redirect($mybb->settings['tor_block_url']);

Or do you want to redirect to the entered url ?
[MyBB 1.8 mods] - Offer me a coffee
Do not ask me help through PM
Reply
#3
(02-26-2015, 08:23 AM)Crazycat Wrote: In your plugin, do:
redirect($mybb->settings['tor_block_url']);

Or do you want to redirect to the entered url ?

yes I want the url entered in the setting to change in the file
Reply
#4
Ok, you want to force tor' users to go to tor_block_url. So my code is right, it uses the mybb redirect function.

Checkout the function parameters to make it working as you need:
/**
 * Redirect the user to a given URL with a given message
 *
 * @param string The URL to redirect the user to
 * @param string The redirection message to be shown
 * @param string The title of the redirection page
 * @param boolean Force the redirect page regardless of settings
 */
function redirect($url, $message="", $title="", $force_redirect=false)
[MyBB 1.8 mods] - Offer me a coffee
Do not ask me help through PM
Reply
#5
(02-26-2015, 03:31 PM)Crazycat Wrote: Ok, you want to force tor' users to go to tor_block_url. So my code is right, it uses the mybb redirect function.

Checkout the function parameters to make it working as you need:
/**
 * Redirect the user to a given URL with a given message
 *
 * @param string The URL to redirect the user to
 * @param string The redirection message to be shown
 * @param string The title of the redirection page
 * @param boolean Force the redirect page regardless of settings
 */
function redirect($url, $message="", $title="", $force_redirect=false)

where would I put that at?
Reply
#6
Which that ?
My last post was just the inline documentation of the redirect function.

All you need in your plugin is:
redirect($mybb->settings['tor_block_url']);
[MyBB 1.8 mods] - Offer me a coffee
Do not ask me help through PM
Reply
#7
so like
 die('<script>window.location.href="redirect($mybb->settings['tor_block_url']); ";</script>'
?

edit: nah that broke the plugins
Reply
#8
No die or anything else.
Juste the line I gave you
[MyBB 1.8 mods] - Offer me a coffee
Do not ask me help through PM
Reply
#9
ok so I have this now:
function wonder_guard_block()
{
    global $mybb;
    
    
    $torExitNodes = file_get_contents("https://www.dan.me.uk/tornodes"); // Ips to block.
    
    $ip = $_SERVER['REMOTE_ADDR']; // IP
        
    if (strpos($torExitNodes, $ip) == true) {
   redirect($mybb->settings['wonder_guard_url']);  // Redirect Page
}

will try it out now

edit: doesn't work
Reply
#10
Any error ?
Did you verify that the IP you use to test is in the file ?
Did you really forget the last } or is it a paste error ?
[MyBB 1.8 mods] - Offer me a coffee
Do not ask me help through PM
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)