MyBB Community Forums

Full Version: $mybb->input
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I'm new to MyBB development and I've been looking at the code for some plugins.

I also looked at the source documentation. The only thing the documentation says about it is, "Input variables received from the outer world."

What does that mean? How do I send variables from the "outer world" to $mybb? Through POST and GET requests? Is the input property like $_REQUEST?

Thanks for any clarification.
What are you trying to achieve exactly? Send some data from an external website to your MyBB forum?
AFAIU, $mybb->input is the equivalent to $_GET/$_POST/etc, but all cleaned up.

So:
$pid = (int)@$_GET['pid'];
if(strtolower($_SERVER['REQUEST_METHOD']) == 'post')
{
die('No post request allowed');
}

Would be the same as:
$pid = $mybb->input['pid'];
if($mybb->request_method == 'post')
{
die('No post request allowed');
}

http://crossreference.mybboard.de/nav.ht...ource.html
Yes, $mybb->input[] simply stores the content of $_GET and $_POST after having done some simple sanitation.
@Omar you should still ideally filter input from $mybb->input in my eyes. Better safe than sorry.
Yes you should, tough some keys are suppose to be cleaned you may never know. It was just so that both pieces of code looked as similar as possible.
(2012-08-22, 07:03 PM)crazy4cs Wrote: [ -> ]What are you trying to achieve exactly? Send some data from an external website to your MyBB forum?
Not sure yet. Just trying to understand the "tools" so that I can figure out what to make with them. Smile

Thanks Omar and euantor
(2012-08-22, 07:06 PM)Omar G. Wrote: [ -> ]AFAIU, $mybb->input is the equivalent to $_GET/$_POST/etc, but all cleaned up.

So:
$pid = (int)@$_GET['pid'];
if(strtolower($_SERVER['REQUEST_METHOD']) == 'post')
{
die('No post request allowed');
}

Would be the same as:
$pid = $mybb->input['pid'];
if($mybb->request_method == 'post')
{
die('No post request allowed');
}

http://crossreference.mybboard.de/nav.ht...ource.html

Just a FYI, you shouldn't ignore "undeclared variable" warnings like this:
(int)@$_GET['pid'];

instead, use isset to check if it's been declared.
^If I do this:
$pid = (isset($_GET['pid']) ? (int)$_GET['pid'] : 0)

Wouldn't it be the same? At the end, it will be equals 0 if it is no set. What is the real difference then Pirata?
Isset is the better option. Suppressing errors should only really be done rarely (MyBB is quite bad for this actually).
Pages: 1 2