$mybb->input returning null?
#1
Hi All,

I am creating a custom page, and for some reason when I try to return $mybb->input["cid"} it returns as null or 0.

However if I try to return $_GET["cid"] it returns with the correct value.

THis is on a custom page


<?php 
define('IN_MYBB', 1); 
require("global.php");


echo "input: ".$mybb->input["cid"];

echo "<br/>input $_GET: " $_GET["cid"];

?>


THere is a whole lot of other stuff on my page but if I just narrow down to that is doesnt work.

Other things like $lang $templates, $db and $mybb->user all seem to work however.

Can anyone think of any reason for this?

Ok for some reason I am guessing because it had "id" in the variable it was looking at cid as an int rather than a string and sanitizing it.

If I change the rewrite rule to con= all is sweet.

Useful info to know
Reply
#2
This user has been denied support. This user has been denied support.
Odd, it should work.
Reply
#3
Did you declare the global $mybb?
My Plugins: [1.8]|[1.6]

** Selling custom plugin that enables Bitcoin payments. PM me if interested in purchasing! **
Reply
#4
This user has been denied support. This user has been denied support.
He's saying $mybb->user and such variables are working, so I believe he did.
Reply
#5
This might be issue in the code from where this cid thing is getting. Please paste the complete code you're using other then the one pasted above.
Reply
#6
(2012-10-26, 07:19 AM)Dannymh Wrote: Ok for some reason I am guessing because it had "id" in the variable it was looking at cid as an int rather than a string and sanitizing it.

If I change the rewrite rule to con= all is sweet.

Useful info to know

That is because the "cid" input key is sanitized in class_core.php:

	/**
	 * Variables that need to be clean.
	 *
	 * @var array
	 */
	public $clean_variables = array(
		"int" => array(
			"tid", "pid", "uid",
			"eid", "pmid", "fid",
			"aid", "rid", "sid",
			"vid", "cid", "bid",
			"pid", "gid", "mid",
			"wid", "lid", "iid",
			"sid"),
		"a-z" => array(
			"sortby", "order"
		)
	);
/*~~~~~~~~~~~~~~~~~~~~~~~~*/
	/**
	 * Cleans predefined input variables.
	 *
	 */
	function clean_input()
	{
		foreach($this->clean_variables as $type => $variables)
		{
			foreach($variables as $var)
			{
				// If this variable is in the ignored array, skip and move to next.
				if(in_array($var, $this->ignore_clean_variables))
				{
					continue;
				}

				if(isset($this->input[$var]))
				{
					if($type == "int" && $this->input[$var] != "lastposter")
					{
						$this->input[$var] = intval($this->input[$var]);
					}
					else if($type == "a-z")
					{
						$this->input[$var] = preg_replace("#[^a-z\.\-_]#i", "", $this->input[$var]);
					}
				}
			}
		}
	}
Soporte en Español

[Image: signature.png]

Discord at omar.gonzalez (Omar G.#6117); Telegram at @omarugc;
Reply
#7
Very good info I'm going to take a deeper look to see what else is sanitized.

In this case the variable I am looking for can be either an iD or a string
Reply
#8
Can you post the whole code?
-Paul H.

Cogisne lingua latina?
Reply
#9
You will need to use a different key then ('con' will work).
Soporte en Español

[Image: signature.png]

Discord at omar.gonzalez (Omar G.#6117); Telegram at @omarugc;
Reply
#10
Yup went with a different key. Can't post while code yet, it's just part of the content delivery system
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)