php-general Digest 15 Feb 2012 01:44:15 -0000 Issue 7689

Topics (messages 316601 through 316611):

Re: handle file_get_contents timeout including dns lookup time
        316601 by: Matijn Woudt
        316609 by: Marco Behnke

Can php be configured to browse through a proxy?
        316602 by: Joan
        316603 by: Matijn Woudt

Form Post to different domain
        316604 by: Rick Dwyer
        316605 by: Daniel Brown
        316606 by: Rick Dwyer
        316607 by: Daniel Brown
        316608 by: Rick Dwyer

MySQL and PHP weirdness
        316610 by: Richard S. Crawford
        316611 by: David Robley

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
On Tue, Feb 14, 2012 at 1:28 PM, nik600 <[email protected]> wrote:
> Dear all
>
> i'm trying to handle a max timeout into a file_get_contents request,
> this is my code:
>
> ******* client.php ******* placed on http://test.foo.com/client.php
> <?php
> ini_set('default_socket_timeout',10);
> $ctx = stream_context_create(array('http' => array('timeout' => 10)));
> $data = file_get_contents("http://www.foo.com/server.php",0,$ctx);
> if(!data){
> die("error during page request");
> }else{
> echo "OK";
> echo $data;
> }
> ?>
>
> ******* server.php ******* placed on www.foo.com at
> http://www.foo.com/server.php
> <?php
> sleep(15);
> echo "OK";
> ?>
>
> i've noticed that in a standard scenario if i call
> http://test.foo.com/client.php all works properly and the timeout is
> handled correctly.
>
> But, if i'm experiencing dns lookup problems, the timeout setting is
> ignored by file_get_contents, or more probably the socket isn't yet
> estabilished so the counter for timeout doesn't start.
>
> I've been able to reproduce this problem on a linux server dropping
> incoming packets of DNS with this command: (be careful, it will
> disable you ability to resolve all dns address!):
>
>    * iptables -A INPUT -p udp --sport 53 -j DROP
>    * iptables -A INPUT -p tcp --sport 53 -j DROP
>
> So, the question is:
>
> is possible to have a timeout check that includes also dns resolution time?
>
> Thanks to all in advance

I don't think this is possible with file_get_contents, but it should
work if you use cURL and set the CURLOPT_CONNECTTIMEOUT option.

- Matijn

--- End Message ---
--- Begin Message ---
Am 14.02.12 14:55, schrieb Matijn Woudt:
> On Tue, Feb 14, 2012 at 1:28 PM, nik600 <[email protected]> wrote:
>>
>> ******* server.php ******* placed on www.foo.com at
>> http://www.foo.com/server.php
>> <?php
>> sleep(15);
>> echo "OK";
>> ?>
>>
> I don't think this is possible with file_get_contents, but it should
> work if you use cURL and set the CURLOPT_CONNECTTIMEOUT option.
>
> - Matijn
That won't help. When you reach the sleep with your request, the
connection is already established.
What you want is curl with

CURLOPT_TIMEOUT     max execution time


-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: [email protected]

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---
--- Begin Message ---
There is some information about configuring php to use a proxy when
connecting to external urls.

According to some sources the proper setup option is by using
the stream-context-set-default function (
http://www.php.net/manual/en/function.stream-context-set-default.php)
Still I have not been able to find any reference about if it can be set on
php.ini (so all the instances of php use it)

Also there is this bug that has been assigned since 2010 and still have not
changed (29280)
https://bugs.php.net/bug.php?id=29280

Any information about this will be well received.

Thanks,

Joan

--- End Message ---
--- Begin Message ---
On Tue, Feb 14, 2012 at 5:41 PM, Joan <[email protected]> wrote:
> There is some information about configuring php to use a proxy when
> connecting to external urls.
>
> According to some sources the proper setup option is by using
> the stream-context-set-default function (
> http://www.php.net/manual/en/function.stream-context-set-default.php)
> Still I have not been able to find any reference about if it can be set on
> php.ini (so all the instances of php use it)
>
> Also there is this bug that has been assigned since 2010 and still have not
> changed (29280)
> https://bugs.php.net/bug.php?id=29280
>
> Any information about this will be well received.
>
> Thanks,
>
> Joan

Hi,

AFAIK there's no such setting in php.ini. If you want to have it set
allways, you could use the php.ini setting auto_prepend_file to run a
simple php script (containing stream_context_set_default) before each
php file is parsed.

- Matijn

--- End Message ---
--- Begin Message ---
Hello all.

If I have a form on domain A that uses POST to submit data and I want to submit the form to domain B on an entirely different server, how do I pull the form values (... echo $_POST["myval"] returns nothing....) from the form at domain B?


 --Rick



--- End Message ---
--- Begin Message ---
On Tue, Feb 14, 2012 at 13:14, Rick Dwyer <[email protected]> wrote:
> Hello all.
>
> If I have a form on domain A that uses POST to submit data and I want to
> submit the form to domain B on an entirely different server, how do I pull
> the form values (... echo $_POST["myval"] returns nothing....) from the form
> at domain B?

    First (basic, obvious) question: do you have full access to both
domains, or is Domain B a third-party site?

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

--- End Message ---
--- Begin Message ---
On Feb 14, 2012, at 1:16 PM, Daniel Brown wrote:

On Tue, Feb 14, 2012 at 13:14, Rick Dwyer <[email protected]> wrote:
Hello all.

If I have a form on domain A that uses POST to submit data and I want to submit the form to domain B on an entirely different server, how do I pull the form values (... echo $_POST["myval"] returns nothing....) from the form
at domain B?

   First (basic, obvious) question: do you have full access to both
domains, or is Domain B a third-party site?


I only have access to domain B... the one receiving the Form POST.

--Rick


--- End Message ---
--- Begin Message ---
On Tue, Feb 14, 2012 at 13:36, Rick Dwyer <[email protected]> wrote:
>
> I only have access to domain B... the one receiving the Form POST.

    Then all you should need to do is:

        a.) Verify that Domain A is indeed pointing to Domain B, to
the script you expect, as a POST request.
        b.) In the POST-receiving script on Domain B, try this simple snippet:

<?php
echo '<pre>'.PHP_EOL;
var_dump($_POST);
die('</pre>');
?>

    That should give you all data from the post request.

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

--- End Message ---
--- Begin Message ---
Thanks Dan.

As it turned out the reason for not showing the passed values is that I didn't have "www" in the destination address and the values must have been getting lost when Apache redirected requests without www to the fully formed URL.


 --Rick


On Feb 14, 2012, at 1:39 PM, Daniel Brown wrote:

On Tue, Feb 14, 2012 at 13:36, Rick Dwyer <[email protected]> wrote:

I only have access to domain B... the one receiving the Form POST.

   Then all you should need to do is:

       a.) Verify that Domain A is indeed pointing to Domain B, to
the script you expect, as a POST request.
b.) In the POST-receiving script on Domain B, try this simple snippet:

<?php
echo '<pre>'.PHP_EOL;
var_dump($_POST);
die('</pre>');
?>

   That should give you all data from the post request.

--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

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



--- End Message ---
--- Begin Message ---
Bear with me here. I have a problem with PHP and MySQL that's been stumping
me for a couple of days now. I'm not even sure how to describe it, so I'll
just do my best.

There's a row in our bugs database that looks like every other row in the
table, but when it's pulled from the database and displayed in PHP, the
"description" field -- which is defined as a "mediumtext" field -- is
displayed as a date field with a value of 12/31/1969. Moreoever, when I use
PHPMyAdmin to look at the row directly, the "description" field has the
data that I expect it to.

Just for fun, here's the text in question:
============================
Quarterly Course Set Up - Spring 2012 (114)
Section  Course title                                    Course Start Date
114MHI214 The Internet and the Future of Patient Care     04/02/2012
114MHI212 Health Information Systems Analysis and Design  04/02/2012
Program administrator 2 users; Laurel Aroner - Susan Catron - Jennifer
Kremer
Instructors;
MHI214; Peter Yellowlees
MHI212; Robert Balch
Per instructions from Rita Smith-Simms - I'm creating this task for myself
and based on instructions given which are that all listed courses are now
to be backed-up and restored sooner (original course set up time-frame was
a month before course starts).
Adding instructions - Follow the 52-step quarterly course set up process
and information from the course matrix; if matrix incomplete, input
information during this set up
As you track your time each day, please include in the notes which courses
(use project code) you worked on and indicate either working on or
completed.
Create and notify by 2/15/2012
============================

I've made sure there are no odd characters that would mess up how PHP is
displaying the text. I've tried changing the field type from "mediumtext"
to "text" but this didn't work.

If anyone has any ideas as to why this might be happening -- or if I just
wasn't clear -- please let me know.


-- 
Sláinte,
Richard S. Crawford ([email protected]) http://www.underpope.com
Twitter: http://twitter.com/underpope
Facebook: http://www.facebook.com/underpope
Google+: http://gplus.to/underpope

--- End Message ---
--- Begin Message ---
Richard S. Crawford wrote:

> Bear with me here. I have a problem with PHP and MySQL that's been
> stumping me for a couple of days now. I'm not even sure how to describe
> it, so I'll just do my best.
> 
> There's a row in our bugs database that looks like every other row in the
> table, but when it's pulled from the database and displayed in PHP, the
> "description" field -- which is defined as a "mediumtext" field -- is
> displayed as a date field with a value of 12/31/1969. Moreoever, when I
> use PHPMyAdmin to look at the row directly, the "description" field has
> the data that I expect it to.
> 
> Just for fun, here's the text in question:
> ============================
> Quarterly Course Set Up - Spring 2012 (114)
> Section  Course title                                    Course Start Date
> 114MHI214 The Internet and the Future of Patient Care     04/02/2012
> 114MHI212 Health Information Systems Analysis and Design  04/02/2012
> Program administrator 2 users; Laurel Aroner - Susan Catron - Jennifer
> Kremer
> Instructors;
> MHI214; Peter Yellowlees
> MHI212; Robert Balch
> Per instructions from Rita Smith-Simms - I'm creating this task for myself
> and based on instructions given which are that all listed courses are now
> to be backed-up and restored sooner (original course set up time-frame was
> a month before course starts).
> Adding instructions - Follow the 52-step quarterly course set up process
> and information from the course matrix; if matrix incomplete, input
> information during this set up
> As you track your time each day, please include in the notes which courses
> (use project code) you worked on and indicate either working on or
> completed.
> Create and notify by 2/15/2012
> ============================
> 
> I've made sure there are no odd characters that would mess up how PHP is
> displaying the text. I've tried changing the field type from "mediumtext"
> to "text" but this didn't work.
> 
> If anyone has any ideas as to why this might be happening -- or if I just
> wasn't clear -- please let me know.
> 
> 

If phpmyadmin gives expected results and _your_ code doesn't, I'd be
suspicious of your code :-)

It might be helpful for you to post relevant part(s) ofthe actual code you
are using.



Cheers
-- 
David Robley

Man who run behind car get exhausted.
Today is Sweetmorn, the 46th day of Chaos in the YOLD 3178. 


--- End Message ---

Reply via email to