Banner
Views: 236,761,653
Time: 2013-05-25 05:55:38 PM
26 users online: Alcaro, AxemJinx, o Camerin, cyphermur9t, Disco, Donaldthescotishtwin, o Doopy Buckride, EvilGuy0613, Falconpunch, Ice Man, o iRhyiku, Jack Kitetsu, o K3fka, LimeMaster92, Lui37, Masterlink, o MVS, phenolatukas, Purple Rex, RaindropDry, Reaper, o ShadowPhoenix, shreerocks1324, Sokobansolver, Tarek701, Usetheforce - Guests: 44 - Bots: 9Users: 22,892 (1,288 active)
Latest: dragon8371
Tip: Create a thread for your hack in the Works in Progress once you have enough screenshots/videos to show.
Strange stuff in $_GET
Forum Index - Hobbies - Computers & Technology - Strange stuff in $_GET
Pages: « 1 »
One of my friends found a way to inject mistyped data into $_GET, which I was able to simplify to this.
Is there any way to get rid of that and limit $_GET (and $_POST/$_COOKIE) to strings only without using is_array on every single item in them?
This is done on purpose so that you can get collections of data from check boxes and such. As far as I know, it can not be disabled.
Alcaro, just use is_array() to check if $_GET/$_POST/$_COOKIE variable is array. You cannot turn off this behavior, but it's useful sometimes... such as during multi-uploads of HTML5. Or you can do something like this:

Code
<?php foreach($_GET as &$variable){ if(is_array($variable)){ unset($variable); } }
The problem is that I've got many forms and $_GET parameters, and adding that code in each of my scripts would quickly drive me crazy. I want a way to get rid of them without editing all of my scripts.
Hack and recompile PHP yourself then I guess? Outside of that there is not much else you can do. Maybe a global include I suppose? But that is about it as far as I know.
Last edited on 2011-07-26 03:53:29 PM by p4plus2.
auto_prepend_file or something is probably the best method.
Sometimes PHP annoys me.
This is an intentional feature. If you use the values as strings, they will be implicitly cast to a string of the value "Array". You can explicitly do this by prepending the variable name with (string).

I don't really see what the problem is.
The problem is that this implicit type casting throws warnings.
Some of PHP's "features" makes me think someone has been drunk.
No it doesn't.
Huh. It does for me. Maybe it changed in PHP 5.3?
Note to self: Find a way to get rid of 5.2 somehow.
It shouldn't in PHP 5.2, either. How exactly are you using the variable?
Code
if ($_GET["chan"]!="serioushax") { //irrelevant junk }
Code
echo "The channel is #",$_GET["chan"];

(The exact codes are slightly different since I don't have access to the real ones on this phone, but I am using very similar constructions.)
Are you doing it differently? If no, maybe show_errors is doing something weird.
That really shouldn't cause any warnings. You should probably double check what the actual cause is.

The only thing I can think of is if you try to access single characters in strings using bracket notation ($var[0] or $var{0}), because they will be treated as array element keys for arrays. It's pretty easy to overcome this by simply using substr($var, 0, 1) instead.

Edit: You never told me what the exact error message is anyway.
Last edited on 2011-07-30 04:56:16 PM by Kieran Menor.
After a discussion on the IRC, this problem is solved. strpos and htmlentities are whinier than the rest if they get oddly typed input. An explicit typecast isn't the perfect solution (I will need to modify some of my scripts), it's good enough.
Pages: « 1 »
Forum Index - Hobbies - Computers & Technology - Strange stuff in $_GET

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2013 - SMW Central
Legal Information - Link To Us


Total queries: 29

Menu