set a request variable, how

Discussion forum for MOD Writers regarding MOD Development.
User avatar
AGC
Registered User
Posts: 292
Joined: Sat Sep 15, 2007 10:26 pm
Contact:

set a request variable, how

Post by AGC »

How do I use the set_var to set a request variable, for me, to use later ?

Thank
(phpBB 2.0.x): []Admin Topics List[] MOD. << Description & Download. , []Highlight Author[] MOD.

Donate-paypal
(phpBB 3.0.x)[ver] MODs: [RC1] >Import old *.pak files MOD. + . . .[8] > ACP - Modules Quick Access (MQA) MOD. + . . . [7-PL1] > Multi Smile (actions) MOD
User avatar
3Di
Former Team Member
Posts: 16096
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano 🇮🇹 Frankfurt 🇩🇪
Name: Marco
Contact:

Re: set a request variable, how

Post by 3Di »

phpbb's request_var already uses set_var ..
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
AGC
Registered User
Posts: 292
Joined: Sat Sep 15, 2007 10:26 pm
Contact:

Re: set a request variable, how

Post by AGC »

I know. I want to set a variable right before requesting it.
I try to use set_var but nothing happend ??? how I use this function ?
(phpBB 2.0.x): []Admin Topics List[] MOD. << Description & Download. , []Highlight Author[] MOD.

Donate-paypal
(phpBB 3.0.x)[ver] MODs: [RC1] >Import old *.pak files MOD. + . . .[8] > ACP - Modules Quick Access (MQA) MOD. + . . . [7-PL1] > Multi Smile (actions) MOD
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52229
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: set a request variable, how

Post by Brf »

set_var() is just for giving a script variable a value, using a type mask. It has nothing at all to do with request variables.
User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: set a request variable, how

Post by Erik Frèrejean »

Code: Select all

// Set a variable to the $_REQUEST array
$_REQUEST['myvar'] = 'something'; 
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)
User avatar
AGC
Registered User
Posts: 292
Joined: Sat Sep 15, 2007 10:26 pm
Contact:

Re: set a request variable, how

Post by AGC »

Brf wrote:set_var() is just for giving a script variable a value, using a type mask. It has nothing at all to do with request variables
Erik Frèrejean wrote:

Code: Select all

// Set a variable to the $_REQUEST array
$_REQUEST['myvar'] = 'something'; 
Thank you for the Info.
But if I used it in a MOD is that forbidden ?
Last edited by AGC on Fri Oct 29, 2010 1:12 am, edited 2 times in total.
(phpBB 2.0.x): []Admin Topics List[] MOD. << Description & Download. , []Highlight Author[] MOD.

Donate-paypal
(phpBB 3.0.x)[ver] MODs: [RC1] >Import old *.pak files MOD. + . . .[8] > ACP - Modules Quick Access (MQA) MOD. + . . . [7-PL1] > Multi Smile (actions) MOD
User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: set a request variable, how

Post by Erik Frèrejean »

I don't see why, as long you don't introduce an security issue with it. But only a MOD team member can give a conclusive answer to that, I'm not aware of all their policies.
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)
User avatar
igorw
Former Team Member
Posts: 8024
Joined: Fri Dec 16, 2005 12:23 pm
Location: {postrow.POSTER_FROM}
Name: Igor Wiedler

Re: set a request variable, how

Post by igorw »

Changing request variables is strongly discouraged because it no longer allows assumptions about superglobals to be made.
Igor Wiedler | area51 | GitHub | trashbin | Formerly known as evil less than three
User avatar
AGC
Registered User
Posts: 292
Joined: Sat Sep 15, 2007 10:26 pm
Contact:

Re: set a request variable, how

Post by AGC »

igorw wrote:Changing request variables is strongly discouraged because it no longer allows assumptions about superglobals to be made.
What if I take a variable data from the database and set $_request and the variable not set before this action, I mean in the $_request array it's not exist yet.
(phpBB 2.0.x): []Admin Topics List[] MOD. << Description & Download. , []Highlight Author[] MOD.

Donate-paypal
(phpBB 3.0.x)[ver] MODs: [RC1] >Import old *.pak files MOD. + . . .[8] > ACP - Modules Quick Access (MQA) MOD. + . . . [7-PL1] > Multi Smile (actions) MOD
User avatar
Dr.Death
Registered User
Posts: 400
Joined: Fri Apr 25, 2003 10:04 am
Location: Germany
Contact:

Re: set a request variable, how

Post by Dr.Death »

You could set the default value of the request_var() to the database value.

Code: Select all

$default = $database_value;
$input = request_var('input', $default);
Doc.
User avatar
igorw
Former Team Member
Posts: 8024
Joined: Fri Dec 16, 2005 12:23 pm
Location: {postrow.POSTER_FROM}
Name: Igor Wiedler

Re: set a request variable, how

Post by igorw »

Dr.Death wrote:You could set the default value of the request_var() to the database value.

Code: Select all

$default = $database_value;
$input = request_var('input', $default);
Please always cast though, related: http://blog.phpbb.com/2009/09/10/how-no ... quest_var/
Igor Wiedler | area51 | GitHub | trashbin | Formerly known as evil less than three
User avatar
AGC
Registered User
Posts: 292
Joined: Sat Sep 15, 2007 10:26 pm
Contact:

Re: set a request variable, how

Post by AGC »

igorw wrote:
Dr.Death wrote:You could set the default value of the request_var() to the database value.

Code: Select all

$default = $database_value;
$input = request_var('input', $default);
Please always cast though, related: http://blog.phpbb.com/2009/09/10/how-no ... quest_var/
First the variable is sanitized, with the sql_query, Second the variable would not write back to the database, But just will be request for later use.
(phpBB 2.0.x): []Admin Topics List[] MOD. << Description & Download. , []Highlight Author[] MOD.

Donate-paypal
(phpBB 3.0.x)[ver] MODs: [RC1] >Import old *.pak files MOD. + . . .[8] > ACP - Modules Quick Access (MQA) MOD. + . . . [7-PL1] > Multi Smile (actions) MOD
User avatar
igorw
Former Team Member
Posts: 8024
Joined: Fri Dec 16, 2005 12:23 pm
Location: {postrow.POSTER_FROM}
Name: Igor Wiedler

Re: set a request variable, how

Post by igorw »

Let me state the conditions more clearly. If you expect $input to be an integer and want to use it in a query later on, you need to cast $default to an integer.
Igor Wiedler | area51 | GitHub | trashbin | Formerly known as evil less than three
User avatar
AGC
Registered User
Posts: 292
Joined: Sat Sep 15, 2007 10:26 pm
Contact:

Re: set a request variable, how

Post by AGC »

igorw wrote:Let me state the conditions more clearly. If you expect $input to be an integer and want to use it in a query later on, you need to cast $default to an integer.
Yes. I know that.
So if the variable is sanitized, I can set $_REQUEST['variable'] = $data as integer.
And then request_var() it later.

Thanks.
(phpBB 2.0.x): []Admin Topics List[] MOD. << Description & Download. , []Highlight Author[] MOD.

Donate-paypal
(phpBB 3.0.x)[ver] MODs: [RC1] >Import old *.pak files MOD. + . . .[8] > ACP - Modules Quick Access (MQA) MOD. + . . . [7-PL1] > Multi Smile (actions) MOD
User avatar
3Di
Former Team Member
Posts: 16096
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano 🇮🇹 Frankfurt 🇩🇪
Name: Marco
Contact:

Re: set a request variable, how

Post by 3Di »

that should be:

Code: Select all

$default = (int) $database_value;
$input = request_var('input', $default);
or I am getting older..
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
Locked

Return to “[3.0.x] MOD Writers Discussion”