Jump to content

Send visitor to forum with specific theme selected

Featured Replies

Posted

Just wondering if anyone is able to help convert this 3.x script into 4.x? I use it to send visitors to my "theme demo board" while also assigning a specific theme for them.

ie. If a URL like this is clicked: site.com/forums/skinchange.php?id=10, it'll take the visitor to the forum and change their theme id to 10.

Version 4 uses a form/buttons for the "Theme changer" rather than a URL, so I was just wondering if anyone with more knowledge than myself is able to help.. The 3.x script is below.

<?
/**
 * <pre>
 * Invision Power Services
 * IP.Board v3.2.0
 * Simple skin change script
 * Place in your site root directory to send a user to a specified skin
 * Last Updated: $Date: 2011-03-11 06:59:39 -0500 (Fri, 11 Mar 2011) $
 * </pre>
 *
 * @author 		$Author: ips_terabyte $
 * @copyright	(c) 2001 - 2009 Invision Power Services, Inc.
 * @license		http://www.invisionpower.com/community/board/license.html
 * @package		IP.Board
 * @link		http://www.invisionpower.com
 * @version		$Rev: 8031 $
 *
 */

define( 'IPS_PUBLIC_SCRIPT', 'index.php' );
define( 'IPB_THIS_SCRIPT', 'public' );
require_once( './initdata.php' );/*noLibHook*/

require_once( IPS_ROOT_PATH . 'sources/base/ipsRegistry.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/base/ipsController.php' );/*noLibHook*/

$reg = ipsRegistry::instance();
$reg->init();

if ( $_GET['id'] )
{
	@header("Location: " . str_replace( '&amp;', '&', ipsRegistry::$settings['base_url'] ) . '&settingNewSkin=' . intval( $_GET['id'] ) . '&k=' . $reg->member()->form_hash );
}
else
{
	die("No ID passed");
}

exit();

Thanks to anyone who can help!

<?php

$_SERVER['SCRIPT_FILENAME']	= __FILE__;
/**
 * Path to your IP.Suite directory with a trailing /
 * Leave blank if in IPS root.
 */
$path	= '';

require_once $path . 'init.php';
if (\IPS\Request::i()->id)
{
    \IPS\Dispatcher\Front::i();
    \IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=system&controller=theme', 'front', 'theme')->setQueryString( array( 'id' => \IPS\Request::i()->id, 'csrfKey' => \IPS\Session::i()->csrfKey ) ) );
}
else
{
    die("No ID passed");
}
exit();

seems to do the trick in testing. Cheers.

  • Author

Thanks for the help.. It works if you simply paste the URL into your address bar and press "go", however if you click the link from a html document, it simply refreshes the page you were viewing and doesn't take you to the forum.

 

<a href="http://www.site.com/theme.php?id=6">Click here</a>

I see. it is changing the skin, it's just sending them exactly back to where they came. Different approach seems to have it.

<?php

$_SERVER['SCRIPT_FILENAME'] = __FILE__;
$path = '';
$_GET['app'] = 'core';
$_GET['module'] = 'system';
$_GET['controller'] = 'theme';

require_once $path . 'init.php';
if (\IPS\Request::i()->id)
{
    $_SERVER['HTTP_REFERER'] = '';
    $disp = \IPS\Dispatcher\Front::i();
    \IPS\Request::i()->csrfKey = \IPS\Session::i()->csrfKey;
    $disp->run();
}
else
{
    die("No ID passed");
}
exit();

 

  • Author

Perfect, that works! Thanks so much for the help - much appreciated! :)

  • 1 year later...
On 28.04.2015 at 1:27 AM, Marcher Technologies said:

I see. it is changing the skin, it's just sending them exactly back to where they came. Different approach seems to have it.


<?php

$_SERVER['SCRIPT_FILENAME'] = __FILE__;
$path = '';
$_GET['app'] = 'core';
$_GET['module'] = 'system';
$_GET['controller'] = 'theme';

require_once $path . 'init.php';
if (\IPS\Request::i()->id)
{
    $_SERVER['HTTP_REFERER'] = '';
    $disp = \IPS\Dispatcher\Front::i();
    \IPS\Request::i()->csrfKey = \IPS\Session::i()->csrfKey;
    $disp->run();
}
else
{
    die("No ID passed");
}
exit();

 

Hello;
I'm having a problem with this code. There is also a report on it.

Can you help with this?

Thanks for your help.

  • Community Expert

Try replacing:

$disp = \IPS\Dispatcher\Front::i();

with this:

$disp = \IPS\Dispatcher\External::i();

 

They added a new external dispatcher for such things in 4.1.14. I haven't tested the change but that's probably the issue.

Thank you so much. :thumbsup:

  • Community Expert

You're welcome :D

  • 1 year later...
On 28.04.2015 at 1:27 AM, Marcher Technologies said:

I see. it is changing the skin, it's just sending them exactly back to where they came. Different approach seems to have it.


<?php

$_SERVER['SCRIPT_FILENAME'] = __FILE__;
$path = '';
$_GET['app'] = 'core';
$_GET['module'] = 'system';
$_GET['controller'] = 'theme';

require_once $path . 'init.php';
if (\IPS\Request::i()->id)
{
    $_SERVER['HTTP_REFERER'] = '';
    $disp = \IPS\Dispatcher\Front::i();
    \IPS\Request::i()->csrfKey = \IPS\Session::i()->csrfKey;
    $disp->run();
}
else
{
    die("No ID passed");
}
exit();

 

With this method, can a product in the store be added directly to the card? How do I follow a path to do this?

Thank you in advance for your help.

Archived

This topic is now archived and is closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.