Re: [PHP] php 4 & php 5

2005-03-05 Thread Rasmus Lerdorf
Richard Lynch wrote:
timothy johnson wrote:
Is there a way to install two version of php on the same machine, and
use them for two different users?

Option 1:
Install two copies of Apache, with different httpd.conf files, on two
different ports.
Somebody gets stuck using http://example.com:81 (or any port but 80) but
this gives everything you asked for.
Option 2:
Use --enable-versioning while compiling PHP.  This definitely allowed for
PHP3 and PHP4 and *might* allow for 4&5...  Or not.  RTFM
But you won't get different Users.
Option 3:
Install at least one of the two as CGI (fastCGI, whatever), and use a
different extension (.php4 or .php5) or use other means (ForceType,
AddHandler, AddType, etc) to change which is used on a per directory
basis.  Use suexec, if you UNDERSTAND THE RAMIFICATIONS to alter the user
of the CGI process.  Mis-use of suexec is incredibly dangerous.  YMMV 
NAIAA  IANAL
The CGI usage will lose some minimal functionality.  HTTP Authentication
springs to mind, but there are 3 or 4 functions/features that just plain
won't work in CGI.  RTFM

Option 4:
In terms of expenses/headaches, you will probably be better off just
buying a second machine.  Problem solved.
Running 2 Apache instances is by far the easiest solution.  And to make 
it invisible to the end user you can ProxyPass connections from your 
port 80 server to your port 81 or whatever port you put it on. For 
example, I have a test app giving PHP 5.1 and the Yahoo Web Services a 
workout on a server that also has a bunch of PHP4 stuff.

The URL is:  http://buzz.progphp.com
This is actually being served off of a port 81 server.  The port 80 conf 
 file has this entry in the buzz vhost:

ProxyPass / http://buzz.progphp.com:81/
Then in the port 81 server I just have a standard vhost config for buzz 
listening on port 81.

If you go to the HTTP Headers block of:
http://buzz.progphp.com/info.php
You can see that you end up with:
Host: buzz.progphp.com:81
Via: 1.1 buzz.progphp.com (Apache/1.3.33)
X-Forwarded-For: 24.6.1.160
X-Forwarded-Host: buzz.progphp.com
X-Forwarded-Server: buzz.progphp.com
So the only thing you may need to change in an application running 
behind ProxyPass is if you have $_SERVER["REMOTE_ADDR"] somewhere. 
Change that to use $_SERVER["HTTP_X_FORWARDED_FOR"] instead.

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


[PHP] warning & question about mysql sessions & concurrency

2005-03-05 Thread Josh Whiting
I've been trying to switch to MySQL-based session storage instead of the 
native PHP session storage.  In doing so, I've run into a lot of code on 
the web that exhibits a serious flaw regarding concurrent requests from 
the same client. All the code I've seen has glossed over the need to 
lock the session for the duration of the request, e.g. not allow 
concurrent requests to use it until it has finished.  PHP's native 
session handler correctly does this, but lots of MySQL-driven session 
code does not.

Example timeline:
1. client sends a request
2. session data is loaded from the db 
3. same client sends a request before the first one is finished (e.g. 
frames, tabbed browsing, slow server response times, etc)
4. session data is again loaded from the db
5. the first request changes some values in $_SESSION
6. the second request changes some values in $_SESSION
7. the first request writes the data to the db and exits
8. the second request writes it's data (over that written by the first 
request) and exits

PHP's native handler solves this problem by forcing concurrent requests
to wait for each other. The same thing needs to happen in a
database-driven session handler.

SO, does anyone have some code that uses MySQL to replace PHP's native
session storage that also correctly handles this concurrency problem? 
Ideally I'd like to see just a set of functions that can be used with 
sessions_set_save_handler() to transparently shift PHP's sessions to a 
database, but I'm not going to use the stuff I've found on the web or 
even in books (appendix D of O'Reilly's Web Database Applications with 
PHP & MySQL publishes code with this problem).

Folks using database sessions who do not deal with this scenario be
warned! I'm surprised so much bad code is going around for this task...

Many thanks in advance,
Josh Whiting

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



[PHP] unexplainable - page generation time class

2005-03-05 Thread James Williams
Howdy!  I've made a class which simply determines the page generation 
time of a php script... After pretty much an hour of straight examining 
the code and trying tons of different things, no good has come of it, 
however I can't find an error... anywhere.


class page_gen {
   //
   // PRIVATE - DO NOT MODIFY
   //
   var $cls_start_time;
   var $cls_stop_time;
   var $cls_gen_time;
   
   //
   // FIGURE OUT THE TIME AT THE BEGINNING OF THE PAGE
   //
   function start() {
   $microstart = explode(' ',microtime());
   $this->cls_start_time = $microstart[0] + $microstart[1];
   }
   
   //
   // FIGURE OUT THE TIME AT THE END OF THE PAGE
   //
   function stop() {
   $microstop = explode(' ',microtime());
   $this->cls_stop_time = $microstop[0] + $microstop[1];
   }
   
   //
   // CALCULATE THE DIFFERENCE BETWEEN THE BEGINNNG AND THE END AND 
COLOR CODE THE RESULT
   //
   function gen() {
   $this->cls_gen_time = $this->cls_stop_time - 
$this->cls_start_time;
   return $this->cls_gen_time;
   }
   }
?>

What happens is it simply returns the $this->cls_start_time variable.  

Both the start() and stop() functions work fine because to test them I 
put print commands at the end and they both returned proper results, the 
error appears to be in the line where I minus the start time from the 
end time.  It simply returns a negative start time instead of minusing 
the two.

I tried changing the minus to a plus for testing sake and it just took 
out the negative.  Does anybody have any idea what is going on here?  
Thanks-you

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


Re: [PHP] cache engine

2005-03-05 Thread Mark Charette
Evert - Rooftop Solutions wrote:
Check it out, is in old article, but it says "|shm| -- The |shm| 
container stores the cached data in the shared memory. Benchmarks 
indicate that the current implementation of this container is much 
slower than the |file| container."
Which, of course, is miles away from saying that shared memory is slower 
than the file system.

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


Re: [PHP] cache engine

2005-03-05 Thread Evert - Rooftop Solutions
Mark Charette wrote:
Evert - Rooftop Solutions wrote:
I heard that shared memory is actually slower than writing and 
reading a file and it is not available on windows systems.

Hmmm ... that's an interesting thing you heard concerning shared 
memory. Care to share _who_ told you that?

I'd like to make sure I don't hire him/her in the future.
http://www.onlamp.com/pub/a/php/2001/10/11/pearcache.html
Check it out, is in old article, but it says "|shm| -- The |shm| 
container stores the cached data in the shared memory. Benchmarks 
indicate that the current implementation of this container is much 
slower than the |file| container."

It is a bit outdated, but I haven't seen any recent benchmarks.
grt,
Evert
--
Rooftop Solutions - Web Applications on Demand
tel. (+31)628962319 fax. (+31)842242474
[EMAIL PROTECTED]
http://www.rooftopsolutions.nl
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] cache engine

2005-03-05 Thread James Williams
Mark Charette wrote:
Evert - Rooftop Solutions wrote:
I heard that shared memory is actually slower than writing and reading 
a file and it is not available on windows systems.

Hmmm ... that's an interesting thing you heard concerning shared memory. 
Care to share _who_ told you that?

I'd like to make sure I don't hire him/her in the future.
Mark C.
HaHa Burn!  so you're saying that this is *not* true.  I'm also 
interested in cacheing although I know nothing about it.  I'm making a 
forum and it's small size and fast processing times are it's forte, so a 
cache system would be awesome, I'm thinking about incorporating it with 
my simple templating class.

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


Re: [PHP] cache engine

2005-03-05 Thread Mark Charette
Evert - Rooftop Solutions wrote:
I heard that shared memory is actually slower than writing and reading a 
file and it is not available on windows systems.
Hmmm ... that's an interesting thing you heard concerning shared memory. 
Care to share _who_ told you that?

I'd like to make sure I don't hire him/her in the future.
Mark C.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] cache engine

2005-03-05 Thread Evert - Rooftop Solutions
Chris Smith wrote:
I have seen some people using stornig cached items in shared memory. 
This is explained in some detail here:

http://www.danga.com/memcached/
I heard that shared memory is actually slower than writing and reading a 
file and it is not available on windows systems.

There are PHP client APIs available.
Alternatively PEAR offers some interesting caching solutions although 
i have not investigated them thoroughly ( http://pear.php.net/ )

Caching brings all sorts of wierdness out in applications due to 
multiple states of data being present in different layers in a system, 
so be careful.

Thanks I will check it out.
Hope this helps,
Chris Smith
Ninja Labs
http://www.ninjalabs.co.uk/
greetings,
Evert
--
Rooftop Solutions - Web Applications on Demand
tel. (+31)628962319 fax. (+31)842242474
[EMAIL PROTECTED]
http://www.rooftopsolutions.nl
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] cache engine

2005-03-05 Thread Chris Smith
Evert - Rooftop Solutions wrote:
I have written an extensive web application frameworks, and I keep 
seeing my execution time and memory-usage growing. Right now it is not a 
problem, but before it get's out of hands I will need to create a good 
cache engine.
My cache engine requires that I can cache method results, based on 
multiple parameters. What would be a good way to implement this? I know 
this propably a well-formed question, but before I start, I want to be 
sure I'll do it the right way. Has anyone got any experience with this, 
or can anyone give me some pointers on where to start looking?
I have seen some people using stornig cached items in shared memory. 
This is explained in some detail here:

http://www.danga.com/memcached/
There are PHP client APIs available.
Alternatively PEAR offers some interesting caching solutions although i 
have not investigated them thoroughly ( http://pear.php.net/ )

Caching brings all sorts of wierdness out in applications due to 
multiple states of data being present in different layers in a system, 
so be careful.

Hope this helps,
Chris Smith
Ninja Labs
http://www.ninjalabs.co.uk/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Comments and performance

2005-03-05 Thread Matthew Fonda
Hello,

Comments should not affect speed or performance at. Commenting is a good
thing, and you should continue to do it. :)

On Sat, 2005-03-05 at 13:15, Chris Smith wrote:
> Hi,
> 
> Probably a silly question, but when I am writing php scripts 
> (specifically large classes), I tend to write just as many comments as 
> lines of code (for my own reference).
> 
> Does this affect _execution performance_ of the scripts at all i.e. are 
> they precompiled/interpreted and cached without comments or interpreted 
> on every execution?
> 
> I am using PHP 5.0.3 on Apache on Windows.
> 
> Many Thanks,
> 
> Chris Smith
> Ninja Labs
> http://www.ninjalabs.co.uk/
-- 
Regards,
Matthew Fonda
http://mfonda.info

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



[PHP] cache engine

2005-03-05 Thread Evert - Rooftop Solutions
Hi people,
I have written an extensive web application frameworks, and I keep 
seeing my execution time and memory-usage growing. Right now it is not a 
problem, but before it get's out of hands I will need to create a good 
cache engine.
My cache engine requires that I can cache method results, based on 
multiple parameters. What would be a good way to implement this? I know 
this propably a well-formed question, but before I start, I want to be 
sure I'll do it the right way. Has anyone got any experience with this, 
or can anyone give me some pointers on where to start looking?

thanks in forward,
Evert
--
Rooftop Solutions - Web Applications on Demand
tel. (+31)628962319 fax. (+31)842242474
http://www.rooftopsolutions.nl
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Comments and performance

2005-03-05 Thread Chris Smith
Hi,
Probably a silly question, but when I am writing php scripts 
(specifically large classes), I tend to write just as many comments as 
lines of code (for my own reference).

Does this affect _execution performance_ of the scripts at all i.e. are 
they precompiled/interpreted and cached without comments or interpreted 
on every execution?

I am using PHP 5.0.3 on Apache on Windows.
Many Thanks,
Chris Smith
Ninja Labs
http://www.ninjalabs.co.uk/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] stream_set_timeout & get_headers (PHP5)

2005-03-05 Thread Chris
I'm requesting some remote files to cache on my own server and performing  
a get_headers() first to find out the file type, since I don't always know  
what it is.  I've discovered some timeout problems with the remote server  
sometimes and my own script would end up with a fatal error because the  
script took longer to process than 30 seconds.  Being able to set a  
timeout would allow me to gracefully recover, rather than displaying an  
ugly error.

I know I can use stream_set_timeout() on fsockopen() if I want to write my  
own get_headers function for < PHP5... but is it possible to set the  
timeout on PHP5's built in get_headers()?

--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: How can i calculate total process time?

2005-03-05 Thread M. Sokolewicz
JoShQuNe wrote:
Hi, i wanna ask if anybody knows how to calculate the total process time. I 
guess there exists a
function to perform but i dont know which one it is. I mean if u c any PHP Nuke 
site, it says this
page is produced in  seconds. I made some codes it calculates but i dont 
believe that it is
equal to total process time.. Thanx..
__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
fetch the microtime() at the top of the script, and at the bottom of the 
script you fetch it again. Subtract the first from the later, and you're 
left with the time it took. Then change it to a human-readable form, and 
you're done. You can't get closer without hacking the ZE

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


[PHP] How can i calculate total process time?

2005-03-05 Thread JoShQuNe \(TR\)
Hi, i wanna ask if anybody knows how to calculate the total process time. I 
guess there exists a
function to perform but i dont know which one it is. I mean if u c any PHP Nuke 
site, it says this
page is produced in  seconds. I made some codes it calculates but i dont 
believe that it is
equal to total process time.. Thanx..

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



[PHP] Re: Database engine in PHP

2005-03-05 Thread Gerben
Thanks Manuel. That's excactly what I was looking for. This will save me a 
lot of time.
Thanks a lot.

greeting Gerben

"Manuel Lemos" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hello,
>
>
> on 03/04/2005 03:45 PM Gerben said the following:
>> I was wondering if there is any DBMS, like MySQL, which is (fully) 
>> implemented
>> in php. That is a database engine written in PHP.
>> I know this is not the most effecient way, but I'm not planning to use it
>> for heavy weight database-driven-application.
>
> Yes, you may want to take a look at this flat file database manager class 
> that even supports SQL, which seems to be exactly what you are looking 
> for:
>
> http://www.phpclasses.org/pdb
>
>
> -- 
>
> Regards,
> Manuel Lemos
>
> PHP Classes - Free ready to use OOP components written in PHP
> http://www.phpclasses.org/
>
> PHP Reviews - Reviews of PHP books and other products
> http://www.phpclasses.org/reviews/
>
> Metastorage - Data object relational mapping layer generator
> http://www.meta-language.net/metastorage.html 

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



Re: [PHP] swaping mysql table values

2005-03-05 Thread Jochem Maas
Dave Carrera wrote:
Hi List,
I have a table like the diag below:
ID Name Pos
1  jig  1
2  pig  2
3  dig  3
4  fig  4
What i am trying to do is upon click to change pos 1 to pos 2 and pos 2 
to pos 1so that i can manage the position i show my list.

Can someone throw me some nuggets of logic wisdom as my searchs are 
coming up blank.
here is a description of a simple ordering mechanism, hope it gives you
an idea how to proceed:
1. output a table that reflects the current order.
   each row should have (at least) 2 links: 'move up' & 'move down',
   the links should have GET params for the direction you want to the
   position to change to and the id of the item whose position you want to
   change.
2. if a user clicks on one of those links do the following processing:
   MOVE DOWN:
1. determine the selected items current 'position'
2. find the item whose 'position' is the next greatest (value) after
   the selected items 'position'
3. if an item with greater 'position' is found then do:
a, update selected items position with position value of item 
found
   in step 2
b, update the 'position' of the item found in step 2 with the 
'position'
   value of the selected item.
   MOVE UP:
1. determine the selected items current 'position'
2. find the item whose 'position' is the next lowest (value) after
   the selected items 'position'
3. if an item with lesser 'position' is found then do:
a, update selected items position with position value of item 
found
   in step 2
b, update the 'position' of the item found in step 2 with the 
'position'
   value of the selected item.
3. go back to step 1. (output a table!)
Thanks you in advance
Dave C
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] swaping mysql table values

2005-03-05 Thread Dave Carrera
Hi List,
I have a table like the diag below:
ID Name Pos
1  jig  1
2  pig  2
3  dig  3
4  fig  4
What i am trying to do is upon click to change pos 1 to pos 2 and pos 2 
to pos 1so that i can manage the position i show my list.

Can someone throw me some nuggets of logic wisdom as my searchs are 
coming up blank.

Thanks you in advance
Dave C
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php