Re: [PHP] framework or not

2013-10-26 Thread Robert Cummings

On 13-10-24 09:41 PM, Larry Garfield wrote:

On 10/23/2013 08:51 AM, Jay Blanchard wrote:

[snip] a bitter rant[/snip]

Dang Larry - bad night?


That wasn't a bitter rant.  You haven't seen me bitter. :-)  That was
tough love to the OP.  I don't see a reason to pussyfoot around the
original question, which is one that comes up about once a month.  The
answer is always the same: How much is your time worth?


Basic math...

Life: finite
Time: infinite

finite / infinite = 0

*sniffle*

Oh wait... you meant in the smaller scheme of things :)

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] framework or not

2013-10-23 Thread Robert Cummings

On 13-10-22 05:38 PM, Larry Garfield wrote:

If you need more convincing, I will cite Fred Brooks:

http://www.cs.nott.ac.uk/~cah/G51ISS/Documents/NoSilverBullet.html


Excellent article, thanks for the pointer. So many assertions have stood 
the test of time thus far.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Static utility class?

2013-09-05 Thread Robert Cummings

On 13-09-04 09:06 PM, Micky Hulse wrote:

Hi Rodrigo, thanks for the help, I really appreciate it!

On Wed, Sep 4, 2013 at 5:55 PM, Rodrigo Santos
rodrigos.santo...@gmail.com wrote:

Hi, first, sorry for the bad English.


Not bad at all! Very clear and well written reply (heck, it's better
than my native English writing), so thank you! :)


Yes, at least, as far as I know, this is the perfect way to do what you want
to do. Think like this: when you instanciate a class, you are allocating
memory. If you don't need any information stored, then you don't need to
allocate memory, right? So, it's is logic to have a class that you will call
only one fragment when you need it, rather than load the entire class just
for one method.


Interesting! That makes a lot of sense.

Now you've piqued my interests! :)

I was going to head down a different path, but you've inspired me to
further explore the use of static methods/properties/variables/other.

A part of me just wants to learn more about PHP OOP, and using static
members is something I've not explored much. Seems like a simple
functional utility class would be a good time to play and learn more.
:D


Just be careful to organize your utility methods by by meaning. Don't put a
method that make dating stuff and a method that write a random string in the
same class. By doing so, you are breaking the object orientation purpose.


Excellent tip! Thank you Rodrigo! I really appreciate the tips/advice
and inspiration. :)


I'll second Rodrigo's opinion, but would like to comment that the name 
of the class is misleading since it's called Singleton. The singleton 
pattern is used when you only ever want one instantiation of a class. In 
your case you are using static methods, the object never needs to be 
instantiated and so it doesn't fit this pattern. What you are creating 
is far more consistent with the utility pattern.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Static utility class?

2013-09-05 Thread Robert Cummings

On 13-09-05 02:27 PM, Micky Hulse wrote:

On Wed, Sep 4, 2013 at 11:07 PM, Robert Cummings rob...@interjinn.com wrote:

I'll second Rodrigo's opinion, but would like to comment that the name of
the class is misleading since it's called Singleton. The singleton pattern
is used when you only ever want one instantiation of a class. In your case
you are using static methods, the object never needs to be instantiated and
so it doesn't fit this pattern. What you are creating is far more consistent
with the utility pattern.


Ahhh, thanks so much for the clarification and details! That's very helpful.

I've updated my gist to reflect the pattern name:

https://gist.github.com/mhulse/6441525

Much appreciated. :)


Probably sufficient (and easier for typing) to just call it Utility 
since it follows the pattern but isn't the pattern itself :)


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] exec and system do not work

2013-08-26 Thread Robert Cummings

On 13-08-25 11:41 PM, Ethan Rosenberg wrote:

Dear List -

I'm lost on this one -

This works -

$out = system(ls -l ,$retvals);
printf(%s, $out);

This does -

echo exec(ls -l);

This does not -

if( !file_exists(/var/www/orders.txt));
{
 $out = system(touch /var/www/orders.txt, $ret);
 $out2 = system(chmod 766 /var/www/orders.txt, $ret);
 echo 'file2br /';
 echo file_exists(/var/www/orders.txt);
}

and this does not -

if( !file_exists(/var/www/orders.txt));
{
 exec(touch /var/www/orders.txt);
 exec(chmod 766 /var/www/orders.txt);
 echo 'file2br /';
 echo file_exists(/var/www/orders.txt);
}

Ethan


Hi Ethan,

Is there a reason you're using shell commands to achieve the following:

?php

$path = '/var/www/orders.txt';
if( !file_exists( $path ) )
{
if( !touch( $path ) )
{
echo 'Failed to touch file into existence: '.$path.\n;
}
else
{
if( !chmod( $path, 0766 ) )
{
echo 'Failed to update file permissions: '.$path.\n;
}
}
}

?

Also, why are you setting the executable bit on a text file? :)

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] How can I submit more than 2000 items of data?

2013-08-19 Thread Robert Cummings

On 13-08-19 11:32 AM, Stuart Dallas wrote:

On 19 Aug 2013, at 16:24, Matijn Woudt tijn...@gmail.com wrote:


You might want to explain how you convert form data to JSON without javascript?


PHP can do it. Ruby can do it. .NET can do it. Just because you want to use 
JSON in a web browser where Javascript is the go-to method, doesn't mean JSON 
requires Javascript.

-Stuart



Yes, of course they can do it, but then you first need to submit the POST data 
(which he could not do because of the above). Javascript is more or less the 
only way to do it (yes I know Flash….)


I wasn't speaking to his specific issue as that was solved by an earlier 
response. I was just commenting that the implied intrinsic link between JSON 
and Javascript in what he had said does not exist.


Your post didn't in anyway indicate that your response had nothing to do 
with his problem:


I know you've had the right answer, but I think it's worth
 pointing out that use of JSON in no way requires Javascript,
 despite its name.

As such, given the requirement of POSTing over HTTP(S) and that 
JavaScript is almost certainly more frequently used than ActionScript, I 
think a JSON based solution was at least 50% linked to JavaScript.


:)

Cheers,
Rob
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Finally....

2013-08-16 Thread Robert Cummings

On 13-08-16 11:58 AM, Marc Guay wrote:

Those Belgacom emails were the only thing keeping me from a crushing
loneliness - undo!


*sniffle* Another friend bites the dust *sniffle*.


--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] POST action

2013-08-01 Thread Robert Cummings

On 13-08-01 05:14 PM, Paul M Foster wrote:

On Thu, Aug 01, 2013 at 02:35:04PM -0500, Larry Garfield wrote:

[snip]



So you're writing your own form tags for each specific time you need
a form, or you wrote your own form builder API that is writing the
form tags for you?


Unless my wife creates the form in Dreamweaver, I write the HTML for the
form fields. Even when she does, I add the proper code to validate each
field and the form overall, using my field validation class, etc.



Because if the former, I claim it's insecure.  The development
process is insecure, so you will screw up sooner or later.  You're
only human.


A-ha! That's where you're wrong, Matey! For I am SUPER-CODER! Faster
than a speeding 300 baud modem! More powerful than a teletype! Able
to leap tall procedural functions at a single bound! With my pocket
protector and trusty slide rule, I defend the indefensible and champion
the cause of spaghetti code!

So there! ;-P


I often get paid to fix such code... keep up the questionable 
methodologies ;)


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] POST action

2013-07-28 Thread Robert Cummings

On 13-07-28 01:14 PM, iccsi wrote:

form action=action.php method=post
  pYour name: input type=text name=name //p
  pYour age: input type=text name=age //p
  pinput type=submit //p
/formIn the PHP tutorial manual, it says that we can have post action to
the form itself just like above coding.I would like to know in the real
projects, can we have action to the same PHP file, since that we only need
have one filebut not 2 files foe POST request,Your help and information is
great appreciated,regards,Iccsi,


From my experience, I would suggest that you ALWAYS post back to the 
same URL. All forms I've seen that post to a different target have 
issues when validation fails and they suddenly need to go back to the 
original form-- they tend to implement weird and not so wonderful 
techniques to get back to that form while preserving the posted data in 
the session or something. If they try to go back at all... some just say 
fail and tell you to hit your browser's back button.


Leaving the action attribute empty should cause the browser to post back 
to the same URL without you needing to re-iterate it programmatically in 
the action attribute.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] POST action

2013-07-28 Thread Robert Cummings

On 13-07-28 01:51 PM, Jim Giner wrote:


On 7/28/2013 1:38 PM, Ashley Sheridan wrote:

On Sun, 2013-07-28 at 13:37 -0400, Jim Giner wrote:

On 7/28/2013 1:26 PM, Larry Garfield wrote:

On 07/28/2013 12:14 PM, iccsi wrote:

form action=action.php method=post
pYour name: input type=text name=name //p
pYour age: input type=text name=age //p
pinput type=submit //p
/formIn the PHP tutorial manual, it says that we can have post
action to the form itself just like above coding.I would like to know
in the real projects, can we have action to the same PHP file, since
that we only need have one filebut not 2 files foe POST request,Your
help and information is great appreciated,regards,Iccsi,


Real projects to all kinds of things.  Which is best depends on who
you ask. :-)

I would argue that there's 3 good approaches, both of which are viable:

1) Define your form abstractly via an API, and have the API detect the
presence of POST request and then process the form after it's built.
That means you do submit back to the same URL.  (Drupal 7 and earlier do
this.)

2) Put 2 separate request handlers / controllers at the same path, one
for GET and one for POST.  So you submit back to the same URL but an
entirely different piece of code responds to it.  (This requires a good
routing system that can differentiate between GET and POST.)

3) Every form is defined as its own object somewhere with a unique ID.
All forms post to the same URL but include the form ID.  Code at that
URL looks up the form object by ID and maps the submitted data to it to
know what to do with it.

Note that in all 3 cases you're defining a form via an API of some
kind.  You are not writing form tags yourself.  Don't do that. Ever.  I
promise you that you will have a security hole or six if you do.  Use a
good form handling API for building forms.  That's what good Real
projects do.  There are a lot out there.  Most fullstack frameworks or
CMSes have one built in (I know Drupal and Code Ignighter do, although
they're quite different), and there are reasonably stand-alone
components available in both Symfony2 Components and Zend Framework.
Please don't write your own.  There are too many good ones (and even
more bad ones, of course) already out there that have been security
hardened.

--Larry Garfield

Never write your own form?  I'm guilty - oh, so guilty.  What exactly is
a 'security hardened' form?

IN answer to OP - yes you can use a single script to handle your from
return.  I do that too!  I start by recognizing my first time thru and
send out a form/page.  I process the submit back from that page, doing
something based on the label of the submit button that I detect.  I may
then do some more processing and produce a newer version of the same
form/page and repeat.  Or I may end it all at that point.  Depends on
what the overall appl is doing.

And now I'll watch and see how much I'm doing wrong.



I don't think there's anything inherently wrong with writing your own
form processing code, as long as you understand what's going on. Many
frameworks do make this a lot easier though, but sometimes I find it
encourages you to ignore some of the details (like security) because
you know the framework handles that stuff.

I would say code forms on your own first, as a learning experience,
then use frameworks once you know what you're doing.

Thanks,
Ash
http://www.ashleysheridan.co.uk



I dont' know that i'll ever use a framework.  Strictly an
ex-professional here doing my own website stuff.  As you say 'code your
own forms first as a learning experience'.  Well, once I've coded them
(aside: I think you mean 'process', not code) and learned how to do it
right, why should I give up that task and pick up a framework?


Chances are, once you've done this yourself and abstracted away the 
implementation details, you have your own framework for performing this 
generally tedious task :)


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] From 24/7/2013 to 2013-07-24

2013-07-26 Thread Robert Cummings

On 13-07-26 11:42 AM, jomali wrote:

On Fri, Jul 26, 2013 at 5:18 AM, Karl-Arne Gjersøyen karlar...@gmail.comwrote:


Below is something I try that ofcourse not work because of rsosort.
Here is my code:
---
$lagret_dato = $_POST['lagret_dato'];
 foreach($lagret_dato as $dag){

 $dag = explode(/, $dag);
rsort($dag);
 $dag = implode(-, $dag);
 var_dump($dag);

What I want is a way to rewrite contents of a variable like this:

 From 24/7/2013 to 2013-07-24

Is there a way in PHP to do this?

Thank you very much.

Karl



$conv_date = str_replace('/', '-','24/7/2013');
echo date('Y-m-d', strtotime($conv_date));
Result: 2013-07-24


It would be better if you reformatted first since this is ambiguous when 
you have the following date:


6/7/2013

Here's a completely unambiguous solution:

?php

$old = '24/7/2013';

$paddy = function( $bit ){ return str_pad( $bit, 2, '0', 
STR_PAD_LEFT ); };
$new = implode( '-', array_map( $paddy, array_reverse( explode( 
'/', $old ) ) ) );


echo $new.\n;

?

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] From 24/7/2013 to 2013-07-24

2013-07-26 Thread Robert Cummings

On 13-07-26 04:38 PM, jomali wrote:

On Fri, Jul 26, 2013 at 1:08 PM, Robert Cummings rob...@interjinn.comwrote:


On 13-07-26 11:42 AM, jomali wrote:


On Fri, Jul 26, 2013 at 5:18 AM, Karl-Arne Gjersøyen karlar...@gmail.com

wrote:


  Below is something I try that ofcourse not work because of rsosort.

Here is my code:
---
$lagret_dato = $_POST['lagret_dato'];
  foreach($lagret_dato as $dag){

  $dag = explode(/, $dag);
 rsort($dag);
  $dag = implode(-, $dag);
  var_dump($dag);

What I want is a way to rewrite contents of a variable like this:

  From 24/7/2013 to 2013-07-24

Is there a way in PHP to do this?

Thank you very much.

Karl



$conv_date = str_replace('/', '-','24/7/2013');
echo date('Y-m-d', strtotime($conv_date));
Result: 2013-07-24



It would be better if you reformatted first since this is ambiguous when
you have the following date:

 6/7/2013




Here's a completely unambiguous solution:

?php

 $old = '24/7/2013';

 $paddy = function( $bit ){ return str_pad( $bit, 2, '0', STR_PAD_LEFT
); };
 $new = implode( '-', array_map( $paddy, array_reverse( explode( '/',
$old ) ) ) );

 echo $new.\n;

?

Cheers,
Rob.


The original question was  about reformatting a European (Day/Month/Year)
date. Your solution does not address this problem. Mine assumes the
European date format explicitly.


Jomali,

Your solution is broken. The original poster requested the following:

 What I want is a way to rewrite contents of a variable like this:

   From 24/7/2013 to 2013-07-24

Your solution makes use of the strtodate(). A useful strategy EXCEPT (as 
you have already noted) the date follows the European formatting rules 
of dd/mm/ since the 24 as the first number makes that obvious. 
HOWEVER, you failed to realize the following (from the PHP online manual):


Dates in the m/d/y or d-m-y formats are disambiguated by looking
at the separator between the various components: if the separator
is a slash (/), then the American m/d/y is assumed; whereas if
the separator is a dash (-) or a dot (.), then the European d-m-y
format is assumed.

And so, as soon as an abiguous date arises, the solution will be 
incorrect because strtotime() will presume an American format due to the 
appearance of the slash instead of the hyphen. It is dangerous to rely 
on magical functions like strtotime() unless you completely understand 
how ambiguity is resolved.


Another solution that was posted only re-ordered the elements and you 
likely noticed that there is a single digit 7 in the source date and in 
the response date it has been 0 padded to conform to the standard 
-mm-dd date format. The other solution does not do this and so it is 
also incorrect.


And so it follows, that my solution, thus far, is the only solution 
posted that actually meets the requirements. Why you think my solution 
does not perform is beyond me since a simple run of the code would 
output the correct answer (yes I did test)-- mine also presumes the 
European ordering for all input with components separated by a slash.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] From 24/7/2013 to 2013-07-24

2013-07-26 Thread Robert Cummings

On 13-07-26 05:33 PM, Jim Giner wrote:

On 7/26/2013 5:29 PM, Robert Cummings wrote:

And so it follows, that my solution, thus far, is the only solution
posted that actually meets the requirements. Why you think my solution
does not perform is beyond me since a simple run of the code would
output the correct answer (yes I did test)-- mine also presumes the
European ordering for all input with components separated by a slash.

Cheers,
Rob.



And my solution doesn't work?



I don't see any padding happening in your solution. Your solution produced:

2013-7-24

The required solution is:

2013-07-24

:)

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Re: Programmers and developers needed

2012-09-19 Thread Robert Cummings

On 12-09-19 06:07 AM, Matijn Woudt wrote:

On Wed, Sep 19, 2012 at 11:53 AM, German Geek geek...@gmail.com wrote:

See below.

On 19 September 2012 04:45, Matijn Woudt tijn...@gmail.com wrote:


On Tue, Sep 18, 2012 at 8:52 AM, agbo onyador onya...@gmail.com wrote:

The growing power of the internet and global networks.
(on the world’s politics, economies and even on daily life of ordinary
people) Programmers and developers needed:


Thanks



I still cannot figure out if this is a joke or if you're really
looking for world peace.. If you're serious, you might want to stop
and take a look at Newton's third law, I quote from wikipedia:
When a first body exerts a force F1 on a second body, the second body
simultaneously exerts a force F2 = −F1 on the first body. This means
that F1 and F2 are equal in magnitude and opposite in direction., or
simplified To every action there is always an equal and opposite
reaction.
It fits also easily on humans, take one step into peace, and it will
have an effect in opposite direction elsewhere.

Also, why do you think you can make a better social network than the
already existing ones? Even the big internet giant Google can't seem
to make it's social network a big success, and you (without even an
concrete idea) can do that better?

You might as well just open a simple website with a 'Like' button and
ask everyone to like that page, so we end up with peace!:)



Seems like an interesting point. But who says that good and evil are always
cancelling each other out? To me good and evil depend on the point of view.
So, what's good for A could be good for B too but bad for C, and therefore
what's good for C is bad for both A and B? Not necessarily (following a
implies b is not equivalent to b implies a). It gets complicated very
quickly with more parties and we have more than 6 billion! One cannot really
say that an action is good or bad for everyone following your argument.
However, world peace, less pollution and equal or less diverse wealth would
be good for everyone, because of less crime and less risk of loosing
everything. Maybe it would trigger something bad at the other end of the
universe, but the universe is pretty big (so I've heard :-), so what do we
care? I vote for world peace in that sense.


Do I hear a vote for communism? That didn't really work out in the
past, so why would it now?


Not to say I'm all in for communism... but communism failed for the same 
reason capitalism is failing. Corruption!


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Re: Programmers and developers needed

2012-09-18 Thread Robert Cummings

On 12-09-18 02:12 PM, Matijn Woudt wrote:

On Tue, Sep 18, 2012 at 8:02 PM, Daevid Vincent dae...@daevid.com wrote:

-Original Message-
From: Matijn Woudt [mailto:tijn...@gmail.com]

You're missing the most important aspect of social networks.. Advertising.


Please tell me that is said sarcastically. Advertising is the cancer of the 
internet. There was a time when there weren't ad banners, interstitials, 
pop-ups, pop-unders, spam, and all the other bullshit you have to sift through 
on a daily basis.



No,  I was not meant to be sarcastic. You might find advertising to be
the cancer of the internet, think again. The internet would be pretty
much dead without ads, or would you rather pay $0.01 per Google search
query? $0.01 for each e-mail send, $0.01 for each news article you
want to read, etc, etc? (or more related, $0.01 for each facebook
message you want to send/read?)

In the end, good advertising means success, take the drop of facebook
shares because of the investors being worried about facebooks'
advertising possibilities.


History suggests the internet would be here without advertising since it 
originated without advertising, originally grew without advertising, and 
finally evolved into this mixed blessing we have today. There's plenty 
of greatness on the internet, there's also plenty of steaming piles of 
manure.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Re: Programmers and developers needed

2012-09-18 Thread Robert Cummings

On 12-09-18 02:38 PM, Jeff Burcher wrote:

-Original Message-
From: Robert Cummings [mailto:rob...@interjinn.com]
Sent: Tuesday, September 18, 2012 2:22 PM
To: Matijn Woudt
Cc: Daevid Vincent; PHP-General
Subject: Re: [PHP] Re: Programmers and developers needed

On 12-09-18 02:12 PM, Matijn Woudt wrote:

On Tue, Sep 18, 2012 at 8:02 PM, Daevid Vincent dae...@daevid.com

wrote:

-Original Message-
From: Matijn Woudt [mailto:tijn...@gmail.com]

You're missing the most important aspect of social networks..

Advertising.


Please tell me that is said sarcastically. Advertising is the cancer of the

internet. There was a time when there weren't ad banners, interstitials, pop-
ups, pop-unders, spam, and all the other bullshit you have to sift through on
a daily basis.




No,  I was not meant to be sarcastic. You might find advertising to be
the cancer of the internet, think again. The internet would be pretty
much dead without ads, or would you rather pay $0.01 per Google search
query? $0.01 for each e-mail send, $0.01 for each news article you
want to read, etc, etc? (or more related, $0.01 for each facebook
message you want to send/read?)

In the end, good advertising means success, take the drop of facebook
shares because of the investors being worried about facebooks'
advertising possibilities.


History suggests the internet would be here without advertising since it
originated without advertising, originally grew without advertising, and finally
evolved into this mixed blessing we have today. There's plenty of greatness
on the internet, there's also plenty of steaming piles of manure.

Cheers,
Rob.


Yeah, it grew out of government funding before advertising via educational

 institutions and the military. Would you rather have a free economy
 supported internet or a government controlled internet? Also, for those
 of us who are old enough to remember posting to text based bulletin 
boards,
 the influx of corporate money has greatly increased the 
infrastructure and
 functionality of the internet and has helped to make it a global 
phenomenon,
 which a government supported internet may have never become. Money 
makes all

things possible. If you don't think so, try building a server farm and

 hooking up to a trunk line without it. My two cents. Now, I'm broke.

You're making me wax philosophical... Money doesn't make all things 
possible. Time and energy make all things possible. Money is just a 
convenient placeholder for time and energy.


At any rate, you're making the assumption that advertising was a 
necessary ingredient. It was not... nor does it's absence guarantee a 
government controlled internet. You have a logical fallacy in your 
argument above, but I'm too lazy to look up which one (or which ones), 
but I can smell it (them) ;)


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Programmers and developers needed

2012-09-14 Thread Robert Cummings

On 12-09-13 06:10 PM, Ashley Sheridan wrote:

On Thu, 2012-09-13 at 16:48 -0400, Tedd Sperling wrote:


On Sep 13, 2012, at 3:45 AM, agbo onyador onya...@gmail.com wrote:


Hello there! We are looking for programmers and developers to create a
world wide system. Your comments are welcome.


Wow!

I'm looking for world wide money.


tedd



Join the queue...


There's a queue? Bah humbug... I've been waiting for delivery all this time.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Programmers and developers needed

2012-09-13 Thread Robert Cummings

On 12-09-13 08:44 AM, Matijn Woudt wrote:

On Thu, Sep 13, 2012 at 2:12 PM, Steven Staples sstap...@mnsi.net wrote:

From: Tim Dunphy [mailto:bluethu...@gmail.com]
Sent: September 13, 2012 7:26 AM


We are looking for programmers and developers to create a world wide

system.

Is it bigger than a bread box?


Will it blend?



Sure, if you find a big enough blender ;)


There's a big one at the center of our galaxy :D

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] extract Occurrences AFTER ... and before -30-

2012-08-20 Thread Robert Cummings

On 12-08-21 12:32 AM, John Taylor-Johnston wrote:




This is usually a first-year CS programming problem (word frequency
counts) complicated a little bit by needing to extract the text.
You've started off fine, stripping tags, converting to lower case,
you'll want to either convert or strip HTML entities as well, deciding
what you want to do with plurals and words like you're, Charlie's,
it's, etc, also whether something like RFC822 is a word or not
(mixed letters and numbers).

When you've arranged all that, splitting on white space is trivial:

$words = preg_split('/[[:space:]]+/',$text);

and then you just run through the words building an associative array
by incrementing the count of each word as the key to the array:

foreach ($words as $word) {
  $freq[$word]++;
}

For output, you may want to sort the array:

ksort($freq);


That's awesome. Thanks!
Let me start with my first problem:

I want to extract All Occurrences of text AFTER News Releases and
before -30-.

http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html

How do I do that?

Yeah, I am still asking first year questions :)) Every project brings
new challenges.


You can use strpos() to find the location of News Releases then you 
can again use strpos() to find the location of -- 30 -- but you will 
want to feed strpos() an offset for matching -- 30 -- (specifically 
the position found for News Releases). This ensures that you only 
match on -- 30 -- when it comes after News Releases. Once you have 
your beginning and start offsets you can use substr() to create a 
substring of the interesting excerpt. Once you have the excerpt in hand 
you can go back to JTJ's recommendation above.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] extract Occurrences AFTER ... and before -30-

2012-08-20 Thread Robert Cummings

On 12-08-21 01:11 AM, Robert Cummings wrote:

On 12-08-21 12:32 AM, John Taylor-Johnston wrote:




This is usually a first-year CS programming problem (word frequency
counts) complicated a little bit by needing to extract the text.
You've started off fine, stripping tags, converting to lower case,
you'll want to either convert or strip HTML entities as well, deciding
what you want to do with plurals and words like you're, Charlie's,
it's, etc, also whether something like RFC822 is a word or not
(mixed letters and numbers).

When you've arranged all that, splitting on white space is trivial:

$words = preg_split('/[[:space:]]+/',$text);

and then you just run through the words building an associative array
by incrementing the count of each word as the key to the array:

foreach ($words as $word) {
   $freq[$word]++;
}

For output, you may want to sort the array:

ksort($freq);


That's awesome. Thanks!
Let me start with my first problem:

I want to extract All Occurrences of text AFTER News Releases and
before -30-.

http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html

How do I do that?

Yeah, I am still asking first year questions :)) Every project brings
new challenges.


You can use strpos() to find the location of News Releases then you
can again use strpos() to find the location of -- 30 -- but you will
want to feed strpos() an offset for matching -- 30 -- (specifically
the position found for News Releases). This ensures that you only
match on -- 30 -- when it comes after News Releases. Once you have
your beginning and start offsets you can use substr() to create a
substring of the interesting excerpt. Once you have the excerpt in hand
you can go back to JTJ's recommendation above.


Sorry... *YOU* are JTJ, but you trimmed the post including the 
responder's name (which you should leave intact when trimming). I defer 
(I think) to tamouse's recommendation above.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] APC expunge notices

2012-08-18 Thread Robert Cummings

On 12-08-17 05:22 PM, Nathan Nobbe wrote:

Hi everyone,

I'd like to see what other folks think about the idea of having APC provide
a E_WARNING or E_NOTICE when it has to expunge the cache.  Ideally, this
would include the amount of memory allocated in the error message.

The idea here is to provide system admins with information that

A. The cache had to be expunged
B. The amount of memory allocated when the cache had to be expunged

Right now, unless a close eye is kept, how is one to garner this
information.

Maybe, if the idea is interesting, it could be expanded to allow a user
defined callback method where custom behavior could be implemented.

Your feedback appreciated,


I like all of these ideas :)

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Need to have form protection techniques

2012-08-17 Thread Robert Cummings

On 12-08-17 10:15 AM, Tedd Sperling wrote:

On Aug 17, 2012, at 10:09 AM, Daniel Brown danbr...@php.net wrote:


On Fri, Aug 17, 2012 at 12:05 AM, Ansry User 01 yrsna.res...@gmail.com wrote:

I need to know the forms validity techniques for Php.


This will probably take a while to absorb, so you may need to
revisit this page several times:

http://oidk.net/php/know-the-forms-validity-techniques-for.php


No tedd, I'm sorry but the info in the link above is pretty much perfect.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Need to have form protection techniques

2012-08-17 Thread Robert Cummings

On 12-08-17 11:14 AM, Tedd Sperling wrote:

On Aug 17, 2012, at 10:42 AM, Robert Cummings rob...@interjinn.com wrote:

On Fri, Aug 17, 2012 at 12:05 AM, Ansry User 01 yrsna.res...@gmail.com wrote:

I need to know the forms validity techniques for Php.


This will probably take a while to absorb, so you may need to
revisit this page several times:

http://oidk.net/php/know-the-forms-validity-techniques-for.php


No tedd, I'm sorry but the info in the link above is pretty much perfect.

Cheers,
Rob.


Oh, to be serious on this list on Fridays is lost cause.

I keep forgetting Fridays are like April 1.


:D

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Need to have form protection techniques

2012-08-17 Thread Robert Cummings

On 12-08-17 10:59 AM, Al wrote:



On 8/17/2012 10:42 AM, Robert Cummings wrote:

On 12-08-17 10:15 AM, Tedd Sperling wrote:

On Aug 17, 2012, at 10:09 AM, Daniel Brown danbr...@php.net wrote:


On Fri, Aug 17, 2012 at 12:05 AM, Ansry User 01 yrsna.res...@gmail.com wrote:

I need to know the forms validity techniques for Php.


 This will probably take a while to absorb, so you may need to
revisit this page several times:

 http://oidk.net/php/know-the-forms-validity-techniques-for.php


No tedd, I'm sorry but the info in the link above is pretty much perfect.

Cheers,
Rob.


Looks to me as if it's been hacked.



I thought it was some intentional Friday entertainment!

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] PHP session variables

2012-08-15 Thread Robert Cummings

On 12-08-15 03:19 PM, Tedd Sperling wrote:

Rob:

Again thanks.

Sorry, I totally missed your point.

In my defense I commonly use the value returned from microtime() as a string and not as 
a float. The code that followed my microtime( false ); demo broke the string and 
recombined it into a float. So, when you said:

Please see the current signature for microtime():

mixed microtime ([ bool $get_as_float = false ] )

I looked at that and said to myself, Oh, I need to define it as 'false'  
because I was using it as a sting. I completely overlooked your point that microtime() 
could return a float and thus no need to work with it as a string -- duh!

The demo is fixed (I think):

http://www.webbytedd.com/b/timed1/

Thanks,

tedd



I only pointed it out because I used to do exactly the same thing :)

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] PHP session variables

2012-08-14 Thread Robert Cummings

On 12-08-14 10:41 AM, Tedd Sperling wrote:

On Aug 13, 2012, at 10:59 AM, Robert Cummings rob...@interjinn.com wrote:


On 12-08-10 04:42 PM, Tedd Sperling wrote:

On Aug 10, 2012, at 1:21 PM, Ege Sertçetin sertce...@itu.edu.tr wrote:


Hi. My question will maybe out of topic, I'm sorry.
How can you know that one way will be much slower than other one? I mean, how 
can I learn which function is faster before I test it?


Ege:

No your question is on topic.

This question should be asked on the list, so I'll present Q:A instead of 
answering privately

http://www.webbytedd.com/b/timed1/

The code is there -- if you have questions, please post them to the list.


Ted,

Please see the current signature for microtime():

mixed microtime ([ bool $get_as_float = false ] )

The optional paramter was added in PHP 5.0.0. I think it's safe to update your 
habits :)

Cheers,
Rob.


Rob:

Fixed.

Thanks -- my habits are always in a state of being updated -- just ask my wife.


I'm not sure if you're making a joke, but your changes have no effect. 
You've merely explicitly stated the optional parameter's default value. 
What I had meant was to change the following:


?php

$starttime = microtime();
$startarray = explode( , $starttime);
$starttime = $startarray[1] + $startarray[0];

?

To the following :)

?php

$starttime = microtime( true );

?

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Repeated New Object Requests

2012-08-13 Thread Robert Cummings

On 12-08-10 02:24 PM, Al wrote:


Off the subject a bit. What does PHP do with repeated new classes, e.g.
$mime = new Mail_mime   Are they simply ignored or are additional new instances
created. PHP won't let you duplicate function names.


Hi Al,

New isn't defining a class, it's a request for an instance of a defined 
class. Thus it will create a new instance over and over again for every 
time the new request is made. The equivalent to won't let you duplicate 
function names is won't let you duplicate class names.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] PHP session variables

2012-08-13 Thread Robert Cummings

On 12-08-10 04:42 PM, Tedd Sperling wrote:

On Aug 10, 2012, at 1:21 PM, Ege Sertçetin sertce...@itu.edu.tr wrote:


Hi. My question will maybe out of topic, I'm sorry.
How can you know that one way will be much slower than other one? I mean, how 
can I learn which function is faster before I test it?


Ege:

No your question is on topic.

This question should be asked on the list, so I'll present Q:A instead of 
answering privately

http://www.webbytedd.com/b/timed1/

The code is there -- if you have questions, please post them to the list.


Ted,

Please see the current signature for microtime():

mixed microtime ([ bool $get_as_float = false ] )

The optional paramter was added in PHP 5.0.0. I think it's safe to 
update your habits :)


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Reading class variable value always returns NULL

2012-08-13 Thread Robert Cummings

On 12-08-12 08:32 AM, Reto Kaiser wrote:

Hi,

So I have this strange situation where I assign a classvariable a
value, but when I read the value it is NULL.

The class has one variable declared:
=
class A {
 private $_cookies;
}
=


That is a private instance variable NOT a class variable.

To declare a class variable you would do the following:

?php

class A
{
private static $_cookies;
}

?


In a method of this class I assign this classvariable plus an
undeclared classvariable and a local variable the value 1:
=
$this-_cookies = 1;
$this-_cookies2 = 1;
$cookies3 = 1;
=

When I now read the values of those variables, the classvariables are
NULL while the local variable is 1:
=
$logEntry .= 'cookies: ' . var_export($this-_cookies, true) . PHP_EOL;
$logEntry .= 'cookies2: ' . var_export($this-_cookies2, true) . PHP_EOL;
$logEntry .= 'cookies3: ' . var_export($cookies3, true) . PHP_EOL;
=
cookies: NULL
cookies2: NULL
cookies3: 1
=

But when reading the whole object, the classvariables are 1:
=
$logEntry .= var_export($this, true) . PHP_EOL;
=
A::__set_state(array(
'_cookies' = 1,
'_cookies2' = 1,
))
=


This happens periodically on a busy webserver. It seems that when it
happens, all classvariables cannot be read anymore (return NULL).
After restarting Apache it does not happen anymore, just to happen
again after some minutes.

The system is current Debian Squeeze:
Linux: linux-image-2.6.32-5-amd64
Apache: apache2-mpm-prefork 2.2.16-6+squeeze7
PHP: PHP 5.3.3-7+squeeze13 with Suhosin-Patch (cli) (built: Jun 10
2012 07:31:32)
php -m: 
https://raw.github.com/gist/3331641/2f7e80bd03abfb728b659634d3f4bac0131f4d6a/gistfile1.txt
php -i: 
https://raw.github.com/gist/3331651/bcf6e3654bf391482627505447848de173d0bbab/gistfile1.txt

Does anyone have an idea what could cause this, or how to further debug?


I can't really speak to your specific problem (unless you're using two 
different instances of the class), just thought I'd clear up the 
difference between class variables and instance variables.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Too many open files

2012-08-10 Thread Robert Cummings

On 12-08-09 08:01 PM, Al wrote:

Getting Too many open files error when processing an email batch process.

The batch size is actually rather small and the email text is small likewise.

I've looked extensively and can't find more than about 100 files that could be
open.  All my fetching is with get_file_contents();

I can't find a way to see what files could be open or what the limit is.

Site is on a shared server, cPanel.

   ^
THIS is probably your problem. Too many open files indicates that either 
the user OR the OS has reached its limit of allowed open file handles. 
Open files are those used by the OS and every user on the shared server. 
The setting can be changed but you'll need an administrator to increase 
the number of allowed open files. I suspect it's at the OS level if 
indeed you only have 100 files open (though you likely have more due to 
files opened for you by the OS or whatnot.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Too many open files

2012-08-10 Thread Robert Cummings

On 12-08-10 02:49 AM, Matijn Woudt wrote:

On Fri, Aug 10, 2012 at 5:36 AM, Jim Lucas li...@cmsws.com wrote:

On 8/9/2012 5:01 PM, Al wrote:


Getting Too many open files error when processing an email batch
process.

I've looked extensively and can't find more than about 100 files that
could be open.  All my fetching is with get_file_contents();



Why not use fopen() and other related functions to open/grap/close your
batch of files?

You could replace a call like this:

$data = file_get_contents($filename);

with this:

if ( $fh = fopen($filename, 'r') ) {
   $data = fread($fh, filesize($filename));
   fclose($fh);
}

This should take care of your issue.

Jim Lucas


Why on earth would you want to reinvent the wheel? There's no point in
saying that fopen/fread/fclose is better, in fact, let me quote from
the manual page of file_get_contents:
file_get_contents() is the preferred way to read the contents of a
file into a string. It will use memory mapping techniques if supported
by your OS to enhance performance.

If your solution would fix the problem (I doubt, but ok), then you
should report a bug to the PHP devs that file_get_contents is broken.


It wouldn't fix the problem. Performing fopen/fread/fclose in PHP is 
slower than the same process implemented in C in the PHP engine. Thus 
the file will spend more time in the open state thus exacerbating the 
problem.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] XML/PHP web service

2012-08-08 Thread Robert Cummings

Hi Philip,

Tell them they can POST submissions to:

https://www.acme.com/xml-submission

Then tell them what fields are supported. Presumably you will support 
the following POST fields as a minimum (as if they were on a form):


username
password
xml

Your handler should also provide some feedback about whether the 
submission was successful of not. You can simply return output of a 1 
for success, a 0 for failure, or if you want to go whole hog you can 
output an XML response for which you can have much greater granularity 
for the response.


Cheers,
Rob.

On 12-08-08 06:57 PM, Phillip Baker wrote:

I was wondering how that would work and if it might be that simple.
How would I inform the client to hit the page (script)?

Blessed Be

Phillip

In the Jim Crow South, for example, government failed and indeed refused
to protect blacks from extra-legal violence. Given our history, it's
stunning we fail to question those who would force upon us a total reliance
on the state for defense.
-- Robert J. Cottrol



On Wed, Aug 8, 2012 at 4:27 PM, Ashley Sheridan 
a...@ashleysheridan.co.ukwrote:




Phillip Baker phil...@freewolf.net wrote:


Greetings all,

I am looking for some options here.

I am in need of creating a service on our web server that will always
be
available and automated.
It will accept an XML file.

I will be checking to see if the XML file is valid and then passing it
on
to another server.
But I need to accept this file without using a submit form.
I have never done anything like this and looking for ideas.

I am using a lamp environment and looking for suggestions.

I am looking to set this up so that our vendors can set up scripts to
automatically post XML files to our servers.

Blessed Be

Phillip

In the Jim Crow South, for example, government failed and indeed
refused
to protect blacks from extra-legal violence. Given our history, it's
stunning we fail to question those who would force upon us a total
reliance
on the state for defense.
-- Robert J. Cottrol


Just set up your php script as if it were accepting input from a form
submission. All you're doing is not showing the form. Imagine it like a
form set up on someone else's server with the action attribute pointing to
your script.

Ashley  Sheridan
http://www.ashleysheridan.co.uk

--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.





--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] why is (intval('444-44444') == '444-44444') EQUAL??!

2012-06-21 Thread Robert Cummings



On 12-06-21 10:27 PM, Daevid Vincent wrote:

Huh? Why is this equal??!

php  $id = '444-4';

php  var_dump($id, intval($id));
string(9) 444-4
int(444)

php  if (intval($id) == $id) echo 'equal'; else echo 'not equal';
equal

or in other words:

php  if (intval('444-4') == '444-4') echo 'equal'; else
echo 'not equal';
equal

I would expect PHP to be evaluating string 444-4 against integer 444
(or string either way)

however, just for giggles, using === works...

php  if ($id === intval($id)) echo 'equal'; else echo 'not equal';
not equal


Using === will always fail because on the left you have a string and on 
the right you have an integer which fails exact comparison based on 
datatype mismatch.


When comparing a string to an integer using == PHP performs type 
juggling and converts the string to an integer first.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Function size

2012-05-29 Thread Robert Cummings

On 12-05-29 07:17 AM, Stuart Dallas wrote:


I wasn't going to respond to this thread because I think it's a largely

 ridiculous topic, but some of the responses have scared me. Sir Cummings
 (hopefully) sarcastic response about using a 5px font size demonstrated
 how daft it is to base function size on how much code you can see on the
 screen at once.

Guilty as charged ;)

One time I was helping a friend of mine do his Java homework at Cornell 
and when he got the assignment back he scored 24 out of 25 and I was 
like What?!. The marker subtracted a point for a function that spanned 
more than one printed page. What a dork! I guess he didn't like my brace 
style since if I'd used a less vertically consumptive style then it 
would have printed cleanly on one page *lol*.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Function size

2012-05-23 Thread Robert Cummings

On 12-05-23 12:15 PM, Tedd Sperling wrote:


On May 23, 2012, at 11:49 AM, shiplu wrote:

On May 21, 2012, at 8:32 PM, tamouse mailing lists wrote:
When number of lines becomes the criteria of function size? Wouldn't it depends 
on the task the function is doing?


You missed the point.

Of course, the difficulty of the task of a specific function will directly 
contribute to the number of lines of code for that function, but that's not 
what I was talking about.

What I was talking about was that what we can grasp in one view, we can 
understand better. If the code lies outside of our view, then we understand it 
less. I can support this claim with numerous articles/books/studies of human 
visual limits vs short-term memory. I am only bringing this forward for us to 
consider in our writing code. If we know why we do things, then we can better 
understand what we do.


That's why I code in 5px font. On my huge monitor I sometimes find the 
code is shaped like a tiger, or a dragon, I swear I even saw Piccolo. It 
really does help to see the big picture :B


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] To ? or not to ?

2012-04-04 Thread Robert Cummings

On 12-04-04 01:14 AM, Donovan Brooke wrote:

Robert Cummings wrote:
[snip]

Could using ob_start and ob_end_flush eliminate the ambiguity of whether
or not to use '?'?


In the generally recommended case of don't use them at the end of your
file... where's the ambiguity?



http://www.php.net/manual/en/function.include.php

http://www.php.net/manual/en/language.basic-syntax.phpmode.php

Those seem to suggest to use them... thus the ambiguity.


From an age long gone when I asked the exact same question and Big 
Daddy answered:


http://marc.info/?l=php-internalsm=106896382030183w=2

Then again a couple of years later:

http://marc.info/?l=php-internalsm=112537775409619w=2

And in the manual itself (see the note):

http://ca.php.net/basic-syntax.instruction-separation

Zend Framework and Drupal are examples of large codebases that have 
adopted the omission as a best practice.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] To ? or not to ?

2012-04-04 Thread Robert Cummings

On 12-04-04 02:42 PM, Lester Caine wrote:

Tedd Sperling wrote:

Let me start a religious war -- should one end their scripts with ? or not?


Just as long as no one proposes making leaving out compulsory ;)

While I can sort of understand the logic when the file is all php and just has
an opening?php, but when it's part of a file that has numerous opening and
closing tags AND using?= then leaving one segment un-terminated just seems
totally wrong?


These kinds of files don't generally have issues with trailing 
whitespace though :) I certainly close the tags in these cases.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] To ? or not to ?

2012-04-04 Thread Robert Cummings

On 12-04-04 04:40 PM, Lester Caine wrote:

( forget email addres :( )
Robert Cummings wrote:

On 12-04-04 02:42 PM, Lester Caine wrote:

Tedd Sperling wrote:

Let me start a religious war -- should one end their scripts with ? or not?


Just as long as no one proposes making leaving out compulsory ;)

While I can sort of understand the logic when the file is all php and just has
an opening?php, but when it's part of a file that has numerous opening and
closing tags AND using?= then leaving one segment un-terminated just seems
totally wrong?


These kinds of files don't generally have issues with trailing whitespace though
:) I certainly close the tags in these cases.


I'm not alone then :)
But I prefer EVERY tag to be closed ... perhaps that would change if the IDE's
faked a closing tag when it's missing so they don't get flagged as an error :(


IDE? Get off my lawn!!

;)

I develop in JOE.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] To ? or not to ?

2012-04-03 Thread Robert Cummings


On 12-04-03 05:29 PM, Tedd Sperling wrote:

Hi gang:

Let me start a religious war -- should one end their scripts with ? or not?

After years of never having a problem with ending any of my scripts with ?, I 
found that several students in my class had scripts that did not produce the desired result even 
after they were given the scripts via highlight_file() to cut and paste.

As it turned out, several students copy/pasted the script with an addition whitespace after 
the ending ? and as such the scripts did not run as expected. You see, the 
scripts created image but apparently the image delivery method objected to the additional 
whitespace.

Does anyone have more examples of where scripts will fail IF they end with ?  
 (note the additional space)?


It's standard practice to NOT include the closing ? on anything 
remotely resembling a class or lib source file. As has been mentioned on 
this list and originally on PHP internals on several occasions, the 
optionality of the closing tag is intentional :)


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] To ? or not to ?

2012-04-03 Thread Robert Cummings

On 12-04-03 11:39 PM, Donovan Brooke wrote:

Stuart Dallas wrote:
[snip]

Usually when setting headers after such a script has been included when output 
buffering is turned off. Personally I never put the closing ?   in if it's at 
the end of the file because it's unnecessary and can cause issues if it's present, 
but it's personal preference more than anything else.

Ultimately you have to consider that there's a reason it's optional - things like that 
don't generally happen by accident. I remember Rasmus commenting on this style issue a 
few years back so a search of the archives should find an official position.

-Stuart



Could using ob_start and ob_end_flush eliminate the ambiguity of whether
or not to use '?'?


In the generally recommended case of don't use them at the end of your 
file... where's the ambiguity?


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-04-02 Thread Robert Cummings

On 12-04-02 04:36 PM, Jay Blanchard wrote:

[snip]

function getTiersJson( $company )
{
$tiers = getTiers( $company );
$json = JSON_encode( $tiers );
}

$tiersJson = getTiersJson( 1 );

?

This will output JSON with the following structure:


[/snip]

OK, now I know I am being dense - but don't I have to add return $json; to 
getTiersJson() ?


yeah, *lol* in my testing I had a print_r() in the getTiersJson() so 
didn't notice I wasn't returning since I didn't do anything with the 
captured value (null without a proper return).


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-30 Thread Robert Cummings

On 12-03-27 11:11 AM, Jay Blanchard wrote:

[snip]On 3/27/2012 12:21 AM, Robert Cummings wrote:

 [-- SNIP --]

Essentially, entries at the root and entries for the children are just
auto indexed array items but the actual entries in those arrays retain
the associative index structure for retrieval of the specific
information. let me know and I can probably whip you up something.


Robert that looks correct. Here is an example of the JSON that the guy
provided for me -

   var json = {
  id: node02,
  name: 0.2,
  data: {},
  children: [{
  id: node13,
  name: 1.3,
  data: {},
  children: [{
  id: node24,
  name: 2.4,
  data: {},
  children: [{
  id: node35,
  name: 3.5,
  data: {},
  children: [{
  id: node46,
  name: 4.6,
  data: {},
  children: []
  }]
  }, {
  id: node37,
  name: 3.7,
  data: {},
  children: [{
  id: node48,
  name: 4.8,
  data: {},
  children: []
  }, {
  id: node49,
  name: 4.9,
  data: {},
  children: []
  }, {
  id: node410,
  name: 4.10,
  data: {},
  children: []
  }, {
  id: node411,
  name: 4.11,
  data: {},
  children: []
  }]
  },
Of course he properly closes up the JSON. I inserted id's (just an
auto-incrementing number) and the data portion where needed. The name:
is the part that has been the result of what you did before.


Here's the code... I did a bit of shuffling and actually tested against 
a test db table:


?mysql :)

DROP TABLE IF EXISTS tiers;
CREATE TABLE tiers
(
company INT NOT NULL,
tier1   VARCHAR( 32 )   NOT NULLDEFAULT '',
tier2   VARCHAR( 32 )   NOT NULLDEFAULT '',
tier3   VARCHAR( 32 )   NOT NULLDEFAULT '',
tier4   VARCHAR( 32 )   NOT NULLDEFAULT '',
tier5   VARCHAR( 32 )   NOT NULLDEFAULT '',
tier6   VARCHAR( 32 )   NOT NULLDEFAULT '',
tier7   VARCHAR( 32 )   NOT NULLDEFAULT '',
tier8   VARCHAR( 32 )   NOT NULLDEFAULT '',
tier9   VARCHAR( 32 )   NOT NULLDEFAULT '',
tier10  VARCHAR( 32 )   NOT NULLDEFAULT '',
tier11  VARCHAR( 32 )   NOT NULLDEFAULT '',
tier12  VARCHAR( 32 )   NOT NULLDEFAULT '',
tier13  VARCHAR( 32 )   NOT NULLDEFAULT '',
tier14  VARCHAR( 32 )   NOT NULLDEFAULT ''
);

INSERT INTO tiers (company, tier1, tier2, tier3) VALUES
(1, 'exec-001','sub-exec-011','sub-sub-exec-111'),
(1, 'exec-001','sub-exec-011','sub-sub-exec-112'),
(1, 'exec-001','sub-exec-012','sub-sub-exec-121'),
(1, 'exec-001','sub-exec-012','sub-sub-exec-122'),
(1, 'exec-002','sub-exec-021','sub-sub-exec-211'),
(1, 'exec-002','sub-exec-021','sub-sub-exec-212'),
(1, 'exec-002','sub-exec-022','sub-sub-exec-221'),
(1, 'exec-002','sub-exec-022','sub-sub-exec-222');

?

And here's the code:

?php

function getTiers( $company )
{
//
// Establish the root.
//

$sDb = ijinn_getServiceRef( 'dbManager' );
$db = $sDb-getConnectionRef();

$query =
SELECT DISTINCT 
   .   * 
   .FROM 
   .   tiers 
   .WHERE 
   .   company = {$company} ;

$root = array();
if( $db-query( $query ) )
{
while( ($row = $db-fetchRow()) )
{
$focus = $root;
for( $i = 1; $i = 14; $i++ )
{
$name = trim( $row['tier'.$i] );
if( $name === '' )
{
break;
}

if( !isset( $focus[$name] ) )
{
$focus[$name] = array
(
'name' = $name,
'children' = array(),
);
}

$focus = $focus[$name]['children'];
}
}
}

$wrapper = array
(
'children' = $root
);

postProcessTiers( $wrapper );

return $root;
}

function postProcessTiers( $root )
{
$root['children'] = array_values( $root['children'] );

foreach( array_keys( $root

Re: [PHP] Need PHP Web Developer in So Cal

2012-03-28 Thread Robert Cummings

On 12-03-28 12:20 PM, Paul Scott wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 28/03/2012 18:04, Michael Frankel wrote:

Hi -

I am looking for a reliable, experienced PHP / Web developer or
development company to assist me with one of my long-time clients.
I need someone who has experience with all the following
technologies working in a hosted environment:


[snip]


- Can be responsive to client emergencies - NOTE: this is the MOST
important quality


Translates to we will be phoning you at 2am and you are expected to
be there with a smile on your face for the client

Am I right? Yeah, I know I am... ;)


I always have a smile on my face... yeah, I'm smiling right now!! :D

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-26 Thread Robert Cummings

On 12-03-26 02:12 PM, Jay Blanchard wrote:

[snip]
This is one of those projects. It is apparently going to be trying every step 
of the way.
[/snip]

I was proven right this morning after all of Robert's good work and what I had 
added to make this work.  It turns out that the one service who was anxious to 
consume the JSON output expects that the JSON be a certain format. When I run 
their format through jslint it does not validate unless I add quotes around the 
name portion of the name:value pairs. In addition they use (perfectly valid) 
square brackets around the children groups that the output from json_encode() 
does not contain.

I am ready to take a loss on this one but I really didn't lose - Robert gave me 
a great way to retrieve the data with one query and create valid JSON from it. 
Thanks again Robert!


*lol* No worries... it's all about solving problems :)

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-26 Thread Robert Cummings

On 12-03-26 05:14 PM, Jay Blanchard wrote:

[snip]

*lol* No worries... it's all about solving problems :)

[/snip]

the other folks who needed to consume the JSON have all done so successfully 
today - just this one. The guy who runs it was plenty arrogant when I discussed 
with him. He is the one who wanted me to remove the extra array name. I cooked 
up some regex to do that but then all of the opening/closing curlies were out 
of whack. If I had kept going it would have been maddening. I told him he 
needed to fix his JSON parsing. He said I needed to add the square brackets. 
Programmer stand-off.


Did you end up with a satisfactory output? It's not overly difficult to 
generate an array instead of an object.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-26 Thread Robert Cummings

On 12-03-26 06:52 PM, Jay Blanchard wrote:

[snip]

Did you end up with a satisfactory output? It's not overly difficult to 
generate an array instead of an object.

[/snip]

I did for all but this one instance. Are you saying that it would be easy to 
make of the children arrays? I thought they were already - am I missing 
something?


They are arrays... but JSON_encode is creating objects. You can create 
arrays by traversing the array structure recursively and outputing your 
own JavaScript code to build a JavaScript array. I don't know if that 
would serve the purpose, but you would end up with an array.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-26 Thread Robert Cummings

On 12-03-26 07:05 PM, Jay Blanchard wrote:

[snip]
On Mar 26, 2012, at 5:58 PM, Robert Cummings wrote:


On 12-03-26 06:52 PM, Jay Blanchard wrote:

[snip]

Did you end up with a satisfactory output? It's not overly difficult to 
generate an array instead of an object.

[/snip]

I did for all but this one instance. Are you saying that it would be easy to 
make of the children arrays? I thought they were already - am I missing 
something?


They are arrays... but JSON_encode is creating objects. You can create arrays 
by traversing the array structure recursively and outputing your own JavaScript 
code to build a JavaScript array. I don't know if that would serve the purpose, 
but you would end up with an array.

[/snip]

I'm listening - so could this be added to the code that you just wrote? Or do I 
need to recurse the output from json_encode()?


I think you need two things... the recursive post processor that removes 
the string indexes for the children. And then a function that creates a 
JavaScript array expression from an object or array. The question I have 
for you... is given the following array structure that might be 
generated from my previous code:


?php

array
(
'exec-001' = array
(
'name' = 'exec-001',
'children' = array
(
'sub-exec-011' = array
(
'name' = 'sub-exec-011',
'children' = array
(
'sub-sub-exec-111' = array
(
'name' = 'sub-sub-exec-111',
'children' = array()
),
'sub-sub-exec-112' = array
(
'name' = 'sub-sub-exec-112',
'children' = array()
)
)
),
'sub-exec-012' = array
(
'name' = 'sub-exec-012',
'children' = array
(
'sub-sub-exec-121' = array
(
'name' = 'sub-sub-exec-121',
'children' = array()
),
'sub-sub-exec-122' = array
(
'name' = 'sub-sub-exec-122',
'children' = array()
)
)
)
)
),
'exec-002' = array
(
'name' = 'exec-002',
'children' = array
(
'sub-exec-021' = array
(
'name' = 'sub-exec-021',
'children' = array
(
'sub-sub-exec-211' = array
(
'name' = 'sub-sub-exec-211',
'children' = array()
),
'sub-sub-exec-212' = array
(
'name' = 'sub-sub-exec-212',
'children' = array()
)
)
),
'sub-exec-022' = array
(
'name' = 'sub-exec-022',
'children' = array
(
'sub-sub-exec-221' = array
(
'name' = 'sub-sub-exec-221',
'children' = array()
),
'sub-sub-exec-222' = array
(
'name' = 'sub-sub-exec-222',
'children' = array()
)
)
)
)
)
);

?

On first blush, I think you want the following structure (from your 
recent posts):


?php

array
(
0 = array
(
'name' = 'exec-001',
'children' = array
(
0 = array
(
'name' = 'sub-exec-011',
'children' = array
(
0 = array
(
'name' = 'sub-sub-exec-111',
'children' = array()
),
1 = array
(
'name' = 'sub-sub-exec-112',
'children' = array()
)
)
),
1 = array
(
'name' = 'sub-exec-012',
'children' = array
(
0 = array
(
'name' = 'sub-sub-exec-121',
'children' = array()
),
1 = array
(
'name' = 'sub-sub-exec-122',
'children' = array()
)
)
)
)
),
1 = array
(
'name' = 'exec-002',
'children' = array
(
0 = array

Re: [PHP] foreach weirdness

2012-03-24 Thread Robert Cummings

On 12-03-24 11:15 AM, Al wrote:



On 3/23/2012 10:11 PM, Robert Cummings wrote:

On 12-03-23 06:30 PM, Simon Schick wrote:

2012/3/23 Robert Cummingsrob...@interjinn.com


On 12-03-23 11:16 AM, Arno Kuhl wrote:



it still does not produce the correct result:
0 1 3 6 10 15 21
0 1 3 6 10 15 15



This looks like a bug... the last row should be the same. What version of
PHP are you using? Have you checked the online bug reports?




Hi, Robert

Does not seem like a bug to me ...
http://schlueters.de/blog/archives/141-References-and-foreach.html

What you should do to get the expected result:
Unset the variable after you don't need this reference any longer.


Ah yes... that clued me in. I disagree with the article's generalization with
respect to references since references accomplish some things that cannot be
accomplished otherwise, but even I missed the fact that the second loop was
using a variable that was a reference to the last element of the array as
created in the first loop *lol*. The user's very act of checking their results
was confounding the result... I love it :)

Cheers,
Rob.


Re, your ...that cannot be accomplished otherwise,... Can you provide some
examples?  The only ones I've found are when using create_function() and the
arguments for callback functions. I can't even remember or find in my code an
example of my foreach()loops needed it. Seems, I recall earlier versions of PHP
[4? ]required references for variables.


After I submitted ...that cannot be accomplished otherwise,..., I 
realized it was a patently false statement (a turing machine is a turing 
machine :). The intent of the statement though was to indicate the 
greater difficulty in achieving something relatively simple with 
references. See the other thread Thinking out loud - continuation. My 
post dated 2012-03-24 00:24 shows a process that is cumbersome and 
inefficient to implement in another fashion. References are like 
pointers... very powerful but with cautions for the unwary.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-24 Thread Robert Cummings

On 12-03-24 08:41 AM, Jay Blanchard wrote:


On Mar 23, 2012, at 11:24 PM, Robert Cummings wrote:


On 12-03-23 05:41 PM, Jay Blanchard wrote:

[-- DELETED GARBAGE --]  :)


I just realized... I've been stuck in a thinking rut. I latched onto one 
solution that works well in some case but didn't fully examine the nuances of 
your own scenario. Given the way you are creating your hierarchy you will 
ultimately retrieve all rows. As such the following simple solution will do 
what you need:

?php

$company = 1;

$query =
SELECT DISTINCT 
   .   * 
   .FROM 
   .   tiers 
   .WHERE 
   .   company = {$company} ;

$root = array();
if( $db-query( $query ) )
{
while( ($row = $db-fetchRow()) )
{
$focus =$root;
for( $i = 1; $i= 14; $i++ )
{
$name = $row['tier'.$i];

if( !isset( $focus[$name] ) )
{
$focus[$name] = array();
}

$focus =$focus[$name];
}
}
}

$json = JSON_encode( $root );

?


The crux of it is:

$focus = $focus[$name];

because it facilitates moving deeper and deeper into the array.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-24 Thread Robert Cummings

On 12-03-24 01:09 PM, Jay Blanchard wrote:

[snip]The crux of it is:


$focus =$focus[$name];
[/snip]


It works as I expect so far. All I have to do is figure out how to make the 
element a name: element in the JSON. for instance an element would look like 
this

{
name: Bob,
children: []
}

So the PHP array would have to look like this -

$json = array (
name =  Bob,
children =  array (
name =  Angie
)
)

and so on. This is for one of the services that will consume the JSON.


A little tweak here... a little tweak there:

?php

//
// Establish the root.
//

$company = 1;

$query =
SELECT DISTINCT 
   .   * 
   .FROM 
   .   tiers 
   .WHERE 
   .   company = {$company} ;

$root = array();
if( $db-query( $query ) )
{
while( ($row = $db-fetchRow()) )
{
$focus = $root;
for( $i = 1; $i = 14; $i++ )
{
$name = $row['tier'.$i];

if( !isset( $focus[$name] ) )
{
$focus[$name] = array
(
'name' = $name,
'children' = array(),
);
}

$focus = $focus[$name]['children'];
}
}
}

$json = JSON_encode( $root );
?
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-24 Thread Robert Cummings

On 12-03-24 04:11 PM, Jay Blanchard wrote:

[snip]

One more little tweak may be required. The JSON looks like this

{Executives and Management:{name:Executives and Management,children:{

The first part {Executives and Management: needs to be removed. I think I 
know what to do.

[/snip]

It has become painfully obvious that I do not know what to do. Ready to call it 
a day. Besides I just burned my finger setting up the smoker for the ribs.


It's a necessary part of building the structure. It can be removed but 
only as a post process. Why does it have to be removed? You can loop 
through the structure in JavaScript without paying heed to the key's value.


If it absolutely must go... you need to recurse through the final 
structure replacing each children entry with the results of passing it 
through array_values().


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] foreach weirdness

2012-03-23 Thread Robert Cummings

On 12-03-23 11:16 AM, Arno Kuhl wrote:

The following snippet is copied from the php manual:
foreach ($arr as $key =  $value) {
echo Key: $key; Value: $valuebr /\n;
}

I've always used the foreach loop that way.
But recently I started hitting some really odd problems.

See this following example that illustrates the problem:
$array = array(0, 1, 2, 3, 4, 5, 6);
foreach ($array as $index=$value) {
if ( ($index+1)  count($array) ) {
$array[$index+1] += $value;
}
echo $value. ;
}
echo br /;
foreach ($array as $index=$value) {
echo $value. ;
}

You'd expect the output to be:
0 1 3 6 10 15 21
0 1 3 6 10 15 21

But it's actually:
0 1 2 3 4 5 6
0 1 3 5 7 9 11


This is what I would expect since the value is a copy. As such, one 
would expect it to be the value before you made modifications to the array.



If you assign the $value by reference in the first loop as someone pointed
out (and confirmed by the manual: As of PHP 5, you can easily modify
array's elements by preceding $value with. This will assign reference
instead of copying the value)

$array = array(0, 1, 2, 3, 4, 5, 6);
foreach ($array as $index=$value) {//- assign $value by reference
if ( ($index+1)  count($array) ) {
$array[$index+1] += $value;
}
echo $value. ;
}
echo br /;
foreach ($array as $index=$value) {
echo $value. ;
}

it still does not produce the correct result:
0 1 3 6 10 15 21
0 1 3 6 10 15 15


This looks like a bug... the last row should be the same. What version 
of PHP are you using? Have you checked the online bug reports?



If I watch the $array in a debugger I see odd behaviour for the last element
$array[6] when stepping through the second foreach loop.
Just before entering the second loop $array[6] == 21 which is correct.
When I move to the next line (echo $value. ;)  $array[6] changes to 0 !!
As I step through the second loop $array[6] keeps on changing for each
iteration, with the following values:
0, 1, 3, 6, 10, 15, 15
And once I've left the second loop $array[6] is permanently changed from 21
to 15, even though there's no code in the second loop to change $array[6].
So what's going on here?

I confirm this by echoing $array[6] in each iteration in the second loop:
$array = array(0, 1, 2, 3, 4, 5, 6);
foreach ($array as $index=$value) {
if ( ($index+1)  count($array) ) {
$array[$index+1] += $value;
}
echo $value. ;
}
echo br /;
foreach ($array as $index=$value) {
echo $array[6]. ;
}
echo br /;
echo $array[6];

the result is:
0 1 3 6 10 15 21
0 1 3 6 10 15 15
15

Note that $array[6] is still 15 even after completing the second foreach
loop.
If you break out of the second loop then $array[6] will be at whatever value
it was at the time you break out (ouch!)

If you assign the $value by reference in the second loop as well:
$array = array(0, 1, 2, 3, 4, 5, 6);
foreach ($array as $index=$value) {
if ( ($index+1)  count($array) ) {
$array[$index+1] += $value;
}
echo $value. ;
}
echo br /;
foreach ($array as $index=$value) {//- assign $value by reference
echo $array[6]. ;
}
echo br /;
echo $array[6];

you finally get the correct result:
0 1 3 6 10 15 21
21 21 21 21 21 21 21
21

You can test this with multiple foreach loops and get the same results. If
you modify the array in the first foreach loop, then use an assign $value by
reference in the next 9 foreach loops to get the correct values (without
modifying the array), and then in the 10th foreach loop you don't use an
assign $value by reference (without modifying the array), the array becomes
corrupted.

I sort of understand the need to assign the $value by reference in the first
loop, but why is it also required in every subsequent loop where the array
is not being modified? Especially since all the examples in the manual show
it's not needed? It would appear that once you've modified an array's
elements in a foreach loop you always have to assign $value by reference in
any subsequent foreach loop using that array. And if you don't, not only
will you get the wrong results but the array itself is actually altered,
even if there's no code in the loop to alter it. Is that correct or is it a
bug? At what stage can you start using the array in the normal way again?
That could create hair-pulling havoc for anyone maintaining code if they
haven't noticed that somewhere previously there was code that modified the
array in a foreach loop. Maybe the answer is to always assign $value by
reference in a foreach loop regardless of what you do in that loop, but I'm
not sure what the implications are.


Here's how you should do it (IMHO) to avoid all sorts of side effects, 
magic behaviour, and unnecessary complications:


?php

$array = array( 0, 1, 2, 3, 4, 5, 6 );
foreach( array_keys( $array ) as $index )
{
if( ($index + 1)  count( $array ) )
{
   

Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Robert Cummings

On 12-03-23 02:08 PM, Jay Blanchard wrote:

[snip]

Your data structure doesn't appear to be very ummm normalized... Nonetheless, 
the following should do it:

[/snip]

You're absolutely correct. Unfortunately I am not the designer and cannot 
really do anything about it. I just have to work with what I have. Thank you 
very much for this - I will test it out this afternoon and let you know how it 
all goes.



I figured it was something you had been given... just thought I'd point 
out the obvious :D


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Robert Cummings

On 12-03-23 03:17 PM, Jay Blanchard wrote:

[snip]

$json = JSON_encode( $root );

[/snip]

Update on my test. This works perfectly Robert - thank you very much! But there 
is one small problem that I am trouble-shooting: it only goes one layer and 
doesn't progress any further. I suspect it is on this section of code that I am 
going to add some stuff to to see what is happening.

if( !($parents =$children) ){
break;
}


I didn't actually test it... if you have trouble figuring out the 
problem feel free to send me a copy of your table (in private) and I'll 
debug :)


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Robert Cummings

On 12-03-23 03:22 PM, Jay Blanchard wrote:



[snip]

   $json = JSON_encode( $root );

[/snip]

Update on my test. This works perfectly Robert - thank you very much! But there 
is one small problem that I am trouble-shooting: it only goes one layer and 
doesn't progress any further. I suspect it is on this section of code that I am 
going to add some stuff to to see what is happening.

if( !($parents =$children) ){
   break;
   }


It would appear that both arrays are empty on the next cycle through so the 
break occurs.


Did you get any results form the database on the second run through the 
query loop?


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] foreach weirdness

2012-03-23 Thread Robert Cummings

On 12-03-23 02:04 PM, Arno Kuhl wrote:

Hi Rob

I'm using php 5.3.5. What result do you get when you run this code?
I haven't checked any bug reports, I'll google to see where I would do that.

Your code gets round the problem, but I was specifically referring to the use 
of foreach with its unexpected side-effects.


I know... but when I first started doing things like what you tried to 
do, there were no references for foreach values and so I've just 
naturally been in the habit of explicitly accessing the values in the 
array by index. Apparently that will serve me well since my stuff won't 
blow up with this bug ;)



There are a few different designs like look-ahead where it seemed the obvious 
way to go. I know I've used this type of foreach coding in the past, and have 
this nagging feeling there's a whole bunch of code just waiting to explode. I 
always just assumed it worked because it's pretty simple. I'd previously been 
caught out forgetting the assign by reference in the foreach loop that modified 
the array but I always caught it long before it went live, but I never 
considered having to also use assign by reference in subsequent foreach loops 
because it so obviously wasn't necessary. Now I'm searching through my scripts 
to see if there are any potential problems caused by this (already found one), 
and wondering what else I've done where I no longer have access to the sources.

BTW I'm told on another forum this issue has been discussed multiple times on 
this mailing list - did I miss it? Was there a resolution?


I must have missed it too... but then I've not been very active in the 
past year or so :)


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Robert Cummings

On 12-03-23 03:28 PM, Jay Blanchard wrote:


On Mar 23, 2012, at 2:25 PM, Robert Cummings wrote:


On 12-03-23 03:17 PM, Jay Blanchard wrote:

[snip]

$json = JSON_encode( $root );

[/snip]

Update on my test. This works perfectly Robert - thank you very much! But there 
is one small problem that I am trouble-shooting: it only goes one layer and 
doesn't progress any further. I suspect it is on this section of code that I am 
going to add some stuff to to see what is happening.

if( !($parents =$children) ){
break;
}


I didn't actually test it... if you have trouble figuring out the problem feel 
free to send me a copy of your table (in private) and I'll debug :)


I had it backwards. Both arrays are empty and the break should not occur 
because they are equal to each other. Let me send you a portion of the table 
Robert.


No, I'm performing assignment... intentionally. Parent's becomes the 
previous children to move down a level. The following:


if( !($parents = $children) )

performs assignment and an empty array check in one statement.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Robert Cummings

On 12-03-23 03:52 PM, Jay Blanchard wrote:

[snip]
SELECT DISTINCT `TIER3DATA` AS id, `TIER2DATA` AS parentId FROM 
`POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `TIER2DATA` IN ('Executives and 
Management','Professionals','Technicians','Craft 
Workers-Skilled','Operatives','Contractor','Sales Workers','Laborers and 
Helpers','Admin Support')

and it is empty.

[/snip]

I figured out part of the problem - the for loop starts at tier2 instead of 
tier1


It's meant to since outside the loop we address tier 1 when we generate 
the root and first set of parents (These have no parent ID so they are a 
special case).



Once I made that change I get the following error:

Fatal error: Cannot use string offset as an array in 
/home/orcadept/public_html/poschart/json_chart.php on line 139

Line 139 is $item['children'][$id] =$child;


$item['children'] should be an array, somehow a string has been assigned :/

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] foreach weirdness

2012-03-23 Thread Robert Cummings

On 12-03-23 06:30 PM, Simon Schick wrote:

2012/3/23 Robert Cummingsrob...@interjinn.com


On 12-03-23 11:16 AM, Arno Kuhl wrote:



it still does not produce the correct result:
0 1 3 6 10 15 21
0 1 3 6 10 15 15



This looks like a bug... the last row should be the same. What version of
PHP are you using? Have you checked the online bug reports?




Hi, Robert

Does not seem like a bug to me ...
http://schlueters.de/blog/archives/141-References-and-foreach.html

What you should do to get the expected result:
Unset the variable after you don't need this reference any longer.


Ah yes... that clued me in. I disagree with the article's generalization 
with respect to references since references accomplish some things that 
cannot be accomplished otherwise, but even I missed the fact that the 
second loop was using a variable that was a reference to the last 
element of the array as created in the first loop *lol*. The user's very 
act of checking their results was confounding the result... I love it :)


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Robert Cummings

On 12-03-23 05:41 PM, Jay Blanchard wrote:

[-- DELETED GARBAGE --]  :)


I just realized... I've been stuck in a thinking rut. I latched onto one 
solution that works well in some case but didn't fully examine the 
nuances of your own scenario. Given the way you are creating your 
hierarchy you will ultimately retrieve all rows. As such the following 
simple solution will do what you need:


?php

$company = 1;

$query =
SELECT DISTINCT 
   .   * 
   .FROM 
   .   tiers 
   .WHERE 
   .   company = {$company} ;

$root = array();
if( $db-query( $query ) )
{
while( ($row = $db-fetchRow()) )
{
$focus = $root;
for( $i = 1; $i = 14; $i++ )
{
$name = $row['tier'.$i];

if( !isset( $focus[$name] ) )
{
$focus[$name] = array();
}

$focus = $focus[$name];
}
}
}

$json = JSON_encode( $root );

?

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-22 Thread Robert Cummings

On 12-03-22 11:28 AM, Jay Blanchard wrote:

[snip]
...stuff...
[/snip]

Here is the explanation for what I have done and what I am trying to do
- (based on the customer's request).

A week or so ago I took a set of queries from one table and made them
into an unordered list. This will be pseudo-code so that you get idea.

SELECT DISTINCT column1 FROM table
WHERE company = '1'

while($column1 = mysql_fetch_array($query1results)){
  SELECT DISTINCT column2 FROM table
  WHERE company = '1'
  AND column1 = $column1[0]

  while($column2 = mysql_fetch_array($query2results)){
  SELECT DISTINCT column3 FROM table
  WHERE company = '1'
  AND column2 = $column2[0]
  }
}

This continues for up to 14 columns of data. I'm not worried about the
recursive data retrieval, I have that part and like I said - I can
output a nested unordered list from it quite handily.

Now the customer wants JSON as the output. The JSON must reflect the
children properly.

So I have two choices, a multidimensional array that I can use
json_encode() on or output a string that ultimately forms the JSON. We
have all agreed that doing an array would be the best thing but I cannot
wrap my head around it.

If you have more questions fire away - I'd love to get this solved and
off of my plate.


Fix this code... I've come across codebases that did this specific type 
of nested querying and it resulted in 1 queries to the database on 
every page. Instead, create a layered approach:


1. Select your root elements.
2. Loop over in PHP and create an array of child IDs.
3. Select the children from the database.
4. Go to step 2.

This way you will only every perform depth number of queries.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-22 Thread Robert Cummings

On 12-03-22 11:58 AM, Jay Blanchard wrote:

[snip]

Fix this code... I've come across codebases that did this specific
type of nested querying and it resulted in 1 queries to the
database on every page. Instead, create a layered approach:

 1. Select your root elements.
 2. Loop over in PHP and create an array of child IDs.
 3. Select the children from the database.
 4. Go to step 2.

This way you will only every perform depth number of queries.

[/snip]

I see what you're saying but I don't know that this reduces the number
of queries - it just handles them in a different order. How do I get to
the output that I need?


It definitely reduces the queries... your current method gets all the 
first level nodes in one query, then performs a query for every single 
parent node. Mine only performs a query for each level in the tree. If 
you have 5 nodes at the first level you will perform 6 queries. Mine 
will perform 2.


To generate the nesting structure at each level you track the level 
members. Something like the following (untested pseudoish):


?php

$parents = query_for_first_level();
$root = $parents;

while( $parents )
{
$parentIds = array();
foreach( $parents as $parent )
{
$parentIds[$parent['id']] = $parent['id'];
}

$children = query_for_children( $parentIds );
foreach( $children as $child )
{
$parents[$child['parentId']]['children'][] = $child;
}

$parents = $children;
}

$jsonData = JSON_encode( $root );

?

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-22 Thread Robert Cummings

On 12-03-22 11:58 AM, Jay Blanchard wrote:

[snip]

Fix this code... I've come across codebases that did this specific
type of nested querying and it resulted in 1 queries to the
database on every page. Instead, create a layered approach:

 1. Select your root elements.
 2. Loop over in PHP and create an array of parent IDs.
 3. Select the children from the database.
 4. Go to step 2.

This way you will only every perform depth number of queries.

[/snip]

I see what you're saying but I don't know that this reduces the number
of queries - it just handles them in a different order. How do I get to
the output that I need?


Sorry, I just realized I didn't make the optimization explicitly 
obvious... when I say Select the children I mean to select them using 
an IN( id1, id2, id3 ) clause instead of a query for each. This is why 
we build the array of parent IDs (also I wrote build an array of child 
IDs, it should have read parent IDs and has been fixed above :).


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-22 Thread Robert Cummings

On 12-03-22 12:34 PM, Jay Blanchard wrote:

[snip]

Sorry, I just realized I didn't make the optimization explicitly
obvious... when I say Select the children I mean to select them
using an IN( id1, id2, id3 ) clause instead of a query for each. This
is why we build the array of parent IDs (also I wrote build an array
of child IDs, it should have read parent IDs and has been fixed
above :).

[/snip]

SELECT DISTINCT children FROM table WHERE column1 IN(id1, id2, id3) ?

I am sure I am not following you now. Maybe I didn't explain clearly?


What's the field for which you are selecting data? I've written this up 
as a parent/child relationship but it works for data/sub-data 
relationships also.


SELECT itemId, otherData FROM table WHERE some condition;

SELECT itemId, subData FROM otherTable WHERE itemId IN (id1, id2, ...);

Then just link up the sub-data to the primary data in a loop and finally 
generate your JSON.


Does that clarify?

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-22 Thread Robert Cummings

On 12-03-22 01:06 PM, Jay Blanchard wrote:

On 3/22/2012 11:40 AM, Robert Cummings wrote:

What's the field for which you are selecting data? I've written this
up as a parent/child relationship but it works for data/sub-data
relationships also.

SELECT itemId, otherData FROM table WHERE some condition;

SELECT itemId, subData FROM otherTable WHERE itemId IN (id1, id2, ...);

Then just link up the sub-data to the primary data in a loop and
finally generate your JSON.

Does that clarify?

[/snip]

I must confess that the raging sinus headache and my general confusion
makes this really unclear for me today. Maybe I should just set it aside
for a day or so. I am super dense today.


Rest might do you well on a number of levels :)


For each level I am selecting for each parent in the level above. Let's
say that level 2 contains 8 people. Level 3 contains 14 people. Only
some of the 14 belong to the 8 and must be associated properly. So how
can I, with one query, associate level 3' 8th, 9th and 10th people with
level 2's 6th person keeping in mind that the 9th person might also
belong to level 2's 4th person.


At one point you indicated all the data was coming from one table. Can 
you send me the table fields and indicate which fields are used to 
determine parent child relationship? Also 2 sample rows of data which 
have a relationship would be helpful.



Just link up the sub-data? Place this array into a child array of the
parent array? Again I apologize - maybe I should push away and let the
customer know that it'll be a couple of more days.


Yeah... child array... 'children' :)

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-22 Thread Robert Cummings

On 12-03-22 03:54 PM, Jay Blanchard wrote:

[snip]

At one point you indicated all the data was coming from one table. Can you send 
me the table fields and indicate which fields are used to determine parent 
child relationship? Also 2 sample rows of data which have a relationship would 
be helpful.

[/snip]

Columns - tier1, tier2, tier3, tier4 etc. (ends with tier14)

Children of tier1 are tier2 -

select distinct tier2 from table where tier1 = foo and company = 1
select distinct tier2 from table where tier1 = bar and company = 1
etc.

Children of tier2 are tier3, etc.

tier1   tier2   tier3
1,  executive,  ceo,ceo
1,  executive,  vp-ops, vp-ops
1,  executive,  vp-admin,   vp-admin mgr
1,  executive,  vp-admin,   vp-admin ops mgr
1,  executive,  vp-admin,   vp-admin mgr
1,  executive,  vp-admin,   vp-admin clerk
1,  professionalpro-mgr pro-admin
1,  professionalpro-IT  pro-dev
1,  professionalpro-IT  pro-infra
1,  professionalpro-IT  pro-dev
1,  technician  tech-admin  tech-admin mgr
1,  technician  tech-opstech-ops mgr

Thanks for all of your help. I know I am being a PITA.


Your data structure doesn't appear to be very ummm normalized... 
Nonetheless, the following should do it:


?php

//
// Establish the root.
//

$company = 1;

$query =
SELECT DISTINCT 
   .   tier1 AS id 
   .FROM 
   .   tiers 
   .WHERE 
   .   company = {$company} ;

$root = array();
$children = array();
if( $db-query( $query ) )
{
while( ($row = $db-fetchRow()) )
{
$id = $row['id'];

unset( $child );

$child = array
(
'id'   = $id,
'parentId' = false,
'children' = array();
);

$root[$id] = $child;
$children[$id][] = $child;
}
}

//
// Establish the nested levels.
//

for( $tier = 2; $tier = 14; $tier++ )
{
if( !($parents = $children) )
{
break;
}

$parentTier = $tier - 1;

$parentIds = array();
foreach( array_keys( $parents ) as $parentId )
{
$parentIds[$parentId] = $db-quote( $parentId );
}

$query =
SELECT DISTINCT 
   .   tier{$tier} AS id, 
   .   tier{$parentTier} AS parentId 
   .FROM 
   .   tiers 
   .WHERE 
   .   company = {$company} 
   .   AND 
   .   tier{$parentTier} IN (.implode( ',', $parentIds ).) ;

if( $db-query( $query ) )
{
unset( $children );
$children = array();
while( ($row = $db-fetchRow()) )
{
$id  = $row['id'];
$pid = $row['parentId'];

unset( $child );

$child = array
(
'id'   = $id,
'parentId' = $pid,
'children' = array();
);

$children[$id][] = $child;

foreach( $parents[$pid] as $items )
{
foreach( $items as $item )
{
$item['children'][$id] = $child;
}
}
}
}
}

$json = JSON_encode( $root );
?

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] set_error_handler() only triggering every Nth time

2012-03-22 Thread Robert Cummings

On 12-03-22 03:57 PM, Daevid Vincent wrote:

Resending since I didn't get a single reply. Maybe it got lost?

-Original Message-
Sent: Tuesday, March 13, 2012 5:58 PM

I am implementing a custom error handler and started noticing some bizarre
behavior. Every Nth time I refresh the page, I see the error/output.


Have you tried sending headers that disable caching?

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-21 Thread Robert Cummings

On 12-03-21 03:52 PM, Jay Blanchard wrote:

[snip]

I would, yes, but that's not the point.  Is Anna single?  I'm
ready to trade Debs in for a newer model.

[/snip]

I'm thinking that Debs would upset your array if you traded her in.

Anyhow, I have spent the last hour trying to output valid JSON but the whole 
thing is making me barking mad. I may try create a multidimensional array here 
in a little bit. After I go for a walk.


Hi Jay,

Why are you trying to create the JSON structure in parts? When I have 
nesting like this i build the full nested structure as PHP, then export 
to JSON.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-21 Thread Robert Cummings

On 12-03-21 04:42 PM, Jay Blanchard wrote:

[snip]

Why are you trying to create the JSON structure in parts? When I have nesting 
like this i build the full nested structure as PHP, then export to JSON.

[/snip]

As PHP? An array?


Yeah sorry... you know what I meant ;)

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] CMS identification

2012-03-18 Thread Robert Cummings

On 12-03-18 06:42 PM, Stuart Dallas wrote:

On 18 Mar 2012, at 22:32, Alain Roger wrote:


ok so here it is: 
http://i220.photobucket.com/albums/dd277/alainroger/cms-login.png


Pass, not one I'm familiar with and a Google Image search for cms login doesn't 
show anything similar. If I were you I'd tell him to give me access to it so I 
can have a look for myself.


On google image search click on the camera icon... then paste in the URL 
with the screen shot.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Arrays: Comma at end?

2012-02-08 Thread Robert Cummings

On 12-02-07 02:50 PM, Micky Hulse wrote:

Was there ever a time when having a comma at the end of the last array
element was not acceptable in PHP?

I just did a few quick tests:

https://gist.github.com/1761490

... and it looks like having that comma ain't no big deal.

I can't believe that I always thought that having the trailing comma
was a no-no in PHP (maybe I picked that up from my C++ classes in
college? I just don't remember where I picked up this (bad) habit).

I would prefer to have the trailing comma... I just can't believe I
have avoided using it for all these years.


JavaScript in Internet Crapsplorer spanks you on the bottom every time 
you have a trailing comma in a JS array. That may be where you picked up 
the aversion.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Arrays: Comma at end?

2012-02-08 Thread Robert Cummings

On 12-02-08 01:12 PM, Micky Hulse wrote:

On Wed, Feb 8, 2012 at 10:08 AM, Robert Cummingsrob...@interjinn.com  wrote:

JavaScript in Internet Crapsplorer spanks you on the bottom every time you
have a trailing comma in a JS array. That may be where you picked up the
aversion.


On Wed, Feb 8, 2012 at 10:10 AM, Micky Hulsergmi...@gmail.com  wrote:

I am just surprised that there wasn't an older version of PHP that did
not allow this... I must have picked up this habit via my JS coding
knowledge. :D


Jinx! You owe me a Coke!!! :)


The timestamps above clearly show I was first ;)

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Long Live GOTO

2012-02-06 Thread Robert Cummings

On 12-02-06 04:07 AM, Tim Streater wrote:

On 06 Feb 2012 at 07:47, Adam Richardsonsimples...@gmail.com  wrote:


While not purely focused on PHP, I toss this out to the group because I
believe there are some novel, interesting points regarding the potential
benefits of using the goto construct as implemented in PHP:

http://adamjonrichardson.com/2012/02/06/long-live-the-goto-statement/


Your val_nested() function looks like a straw-man to me. I've not used a goto 
since I stopped writing in FORTRAN in 1978, and not missed it [1]. Neither do I 
ever have deeply nested if-then-else - these are a good source of bugs. I 
suppose the rest of your article might have been dealing with simplifying 
val_nested() but TBH I wasn't interested enough to find out.

[1] Not quite true - a Pascal compiler I once had to use in 1983 lacked a 
return statement, so I had to fake it by putting a 999: label at the end of the 
function and goto-ing to that.


Goto has it's uses, demonizing it due to the poor implementation and 
misuse of it's same-named historical counterparts is an exercise in 
closed-mindedness. Goto can really shine in parsers and various other 
scenarios. While the example shown may be contrived it doesn't miss the 
point. Since goto cannot jump out of the function nor jump into the 
function it is well constrained to provide readability while eliminating 
complexity. Additionally, it is quite likely that it is more optimal. A 
single jump target versus one or more state variables to control nested 
conditionals or loops results in faster execution (also important for 
parsers).


I've had a strong opinion on goto for a very long time. I was one of the 
proponents who argued on internals for its inclusion several years ago. 
I stand by its utility and refer the reader to the fact that many open 
source projects, especially ones that use some kind of parser, have goto 
hidden within their implementation. You can find it in the C code for 
the PHP, MySQL, and Apache to name a few easily recognizable projects.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Long Live GOTO

2012-02-06 Thread Robert Cummings

On 12-02-06 11:58 AM, Tim Streater wrote:

On 06 Feb 2012 at 09:48, Adam Richardsonsimples...@gmail.com  wrote:


On Mon, Feb 6, 2012 at 4:25 AM, Adam Richardsonsimples...@gmail.comwrote:


On Mon, Feb 6, 2012 at 4:07 AM, Tim Streatert...@clothears.org.uk  wrote:



I disagree that the nested function is a straw-man. I (just as the other
authors I'd linked to describing the arrow pattern of code) have seen
plenty of examples of similar code.


I guess what I meant was, that I'd never have written it that way in the first 
place, so as an example it felt contrived. Amateurs or people with no training 
(in particular physicists at CERN 40 years ago) should be kept well clear of 
the goto. I'd probably write your function like this:

function val_nested ($name = null, $value = null, $is_mutable = false)
  {

  static $values   = array();
  static $mutables = array();

  if  ($name===null)  return $values;

  if  ($value===null)  return isset($values[$name]) ? $values[$name] : null;

[-- SNIPP --]

I always add blank lines for clarity. Remove those and the above is 30% shorter 
than yours - as far as I could tell, none of the else clauses was required.

My approach is:

1) deal with the trivial and error cases first


Some say you should never return early from a function... I too think 
that early returns can improve the readability of a function-- 
especially if they are short snippets of logic that clearly indicate the 
reason for an early exit (usually edge case constraints).


:)

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Re: Long Live GOTO

2012-02-06 Thread Robert Cummings

On 12-02-06 11:35 AM, Alain Williams wrote:

On Mon, Feb 06, 2012 at 09:28:10AM -0700, Larry Martell wrote:

On Mon, Feb 6, 2012 at 9:23 AM, Alain Williamsa...@phcomp.co.uk  wrote:



If I survey my code I find that I use one GOTO in about 4,000 lines of code -
that I do not find excessive.

There are, however, people who consider any GOTO as communion with the devil.
IMHO: not so - if used sparingly.


Just for another data point, the FAA does not allow gotos in any code
that goes into an airplane.


And your point is ?

It just means that someone in the FAA does not like GOTO.
If you can come up with their reasoned argument for the ban I will look at it,
but without that the data point does not have much value - IMHO.


The date for when the ban was imposed might be interesting too... 
perhaps it hasn't been revisited since the 70s.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Reading only RGB portion of an image, file_get_conents minus file headers etc

2012-01-23 Thread Robert Cummings

On 12-01-23 01:32 PM, Alex Nikitin wrote:

If you don't mind me asking, if you want performance, which is kind of
essential if you are processing a large number of files, why are you
doing it in PHP?

--
The trouble with programmers is that you can never tell what a
programmer is doing until it’s too late.  ~Seymour Cray


Hi Alex,

If you're processing a large number of files, the bottleneck could just 
as likely be the hard drive read/write and not so much PHP. And what's a 
large number of files? 50? 100? 1000? 100? Remember, PHP internal 
functions are usually wrappers around compiled C code... the shuffling 
around in the PHP engine itself can be quite tiny.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Reading only RGB portion of an image, file_get_conents minus file headers etc

2012-01-23 Thread Robert Cummings

On 12-01-23 09:29 PM, Alex Nikitin wrote:

Have you done image processing? In my experience, with image
generation, photography and processing, typically you are bound by
resources when processing large amount of files than your connection,
or sometimes even disk io.


It really depends on what you're doing with images, if it's intensive 
processing that's already implemented in the gd or imagick library to 
which you can just punt, then how much overhead do you think PHP is 
really going to add since these are C implemented libraries? Sure, if 
you are manipulating pixels one by one within your PHP code you may be 
running into resource issues, but for scaling images, or cropping, or 
even clipping and overlaying... you're not usually doing a whole lot 
within PHP itself. The love is happening in the C code in these cases. 
This is why when working with these libs you get a resource handle and 
not a string. The resource handle almost certainly maps to a native GD 
or imagick structure.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] number_format

2011-12-19 Thread Robert Cummings

On 11-12-19 11:08 AM, Bastien Koert wrote:

On Mon, Dec 19, 2011 at 9:19 AM, Floyd Reslerfres...@adex-intl.com  wrote:

In the previous version of PHP we were using, I could pass a string to number_format and 
it would just change it to a 0 without complaint.  With 5.3.6 I get an expects 
double error.  I don't suppose there's a way to make it work like it used to???  
I'm dealing with really old code that wasn't very well structured.

Thanks!
Floyd


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




Could you check it before formatting? Or if the data is coming from
the db, force it to 0 if null?

$var = (is_double($number_var)) ? $number_var : 0;


Or possibly:

?php

number_format( (float)$your_input, 2 );

?

Cheers,
Rob.







--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Re: Preferred Syntax

2011-12-18 Thread Robert Cummings

On 11-12-17 09:42 AM, Eric Butera wrote:

Hi Adam,

Thanks for the reply, noted!  I was coming from the angle that I've
had to deal with a lot of code that is 2000 lines of
php/html/javascript inside heredocs, mixed quote escaping, etc.  I was
hoping to prevent that from becoming a new thing in this persons code
if that was the case.  Apologies for assuming.


I understand that point of view, but your overarching statement of using 
full separation of presentation and logic at all times is wrong in the 
general case. Sometimes a 10 line script of mixed logic and presentation 
is just what the doctor ordered... but that might happen more often when 
doing small concise command-line scripts :)


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Re: Preferred Syntax

2011-12-15 Thread Robert Cummings

On 11-12-15 02:50 AM, Ross McKay wrote:

On Wed, 14 Dec 2011 07:59:46 -0500, Rick Dwyer wrote:


Can someone tell me which of the following is preferred and why?

  echo a style='text-align:left;size:14;font-weight:bold' href='/
mypage.php/$page_id'$page_name/abr;

  echo a style='text-align:left;size:14;font-weight:bold' href='/
mypage.php/.$page_id.'.$page_name./abr;
[...]


Just to throw in yet another possibility:

echoHTML
a style=text-align:left;size:14;font-weight:bold
href=/mypage.php/$page_id$page_name/abr
HTML;

I love HEREDOC for slabs of HTML, sometimes SQL, email bodies, etc.
because they allow you to drop your variables into the output text
without crufting up the formatting with string concatenation, AND they
allow you to use double quotes which can be important for HTML
attributes that may contain single quotes.

So whilst either above option is fine for the specific context, I prefer
HEREDOC when there's attributes like href.

But what is preferred is rather dependent on the preferrer.


Heredoc and Nowdoc are nice but I hate the way they muck up my 
indentation aesthetics. As such when I use them I use as minimalist a 
terminator as possible:


?php

echo _
a href=foo.htmlBlah blah blah/a
_;

?

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Preferred Syntax

2011-12-14 Thread Robert Cummings

On 11-12-14 01:10 PM, David Harkness wrote:

On Wed, Dec 14, 2011 at 4:59 AM, Rick Dwyerrpdw...@earthlink.net  wrote:


Can someone tell me which of the following is preferred and why?

  echo a style='text-align:left;size:**14;font-weight:bold'
href='/mypage.php/$page_id'$**page_name/abr;

  echo a style='text-align:left;size:**14;font-weight:bold'
href='/mypage.php/.$page_id.**'.$page_name./abr;



On Wed, Dec 14, 2011 at 9:09 AM, Peter Fordp...@justcroft.com  wrote:


Horses for courses. I use whatever I feel like at the time, and mix
various styles, as long as it's readable!



I agree with Peter here. I would bet that the string with embedded
variables is parsed once when the file is loaded and turned into the same
bytecode as the second form.

If you are going to use the second style above, I would at least switch the
quotes around so you can use the double-quotes in the HTML as that to me
reads nicer and avoids the minor cost of scanning the string for embedded
code. I also put spaces around the dots to make the variable concatenation
easier to spot when skimming it.

 echo 'a style=text-align:left;size:**14;font-weight:bold
href=/mypage.php/' . $page_id . '' . $page_name .'/abr';


+1 on the use of single quotes instead of double quotes. With a bytecode 
cache it's not really going to make a lick of difference, but using 
double quotes for HTML seems far more palatable to me. I too like to 
pull the variable out into code space. I also like to format my 
attributes for easy reading and commenting:


echo 'a'
.' style=text-align:left;size:**14;font-weight:bold'
.' href=/mypage.php/'.$page_id.''
.''
.$page_name
.'/a'
.'br /';

Although, I usually only do the above for tags that have lots of 
attributes. Otherwise the following is more likely:


echo 'div class=some-class'
.'Something something'
.'/div';

As I said before though, a bytecode cache with any degree of 
optimization should make any particular style have zero impact on 
runtime (beyond original parse) by optimizing the strings into a minimal 
set of operations. For instance 'foo'.'fee' would be coverted to 
'foofee' by the bytecode engine.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] How to use a variable variable with an array

2011-12-14 Thread Robert Cummings

On 11-12-14 01:11 AM, Laruence wrote:

On Wed, Dec 14, 2011 at 9:27 AM, Nils Leidecknils.leid...@leidex.net  wrote:

Hi Al,

many thanks for your feedback. Unfortunately I don’t know the deepness of the 
array so I can’t use the nested foreach() idea :-( Let me try to simplify my 
question (which also helps myself to clarify my process ;-)

I have a variable where the value is a string that is exactly the path to the 
array value:

[code]
$arrayPath = ['user_interface’][‘design']['my_colors']['item_number_one’]”;
[/code]

And I have an array that has all the details:

[code]
$myArray = coolFunction(‘getArray’);
[/code]

The question is, how can I use these both informations to return a value from 
the $myArray?

Examples I tried unsuccessfully:

[code]
[...]
echo $myArray$arrayPath;
echo $myArray{$arrayPath};
echo $myArray${arrayPath};
echo $myArray${$arrayPath};
echo $myArray.$arrayPath;
echo $myArray.$arrayPath;
[...]
[/code]
etc...

your feedback is much much much appreciated!!!

Cheers, Nils
--
http://webint.cryptonode.de / a Fractal project


for you quesion, try eval:
?php
$arr = array(a=array(b=array(c)));
$key = ['a']'['b];
$value = eval(return \$arr. $key .;);
?

ps: your requirement is a little odd :)


If the solution is to use eval() then you've almost certainly come up 
with the wrong answer.


To get the desired answer you can either use recursion to recursively 
index the array as necessitated by the path or you can use references 
to incremententally step through the array. Example:


?php

$path = 'path/to/data/in/my/arbitrarily/deep/array';
$array = $someBigFatArray;

$focus = $array();
foreach( explode( '/', $path ) as $step )
{
if( isset( $focus[$step] ) )
{
$focus = $focus[$step];
}
else
{
unset( $focus );
$focus = null;
break;
}
}

echo $focus;

?

You can wrap this puppy in a function too... and it will be faster than 
the recursive version someone else wrote because it doesn't incur the 
overhead of multiple function calls (for depths greater than 1).


Recursion is great, recursion is elegant, computer science professors 
love recursion, but it can also be a resource pig and PHP doesn't do 
tail recursion :)


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] inotify

2011-12-08 Thread Robert Cummings

Not to my knowledge.



On 11-12-08 10:52 AM, Floyd Resler wrote:

Is there any way to get who moved a file, deleted a file, etc. from inotify?  I 
search and couldn't find a way but thought someone on the list might know.

Thanks!
Floyd




--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Sniping on the List

2011-11-19 Thread Robert Cummings

On 11-11-19 03:14 AM, Lester Caine wrote:

Robert Cummings wrote:

It's Friday... traditionally content anal-ness has been somewhat disregarded on
this day. Need one go through the archives to see if you're being a tad
hypocritical?


Although it only seems to be this latest thread that seems to have got totally
OTT even for a Friday. And I think 'Friday Distraction' is a fairly recent
development that was never every Friday ...
I have the archive since 2004 on-line here and it sort of started on 09, but
there were only a few each year - usually over the summer? And most of them were
realistic tangential discussions rather than totally anal.
Personally, this last one has become irritating and obviously others find the
same thing?


I don't know... I haven't heard from many on the list and there seems to 
be as many responding as wishing it would stop. That said, why re-hash 
it on a Saturday (or as the case may be... so close to Saturday). Were 
you hoping to continue it over the weekend? Also, you say it seems to 
have started around 2009... that's almost 3 years. I consider that a 
fairly long standing trend and not quite as recent as you make it 
sound. I've been on this list in one form or another since 2000... I'd 
say for the most part these kinds of conversations crop up with fair 
regularity. I'm not saying every day, but often enough that I don't 
understand the sudden whining-- and as I've also pointed out, there's 
likely a degree of hypocrisy afoot. Either way, I'm done with the 
thread, enjoy your weekend.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Sniping on the List

2011-11-18 Thread Robert Cummings

On 11-11-18 05:15 AM, Tim Streater wrote:

On 18 Nov 2011 at 05:40, Robert Cummingsrob...@interjinn.com  wrote:


without a proof it's just farts in the wind :) No more valid than a
theory of creation or the big ass spaghetti thingy majingy dude. Folded


The theory of creation is not a theory. It's a hypothesis, as is scientific 
creationism.


From Merriam-Webster's online dictionary:

Hypothesis - Synonyms: theory, proposition, supposition, thesis

http://www.merriam-webster.com/dictionary/hypothesis


Thus before the big bang
is perfectly valid whether we could perceive it or not.


Not really. It's as meaningless as asking what's north of the North Pole.


No, this is a false analogy. Again from Merriam-Webster:

north pole: the northernmost point of the earth

As such, by definition there can be no further north than the north 
pole. No such equivalent exists for the big bang event. Beginning of the 
universe? YES. Beginning of time? NO!


Given the discussion, I think the following is in order: BAZINGA * 2

Thank you, I won't be here all day!

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Sniping on the List

2011-11-18 Thread Robert Cummings

On 11-11-18 10:03 AM, Curtis Maurand wrote:



Robert Cummings wrote:
Robert Cummings wrote:




Given the discussion, I think the following is in order: BAZINGA * 2

  And what does any of this have to do with PHP?  It's time to
end this thread.


It's Friday... traditionally content anal-ness has been somewhat 
disregarded on this day. Need one go through the archives to see if 
you're being a tad hypocritical?


Cheese,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Sniping on the List

2011-11-17 Thread Robert Cummings

On 11-11-17 11:33 AM, HallMarc Websites wrote:



To all:

Okay, so now that we have had people reply, here's my take.

The Unix timestamp started on 01 Jan 1970 00:00:00 + -- and that was

a

Thursday.


The second before (i.e., 31 December, 1969 23:59:59:59 + ) was null,

which was Wednesday.

I take issue with this. The second before was -1 seconds from the epoch.

Null

is the absence of a value, so you can't get to null by simple arithmetic.

I learnt

about negative numbers from the Greeks. And no, I'm not going to comment
on their current mathematical difficulties.

Hmm.

D'oh!

But the point still stands: -1 !== null.

-Stuart



What if we were to throw in quantum duality in here?  Null and !Null at the
same time


False

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Sniping on the List

2011-11-17 Thread Robert Cummings

On 11-11-17 06:24 PM, Fredric L. Rice wrote:

Consider this -- do you think the second before
the Big Bang was negative or null?

I don't know. There's no point concerning ourselves
with unanswerable questions.


The question itself is a logical absurdity since there was no time prior
to the Big Bang. The advent of time began when the dimention we perceive
as the passage of time froze out of folded reality during the expansion
phases's symmertry breaking period, there is not only no answer to what
happened before, even suggesting there *was* a before is not possible.

It's another nail in the coffin of deity constructors.


By you're reasoning since I did not exist before 1974 then time itself 
could not possibly have existed before then either since I was not in 
existence to perceive it. That's as ludicrous as suggesting time did not 
exist before the big bang (presuming this model is correct).  Also, 
them's some fancy shmancy words you're slinging about up there, but 
without a proof it's just farts in the wind :) No more valid than a 
theory of creation or the big ass spaghetti thingy majingy dude. Folded 
shmeality and phases of whatsyamacallit may well be true, but 
provability of the non-existence of time before the big bang theory is 
not provable by this model. However, what is valid is to take a point of 
reference in time and infer a period before it. Thus before the big bang 
is perfectly valid whether we could perceive it or not.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Sniping on the List

2011-11-17 Thread Robert Cummings

On 11-11-18 12:40 AM, Robert Cummings wrote:

On 11-11-17 06:24 PM, Fredric L. Rice wrote:

Consider this -- do you think the second before
the Big Bang was negative or null?

I don't know. There's no point concerning ourselves
with unanswerable questions.


The question itself is a logical absurdity since there was no time prior
to the Big Bang. The advent of time began when the dimention we perceive
as the passage of time froze out of folded reality during the expansion
phases's symmertry breaking period, there is not only no answer to what
happened before, even suggesting there *was* a before is not possible.

It's another nail in the coffin of deity constructors.


By you're reasoning since I did not exist before 1974 then time itself
could not possibly have existed before then either since I was not in
existence to perceive it. That's as ludicrous as suggesting time did not
exist before the big bang (presuming this model is correct).  Also,
them's some fancy shmancy words you're slinging about up there, but
without a proof it's just farts in the wind :) No more valid than a
theory of creation or the big ass spaghetti thingy majingy dude. Folded
shmeality and phases of whatsyamacallit may well be true, but
provability of the non-existence of time before the big bang theory is
not provable by this model. However, what is valid is to take a point of
reference in time and infer a period before it. Thus before the big bang
is perfectly valid whether we could perceive it or not.


The following pretty much sums up the entire argument:

http://shorl.com/tebrakefesahe

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] {} forms

2011-11-16 Thread Robert Cummings

On 11-11-16 09:27 AM, Richard Quadling wrote:

On 16 November 2011 13:56, Tim Streatert...@clothears.org.uk  wrote:

I'm looking at the source of a web sockets server and I see these various forms:

  ws://{$host}{$path}
  HTTP/1.1 ${status}\r\n

Are these simply equivalent to:

  ws:// . $host . $path
  HTTP/1.1  . $status . \r\n;

and if so, is there any particular benefit to using that form? Or if not, what 
do they mean?

(I've read up about variable variables).



If you want to embed $array[CONSTANT], then the {} is used.

I use {} out of habit for non arrays. Not sure if there is an impact.



The braces are also used when the characters following the variable are 
also valid variable name characters :)


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Variable question

2011-10-01 Thread Robert Cummings

On 11-10-01 02:03 PM, Mike Mackintosh wrote:


On Oct 1, 2011, at 1:59 PM, Ron Piggott wrote:



If $correct_answer has a value of 3 what is the correct syntax needed to use 
echo to display the value of $trivia_answer_3?

I know this is incorrect, but along the lines of what I am wanting to do:

echo $trivia_answer_$correct_answer;

$trivia_answer_1 = “1,000”;
$trivia_answer_2 = “1,250”;
$trivia_answer_3 = “2,500”;
$trivia_answer_4 = “5,000”;

Ron




www.TheVerseOfTheDay.info


Best bet would to toss this into either an object or array for simplification, 
otherwise that type of syntax would need the use of eval.

example:  eval('echo $trivia_answer_'.$correct_answer.';');

best bet would be to..

$trivia_answer = array();

$trivia_answer[1] = 1000;
$trivia_answer[2] = 1250;
$trivia_answer[3] = 2500;
$trivia_answer[4] = 5000;

echo $trivia_answer[$correct_answer];


Agreed the OP's value list isn't optimal, but eval is not needed to 
address the solution:


?php

$trivia_answer_1 = 1,000;
$trivia_answer_2 = 1,250;
$trivia_answer_3 = 2,500;
$trivia_answer_4 = 5,000;

$answer
= isset( ${'trivia_answer_'.$correct_answer} )
? ${'trivia_answer_'.$correct_answer}
: 'Not found';

echo $answer.\n;
?

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Re: Repetitive answers . . .

2011-09-16 Thread Robert Cummings

On 11-09-15 09:31 PM, Joshua Stoutenburg wrote:

class baboon
{
 $ammo = '';

 public __construct($ammo)
 {
 $this-ammo = $ammo;
 }

 public function flingAt($target)
 {
 $target-flingAlert($this-ammo);
 }
}


$me = new baboon($information);
$you = new baboon();
$me-flingAt($you);


I'm sorry, but this is unnacceptably ambiguous. Due to the poor design I 
don't know whether to duck or open my mouth for a treat. Let's make the 
program a bit more flexible and useful...


?php

class baboon extends mammal
{
public function fling( $something, $target )
{
$target-flingAlert( $something, $target );
}

public function openMouth()
{
echo Aaah\n;
}

public function evade()
{
if( rand( 1, 100 ) = 70 )
{
echo Pheeew! That was close.\n;
}
else
{
echo SPLAT!\n;
}
}

public function flingAlert( $something, $target )
{
switch( $something )
{
case 'treat':
{
$this-openMouth();
break;
}

default:
{
$this-evade();
break;
}
}
}
}

$me = new baboon();
$you = new baboon();

$me-fling( 'scooby snack', $you );
$me-fling( 'poo', $you );

?

I love Friday :)

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Episode 2 - All The Cool Kids Use Ruby

2011-09-16 Thread Robert Cummings

On 11-09-16 02:30 PM, Daevid Vincent wrote:

http://www.youtube.com/watch?v=5GpOfwbFRcs

LOLercopter


That's just fantastic!

Have a great weekend.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] What would you like to see in most in a text editor?

2011-09-13 Thread Robert Cummings

On 11-09-13 03:56 PM, Brad Huskins wrote:

Hello all you php coders out there,

I'm doing an Open Source text editor (just a hobby) that's designed for
PHP developers and is accessible through the web. This has been stewing
for a while, and has gotten to the point where I can use it for my own
work. I would like any feedback on things that people really
like/dislike about their current editors, as I believe some of these
things could be resolved in mine.

I currently have username/password protection (with Salted-Hash
passwords), a file-system browser, file loading/saving, and syntax
highlighting -- and these things seem to work reasonably well. As well,
most things about the editor are scriptable with JavaScript. This would
seem to imply that in a few weeks I would have something useful. So I
would like to get some feedback on what features people would most want,
since I am still at a very flexible stage in development.

If you would like to see what I have, you can go to
un1tware.wordpress.com. You can also peruse the code at
github.com/bhus/scriptr. In particular, the README on github gives a
little bit better rationality for why something like this might be
useful, and how things are currently structured.


I'm a big fan of editors that work in the terminal.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Re: Repetitive answers . . .

2011-09-09 Thread Robert Cummings

On 11-09-09 02:19 PM, Joshua Stoutenburg wrote:

Is there a way to reconfigure gmail settings to prevent this?


Yes, just filter all PHP mail to junk. But in all reality, I can't 
imagine an email filter, short of genius AI, that could determine that 
one message was the best answer and then automatically remove all others 
that follow.


Cheers,
Rob
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Re: Repetitive answers . . .

2011-09-09 Thread Robert Cummings

On 11-09-09 02:24 PM, George Langley wrote:

On 2011-09-09, at 11:34 AM, Marc Guay wrote:


That low-hanging fruit is too hard for some to resist...

---
Phishing is a art.


Did anyone notice it's Friday?

Oblig: http://www.youtube.com/watch?v=sUntx0pe_qI

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Code should be selv-maintaining!

2011-09-01 Thread Robert Cummings

On 11-08-31 08:20 PM, Tedd Sperling wrote:

On Aug 30, 2011, at 3:09 PM, Robert Cummings wrote:


On 11-08-30 11:36 AM, Richard Quadling wrote:

On 30 August 2011 15:04, Tedd Sperlingtedd.sperl...@gmail.com   wrote:

To all:

I prefer the Whitesmiths style:

http://rebel.lcc.edu/sperlt/citw229/brace-styles.php

But style is really up to the individual -- what works best for you is the 
best (unless it's a team effort or the clients demand).

Cheers,

tedd


At last Someone's code I could read without having to reformat it
every bloody time!!!

http://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style


You're just saying that so Tedd will be your friend!! Come now, let's be honest 
with everyone... Whitesmith's is -GLEE! ;)

Cheers,
Rob.


No, not indenting braces is T LYY.

Make things uniform -- a condition followed by indented code located between 
equally indented braces makes sense to me. How people read other code styles is 
a mystery to me.


Come now Tedd! It's only Thursday and yet you jest so!!

:)

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Code should be selv-maintaining!

2011-09-01 Thread Robert Cummings

On 11-09-01 01:44 AM, Ross McKay wrote:

On Tue, 30 Aug 2011 10:04:54 -0400, Tedd Sperling wrote:


I prefer the Whitesmiths style:

http://rebel.lcc.edu/sperlt/citw229/brace-styles.php

But style is really up to the individual -- what works best for you
is the best (unless it's a team effort or the clients demand).


I note on your page that you prefer Whitesmiths (truly ugly!) style even
for JavaScript. I'd strongly recommend against that, and also Allman
style, due to semicolon insertion. e.g. (randomly selected from Google)

http://encosia.com/in-javascript-curly-brace-placement-matters-an-example/
http://robertnyman.com/2008/10/16/beware-of-javascript-semicolon-insertion/

Sure, instances of the problem are minimal, but if you're in the habit
of Dangerous Open Brace Placement then you just might fall afoul of it.

Besides, my editor (Geany) folds code mostly neatly with KR :)


That's because JavaScript is broken in some ways. As much as I like 
JavaScript, some parts of the language were thrown together by flinging 
crap at a fan and seeing what sticks to the wall... this being a prime 
example.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Code should be selv-maintaining!

2011-09-01 Thread Robert Cummings

On 11-09-01 02:39 AM, Ross McKay wrote:

Robert Cummings wrote:


That's because JavaScript is broken in some ways. As much as I like
JavaScript, some parts of the language were thrown together by flinging
crap at a fan and seeing what sticks to the wall... this being a prime
example.


Sounds a lot like PHP :) which I must add I love dearly, though it
certainly resembles your remark much more closely than JavaScript.

But on-topic, novices using a coding style and feeling their way around
a new language would be better served by the 1TB style than anything
that easily allows statement insertion (either by them, or by silly
language defects like JavaScript's semicolon insertion).


Oh for sure, it's necessary that novices have something towards which 
they can evolve. If they start with Allman's then how could they improve 
their brace style :)


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Code should be selv-maintaining!

2011-08-30 Thread Robert Cummings

On 11-08-30 11:36 AM, Richard Quadling wrote:

On 30 August 2011 15:04, Tedd Sperlingtedd.sperl...@gmail.com  wrote:

To all:

I prefer the Whitesmiths style:

http://rebel.lcc.edu/sperlt/citw229/brace-styles.php

But style is really up to the individual -- what works best for you is the 
best (unless it's a team effort or the clients demand).

Cheers,

tedd


At last Someone's code I could read without having to reformat it
every bloody time!!!

http://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style


You're just saying that so Tedd will be your friend!! Come now, let's be 
honest with everyone... Whitesmith's is -GLEE! ;)


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



  1   2   3   4   5   6   7   8   9   10   >