Re: Wierd ass code...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux