How does PHP play with Zope? We have a lot of PHP pages that we would have to convert if we moved over to Zope. Thanks Allen May MCSi Web Admin 800.842.1702 x7628
On Friday, December 28, 2001, at 02:22 , Allen May wrote:
How does PHP play with Zope? We have a lot of PHP pages that we would have to convert if we moved over to Zope.
You could use some Apache RewriteRules to allow for part of your site to use PHP. Just make sure that it gets hit before any Zope defaults. I use Apache + VirtualHostMonster + mod_rewrite. Sorta like this: <IfModule mod_rewrite.c> RewriteEngine On RewriteLog "logs/www.yourdomain.com-rewrite_log" RewriteLogLevel 1 RewriteRule ^/php-stuff/ - [L] RewriteRule ^(.*) http://www.yourdomain.com:8080/VirtualHostBase/http/www.yourdomain.com:80/ yourdomain/VirtualHostRoot/$1 [P] </IfModule> Zachery Bir <zbir@urbanape.com> <URL:http://www.urbanape.com/>
-> You could use some Apache RewriteRules to allow for part of your -> site to use PHP. There is also a Zope Product that allows you to add PHP pages to your Zope site. However, I think it uses PHP as a command-line interpreter instead of a loaded 'module' (I'm not certain), so check into it. The Apache rewriting may be the better performing solution. --Derek
There is also a Zope Product that allows you to add PHP pages to your Zope site. However, I think it uses PHP as a command-line interpreter instead of a loaded 'module' (I'm not certain), so check into
Yes, that's correct. PHPDocument uses PHP as a command line, so there may be some limitations, and also some performance impact, but advantages (sharing variables without passing through internet with GET/POST) are huge. -- Milos Prudek
Milos Prudek wrote:
There is also a Zope Product that allows you to add PHP pages to your Zope site. However, I think it uses PHP as a command-line interpreter instead of a loaded 'module' (I'm not certain), so check into
Yes, that's correct. PHPDocument uses PHP as a command line, so there may be some limitations, and also some performance impact, but advantages (sharing variables without passing through internet with GET/POST) are huge.
Milos: You posted a question a couple weeks ago looking for a way for authenticated Zope users to access IMP without having to re-authenticate...I was sort of keeping an eye out for an answer to that, since I'd like to do either the same thing or the reverse (have an authenticated IMP user be able to access Zope (possibly management screens) without having to re-authenticate). Did this PPHPDocument product allow for that sort of thing? and if so, do you have any tips or samples you could share? Thanks Barry
You posted a question a couple weeks ago looking for a way for authenticated Zope users to access IMP without having to re-authenticate...I was sort of keeping an eye out for an answer to that, since I'd like to do either the same thing or the reverse (have an authenticated IMP user be able to access Zope (possibly management screens) without having to re-authenticate).
Did this PPHPDocument product allow for that sort of thing? and if so, do you have any tips or samples you could share?
I did not finish that job yet. When I do (within two weeks), I'll post here. -- Milos Prudek
You posted a question a couple weeks ago looking for a way for authenticated Zope users to access IMP without having to re-authenticate...I was sort of keeping an eye out for an answer to that, since I'd like to do either the same thing or the reverse (have an authenticated IMP user be able to access Zope (possibly management screens) without having to re-authenticate).
Did this PPHPDocument product allow for that sort of thing? and if so, do you have any tips or samples you could share?
I did get quite far with PHPDocument, but not far enough. I was able to modify IMP's redirect.php to autologin. Then I made two very slight modifications to allow redirect.php to run from PHPDocument (see the source below, the lines marked as [mod for Zope]). It does not give any errors, but it also does not give any results. Just an empty page. The reason, I believe, is because redirect.php writes raw http header and that is something that PHPDocument cannot handle. I CC: this to PHPDocument author in case he would like to look at it. THE SOURCE OF redirect.php: <?php /* * $Horde: imp/redirect.php,v 1.23.2.3 2002/01/02 17:05:32 jan Exp $ * * Copyright 1999-2002 Charles J. Hagenbuch <chuck@horde.org> * Copyright 1999-2002 Jon Parise <jon@horde.org> * * See the enclosed file COPYING for license information (GPL). If you * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. */ // [mod for Zope] /* define('IMP_BASE', dirname(__FILE__)); */ define('IMP_BASE', '/home/httpd/html/horde/imp'); require_once IMP_BASE . '/lib/base.php'; $HTTP_POST_VARS['imapuser'] = 'milos'; $HTTP_POST_VARS['pass'] = 'secretsecret'; $HTTP_POST_VARS['server'] = 'localhost'; $HTTP_POST_VARS['actionID'] = '105'; $HTTP_POST_VARS['mailbox'] = 'INBOX'; $HTTP_POST_VARS['port'] = '143'; $HTTP_POST_VARS['maildomain'] = 'example.com'; $HTTP_POST_VARS['protocol'] = 'imap'; $HTTP_POST_VARS['realm'] = 'example.com'; $HTTP_POST_VARS['folders'] = 'mail%2F'; $HTTP_POST_VARS['new_lang'] = 'cz_CZ'; $HTTP_POST_VARS['button'] = 'P%F8ihl%E1%B9en%ED+do+syst%E9mu'; $action = Horde::getFormData('action', ''); if ($action === 'compose') { $actionID = LOGIN_COMPOSE; } else { $actionID = Horde::getFormData('actionID', IMP_LOGIN); } /* If we already have a session... */ if (isset($HTTP_SESSION_VARS['imp']) && is_array($HTTP_SESSION_VARS['imp'])) { /* Make sure that if a username was specified, it is the current username */ if ((!isset($HTTP_POST_VARS['imapuser']) || $HTTP_POST_VARS['imapuser'] == $HTTP_SESSION_VARS['imp']['user']) && (!isset($HTTP_POST_VARS['pass']) || $HTTP_POST_VARS['pass'] == Secret::read(Secret::getKey('imp'), $HTTP_SESSION_VARS['imp']['pass']))) { if ($actionID == IMP_LOGIN) { $actionID = NO_ACTION; } header('Location: ' . Horde::applicationUrl('mailbox.php?actionID=' . $actionID, true)); exit; } else { /* Disable the old session. */ $imp = false; session_unregister('imp'); header('Location: ' . Horde::applicationUrl(IMP::logoutUrl('login.php', 'failed'), true)); exit; } } /* Create a new session if we're given the proper parameters. */ if (isset($HTTP_POST_VARS['imapuser']) && isset($HTTP_POST_VARS['pass'])) { if (!isset($HTTP_POST_VARS['mailbox'])) { $HTTP_POST_VARS['mailbox'] = 'INBOX'; } if (($reason = IMP::createSession()) === true) { $imp['_login'] = true; // [mod for Zope] $entry = sprintf('Login success for %s [%s] to {%s:%s}', $imp['user'], '<dtml-var REMOTE_ADDR>', $imp['server'], $imp['port']); Horde::logMessage($entry, __FILE__, __LINE__, LOG_NOTICE); if (Horde::getFormData('redirect_url')) { header('Location: ' . Horde::getFormData('redirect_url')); exit; } header('Location: ' . Horde::applicationUrl('mailbox.php?actionID=' . $actionID, true)); exit; } else { header('Location: ' . Horde::applicationUrl(IMP::logoutUrl('login.php', $reason), true)); exit; } } /* No session, and no login attempt. Just go to the login page. */ $uri = 'login.php'; if (!empty($HTTP_SERVER_VARS['QUERY_STRING'])) { $uri .= '?' . $HTTP_SERVER_VARS['QUERY_STRING']; } header('Location: ' . Horde::applicationUrl($uri, true)); exit; ?> <dtml-var standard_html_footer> -- Milos Prudek
Hello Everyone! I'm sorry! Is my mistake! I extracted headers from zope document only and I let PHP to render without headers (option -q)!! Double mistake! Download version 2.3 http://www.zope.org/Members/Ioan/PHPObject/ and tell me if is working! Yours, Ioan. --- Milos Prudek <milos.prudek@tiscali.cz> wrote:
You posted a question a couple weeks ago looking for a way for authenticated Zope users to access IMP without having to re-authenticate...I was sort of keeping an eye out for an answer to that, since I'd like to do either the same thing or the reverse (have an authenticated IMP user be able to access Zope (possibly management screens) without having to re-authenticate).
Did this PPHPDocument product allow for that sort of thing? and if so, do you have any tips or samples you could share?
I did get quite far with PHPDocument, but not far enough.
I was able to modify IMP's redirect.php to autologin. Then I made two very slight modifications to allow redirect.php to run from PHPDocument (see the source below, the lines marked as [mod for Zope]). It does not give any errors, but it also does not give any results. Just an empty page.
The reason, I believe, is because redirect.php writes raw http header and that is something that PHPDocument cannot handle.
I CC: this to PHPDocument author in case he would like to look at it.
THE SOURCE OF redirect.php:
<?php /* * $Horde: imp/redirect.php,v 1.23.2.3 2002/01/02 17:05:32 jan Exp $ * * Copyright 1999-2002 Charles J. Hagenbuch <chuck@horde.org> * Copyright 1999-2002 Jon Parise <jon@horde.org> * * See the enclosed file COPYING for license information (GPL). If you * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. */
// [mod for Zope] /* define('IMP_BASE', dirname(__FILE__)); */ define('IMP_BASE', '/home/httpd/html/horde/imp');
require_once IMP_BASE . '/lib/base.php';
$HTTP_POST_VARS['imapuser'] = 'milos'; $HTTP_POST_VARS['pass'] = 'secretsecret'; $HTTP_POST_VARS['server'] = 'localhost'; $HTTP_POST_VARS['actionID'] = '105'; $HTTP_POST_VARS['mailbox'] = 'INBOX'; $HTTP_POST_VARS['port'] = '143'; $HTTP_POST_VARS['maildomain'] = 'example.com'; $HTTP_POST_VARS['protocol'] = 'imap'; $HTTP_POST_VARS['realm'] = 'example.com'; $HTTP_POST_VARS['folders'] = 'mail%2F'; $HTTP_POST_VARS['new_lang'] = 'cz_CZ'; $HTTP_POST_VARS['button'] = 'P%F8ihl%E1%B9en%ED+do+syst%E9mu';
$action = Horde::getFormData('action', ''); if ($action === 'compose') { $actionID = LOGIN_COMPOSE; } else { $actionID = Horde::getFormData('actionID', IMP_LOGIN); }
/* If we already have a session... */ if (isset($HTTP_SESSION_VARS['imp']) && is_array($HTTP_SESSION_VARS['imp'])) { /* Make sure that if a username was specified, it is the current username */ if ((!isset($HTTP_POST_VARS['imapuser']) || $HTTP_POST_VARS['imapuser'] == $HTTP_SESSION_VARS['imp']['user']) && (!isset($HTTP_POST_VARS['pass']) || $HTTP_POST_VARS['pass'] == Secret::read(Secret::getKey('imp'), $HTTP_SESSION_VARS['imp']['pass']))) {
if ($actionID == IMP_LOGIN) { $actionID = NO_ACTION; } header('Location: ' . Horde::applicationUrl('mailbox.php?actionID=' . $actionID, true)); exit; } else { /* Disable the old session. */ $imp = false; session_unregister('imp'); header('Location: ' . Horde::applicationUrl(IMP::logoutUrl('login.php', 'failed'), true)); exit; } }
/* Create a new session if we're given the proper parameters. */ if (isset($HTTP_POST_VARS['imapuser']) && isset($HTTP_POST_VARS['pass'])) { if (!isset($HTTP_POST_VARS['mailbox'])) { $HTTP_POST_VARS['mailbox'] = 'INBOX'; } if (($reason = IMP::createSession()) === true) { $imp['_login'] = true;
// [mod for Zope] $entry = sprintf('Login success for %s [%s] to {%s:%s}', $imp['user'], '<dtml-var REMOTE_ADDR>', $imp['server'], $imp['port']); Horde::logMessage($entry, __FILE__, __LINE__, LOG_NOTICE);
if (Horde::getFormData('redirect_url')) { header('Location: ' . Horde::getFormData('redirect_url')); exit; }
header('Location: ' . Horde::applicationUrl('mailbox.php?actionID=' . $actionID, true)); exit; } else { header('Location: ' . Horde::applicationUrl(IMP::logoutUrl('login.php', $reason), true)); exit; } }
/* No session, and no login attempt. Just go to the login page. */ $uri = 'login.php'; if (!empty($HTTP_SERVER_VARS['QUERY_STRING'])) { $uri .= '?' . $HTTP_SERVER_VARS['QUERY_STRING']; } header('Location: ' . Horde::applicationUrl($uri, true)); exit;
?>
<dtml-var standard_html_footer>
-- Milos Prudek
__________________________________________________ Do You Yahoo!? Send FREE video emails in Yahoo! Mail! http://promo.yahoo.com/videomail/
Ioan Coman wrote:
Hello Everyone!
I'm sorry! Is my mistake!
I extracted headers from zope document only and I let PHP to render without headers (option -q)!! Double mistake!
Great response time! Here are my results: My source gives now the following error: X-Powered-By: PHP/4.0.6 Content-type: text/html Warning: Cannot add header information - headers already sent by (output started at /tmp/1010602169_14.txt:8) in /tmp/1010602169_14.txt on line 79 I quote the "/tmp/1010602169_14.txt" file at the end of this message. Line 79 is this one: header('Location: ' . Horde::applicationUrl('mailbox.php?actionID=' . $actionID, true)); The "/tmp/1010602169_14.txt" file: <html><head><title>3</title> <meta http-equiv="Content-Type" content="text/html; charset=windows-1250"> <link rel="stylesheet" href="normal.html" type="text/css"> </head> <body bgcolor="#FFFFFF" text="#000000"> <?php /* * $Horde: imp/redirect.php,v 1.23.2.3 2002/01/02 17:05:32 jan Exp $ * * Copyright 1999-2002 Charles J. Hagenbuch <chuck@horde.org> * Copyright 1999-2002 Jon Parise <jon@horde.org> * * See the enclosed file COPYING for license information (GPL). If you * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. */ /* define('IMP_BASE', dirname(__FILE__)); */ define('IMP_BASE', '/home/httpd/html/horde/imp'); require_once IMP_BASE . '/lib/base.php'; $HTTP_POST_VARS['imapuser'] = 'milos'; $HTTP_POST_VARS['pass'] = 'secret'; $HTTP_POST_VARS['server'] = 'localhost'; $HTTP_POST_VARS['actionID'] = '105'; $HTTP_POST_VARS['mailbox'] = 'INBOX'; $HTTP_POST_VARS['port'] = '143'; $HTTP_POST_VARS['maildomain'] = 'orl.cz'; $HTTP_POST_VARS['protocol'] = 'imap'; $HTTP_POST_VARS['realm'] = 'orl.cz'; $HTTP_POST_VARS['folders'] = 'mail%2F'; $HTTP_POST_VARS['new_lang'] = 'cz_CZ'; $HTTP_POST_VARS['button'] = 'P%F8ihl%E1%B9en%ED+do+syst%E9mu'; $action = Horde::getFormData('action', ''); if ($action === 'compose') { $actionID = LOGIN_COMPOSE; } else { $actionID = Horde::getFormData('actionID', IMP_LOGIN); } /* If we already have a session... */ if (isset($HTTP_SESSION_VARS['imp']) && is_array($HTTP_SESSION_VARS['imp'])) { /* Make sure that if a username was specified, it is the current username */ if ((!isset($HTTP_POST_VARS['imapuser']) || $HTTP_POST_VARS['imapuser'] == $HTTP_SESSION_VARS['imp']['user']) && (!isset($HTTP_POST_VARS['pass']) || $HTTP_POST_VARS['pass'] == Secret::read(Secret::getKey('imp'), $HTTP_SESSION_VARS['imp']['pass']))) { if ($actionID == IMP_LOGIN) { $actionID = NO_ACTION; } header('Location: ' . Horde::applicationUrl('mailbox.php?actionID=' . $actionID, true)); exit; } else { /* Disable the old session. */ $imp = false; session_unregister('imp'); header('Location: ' . Horde::applicationUrl(IMP::logoutUrl('login.php', 'failed'), true)); exit; } } /* Create a new session if we're given the proper parameters. */ if (isset($HTTP_POST_VARS['imapuser']) && isset($HTTP_POST_VARS['pass'])) { if (!isset($HTTP_POST_VARS['mailbox'])) { $HTTP_POST_VARS['mailbox'] = 'INBOX'; } if (($reason = IMP::createSession()) === true) { $imp['_login'] = true; $entry = sprintf('Login success for %s [%s] to {%s:%s}', $imp['user'], '127.0.0.1', $imp['server'], $imp['port']); Horde::logMessage($entry, __FILE__, __LINE__, LOG_NOTICE); if (Horde::getFormData('redirect_url')) { header('Location: ' . Horde::getFormData('redirect_url')); exit; } header('Location: ' . Horde::applicationUrl('mailbox.php?actionID=' . $actionID, true)); exit; } else { header('Location: ' . Horde::applicationUrl(IMP::logoutUrl('login.php', $reason), true)); exit; } } /* No session, and no login attempt. Just go to the login page. */ $uri = 'login.php'; if (!empty($HTTP_SERVER_VARS['QUERY_STRING'])) { $uri .= '?' . $HTTP_SERVER_VARS['QUERY_STRING']; } header('Location: ' . Horde::applicationUrl($uri, true)); exit; ?> <hr> <p><b>WELCOME BACK, mil</b></p> <p> <h3>form</h3><table></table><h3>cookies</h3><table><tr valign="top" align="left"><th>tree-s</th><td>'eJzTiFZ3hANPW/VYHU0ALlYElA'</td></tr></table><h3>other</h3><table><tr valign="top" align="left"><th>AUTHENTICATION_PATH</th><td>''</td></tr><tr valign="top" align="left"><th>TraversalRequestNameStack</th><td>[]</td></tr><tr valign="top" align="left"><th>tree-s</th><td>'eJzTiFZ3hANPW/VYHU0ALlYElA'</td></tr><tr valign="top" align="left"><th>URL</th><td>'http://localhost:8080/test/php/3'</td></tr><tr valign="top" align="left"><th>PUBLISHED</th><td><PHPDocument instance at 89d7d30></td></tr><tr valign="top" align="left"><th>SERVER_URL</th><td>'http://localhost:8080'</td></tr><tr valign="top" align="left"><th>AUTHENTICATED_USER</th><td>mil</td></tr><tr valign="top" align="left"><th>URL0</th><td>http://localhost:8080/test/php/3</td></tr><tr valign="top" align="left"><th>URL1</th><td>http://localhost:8080/test/php</td></tr><tr valign="top" align="left"><th>URL2</th><td>http://localhost:8080/test</td></tr><tr valign="top" align="left"><th>URL3</th><td>http://localhost:8080</td></tr><tr valign="top" align="left"><th>BASE0</th><td>http://localhost:8080</td></tr><tr valign="top" align="left"><th>BASE1</th><td>http://localhost:8080</td></tr><tr valign="top" align="left"><th>BASE2</th><td>http://localhost:8080/test</td></tr><tr valign="top" align="left"><th>BASE3</th><td>http://localhost:8080/test/php</td></tr><tr valign="top" align="left"><th>BASE4</th><td>http://localhost:8080/test/php/3</td></tr></table><h3>environ</h3><table><tr valign="top" align="left"><th>HTTP_ACCEPT_ENCODING</th><td>'gzip'</td></tr><tr valign="top" align="left"><th>channel.creation_time</th><td>1010602133</td></tr><tr valign="top" align="left"><th>SERVER_PROTOCOL</th><td>'HTTP/1.0'</td></tr><tr valign="top" align="left"><th>SERVER_PORT</th><td>'8080'</td></tr><tr valign="top" align="left"><th>PATH_INFO</th><td>'/test/php/3'</td></tr><tr valign="top" align="left"><th>HTTP_HOST</th><td>'localhost:8080'</td></tr><tr valign="top" align="left"><th>REQUEST_METHOD</th><td>'GET'</td></tr><tr valign="top" align="left"><th>PATH_TRANSLATED</th><td>'/test/php/3'</td></tr><tr valign="top" align="left"><th>CONNECTION_TYPE</th><td>'Keep-Alive'</td></tr><tr valign="top" align="left"><th>SCRIPT_NAME</th><td>''</td></tr><tr valign="top" align="left"><th>SERVER_SOFTWARE</th><td>'Zope/(Zope 2.4.3 (source release, python 2.1, linux2), python 2.1.1, linux2) ZServer/1.1b1'</td></tr><tr valign="top" align="left"><th>HTTP_ACCEPT_LANGUAGE</th><td>'en'</td></tr><tr valign="top" align="left"><th>HTTP_ACCEPT_CHARSET</th><td>'iso-8859-1,*,utf-8'</td></tr><tr valign="top" align="left"><th>REMOTE_ADDR</th><td>'127.0.0.1'</td></tr><tr valign="top" align="left"><th>HTTP_COOKIE</th><td>'tree-s="eJzTiFZ3hANPW/VYHU0ALlYElA"'</td></tr><tr valign="top" align="left"><th>SERVER_NAME</th><td>'ns'</td></tr><tr valign="top" align="left"><th>GATEWAY_INTERFACE</th><td>'CGI/1.1'</td></tr><tr valign="top" align="left"><th>HTTP_USER_AGENT</th><td>'Mozilla/4.76 [en] (X11; U; Linux 2.4.10 i686)'</td></tr><tr valign="top" align="left"><th>HTTP_ACCEPT</th><td>'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*'</td></tr></table> </p> </body></html> -- Milos Prudek
Hi! I know why! It is important to use <?php header('what ever'); ?> before anything else. I'm almost sure if there is even an space, TAB or CR/LF before <?php header ... the PHP will create the header (Content type: text/html + ... ) and you can't stop it! My advice is to move <html><head><title>3</title>... down and let <?php header ... to be on top! Between <?php and rest you may put anything except echo ..... :-) I think that PHP has a bug! I know about this problem because I tested php from command line - console input! Tell me what you've done! After is working maybe you publish nocc or horde IMAP reader for Zope or something like that into Zope server as one of 'PHP applications for Zope'! Yours, Ioan. __________________________________________________ Do You Yahoo!? Send FREE video emails in Yahoo! Mail! http://promo.yahoo.com/videomail/
Allen May wrote:
How does PHP play with Zope? We have a lot of PHP pages that we would have to convert if we moved over to Zope.
You need to use PHPDocument product. This product allows running PHP source from Zope, so that Zope and PHP code is integrated, can share variables, and so on. Download it from www.zope.org -- Milos Prudek
Milos Prudek wrote: [deleted]
You need to use PHPDocument product. This product allows running PHP source from Zope, so that Zope and PHP code is integrated, can share variables, and so on.
The only bad thinkg is: Many php program include other php file, but this doesn't work on PHPDocument...
participants (7)
-
Allen May -
Barry Pederson -
Derek Simkowiak -
Ioan Coman -
Milos Prudek -
ycheng -
Zachery Bir