php-general Digest 3 Dec 2008 06:24:37 -0000 Issue 5823
Topics (messages 283998 through 284034):
Re: How to type arguments
283998 by: Richard Heyes
284007 by: Nathan Rixham
284030 by: Nathan Nobbe
284034 by: Gautier Di Folco
Slow file download
283999 by: Brian Dunning
284000 by: Ashley Sheridan
284001 by: Brian Dunning
284002 by: Ashley Sheridan
284005 by: Nathan Rixham
284008 by: Brian Dunning
284009 by: ceo.l-i-e.com
284010 by: Nathan Rixham
284011 by: Nathan Rixham
284012 by: Ashley Sheridan
284013 by: Ashley Sheridan
284014 by: Nathan Rixham
get_meta_data for string.
284003 by: ×× ××× ×× ××
why this code needs mysql.sock instead of mysqld.sock
284004 by: ann kok
284006 by: Stut
Re: Multiple MySQL INSERT
284015 by: Chris
284033 by: ddg2sailor
stream_socket_accept() on an SSL socket
284016 by: Darren
284017 by: Ashley Sheridan
284018 by: Tim | iHostNZ
284019 by: German Geek
284020 by: Nathan Rixham
284021 by: Nathan Rixham
284022 by: Nathan Rixham
284026 by: ceo.l-i-e.com
284032 by: Darren
Accessing the 'media' attribute in php
284023 by: Clancy
284024 by: German Geek
284027 by: ceo.l-i-e.com
284028 by: Clancy
284029 by: German Geek
Objects and Arrays Conversion
284025 by: VamVan
284031 by: Micah Gersten
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 ---
> I'm a french student, sorry for my mail :
>
> I want to know how can I type my functions' arguments ?
>
> It is heavy to do :
> function post($id)
> {
> $id=(int)$id;
> //...
PHP is loosely typed so strictly (...) speaking, that would be fine.
However, you're best off making sure that what you've been given is
what you think it is. Ergo, what you've written, is what I would do.
> or tu put (int) before each use...
Not necessary to put it there for each use, just the first.
--
Richard Heyes
HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated November 29th)
--- End Message ---
--- Begin Message ---
Richard Heyes wrote:
I'm a french student, sorry for my mail :
I want to know how can I type my functions' arguments ?
It is heavy to do :
function post($id)
{
$id=(int)$id;
//...
PHP is loosely typed so strictly (...) speaking, that would be fine.
However, you're best off making sure that what you've been given is
what you think it is. Ergo, what you've written, is what I would do.
or tu put (int) before each use...
Not necessary to put it there for each use, just the first.
also worth noting that you can type-hint as long as the type you're
hinting is an object and not a primitive:
function post(SomeObject $obj)
{
// php will effectively throw a catchable fatal error if
// $obj is not an instance of SomeObject
}
sadly you can't:
function post(int $number)
{
// doesn't work for primitives
// but then php has limited primitive types :(
}
so safest bet is as you mentioned but with at least some scalar checking
first
function post( $id )
{
if( is_scalar($id) ) {
return (int)$id;
}
// if you get here you're id is an object, resource
// or array and can't be cast to scalar type.
}
--- End Message ---
--- Begin Message ---
On Tue, Dec 2, 2008 at 1:49 PM, Nathan Rixham <[EMAIL PROTECTED]> wrote:
> Richard Heyes wrote:
>
>> I'm a french student, sorry for my mail :
>>>
>>> I want to know how can I type my functions' arguments ?
>>>
>>> It is heavy to do :
>>> function post($id)
>>> {
>>> $id=(int)$id;
>>> //...
>>>
>>
>> PHP is loosely typed so strictly (...) speaking, that would be fine.
>> However, you're best off making sure that what you've been given is
>> what you think it is. Ergo, what you've written, is what I would do.
>>
>> or tu put (int) before each use...
>>>
>>
>> Not necessary to put it there for each use, just the first.
>>
>>
> also worth noting that you can type-hint as long as the type you're hinting
> is an object and not a primitive:
>
> function post(SomeObject $obj)
> {
> // php will effectively throw a catchable fatal error if
> // $obj is not an instance of SomeObject
> }
>
> sadly you can't:
>
> function post(int $number)
> {
> // doesn't work for primitives
> // but then php has limited primitive types :(
> }
however, type-hinting does support arrays
function alterArr(array $a) { #.. }
-nathan
--- End Message ---
--- Begin Message ---
> Date: Tue, 2 Dec 2008 19:39:53 -0700> From: [EMAIL PROTECTED]> To: [EMAIL
> PROTECTED]> CC: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]>
> Subject: Re: [PHP] How to type arguments> > On Tue, Dec 2, 2008 at 1:49 PM,
> Nathan Rixham <[EMAIL PROTECTED]> wrote:> > > Richard Heyes wrote:> >> >> I'm
> a french student, sorry for my mail :> >>>> >>> I want to know how can I type
> my functions' arguments ?> >>>> >>> It is heavy to do :> >>> function
> post($id)> >>> {> >>> $id=(int)$id;> >>> //...> >>>> >>> >> PHP is loosely
> typed so strictly (...) speaking, that would be fine.> >> However, you're
> best off making sure that what you've been given is> >> what you think it is.
> Ergo, what you've written, is what I would do.> >>> >> or tu put (int) before
> each use...> >>>> >>> >> Not necessary to put it there for each use, just the
> first.> >>> >>> > also worth noting that you can type-hint as long as the
> type you're hinting> > is an object and not a primitive:> >> > function
> post(SomeObject $obj)> > {> > // php will effectively throw a catchable fatal
> error if> > // $obj is not an instance of SomeObject> > }> >> > sadly you
> can't:> >> > function post(int $number)> > {> > // doesn't work for
> primitives> > // but then php has limited primitive types :(> > }> > >
> however, type-hinting does support arrays> > function alterArr(array $a) {
> #.. }> > -nathan
Ok, thank you,
> > type-hint as long as the type you're hinting> > is an object and not a
> > primitive:
yes, but it is heavyer than doint $v=(int)$v;
It is all right
thank you
_________________________________________________________________
Email envoyé avec Windows Live Hotmail. Dites adieux aux spam et virus, passez
à Hotmail ! C'est gratuit !
http://www.windowslive.fr/hotmail/default.asp
--- End Message ---
--- Begin Message ---
I'm using a PHP cron job to constantly download files from a remote
server. Client and server both have abundant unused bandwidth, and the
sysads have already eliminated switches, interface cards, etc. as the
source of the slowdown. I'm looking at the script to see why file
downloads are taking so long and going so much slower than if I were
to simply manually download them with a browser on the same machine.
The script says:
$ctx = stream_context_create(array('http' => array('timeout' =>
1200))); // 20 minutes per file
$contents = file_get_contents($full_url, 0, $ctx);
$fp = fopen('D:\\DocShare\\'.$filename, "w");
$bytes_written = fwrite($fp, $contents);
fclose($fp);
Yes, it's on Windows. Any idea whether my PHP code might be
introducing a slowdown? The files range from 500K to 50MB. I often
launch multiple instances of the script but it doesn't seem to help
much.
--- End Message ---
--- Begin Message ---
On Tue, 2008-12-02 at 11:55 -0800, Brian Dunning wrote:
> I'm using a PHP cron job to constantly download files from a remote
> server. Client and server both have abundant unused bandwidth, and the
> sysads have already eliminated switches, interface cards, etc. as the
> source of the slowdown. I'm looking at the script to see why file
> downloads are taking so long and going so much slower than if I were
> to simply manually download them with a browser on the same machine.
> The script says:
>
> $ctx = stream_context_create(array('http' => array('timeout' =>
> 1200))); // 20 minutes per file
> $contents = file_get_contents($full_url, 0, $ctx);
> $fp = fopen('D:\\DocShare\\'.$filename, "w");
> $bytes_written = fwrite($fp, $contents);
> fclose($fp);
>
> Yes, it's on Windows. Any idea whether my PHP code might be
> introducing a slowdown? The files range from 500K to 50MB. I often
> launch multiple instances of the script but it doesn't seem to help
> much.
>
Instead of using PHP for this, why not have a look at WGET for Windows.
This is pretty much the standard way on *nix machines to grab files over
the Internet using the command line, and if the Windows version is half
as versatile as the Linux version, you'll find it has a lot of useful
features too, like support for dropped connections, etc.
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
I'm open to something like that - we're in the middle of the holiday
crunch and can't afford any downtime, so a significant change is out
of the question. This is part of much larger and more involved
scripting, so it would need to be a plug-n-play replacement and also
be able to return information to the script calling it - bytes,
success or failure. We're grabbing filenames and credentials out of
MySQL, marking them "in progress", attempting the download, and then
updating the MySQL record with the results.
On Dec 2, 2008, at 12:04 PM, Ashley Sheridan wrote:
Instead of using PHP for this, why not have a look at WGET for
Windows.
--- End Message ---
--- Begin Message ---
On Tue, 2008-12-02 at 12:14 -0800, Brian Dunning wrote:
> I'm open to something like that - we're in the middle of the holiday
> crunch and can't afford any downtime, so a significant change is out
> of the question. This is part of much larger and more involved
> scripting, so it would need to be a plug-n-play replacement and also
> be able to return information to the script calling it - bytes,
> success or failure. We're grabbing filenames and credentials out of
> MySQL, marking them "in progress", attempting the download, and then
> updating the MySQL record with the results.
>
> On Dec 2, 2008, at 12:04 PM, Ashley Sheridan wrote:
>
> > Instead of using PHP for this, why not have a look at WGET for
> > Windows.
>
>
>
Well you could always replace your CURL request with an exec() call to
WGET, which will be able to return the HTTP request codes (200 for
success, 404 for file not found, etc) and other information.
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Brian Dunning wrote:
I'm using a PHP cron job to constantly download files from a remote
server. Client and server both have abundant unused bandwidth, and the
sysads have already eliminated switches, interface cards, etc. as the
source of the slowdown. I'm looking at the script to see why file
downloads are taking so long and going so much slower than if I were to
simply manually download them with a browser on the same machine. The
script says:
$ctx = stream_context_create(array('http' => array('timeout' => 1200)));
// 20 minutes per file
$contents = file_get_contents($full_url, 0, $ctx);
$fp = fopen('D:\\DocShare\\'.$filename, "w");
$bytes_written = fwrite($fp, $contents);
fclose($fp);
Yes, it's on Windows. Any idea whether my PHP code might be introducing
a slowdown? The files range from 500K to 50MB. I often launch multiple
instances of the script but it doesn't seem to help much.
what's the server running? iis/apache, win/linux version of php (as
accurate as you can) oh and via http or https/ssl?
--- End Message ---
--- Begin Message ---
IIS, Windows PHP 5.2.6, and unfortunately the downloads are https.
On Dec 2, 2008, at 12:32 PM, Nathan Rixham wrote:
what's the server running? iis/apache, win/linux version of php (as
accurate as you can) oh and via http or https/ssl?
--- End Message ---
--- Begin Message ---
If the files are LARGE, file_get_contents is a Bad Idea (tm).
You're trying to suck the whole thing into RAM, which it can't, which swaps and
thrashes the bleep out of your RAM/swap space...
Use fopen and an fread loop instead, and you'll probably see much better
performance.
Also, consider going old school and getting rid of the stream_context stuff.
It's "new" and "untested" :-)
You can use ini_set and the parameter or even fall back to fsockopen with a
timeout.
Note that those time-outs are for any given packet to arrive (or the socket to
open) not the whole enchilada to download.
--- End Message ---
--- Begin Message ---
Brian Dunning wrote:
IIS, Windows PHP 5.2.6, and unfortunately the downloads are https.
On Dec 2, 2008, at 12:32 PM, Nathan Rixham wrote:
what's the server running? iis/apache, win/linux version of php (as
accurate as you can) oh and via http or https/ssl?
now I may be wrong but I'm rather sure that IIS has a bug where it
doesn't close http connections properly, thus you're connection isn't
closing until it times out (even though download finished ages ago).
There's some notes on the php site about it but can't seem to spot them
at the minute..
if memory serves me correctly lowering that timeout to something like 5
seconds will do the trick / or using a manual conenction like..
<?php
$protocol = 'ssl://';
$server = 'yoursite.com';
$port = 443; // ssl port?
$context = // your context here
$rawHttpResponse = '';
$rawHttpRequest = "GET /file.ext HTTP/1.1\r\nHost: " . $server . "\r\n";
$rawHttpRequest .= "Connection: Close\r\n\r\n';
if( $fp = stream_socket_client($protocol.$server.':'.$port], $errno,
$errstr, 5, STREAM_CLIENT_CONNECT, $context) ) {
fwrite($fp, $rawHttpRequest);
stream_set_timeout($fp, 10);
while (!feof($fp)) {
$a = stream_get_meta_data($fp);
if($a['timed_out']) {
return false; //timed out
}
$rawHttpResponse .= fgets($fp, 2);
}
fclose($fp);
}
echo $rawHttpResponse . PHP_EOL;
?>
totally untested :p
best of luck!
--- End Message ---
--- Begin Message ---
Nathan Rixham wrote:
Brian Dunning wrote:
IIS, Windows PHP 5.2.6, and unfortunately the downloads are https.
On Dec 2, 2008, at 12:32 PM, Nathan Rixham wrote:
what's the server running? iis/apache, win/linux version of php (as
accurate as you can) oh and via http or https/ssl?
now I may be wrong but I'm rather sure that IIS has a bug where it
doesn't close http connections properly, thus you're connection isn't
closing until it times out (even though download finished ages ago).
doesn't close HTTPS/SSL connections properly - key typo there!
--- End Message ---
--- Begin Message ---
On Tue, 2008-12-02 at 21:10 +0000, Nathan Rixham wrote:
> Brian Dunning wrote:
> > IIS, Windows PHP 5.2.6, and unfortunately the downloads are https.
> >
> > On Dec 2, 2008, at 12:32 PM, Nathan Rixham wrote:
> >
> >> what's the server running? iis/apache, win/linux version of php (as
> >> accurate as you can) oh and via http or https/ssl?
>
> now I may be wrong but I'm rather sure that IIS has a bug where it
> doesn't close http connections properly, thus you're connection isn't
> closing until it times out (even though download finished ages ago).
>
> There's some notes on the php site about it but can't seem to spot them
> at the minute..
>
> if memory serves me correctly lowering that timeout to something like 5
> seconds will do the trick / or using a manual conenction like..
>
> <?php
> $protocol = 'ssl://';
> $server = 'yoursite.com';
> $port = 443; // ssl port?
> $context = // your context here
> $rawHttpResponse = '';
>
> $rawHttpRequest = "GET /file.ext HTTP/1.1\r\nHost: " . $server . "\r\n";
> $rawHttpRequest .= "Connection: Close\r\n\r\n';
>
> if( $fp = stream_socket_client($protocol.$server.':'.$port], $errno,
> $errstr, 5, STREAM_CLIENT_CONNECT, $context) ) {
> fwrite($fp, $rawHttpRequest);
> stream_set_timeout($fp, 10);
> while (!feof($fp)) {
> $a = stream_get_meta_data($fp);
> if($a['timed_out']) {
> return false; //timed out
> }
> $rawHttpResponse .= fgets($fp, 2);
> }
> fclose($fp);
> }
> echo $rawHttpResponse . PHP_EOL;
> ?>
>
> totally untested :p
>
> best of luck!
>
I'm fair sure I hear of more bugs in IIS than I've ever heard of with
Apache...
*insert obvious troll disclaimer here*
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On Tue, 2008-12-02 at 21:13 +0000, Nathan Rixham wrote:
> Nathan Rixham wrote:
> > Brian Dunning wrote:
> >> IIS, Windows PHP 5.2.6, and unfortunately the downloads are https.
> >>
> >> On Dec 2, 2008, at 12:32 PM, Nathan Rixham wrote:
> >>
> >>> what's the server running? iis/apache, win/linux version of php (as
> >>> accurate as you can) oh and via http or https/ssl?
> >
> > now I may be wrong but I'm rather sure that IIS has a bug where it
> > doesn't close http connections properly, thus you're connection isn't
> > closing until it times out (even though download finished ages ago).
>
> doesn't close HTTPS/SSL connections properly - key typo there!
>
I did hear something about that too, and also, not too sure, but think
it might have been fixed in later versions of IIS, but, don't quote me
on that!
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Ashley Sheridan wrote:
On Tue, 2008-12-02 at 21:13 +0000, Nathan Rixham wrote:
Nathan Rixham wrote:
Brian Dunning wrote:
IIS, Windows PHP 5.2.6, and unfortunately the downloads are https.
On Dec 2, 2008, at 12:32 PM, Nathan Rixham wrote:
what's the server running? iis/apache, win/linux version of php (as
accurate as you can) oh and via http or https/ssl?
now I may be wrong but I'm rather sure that IIS has a bug where it
doesn't close http connections properly, thus you're connection isn't
closing until it times out (even though download finished ages ago).
doesn't close HTTPS/SSL connections properly - key typo there!
I did hear something about that too, and also, not too sure, but think
it might have been fixed in later versions of IIS, but, don't quote me
on that!
Ash
www.ashleysheridan.co.uk
they might have, either way I'm pretty sure this isn't a download speed
but rather a connection not getting closed / eof not being detected type
error so the timeout of 20mins+download time is being hit; hopefully a
drop in timeout to 5/10 seconds will sort it.
will be interested to hear if this is the cause or not!
--- End Message ---
--- Begin Message ---
I was wondering, is there any get_meta_data function for string? as far as I
saw, the user-made functions had lack of handling with pattern order, or
unquoted meta tags (etc: "<META content=text/html; charset=UTF-8
http-equiv=Content-Type>" or even "<META content="text/html; charset=UTF-8"
http-equiv=Content-Type>".
How comes the function only get url as an argument?
--- End Message ---
--- Begin Message ---
Hi all
<?php
$link=mysql_connect('localhost','usrname','password');
if(!$link) echo "fail";
else echo "success";
mysql_close();
?>
Thank you
__________________________________________________________________
Connect with friends from any web browser - no download required. Try the new
Yahoo! Canada Messenger for the Web BETA at
http://ca.messenger..yahoo.com/webmessengerpromo.php
--- End Message ---
--- Begin Message ---
On 2 Dec 2008, at 20:15, ann kok wrote:
<?php
$link=mysql_connect('localhost','usrname','password');
if(!$link) echo "fail";
else echo "success";
mysql_close();
?>
The location of the socket is compiled into the mysql lib. I believe
it can be changed from php.ini - check the manual for details. If not
then your easiest option is to create a symlink, or alternatively
recompile the extension.
-Stut
--
http://stut.net/
--- End Message ---
--- Begin Message ---
ddg2sailor wrote:
chris smith-9 wrote:
ddg2sailor wrote:
$row = mysql_fetch_array($res);
$res = mysql_query("SELECT passhash, editsecret, status FROM users WHERE
id
= $id");
$row = mysql_fetch_array($res);
I hope this is a copy/paste error or are you running the same thing twice?
I diddnt see that right away. In fact Im combining 2 pieces of code. The
owner of this site dosent want to use a mail server and dosent want to do
a manual confirm. So I added part of the confirm.php to the takesignup.php
file....
mysql_query("UPDATE users SET status='confirmed', uploaded = $giveupload
");
This updates *every* user to have a confirmed status. Probably not what
you want.
Add a
WHERE id='X';
clause
Believe me I agree with you... but this is how he wants it. It took me a
while to realize that the new user cant call up the confirm.php without
the mail with the link and the user name and secret word.
It's still wrong regardless.
User "A" signs up
User "B" signs up
User "A" clicks the confirm link
User "B" does not, but is confirmed anyway.
//send pm to new user
{
$msg = sqlesc("Hello and welcome to Cyber Drive In you have been
given a 1gb head start to help your ratio. .we are a strict but fair site
and our warning are based on the torrent ratio not the global just
because
you have a good ratio dont mean you can hit and run if you do hit and run
your downloads maybe disabled even if your global ratio is fine..so enjoy
our free 1gb gift rules are seed what you take or for 72 hours..plz read
the
rules and facts now you have joined our friendly community");
$added = sqlesc(get_date_time());
$subject = sqlesc("Welcome to Cyber Drive In");
mysql_query("INSERT INTO messages (sender, receiver, subject,
msg,
added) VALUES (0, $id, $subject, $msg, $added)");
What is the sqlesc function?
This is the way the code is when I got it. I think that this is how it
reads from the array. I can see where a table might be more use here.
Eh? I asked about what the sqlesc function does - it is not a native php
function.
You need quotes around your values:
$sql = "insert into table(f1, f2, f3) values ('" .
mysql_real_escape_string($value_1) . "', '" .
mysql_real_escape_string($value_2) . "')";
Im guessing that the preceding line got a bit chopped in the sending....
at least it dosent look quite right as it is. If I cut and paste this back
together I should be able to follow your convention.
No, I was just too lazy to use your code and instead I gave an example.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
chris smith-9 wrote:
>
> ddg2sailor wrote:
>>
>
>
>>It's still wrong regardless.
>
> I dont run the system , However the code I didnt post checks to make sure
> the user name or email isnt already in use or in fact was in use but
> removed. Diddnt have to bother with that part , it works fine.
>
>>User "A" signs up
>>User "B" signs up
>
>>User "A" clicks the confirm link
>
>>User "B" does not, but is confirmed anyway.
>
>>> reads from the array. I can see where a table might be more use here.
>
>>Eh? I asked about what the sqlesc function does - it is not a native php
>>function.
>
> I wish I could tell you more... but this isnt my code. now it no doubt
> looks sloppy but It does work on anther system and sends the pm. My
> thinking is more along the lines of getting the value for $id comming out
> to = ' ' (null) instead of the Username...
>
> I havent been able yet to test the last edit of this code yet... It may
> even work. It runs on windows 2003 server sqlserver if this helps any.
>
>>> You need quotes around your values:
>>>
>>> $sql = "insert into table(f1, f2, f3) values ('" .
>>> mysql_real_escape_string($value_1) . "', '" .
>>> mysql_real_escape_string($value_2) . "')";
>>>
>>> Im guessing that the preceding line got a bit chopped in the sending....
>>> at least it dosent look quite right as it is. If I cut and paste this
>>> back
>>> together I should be able to follow your convention.
>
>>No, I was just too lazy to use your code and instead I gave an example.
>
> I diddnt expect you to do my work for me :) But thanks for the tip.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
--
View this message in context:
http://www.nabble.com/Multiple-MySQL-INSERT-tp20786333p20805879.html
Sent from the PHP - General mailing list archive at Nabble.com.
--- End Message ---
--- Begin Message ---
I'm trying to connect to an SSL server, but I keep on getting these errors:
---------
PHP Warning: stream_socket_accept(): SSL operation failed with code 1.
OpenSSL Error messages:
error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol in
C:\scripts\bouncer.php on line 273
PHP Warning: stream_socket_accept(): Failed to enable crypto in
C:\scripts\bouncer.php on line 273
PHP Warning: stream_socket_accept(): accept failed: The operation
completed successfully.
in C:\scripts\bouncer.php on line 273
---------
Line 273: while ($client = stream_socket_accept($srv_socket)) {
Over the past few days of searching I've found a lot of people asking a
similar thing but without any answers. I've tried the latest PHP
snapshot too.
Can anyone here give any insight to these errors??
Thanks for any help
Darren
--- End Message ---
--- Begin Message ---
On Tue, 2008-12-02 at 23:48 +0000, Darren wrote:
> I'm trying to connect to an SSL server, but I keep on getting these errors:
> ---------
> PHP Warning: stream_socket_accept(): SSL operation failed with code 1.
> OpenSSL Error messages:
> error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol in
> C:\scripts\bouncer.php on line 273
> PHP Warning: stream_socket_accept(): Failed to enable crypto in
> C:\scripts\bouncer.php on line 273
> PHP Warning: stream_socket_accept(): accept failed: The operation
> completed successfully.
> in C:\scripts\bouncer.php on line 273
> ---------
>
> Line 273: while ($client = stream_socket_accept($srv_socket)) {
>
> Over the past few days of searching I've found a lot of people asking a
> similar thing but without any answers. I've tried the latest PHP
> snapshot too.
>
> Can anyone here give any insight to these errors??
>
> Thanks for any help
> Darren
>
I believe this shares something in common with another thread [Slow File
Download]. Sockets on IIS using SSL has some problems. It's possible
that the one you're suffering here is where IIS closes the connection
prematurely. I have no idea how to solve this, but there are a number of
answers to something similar on the PHP manual pages as far as I know.
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
When you "talk" to an SSL server directly with sockets, I believe you need
to implement the SSL protocol yourself, which would probably be overkill.
There must be a PHP library which does or a native function. You should
probably look at this page:
http://nz.php.net/manual/en/wrappers.http.php
and use fopen instead.
On Wed, Dec 3, 2008 at 12:48 PM, Darren <[EMAIL PROTECTED]> wrote:
> I'm trying to connect to an SSL server, but I keep on getting these errors:
> ---------
> PHP Warning: stream_socket_accept(): SSL operation failed with code 1.
> OpenSSL Error messages:
> error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol in
> C:\scripts\bouncer.php on line 273
> PHP Warning: stream_socket_accept(): Failed to enable crypto in
> C:\scripts\bouncer.php on line 273
> PHP Warning: stream_socket_accept(): accept failed: The operation
> completed successfully.
> in C:\scripts\bouncer.php on line 273
> ---------
>
> Line 273: while ($client = stream_socket_accept($srv_socket)) {
>
> Over the past few days of searching I've found a lot of people asking a
> similar thing but without any answers. I've tried the latest PHP snapshot
> too.
>
> Can anyone here give any insight to these errors??
>
> Thanks for any help
> Darren
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Tim-Hinnerk Heuer
http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
--- End Message ---
--- Begin Message ---
When you "talk" to an SSL server directly with sockets, I believe you need
to implement the SSL protocol yourself, which would probably be overkill.
There must be a PHP library which does or a native function. You should
probably look at this page:
http://nz.php.net/manual/en/wrappers.http.php
and use fopen instead.
On Wed, Dec 3, 2008 at 12:57 PM, Ashley Sheridan
<[EMAIL PROTECTED]>wrote:
> On Tue, 2008-12-02 at 23:48 +0000, Darren wrote:
> > I'm trying to connect to an SSL server, but I keep on getting these
> errors:
> > ---------
> > PHP Warning: stream_socket_accept(): SSL operation failed with code 1.
> > OpenSSL Error messages:
> > error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol in
> > C:\scripts\bouncer.php on line 273
> > PHP Warning: stream_socket_accept(): Failed to enable crypto in
> > C:\scripts\bouncer.php on line 273
> > PHP Warning: stream_socket_accept(): accept failed: The operation
> > completed successfully.
> > in C:\scripts\bouncer.php on line 273
> > ---------
> >
> > Line 273: while ($client = stream_socket_accept($srv_socket)) {
> >
> > Over the past few days of searching I've found a lot of people asking a
> > similar thing but without any answers. I've tried the latest PHP
> > snapshot too.
> >
> > Can anyone here give any insight to these errors??
> >
> > Thanks for any help
> > Darren
> >
> I believe this shares something in common with another thread [Slow File
> Download]. Sockets on IIS using SSL has some problems. It's possible
> that the one you're suffering here is where IIS closes the connection
> prematurely. I have no idea how to solve this, but there are a number of
> answers to something similar on the PHP manual pages as far as I know.
>
>
> Ash
> www.ashleysheridan.co.uk
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Tim-Hinnerk Heuer
http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
--- End Message ---
--- Begin Message ---
Darren wrote:
I'm trying to connect to an SSL server, but I keep on getting these errors:
---------
PHP Warning: stream_socket_accept(): SSL operation failed with code 1.
OpenSSL Error messages:
error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol in
C:\scripts\bouncer.php on line 273
PHP Warning: stream_socket_accept(): Failed to enable crypto in
C:\scripts\bouncer.php on line 273
PHP Warning: stream_socket_accept(): accept failed: The operation
completed successfully.
in C:\scripts\bouncer.php on line 273
---------
Line 273: while ($client = stream_socket_accept($srv_socket)) {
Over the past few days of searching I've found a lot of people asking a
similar thing but without any answers. I've tried the latest PHP
snapshot too.
Can anyone here give any insight to these errors??
Thanks for any help
Darren
you are calling ssl://server.com:port and not https://server.com ya?
you've got openssl installed ya?
--- End Message ---
--- Begin Message ---
Darren wrote:
I'm trying to connect to an SSL server, but I keep on getting these errors:
---------
PHP Warning: stream_socket_accept(): SSL operation failed with code 1.
OpenSSL Error messages:
error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol in
C:\scripts\bouncer.php on line 273
PHP Warning: stream_socket_accept(): Failed to enable crypto in
C:\scripts\bouncer.php on line 273
PHP Warning: stream_socket_accept(): accept failed: The operation
completed successfully.
in C:\scripts\bouncer.php on line 273
---------
Line 273: while ($client = stream_socket_accept($srv_socket)) {
Over the past few days of searching I've found a lot of people asking a
similar thing but without any answers. I've tried the latest PHP
snapshot too.
Can anyone here give any insight to these errors??
Thanks for any help
Darren
after more looking in to it the only thing I can see it possibly being
is a broken ssl certificate on the webserver.
--- End Message ---
--- Begin Message ---
Nathan Rixham wrote:
Darren wrote:
I'm trying to connect to an SSL server, but I keep on getting these
errors:
---------
PHP Warning: stream_socket_accept(): SSL operation failed with code
1. OpenSSL Error messages:
error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol in
C:\scripts\bouncer.php on line 273
PHP Warning: stream_socket_accept(): Failed to enable crypto in
C:\scripts\bouncer.php on line 273
PHP Warning: stream_socket_accept(): accept failed: The operation
completed successfully.
in C:\scripts\bouncer.php on line 273
---------
Line 273: while ($client = stream_socket_accept($srv_socket)) {
Over the past few days of searching I've found a lot of people asking
a similar thing but without any answers. I've tried the latest PHP
snapshot too.
Can anyone here give any insight to these errors??
Thanks for any help
Darren
after more looking in to it the only thing I can see it possibly being
is a broken ssl certificate on the webserver.
last one, an interesting discussion back in 2005 on the openssl mailing
lists, everything pointed to not authenticating - (using HTTP request
when a SSL handshake is required)
I'm going to drop this one now; best of luck!
--- End Message ---
--- Begin Message ---
First thing I would check is <?php phpinfo();?> and make sure you have OpenSSL
compiled in.
--- End Message ---
--- Begin Message ---
Darren wrote:
I'm trying to connect to an SSL server, but I keep on getting these errors:
---------
PHP Warning: stream_socket_accept(): SSL operation failed with code 1.
OpenSSL Error messages:
error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol in
C:\scripts\bouncer.php on line 273
PHP Warning: stream_socket_accept(): Failed to enable crypto in
C:\scripts\bouncer.php on line 273
PHP Warning: stream_socket_accept(): accept failed: The operation
completed successfully.
in C:\scripts\bouncer.php on line 273
---------
Line 273: while ($client = stream_socket_accept($srv_socket)) {
Over the past few days of searching I've found a lot of people asking a
similar thing but without any answers. I've tried the latest PHP
snapshot too.
Can anyone here give any insight to these errors??
Thanks for any help
Darren
Ok thanks guys. Turns out the SSL server was messing up, so PHP wasn't
at fault here. (It's a bespoke server app, not apache).
Thanks for your help.
--- End Message ---
--- Begin Message ---
Is it possible to access the 'media' attribute from php, so (for
example) you can tailor a page for printing?
--- End Message ---
--- Begin Message ---
PHP is a server side language...
On Wed, Dec 3, 2008 at 2:16 PM, Clancy <[EMAIL PROTECTED]> wrote:
> Is it possible to access the 'media' attribute from php, so (for
> example) you can tailor a page for printing?
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Tim-Hinnerk Heuer
http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
--- End Message ---
--- Begin Message ---
I think you just want to have a CSS sheet for print media and be done with it.
You could, in theory, add some kind of listener with JS, that would detect the
'media' attribute and then Ajax back to the server to do something, but that's
an awful Rube Goldberg compared to just one more tag with a print stylesheet.
--- End Message ---
--- Begin Message ---
Oh?
Unfortunately I have had great difficulty trying to find out how
things really work, as all the books I have seen are recipe books,
which tell you how to achieve particular results, but not what is
going on behind the scenes. I had assumed that when you hit the
'print' button the browser sent a new request to the server, with a
different set of parameters, but I gather from your reply that the
browser issues the new (printer) page without reference to the server.
Is this what actually happens?
If so I fear I will have to work out how to achieve the results I want
with CSS styles. It would have been far simpler if I could have done
it in php.
Thank you for your help.
On Wed, 3 Dec 2008 14:34:20 +1300, [EMAIL PROTECTED] ("German Geek")
wrote:
>PHP is a server side language...
>
>On Wed, Dec 3, 2008 at 2:16 PM, Clancy <[EMAIL PROTECTED]> wrote:
>
>> Is it possible to access the 'media' attribute from php, so (for
>> example) you can tailor a page for printing?
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
--- End Message ---
--- Begin Message ---
You can do things on the client side with Javascript ;) Sorry, what was the
result you are after?
On Wed, Dec 3, 2008 at 3:22 PM, Clancy <[EMAIL PROTECTED]> wrote:
> Oh?
>
> Unfortunately I have had great difficulty trying to find out how
> things really work, as all the books I have seen are recipe books,
> which tell you how to achieve particular results, but not what is
> going on behind the scenes. I had assumed that when you hit the
> 'print' button the browser sent a new request to the server, with a
> different set of parameters, but I gather from your reply that the
> browser issues the new (printer) page without reference to the server.
> Is this what actually happens?
>
> If so I fear I will have to work out how to achieve the results I want
> with CSS styles. It would have been far simpler if I could have done
> it in php.
>
> Thank you for your help.
>
> On Wed, 3 Dec 2008 14:34:20 +1300, [EMAIL PROTECTED] ("German Geek")
> wrote:
>
> >PHP is a server side language...
> >
> >On Wed, Dec 3, 2008 at 2:16 PM, Clancy <[EMAIL PROTECTED]> wrote:
> >
> >> Is it possible to access the 'media' attribute from php, so (for
> >> example) you can tailor a page for printing?
> >>
> >>
> >> --
> >> 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
>
>
--
Tim-Hinnerk Heuer
http://www.ihostnz.com -- Web Design, Hosting and free Linux Support
--- End Message ---
--- Begin Message ---
Hello All,
I was stuck with this issue. So just felt the need to reach out to other
strugglers.
May be people might enjoy this:
Here is the code for object to array and array to object conversion:
function object_2_array($data)
{
if(is_array($data) || is_object($data))
{
$result = array();
foreach ($data as $key => $value)
{
$result[$key] = object_2_array($value);
}
return $result;
}
return $data;
}
function array_2_object($array) {
$object = new stdClass();
if (is_array($array) && count($array) > 0) {
foreach ($array as $name=>$value) {
$name = strtolower(trim($name));
if (!empty($name)) {
$object->$name = $value;
}
}
}
return $object;
}
have fun !!!!!
Thanks
--- End Message ---
--- Begin Message ---
VamVan wrote:
> Hello All,
>
> I was stuck with this issue. So just felt the need to reach out to other
> strugglers.
> May be people might enjoy this:
>
> Here is the code for object to array and array to object conversion:
>
> function object_2_array($data)
> {
> if(is_array($data) || is_object($data))
> {
> $result = array();
> foreach ($data as $key => $value)
> {
> $result[$key] = object_2_array($value);
> }
> return $result;
> }
> return $data;
> }
>
> function array_2_object($array) {
> $object = new stdClass();
> if (is_array($array) && count($array) > 0) {
> foreach ($array as $name=>$value) {
> $name = strtolower(trim($name));
> if (!empty($name)) {
> $object->$name = $value;
> }
> }
> }
> return $object;
> }
>
> have fun !!!!!
>
> Thanks
>
>
This page at the bottom describes your array_2_object function as a
simple typecast:
http://us2.php.net/manual/en/language.types.object.php
$object = (object) $array;
As for the object to array, the same thing applies:
http://us2.php.net/manual/en/language.types.array.php
$array = (array) $object;
Not sure if these are PHP 5 only or not.
Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com
--- End Message ---