On Sat, May 13, 2006 2:20 pm, Ryan A wrote:
> Been reading some other code that I got from the net,
> and  have come across some wierd looking code, would
> appreciate it if someone could explain it to me:
>
> $hits = array();
> $bytes = array();
> $blocked = array();
> $baps = array();
> $bapm = array();
>
> So far so good.... then further down:
>
> // Add to the running totals
> @$hits["$username|$subnet"]++;
> @$bytes["$username|$subnet"]+=$byte;
> @$baps["$username|$subnet|$this_second"]++;
> @$bapm["$username|$subnet|$this_minute"]++;

@ is suppressing the E_NOTICE error message that the variables are not
pre-set.

This is BAD if register_globals is ON as it means that somebody would
use:
http://example.com/example.php?hits[user|192.168]=10000
to forge the hit counters

The rest of it is just funky array indexes, and the ++ operator to add
1 to each thingie.

Homework:
http://www.php.net/manual/language.operators.errorcontrol.php

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to