php-general Digest 3 Dec 2005 10:13:25 -0000 Issue 3829
Topics (messages 226791 through 226809):
Re: Upgrading on RH ES3
226791 by: John Nichel
226804 by: Rick Emery
Re: Submit Form Values To Parent
226792 by: Matt Monaco
Determine object type
226793 by: Matt Monaco
226794 by: Ray Hauge
226795 by: Matt Monaco
Sessions, Expire-headers and Firefox's back button
226796 by: Peter Brodersen
226798 by: Chris Shiflett
226799 by: Peter Brodersen
Re: MVC platform choice.
226797 by: Brian Fioca
Why do Sessions use Cookies?
226800 by: Michael B Allen
226801 by: Peter Brodersen
226802 by: Chris Shiflett
Re: Zend Sudio's Optimizer / PHP 5.1.1
226803 by: Rick Emery
Simple Authentication Infrastructure
226805 by: Michael B Allen
Newline character problem...
226806 by: Robert
226807 by: ?ukasz Hejnak
Mail SMTP settings
226808 by: Dan
Count and Preg_Replace Using Version 4.4.1
226809 by: Shaun
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 ---
Jeff McKeon wrote:
-----Original Message-----
From: Kristen G. Thorson [mailto:[EMAIL PROTECTED]
Sent: Friday, December 02, 2005 14:50
To: Jeff McKeon
Cc: php
Subject: Re: [PHP] Upgrading on RH ES3
Jeff McKeon wrote:
I've got a server with RedHat ES3 running. It has PHP 4.3.2
installed
but for an application I want to install I need a min of
4.3.9. This
server also runs apache2.0.
I can't find RPMs for RH ES3 so I downloaded the source for PHP4.4.1
figuring I would just compile myself. Problem is, the INSTALL file
gives instructions based on the idea that you don't already have
Apache2 or an earlier ver of PHP Installed already. Since
Apache2 was
installed via RPM originally the INSTALL instruction for PHP with
Apache2 prob won't work.
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
It's the:
--with-apxs2=/usr/local/apache2/bin/apxs
Switch that has got me scratching my head.
/usr/local/apache2/ doesn't
exist and I can't find apxs anywhere on the sys.
Can I just configure with ./configure --with-mysql??
Thanks,
Jeff
I believe you need the httpd-devel rpm to get apxs2.
kgt
Interesting. Would the current ver of php run if I didn't have
httpd-devel installed? What exactly does the switch
--with-apxs2=/usr/local/apache2/bin/apxs do?
<snip>
This allows you to install php (as well as other modules) as dynamic
modules vs. as a CGI or having to recompile Apache each time you want to
upgrade something plugged into it.
</snip>
Currently PHP 4.3.2 runs find on this system.
It is either running as a CGI or was compiled in with Apache.
--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Quoting Jeff McKeon <[EMAIL PROTECTED]>:
-----Original Message-----
From: Kristen G. Thorson [mailto:[EMAIL PROTECTED]
Sent: Friday, December 02, 2005 14:50
To: Jeff McKeon
Cc: php
Subject: Re: [PHP] Upgrading on RH ES3
Jeff McKeon wrote:
>I've got a server with RedHat ES3 running. It has PHP 4.3.2
installed
>but for an application I want to install I need a min of
4.3.9. This
>server also runs apache2.0.
>
>I can't find RPMs for RH ES3 so I downloaded the source for PHP4.4.1
>figuring I would just compile myself. Problem is, the INSTALL file
>gives instructions based on the idea that you don't already have
>Apache2 or an earlier ver of PHP Installed already. Since
Apache2 was
>installed via RPM originally the INSTALL instruction for PHP with
>Apache2 prob won't work.
>
>./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
>
>It's the:
>
>--with-apxs2=/usr/local/apache2/bin/apxs
>
>Switch that has got me scratching my head.
/usr/local/apache2/ doesn't
>exist and I can't find apxs anywhere on the sys.
>
>Can I just configure with ./configure --with-mysql??
>
>Thanks,
>
>Jeff
>
>
>
I believe you need the httpd-devel rpm to get apxs2.
kgt
Interesting. Would the current ver of php run if I didn't have
httpd-devel installed? What exactly does the switch
--with-apxs2=/usr/local/apache2/bin/apxs do?
If I'm not mistaken (and I very easily could be), apxs is used to
create the php module for apache. Red Hat/Fedora provide a mod_php rpm,
and your older version may have had that rpm installed; thus, apxs (and
the httpd-devel rpm) was not needed on your system to build the module.
Rick
--
Rick Emery
"When once you have tasted flight, you will forever walk the Earth
with your eyes turned skyward, for there you have been, and there
you will always long to return"
-- Leonardo Da Vinci
--- End Message ---
--- Begin Message ---
<form .... target="_parent"> is valid just as with any other link.
""Shaun"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> How can I get the form values submitted from an iframe where the target is
> the parent window?
--- End Message ---
--- Begin Message ---
Is there a function or method to determine the class an object was defined
from?
--- End Message ---
--- Begin Message ---
That would be get_class( [obj] );
http://us3.php.net/manual/en/function.get-class.php
Matt Monaco wrote:
Is there a function or method to determine the class an object was defined
from?
--- End Message ---
--- Begin Message ---
Hah, I was looking in the object aggregation functions, that really deserved
a RTFM
"Ray Hauge" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> That would be get_class( [obj] );
>
> http://us3.php.net/manual/en/function.get-class.php
>
> Matt Monaco wrote:
>
>>Is there a function or method to determine the class an object was defined
>>from?
>>
--- End Message ---
--- Begin Message ---
Hi,
When I begin session with session_start() PHP sets an Expired-header. I
suppose that's fine for the sake of unwanted caching.
Unfortunately, Firefox seem to reload a page that's expired when using
the browser's "Back" navigation instead of showing the page as it was as
the user left it.
This seem to complicate some things. If I create a page with a form, the
user submits it and press "back", the page is reloaded and the form is
wiped instead of preserving the values as they were when the user
submitted/left the page.
I'm curious if there is a simple, acceptable workaround like disabling
the Expires-header?
I'm *not* looking for a solution where the session stores the form
values and insert them into a value attribute. This won't work:
1. There is no way to distinct whether the user pushed "back" or clicked
on a link to request the search page. The variables should be kept in
the first situation but not in the second (and looking at the Referer
header would be considered a hack as well).
2. Users can have multiple windows/tabs open which should not interfere
with the navigation.
It seems like Opera, Internet Explorer, links, lynx and w3m behave more
reasonable. I believe that W3 also states that when using back buttons
browsers should always show the page as when the user left it and not
requesting it at new.
Even if it is a bug in Firefox I would still like to know whether there
is an acceptable workaround that would reduce the number of requests and
make Firefox use the cached page (or cache the page in the first place).
--
- Peter Brodersen
--- End Message ---
--- Begin Message ---
Hi Peter,
When I begin session with session_start() PHP sets an Expired-header.
I suppose that's fine for the sake of unwanted caching.
Unfortunately, Firefox seem to reload a page that's expired when using
the browser's "Back" navigation instead of showing the page as it was
as the user left it.
You might find this article helpful:
http://shiflett.org/articles/guru-speak-nov2004
I suspect that Firefox's behavior is based on their interpretation of
the HTTP specification. If you read section 14.9.2 of RFC 2616, you'll
see the following statement about the no-store directive:
"If sent in a response, a cache MUST NOT store any part of either this
response or the request that elicited it. This directive applies to both
non-shared and shared caches."
A browser's history mechanism relies on a non-shared cache, the
browser's cache. If a browser isn't allowed to store the resource, it
can't redisplay the resource without sending another request.
There's another relevant section of the RFC, section 13.13:
"History mechanisms and caches are different. In particular history
mechanisms SHOULD NOT try to show a semantically transparent view of the
current state of a resource. Rather, a history mechanism is meant to
show exactly what the user saw at the time when the resource was retrieved."
This seems to conflict with the earlier statement, and I think this is
the reason for the inconsistent implementations in the industry. This
particular statement attempts to distinguish between the history
mechanism and caches, a distinction that doesn't naturally exist.
I don't really fault Firefox for abiding by the no-store directive, nor
do I fault Internet Explorer for ignoring it.
Hope that helps.
Chris
--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/
--- End Message ---
--- Begin Message ---
Hi Chris,
On Fri, 02 Dec 2005 19:21:43 -0500
Chris Shiflett <[EMAIL PROTECTED]> wrote:
> You might find this article helpful:
>
> http://shiflett.org/articles/guru-speak-nov2004
Very helpful indeed! I was mainly focused on the "Expires" header, but
changing the Cache-Control output (by setting session.cache_limiter to
'private') seem to make everything work.
private_no_expire could also be a possibility. I think I'll read the RFC
a bit more to see which one would be the most appropate one in my
situation.
> This seems to conflict with the earlier statement, and I think this is
> the reason for the inconsistent implementations in the industry. This
> particular statement attempts to distinguish between the history
> mechanism and caches, a distinction that doesn't naturally exist.
Tell me about it. Earlier this evening I fell over a strange behaviour in
IE, Firefox and Opera. Point one window to a URL pointing at an image.
Overwrite the image with a new one. Open another window/tab and open the
new image (at the same URL). Get properties for the old image in the old
window.
Both IE and Firefox would provide the correct information about image
dimensions but would get the file size from the new image. Opera will
replace the old image in runtime leading to spurious graphic updates.
The whole concept about the history mechanism (and even content in
current open windows) opposed to a cache is a bit mind boggling.
> I don't really fault Firefox for abiding by the no-store directive, nor
> do I fault Internet Explorer for ignoring it.
Agreed. Furthermore, the change in cache_limiter makes very good sense
in this context and doesn't seem like "just a hack".
> Hope that helps.
Very much. Thanks for the quick and precise reply!
--
- Peter Brodersen
--- End Message ---
--- Begin Message ---
WASP:
http://wasp.sourceforge.net
On Nov 30, 2005, at 2:04 AM, Gregory Machin wrote:
Hi..
Any body recomend a good MVC platform that is easy to work with,
and build
on...
I'm looking at cakephp, solar, php on trax..
Anything better out there.
--
Gregory Machin
[EMAIL PROTECTED]
[EMAIL PROTECTED]
www.linuxpro.co.za
www.exponent.co.za
Web Hosting Solutions
Scalable Linux Solutions
www.iberry.info (support and admin)
+27 72 524 8096
/**
* Brian Fioca
* Chief Scientist / Sr. Technical Consultant
* PangoMedia - http://pangomedia.com
* @work 907.868.8092x108
* @cell 907.440.6347
*/
smime.p7s
Description: S/MIME cryptographic signature
--- End Message ---
--- Begin Message ---
Why do sessions use cookies? Isn't a session just a container associated
with the user's socket?
Thanks,
Mike
--- End Message ---
--- Begin Message ---
On Fri, 2 Dec 2005 20:43:48 -0500, in php.general [EMAIL PROTECTED]
(Michael B Allen) wrote:
>Why do sessions use cookies? Isn't a session just a container associated
>with the user's socket?
No. Even though mechanisms such as keepalive exists they are not
reliable for tracking a user. A client can still open multiple HTTP
connections to the same host even when using keepalive.
Furthermore we would like the session to survive the smallest hickups
(e.g. disconnects, TCP RSTs, ...).
--
- Peter Brodersen
--- End Message ---
--- Begin Message ---
Michael B Allen wrote:
Why do sessions use cookies?
The client needs to identify itself, and cookies are a mechanism created
for exactly this purpose.
Isn't a session just a container associated with the user's socket?
I'm not sure what you mean, but I suspect the answer is no. :-)
Chris
--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/
--- End Message ---
--- Begin Message ---
Quoting Joseph Crawford <[EMAIL PROTECTED]>:
i keep getting an error that zend optimizer doesnt work with this version of
PHP, can anyone explain why that would be?
From Zend's web site:
"Supported PHP versions: 4.0.5 up through 5.0.x."
http://www.zend.com/store/products/optimizer-sysreq.php
I don't think they have a version for PHP 5.1.x yet.
--
Rick Emery
"When once you have tasted flight, you will forever walk the Earth
with your eyes turned skyward, for there you have been, and there
you will always long to return"
-- Leonardo Da Vinci
--- End Message ---
--- Begin Message ---
Hi,
I scoping out an Internet site project and my primary consideration at
the moment is authentication infrastructure. Conceptually I was thinking
about something like the pseudocode at the bottom of this message
(pardon all the Java-esc typing).
Can PHP do this sort of thing? I'm wondering if there are some classes
available to do this? I don't think I want to use WWW-Authenticate (at
least I don't want to use the ugly password dialog) and I certainly don't
want to authenticate via pam or something like that. I want "as simple
as possible, but not simpler" type of thing. I have a strong aversion
to bloatware.
Or am I off track? I normally do pretty low level C type stuff so websites
are new to me (ie. php).
Thanks,
Mike
int
handleRequest(Request req)
{
Ticket ticket, tmp;
/* If the user already has a ticket associated with their session,
* just pass through and handle the request
*/
if ((ticket = req.session.getProperty("ticket")) == null) {
SqlResults results;
/* If the user has a ticket (embeeded in a cookie) then associate
* it with their session and pass through and handle the request.
*/
String cookie = req.getCookie("ticket");
if (cookie) { /* try ticket from cookie */
tmp = Ticket.decrypt("12345", cookie);
results = Sql.exec( /* sql injection vulnerbility, wahoo! */
"select ssnkey from accounts where emailaddr = " + tmp.emailaddr);
if (results.size() == 1 && tmp.sshkey == results.getInteger(0)) {
req.session.setProperty("ticket", tmp);
ticket = tmp; /* Success! */
}
}
if (ticket == null && req.session.isHttps) { /* try new login */
String emailaddr = req.getParameter("emailaddr");
String password = req.getParameter("password");
if (emailaddr && password) {
results = Sql.exec(
"select status, password from accounts where emailaddr = " +
emailaddr);
if (results.size() != 1 ||
results.getString(0) != "valid" ||
password != results.getString(1)) {
return sendError(req, ERROR_AUTH_FAILED);
}
tmp = new Ticket(emailaddr);
Sql.exec("update accounts set ssnkey = " + tmp.ssnkey +
" where emailaddr = " + tmp.emailaddr);
req.setCookie("ticket", ticket.encrypt("12345"));
req.session.setProperty("ticket", tmp);
ticket = tmp; /* Success! */
}
}
}
/* null ticket means not logged in / anonymous
*/
return handleAuthenticatedRequest(req, ticket);
}
--- End Message ---
--- Begin Message ---
I'm new to PHP but not programming in general. I have used C++ for a while
and I'm familiar with the newline character as it's basically the same in
PHP. Whenever I print something with a newline character in it all it
produces is a space between whatever two things I'm printing. I'm running
php 5.1.1 running on FreeBSD 6 with apache 2.2.0. All the latest versions
installed today.
This is the most basic of examples:
print 'one' ;
print "\n" ;
print 'two' ;
The output of this when accessed on my server is: one two
It should be: one
two
I've tried using printf as well but to no avail. It just adds a space
between the outputs. I've also tried using different browsers but still get
the same result. What am I doing wrong? Could this a php configuration
issue? Apache maybe?
Thanks,
Rob
--- End Message ---
--- Begin Message ---
Robert napisal(a):
I'm new to PHP but not programming in general. I have used C++ for a while
and I'm familiar with the newline character as it's basically the same in
PHP.
This is the most basic of examples:
print 'one' ;
print "\n" ;
print 'two' ;
The output of this when accessed on my server is: one two
It should be: one
two
Hi
well this isn't apache or php related, as it's webbrowser related, and
even more, it's correct.
The thing is, what You see in Your browser is an interpreted version of
the html outputed by the php (obvious?), so if You do a html file, and put:
one
two
in there, and view it with Your browser, it will still look like this:
one two
to get the expected (as in C/C++) result, You need to add a <br> or any
other line breaking method in there (<p>one</p><p>two</p> is another one)
Now, if You'd see the generated source code, You'd notice that there is
in fact the line break as it should be :)
so it is good to use '\n' to get the output code clear to read, for
debugging and so..
Best wishes
?ukasz Hejnak
--- End Message ---
--- Begin Message ---
I have a PHP 4.x install on an Apache server. I have a PHP
application and a call to the mail function. I have 2 static IP's on
the server and I have one web server and one instance of postfix for
each IP to basically separate the two sites. The only issue I have
right now is sending mail via PHP.
I have tried to set the SMTP server and reply address via a php_value
in my httpd.conf file and via the ini_set function for my site in
question. Regardless of these setting mail is sent from the www user
at my main site domain:
Return-Path: <[EMAIL PROTECTED]>
Received: from mail.wavefront.ca ([unix socket])
by mail.wavefront.ca (Cyrus v2.2.12-OS X 10.4.0) with LMTPA;
Fri, 02 Dec 2005 12:45:07 -0700
I've also tried the IMAP functions but also with no success. I
basically want the mail to look as though it was from the other domain.
Dan T
--- End Message ---
--- Begin Message ---
Hi,
The following code matches all occurences of <p> tags within an html page
and wraps form tags around it:
echo preg_replace(
'/<p[^>]*>(.*?)<\/p>/ms',
'<form name="form" target="_parent"
action="'.$CFG->edit_pages_adm.'/index.php?action=edit_paragraph"
method="post">
<input type="hidden" name="text" value="$1">
<p><a href="javascript:;" onclick="document.form.submit();">$1</a></p>
</form>',
file_get_contents($CFG->frontenddir_editable.'/'.$file) );
Unfortunately if there is more than one match the form won't submit because
the forms have the same name. Does anyone know how can I modify this so that
each occurence is numbered sequentially i.e.
form'.$count.'...
As I am using version 4.4.1 I don't have access to the count paramter in
version 5.1.
Thanks for your advice
--- End Message ---