Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
Swivelgames | PHPBB Support Forum wrote:
I was wondering if anyone could give me a basic idea on how to create a new script that will change the current users theme to a select theme when the script is executed.

I have no clue where to start, what files to look in, what queries to send out, more or less how to write to a MySQL DB.

Yes I am an extremely big n00b at working with SQL DB's, but thats why I am trying to learn now Smile .

Please help me out if you can, and step me through this please Very Happy
Swivelgames | PHPBB Support Forum wrote:
Heres what I am trying to do...

I have two domains...
http://psp.domain.com
http://forum.domain.com

I have created a psp theme that works almost perfectly on the PSP, and I need it when people goto the psp.domain.com it will redirect them to forum.domain.com(already done) and change the theme to the psp theme for better navigation and what not.

I need an automatic script. I already know how to change it manually and restrict the board to one theme.
Swivelgames | PHPBB Support Forum wrote:
I already know how to do that. What I need to do is...
Swivelgames | PHPBB Support Forum wrote:
Heres what I need, a script that will edit the users profile and change there theme to the PSP theme automatically.

Lumpy Burgertushie wrote:
well, I don't know how that would be done , especially coming from out side the board via a link.

The script is not outside of the board. psp.domain.com redirects to the script on forum.domain.com.

The file will not be outside the board, that was the last thing I had on my mind.
And there are plenty of different replies to that topic basicly telling me that I was a complete idiot and had no clue what the features were in phpbb.
Quote:
Just go to the admin panel and set your psp skin as the default style and select the option to over ride the users style, this way when they got to your forum it will automatically show the psp style
Quote:
you are aware that users can change their skin in their profiles, correct? And as an admin you can edit their profile yourself through the ACP? Do you need a script that will force ALL users to the same skin?
Good lord... I am hopeless getting help there. Anyone here able to help me out? Heres what I need...


A script that will edit the users profile and change there theme to the theme I want, and redirect to the index.php page, when the script is executed.
Here you go, off the top of my head, this should work, but only for logged-in users:


Code:
<?php
define('IN_PHPBB',true);
$phpbb_root_path = "<../forum/>"; // set path to phpBB files in <stuff> here
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
if (isset($userdata) && $userdata['user_logged_in'])
{
       $sql = "UPDATE <your_table_users> SET user_style = '<stylenumber>' WHERE user_id = '" . $userdata['user_id'] . '"'; //edit the <stuff> here
       if (!$result = $db->sql_query($sql)) message_die(GENERAL_ERROR, 'Error reading database.', '', __LINE__, __FILE__);
       header('Location: http://psp.domain.com');
} else {
       message_die(GENERAL_ERROR, 'You need to log in for this feature', '', __LINE__, __FILE__);
}
?>
ROFL!!!

Less than 10mins after posting it here I get an awesome answer! And more than 6 hours after posting it on phpbb support forum the people there still have no clue what the hell I am talking about. Laughing

Thanks Kerm Laughing

Though I did get this error...
Quote:
"You need to log in for this feature

DEBUG MODE

Line : 12
File : psptheme.php"
... and yes I am logged in.
My mistake, try this:


Code:
<?php
define('IN_PHPBB',true);
$phpbb_root_path = "<../forum/>"; // set path to phpBB files in <stuff> here
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
init_userprefs($userdata); // load user prefs
if (isset($userdata) && $userdata['session_logged_in'])
{
       $sql = "UPDATE <your_table_users> SET user_style = '<stylenumber>' WHERE user_id = '" . $userdata['user_id'] . '"'; //edit the <stuff> here
       if (!$result = $db->sql_query($sql)) message_die(GENERAL_ERROR, 'Error reading database.', '', __LINE__, __FILE__);
       header('Location: http://psp.domain.com');
} else {
       message_die(GENERAL_ERROR, 'You need to log in for this feature', '', __LINE__, __FILE__);
}
?>

Code:
<?php
define('IN_PHPBB',true);
$phpbb_root_path = "./"; // set path to phpBB files in <stuff> here
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
init_userprefs($userdata); // load user prefs
if (isset($userdata) && $userdata['session_logged_in'])
{
       $sql = "UPDATE users SET user_style = '3' WHERE user_id = '" . $userdata['user_id'] . "'"; //edit the <stuff> here
       if (!$result = $db->sql_query($sql)) message_die(GENERAL_ERROR, 'Error reading database.', '', __LINE__, __FILE__);
       header('Location: http://rhika.swivelgames.com');
} else {
       message_die(GENERAL_ERROR, 'You need to log in for this feature', '', __LINE__, __FILE__);
}
?>

Tell me what I am doing wrong Sad
Very Happy Tell me what error you're getting, if any. Same one?
Same.
Quote:
You need to log in for this feature

DEBUG MODE

Line : 13
File : psptheme.php
Try this and tell me what happens:

Code:
<?php
define('IN_PHPBB',true);
$phpbb_root_path = "./"; // set path to phpBB files in <stuff> here
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
init_userprefs($userdata); // load user prefs
print_r($userdata);
if (isset($userdata) && $userdata['session_logged_in'])
{
       $sql = "UPDATE users SET user_style = '3' WHERE user_id = '" . $userdata['user_id'] . "'"; //edit the <stuff> here
       if (!$result = $db->sql_query($sql)) message_die(GENERAL_ERROR, 'Error reading database.', '', __LINE__, __FILE__);
       header('Location: http://rhika.swivelgames.com');
} else {
       message_die(GENERAL_ERROR, 'You need to log in for this feature', '', __LINE__, __FILE__);
}
?>
Shock Shock Shock
Quote:
Array ( )
Warning: Cannot modify header information - headers already sent by (output started at /var/www/rhika_files/psptheme.php:7) in /var/www/rhika_files/includes/sessions.php on line 366

Warning: Cannot modify header information - headers already sent by (output started at /var/www/rhika_files/psptheme.php:7) in /var/www/rhika_files/includes/sessions.php on line 367

Warning: Cannot modify header information - headers already sent by (output started at /var/www/rhika_files/psptheme.php:7) in /var/www/rhika_files/includes/page_header.php on line 521

Warning: Cannot modify header information - headers already sent by (output started at /var/www/rhika_files/psptheme.php:7) in /var/www/rhika_files/includes/page_header.php on line 523

Warning: Cannot modify header information - headers already sent by (output started at /var/www/rhika_files/psptheme.php:7) in /var/www/rhika_files/includes/page_header.php on line 524
Quote:
You need to log in for this feature

DEBUG MODE

Line : 14
File : psptheme.php


1...3..4..5 errors... It really wants to get the point across. Laughing
Eeeexcelllent, I suspected as much. Frack, my mistake. Here, this should do it:


Code:
<?php
define('IN_PHPBB',true);
$phpbb_root_path = "./"; // set path to phpBB files in <stuff> here
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$userdata = session_pagestart($user_ip, PAGE_LOGIN); // initiate session
init_userprefs($userdata); // load user prefs
print_r($userdata);
if (isset($userdata) && $userdata['session_logged_in'])
{
       $sql = "UPDATE users SET user_style = '3' WHERE user_id = '" . $userdata['user_id'] . "'"; //edit the <stuff> here
       if (!$result = $db->sql_query($sql)) message_die(GENERAL_ERROR, 'Error reading database.', '', __LINE__, __FILE__);
       header('Location: http://rhika.swivelgames.com');
} else {
       message_die(GENERAL_ERROR, 'You need to log in for this feature', '', __LINE__, __FILE__);
}
?>


Saying my setup is nonstandard would be an understatement; I forgot to take into account the default setup. Razz
Quote:
Array ( [0] => 4 [user_id] => 4 [1] => 1 [user_active] => 1 [2] => Swivelgames [username] => Swivelgames [3] => ** [user_password] => ** [4] => 1162960105 [user_session_time] => 1162960105 [5] => 0 [user_session_page] => 0 [6] => 1162874819 [user_lastvisit] => 1162874819 [7] => 1149762244 [user_regdate] => 1149762244 [8] => 1 [user_level] => 1 [9] => 201 [user_posts] => 201 [10] => -5.00 [user_timezone] => -5.00 [11] => 1 [user_style] => 1 [12] => english [user_lang] => english [13] => D M d, Y g:i a [user_dateformat] => D M d, Y g:i a [14] => 0 [user_new_privmsg] => 0 [15] => 0 [user_unread_privmsg] => 0 [16] => 1161496444 [user_last_privmsg] => 1161496444 [17] => 0 [user_login_tries] => 0 [18] => 0 [user_last_login_try] => 0 [19] => 1155686916 [user_emailtime] => 1155686916 [20] => 0 [user_viewemail] => 0 [21] => 1 [user_attachsig] => 1 [22] => 0 [user_allowhtml] => 0 [23] => 1 [user_allowbbcode] => 1 [24] => 1 [user_allowsmile] => 1 [25] => 1 [user_allowavatar] => 1 [26] => 1 [user_allow_pm] => 1 [27] => 1 [user_allow_viewonline] => 1 [28] => 0 [user_notify] => 0 [29] => 0 [user_notify_pm] => 0 [30] => 1 [user_popup_pm] => 1 [31] => 1 [user_rank] => 1 [32] => [user_avatar] => [33] => 0 [user_avatar_type] => 0 [34] => swivelgame@swivelgames.com [user_email] => swivelgame@swivelgames.com [35] => [user_icq] => [36] => http://rhika.swivelgames.com [user_website] => http://rhika.swivelgames.com [37] => East Texas [user_from] => East Texas [38] => [img:51de8eca6c]http://img133.imageshack.us/img133/3710/7017315480b69c9b8fp6.png[/img:51de8eca6c] [img:51de8eca6c]http://www.swivelgames.com/sig/2.png[/img:51de8eca6c] [img:51de8eca6c]http://www.cemetech.net/img/sigs/blubbar.png[/img:51de8eca6c] [img:51de8eca6c]http://www.cemetech.net/img/sigs/forumsig/111.png[/img:51de8eca6c] [img:51de8eca6c]http://miniprofile.xfire.com/bg/sf/type/2/swivelgames.png[/img:51de8eca6c] [size=9:51de8eca6c][b:51de8eca6c]D. Shiznit: [/b:51de8eca6c][i:51de8eca6c]Shouldn't a movie about noobs be filmed in rtb? It would be way more authentic.[/i:51de8eca6c][/size:51de8eca6c] [user_sig] => [img:51de8eca6c]http://img133.imageshack.us/img133/3710/7017315480b69c9b8fp6.png[/img:51de8eca6c] [img:51de8eca6c]http://www.swivelgames.com/sig/2.png[/img:51de8eca6c] [img:51de8eca6c]http://www.cemetech.net/img/sigs/blubbar.png[/img:51de8eca6c] [img:51de8eca6c]http://www.cemetech.net/img/sigs/forumsig/111.png[/img:51de8eca6c] [img:51de8eca6c]http://miniprofile.xfire.com/bg/sf/type/2/swivelgames.png[/img:51de8eca6c] [size=9:51de8eca6c][b:51de8eca6c]D. Shiznit: [/b:51de8eca6c][i:51de8eca6c]Shouldn't a movie about noobs be filmed in rtb? It would be way more authentic.[/i:51de8eca6c][/size:51de8eca6c] [39] => 51de8eca6c [user_sig_bbcode_uid] => 51de8eca6c [40] => crfst9 [user_aim] => crfst9 [41] => swivelgames [user_yim] => swivelgames [42] => wizandwars@hotmail.com [user_msnm] => wizandwars@hotmail.com [43] => Web Designer [user_occ] => Web Designer [44] => PHP Programming, and pwning n00bs on Halo! [user_interests] => PHP Programming, and pwning n00bs on Halo! [45] => [user_actkey] => [46] => [user_newpasswd] => [47] => 0 [user_firstpost] => 0 [48] => 2271990 [user_birthday] => 2271990 [49] => 43576.70 [user_points] => 43576.70 [50] => [user_trade] => [51] => �on�FF9900�no�0�no�0 [user_effects] => �on�FF9900�no�0�no�0 [52] => �no�0�on�0�on�0 [user_privs] => �no�0�on�0�on�0 [53] => �on�333399�off�0�off�0�on�Founder of rhika�off�0 [user_custitle] => �on�333399�off�0�off�0�on�Founder of rhika�off�0 [54] => [user_specmsg] => [55] => �Forum_Spot��Sub-Forum Spot��Sub-Forum Spot��Sub-Forum Spot� [user_items] => �Forum_Spot��Sub-Forum Spot��Sub-Forum Spot��Sub-Forum Spot� [56] => 1e8448c7f331029f9ced4b95e8e5d0de [session_id] => 1e8448c7f331029f9ced4b95e8e5d0de [57] => 4 [session_user_id] => 4 [58] => 1162944579 [session_start] => 1162944579 [59] => 1162960105 [session_time] => 1162960105 [60] => 46ad8ef8 [session_ip] => 46ad8ef8 [61] => 0 [session_page] => 0 [62] => 1 [session_logged_in] => 1 [63] => 0 [session_admin] => 0 )
Warning: Cannot modify header information - headers already sent by (output started at /var/www/rhika_files/psptheme.php:Cool in /var/www/rhika_files/psptheme.php on line 13


Is Kerm tired?!? Shock
Very Happy No dude, you just forgot to take out the debug line that I also forgot. Take out the line beginning print_r(...). Also, I'm quite tired. Smile
So it should look like this...
Code:
<?php
define('IN_PHPBB',true);
$phpbb_root_path = "./"; // set path to phpBB files in <stuff> here
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$userdata = session_pagestart($user_ip, PAGE_LOGIN); // initiate session
init_userprefs($userdata); // load user prefs
       $sql = "UPDATE users SET user_style = '3' WHERE user_id = '" . $userdata['user_id'] . "'"; //edit the <stuff> here
       if (!$result = $db->sql_query($sql)) message_die(GENERAL_ERROR, 'Error reading database.', '', __LINE__, __FILE__);
       header('Location: http://rhika.swivelgames.com');
?>
...correct?

Worked Very Happy Very Happy
Ok, Now to detect the browser and change the theme when needed. I could combine JS and PHP, and create this code...
Code:
<script language="javascript">
var browser=navigator.appName
var style="<?php echo($userdata['user_style']); ?>"
if(style != "3" && browser == "PSP (PlayStaion Portable) Internet Browser") {
location.replace('http://rhika.swivelgames.com/psptheme.php')
} else if(style != "1" && browser != "PSP (PlayStaion Portable) Internet Browser") {
location.replace('http://rhika.swivelgames.com/regtheme.php') }
</script>
Which would go into the header. I already found out what the PSP's 'navigator.appName' is, so this would work correct?

Info...
  • First if statement is supposed to check if the users style isn't 3 and the browser is 'PSP (PlayStaion Portable) Internet Browser'. If true it will redirect to http://rhika.swivelgames.com/psptheme.php which will change the theme to the PSP theme(style 3)
  • Second if statement is supposed to check if the users style isn't 1 and if the browser is not the 'PSP (PlayStaion Portable) Internet Browser'. If true it will redirect to http://rhika.swivelgames.com/redtheme.php which will change the theme to theme 1.
But this is creating an endless loop Bad Idea
For one thing, you misspelled "Playstation" Razz
I remembered that I fixed that actually. I worked on it alot last night and came up dry.

Got any ideas?

(Man, I really need to get better at programming and stop asking people)
Idea Is this what I think it is? A script to detect the PSP browser! YAY! I've been looking for ages! Just, I need it for a different reason (to refer the browser to a different page, rather than theme). I'm not intending to use this for my phpBB theme. So... I won't ask what I need here. =P. I'll create a topic someother day. ^^; Thanks for the script idea. I can possibly edit it w/o any knowledge of JS! Woo for me! ( I work miracles ok?!)
Swivel: make sure this is the first thing on the page:


Code:
<?php
define('IN_PHPBB',true);
$phpbb_root_path = "./"; // set path to phpBB files in <stuff> here
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$userdata = session_pagestart($user_ip, PAGE_LOGIN); // initiate session
init_userprefs($userdata); // load user prefs?>


Otherwise $userdata is just a null variable.
Is it possible to use a theme that PHP does not have listed? Like I have a very simple theme that I don't have listed in the current themes. Would it be possible to sue it as an exclusive theme? Only for PSP browsers?
All themes in the theme tale show up as options for users. You'd have to mod the table and code to exclude styles with a certain flag in their style data from an option in profile settings.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement