Re: [PHP] Invalid Arguements

2008-11-20 Thread Lars Torben Wilson
2008/11/19 Robert Cummings <[EMAIL PROTECTED]>:
> On Wed, 2008-11-19 at 19:49 +, Ashley Sheridan wrote:
>> On Wed, 2008-11-19 at 08:31 -0600, Terion Miller wrote:
>> > I am still getting the Invalid arguement error on this implode:
>> >
>> > if (isset($_POST['BannerSize'])){$BannerSize =
>> > implode(',',$_POST['BannerSize']);} else {$BannerSize = "";}
>> >
>> > I have moved the ',', from the beginning to the end of the statement and
>> > nothing works is there any other way to do this, basically there is a form
>> > and the people entering work orders can select different sized banners they
>> > need, which goes into the db as text so...argh...
>>
>> As mentioned quite a few times before, you cannot change the order of
>> the arguments, it will not work! There is no indicator in the PHP Manual
>> page for this function either that says you can switch the orders, so
>> I'm not sure why you think you can.
>
> In PHP 5.2.6 and in PHP 4.4.9 I get the same output for the following:
>
> 
>$foo = array( 1, 2 );
>
>   echo implode( $foo, ',' )."\n";
>   echo implode( ',', $foo )."\n";
>
> ?>
>
> I believe, that a long time ago it was added as a feature so that PHP
> would detect inverted parameter order on this particular function and
> output appropriately.
>
> It is probably undocumented so as to encourage a single documented
> order.
>
> Cheers,
> Rob.
> --
> http://www.interjinn.com
> Application and Templating Framework for PHP

It was added a long time ago, yes, and it is indeed documented (as
already noted in this thread). I'm not sure which copy of the manual
Ash is reading from, but the one I'm looking at documents this
behaviour. And it's right there in the PHP source code (and easily
testable, as you have shown).


Torben

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



Re: [PHP] fread() behaviour

2008-11-20 Thread Stut

On 20 Nov 2008, at 01:29, Rene Fournier wrote:
I'm trying to understand something about fread(). I'm using fread()  
on an incoming socket stream that will send, for example, 26630  
characters:


while ( ($buf=fread($read[$i], 8192)) != '' ) {
$sock_data .= $buf;
usleep(1000);
echo ".";
}
echo ",";


As soon as the socket client sends the data, immediately the server  
will echo:




Then wait nearly a minute, and echo:

,

So my question is, why does fread wait if there is nothing more to  
read? Shouldn't it return immediately? (That's what I want.) And as  
for the delay, it's there so that if the incoming data is a little  
slow, it has time to catch up with fread. Thanks.


As Craige already mentioned, fread will read bytes until it meets an  
EOF so unless the other side sends one or closes the socket fread will  
wait for the number of characters you've asked for (8192) or a timeout  
(which is the delay you're seeing). In other words it's not detecting  
the end of the data, it's just timing out waiting for more.


You ideally want to have the other side tell you how many bytes it's  
going to send. If you can't do that then hopefully the data you're  
receiving has some sort of structure so you can check the incoming  
data for some terminating string. If not then you've got a problem  
that can't be reliably solved. You could mess around with the timeout  
and/or make use of functions like socket_select to check for waiting  
data, but what you'll end up with will be problematic on slow  
connections and generally unreliable.


-Stut

--
http://stut.net/

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



Re: [PHP] in_array breaks down for 0 as value

2008-11-20 Thread Stut

On 20 Nov 2008, at 06:55, Yashesh Bhatia wrote:

 I wanted to use in_array to verify the results of a form submission
for a checkbox and found an interesting
behaviour.

$ php -v
PHP 5.2.5 (cli) (built: Jan 12 2008 14:54:37)
$

$ cat in_array2.php
 'page',
  'story'  => 'story',
  'nodereview' => 'abc',
  );

if (in_array('page', $node_review_types)) {
 print "page found in node_review_types\n";
}
if (in_array('nodereview', $node_review_types)) {
 print "nodereview found in node_review_types\n";
}

?>
$ php in_array2.php
page found in node_review_types
$

This  works fine. but if i change the value of the key 'nodereview' to
0 it breaks down.

$ diff in_array2.php in_array3.php
6c6
<'nodereview' => 'abc',
---

  'nodereview' => 0,

$

$ php in_array3.php
page found in node_review_types
nodereview found in node_review_types
$

Any reason why in_array is returning TRUE when one has a 0 value on  
the array ?


That's weird, 5.2.6 does the same thing. There's actually a comment  
about this on the in_array manual page from james dot ellis at gmail  
dot com...




Be aware of oddities when dealing with 0 (zero) values in an array...

This script:


It seems in non strict mode, the 0 value in the array is evaluating to  
boolean FALSE and in_array returns TRUE. Use strict mode to work  
around this peculiarity.
This only seems to occur when there is an integer 0 in the array. A  
string '0' will return FALSE for the first test above (at least in  
5.2.6).




So use strict mode and this problem will go away. Oh, and please read  
the manual before asking a question in future.


-Stut

--
http://stut.net/

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



Re: [PHP] Re: PHP Warning: HTTP request failed -- BSD resource limit reached?

2008-11-20 Thread Nathan Rixham

Rene Fournier wrote:

On 19-Nov-08, at 12:52 PM, Nathan Rixham wrote:


Rene Fournier wrote:

Hi,
I have four identical command-line PHP scripts running, and each will 
frequently fetch some data from another server via 
file_get_contents(). By frequently, I mean on average, every second.
Periodically, one of the processes (command-line PHP scripts), will 
fail on file_get_contents(), with the error message:


first thing that springs to mind is some form of hardware limitation, 
quite sure it's not php - could be a firewall with flood protection 
(or even your own isp's anti malware set-up)
to combat it try binding the outgoing request to a random ip each time 
(if you have multiple ip's on the box) [context: socket -> bindto]


That could explain it, except that all the traffic is on the same LAN. 
There's no firewall between Server A and Servers B and C.


next up (very unlikely) but possibly outgoing port conflict where the 
previous local port is still closing whilst trying to be re-opened.


That's interesting. I will look into that.

to get an ideal fix though you'll want to move away from 
file_get_contents() as you're not doing things


Yes, I've also read that CURL is preferred to file_get_contents for 
reasons of performance and security. I'm going to try that too.



the most efficient way; HTTP/1.1 allows you to keep a port open and 
make multiple requests through the same socket/connection, simply keep 
the socket open and don't send a connection: close header after the 
request. (i say simply but you'll be needing to make you're own, or 
find a good, http handler that allows you to write raw requests and 
decode the raw http responses that come back)


best of luck; feel free to post your code incase anything jumps out as 
obvious.





I will let you know how it goes. Thanks for the advice!

...Rene



had another thought, it could be the web server you're requesting that 
is locking up, not enough worker threads, running cpu high etc etc - 
worth checking


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



Re: [PHP] Re: anchor name on URL

2008-11-20 Thread Dan
>
> The Webkist engine afaik is licensed under the GPL, because of the use
> of the code from the original KHTML. I'm not sure how this fits with M$
> proprietary plan however...
>

Webkit is licensed under LGPL and BSD licenses.

> You say that, have you heard the latest for IE9? They're already
> planning it, and apparently it's going to use the Webkit engine!

Actually they haven't planned that at all. There was a comment by Steve
Ballmer in an interview that it was an interesting project, and something
they may look at, but that comment was quickly countered the next day by
Microsoft PR. Also, 'look at' != 'adopt'. They have no intention of using
Webkit, as they feel it important that they're able to continue to 'extend
the web' with proprietary additions to Trident. ;)


[PHP] store class zithin session

2008-11-20 Thread Alain Roger
Hi,

i have a class and i would like to store it zithin session.
i was thinking to use serialize/unserialize but it does not work.

any idea how to do it ?
thx.

F.


Re: [PHP] store class zithin session

2008-11-20 Thread Stut

On 20 Nov 2008, at 11:01, Alain Roger wrote:

i have a class and i would like to store it zithin session.
i was thinking to use serialize/unserialize but it does not work.

any idea how to do it ?


Alain, you've been on this list long enough to know that "it does not  
work" is not enough information for people to be able to help you.


Firstly there is no need to serialise anything going into the session.  
Secondly I assume you want to store objects not classes. Thirdly there  
is no reason why it should not work, but there are some caveats you  
need to be aware of...


* The class definition must have been loaded before session_start() is  
called, otherwise you'll end up with an object of type stdClass rather  
than your class.


* Resources stored inside the object must be cleaned up in __sleep()  
and can be recreated in __wake() as they will not be stored in the  
session along with the rest of the object.


If you still can't get it to work after reading this, send us the code.

-Stut

--
http://stut.net/

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



Re: [PHP] store class zithin session

2008-11-20 Thread Yeti
If you can't load the class before calling session_start you can store
the serialized object in a file and simple set a
$_SESSION['path_to_file'] session variable..

EXAMPLE:


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



Re: [PHP] store class zithin session

2008-11-20 Thread Eric Butera
On Thu, Nov 20, 2008 at 8:37 AM, Yeti <[EMAIL PROTECTED]> wrote:
> If you can't load the class before calling session_start you can store
> the serialized object in a file and simple set a
> $_SESSION['path_to_file'] session variable..
>
> EXAMPLE:
>  session_start();
>
> //some code
>
> class apple_tree {
> var $apples = 17;
> }
>
> $temporary_file = 'appletree.txt';
> $file_content = serialize(new apple_tree());
>
> if ($fp = fopen($temporary_file, 'w')) {
> fwrite($fp, $file_content);
> $_SESSION['path_to_file'] = $temporary_file;
> fclose($fp);
> }
>
> ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Autoload.  Why on earth would you do such a thing?

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



Re: [PHP] Invalid Arguements

2008-11-20 Thread Terion Miller
I currently have it like this:

Select a Banner
Size
728x90 -
Leaderboard
160x600 -
Skyscraper
300x250 -
Square
88x31 and
300x250
120x240
940x30 - Pencil
Ad

but your saying it should be 

On Wed, Nov 19, 2008 at 8:14 PM, Jim Lucas <[EMAIL PROTECTED]> wrote:

> Terion Miller wrote:
>
>> Actually it did at one point have bannersize[#] # being the numbers
>> 1-however many were there
>> I've since gotten rid of that and made it a select.
>> and gotten rid of the implode all together because it wouldn't work in
>> either case and the more I read the more confused I got.
>> Terion
>>
>>
> Why don't you show us a snippet of code that is the form page for this.
>
> Let us see what you are trying to describe to us.
>
> Even if you switched it to a  the name attribute still
> needs to contain the brackets if you expect to pass more then one 
> field in the same form.
>
> --
> Jim Lucas
>
>   "Some men are born to greatness, some achieve greatness,
>   and some have greatness thrust upon them."
>
> Twelfth Night, Act II, Scene V
>by William Shakespeare
>
>


Re: [PHP] Invalid Arguements

2008-11-20 Thread Stut

On 20 Nov 2008, at 14:37, Terion Miller wrote:

I currently have it like this:

   Select a Banner
Size
   728x90 -
Leaderboard
   160x600 -
Skyscraper
   300x250 -
Square
   88x31 and
300x250
   120x240option>

   940x30 - Pencil
Ad
   
but your saying it should be 


That's a single select field, why are you trying to implode it??

-Stut

--
http://stut.net/


On Wed, Nov 19, 2008 at 8:14 PM, Jim Lucas <[EMAIL PROTECTED]> wrote:


Terion Miller wrote:


Actually it did at one point have bannersize[#] # being the numbers
1-however many were there
I've since gotten rid of that and made it a select.
and gotten rid of the implode all together because it wouldn't  
work in

either case and the more I read the more confused I got.
Terion


Why don't you show us a snippet of code that is the form page for  
this.


Let us see what you are trying to describe to us.

Even if you switched it to a  the name  
attribute still
needs to contain the brackets if you expect to pass more then one  


field in the same form.

--
Jim Lucas

 "Some men are born to greatness, some achieve greatness,
 and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
  by William Shakespeare





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



Re: [PHP] Invalid Arguements

2008-11-20 Thread Nathan Rixham

On 20 Nov 2008, at 14:37, Terion Miller wrote:

I currently have it like this:



if you've got it working don't change it :)

but to explain:

it is possible to send through an array of data from a form, to do this 
you place multiple elements with the same name followed by [] in the form..

so
 .. (our first select)
 ... (our second select)

when you do this php will recieve the BannerSize as an array.. so in the 
above scenario

$_POST['BannerSize'] will contain an array as such:
array(
  0 => "300x250", #whatever was chosen in the first select
  0 => "88x31-300x250" #whatever was chosen in the second select
);

now in the script you originally posted, php was using 
implode($_POST['BannerSize'] , ',' );
this function was basically taking the array values and combining them 
together as a single string.


the problem was that if you're form had  (no 
brackets) then php didn't receive and array of info in 
$_POST['BannerSize'] - and thus when it tried to implode the array, it 
broke, as there wasn't an array within :)


now, most got confused because most people write implode with the 
parameters the other way around, and they thought that was the error, so 
kind of confused things. [and because you posted it about 5 times under 
different names which didn't help ;)]


in short:
if you were using  's then you'd be wanting 
to implode the data as it's an array you're recieving
if you're using  as you currently are, then 
you can forget about all the implode etc.


the ideal fix would have been to make the php code accept either and 
detect if it was an array or not being passed by replacing the original 
code:


if (isset($_POST['BannerSize'])){$BannerSize =
implode($_POST['BannerSize'],',');} else {$BannerSize = "";}

with this new code:

if (isset($_POST['BannerSize'])) {
 if(is_array($_POST['BannerSize']) ) {
  $BannerSize = implode(',', $_POST['BannerSize']); //in right order..
 } else {
  $BannerSize = $_POST['BannerSize'];
 }
} else {
 $BannerSize = "";
}

which first checks if banner size has been sent at all,
if it has is it an array? [if yes implode it, if not just pick up the 
value sent]


hope that helps!

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



Re: [PHP] Invalid Arguements

2008-11-20 Thread Nathan Rixham

Terion Miller wrote:

Nathan, thank you thank you thank you
now I get it! your the bomb!!
terion


joy, glad to hear it

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



Re: [PHP] Re: PHP Warning: HTTP request failed -- BSD resource limit reached?

2008-11-20 Thread Rene Fournier


On 20-Nov-08, at 2:59 AM, Nathan Rixham wrote:


Rene Fournier wrote:

On 19-Nov-08, at 12:52 PM, Nathan Rixham wrote:

Rene Fournier wrote:

Hi,
I have four identical command-line PHP scripts running, and each  
will frequently fetch some data from another server via  
file_get_contents(). By frequently, I mean on average, every  
second.
Periodically, one of the processes (command-line PHP scripts),  
will fail on file_get_contents(), with the error message:


first thing that springs to mind is some form of hardware  
limitation, quite sure it's not php - could be a firewall with  
flood protection (or even your own isp's anti malware set-up)
to combat it try binding the outgoing request to a random ip each  
time (if you have multiple ip's on the box) [context: socket ->  
bindto]
That could explain it, except that all the traffic is on the same  
LAN. There's no firewall between Server A and Servers B and C.
next up (very unlikely) but possibly outgoing port conflict where  
the previous local port is still closing whilst trying to be re- 
opened.

That's interesting. I will look into that.
to get an ideal fix though you'll want to move away from  
file_get_contents() as you're not doing things
Yes, I've also read that CURL is preferred to file_get_contents for  
reasons of performance and security. I'm going to try that too.
the most efficient way; HTTP/1.1 allows you to keep a port open  
and make multiple requests through the same socket/connection,  
simply keep the socket open and don't send a connection: close  
header after the request. (i say simply but you'll be needing to  
make you're own, or find a good, http handler that allows you to  
write raw requests and decode the raw http responses that come back)


best of luck; feel free to post your code incase anything jumps  
out as obvious.



I will let you know how it goes. Thanks for the advice!
...Rene


had another thought, it could be the web server you're requesting  
that is locking up, not enough worker threads, running cpu high etc  
etc - worth checking


Don't think that can be it, since (a) the other processes are not  
being denied their http requests and (b) requests are going to two  
servers.



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



Re: [PHP] Re: PHP Warning: HTTP request failed -- BSD resource limit reached?

2008-11-20 Thread Daniel P. Brown
On Thu, Nov 20, 2008 at 11:50 AM, Rene Fournier <[EMAIL PROTECTED]> wrote:
>
> Don't think that can be it, since (a) the other processes are not being
> denied their http requests and (b) requests are going to two servers.

Have you checked your firewall settings?  It may be configured to
deny requests temporarily on hosts it thinks may be attempting an HTTP
DDoS, or perhaps something similar.  Nathan mentioned the same, but is
it possible that you're only considering a hardware firewall?  Unless
explicitly configured, a software firewall on the OS level could be
blocking all matching traffic on all interfaces (including the LAN).

-- 

http://www.parasane.net/
[EMAIL PROTECTED] || [EMAIL PROTECTED]
1 LEFT: $149/mo. $0 Setup - Dual-Core/320GB HDD/1GB RAM/3TB
100Mbps/cPanel - SAME-DAY SETUP! Contact me to buy.

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



Re: [PHP] Re: PHP Warning: HTTP request failed -- BSD resource limit reached?

2008-11-20 Thread Nathan Rixham

Daniel P. Brown wrote:

On Thu, Nov 20, 2008 at 11:50 AM, Rene Fournier <[EMAIL PROTECTED]> wrote:

Don't think that can be it, since (a) the other processes are not being
denied their http requests and (b) requests are going to two servers.


Have you checked your firewall settings?  It may be configured to
deny requests temporarily on hosts it thinks may be attempting an HTTP
DDoS, or perhaps something similar.  Nathan mentioned the same, but is
it possible that you're only considering a hardware firewall?  Unless
explicitly configured, a software firewall on the OS level could be
blocking all matching traffic on all interfaces (including the LAN).



Rene, are you forking the command line script for each request by any 
chance? if you are remember to do an exit() after each one is finished 
otherwise the new forked process will stay open until cleaned up by the 
system (or until the thread that forked is finished) which could be 
creating you're problem.


apologies if way off the mark, just attempting some lateral thinking on 
this one!


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



Re: [PHP] store class zithin session

2008-11-20 Thread Jochem Maas
Eric Butera schreef:
> On Thu, Nov 20, 2008 at 8:37 AM, Yeti <[EMAIL PROTECTED]> wrote:

...

>>
> 
> Autoload.  Why on earth would you do such a thing?

autoload ... your neighbourhood opcode cache performance killer,
then again so is file based sessions (for ease of use I stick
my session files on /dev/shm/foo [i.e. RAM] if/when using a
file based session handler ... I figure if the box goes down and
takes /dev/shm with it the lost session data is the least of
my worries ... besides by the time the box is up current visitors
will generally have given up and left already)

... and storing a path to
a file containing a serialized object in the session is a bit nuts,
you might as well store the serialized object in the session and
save at least one file write/read. storing a serialized object,
as opposed to letting the session handler do transparent serialization
can help you get round an infrastructure problem (where you can't
load the class before starting the session) and also can improve
performance where you might not want/need to initialize the
given object on every request.

> 


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



Re: [PHP] fread() behaviour

2008-11-20 Thread Jochem Maas
Stut schreef:
> On 20 Nov 2008, at 01:29, Rene Fournier wrote:
>> I'm trying to understand something about fread(). I'm using fread() on
>> an incoming socket stream that will send, for example, 26630 characters:
>>
>> while ( ($buf=fread($read[$i], 8192)) != '' ) {
>> $sock_data .= $buf;
>> usleep(1000);
>> echo ".";
>> }
>> echo ",";
>>
>>
>> As soon as the socket client sends the data, immediately the server
>> will echo:
>>
>> 
>>
>>
>> Then wait nearly a minute, and echo:
>>
>> ,
>>
>> So my question is, why does fread wait if there is nothing more to
>> read? Shouldn't it return immediately? (That's what I want.) And as
>> for the delay, it's there so that if the incoming data is a little
>> slow, it has time to catch up with fread. Thanks.
> 
> As Craige already mentioned, fread will read bytes until it meets an EOF
> so unless the other side sends one or closes the socket fread will wait
> for the number of characters you've asked for (8192) or a timeout (which
> is the delay you're seeing). In other words it's not detecting the end
> of the data, it's just timing out waiting for more.
> 
> You ideally want to have the other side tell you how many bytes it's
> going to send. If you can't do that then hopefully the data you're
> receiving has some sort of structure so you can check the incoming data
> for some terminating string. If not then you've got a problem that can't
> be reliably solved. You could mess around with the timeout and/or make
> use of functions like socket_select to check for waiting data, but what
> you'll end up with will be problematic on slow connections and generally
> unreliable.

good stuff from Stut & Craige ... I just wondered, Im pretty sure that the
usleep(1000) is completely superfluous. fread() will read to the buffer length
or EOF regardless of how slow the stream trickles in (obviously it may timeout
if nothing trickles in for ages but that's a different issue and not solved
with a usleep() AFAICT).

> 
> -Stut
> 


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



Re: [PHP] store class zithin session

2008-11-20 Thread Eric Butera
On Thu, Nov 20, 2008 at 2:07 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:
> Eric Butera schreef:
>> On Thu, Nov 20, 2008 at 8:37 AM, Yeti <[EMAIL PROTECTED]> wrote:
>
> ...
>
>>>
>>
>> Autoload.  Why on earth would you do such a thing?
>
> autoload ... your neighbourhood opcode cache performance killer,
> then again so is file based sessions (for ease of use I stick
> my session files on /dev/shm/foo [i.e. RAM] if/when using a
> file based session handler ... I figure if the box goes down and
> takes /dev/shm with it the lost session data is the least of
> my worries ... besides by the time the box is up current visitors
> will generally have given up and left already)
>
> ... and storing a path to
> a file containing a serialized object in the session is a bit nuts,
> you might as well store the serialized object in the session and
> save at least one file write/read. storing a serialized object,
> as opposed to letting the session handler do transparent serialization
> can help you get round an infrastructure problem (where you can't
> load the class before starting the session) and also can improve
> performance where you might not want/need to initialize the
> given object on every request.
>
>>
>
>

Well I wouldn't put objects into the session to begin with.  I was
just talking about this specific case.  Wouldn't autoload be fine if
the file was already in the opcode cache?

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



Re: [PHP] store class zithin session

2008-11-20 Thread Kevin Waterson
This one time, at band camp, "Alain Roger" <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> i have a class and i would like to store it zithin session.
> i was thinking to use serialize/unserialize but it does not work.

http://www.phpro.org/tutorials/Introduction-To-PHP-Sessions.html#8

Kevin

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



Re: [PHP] Re: PHP Warning: HTTP request failed -- BSD resource limit reached?

2008-11-20 Thread Rene Fournier


On 20-Nov-08, at 9:56 AM, Daniel P. Brown wrote:

On Thu, Nov 20, 2008 at 11:50 AM, Rene Fournier  
<[EMAIL PROTECTED]> wrote:


Don't think that can be it, since (a) the other processes are not  
being

denied their http requests and (b) requests are going to two servers.


   Have you checked your firewall settings?  It may be configured to
deny requests temporarily on hosts it thinks may be attempting an HTTP
DDoS, or perhaps something similar.  Nathan mentioned the same, but is
it possible that you're only considering a hardware firewall?  Unless
explicitly configured, a software firewall on the OS level could be
blocking all matching traffic on all interfaces (including the LAN).


There is no firewall between any of the servers -- they are all on the  
same LAN.


...Rene

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



Re: [PHP] Re: PHP Warning: HTTP request failed -- BSD resource limit reached?

2008-11-20 Thread Rene Fournier


On 20-Nov-08, at 10:46 AM, Nathan Rixham wrote:


Daniel P. Brown wrote:
On Thu, Nov 20, 2008 at 11:50 AM, Rene Fournier  
<[EMAIL PROTECTED]> wrote:
Don't think that can be it, since (a) the other processes are not  
being
denied their http requests and (b) requests are going to two  
servers.

   Have you checked your firewall settings?  It may be configured to
deny requests temporarily on hosts it thinks may be attempting an  
HTTP
DDoS, or perhaps something similar.  Nathan mentioned the same, but  
is

it possible that you're only considering a hardware firewall?  Unless
explicitly configured, a software firewall on the OS level could be
blocking all matching traffic on all interfaces (including the LAN).


Rene, are you forking the command line script for each request by  
any chance? if you are remember to do an exit() after each one is  
finished otherwise the new forked process will stay open until  
cleaned up by the system (or until the thread that forked is  
finished) which could be creating you're problem.


apologies if way off the mark, just attempting some lateral thinking  
on this one!


No apologies necessary -- I really appreciate the feedback.

But no, I'm not forking anything. Each script (process) runs in a  
loop, and during each iteration it will call file_get_contents(Server  
A/B) one or more times.


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



Re: [PHP] Re: PHP Warning: HTTP request failed -- BSD resource limit reached?

2008-11-20 Thread Daniel P. Brown
On Thu, Nov 20, 2008 at 2:41 PM, Rene Fournier <[EMAIL PROTECTED]> wrote:
>
> There is no firewall between any of the servers -- they are all on the same
> LAN.

I read when you said that, but I must not have explained myself
well enough before.  Sorry.

Linux, by default, has firewalls installed with the OS.  It
doesn't matter whether you're on a LAN, WAN, or all by your lonesome.

-- 

http://www.parasane.net/
[EMAIL PROTECTED] || [EMAIL PROTECTED]
1 LEFT: $149/mo. $0 Setup - Dual-Core/320GB HDD/1GB RAM/3TB
100Mbps/cPanel - SAME-DAY SETUP! Contact me to buy.

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



Re: [PHP] store class zithin session

2008-11-20 Thread Stut

On 20 Nov 2008, at 19:35, Eric Butera wrote:

Well I wouldn't put objects into the session to begin with.


Why not? I do it all the time and it works fine.


I was
just talking about this specific case.  Wouldn't autoload be fine if
the file was already in the opcode cache?


Opcode caches work during the compilation phase, so any dynamic  
loading such as that provided by autoloaders cannot be optimised. This  
has been discussed in the past on this list, check the archives for  
more details.


-Stut

--
http://stut.net/

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



Re: [PHP] store class zithin session

2008-11-20 Thread Eric Butera
On Thu, Nov 20, 2008 at 2:51 PM, Stut <[EMAIL PROTECTED]> wrote:
> On 20 Nov 2008, at 19:35, Eric Butera wrote:
>>
>> Well I wouldn't put objects into the session to begin with.
>
> Why not? I do it all the time and it works fine.
>
>> I was
>> just talking about this specific case.  Wouldn't autoload be fine if
>> the file was already in the opcode cache?
>
> Opcode caches work during the compilation phase, so any dynamic loading such
> as that provided by autoloaders cannot be optimised. This has been discussed
> in the past on this list, check the archives for more details.
>
> -Stut
>
> --
> http://stut.net/
>


http://till.vox.com/library/post/zendframework-performance.html?_c=feed-rss-full

Item #3: Get rid off require_once, use __autoload (and the Zend_Loader)

It just lead me to believe that after autoload found a class it
somehow cached the code for it.  I'll look into this when I get some
free time for testing.

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



[PHP] Model Web Site

2008-11-20 Thread Stephen

My prime hobby is photography and the next is web site building.

So now I have a young model (18+) asking me about getting a web site.

The idea is members can see content, that will include, photos, her blog 
and a discussion forum.


I like the idea of building it, but it includes a lot of things I have 
no experience in.


Can someone point me to documentation/tutorials/scripts or anything that 
might help.


I don't want a turnkey solution. I want to learn how to do this.

Thank you!
Stephen

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



RE: [PHP] Model Web Site

2008-11-20 Thread Boyd, Todd M.
> -Original Message-
> From: Stephen [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 20, 2008 4:17 PM
> To: PHP-General
> Subject: [PHP] Model Web Site
> 
> My prime hobby is photography and the next is web site building.
> 
> So now I have a young model (18+) asking me about getting a web site.
> 
> The idea is members can see content, that will include, photos, her
> blog
> and a discussion forum.
> 
> I like the idea of building it, but it includes a lot of things I have
> no experience in.
> 
> Can someone point me to documentation/tutorials/scripts or anything
> that
> might help.
> 
> I don't want a turnkey solution. I want to learn how to do this.

http://www.w3schools.com/html
http://www.w3schools.com/xhtml
http://www.w3schools.com/css
http://www.w3schools.com/js 
http://www.w3schools.com/php
http://www.w3schools.com/sql
http://www.php.net
http://www.mysql.com

most important link:

http://www.google.com

Get comfortable with programming; with algorithms; with data structures;
with databases; with client-server relationships.

HTH,


// Todd

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



Re: [PHP] Model Web Site

2008-11-20 Thread Daniel P. Brown
On Thu, Nov 20, 2008 at 5:16 PM, Stephen <[EMAIL PROTECTED]> wrote:
>
> Can someone point me to documentation/tutorials/scripts or anything that
> might help.

Stephen,

The whole thing could be built pretty quickly using existing open
source systems such as phpBB3[1] and Gallery[2] as a core.  Then it's
a matter of putting up smaller additional scripts to link your other
things together.

1: http://www.phpbb.com/
2: http://www.nukedgallery.net/

Just some examples, of course.  There are literally thousands of
options, including building your own or hiring someone to do it.  You
should have no problem jumping right in.

-- 

http://www.parasane.net/
[EMAIL PROTECTED] || [EMAIL PROTECTED]
1 LEFT: $149/mo. $0 Setup - Dual-Core/320GB HDD/1GB RAM/3TB
100Mbps/cPanel - SAME-DAY SETUP! Contact me to buy.

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



Re: [PHP] Model Web Site

2008-11-20 Thread Stephen

Boyd, Todd M. wrote:

http://www.w3schools.com/html
http://www.w3schools.com/xhtml
http://www.w3schools.com/css
http://www.w3schools.com/js 
http://www.w3schools.com/php

http://www.w3schools.com/sql
http://www.php.net
http://www.mysql.com

most important link:

http://www.google.com

Get comfortable with programming; with algorithms; with data structures;
with databases; with client-server relationships.

HTH,
  

Thanks . but ... ouch!

I have been doing HTML sites for 5 years. CSS for four and PHP/MySQL for 
three.


What is new to me is controlling access based on being a member. And 
making it tough for hackers.


Stephen

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



Re: [PHP] Re: PHP Warning: HTTP request failed -- BSD resource limit reached?

2008-11-20 Thread Rene Fournier


On 20-Nov-08, at 12:44 PM, Daniel P. Brown wrote:

On Thu, Nov 20, 2008 at 2:41 PM, Rene Fournier <[EMAIL PROTECTED]>  
wrote:


There is no firewall between any of the servers -- they are all on  
the same

LAN.


   I read when you said that, but I must not have explained myself
well enough before.  Sorry.

   Linux, by default, has firewalls installed with the OS.  It
doesn't matter whether you're on a LAN, WAN, or all by your lonesome.


That's a good point, but I don't believe it can explain the failures,  
since even though one process repeatedly fails at an HTTP request to  
Server A, several other processes on the same box are successfully  
executing HTTP requests (file_get_contents()).


It seems to me that I'm periodically maxing-out a certain per-process  
resource limit.  For example, number of open files or something  
similar... (Assuming file_get_contents() counts as that)... After  
10-60 seconds, previous open files/connections for that particular  
process close, allowing it to again open HTTP requests to Server A.  I


I guess my next question is, what resource does file_get_contents()  
use upon execution?


...Rene

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



Re: [PHP] Model Web Site

2008-11-20 Thread Chris

Stephen wrote:

Boyd, Todd M. wrote:

http://www.w3schools.com/html
http://www.w3schools.com/xhtml
http://www.w3schools.com/css
http://www.w3schools.com/js http://www.w3schools.com/php
http://www.w3schools.com/sql
http://www.php.net
http://www.mysql.com

most important link:

http://www.google.com

Get comfortable with programming; with algorithms; with data structures;
with databases; with client-server relationships.

HTH,
  

Thanks . but ... ouch!

I have been doing HTML sites for 5 years. CSS for four and PHP/MySQL for 
three.


..none of which was originally mentioned.

What is new to me is controlling access based on being a member. And 
making it tough for hackers.


Look for a tutorial on building a login system and go from there.

--
Postgresql & php tutorials
http://www.designmagick.com/


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



Re: [PHP] Re: PHP Warning: HTTP request failed -- BSD resource limit reached?

2008-11-20 Thread Nathan Rixham

Rene Fournier wrote:


On 20-Nov-08, at 12:44 PM, Daniel P. Brown wrote:

On Thu, Nov 20, 2008 at 2:41 PM, Rene Fournier <[EMAIL PROTECTED]> 
wrote:


There is no firewall between any of the servers -- they are all on 
the same

LAN.


   I read when you said that, but I must not have explained myself
well enough before.  Sorry.

   Linux, by default, has firewalls installed with the OS.  It
doesn't matter whether you're on a LAN, WAN, or all by your lonesome.


That's a good point, but I don't believe it can explain the failures, 
since even though one process repeatedly fails at an HTTP request to 
Server A, several other processes on the same box are successfully 
executing HTTP requests (file_get_contents()).


It seems to me that I'm periodically maxing-out a certain per-process 
resource limit.  For example, number of open files or something 
similar... (Assuming file_get_contents() counts as that)... After 
10-60 seconds, previous open files/connections for that particular 
process close, allowing it to again open HTTP requests to Server A.  I


I guess my next question is, what resource does file_get_contents() 
use upon execution?


...Rene

is it an https(ssl) address you're calling, and more specifically IIS 
servers? if so they don't close the connection properly meaning the 
connections will be left open until they time out andthus cause you're 
problem.


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



Re: [PHP] Model Web Site

2008-11-20 Thread Yeti
>> What is new to me is controlling access based on being a member. And
>> making it tough for hackers.
>
> Look for a tutorial on building a login system and go from there.

Since you mentioned security I would recommend HTTPS.
http://en.wikipedia.org/wiki/HTTPS

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



Re: [PHP] in_array breaks down for 0 as value

2008-11-20 Thread Ashley Sheridan
On Thu, 2008-11-20 at 09:25 +, Stut wrote:
> On 20 Nov 2008, at 06:55, Yashesh Bhatia wrote:
> >  I wanted to use in_array to verify the results of a form submission
> > for a checkbox and found an interesting
> > behaviour.
> >
> > $ php -v
> > PHP 5.2.5 (cli) (built: Jan 12 2008 14:54:37)
> > $
> >
> > $ cat in_array2.php
> >  > $node_review_types = array(
> >   'page'   => 'page',
> >   'story'  => 'story',
> >   'nodereview' => 'abc',
> >   );
> >
> > if (in_array('page', $node_review_types)) {
> >  print "page found in node_review_types\n";
> > }
> > if (in_array('nodereview', $node_review_types)) {
> >  print "nodereview found in node_review_types\n";
> > }
> >
> > ?>
> > $ php in_array2.php
> > page found in node_review_types
> > $
> >
> > This  works fine. but if i change the value of the key 'nodereview' to
> > 0 it breaks down.
> >
> > $ diff in_array2.php in_array3.php
> > 6c6
> > <'nodereview' => 'abc',
> > ---
> >>   'nodereview' => 0,
> > $
> >
> > $ php in_array3.php
> > page found in node_review_types
> > nodereview found in node_review_types
> > $
> >
> > Any reason why in_array is returning TRUE when one has a 0 value on  
> > the array ?
> 
> That's weird, 5.2.6 does the same thing. There's actually a comment  
> about this on the in_array manual page from james dot ellis at gmail  
> dot com...
> 
> 
> 
> Be aware of oddities when dealing with 0 (zero) values in an array...
> 
> This script:
>  $array = array('testing',0,'name');
> var_dump($array);
> //this will return true
> var_dump(in_array('foo', $array));
> //this will return false
> var_dump(in_array('foo', $array, TRUE));
> ?>
> 
> It seems in non strict mode, the 0 value in the array is evaluating to  
> boolean FALSE and in_array returns TRUE. Use strict mode to work  
> around this peculiarity.
> This only seems to occur when there is an integer 0 in the array. A  
> string '0' will return FALSE for the first test above (at least in  
> 5.2.6).
> 
> 
> 
> So use strict mode and this problem will go away. Oh, and please read  
> the manual before asking a question in future.
> 
> -Stut
> 
> -- 
> http://stut.net/
> 
What about using the === and !== comparisons to compare and make sure
that 0 is not giving a false false.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Re: PHP Warning: HTTP request failed -- BSD resource limit reached?

2008-11-20 Thread Rene Fournier


On 20-Nov-08, at 3:57 PM, Nathan Rixham wrote:


Rene Fournier wrote:


On 20-Nov-08, at 12:44 PM, Daniel P. Brown wrote:

On Thu, Nov 20, 2008 at 2:41 PM, Rene Fournier  
<[EMAIL PROTECTED]> wrote:


There is no firewall between any of the servers -- they are all  
on the same

LAN.


  I read when you said that, but I must not have explained myself
well enough before.  Sorry.

  Linux, by default, has firewalls installed with the OS.  It
doesn't matter whether you're on a LAN, WAN, or all by your  
lonesome.


That's a good point, but I don't believe it can explain the  
failures, since even though one process repeatedly fails at an HTTP  
request to Server A, several other processes on the same box are  
successfully executing HTTP requests (file_get_contents()).


It seems to me that I'm periodically maxing-out a certain per- 
process resource limit.  For example, number of open files or  
something similar... (Assuming file_get_contents() counts as  
that)... After 10-60 seconds, previous open files/connections for  
that particular process close, allowing it to again open HTTP  
requests to Server A.  I


I guess my next question is, what resource does file_get_contents()  
use upon execution?


...Rene

is it an https(ssl) address you're calling, and more specifically  
IIS servers? if so they don't close the connection properly meaning  
the connections will be left open until they time out andthus cause  
you're problem.


Nope, it's just http, port 80, and not to IIS. To be clear, PHP  
scripts/processes on Server A (Mac OS X Server 10.4.11, PHP 5.2.4) are  
issuing these http requests (file_get_contents) to Servers B (Centos  
5.2) and itself (Server A).


The failures occur on attempts to Server B and A (itself), but only in  
one process at a time. (Server A is running several identical scripts/ 
processes -- even while one fails for a while, the others work -- that  
is, Servers B and A respond fine.)


...Rene



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



[PHP] Can GD make a JPG thumbnail of a PDF?

2008-11-20 Thread Brian Dunning

Well can it?

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



Re: [PHP] Can GD make a JPG thumbnail of a PDF?

2008-11-20 Thread Stephen Johnson
No but you can use imagemagicks convert to convert the pdf to an image and
then make a thumbnail of it.


On 11/20/08 4:39 PM, "Brian Dunning" <[EMAIL PROTECTED]> wrote:

> Well can it?

-- 
Stephen Johnson
The Lone Coder

http://www.ouradoptionblog.com
*Join us on our adoption journey*

[EMAIL PROTECTED]
http://www.thelonecoder.com

*Continuing the struggle against bad code*
--



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



Re: [PHP] Model Web Site

2008-11-20 Thread Craige Leeder
As Daniel mentioned, I would recomed building it upon an existing 
system. I've seen whole sites custom built around PHPBB.


This might be something you want to look into. Google for PHPBB 
programming tutorials; it's pretty well documented. I think it's your 
best bet if you don't want to spend forever building it from the ground-up.


PHPNuke might be a good option too, but I never liked it myself. It's 
all provided out of the box though.


- Craige

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



Re: [PHP] in_array breaks down for 0 as value

2008-11-20 Thread Lars Torben Wilson
2008/11/20 Stut <[EMAIL PROTECTED]>:
> On 20 Nov 2008, at 06:55, Yashesh Bhatia wrote:
>>
>>  I wanted to use in_array to verify the results of a form submission
>> for a checkbox and found an interesting
>> behaviour.
>>
>> $ php -v
>> PHP 5.2.5 (cli) (built: Jan 12 2008 14:54:37)
>> $
>>
>> $ cat in_array2.php
>> > $node_review_types = array(
>>  'page'   => 'page',
>>  'story'  => 'story',
>>  'nodereview' => 'abc',
>>  );
>>
>> if (in_array('page', $node_review_types)) {
>>  print "page found in node_review_types\n";
>> }
>> if (in_array('nodereview', $node_review_types)) {
>>  print "nodereview found in node_review_types\n";
>> }
>>
>> ?>
>> $ php in_array2.php
>> page found in node_review_types
>> $
>>
>> This  works fine. but if i change the value of the key 'nodereview' to
>> 0 it breaks down.
>>
>> $ diff in_array2.php in_array3.php
>> 6c6
>> <'nodereview' => 'abc',
>> ---
>>>
>>>  'nodereview' => 0,
>>
>> $
>>
>> $ php in_array3.php
>> page found in node_review_types
>> nodereview found in node_review_types
>> $
>>
>> Any reason why in_array is returning TRUE when one has a 0 value on the
>> array ?
>
> That's weird, 5.2.6 does the same thing. There's actually a comment about
> this on the in_array manual page from james dot ellis at gmail dot com...
>
> 
>
> Be aware of oddities when dealing with 0 (zero) values in an array...
>
> This script:
>  $array = array('testing',0,'name');
> var_dump($array);
> //this will return true
> var_dump(in_array('foo', $array));
> //this will return false
> var_dump(in_array('foo', $array, TRUE));
> ?>
>
> It seems in non strict mode, the 0 value in the array is evaluating to
> boolean FALSE and in_array returns TRUE. Use strict mode to work around this
> peculiarity.
> This only seems to occur when there is an integer 0 in the array. A string
> '0' will return FALSE for the first test above (at least in 5.2.6).
>
> 
>
> So use strict mode and this problem will go away. Oh, and please read the
> manual before asking a question in future.
>
> -Stut

I wouldn't consider it weird; it's just how PHP handles loose type
comparisons. I would certainly agree that it's not terribly obvious
why it happens, though. :) That said, it's consistent with PHP
behaviour.

James Ellis almost got it right in his note. As I already noted, it's
not because of a conversion to boolean FALSE, but a conversion to
integer 0. You can test this by substituting FALSE for the 0 in the
array in the example and trying it.


Torben

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



[PHP] reading XML

2008-11-20 Thread Angelo Zanetti
Hi all, 

 

I have a script that I call with CURL and get an XML response with a few
parameters.

 

I need to be able to read that XML but not sure how to.

 

I know of simpleXML but the server is php4.

 

Would xml_parse be the thing to look at?

 

What is the simplest way to accomplish this small challenge?

 

Thanks in advance.

 

 



Re: [PHP] reading XML

2008-11-20 Thread Jim Lucas

Angelo Zanetti wrote:
Hi all, 

 


I have a script that I call with CURL and get an XML response with a few
parameters.

 


I need to be able to read that XML but not sure how to.

 


I know of simpleXML but the server is php4.

 


Would xml_parse be the thing to look at?

 


What is the simplest way to accomplish this small challenge?

 


Thanks in advance.

 

 





Maybe look into this example.  Just a quick search and found this.  Not 
sure if it will even work in your situation, but thought I would pass it 
along.


http://us2.php.net/manual/en/function.xml-parser-create.php#38739

Jim Lucas

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



Re: [PHP] reading XML

2008-11-20 Thread Jim Lucas

Angelo Zanetti wrote:
Hi all, 

 


I have a script that I call with CURL and get an XML response with a few
parameters.

 


I need to be able to read that XML but not sure how to.

 


I know of simpleXML but the server is php4.

 


Would xml_parse be the thing to look at?

 


What is the simplest way to accomplish this small challenge?

 


Thanks in advance.

 

 





Or this one even

http://us2.php.net/manual/en/function.xml-parse.php#83416

Jim Lucas

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