MyBB Community Forums

Full Version: Change a URL
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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
In your plugin, do:
redirect($mybb->settings['tor_block_url']);

Or do you want to redirect to the entered url ?
(2015-02-26, 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
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)
(2015-02-26, 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?
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']);
so like
 die('<script>window.location.href="redirect($mybb->settings['tor_block_url']); ";</script>'
?

edit: nah that broke the plugins
No die or anything else.
Juste the line I gave you
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
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 ?
Pages: 1 2