Re: [PHP] What's your game? (X-PHP)

2010-04-27 Thread Programming Guides
On Tue, Apr 27, 2010 at 7:37 AM, Richard Quadling
wrote:

> On 26 April 2010 19:54, Williams, Dewey  wrote:
> > The only online games I play are Guild Wars and - now - Dungeons and
> > Dragons Online (FREE!).  I haven't played vgaplanets in ages - too few
> > servers to get a decent game. Not certain I can even install my original
> > 3.5 inch disk anymore!
> >
> > Dewey Williams
> >
> >> -Original Message-
> >> From: tedd [mailto:t...@sperling.com]
> >> Sent: Sunday, April 25, 2010 9:16 AM
> >> To: php-general@lists.php.net
> >> Subject: [PHP] What's your game? (X-PHP)
> >>
> >> Hi gang:
> >>
> >> Considering we recently had several people mention what games they
> >> play, it might be interesting to see what everyone plays.
> >>
> >> As for me, I currently play "Modern Warfare 2" on XBOX. It's the most
> >> recent in a long line of war games (i.e., Call of Duty, Ghost Recon,
> >> etc.).
> >>
> >> My gamer tag is "special tedd"
> >>
> >> What's your game?
> >>
> >> Cheers,
> >>
> >> tedd
> >>
> >>
> >> --
> >> ---
> >> http://sperling.com  http://ancientstones.com  http://earthstones.com
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> I also like Ico and Shadow Of The Colossus, both on PS2.
>
> I bought the PS2 because of Ico.
>
> I'll probably buy a PS3 because of the next game they are making in
> the same style.
>
>
>
>
> --
> -
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I've played and still play StarCraft: Brood War a lot. StarCraft 2 is now
available for pre-order and the beta is active. I'm looking forward to it
but I'm not looking forward to how much time I'll sink into it :)

-- 
Viktor
http://programming-guides.com


Re: [PHP] What's your game? (X-PHP)

2010-04-27 Thread Programming Guides
On Tue, Apr 27, 2010 at 8:27 AM, Dan Joseph  wrote:

> On Tue, Apr 27, 2010 at 9:24 AM, Programming Guides <
> programming.gui...@gmail.com> wrote:
>
> > I've played and still play StarCraft: Brood War a lot. StarCraft 2 is now
> > available for pre-order and the beta is active. I'm looking forward to it
> > but I'm not looking forward to how much time I'll sink into it :)
> >
> > --
> > Viktor
> > http://programming-guides.com
> >
>
>
> I am amazed at how long Starcraft has lasted, and how popular it still is.
> Is the MMORPG version Starcraft 2?  Or is that yet another one?
>
>
> --
> -Dan Joseph
>
> www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
> Code "NEWTHINGS" for 10% off initial order
>
> http://www.facebook.com/canishosting
> http://www.facebook.com/originalpoetry
>

It's not an MMO; it's still an RTS. It's just new graphics, new interface,
some rebalancing and a continuation of the storyline.

-- 
http://programming-guides.com


Re: [PHP] auto indentation

2010-04-27 Thread Programming Guides
On Tue, Apr 27, 2010 at 6:00 PM, D. Dante Lorenso  wrote:

> On 4/27/2010 3:55 PM, Ashley Sheridan wrote:
>
>> On Tue, 2010-04-27 at 16:33 -0400, David McGlone wrote:
>>
>>> Hi everyone.
>>> I got a quickie LOL
>>> is there a way to auto indent code. I'm using Kate and I have it set so
>>> the
>>> tab is only 4 spaces, but I was wondering if there was an easier way than
>>> to
>>> have to hit the tab key 1x then 2x then 3x then 2x then 1x to create nice
>>> laid
>>> out code like this:
>>>
>>
> I use PHPEclipse for this.  It's not Eclipse with PDT, it's PHP Eclipse:
>
> http://www.phpeclipse.com/
>
> The code formatter built into that formats my code when I hit Ctrl+Shift+F.
>  No other code formatter works as well for what I've found.  Many formatters
> just indent, this one will reformatt by putting brackets up or down, and
> reindent all the code to fit my coding standards.
>
> Project is getting a little old, though and doesn't yet support PHP 5.3
> syntax, but it's still the best I've found.
>
> -- Dante
>
> --
> D. Dante Lorenso
> da...@lorenso.com
> 972-333-4139
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
vim ftw:

1. select the piece of code you want to indent (or select all with "ggVG")
2. Hit =
3. profit!

-- 
http://programming-guides.com


Re: [PHP] auto indentation

2010-04-27 Thread Programming Guides
On Tue, Apr 27, 2010 at 9:15 PM, Paul M Foster wrote:

> On Tue, Apr 27, 2010 at 08:52:09PM -0500, Programming Guides wrote:
>
> > On Tue, Apr 27, 2010 at 6:00 PM, D. Dante Lorenso 
> wrote:
> >
> > > On 4/27/2010 3:55 PM, Ashley Sheridan wrote:
> > >
> > >> On Tue, 2010-04-27 at 16:33 -0400, David McGlone wrote:
> > >>
> > >>> Hi everyone.
> > >>> I got a quickie LOL
> > >>> is there a way to auto indent code. I'm using Kate and I have it set
> so
> > >>> the
> > >>> tab is only 4 spaces, but I was wondering if there was an easier way
> than
> > >>> to
> > >>> have to hit the tab key 1x then 2x then 3x then 2x then 1x to create
> nice
> > >>> laid
> > >>> out code like this:
> > >>>
> > >>
>
> 
>
> > vim ftw:
> >
> > 1. select the piece of code you want to indent (or select all with
> "ggVG")
> > 2. Hit =
> > 3. profit!
>
> +1 for vim
>
> I use a limited number of "g" commands, like gg, G and gwap, but I use
> them rotely; I've never understood the variations. Can you point me to
> some sort of tutorial on these?
>
> Paul
>
>
> --
> Paul M. Foster
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I gotta say I dont understand the "g" commands very well either. They dont
seem to have much in common, and I, like yourself know a handful that I am
comfortable using. In any case, this cheat sheet has several "g" commands
(although I commonly use some that are not listed):

http://www.fprintf.net/vimCheatSheet.html

-- 
Viktor
http://programming-guides.com


Re: [PHP] Security/Development Question

2010-04-28 Thread Programming Guides
On Wed, Apr 28, 2010 at 4:02 PM, Andre Polykanine  wrote:

> Hello David,
>
> I'm not a PHP god but I would never ever do such things.I can't even
> imagine what can be the reason of passing an SQL query through a
> form...
> --
> With best regards from Ukraine,
> Andre
> Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @
> jabber.org
> Yahoo! messenger: andre.polykanine; ICQ: 191749952
> Twitter: m_elensule
>
> - Original message -
> From: David Stoltz 
> To: php-general@lists.php.net 
> Date: Wednesday, April 28, 2010, 11:54:56 PM
> Subject: [PHP] Security/Development Question
>
> Hi folks,
>
>
>
> This isn't really a PHP question per se, but could apply to any
> language...
>
>
>
> I have a public facing web server, which we have a software component
> that helps protect us from SQL Injection, and the like.
>
>
>
> We recently have added a very small web application that is vendor
> supported. They said it's not working, so I investigated. I found that
> our software protection was blocking their pages because they are
> actually passing entire SQL queries in their form POSTs. Now, the app is
> SSL protected, and they claim the queries are not executed - only
> inserted into the database to be used later. They also said it's
> protected by the ASP.NET framework authenticationnot sure about any
> of that.
>
>
>
> My concern is passing SQL queries in this way is not best practice - am
> I wrong? Please let me know how you would react to this?
>
>
>
> See below for the stuff they are passing in the POST (obvious things
> like table names have been changed):
>
>
>
> /wEWBQLciq6UBwLEhISFCwLa2223bD3wK3+56LBAKc37iSDEsHMFjpB6o1vHld19wT+Tt3sY
> 8E&CRITICAL_RESULT&on&Declare @critical varchar (40)
>
> set @critical = (select top 1 code from table where id = 'clr7' and
> thename = 'critical')
>
>
>
> sELECT
>
>  OPR_SECD.REC USER_REC_NO,
>
>  RESULT.*,
>
>  (SELECT RESULT_DESC FROM table WHERE code = RESULT.RES_MSTR_CODE)
> [DESC],
>
>  [ORDER].*,
>
>  (SELECT VALUE FROM table WHERE this_CODE = 'Email' AND USER_REC =
> OPR_SECD.RECNUM) MBMD_EMAIL,
>
>  OPR_SECD.OPR_INITIAL
>
>  FROM RESULTING LEFT JOIN [ORDER] ON RESULTING.ORDER_REC =
> [ORDERBY].RECNUM
>
>  LEFT JOIN OPR_SECD ON [ORDER].DR_CODE = OPR_SECD.XREF_CODE
>
>  where (RESULT.FLAG_TEXT) = @critical  AND RESULT.REC = @ID&Save
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I can't say that I agree with this design but it is certainly possible to
prevent against crafted POST data. I think in your particular case they
might be doing that judging by the presence of the hash at the beginning of
the POST data (although that could be anything... I'm just guessing).

A general way to prevent against crafted POST data is to have a session or
even a page secret key. The key is hashed with the value which is then
written to the (I suppose) hidden form field. When the POST data comes back
it's hashed with the key and checked against the hash in the POST. So.. yes
it's possible to prevent from crafting the POST data but the design is still
crappy; I wouldn't do it.

-- 
Viktor
http://programming-guides.com


Re: [PHP] multi dimensional array question

2010-05-01 Thread Programming Guides
On Fri, Apr 30, 2010 at 7:33 PM, Nick Balestra  wrote:

> thanks Piero!
>
> i was trying to solve an excercise on "learning php5" (O'reilyl) book.
>
> I am happy abotut his solution with the array_sum funtion you suggested,
> and my multidimensional array make much more sense to mee then they
> suggested solution that also much more line of code comapred...
>
> look: my solution (with Piero suggeston): and ont he bottom the book
> solution. what do u say is the best one? why? i am learning so i am
> interested in understanding why a solution can be better then an other...
>
> $us_census = array('NY' => array('New York' => 8008278),
>   'CA' => array('Los Angeles' => 3694820,
> 'San Diego'
> => 1223400),
>   'IL' => array('Chicago' => 2896016),
>   'TX' => array('Houston' => 1953631,
> 'Dallas' =>
> 1188580,
> 'San
> Antonio' => 1144646),
>   'PA' => array('Philadelphia' => 1517550),
>   'AZ' => array('Phoenix' => 1321045),
>   'MI' => array('Detroit' => 951270));
>
>
>
> print
> "StateCityPopulationTotal";
>
>
> foreach ($us_census as $state => $cities) {
>
> foreach ($cities as $city => $habitants){
>
> $tothabitants += $habitants;
>
>print
> "$state$city$habitants";
>}
>}
>
> print "$tothabitants";
>
>
> foreach ($us_census as $state => $cities) {
> $population_per_state = array_sum($cities);
> print "$state $population_per_state";
> }
>
> --
> the book solution:
>
>
> $population = array('New York' => array('state' => 'NY', 'pop' => 8008278),
> 'Los Angeles' => array('state' => 'CA', 'pop' => 3694820),
> 'Chicago' => array('state' => 'IL', 'pop' => 2896016),
> 'Houston' => array('state' => 'TX', 'pop' => 1953631),
> 'Philadelphia' => array('state' => 'PA', 'pop' => 1517550),
> 'Phoenix' => array('state' => 'AZ', 'pop' => 1321045),
> 'San Diego' => array('state' => 'CA', 'pop' => 1223400),
> 'Dallas' => array('state' => 'TX', 'pop' => 1188580),
> 'San Antonio' => array('state' => 'TX', 'pop' => 1144646),
> 'Detroit' => array('state' => 'MI', 'pop' => 951270));
>
> $state_totals = array( );
> $total_population = 0;
> print "CityPopulation\n";
> foreach ($population as $city => $info) {
>
>
> $total_population += $info['pop'];
>
> $state_totals[$info['state']] += $info['pop'];
> print "$city, {$info['state']}{$info['pop']}\n";
> }
>
> foreach ($state_totals as $state => $pop) {
> print "$state$pop\n";
> }
> print "Total$total_population\n";
> print "\n";
>
>
>
>
>
I actually prefer your solution - it's easier to read and understand. On the
other hand the solution the book offers has the advantage of being more
extensible in that more pieces of information can be added per city.

One thing I dont like about both solutions is that they both intertwine
computation logic with presentation. A *much* better approach in this case
is to first calculate all population data you need and put together one data
structure that has all of that. Only after you have that ready do you begin
to output HTML. And while outputting HTML the only PHP you should need is to
iterate over your data structure and output.

-- 
http://programming-guides.com