[PHP] including PHP code from another server..

2012-03-26 Thread rene7705
Hi.

My last thread got derailed into a javascript and even photoshop
discussion, and while I can't blame myself for that really, this time I
would like to bring a pure PHP issue to your scrutiny.

I run several sites now, on the same shared hoster, but with such a setup
that I cannot let PHP require() or include() code from a central place
located on another domain name on the same shared hosting account, not the
normal way at least.
$_SERVER['DOCUMENT_ROOT'] is a completely different path for each of the
domains on the same hosting account, and obviously you can't access one
domain's directory from another domain.

Hoster support's reply is A) I dont know code, B) You can't include code
from one domain on another and C) use multiple copies, 1 for each domain

But that directory (my opensourced /code in the zip on
http://mediabeez.wsbtw), takes a while to update to my hoster, many
files.
Plus, as I add more domains that use the same code base, my overhead and
waiting time increases lineary at a steep incline.

So.. Since all of this code is my own, and tested and trusted, I can just
eval(file_get_contents('
http://sitewithwantedcode.com/code/get_php.php?file=/code/sitewide_rv/autorun.php'))
hehe
And get_php.php takes care of the nested includes by massaging what it
retrieves. Or so is my thinking.

The problem I'm facing, and for which I'm asking your most scrutinous
feedback, is:
How would you transform _nested_ require(_once) and include(_once)? I
haven't figured out yet how to transform a relative path include/require.
What about for instance a require_once($fileIwantNow)?
I do both in my /code tree atm.

For my own purposes, I could massage my own PHP in /code/libraries_rv and
/code/sitewide_rv manually, but I'd also like to be able to include a
single copy of the 3rd party free libs that I use in
/code/libraries(/adodb-5.10 for instance). And god knows how they might
include and require.

Plus, I'd like to turn this into another free how-to blog entry on
http://mediabeez.ws, plus accompanying code, so I think I might find some
free tips here again.

Greetings,
 from spring sun soaked amsterdam.nl,
 Rene


Re: [PHP] including PHP code from another server..

2012-03-26 Thread Stuart Dallas
REMOVE THAT SCRIPT FROM YOUR SERVER RIGHT NOW!

See follow-up email direct to you for the reason!

On 26 Mar 2012, at 14:53, rene7705 wrote:

> Hi.
> 
> My last thread got derailed into a javascript and even photoshop
> discussion, and while I can't blame myself for that really, this time I
> would like to bring a pure PHP issue to your scrutiny.
> 
> I run several sites now, on the same shared hoster, but with such a setup
> that I cannot let PHP require() or include() code from a central place
> located on another domain name on the same shared hosting account, not the
> normal way at least.
> $_SERVER['DOCUMENT_ROOT'] is a completely different path for each of the
> domains on the same hosting account, and obviously you can't access one
> domain's directory from another domain.
> 
> Hoster support's reply is A) I dont know code, B) You can't include code
> from one domain on another and C) use multiple copies, 1 for each domain
> 
> But that directory (my opensourced /code in the zip on
> http://mediabeez.wsbtw), takes a while to update to my hoster, many
> files.
> Plus, as I add more domains that use the same code base, my overhead and
> waiting time increases lineary at a steep incline.
> 
> So.. Since all of this code is my own, and tested and trusted, I can just
> eval(file_get_contents('
> http://sitewithwantedcode.com/code/get_php.php?file=/code/sitewide_rv/autorun.php'))
> hehe
> And get_php.php takes care of the nested includes by massaging what it
> retrieves. Or so is my thinking.
> 
> The problem I'm facing, and for which I'm asking your most scrutinous
> feedback, is:
> How would you transform _nested_ require(_once) and include(_once)? I
> haven't figured out yet how to transform a relative path include/require.
> What about for instance a require_once($fileIwantNow)?
> I do both in my /code tree atm.
> 
> For my own purposes, I could massage my own PHP in /code/libraries_rv and
> /code/sitewide_rv manually, but I'd also like to be able to include a
> single copy of the 3rd party free libs that I use in
> /code/libraries(/adodb-5.10 for instance). And god knows how they might
> include and require.
> 
> Plus, I'd like to turn this into another free how-to blog entry on
> http://mediabeez.ws, plus accompanying code, so I think I might find some
> free tips here again.
> 
> Greetings,
> from spring sun soaked amsterdam.nl,
> Rene


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



Re: [PHP] including PHP code from another server..

2012-03-26 Thread Simon Schick
Hi, Rene

I just want to say the same ... whatever you're trying to do here - it
will end up in a major security-isse that (I think) you won't fix that
soon as someone has hacked your server.

That sounds like you don't wanna pay 10$ per month for a good
multiple-domain-hosting solution.
If you're searching for something cheap for multi-domains, take a look
at providers like DreamHost or something similar.

Bye
Simon

2012/3/26 Stuart Dallas :
> REMOVE THAT SCRIPT FROM YOUR SERVER RIGHT NOW!
>
> See follow-up email direct to you for the reason!
>
> On 26 Mar 2012, at 14:53, rene7705 wrote:
>
>> Hi.
>>
>> My last thread got derailed into a javascript and even photoshop
>> discussion, and while I can't blame myself for that really, this time I
>> would like to bring a pure PHP issue to your scrutiny.
>>
>> I run several sites now, on the same shared hoster, but with such a setup
>> that I cannot let PHP require() or include() code from a central place
>> located on another domain name on the same shared hosting account, not the
>> normal way at least.
>> $_SERVER['DOCUMENT_ROOT'] is a completely different path for each of the
>> domains on the same hosting account, and obviously you can't access one
>> domain's directory from another domain.
>>
>> Hoster support's reply is A) I dont know code, B) You can't include code
>> from one domain on another and C) use multiple copies, 1 for each domain
>>
>> But that directory (my opensourced /code in the zip on
>> http://mediabeez.wsbtw), takes a while to update to my hoster, many
>> files.
>> Plus, as I add more domains that use the same code base, my overhead and
>> waiting time increases lineary at a steep incline.
>>
>> So.. Since all of this code is my own, and tested and trusted, I can just
>> eval(file_get_contents('
>> http://sitewithwantedcode.com/code/get_php.php?file=/code/sitewide_rv/autorun.php'))
>> hehe
>> And get_php.php takes care of the nested includes by massaging what it
>> retrieves. Or so is my thinking.
>>
>> The problem I'm facing, and for which I'm asking your most scrutinous
>> feedback, is:
>> How would you transform _nested_ require(_once) and include(_once)? I
>> haven't figured out yet how to transform a relative path include/require.
>> What about for instance a require_once($fileIwantNow)?
>> I do both in my /code tree atm.
>>
>> For my own purposes, I could massage my own PHP in /code/libraries_rv and
>> /code/sitewide_rv manually, but I'd also like to be able to include a
>> single copy of the 3rd party free libs that I use in
>> /code/libraries(/adodb-5.10 for instance). And god knows how they might
>> include and require.
>>
>> Plus, I'd like to turn this into another free how-to blog entry on
>> http://mediabeez.ws, plus accompanying code, so I think I might find some
>> free tips here again.
>>
>> Greetings,
>> from spring sun soaked amsterdam.nl,
>> Rene
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

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



Re: [PHP] including PHP code from another server..

2012-03-26 Thread Stuart Dallas
On 26 Mar 2012, at 15:17, Simon Schick wrote:

> Hi, Rene
> 
> I just want to say the same ... whatever you're trying to do here - it
> will end up in a major security-isse that (I think) you won't fix that
> soon as someone has hacked your server.

I couldn't care less about Rene's stuff. It's compromising the security of 
every customer on that server, and that's not acceptable. Security is arguably 
more important when using shared servers because your lack of focus on security 
issues has consequences for everyone else on that server, and potentially on 
that network.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

Re: [PHP] including PHP code from another server..

2012-03-26 Thread Stuart Dallas
On 26 Mar 2012, at 14:53, rene7705 wrote:

> My last thread got derailed into a javascript and even photoshop
> discussion, and while I can't blame myself for that really, this time I
> would like to bring a pure PHP issue to your scrutiny.
> 
> I run several sites now, on the same shared hoster, but with such a setup
> that I cannot let PHP require() or include() code from a central place
> located on another domain name on the same shared hosting account, not the
> normal way at least.
> $_SERVER['DOCUMENT_ROOT'] is a completely different path for each of the
> domains on the same hosting account, and obviously you can't access one
> domain's directory from another domain.
> 
> Hoster support's reply is A) I dont know code, B) You can't include code
> from one domain on another and C) use multiple copies, 1 for each domain
> 
> But that directory (my opensourced /code in the zip on
> http://mediabeez.wsbtw), takes a while to update to my hoster, many
> files.
> Plus, as I add more domains that use the same code base, my overhead and
> waiting time increases lineary at a steep incline.
> 
> So.. Since all of this code is my own, and tested and trusted, I can just
> eval(file_get_contents('
> http://sitewithwantedcode.com/code/get_php.php?file=/code/sitewide_rv/autorun.php'))
> hehe
> And get_php.php takes care of the nested includes by massaging what it
> retrieves. Or so is my thinking.
> 
> The problem I'm facing, and for which I'm asking your most scrutinous
> feedback, is:
> How would you transform _nested_ require(_once) and include(_once)? I
> haven't figured out yet how to transform a relative path include/require.
> What about for instance a require_once($fileIwantNow)?
> I do both in my /code tree atm.
> 
> For my own purposes, I could massage my own PHP in /code/libraries_rv and
> /code/sitewide_rv manually, but I'd also like to be able to include a
> single copy of the 3rd party free libs that I use in
> /code/libraries(/adodb-5.10 for instance). And god knows how they might
> include and require.
> 
> Plus, I'd like to turn this into another free how-to blog entry on
> http://mediabeez.ws, plus accompanying code, so I think I might find some
> free tips here again.

Don't do this. Use a central source to host your code by all means, but create 
constantly updated copies on every server that uses it. Since I use git for 
source control I make use of the submodule feature to make this simplicity 
itself. It's worth investing time in building the processes that ensure 
consistency between your various environments. The best ops strategy is the 
lazy op's strategy!

Set up cron scripts on each server to update that code periodically so 
everything is always up to date. I wouldn't recommend that unless you have good 
testing procedures in place before your code hits production, but from what 
I've seen I find the highly doubtful. However, sharing code at runtime over 
http is a very very very bad idea.

Even farms with hundreds or thousands of servers, all running the same 
application on a fast local network, don't share code in this way. Each server 
has its own copy of the code, and it's the deployment processes that ensure 
they're kept up to date.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

Re: [PHP] including PHP code from another server..

2012-03-26 Thread Curtis Maurand



rsync is your friend.

--C

Stuart Dallas
wrote:
> On 26 Mar 2012, at 14:53, rene7705 wrote:
> 
>> My last thread got derailed into a javascript and even
photoshop
>> discussion, and while I can't blame myself for
that really, this time I
>> would like to bring a pure PHP
issue to your scrutiny.
>>
>> I run several sites
now, on the same shared hoster, but with such a
>> setup
>> that I cannot let PHP require() or include() code from a
central place
>> located on another domain name on the same
shared hosting account, not
>> the
>> normal way at
least.
>> $_SERVER['DOCUMENT_ROOT'] is a completely different
path for each of the
>> domains on the same hosting account,
and obviously you can't access one
>> domain's directory from
another domain.
>>
>> Hoster support's reply is A) I
dont know code, B) You can't include code
>> from one domain on
another and C) use multiple copies, 1 for each domain
>>
>> But that directory (my opensourced /code in the zip on
>> http://mediabeez.wsbtw), takes a while to update to my hoster,
many
>> files.
>> Plus, as I add more domains that
use the same code base, my overhead and
>> waiting time
increases lineary at a steep incline.
>>
>> So..
Since all of this code is my own, and tested and trusted, I can
>> just
>> eval(file_get_contents('
>>
http://sitewithwantedcode.com/code/get_php.php?file=/code/sitewide_rv/autorun.php'))
>> hehe
>> And get_php.php takes care of the nested
includes by massaging what it
>> retrieves. Or so is my
thinking.
>>
>> The problem I'm facing, and for
which I'm asking your most scrutinous
>> feedback, is:
>> How would you transform _nested_ require(_once) and
include(_once)? I
>> haven't figured out yet how to transform a
relative path
>> include/require.
>> What about for
instance a require_once($fileIwantNow)?
>> I do both in my
/code tree atm.
>>
>> For my own purposes, I could
massage my own PHP in /code/libraries_rv
>> and
>>
/code/sitewide_rv manually, but I'd also like to be able to include a
>> single copy of the 3rd party free libs that I use in
>> /code/libraries(/adodb-5.10 for instance). And god knows how
they might
>> include and require.
>>
>>
Plus, I'd like to turn this into another free how-to blog entry on
>> http://mediabeez.ws, plus accompanying code, so I think I might
find
>> some
>> free tips here again.
> 
> Don't do this. Use a central source to host your code by all means,
but
> create constantly updated copies on every server that uses
it. Since I use
> git for source control I make use of the
submodule feature to make this
> simplicity itself. It's worth
investing time in building the processes
> that ensure consistency
between your various environments. The best ops
> strategy is the
lazy op's strategy!
> 
> Set up cron scripts on each
server to update that code periodically so
> everything is always
up to date. I wouldn't recommend that unless you have
> good
testing procedures in place before your code hits production, but
> from what I've seen I find the highly doubtful. However, sharing
code at
> runtime over http is a very very very bad idea.
> 
> Even farms with hundreds or thousands of servers, all
running the same
> application on a fast local network, don't
share code in this way. Each
> server has its own copy of the
code, and it's the deployment processes
> that ensure they're kept
up to date.
> 
> -Stuart
> 
> --
>
Stuart Dallas
> 3ft9 Ltd
> http://3ft9.com/


[PHP] CURL -d

2012-03-26 Thread QI.VOLMAR QI
I have this lines:
curl -H "Content-Type: application/json" -d "hello world" \
"http://api.pusherapp.com/apps/17331/channels/test_channel/events?"\

The option -d is for data. But How I can set it on the PHP  CURL extension?
I have found that if I set something like array('Hello Word', 'name'
=> 'my_name'), for the POST data may occurs. Can you give me a  little
help?

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



Re: [PHP] including PHP code from another server..

2012-03-26 Thread Lester Caine

Curtis Maurand wrote:

rsync is your friend.

and is even available for windows machines ...

--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

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



Re: [PHP] including PHP code from another server..

2012-03-26 Thread Alex Pojarsky
Now, as the issue adressed and script removed, can you please explain
what exactly are the issues of using such approach? I mean security
ones, not performance.

2012/3/26 Lester Caine :
> Curtis Maurand wrote:
>>
>> rsync is your friend.
>
> and is even available for windows machines ...
>
> --
> Lester Caine - G8HFL
> -
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk//
> Firebird - http://www.firebirdsql.org/index.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

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



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

2012-03-26 Thread Jay Blanchard
[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!


--
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 Stuart Dallas
On 26 Mar 2012, at 19:12, 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!

Square brackets in JSON represent arrays. Take their JSON, run it through 
json_decode, and assuming it decodes correctly compare the structure to what 
you already have. You should then be able to modify what you have so it 
generates JSON in the format they are expecting.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

--
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 Jay Blanchard
[snip]
> Square brackets in JSON represent arrays. Take their JSON, run it through 
> json_decode, and assuming it decodes correctly compare the structure to what 
> you already have. You should then be able to modify what you have so it 
> generates JSON in the format they are expecting.
[/snip]

Done. I knew about the square brackets. In the code being used the array, if 
blank, gets square brackets. For some reason an array containing actual data 
does not.


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



Re: [PHP] including PHP code from another server..

2012-03-26 Thread Stuart Dallas
On 26 Mar 2012, at 17:41, Alex Pojarsky wrote:

> Now, as the issue adressed and script removed, can you please explain
> what exactly are the issues of using such approach? I mean security
> ones, not performance.

It's the wrong solution to a process and organisation problem. Ultimately it's 
not really a problem IF you control every part of the infrastructure. Rene 
clearly doesn't so it has implications for everyone sharing that 
infrastructure, and anyone using the applications hosted there.

* It requires the host to enable allow_url_fopen which means every single 
script on the server is then able to include/require URLs. It just needs one of 
them to have a related vulnerability and suddenly people can execute arbitrary 
PHP code on the server.

* Rene mentioned that the code is open source. This implies that the security 
risk is lessened because the code that is being made publicly accessible is 
already publicly accessible, so the opportunity for someone to find 
vulnerabilities already exists. It gets an order of magnitude worse if other 
people start ignorantly using his code because they're essentially giving him 
the ability to execute arbitrary PHP code on their server. Not good no matter 
how much he protests that he won't "be evil."

* You specifically wished to exclude performance from the discussion, but 
scalability is potentially a big issue here and should not be completely 
ignored.

I think the real issue for Rene is that of perceived complexity. The idea of 
having to manually keep many copies of the same code in sync is what leads to 
finding solutions like this one. This solution leads to unnecessary network 
traffic and introduces potential security risks that go way beyond your own 
code, and even if it's not a big issue now it has the potential to become 
catastrophic!

I'd put a fair amount of cash on my guess that Rene is not using any form of 
source control. To me that is the best solution to this problem. Curtis 
mentioned rsync which will also do the job, but in my view you're nuts if 
you're not using some form of source control already, and building a largely 
automated process around that is trivial and automatically audited.

Rene: please read a book / website / something on PHP security. Some things are 
important whether you believe they are or not.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

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



Re: [PHP] including PHP code from another server..

2012-03-26 Thread Alex Pojarsky
I understand what performance issues this brings, but as for security
was just a bit curious. You have just showed me what I was thinking
about, but you wrote it much better, clear and structured.

Thank you.

2012/3/26 Stuart Dallas :
> On 26 Mar 2012, at 17:41, Alex Pojarsky wrote:
>
>> Now, as the issue adressed and script removed, can you please explain
>> what exactly are the issues of using such approach? I mean security
>> ones, not performance.
>
> It's the wrong solution to a process and organisation problem. Ultimately 
> it's not really a problem IF you control every part of the infrastructure. 
> Rene clearly doesn't so it has implications for everyone sharing that 
> infrastructure, and anyone using the applications hosted there.
>
> * It requires the host to enable allow_url_fopen which means every single 
> script on the server is then able to include/require URLs. It just needs one 
> of them to have a related vulnerability and suddenly people can execute 
> arbitrary PHP code on the server.
>
> * Rene mentioned that the code is open source. This implies that the security 
> risk is lessened because the code that is being made publicly accessible is 
> already publicly accessible, so the opportunity for someone to find 
> vulnerabilities already exists. It gets an order of magnitude worse if other 
> people start ignorantly using his code because they're essentially giving him 
> the ability to execute arbitrary PHP code on their server. Not good no matter 
> how much he protests that he won't "be evil."
>
> * You specifically wished to exclude performance from the discussion, but 
> scalability is potentially a big issue here and should not be completely 
> ignored.
>
> I think the real issue for Rene is that of perceived complexity. The idea of 
> having to manually keep many copies of the same code in sync is what leads to 
> finding solutions like this one. This solution leads to unnecessary network 
> traffic and introduces potential security risks that go way beyond your own 
> code, and even if it's not a big issue now it has the potential to become 
> catastrophic!
>
> I'd put a fair amount of cash on my guess that Rene is not using any form of 
> source control. To me that is the best solution to this problem. Curtis 
> mentioned rsync which will also do the job, but in my view you're nuts if 
> you're not using some form of source control already, and building a largely 
> automated process around that is trivial and automatically audited.
>
> Rene: please read a book / website / something on PHP security. Some things 
> are important whether you believe they are or not.
>
> -Stuart
>
> --
> Stuart Dallas
> 3ft9 Ltd
> http://3ft9.com/

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



Re: [PHP] CURL -d

2012-03-26 Thread Ashley Sheridan
On Mon, 2012-03-26 at 09:45 -0600, QI.VOLMAR QI wrote:

> I have this lines:
> curl -H "Content-Type: application/json" -d "hello world" \
> 
> "http://api.pusherapp.com/apps/17331/channels/test_channel/events?"\
> 
> The option -d is for data. But How I can set it on the PHP  CURL extension?
> I have found that if I set something like array('Hello Word', 'name'
> => 'my_name'), for the POST data may occurs. Can you give me a  little
> help?
> 


Have a look at curl_setopt() which can set those flags as you need
inside PHP:

http://uk3.php.net/manual/en/function.curl-setopt.php


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




Re: [PHP] CURL -d

2012-03-26 Thread QI.VOLMAR QI
I know guess that it is a POST field, but the detail is on simulate the -d
without a label. I've already looked at setopt man page, but nothing seems
like what I need.

2012/3/26 Ashley Sheridan 

> **
> On Mon, 2012-03-26 at 09:45 -0600, QI.VOLMAR QI wrote:
>
> I have this lines:
> curl -H "Content-Type: application/json" -d "hello world" \
> 
> "http://api.pusherapp.com/apps/17331/channels/test_channel/events?"\ 
> 
>
> The option -d is for data. But How I can set it on the PHP  CURL extension?
> I have found that if I set something like array('Hello Word', 'name'
> => 'my_name'), for the POST data may occurs. Can you give me a  little
> help?
>
>
>
> Have a look at curl_setopt() which can set those flags as you need inside
> PHP:
>
> http://uk3.php.net/manual/en/function.curl-setopt.php
>
>
>   --
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>


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 Jay Blanchard
[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.


--
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 Jay Blanchard
[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?


--
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 Jay Blanchard
[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()? 


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



RES: [PHP] CURL -d

2012-03-26 Thread Alejandro Michelin Salomon
Hi try this :


 $ch = curl_init();

curl_setopt ( $ch, CURLOPT_URL, "URL HERE" );
curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt ( $ch, CURLOPT_HEADER, 1 );
curl_setopt ( $ch, CURLOPT_TIMEOUT, 10);
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, false );

This to use SSL Certicade
curl_setopt ( $ch, CURLOPT_SSLCERT, Public Key );
curl_setopt ( $ch, CURLOPT_SSLCERTPASSWD, '');
curl_setopt ( $ch, CURLOPT_SSLCERTTYPE, 'PEM' ); --> Type o certificade
curl_setopt ( $ch, CURLOPT_SSLKEY, Private Key );
curl_setopt ( $ch, CURLOPT_SSLKEYPASSWD, Password of private key);


curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_POST, true );
curl_setopt ( $ch, CURLOPT_PORT , 443 ); --> port
curl_setopt($ch, CURLOPT_POSTFIELDS, DATA HERE );


curl_setopt($ch, CURLOPT_HTTPHEADER,
array(
'User-Agent: Some name',
'Accept-Encoding: gzip, deflate',
'POST "some post data" HTTP/1.1', 
'Host: some host',
'Content-type: application/soap+xml; charset="utf-8"', The content type
'Content-Length: ', length of data

// This for soap action 
'SOAPAction: action here  ')
);

$xResult = curl_exec($ch);

Alejandro M.S.

-Mensagem original-
De: QI.VOLMAR QI [mailto:qi.vol...@gmail.com] 
Enviada em: segunda-feira, 26 de março de 2012 12:46
Para: PHP General
Assunto: [PHP] CURL -d

I have this lines:
curl -H "Content-Type: application/json" -d "hello world" \
 
"http://api.pusherapp.com/apps/17331/channels/test_channel/events?"\

The option -d is for data. But How I can set it on the PHP  CURL extension?
I have found that if I set something like array('Hello Word', 'name'
=> 'my_name'), for the POST data may occurs. Can you give me a  little help?

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



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



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:


 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):


 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
(