[PHP] Re: Blocking gethostbyname and Net_DNS2 behaviour
My apologies, it looks like it was a false alarm and the blocking actually comes from PHP's session manager. Sorry, Alexander On 11 September 2012 14:22, a m wrote: > Hi, > > I was using gethostbyname up until recently but switched to Net_DNS2 > due to lack of support for a timeout. Now I discovered some "worrying" > behaviour and hope someone here get shed some light onto it. > > I am running PHP inside an Apache 2 installation as module and noticed > that once I call gethostbyname it appears to block all other > concurrent independent requests to PHP pages until the call returned. > I do seem to remember that there were some reentrant issues with the > native gethostbyname function but I wouldnt assume there is some kind > of global lock on it blocking the entire runtime. > > What is even more worrying is that Net_DNS2 appears to show the same > behaviour, even though from my understanding it is supposed to work > completely independent with its own streams/sockets. > > Of course this behaviour only shows with a domain with non-responding > name servers, hence I used vuav.com. You should be able to reproduce > it easily with > > > echo gethostbyname('vuav.com'); > > // OR .. > > require('Net/DNS2.php'); > > $dr=new Net_DNS2_Resolver(['nameservers'=>['8.8.8.8']]); > $ans=$dr->query('vuav.com'); > echo $ans->answer[0]->address; > > ?> > > Could it have to do something with a configuration setting or might I > be onto something? > > Thanks a lot! > > cheers, > Alexander -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Blocking gethostbyname and Net_DNS2 behaviour
Hi, I was using gethostbyname up until recently but switched to Net_DNS2 due to lack of support for a timeout. Now I discovered some "worrying" behaviour and hope someone here get shed some light onto it. I am running PHP inside an Apache 2 installation as module and noticed that once I call gethostbyname it appears to block all other concurrent independent requests to PHP pages until the call returned. I do seem to remember that there were some reentrant issues with the native gethostbyname function but I wouldnt assume there is some kind of global lock on it blocking the entire runtime. What is even more worrying is that Net_DNS2 appears to show the same behaviour, even though from my understanding it is supposed to work completely independent with its own streams/sockets. Of course this behaviour only shows with a domain with non-responding name servers, hence I used vuav.com. You should be able to reproduce it easily with ['8.8.8.8']]); $ans=$dr->query('vuav.com'); echo $ans->answer[0]->address; ?> Could it have to do something with a configuration setting or might I be onto something? Thanks a lot! cheers, Alexander -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] avoid calling php script
HTTP_REFERER will do the job, thanks! Hugo. --- Steve Edberg escribió: At 3:55 AM +0100 3/13/08, H u g o H i r a m wrote: Hello I have a swf that runs a PHP script that generates a XML, on the PHP is there any way to detect if the file is being called from the swf or from the browser? because I want to avoid the file being run directly from the browser or from any other file than the swf. regards, Hugo. You might want to check the HTTP_REFERER value; test the program from a browser and the swf, and see what happens. Alternatively you could use a GET parameter like http://example.com/yourscript.php?calledby=swf Be aware that anything sent back from the client can be spoofed - and HTTP_REFERER can be altered or disabled - so it probably wouldn't be hard for someone to make it appear to your script that it is being called by your SWF. If you're really concerned about restricting the communication between the Flash movie and your server, there might be some way to build a challenge-response mechanism into the flash; I don't know much about it. If, on the other hand, you just don't want to confuse someone who might accidentally run the XML-generating script from the browser, checking a GET parameter as above is probably the safest. If it's not set properly, redirect the user, eg: if (!isset($_GET['calledby']) || $_GET['calledby'] != 'swf') { header('Location: http://example.com/thecorrectpage.html'); exit(); } ... - steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] avoid calling php script
Hello I have a swf that runs a PHP script that generates a XML, on the PHP is there any way to detect if the file is being called from the swf or from the browser? because I want to avoid the file being run directly from the browser or from any other file than the swf. regards, Hugo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] multiple curl and web service
Hi, I am having this problem, I am retrieving some data from a MySQL DB, and using it to post a cURL, what I am calling is a web service, and I have 3 options to do it: SOAP, GET and POST, I am not very familiar with SOAP, so I am using POST, in response I get a XML on each call to the web service. If I call only one curl and web service each time, then everything works just perfect, but if I try to make multiple calls then I get weird results, I get some responses OK (an XML), but others are empty responses. The first three responses are always empty, I don't get any errors, instead only those empty responses (no XML). Ok, I'm posting the code right here: $sql_aero = "SELECT code FROM airports ORDER BY id ASC limit 0, 10"; $result_aero = mysql_query($sql_aero); $num_results_aero = mysql_num_rows($result_aero); if (!empty($num_results_aero)) { $i = 0; $mh = curl_multi_init(); while($row_aero = mysql_fetch_array($result_aero)) { $aero = $row_aero["code"]; $ws = "www.webservicex.com/airport.asmx/getAirportInformationByAirportCode"; $post = "airportCode=$aero"; print "$i = $aero, $post"; $conn[$i] = curl_init($ws); curl_setopt($conn[$i], CURLOPT_RETURNTRANSFER, 1); curl_setopt($conn[$i], CURLOPT_POSTFIELDS, $post); curl_multi_add_handle ($mh, $conn[$i]); $i++; } } do { $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); for ($j=0; $j<$i; $j++) { if (($err = curl_error($conn[$j])) == '') { $res[$j] = curl_multi_getcontent($conn[$j]); print "$j$newstr[$j]"; } else { print "Curl error on handle $j: $err\n"; } curl_multi_remove_handle($mh, $conn[$j]); curl_close($conn[$j]); } curl_multi_close($mh); As you won't have the DB, if want to try the code, use this array with the proper change to the code: $airports = ['LAX', 'ATL', 'JFK', 'SAN', 'CDG', 'MAD', 'BCN', 'GDL', 'TIJ', 'SYD']; I am working on Localhost: Windows, Apache 2.2.3, PHP 5.1.6 and MySQL 5.0.24 here's the original code: http://www.php.net/manual/en/function.curl-multi-exec.php Regards! hugo Hiram. --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Trans_sid not working
Hey everyone, I'm using PHP 4.1.2 and I want to pass the SID through the URL when the user switched off cookies. I enabled session.use_trans_sid in my php.ini, but that doesn't seem to work. With cookies it works perfect. Thanks for any help, Tom Suter