Re: [PHP] Image copying

2005-01-06 Thread Jason Wong
On Thursday 06 January 2005 14:24, Liam Gibbs wrote:

 What I'm trying to do is copy one JPEG to another JPEG (as mentioned) on
 the fly. I don't want to have a new file produced, just a modified JPEG (a
 few circles here and there) held in a resource. Here's how I call my
 function and how I display the image via HTML:

 print(IMG ALT... HEIGHT... WIDTH... SRC = \ . copy_pic($sourcepic) .
 \);

 So I'm calling the function straight from the SRC attribute of the IMG tag.

SRC is supposed to be a URL ...

 Here's what's in my function:

 function copy_pic($sourcepic) {
if(file_exists($sourcepic)) {
   $destinationpic = imagecreatetruecolor(imagesx($sourcepic),
 imagesy($sourcepic)); imagecopy($destinationpic, $sourcepic, 0, 0, 0, 0,
 imagesx($sourcepic), imagesy($sourcepic)); }

return $destinationpic;
 }

... but you're giving it an image resource!

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



Re: [PHP] Weird search and replace

2005-01-06 Thread Jason Wong
On Thursday 06 January 2005 14:24, Liam Gibbs wrote:

Please fix your mail client so that in word wraps properly!

 Here's what I need. I have a string such as this:

 Yadda yadda yadda yadda '32'(l) yadda yadda yadda '2'(l) yadda '419'(l).
 (#2)

 I need to find the strings like '32'(l), '2'(l), and '419'(l), including
 the single quotes. Basically a '[0-9]*'(l). This is #1.

 Take that string, look up a record in an SQL table based on the number in
 the single quotes. Take a field in the record (#3) and replace #1 with it.
 So basically, we have:

 Yadda yadda yadda yadda supplanted-string yadda yadda yadda
 supplanted-string yadda supplanted-string. (#2)

It seems preg_replace_callback() would be ideal for this job.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



Re: [PHP] endless while loop

2005-01-06 Thread Jason Wong
On Thursday 06 January 2005 05:17, Gunter Sammet wrote:

 I am having some trouble getting the following code to work:

 if (is_array($bundle_attributes)) {

 reset($bundle_attributes);

 while (list($option, $value) = each($bundle_attributes)) {

 reset($value);

 while (list($option2, $value2) = each($value)) {

 $this-contents[$products_id]['attributes'][$option] = $value;

 if (tep_session_is_registered('customer_id')) tep_db_query(insert into  .
 TABLE_CUSTOMERS_BASKET_BUNDLE_ATTRIBUTES .  (customers_id, products_id,
 sub_product_id, products_options_id, products_options_value_id) values ('
 . (int)$customer_id . ', ' . tep_db_input($products_id) . ', ' .
 $option . ', ' . (int)$option2 . ', ' . (int)$value2 . '));

 }

 }

 }

 }

 It gives me an endless loop in the second while loop. It seems like it
 doesn't move the pointer to the next value in the $option array. 

But isn't the next value of $option controlled by the outer while-loop?

 When I do 
 a print in that loop, I am getting the key value pair for the first element
 in the $option array. 

So inside the inner while-loop, $option should never change.

 Changing it to a for loop works. Any ideas why this 
 happens?

No. But I can tell you that:

1) the reset() aren't necessary
2) even better, use a foreach-loop instead of while-loop

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



[PHP] Removing all tr tag

2005-01-06 Thread Binoy AV
Hi,
  I have an html file containing a table. I applied
  eregi(TR.*/TR,$contents,$temp) through my Php.I am getting 
  the output like this-
   tdA/tdtdB/td/tr
   trtdC/tdtdD/td/tr 
   trtdE/tdtdF/td 
But my expected output is -
 tdA/tdtdB/td
 tdC/tdtdD/td
 tdE/tdtdF/td 
 The code removing only the first and last (/)tr.
How to do it using eregi ? (or using any other regular expression function. I 
don't want to use any string replace function.)

Binav

 

 
__ __ __ __
Sent via the WebMail system at softwareassociates.co.uk


 
   
---
Scanned by MessageExchange.net (10:05:41 SPITFIRE)

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



RE: [PHP] multiple deleting and updating raw mysql via php

2005-01-06 Thread Sejati Opreker
 [snip]
 I meet a problem when I want to deleting a multiple
 row, I have a table that contain columns UserID,
 name,
 company name, and bill. UserID is uniq.
 perhaps, some of UserID, say it five UserID I have
 to
 delete, how to delete all raw that contain that
 UserID
 ? and if I want to update bill of a users (multiple
 user) that data of users taking from a file ( so the
 file contain user UserId and bill), how to make it ?


I', sorry if my previous email not that clear, I'm
making a simple web-base inventory using PHP, and I
don't know how to using a web form to :
1. delete multiple raw by input an uniqID (in this
case UserID, say there was five users)
2. after deleting it, there will be say six users need
to add.
3. and I make delete or add by uploading file that
contain data I need ?

And all I hope can do by a web-base application using
PHP

sorry If I can't make it clear in my previos posting

Aji



__ 
Do you Yahoo!? 
All your favorites on one personal page – Try My Yahoo!
http://my.yahoo.com 

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



Re: [PHP] Removing all tr tag

2005-01-06 Thread Christophe Chisogne
Binoy AV a écrit :
Hi,
  I have an html file containing a table. I applied
  eregi(TR.*/TR,$contents,$temp) through my Php.I am getting 
 (...)
 The code removing only the first and last (/)tr.
Expected behaviour : regex are 'greedy', ie
the .* matches the longuest string possible
How to do it using eregi ? 
Use preg_* functions (Perl regex are more powerfull and faster)
ex (not tested)
$temp = preg_replace('/tr(.*?)\\/tr/', '$1', $content);
PS the '?' in '.*?' means previous modifier (*) is not greedy
   (Perl re syntax, man perlre)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[suspicious - maybe spam] [PHP] [suspicious - maybe spam] SELECT probrem

2005-01-06 Thread Phpu
Hi,

I have an array, for ex: $products=array(1, 2,  5 , 7)

I want to select all products from the database that has the ids of products.
I use this but doesn't work:

$sql = '';
foreach($products AS $products_id){
if(strlen($sql)){ $sql .= ' OR '; }
$sql .= product_id = '$products_id';
}
  
$sql2 = SELECT product_name FROM accessories WHERE  .$sql;

Please help me 

Thanks


[PHP] Re: [suspicious - maybe spam] [PHP] [suspicious - maybe spam] SELECT probrem

2005-01-06 Thread Richard Davey
Hello Phpu,

Thursday, January 6, 2005, 10:42:15 AM, you wrote:

P I have an array, for ex: $products=array(1, 2,  5 , 7)
P I want to select all products from the database that has the ids of products.
P I use this but doesn't work:

$product_ids = implode(',', $products);
$sql = SELECT product_name FROM accessories WHERE product_id IN 
($product_ids);

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 I am not young enough to know everything. - Oscar Wilde

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



[PHP] Form to email with Special Characters

2005-01-06 Thread Hugo Tavares
Hello:

I'm new (very new) to php.

I'm making a simple srcipt wich sends and email from a form.

My problem is tha special characters like ç,á,à,é, etc don't work.

Can anyone help me?

Thanks 

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



[PHP] Re: Form to email with Special Characters

2005-01-06 Thread Bogomil Shopov
Hello Can you show me the script?
Please look first at mail functions on php.net/mail to see how to use
headers (and encodings too)

Best Regards
Bogomil Shopov
http://purplerain.org

Hugo Tavares wrote:
 Hello:
 
 I'm new (very new) to php.
 
 I'm making a simple srcipt wich sends and email from a form.
 
 My problem is tha special characters like  etc don't work.
 
 Can anyone help me?
 
 Thanks 

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



[PHP] Re: Form to email with Special Characters

2005-01-06 Thread Hugo Tavares
Here it is:

 $headers = From: $name $email\r\n;
 $headers .= Reply-to: $email\r\n;
 $headers .= Return-Path: $email\r\n;
 $headers .= MIME-Version: 1.0\r\n;
 $headers .= Content-Type: multipart/alternative; charset=\iso-8859-1\; 
boundary=\$mime_boundary\;\r\n\r\n;
 $headers .= This is a multi-part message in MIME format.\r\n\r\n;
 $msg .= --$mime_boundary\r\n;
 $msg .= Content-Type: text/plain; charset=\iso-8859-1\\r\n; // deleted 
boundary
 $msg .= Content-Transfer-Encoding: 8bit\r\n\r\n;
 $msg .= $text_version.\r\n\r\n;
 $msg .= --$mime_boundary\r\n;
 $msg .= Content-Type: text/html; charset=\iso-8859-1\\r\n;
 $msg .= Content-Transfer-Encoding: 8bit\r\n\r\n;
 $msg .= $message.\r\n\r\n;
 $msg .= --$mime_boundary--\r\n\r\n\r\n;
 mail($recipient, $subject, $msg, $headers);

Thanks for the help!


Bogomil Shopov [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hello Can you show me the script?
 Please look first at mail functions on php.net/mail to see how to use
 headers (and encodings too)

 Best Regards
 Bogomil Shopov
 http://purplerain.org

 Hugo Tavares wrote:
 Hello:

 I'm new (very new) to php.

 I'm making a simple srcipt wich sends and email from a form.

 My problem is tha special characters like ç,á,à,é, etc don't work.

 Can anyone help me?

 Thanks 

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



[PHP] Regexp help second

2005-01-06 Thread Uro Gruber
Hi!
Last help about regexp solve my problem, but I have another one.
I've made some regexp but it does not work always
Let say I have some strings
1) this is some domain.com test
2) domain.com
I can make this work either for first example of fo second, but not for 
both. What I want is replace of domain.com to get

this is dome domain.com domain com test so replace should be
\1 \2 \3
so for second example I did /((.+)\.{1}(.+))/
How can I extend this to work in both.
regards
Uros
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Setting Up PHP

2005-01-06 Thread Mike Smith
You'll need to modify your httpd.conf. Depending on you OS/Apache
version it will be different.

For Windows/Apache1.3.x:
http://us2.php.net/manual/en/install.windows.apache1.php

For Windows/Apache2.x:
http://us2.php.net/manual/en/install.windows.apache2.php

For Linux/Apache1.3.x:
http://us2.php.net/manual/en/install.unix.php#install.unix.apache

For Linux/Apache2.x:
http://us2.php.net/manual/en/install.unix.apache2.php

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



Re: [PHP] Re: apache 1 vs 2 w/php

2005-01-06 Thread William Lovaton
My experience dictates the contrary.

Apache 2 is much faster with PHP that Apache 1.3.  I run an enterprise
web application in my company with about 950 users concurrently.  I
configured the apache logs to add the execution time for each request
(this is done with %T in the LogFormat).  We started the production
system around 2 years ago with RH9 and Apache 1.3.  Only 72% of the
requests scored 0 seconds (which means less than 1 second).  Then I
updated to Fedora Core 2 with Apache 2 and it scored 96%.

I know the kernel is a lot better but this improvement is almost because
of Apache 2 since I tested Apache 1.3 in the same system and I got back
to the 72% performance.

I guess this dependes of what you use.  Because PHP has an Apache filter
and an Apache handler.  I use the later.


-William


El mié, 05-01-2005 a las 14:20 +, Matthew Weier O'Phinney escribió:
 * Sebastian [EMAIL PROTECTED]:
  I am undecided whether to upgrade to apache 2 (currently running 1.3.33)
  I've heard some bad stuff (some good maybe) about using apache 2 with php..
  does anyone have an opinions?
 
  I know everything has cons/pros but i am just looking for advice on whether
  my site will benifit from the upgrade. I'm curious to know if a site that
  normally sees 300-500 users online would see any improvements.
 
  any on going issues? is php faster/slower? downsides? advantages? anything
  in general that can help me decide.
 
 This study might help you make up your mind:
 
 http://ilia.ws/archives/32-Apache-1-vs-Apache-2-Performance.html
 
 In summary: apache2 is faster for static content, but slower at serving
 PHP; additionally, if using the prefork version of apache2 (which you
 need to do to keep PHP stable), much of your performance boost for
 static content will be lost. Your best bet: stick with apache1 if using
 PHP heavily.
 
 -- 
 Matthew Weier O'Phinney   | mailto:[EMAIL PROTECTED]
 Webmaster and IT Specialist   | http://www.garden.org
 National Gardening Association| http://www.kidsgardening.com
 802-863-5251 x156 | http://nationalgardenmonth.org
 

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



Re: [PHP] Re: apache 1 vs 2 w/php

2005-01-06 Thread William Lovaton
Rasmus,

I see much better performance with Apache 2.  I'm not an expert in the
internals of Apache nor PHP but I guess one of the improvements in
apache is the log mechanism, I think it use a different technique that
makes it faster that Apache 1.3

The reason I say this is because Apache 1.3 log are written in perfect
order according to the time field.  I Apache 2 the logs are not ordered
so you can have something like this:

172.20.15.138 - - [06/Jan/2005:09:43:55 -0500]
192.168.149.42 - - [06/Jan/2005:09:43:55 -0500]
192.168.150.27 - - [06/Jan/2005:09:43:55 -0500]
172.16.113.22 - - [06/Jan/2005:09:43:53 -0500]
192.1.20.197 - - [06/Jan/2005:09:43:54 -0500]
192.168.172.20 - - [06/Jan/2005:09:43:55 -0500]
192.168.150.66 - - [06/Jan/2005:09:43:55 -0500]

This is extracted from my production server with FC3 Apache 2.0.52 and
PHP 4.3.9


-William


El mié, 05-01-2005 a las 04:58 -0800, Rasmus Lerdorf escribió:
 Lester Caine wrote:
  Sebastian wrote:
  I know everything has cons/pros but i am just looking for advice on 
  whether
  my site will benifit from the upgrade. I'm curious to know if a site that
  normally sees 300-500 users online would see any improvements.
  
  That would be nice information to find out, but does not seem to be 
  available.
 
 If you are serving up a lot of static file, you will see an improvement. 
   If it is all dynamic PHP requests, then you won't.  Apache really 
 doesn't have much to do on a PHP request so all the performance depends 
 on the speed of PHP, not Apache.  There are a few places where Apache2 
 has improved things for a PHP request, but these tend to be countered by 
 a few places where things have gotten ore expensive.  Every benchmark I 
 have done puts PHP under Apache2 right in the same ballpark as PHP under 
 Apache1 with Apache1 usually a little bit ahead.  But do your own 
 testing on your own platform.  Other peoples' benchmarks are meaningless.
 
 -Rasmus
 

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



Re: [PHP] Persistent PHP web application?

2005-01-06 Thread William Lovaton
Hi Rasmus,

El lun, 03-01-2005 a las 14:13 -0500, Rasmus Lerdorf escribió:
 If you need to do something fancier you can stick things in shared 
 memory.  Many of the accelerators give you access to their shared memory 
 segments.  For example, the CVS version of pecl/apc provides apc_store() 
 and apc_fetch() which lets you store PHP datatypes in shared memory 
 directly without needing to serialize/unserialize them.

This is great.  In my high performance web app I created a PHP library
that abstracted this to use several backends.  For instance I have a
File backend and a SHM backend that uses the functions provided by the
sysvshm PHP module.  With this functions, do they need to
serialize/unserialize every time I put/get something in/from the cache??

Also I use sysvsem for locking capabilities.  does apc take care of the
locking? does it have an API to do that?

My experience with shared memory have been great.  My production server
uses a segment of 384MB to cache lots of resultsets and PHP objects and
the performance is almost unbeatable... well if it serializes then
pecl/apc will give better performance I guess.


-William

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



Re: [PHP] Setting Up PHP

2005-01-06 Thread John Nichel
George McGuey wrote:
I am using SAMS Teach Yourself on PHP,MYSQL and Apache.
 

Everything has gone well except for the final step to test the PHP by
creating in Apache htdocs file called phpinfo.php.
 
When I do this and then go to the http://localhost/phpinfo.php to view the
information page all I get is the original lines of that are in the text
file which is ?php phpinfo() ; ?
 
Need help and I am an absolute novice in terms of knowledge.
 
Thanks 
Did you configure Apache to parse php files?
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Total Server Sessions

2005-01-06 Thread William Lovaton
Additionally you can check the access time to see which of those
sessions has been accessed in the last, let's say, 10 minutes or
something.

But there are several problems with this.  Relying on session files is
not good enough, they might be stored in a database or in shared memory.
Other problem is that those sessions are for every PHP app installed in
the server so you are counting sessions for different apps like it were
from yours.

To solve this you could put some APPID in the session and check for its
value reading the sess file as text.  Obviously you will have to figure
out the format a little bit.


-William


El lun, 03-01-2005 a las 08:25 -0700, Rob Adams escribió:
 HarryG [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
  Is there an easier way to count the total number of sessions running on a
  PHP webserver? something like session_count();
 
 If you're using file based sessions, you could count the number of files in 
 the directory where the sessions get saved.  If there are files in there 
 other than just session files, you'll have to look for just the session 
 files.  On all my systems, they've started with sess.
 
   -- Rob 
 

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



[PHP] OpenSSL Problem

2005-01-06 Thread Gustafson, Tim
Hello

I am trying to use the OpenSSL module for PHP on a FreeBSD 4.10 server.
I have CVS'd everything, so I have the most current version of the
FreeBSD port.

I have attached the PHP file that I'm running.  Here's the error message
I get:

openssl_csr_sign(): cannot get cert from parameter 2

The file that is being referenced is a valid certificate, encoded in
base-64 format and the path is correct, and OpenSSL is able to sign
using this certificate and the corresponding key if I run it directly
from the command line.  I have also attached the certificate.  What am I
missing?

Tim Gustafson
MEI Technology Consulting, Inc
[EMAIL PROTECTED]
(516) 379-0001 Office
(516) 480-1870 Mobile/Emergencies
(516) 908-4185 Fax
http://www.meitech.com/ 




keys.phtml
Description: Binary data


falconsoft.com.crt
Description: application/x509-ca-cert


smime.p7s
Description: S/MIME cryptographic signature


Re: [PHP] migrating to PHP 5 + Apache 2 from PHP 4.3.8 + Apache 1.3.33.

2005-01-06 Thread symbulos partners
We know that. We understood all of that.

What we need to know is:

1)Are php core function thread safe?

2)Does php have internal mechanisms in php for protecting thread safety
(memory leak, threads overwriting memory in use by another thread, blah,
blah)?

3)Are the function in this LIMITED LIST thread safe? (This is THE LIMITED
LIST extracted from the list of the functions in section VI, the one you
requested, the one R.Lynch requested). Since we sent the list with the
functions we need already 2 times, would you please be so gentle as to
answer now?

Apache-specific Functions
Array Functions
Calendar Functions
Class/Object Functions
CURL, Client URL Library Functions
Cyrus IMAP administration Functions
Date and Time Functions
Direct IO Functions
Directory Functions
DOM Functions
DOM XML Functions
Error Handling and Logging Functions
File Alteration Monitor Functions
Filesystem Functions
Forms Data Format Functions
FTP Functions
Function Handling Functions
Gettext
GMP Functions
HTTP Functions
Image Functions
IMAP, POP3 and NNTP Functions
PHP / Java Integration
LDAP Functions
Mail Functions
Mathematical Functions
Multibyte String Functions
Mimetype Functions
Miscellaneous Functions
MySQL Functions
Improved MySQL Extension
Network Functions
Unified ODBC Functions
Object Aggregation/Composition Functions
Object property and method call overloading
OpenSSL Functions
Output Control Functions
PDF functions
PHP OptionsInformation
PostgreSQL Functions
Program Execution Functions
Session Handling Functions
Shared Memory Functions
SimpleXML functions
SQLite
Shockwave Flash Functions
Standard PHP Library (SPL) Functions
String Functions
URL Functions
Variable Functions
vpopmail Functions
XML Parser Functions
XML-RPC Functions
XSL functions
XSLT Functions

-- 
symbulos partners
-.-
symbulos - ethical services for your organisation
http://www.symbulos.com

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



Re: [PHP] Persistent PHP web application?

2005-01-06 Thread Josh Whiting
 Anything you do in the MINIT hook is basically free, so it would be 
 trivial to load the data for the array from somewhere.  Like a database, 
 an xml file, etc.  So you wouldn't need to hardcode a complex array 
 structure in your MINIT hook, just have this generic little extension 
 that creates an array (or object) from some external source.  To change 
 the data you would change that external source and restart your server, 
 or you could write a PHP function in your extension that forced a reload 
 with the caveat that each running httpd process would need to have that 
 function be called since your array/object lives in each process separately.
 
 If you ask really nicely one of the folks on the pecl-dev list might 
 just write this thing for you.  Especially if you spec it out nicely and 
 think through how it should work.
 
 -Rasmus

Call me crazy or ignorant, i'm both, but would it be possible to build
an extension that, in its MINIT hook as you suggest, actually runs a
separate PHP script that contains global definitions, then makes those
definitions available to later scripts?  this is basically my original
desire of having a one-time, persistent global include for each apache
process.  i realize you suggest pulling array data from a source like a
DB or XML file, which would be a 90% solution for me, but the next step
(a PHP script) just seemed logical/exciting...

i realize i'm reaching with this, and it implies a conundrum (how does
an extension run a PHP script if PHP hasn't fully started yet) but this
kind of thing is just what makes me go and learn new things (C, php/zend
internals) and I just might try to do it if it was feasible, for the fun
of it, because it could be useful to lots of people, even if it took me
a year or two to pull off.

alas, this is a question for the pecl-dev list.

(the mental gears are churning...)

/jw

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



RE: [PHP] OpenSSL Problem

2005-01-06 Thread Gustafson, Tim
Richard,

Actually, if you leave the code exactly as-is, but change the
openssl_csr_sign function to create a self-signed certificate, the
entire script executes perfectly.  I know there is a lot of error
checking needed - I'm just making a test script to get a feel for how
OpenSSL operates in PHP.  The certificate and key files are mode 444
(readable by everyone) as they are just test certificates right now.
I have a valid openssl.cnf file (in /etc/ssl/openssl.cnf, which is
what's complied into OpenSSL) and I use that configuration file that I
use with some shell scripts to do everything that I want to do in PHP,
so I'm sure it's a valid openssl.cnf file.

Does PHP restrict access to /etc/ssl for the OpenSSL library if I have
open_basedir set?  Perhaps I need to make an openssl.cnf in the
/usr/home/ws1086 (which is the open_basedir path) so that it's readable?
I would think that the library would have access to the whole system
since it's not really part of PHP, but maybe I'm wrong.

Either way, it's not complaining about access to openssl.cnf, it's
complaining about access to the certificate, so let's take it one step
at a time.  :)

Tim Gustafson
MEI Technology Consulting, Inc
[EMAIL PROTECTED]
(516) 379-0001 Office
(516) 480-1870 Mobile/Emergencies
(516) 908-4185 Fax
http://www.meitech.com/ 




-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 06, 2005 11:24 AM
To: Gustafson, Tim
Cc: php-general@lists.php.net
Subject: Re: [PHP] OpenSSL Problem


Gustafson, Tim wrote:
 I am trying to use the OpenSSL module for PHP on a FreeBSD 4.10
server.
 I have CVS'd everything, so I have the most current version of the
 FreeBSD port.

 I have attached the PHP file that I'm running.  Here's the error
message
 I get:

 openssl_csr_sign(): cannot get cert from parameter 2

 The file that is being referenced is a valid certificate, encoded in
 base-64 format and the path is correct, and OpenSSL is able to sign
 using this certificate and the corresponding key if I run it directly
 from the command line.  I have also attached the certificate.  What am
I
 missing?

You are missing error checking on the openssl_pkey_new() and
openssl_csr_new() function calls.

You don't even know for sure that you have a valid PKEY nor that you
have
a valid CSR resource.

And, of course, you should have some error-checking on the return value
from openssl_csr_sign() to see if it worked.

Odds are really good that if you add all that error-checking, and the
code
needed to find out what error occurred --
http://php.net/openssl_error_string -- you'll find out that the OpenSSL
software and PHP have conpsired to tell you *exactly* what is going
wrong.
:-)

My first Wild Guess would be that your PHP user doesn't have permission
to
read your .crt and .key files, or that you don't have a PHP-readable
valid
openssl.cnf file.

If all else fails, despite the examples in the manual, you may want to
try
to get rid of the 'file://' parts of your file names.  But maybe you
need
those for some arcane OpenSSL reason beyond my ken. [shrug]

-- 
Like Music?
http://l-i-e.com/artists.htm



smime.p7s
Description: S/MIME cryptographic signature


Re: [PHP] migrating to PHP 5 + Apache 2 from PHP 4.3.8 + Apache 1.3.33.

2005-01-06 Thread Jason Barnett
Symbulos Partners wrote:
We know that. We understood all of that.
Let me ask you this.  Do you know what underlying libraries are 
associated with the extensions you want to use (in your list below)?  If 
you do then you *should* be able to google for each library individually 
and see if that library is thread safe.  I have not gone through this 
exercise for myself, but then again I don't need to either.  ;)  This 
would also be something that would be a great benefit to share with the 
PHP community if you decide to compile this list of thread-safe extensions.


What we need to know is:
1)Are php core function thread safe?
I have read somewhere that this is true, but I have absolutely no 
firsthand experience in PHP's source to tell you if this is the case. 
Rasmus will know (whistling and walking away...)

2)Does php have internal mechanisms in php for protecting thread safety
(memory leak, threads overwriting memory in use by another thread, blah,
blah)?
Yes it does... IIRC check out TSRM in the source.
3)Are the function in this LIMITED LIST thread safe? (This is THE LIMITED
LIST extracted from the list of the functions in section VI, the one you
requested, the one R.Lynch requested). Since we sent the list with the
functions we need already 2 times, would you please be so gentle as to
answer now?
I have no idea.  ;)  But I use a lot of these functions as well and it 
would be good to know.

Apache-specific Functions
Array Functions
Calendar Functions
Class/Object Functions
CURL, Client URL Library Functions
Cyrus IMAP administration Functions
Date and Time Functions
Direct IO Functions
Directory Functions
DOM Functions
DOM XML Functions
To anyone reading this, remember he's using PHP 4.3.x but he's asking 
about PHP 5.x.  So I guess the question there: is libxml2 thread-safe?

Error Handling and Logging Functions
File Alteration Monitor Functions
Filesystem Functions
Forms Data Format Functions
FTP Functions
Function Handling Functions
Gettext
GMP Functions
HTTP Functions
Image Functions
IMAP, POP3 and NNTP Functions
PHP / Java Integration
LDAP Functions
Mail Functions
Mathematical Functions
Multibyte String Functions
Mimetype Functions
Miscellaneous Functions
MySQL Functions
Improved MySQL Extension
Network Functions
Unified ODBC Functions
Object Aggregation/Composition Functions
Object property and method call overloading
OpenSSL Functions
Output Control Functions
PDF functions
PHP OptionsInformation
PostgreSQL Functions
Program Execution Functions
Session Handling Functions
Shared Memory Functions
Good lord I would hope so :)
SimpleXML functions
SQLite
Shockwave Flash Functions
Standard PHP Library (SPL) Functions
String Functions
URL Functions
Variable Functions
vpopmail Functions
XML Parser Functions
XML-RPC Functions
XSL functions
XSLT Functions
All of the XSL stuff should fall under the umbrella of is libxml2 
thread safe? since we use that library for XSL functionality too.

One final note.  I notice that you make of the PHP4 XML libraries? 
Well, there was a break in this functionality in PHP5.  If you used the 
almost W3C compliant domxml functions then you should be ok.  If not, 
well, you might be in for some rewriting there.  :(

http://php.net/manual/en/ref.dom.php
--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://php.net/manual/
php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Image copying

2005-01-06 Thread Richard Lynch
Liam Gibbs wrote:
 print(IMG ALT... HEIGHT... WIDTH... SRC = \ . copy_pic($sourcepic) .
 \);

 So I'm calling the function straight from the SRC attribute of the IMG
 tag. Here's what's in my function:

 function copy_pic($sourcepic) {
if(file_exists($sourcepic)) {
   $destinationpic = imagecreatetruecolor(imagesx($sourcepic),
 imagesy($sourcepic));
   imagecopy($destinationpic, $sourcepic, 0, 0, 0, 0,
 imagesx($sourcepic), imagesy($sourcepic));
}

return $destinationpic;
 }

 After this, I'm going to be tampering with the pic, but I just wanted to
 make sure I'm getting something, which I'm not. All I get is a broken
 image. No error message, no nothing. Please tell me I'm not overlooking
 some really idiotic thing, but I'm just having one heckuva time with this.

Not idiotic at all.

You have to sort of un-learn something, and wrap your brain around a new
concept. :-)

You know how PHP spits out HTML?

Yeah, well, PHP doesn't *just* spit out HTML.

PHP can *also* spit out an actual JPEG.

Like, it spits out what you would get if you opened up a JPEG in a text
editor and you see all that gobbledy-gook.

But to do this, you've *still* got to have it being spit out as *JUST* the
image, in a separate file, the *same* as having a separate JPEG image file
on the server which is not all that gobbledy-gook pasted into your HTML.

Or, to put it this way:

You currently have something like this all in one big file:

HTMLBODY
...
IMG SRC=JPEG%(**^#@@#R%GFGE#WWRYUIIUUYY**%*%$^[EMAIL PROTECTED]@#%$^%
...
/BODY/HTML

But, a valid setup would have *TWO* files.  One with:
HTMLBODY
IMG SRC=otherfile.jpg/HTML
/BODY/HTML

otherfile.jpg would have the JPEG stuff in it:
JPEG%(**^#@@#R%GFGE#WWRYUIIUUYY**%*%$^[EMAIL PROTECTED]@#%$^%

So you need to move your copy_pic stuff and all of that to a DIFFERENT
file, say dynamic_jpeg.php.

Your HTML will then have:
IMG SRC=dynamic_jpeg.php
in it.

Plus your dynamic_jpeg.php file will have to have this stuff at the end:

header(Content-type: image/jpeg);
imagejpeg($destinationpic);

PS:  You may not be *SEEING* the error messages, because they are buried
in the contents of what is supposed to be a JPEG.  But if your JPEG looks
like this:

JPEG*(*^*^%^% PHP Error: blah blah blah **^%$$##@@#$%^^^

then it's just a broken JPEG, as far as the browser is concerned.

So  surf *DIRECTLY* to it when the browser shows you a broken image icon:

http://sympatico.ca/dynamic_jpeg.php

for example.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



RE: [PHP] OpenSSL Problem

2005-01-06 Thread Gustafson, Tim
I figured it out!

I had to change the key references to something like this:

file://../falconsoft.com.crt

Using an absolute path seems to break it.  :\

Tim Gustafson
MEI Technology Consulting, Inc
[EMAIL PROTECTED]
(516) 379-0001 Office
(516) 480-1870 Mobile/Emergencies
(516) 908-4185 Fax
http://www.meitech.com/ 


-Original Message-
From: Gustafson, Tim 
Sent: Thursday, January 06, 2005 10:45 AM
To: php-general@lists.php.net
Subject: [PHP] OpenSSL Problem

Hello

I am trying to use the OpenSSL module for PHP on a FreeBSD 4.10 server.
I have CVS'd everything, so I have the most current version of the
FreeBSD port.

I have attached the PHP file that I'm running.  Here's the error message
I get:

openssl_csr_sign(): cannot get cert from parameter 2

The file that is being referenced is a valid certificate, encoded in
base-64 format and the path is correct, and OpenSSL is able to sign
using this certificate and the corresponding key if I run it directly
from the command line.  I have also attached the certificate.  What am I
missing?

Tim Gustafson
MEI Technology Consulting, Inc
[EMAIL PROTECTED]
(516) 379-0001 Office
(516) 480-1870 Mobile/Emergencies
(516) 908-4185 Fax
http://www.meitech.com/ 




smime.p7s
Description: S/MIME cryptographic signature


Re: [PHP] Persistent PHP web application?

2005-01-06 Thread William Lovaton
Rasmus,

El jue, 06-01-2005 a las 08:23 -0800, Rasmus Lerdorf escribió:
 On Thu, 6 Jan 2005, William Lovaton wrote:
  This is great.  In my high performance web app I created a PHP library
  that abstracted this to use several backends.  For instance I have a
  File backend and a SHM backend that uses the functions provided by the
  sysvshm PHP module.  With this functions, do they need to
  serialize/unserialize every time I put/get something in/from the cache??
 
 If you are doing this in user-space PHP, then yes, you will have to 
 serialize.

From my PHP library I use shm_put_var() and shm_get_var().  If
serialization is done this way then it is implicit... right?


-William

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



Re: [PHP] Persistent PHP web application?

2005-01-06 Thread Rasmus Lerdorf
On Thu, 6 Jan 2005, William Lovaton wrote:

 Hi Rasmus,
 
 El lun, 03-01-2005 a las 14:13 -0500, Rasmus Lerdorf escribió:
  If you need to do something fancier you can stick things in shared 
  memory.  Many of the accelerators give you access to their shared memory 
  segments.  For example, the CVS version of pecl/apc provides apc_store() 
  and apc_fetch() which lets you store PHP datatypes in shared memory 
  directly without needing to serialize/unserialize them.
 
 This is great.  In my high performance web app I created a PHP library
 that abstracted this to use several backends.  For instance I have a
 File backend and a SHM backend that uses the functions provided by the
 sysvshm PHP module.  With this functions, do they need to
 serialize/unserialize every time I put/get something in/from the cache??

If you are doing this in user-space PHP, then yes, you will have to 
serialize.

 Also I use sysvsem for locking capabilities.  does apc take care of the
 locking? does it have an API to do that?

APC takes care of locking and all cache management.

 My experience with shared memory have been great.  My production server
 uses a segment of 384MB to cache lots of resultsets and PHP objects and
 the performance is almost unbeatable... well if it serializes then
 pecl/apc will give better performance I guess.

It should, yes.  Try it.

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

Re: [PHP] endless while loop

2005-01-06 Thread Gunter Sammet
Jason Wong [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On Thursday 06 January 2005 05:17, Gunter Sammet wrote:

 I am having some trouble getting the following code to work:

 if (is_array($bundle_attributes)) {

 reset($bundle_attributes);

 while (list($option, $value) = each($bundle_attributes)) {

 reset($value);

 while (list($option2, $value2) = each($value)) {

 $this-contents[$products_id]['attributes'][$option] = $value;

 if (tep_session_is_registered('customer_id')) tep_db_query(insert into  
 .
 TABLE_CUSTOMERS_BASKET_BUNDLE_ATTRIBUTES .  (customers_id, products_id,
 sub_product_id, products_options_id, products_options_value_id) values 
 ('
 . (int)$customer_id . ', ' . tep_db_input($products_id) . ', ' .
 $option . ', ' . (int)$option2 . ', ' . (int)$value2 . '));

 }

 }

 }

 }

 It gives me an endless loop in the second while loop. It seems like it
 doesn't move the pointer to the next value in the $option array.

 But isn't the next value of $option controlled by the outer while-loop?

 When I do
 a print in that loop, I am getting the key value pair for the first 
 element
 in the $option array.

 So inside the inner while-loop, $option should never change.

 Changing it to a for loop works. Any ideas why this
 happens?

 No. But I can tell you that:

 1) the reset() aren't necessary
 2) even better, use a foreach-loop instead of while-loop

 -- 
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 New Year Resolution: Ignore top posted posts

Hi Jason:
Thanks for the reply.

I added some of the reset in just to make sure the pointer isn't somewhere 
else through earlier iterations/to make sure it doesn't make a difference.
Will play around with the foreach as soon as I have some time. Reading 
through php.net it seems like there are a few pitfalls (as there can be with 
while) to watch out for.

Found out what the problem was after I posted. Reading through the function 
manual for each I found the following:
snip
 Caution
Because assigning an array to another variable resets the original arrays 
pointer, our example above would cause an endless loop had we assigned 
$fruit to another variable inside the loop.

/snip

That's what I did. Didn't had to but it has been a copy and paste from some 
other code I haven't cleaned up. Good thing on it is, that I now know that I 
can't do this.

Thanks again!

Gunter

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



Re: [PHP] Persistent PHP web application?

2005-01-06 Thread Rasmus Lerdorf
On Thu, 6 Jan 2005, Josh Whiting wrote:

  Anything you do in the MINIT hook is basically free, so it would be 
  trivial to load the data for the array from somewhere.  Like a database, 
  an xml file, etc.  So you wouldn't need to hardcode a complex array 
  structure in your MINIT hook, just have this generic little extension 
  that creates an array (or object) from some external source.  To change 
  the data you would change that external source and restart your server, 
  or you could write a PHP function in your extension that forced a reload 
  with the caveat that each running httpd process would need to have that 
  function be called since your array/object lives in each process separately.
  
  If you ask really nicely one of the folks on the pecl-dev list might 
  just write this thing for you.  Especially if you spec it out nicely and 
  think through how it should work.
  
  -Rasmus
 
 Call me crazy or ignorant, i'm both, but would it be possible to build
 an extension that, in its MINIT hook as you suggest, actually runs a
 separate PHP script that contains global definitions, then makes those
 definitions available to later scripts?  this is basically my original
 desire of having a one-time, persistent global include for each apache
 process.  i realize you suggest pulling array data from a source like a
 DB or XML file, which would be a 90% solution for me, but the next step
 (a PHP script) just seemed logical/exciting...
 
 i realize i'm reaching with this, and it implies a conundrum (how does
 an extension run a PHP script if PHP hasn't fully started yet) but this
 kind of thing is just what makes me go and learn new things (C, php/zend
 internals) and I just might try to do it if it was feasible, for the fun
 of it, because it could be useful to lots of people, even if it took me
 a year or two to pull off.
 
 alas, this is a question for the pecl-dev list.
 
 (the mental gears are churning...)

The apache-hooks SAPI can do this, although when I initially wrote it 
nobody seemed interested.  George fixed it/rewrote it to work much better, 
but nobody was interested in his version either, so the current 
implementation isn't up to date anymore.  The problem was likely that 
people really didn't understand how to use it and it is a rather unsafe 
thing to let PHP scripts fiddle with all the various Apache request hooks.  
You can really toast your server that way.  A simple generic data loading 
extension is something people will be able to understand and they are 
unlikely to destroy their server with it.

-Rasmus

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



Re: [PHP] call a function within the same class

2005-01-06 Thread Richard Lynch
kalinga wrote:
 Dear all,
 I recently started PHP OOP and I'm bit confused about best and the most
 efficient methods when 'declaring a class' and 'calling function',
 could somebody
 explain me with following sample code, it would be great..

 thanks..

 class classLdap{

 $rslt = $_POST['rslt'];

   function ldapConnect($rslt){
   
   ..
   return $rslt;
 }// end function ldapConnect

   function ldapAdd($rslt){
   // i want to call ldapConnect($rslt) here what is the best
 method.

 $rslt = classLdap::ldapConnect($rslt);

This is generally done when you:
A) Don't have an instance of a classLdap to work with.
B) Calling ldapConnect() on the instance you have would cause side effects
to the instance (or other objects) that you don't want to happen in some
unusual case.

A. does not apply here, as you are in the method of the class, so you have
'$this' which is the instance you have created.

B. might or might not apply, but it all depends on YOUR application and
what you want it to do...

 //or
   //(curently i'm doing this way, it's to lengthy)

  $new_classLdap = new classLdap;
$rslt = $new_classLdap-ldapConnect($rslt);

This can also be used to avoid altering the existing object you have
created -- though it's a bit more expensive than the previous way of doing
that.

There might be some super RARE case where you really really need an object
instantiated to have it be valid, and you would *HAVE* to do the above.

But that would be super rare, so this is probably not what you want.

 //or

$rslt = $this-ldapConnect($rslt);


works if you just want to affect *THIS* same object that you have -- In
other words, use $this- when you are thinking about 'this' object that
you have created and want it to change itself in some way.  Kind of like a
self-help sort of deal.


You might not want to assign the result back into $rslt -- depending on
what $rslt actually *IS* which I don't know, since you have it coming in
from $_POST...

Which you also need to do some checking on, since it's NOT SAFE to accept
$_POST data -- *any* Bad Guy out there could send any nasty thing they
want to your script through $_POST.

 }// end function ldapAdd

 }// end class

Based on what you are doing, and your experience level, I'd say stick with
the last answer:

$this-ldapConnect($rslt)

unless you have a very specific need to use the others.

Just keep it in the back of your mind that there *ARE* alternatives, so
that, years from now, when you run into one of those weird-o cases where
you need the others, you'll remember that they exist as alternatives.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] migrating to PHP 5 + Apache 2 from PHP 4.3.8 + Apache 1.3.33.

2005-01-06 Thread Rasmus Lerdorf
On Thu, 6 Jan 2005, Jason Barnett wrote:
 Symbulos Partners wrote:
  We know that. We understood all of that.
  
 
 Let me ask you this.  Do you know what underlying libraries are associated
 with the extensions you want to use (in your list below)?  If you do then you
 *should* be able to google for each library individually and see if that
 library is thread safe.  I have not gone through this exercise for myself, but
 then again I don't need to either.  ;)  This would also be something that
 would be a great benefit to share with the PHP community if you decide to
 compile this list of thread-safe extensions.

Keep in mind that it isn't that simple.  If it was we would have done this 
long ago.  Whether something is threadsafe depends on a lot of factors.  
The author of a certain library might tell you his library is threadsafe, 
but depending on how you compile it and which libc you are using it may or 
may not be threadsafe.  So, while one person's library on his platform 
will work perfectly and be threadsafe, that exact same library on another 
platform may not be.

Some examples of this are the c-client (imap) library and the postgresql 
library.  Both may or may not be threadsafe depending on your platform and 
how you build them.  Your crypt() libc call isn't threadsafe, for example.  
libpq used to call crypt() if you used the PASSWD() function in an SQL 
query.  Now you might tick along for months without ever having 2 threads 
execute the SQL query that calls PASSWD() at exactly the same time, but 
then suddenly your lucky karma runs out and they do.  You end up with 2 
records in your database that are corrupted.  The PostgreSQL guys fixed 
this, I think, but prior to this they were saying that libpq was 
threadsafe.  The problem is always in code you don't control.  They didn't 
control the libc crypt implementation and it bit them.  

I guarantee that there are dozens if not hundreds of examples of problems 
like this in just about every library, and probably a few left in PHP 
itself still.  Unless someone hits a problem (which is likely) and 
recognizes it for what it is (which is unlikely) and informs the 
developers these tricky thread problems are never going to be fixed.

I still content that humans are simply not smart enough to write 
threadsafe code for a largescale heterogenious project such as PHP with 
all the platforms and libraries that all have to interact perfectly.

-Rasmus

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



Re: [PHP] OpenSSL Problem

2005-01-06 Thread Richard Lynch
Gustafson, Tim wrote:
 I am trying to use the OpenSSL module for PHP on a FreeBSD 4.10 server.
 I have CVS'd everything, so I have the most current version of the
 FreeBSD port.

 I have attached the PHP file that I'm running.  Here's the error message
 I get:

 openssl_csr_sign(): cannot get cert from parameter 2

 The file that is being referenced is a valid certificate, encoded in
 base-64 format and the path is correct, and OpenSSL is able to sign
 using this certificate and the corresponding key if I run it directly
 from the command line.  I have also attached the certificate.  What am I
 missing?

You are missing error checking on the openssl_pkey_new() and
openssl_csr_new() function calls.

You don't even know for sure that you have a valid PKEY nor that you have
a valid CSR resource.

And, of course, you should have some error-checking on the return value
from openssl_csr_sign() to see if it worked.

Odds are really good that if you add all that error-checking, and the code
needed to find out what error occurred --
http://php.net/openssl_error_string -- you'll find out that the OpenSSL
software and PHP have conpsired to tell you *exactly* what is going wrong.
:-)

My first Wild Guess would be that your PHP user doesn't have permission to
read your .crt and .key files, or that you don't have a PHP-readable valid
openssl.cnf file.

If all else fails, despite the examples in the manual, you may want to try
to get rid of the 'file://' parts of your file names.  But maybe you need
those for some arcane OpenSSL reason beyond my ken. [shrug]

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] migrating to PHP 5 + Apache 2 from PHP 4.3.8 + Apache 1.3.33.

2005-01-06 Thread Greg Donald
On Thu, 06 Jan 2005 16:15:43 +, symbulos partners
[EMAIL PROTECTED] wrote:
 We know that. We understood all of that.
 
 What we need to know is:

Please, do not assimilate me.


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



Re: [PHP] Regexp help second

2005-01-06 Thread Richard Lynch
You could maybe cheat and add an X at the beginning and end of the string
before your Regex, then you will have:

X\1 \2 \3X

and you can strip off the initial X from \1 and the trailing X from \3

There's probably some fancy Regexp way to do it though.

Uroš Gruber wrote:
 Hi!

 Last help about regexp solve my problem, but I have another one.

 I've made some regexp but it does not work always

 Let say I have some strings

 1) this is some domain.com test
 2) domain.com

 I can make this work either for first example of fo second, but not for
 both. What I want is replace of domain.com to get

 this is dome domain.com domain com test so replace should be
 \1 \2 \3

 so for second example I did /((.+)\.{1}(.+))/

 How can I extend this to work in both.

 regards

 Uros

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




-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: Re[3]: [PHP] How to argue with ASP people...

2005-01-06 Thread Matthew Sims
 It should be noted that the MS KnowledgeBase article about trying to do a
 dynamic include (as of when I last used ASP, years ago) made absolutely NO
 mention of using:

 !--#include %=FileName% --!

 and tells you to just 'read' and 'print' the file -- which doesn't execute
 the ASP at all, and there is no 'eval' function (as far as I could find).

 So, assuming this #include stuff actually works, I guess it's just the
 documentation that sucked, not the actual technology.

 For *THIS* problem.

 I fought with ASP for only a few months, but it felt like years, and I
 hated every minute of it.

 I actually wrote comments in ASP like:

 % /*
 Microsoft sucks, Microsoft sucks
 Can't moveFirst in an empty record set
 */ %

 My co-workers knew when such comments were written, since I would sing
 them as I typed.  (Yes, really)

 I had a lonng song before that two months was up...

 Boolean expressions don't short-circuit is another verse I recall, off
 the top of my head.

 Sadly, I lost all my copies of that song/project.

 Oh well.

 If somebody out there actually *LIKES* ASP VBScript programming, more
 power to them -- So long as I don't have to ever use it again, I don't
 care what you use.

 Oh yeah, here's a good one:

 *EVERY* error message coming back from SQL Server had the same error
 number -- Even when the error *message* was different!  That's got to be
 in the running for dumbest software design choice on the planet.


TimeLife music presents a collection unlike any other.

**The Best of Richard Lynch**

Remember the classics such as

- Microsoft Sucks, Microsoft Sucks!

- Can't moveFirst in an Empty Record Set

- Boolean Expressions Don't Short-Circuit

and the ever classic

- ASP, I Think It's Giving Me Cancer of the Rectum

And for a limited time, we'll include documentation that leaves out most
of what you're looking for.

Order yours today!

-- 
--Matthew Sims
--http://killermookie.org

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



Re: [PHP] Persistent PHP web application?

2005-01-06 Thread Adrian Madrid
I think I understand where you're coming from. I've had a similar 
problem and the best solution I've found is eAccelerator (previously 
known as Turck MMCache). What EA does is keep the bytecodes PHP compiles 
inshared memory so next time you need that script PHP doesn't need to 
recompile, EA returns the bytecode from SHM. Now, since PHP scripts are 
compiled and saved in SHM all I need to do is /save/ the data that does 
not change often but requires a lot of queries as code (an array inside 
a script) and include it whenever I need the data. No recompiling, no 
need to touch the DB again, pure speed. I hope all this helps you. I 
personally don't need extra processes and stuff like that but if you 
really want all that you can take a look at phpbeans.

Hope it helps,
Adrian Madrid
eAccelerator: http://eaccelerator.sourceforge.net/Home
phpbeans: http://www.simian.ca/index/phpbeans
Josh Whiting wrote:
Dear list,
My web application (an online classifieds server) requires a set of
fairly large global arrays which contain vital information that most all
the page scripts rely upon for information such as the category list,
which fields belong to each category, and so on. Additionally, there are
a large number of function definitions (more than 13,000 lines of code
in all just for these global definitions).
These global arrays and functions never change between requests.
However, the PHP engine destroys and recreates them every time. After
having spent some serious time doing benchmarking (using Apache Bench),
I have found that this code takes at least 7ms to parse per request on
my dual Xeon 2.4ghz server (Zend Accelerator in use*). This seriously
cuts into my server's peak capacity, reducing it by more than half.
My question is: is there a way to define a global set of variables and
functions ONCE per Apache process, allowing each incoming hit to run a
handler function that runs within a persistent namespace? OR, is it
possible to create some form of shared variable and function namespace
that each script can tap?
AFAIK, mod_python, mod_perl, Java, etc. all allow you to create a
persistent, long-running application with hooks/handlers for individual
Apache requests. I'm surprised I haven't found a similar solution for
PHP.
In fact, according to my work in the past few days, if an application
has a large set of global functions and variable definitions, mod_python
FAR exceeds the performance of mod_php, even though Python code runs
significantly slower than PHP code (because in mod_python you can put
all these definitions in a module that is loaded only once per Apache
process).
The most promising prospect I've come across is FastCGI, which for Perl
and other languages, allows you to run a while loop that sits and
receives incoming requests (e.g. while(FCGI::accept() = 0) {..}).
However, the PHP/FastCGI modality seems to basically compare to mod_php:
every request still creates and destroys the entire application
(although the PHP interpreter itself does persist).
Essentially I want to go beyond a persistent PHP *interpreter* (mod_php,
PHP/FastCGI) and create a persistent PHP *application*... any
suggestions?
Thanks in advance for any help!
Regards,
J. Whiting
* - Please note that I am using the Zend Accelerator (on Redhat
Enterprise with Apache 1.3) to cache the intermediate compiled PHP code.
My benchmarks (7ms+) are after the dramatic speedup provided by the
accelerator. I wouldn't even bother benchmarking this without the
compiler cache, but it is clear that a compiler cache does not prevent
PHP from still having to run the (ableit precompiled) array and function
definition code itself.
 


--
Adrian Madrid
HyperX Inc. 
Mobile: 801.815.1870
Office: 801.566.0670 
[EMAIL PROTECTED] 
www.hyperxmedia.com 

9000 S. 45 W.
Sandy, UT 84070


[PHP] Re: Apologies for the last e-mail concerning (Re: [PHP] migrating to PHP 5 + Apache 2 from PHP 4.3.8 + Apache 1.3.33)

2005-01-06 Thread Richard Lynch
Plan on doing a LOT of testing -- My guesses on the probability of
thread-safety were just that:  GUESSES

Thread-safe bugs are the kind of thing that can remain hidden for *YEARS*
or even *DECADES* and not get triggered but once in a million executions
of your scripts.

By definition, they rely on *TWO* copies of your script running in
parallel and timing is everything.

For example, suppose your script is like this:

?php
/* LOTS OF CODE */
thread_bug_function();
/* LOTS OF CODE */
?

You can run that script a million times, and nothing will go wrong.

You can even run your web-server with multiple copies of your PHP script
running a million times and nothing will go wrong.

Let's examine the case of just *TWO* Apache children processes, running
your script in parallel.

Depending on when one script starts, when it gets interrupted by the OS so
other processes can run, and when it re-starts, you have *THREE* possible
cases:

(where the time at which something is run is indicated in a vertical
manner.

CASE #1:
APACHE CHILD ONEAPACHE CHILD TWO
?php   ?php
/* LOTS OF CODE */  /* LOTS OF CODE */ thread_bug_function();
thread_bug_function();  /* LOTS OF CODE */
/* LOTS OF CODE */ ?
?

CASE #2:
APACHE CHILD ONEAPACHE CHILD TWO
?php   ?php
/* LOTS OF CODE */  /* LOTS OF CODE */
thread_bug_function();
/* LOTS OF CODE */ thread_bug_function(); /* LOTS OF CODE */
? ?

CASE #3:
APACHE CHILD ONEAPACHE CHILD TWO
?php   ?php
/* LOTS OF CODE */  /* LOTS OF CODE */
thread_bug_function();  thread_bug_function();
/* LOTS OF CODE */  /* LOTS OF CODE */
?  ?


CASE #1 and CASE #2 cause no problem at all -- The 'thread_bug_function'
doesn't run at the same time in one child as the other child, because of
the timing -- it runs BEFORE or AFTER the same function in the other
child.

CASE #3 will crash big-time, because the thread-bug got executed at the
SAME TIME in BOTH children.

But here's the thing:  The *larger* your code base, the better the odds
are that CASE #1 and CASE #2 will happen, because there is so much going
on in the /* LOTS OF CODE */ sections.

The ONLY time the bug is triggered is when the two scripts happen to try
to execute the buggy line AT THE SAME TIME.

So CASE #3 is super super super rare.  And it gets more and more rare as
you add more and more code (yours or the PHP Modules you are asking about)
to your project.

The more you think about this, the more you'll realize just how impossible
a question you are posing, and just how complicated you are making your
server by using threads.

There is NO PRACTICAL WAY to systematically test for a thread bug.

Only disciplined coding by experienced software developers will avoid
thread bugs -- and even that is hardly a given

So you're really really really going out on a limb to use the threads.

If you *NEED* the threads, you are going to have to pay a heavy heavy
heavy price in doing a *TON* of testing under heavy load servers, with as
much variance in timing of script start/end as you can introduce.

Every line of code you add, and every Module you load in to add
functionality/features will GEOMETRICALLY INCREASE your risk and the need
for testing.

The reason you kept getting bad answers, or answer at all, is you kept
asking a bad question :-)

Things to consider:
#1. Do you really *NEED* threads?
#2. If you *DO* need them, can you segment your application and modularize
and isolate the thread usage to a single server, or a single body of code,
or an isolated case that will be called rarely or ???
#3. Do you have the resources to run a billion tests?

If you need threads, and you can't isolate them to a sandbox, and you
don't have the resources for a billion tests, QUIT NOW.

You will save yourself a ton of money and frustration by not tackling an
insurmountable project that will ruin you.

A man's got to know his limitations
   -- Dirty Harry

symbulos partners wrote:
 I apologise for the last e-mail concerning this subject, but I had not
 received your e-mail back.

 Thanks for the explanations, they will be very useful.
 --
 symbulos partners
 -.-
 symbulos - ethical services for your organisation
 http://www.symbulos.com



-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] php ignores php_value from httpd.conf?

2005-01-06 Thread Richard Lynch
Steve Kieu wrote:
 I am trying to debug the problem I have; which is that php seems to
 ignore all php_value I set in httpd.conf. Example I have:

 but when I access http://10.0.44.254:800/some_upload.php
 it still sees that the file upload size if 2M (set in global php.ini).
 If I comment out in php.ini; it doesn't have a value at all.
 Is it a bug in apache or php or I missed something when compiling them?
 apache-1.3.33 PHP 4.3.10.

Most flags/values can be set in httpd.conf *OR* php.ini, and over-ridden
in .htaccess, and over-ridden again in your PHP script.

I don't know for sure either way what it means to try and set something in
both httpd.conf and php.ini in general -- In most cases, the person who
has access to either has access to both and can just set it in ONE place
the way they want and move on with life.  So I suspect that you're only
supposed to set it in php.ini *OR* httpd.conf

Note, however, that the particular setting you are using,
upload_max_filesize is one of the oddball settings that can *NOT* be
over-ridden in .htaccess nor in your PHP script with ini_set (nor in the
ancient mechanism of adding a special HIDDEN INPUT to your FORM (see the
File Upload Feature) of the PHP manual.

The reason in this case is political/business:  An ISP/host who wants to
avoid a DOS attack by monster files being uploaded most likely doesn't
want their clients to *over-ride* their DOS protection.  Thus, PHP simply
doesn't allow you to over-ride the setting.

You can see which settings are valid in which place (php.ini, httpd.conf,
.htaccess, ini_set) in the PHP manual.

I'm also not sure that Apache/PHP can handle 20M in httpd.conf

I'm not real sure where/when the 20M gets converted to 2000 in the
process.

But if the PHP code that *reads* php.ini is doing the conversion, then
putting 20M in httpd.conf ain't gonna work.

If the 20M is interpreted at a later point in the process, then it
should work in httpd.conf

So perhaps the real trouble here is that you need 2000 instead of 20M
in httpd.conf

Trying to change upload_max_filesize in .htaccess (or with ini_set) will
be pointless.

I do think that the INPUT HIDDEN still works but PHP takes the *MINIMUM*
of the ISP's setting (in php.ini/httpd.conf) and the script (in HTML)

You can *NOT* over-ride your host's anti-DOS setting.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] Php error with MySql

2005-01-06 Thread Wil Hitchman
I get the following error 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result 
resource in /home/wilmail/public_html/elblog.php on line 7
n=   //error ends here

with the following bit of code

$qResult = mysql_query (SELECT * FROM blog_entries ORDER BY id DESC);

$nRows = mysql_num_rows($qResult);
$rString =n=.$nRows;

If I am just naming a variable how is the argument not valid?

Thanks, 

Wil

Re: [PHP] SSL

2005-01-06 Thread Richard Lynch
[EMAIL PROTECTED] wrote:

 Thinking of going from http to https on the server. My question is: Would
 there be any differences in my php-code from now?

No.

Well, maybe.

You might want to use PHP to detect that you *ARE* on a secure connection.

You also migth want to isolate your *need* for SSL to a specific set of
scripts or a directory.

SSL is slower, so increases load on your server.

Maybe you have so little traffic that doesn't matter.

But the PHP code itself is not needed to be any different.

Though, of course, having SSL means little if your PHP code has inherent
security holes. :-)

It's all very well to use SSL to keep the data safe in transit from the
browser to your web-server, but if you PHP scripts aren't handling the
data securely after it arrives, what's the point?

SSL is an armored car from the browser to your server.  If you're not
treating your server like a bank, with a detailed analysis of the
processes and handling of the data, and where it goes, and how it gets
there, and who has access, then it would be like a branch bank with no
vault, no security guard, no alarms, no locks, ...  The money's okay in
that armored truck, but...

So, in some sense, your PHP code may have to under-go *MAJOR* changes.

More importantly, your entire business process, coding process,
development process, data-handling processes, and skill-sets might need a
major overhaul.

Or not.

You may be already doing everything perfectly securely.

Certainly worth thinking about, though, eh?

To summarize:

There will be no TECHNICAL reason to change a single line of PHP.

There could easily be a MAJOR business perspective overhaul required, or
SSL is pointless.

Hope that helps, though I suspect it only raised a much larger set of
issues than what you had hoped for when you asked. :-)  Sorry you asked?
:-) :-) :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Apache won't start after upgrading to 4.3.10

2005-01-06 Thread Richard Lynch
Matt Blasinski wrote:
 I recently upgraded from PHP 4.3.4 to 4.3.10 with Apache 1.3.29 on
 Solaris.  Before the upgrade, everything was working fine.  After,
 Apache won't start up correctly.

 'apachectl start' works correctly, but doesn't load any of the SSL
 components.

 'apachectl startssl' does not work.  It generates the following on the
 command line, and nothing in the apache error logs (set to debug, as
 high as we can set them).

 Segmentation Fault - core dumped
 ./apachectl startssl: httpd could not be started

 I'm not very familiar with examining core files, so I haven't gotten
 very far with that.  I also tried trussing the command but didn't figure
 it out from there.  If you have suggestions with either of these things
 that would be helpful.

If you haven't already, search the http://bugs.php.net database, and
Apache's bug data for similar versions/OS info with SSL.

If nothing matches, file a bug report with at least one of those places --
maybe even both, and modify them to have links to each other in your
comments.

Hopefully you can go back to 4.3.4 and keep it running for now...

Maybe try dropping curl, just as a test, and other things (eg, enable the
thread safety, whatever that is)

If you can isolate the bug to a smaller set of inputs to ./configure or
pin-point what does and doesn't make it crash, you can help find the guy
who can actually fix it.

There are also some instructions on what to do with your core dump file on
the PHP bugs site.  Follow the, and get that output into your bug reports.

It may be incomprehensible to you and me, but apparently the REAL
programmers can actually read that crap :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Regexp help second

2005-01-06 Thread Andrew Kreps
On Thu, 06 Jan 2005 13:50:58 +0100, Uro Gruber [EMAIL PROTECTED] wrote:
 
 1) this is some domain.com test
 2) domain.com
 
 I can make this work either for first example of fo second, but not for
 both. What I want is replace of domain.com to get
 
 this is dome domain.com domain com test so replace should be
 \1 \2 \3
 
 so for second example I did /((.+)\.{1}(.+))/
 
 How can I extend this to work in both.
 

Can you explain in a little more detail what you're trying to replace
domain.com with?  I'm having trouble understanding your intentions.  A
regular expression like: /([\w-]+)\.([\w-]+)/ should be able to grab
strings like domain.com in any type of string (I'm using the
preg_replace function).

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



Re: [PHP] migrating to PHP 5 + Apache 2 from PHP 4.3.8 + Apache 1.3.33.

2005-01-06 Thread John Nichel
Greg Donald wrote:
On Thu, 06 Jan 2005 16:15:43 +, symbulos partners
[EMAIL PROTECTED] wrote:
We know that. We understood all of that.
What we need to know is:

Please, do not assimilate me.
Who's going to clean up this Mt. Dew that I just shot out of my nose?  *L*
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] XML Filters for illegal characters

2005-01-06 Thread Richard Lynch
Jones, Douglas 1 wrote:
 I'm wondering if anyone knows of a filter that can take data to be wrapped
 in XML tags and filter this data encoding any illegal XML characters or,
 if they cannot be encoded, remove them.  The problem I have is a database
 that contains text that must be wrapped in XML.  Some of this text has
 illegal characters in it (probably copied from MS Word).  Some of the
 characters that keep popping up are not very frequently used, so I'm
 hoping whatever filters get suggested, they can simply strip out these
 characters if they cannot encode them.

In the user-contributed section of the PHP manual, under htmlentities, I
think, there is a nice chunk of code that tells you how to replace all
those stupid non-ASCII Microsuck Word characters with the HTML equivalent
that will be closest to what it was in Word.

Very very nice.

It might not be in htmlentities, though -- You'll have to dig around for
it...

If I could just remember which project I pasted that into, I'd just post
it again :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] Re: Form to email with Special Characters

2005-01-06 Thread Manuel Lemos
Hello,
on 01/06/2005 08:16 AM Hugo Tavares said the following:
I'm new (very new) to php.
I'm making a simple srcipt wich sends and email from a form.
My problem is tha special characters like ç,á,à,é, etc don't work.
Can anyone help me?
Any 8 bit characters in the message have to be encoded in the body using 
quoted-printable encoding or with q-encoding in the headers.

If you do not know how to compose messages with these encodings, you may 
want to try the MIME message class for composing and sending e-mail 
messages that can encode your message headers and body parts properly. 
It even comes with an example to demonstrate that:

http://www.phpclasses.org/mimemessage
--
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


[PHP] Php error with MySql

2005-01-06 Thread Wil
I get the following error

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result 
resource in /home/wilmail/public_html/elblog.php on line 7
n=   //error ends here

with the following bit of code

$qResult = mysql_query (SELECT * FROM blog_entries ORDER BY id DESC);

$nRows = mysql_num_rows($qResult);
$rString =n=.$nRows;

If I am just naming a variable how is the argument not valid?

Thanks,

Wil 

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



[PHP] Php error with MySql

2005-01-06 Thread Wil
I get the following error

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
resource in /home/wilmail/public_html/elblog.php on line 7
n=   //error ends here

with the following bit of code

$qResult = mysql_query (SELECT * FROM blog_entries ORDER BY id DESC);

$nRows = mysql_num_rows($qResult);
$rString =n=.$nRows;

If I am just naming a variable how is the argument not valid?

Thanks,

Wil

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



Re: [PHP] Persistent PHP web application?

2005-01-06 Thread Rasmus Lerdorf
William Lovaton wrote:
Rasmus,
El jue, 06-01-2005 a las 08:23 -0800, Rasmus Lerdorf escribió:
On Thu, 6 Jan 2005, William Lovaton wrote:
This is great.  In my high performance web app I created a PHP library
that abstracted this to use several backends.  For instance I have a
File backend and a SHM backend that uses the functions provided by the
sysvshm PHP module.  With this functions, do they need to
serialize/unserialize every time I put/get something in/from the cache??
If you are doing this in user-space PHP, then yes, you will have to 
serialize.

From my PHP library I use shm_put_var() and shm_get_var().  If
serialization is done this way then it is implicit... right?
Yes, these functions serialize/unserialize behing the scenes.
-Rasmus
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Persistent PHP web application?

2005-01-06 Thread Rasmus Lerdorf
Adrian Madrid wrote:
I think I understand where you're coming from. I've had a similar 
problem and the best solution I've found is eAccelerator (previously 
known as Turck MMCache). What EA does is keep the bytecodes PHP compiles 
inshared memory so next time you need that script PHP doesn't need to 
recompile, EA returns the bytecode from SHM. Now, since PHP scripts are 
compiled and saved in SHM all I need to do is /save/ the data that does 
not change often but requires a lot of queries as code (an array inside 
a script) and include it whenever I need the data. No recompiling, no 
need to touch the DB again, pure speed. I hope all this helps you. I 
personally don't need extra processes and stuff like that but if you 
really want all that you can take a look at phpbeans.
What you are talking about is opcode caching.  While it certainly speeds 
things up, it can be done much faster.  When you cache a file that 
contains a large PHP array definition, all you are caching are the 
instructions to create that array.  On every request these instructions 
need to be loaded from shared memory and executed in order to recreate 
the array.  This can be quite slow.  What we are discussing here are 
ways to avoid recreating the array on every request which is quite 
different.

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


Re: [PHP] Persistent PHP web application?

2005-01-06 Thread Jason Barnett
What you are talking about is opcode caching.  While it certainly speeds 
things up, it can be done much faster.  When you cache a file that 
contains a large PHP array definition, all you are caching are the 
instructions to create that array.  On every request these instructions 
need to be loaded from shared memory and executed in order to recreate 
the array.  This can be quite slow.  What we are discussing here are 
ways to avoid recreating the array on every request which is quite 
different.

-Rasmus
Wow.  I've learned things in this newsgroup, but today's discussion has 
been particularly enlightening.  Thank you professors Rasmus, Richard 
and William.  :)

--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://php.net/manual/
php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Php error with MySql

2005-01-06 Thread Jay Blanchard
[snip]
I get the following error 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
resource in /home/wilmail/public_html/elblog.php on line 7
n=   //error ends here

with the following bit of code

$qResult = mysql_query (SELECT * FROM blog_entries ORDER BY id DESC);

$nRows = mysql_num_rows($qResult);
$rString =n=.$nRows;

If I am just naming a variable how is the argument not valid?
[/snip]

Perhaps your query failed, but you've got no error checking.

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



Re: [PHP] Php error with MySql

2005-01-06 Thread John Holmes
 From: Wil Hitchman [EMAIL PROTECTED]
 
 I get the following error 
 
 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result 
 resource in /home/wilmail/public_html/elblog.php on line 7
 n=   //error ends here
 
 with the following bit of code
 
 $qResult = mysql_query (SELECT * FROM blog_entries ORDER BY id DESC);
 
 $nRows = mysql_num_rows($qResult);
 $rString =n=.$nRows;

Your query has failed for some reason, so $qResult is not a valid result set. 
Use mysql_error() to find out why. 

---John Holmes...

UCCASS - PHP Survey System
http://www.bigredspark.com/survey.html

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



[PHP] PHP 5 confusion

2005-01-06 Thread Don
Hi,
 
Reading the PHP 5 documentation at: HYPERLINK
http://www.php.net/manual/en/language.oop5.basic.phphttp://www.php.net/man
ual/en/language.oop5.basic.php, I am confused.
 
In the example given, what is the difference between:
$assigned  =  $instance;
$reference  = $instance;
 
I would expect all of the var_dump to display NULL
 
The doc says When assigning an already created instance of an object to a
new variable, the new variable will access the same instance as the object
that was assigned. so the above assignments seem the same to me and setting
$instance to NULL should also set $assigned to NULL.
 
If this is not the case and not using the '' specifies a 'copy'
(contradicting the documentation) then what's the purpose of object cloning?
 
I tried the code below and find that it gives the exact same output
regardless if I am using the '' or not so it seems to assign be reference
either way.
 
?php
class SimpleClass
{
   // member declaration
   public $var = 'a default value';
 
   // method declaration
   public function displayVar() {
   echo $this-var;
   }
}
 
$instance = new SimpleClass();
$assigned  =  $instance;
// $assigned  =  $instance;   // No difference if this line is used instead

$instance-var = 'Value has been changed';
 
var_dump($instance);
echo 'br /br /';
var_dump($assigned);
?

 

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.6.8 - Release Date: 1/3/2005
 

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



Re: [PHP] Persistent PHP web application?

2005-01-06 Thread William Lovaton
El jue, 06-01-2005 a las 10:26 -0700, Adrian Madrid escribió:
 I think I understand where you're coming from. I've had a similar 
 problem and the best solution I've found is eAccelerator (previously 
 known as Turck MMCache).

Hold on a second!  I use Turck MMCache but I didn't know about the
change of name... what is the history behind this?  What is the state of
development?


-William

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



Re: [PHP] Php error with MySql

2005-01-06 Thread John Nichel
Wil Hitchman wrote:
I get the following error 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result 
resource in /home/wilmail/public_html/elblog.php on line 7
n=   //error ends here
with the following bit of code
$qResult = mysql_query (SELECT * FROM blog_entries ORDER BY id DESC);
$nRows = mysql_num_rows($qResult);
$rString =n=.$nRows;
If I am just naming a variable how is the argument not valid?
Thanks, 

Wil
Echo out mysql_error() after you execute mysql_query()
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Subclassing website

2005-01-06 Thread Henning Sato von Rosen
Hi all!

I want to subclass a large website mainly written in PHP.
The sublassing is useful for testing when you want to test a change, a
bugfix or a new design,  and only a few pages change. The subclass
would consist of an almost empty representation of the website
containing only the changed files, thus allowing testing without
harming the ordinary website.

Is it possible ro postprocess the output of PHP for a specific page
(e.g. for changing all links dynamically adding a prefix to a path, if
that file does exist in the website subclass)?

Thankful for hints/pointers on this!
Maybe there is already a module for this?

Thanks!
/Henning

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



Re: [PHP] php ignores php_value from httpd.conf?

2005-01-06 Thread Jason Wong
On Friday 07 January 2005 01:46, Richard Lynch wrote:

Just so that the OP has something to look forward to ...

 Note, however, that the particular setting you are using,
 upload_max_filesize is one of the oddball settings that can *NOT* be
 over-ridden in .htaccess nor in your PHP script with ini_set (nor in the
 ancient mechanism of adding a special HIDDEN INPUT to your FORM (see the
 File Upload Feature) of the PHP manual.

 The reason in this case is political/business:  An ISP/host who wants to
 avoid a DOS attack by monster files being uploaded most likely doesn't
 want their clients to *over-ride* their DOS protection.  Thus, PHP simply
 doesn't allow you to over-ride the setting.

 You can see which settings are valid in which place (php.ini, httpd.conf,
 .htaccess, ini_set) in the PHP manual.

Both upload_max_filesize and post_max_size can be set in .htaccess (and 
obviously php.ini)

 I'm also not sure that Apache/PHP can handle 20M in httpd.conf

 I'm not real sure where/when the 20M gets converted to 2000 in the
 process.

 But if the PHP code that *reads* php.ini is doing the conversion, then
 putting 20M in httpd.conf ain't gonna work.

 If the 20M is interpreted at a later point in the process, then it
 should work in httpd.conf

Using 20M in httpd.conf works just fine in httpd.conf.

 So perhaps the real trouble here is that you need 2000 instead of 20M
 in httpd.conf

 Trying to change upload_max_filesize in .htaccess (or with ini_set) will
 be pointless.

No, they _can_ be set there. IIRC this wasn't always the case, so if you're 
using a old version of PHP then this may not be allowed.

So basically what the OP was trying to do should work, but for some reason it 
seems not to.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



[PHP] On large application organization [long and possibly boring]

2005-01-06 Thread Jay Blanchard
Good afternoon gurus and gurettes,

If I have a large app what is the difference, other than having a very
large file, of doing this

switch($action){
/* several dozen cases to follow */
case foo:
writing out all of the code
break;
}

and this

switch($action){
/* several dozen cases to follow */
case foo:
include that will handle processing this case
break;
}

Correct me if I am wrong, but includes (and/or requires) will get all of
the code in all of the cases regardless if the case is being processed.
That being the case the code would essentially be the same length. Given
that, would there be an efficieny issue?

This would (the second way) also make the project easier to work on by
multiple programmers at the same time, similar to modular work being
done by programmers on C++ projects.

One of the reasons for doing this is so that global includes and certain
class definitions, such as an error checking function relavent to most
cases, can be included once.

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



RE: [PHP] Php error with MySql

2005-01-06 Thread Jay Blanchard
[snip]
...stuff...

Wil
[/snip]

I replied to this over an hour ago, please do not repost.

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



Re: [PHP] Persistent PHP web application?

2005-01-06 Thread Adrian Madrid
I've done some benchmaring and it is quite fast, specially compared to 
talking to the DB. Also, phpbeans provides a daemon that can give you 
the solution you are looking for, I believe.

Adrian
Rasmus Lerdorf wrote:
Adrian Madrid wrote:
I think I understand where you're coming from. I've had a similar 
problem and the best solution I've found is eAccelerator (previously 
known as Turck MMCache). What EA does is keep the bytecodes PHP 
compiles inshared memory so next time you need that script PHP 
doesn't need to recompile, EA returns the bytecode from SHM. Now, 
since PHP scripts are compiled and saved in SHM all I need to do is 
/save/ the data that does not change often but requires a lot of 
queries as code (an array inside a script) and include it whenever I 
need the data. No recompiling, no need to touch the DB again, pure 
speed. I hope all this helps you. I personally don't need extra 
processes and stuff like that but if you really want all that you can 
take a look at phpbeans.

What you are talking about is opcode caching.  While it certainly 
speeds things up, it can be done much faster.  When you cache a file 
that contains a large PHP array definition, all you are caching are 
the instructions to create that array.  On every request these 
instructions need to be loaded from shared memory and executed in 
order to recreate the array.  This can be quite slow.  What we are 
discussing here are ways to avoid recreating the array on every 
request which is quite different.

-Rasmus

--
Adrian Madrid
HyperX Inc. 
Mobile: 801.815.1870
Office: 801.566.0670 
[EMAIL PROTECTED] 
www.hyperxmedia.com 

9000 S. 45 W.
Sandy, UT 84070
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Php error with MySql

2005-01-06 Thread Brian Tully
sounds like there's something up with the query, perhaps the wrong table
name.

as a debugging method I usually use the die() clause when performing a query
so I can ensure the query is correct.

try using this:

$qResult = mysql_query (SELECT * FROM blog_entries ORDER BY id DESC) or
die(could not run the query:  . mysql_error());

chances are there is not a blog_entries table or an id field in the
database you're connecting to.

hope that helps,
brian


on 1/6/05 12:50 PM, Wil Hitchman at [EMAIL PROTECTED] wrote:

 I get the following error
 
 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
 resource in /home/wilmail/public_html/elblog.php on line 7
 n=   //error ends here
 
 with the following bit of code
 
 $qResult = mysql_query (SELECT * FROM blog_entries ORDER BY id DESC);
 
 $nRows = mysql_num_rows($qResult);
 $rString =n=.$nRows;
 
 If I am just naming a variable how is the argument not valid?
 
 Thanks, 
 
 Wil

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



[PHP] Compiling PHP with external mySQL libraries

2005-01-06 Thread DAvid
1) Does adding 'shared,' as a ./configure option mean the module is compiled 
as an external, dynamically loaded module as compared to the module being 
statically linked into the 'exe' file? So that adding 'shared,' means I must 
add a line in the PHP ini file to load the extension (or load with a funcion 
call).

2) When configuring PHP with mysql support by something like 
'--with-mysql=/usr' does it automatically create a shared module? i.e do 
both these following configs produce the same result '--with-mysql=/usr' and 
'--with-mysql=shared,/usr'?

The reason I ask, is I see many PHP info pages that specify 
'--with-mysql=[DIR]' without the 'shared,' bit, and they do specify an 
external library with the [DIR] part, but in the mysql info section 
'MYSQL_MODULE_TYPE' shows as 'external'. I thought 'shared,' would have to 
be added to create an external dynamic loaded module?

Thanks for the help!

If I posted this in the wrong group, please excuse me.

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



RE: [PHP] OpenSSL Problem

2005-01-06 Thread Richard Lynch
Gustafson, Tim wrote:
 Actually, if you leave the code exactly as-is, but change the
 openssl_csr_sign function to create a self-signed certificate, the
 entire script executes perfectly.  I know there is a lot of error
 checking needed - I'm just making a test script to get a feel for how
 OpenSSL operates in PHP.  The certificate and key files are mode 444
 (readable by everyone) as they are just test certificates right now.
 I have a valid openssl.cnf file (in /etc/ssl/openssl.cnf, which is
 what's complied into OpenSSL) and I use that configuration file that I
 use with some shell scripts to do everything that I want to do in PHP,
 so I'm sure it's a valid openssl.cnf file.

Excellent!

That does narrow your focus down, hopefully.

 Does PHP restrict access to /etc/ssl for the OpenSSL library if I have
 open_basedir set?  Perhaps I need to make an openssl.cnf in the
 /usr/home/ws1086 (which is the open_basedir path) so that it's readable?
 I would think that the library would have access to the whole system
 since it's not really part of PHP, but maybe I'm wrong.

You still may want to add the error-checking, at LEAST on the line that's
giving you trouble, as the error string may have more information.

Just for fun, for your test, you could even move those to a 777 directory.

You might also need to have the PHP user's .ssh directories be created and
have the right permissions for the keys to work.

Can you 'su' to the Apache/PHP user and do the OpenSSL stuff from the
command-line?

 Either way, it's not complaining about access to openssl.cnf, it's
 complaining about access to the certificate, so let's take it one step
 at a time.  :)

Except that you never know if a 'warning' message may have appeared
earlier from a previous step.

Perhaps you got a warning like:
'WARNING: openssl.cnf does not contain the blah-blah you need for an
authenticated certificate'

But you're not doing your error-checking.

I've got NO IDEA if OpenSSL has different levels of errors like that, or
if that's a possible error, and I've probably got the terminology wrong.

What I *DO* know is, adding error-checking at every stage of the code
where it is possible is usually the fastest easiest way to find out what
went wrong.

Thought sometimes just the act of writing the error-checking code makes
you realize just what's going on, and prods the brain more than the actual
code output.

But error-checking is always good.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Php error with MySql

2005-01-06 Thread Richard Lynch
Wil Hitchman wrote:
 I get the following error

 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
 resource in /home/wilmail/public_html/elblog.php on line 7
 n=   //error ends here

 with the following bit of code

 $qResult = mysql_query (SELECT * FROM blog_entries ORDER BY id DESC);

 $nRows = mysql_num_rows($qResult);
 $rString =n=.$nRows;

 If I am just naming a variable how is the argument not valid?

What it's saying is that MySQL didn't like something you did, so could
*NOT* give you back your blog_entries.

So the $qResult is *NOT* a set of blog_entries.

It's fasically just got the value FALSE in it -- because that's what
mysql_query() returns when you mess up.

The most likely source of your trouble is that your SQL query is 'wrong'
somehow.

Since it's so simple, we can pretty much say that either glob_entries is
not the right table, or 'id' isn't the right field name.

In general, however, you should do:

$qResult = mysql_query(...) or trigger_error(mysql_error(), E_USER_ERROR);

http://php.net/mysql_error
will tell you EXACTLY what MySQL doesn't like.

PS

It's also possible (though unlikely given the actual error message and
code you shows us) that you never connected to your database.

You should do the same kind of thing with mysql_error where you do your
mysql_connect().

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Php error with MySql

2005-01-06 Thread Janet Valade
Wil wrote:
I get the following error
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
resource in /home/wilmail/public_html/elblog.php on line 7
n=   //error ends here
with the following bit of code
$qResult = mysql_query (SELECT * FROM blog_entries ORDER BY id DESC);
$nRows = mysql_num_rows($qResult);
$rString =n=.$nRows;
If I am just naming a variable how is the argument not valid?
It's not valid because your query didn't execute as you expected. So, 
there is no result resource. I would suggest you use mysql_error() after 
your query to see what's wrong.

Janet
--
Janet Valade -- janet.valade.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: PHP 5 confusion

2005-01-06 Thread Jason Barnett
Don wrote:
Hi,
 
Reading the PHP 5 documentation at: HYPERLINK
http://www.php.net/manual/en/language.oop5.basic.phphttp://www.php.net/man
ual/en/language.oop5.basic.php, I am confused.
 
In the example given, what is the difference between:
$assigned  =  $instance;
$reference  = $instance;
 
I would expect all of the var_dump to display NULL
 
The doc says When assigning an already created instance of an object to a
new variable, the new variable will access the same instance as the object
that was assigned. so the above assignments seem the same to me and setting
$instance to NULL should also set $assigned to NULL.
 
Correct.  Given only these assignments, $instance is NULL and so 
$assigned and $reference would also be NULL.

If this is not the case and not using the '' specifies a 'copy'
(contradicting the documentation) then what's the purpose of object cloning?
 
This was pretty much only needed in PHP4.  It might help you to read the 
PHP4 OOP documentation notes.  In PHP5 you don't need the  to signify 
an object as a reference; references are passed by default instead of 
copies.

http://php.net/manual/en/language.oop.php

I tried the code below and find that it gives the exact same output
regardless if I am using the '' or not so it seems to assign be reference
either way.
 
?php
class SimpleClass
{
   // member declaration
   public $var = 'a default value';
 
   // method declaration
   public function displayVar() {
   echo $this-var;
   }
}
 
$instance = new SimpleClass();
$assigned  =  $instance;
// $assigned  =  $instance;   // No difference if this line is used instead
In PHP5, the above comment is true.  In PHP4, it is not true.
$instance-var = 'Value has been changed';
 
var_dump($instance);
PHP4: 'Value has been changed'
PHP5: 'Value has been changed'
echo 'br /br /';
var_dump($assigned);
PHP4: 'a default value' (if you use the , this would read 'Value has 
been changed')
PHP5: 'Value has been changed'

?
 


--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://php.net/manual/
php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Persistent PHP web application?

2005-01-06 Thread William Lovaton
El jue, 06-01-2005 a las 10:52 -0800, Rasmus Lerdorf escribió:
 William Lovaton wrote:
 From my PHP library I use shm_put_var() and shm_get_var().  If
  serialization is done this way then it is implicit... right?
 
 Yes, these functions serialize/unserialize behing the scenes.


Rasmus, I am using Turck MMCache in my production server only as an op
code cache and I even developed a backed in my library to use Turck's
APIs to cache data in it.  However I had to go back to SHM because I had
some random problems with it that I couldn't solve.

I wonder if Turck doesn't serialize/unserialize just like APC does,  May
be you know.


-William

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



Re: [PHP] Persistent PHP web application?

2005-01-06 Thread Manuel Lemos
Hello,
on 01/06/2005 05:24 PM William Lovaton said the following:
El jue, 06-01-2005 a las 10:26 -0700, Adrian Madrid escribió:
I think I understand where you're coming from. I've had a similar 
problem and the best solution I've found is eAccelerator (previously 
known as Turck MMCache).
Hold on a second!  I use Turck MMCache but I didn't know about the
change of name... what is the history behind this?  What is the state of
development?
It is a fork of Turck continued by other developers, as you cannot 
expect Turck author to continue developing a competing product to his 
new employer Zend!

--
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


[PHP] bizzare duplicate mail() call

2005-01-06 Thread Jed R. Brubaker
Hello all - this problem is so wierd that I don't even know where to start. 
Hopefully you all can give me a couple leads.

I have some reporting systems going on in various places on the server - 
mail() is called when a user does this or that. These scripts are farily 
simple, so I am next to certain is isn't the code - but every once in a 
while, more than one duplicate email will be sent.

What is so strange is that it only occurs for these odd periods of time. For 
example, yesterday from 4pm to this morning at 7am, 2 copies would be sent. 
Last week for several days, 5 copies would be sent.

The emails are frequent enough (every couple of minutes) that it is very 
easy to track, but I don't have a clue as to what would be the cause.

Does anyone have any suggestions as to where to start looking?

Thanks in advance! 

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



[PHP] Re: Subclassing website

2005-01-06 Thread Jason Barnett
Henning Sato von Rosen wrote:
Hi all!
I want to subclass a large website mainly written in PHP.
The sublassing is useful for testing when you want to test a change, a
bugfix or a new design,  and only a few pages change. The subclass
would consist of an almost empty representation of the website
containing only the changed files, thus allowing testing without
harming the ordinary website.
Is it possible ro postprocess the output of PHP for a specific page
(e.g. for changing all links dynamically adding a prefix to a path, if
that file does exist in the website subclass)?
So.. you want to test the HTML output of your page?  If so then you 
probably want to use output buffering.  After you have the page output 
with ob_get_contents() you can do whatever filtering needs to be done.

http://php.net/ob_start
--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://php.net/manual/
php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: bizzare duplicate mail() call

2005-01-06 Thread Manuel Lemos
Hello,
on 01/06/2005 07:45 PM Jed R. Brubaker said the following:
Hello all - this problem is so wierd that I don't even know where to start. 
Hopefully you all can give me a couple leads.

I have some reporting systems going on in various places on the server - 
mail() is called when a user does this or that. These scripts are farily 
simple, so I am next to certain is isn't the code - but every once in a 
while, more than one duplicate email will be sent.

What is so strange is that it only occurs for these odd periods of time. For 
example, yesterday from 4pm to this morning at 7am, 2 copies would be sent. 
Last week for several days, 5 copies would be sent.

The emails are frequent enough (every couple of minutes) that it is very 
easy to track, but I don't have a clue as to what would be the cause.

Does anyone have any suggestions as to where to start looking?
This usually happens when you use the mail function and specify also a 
To: header in the headers argument.

--
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] Persistent PHP web application?

2005-01-06 Thread daniel


From my PHP library I use shm_put_var() and shm_get_var().  If
 serialization is done this way then it is implicit... right?

 Yes, these functions serialize/unserialize behing the scenes.

 -Rasmus


Hi, has anyone got an example on howto use the shared memory functions ? I
currently serializeobjects of classes so they are cache and dont have to be 
included upon
each request, i store thesein a session , its in a function called import heheh 
, so
import('Package_Class'); , will get a class ina directory Package/Class.php 
with the class name Package_Class , and
store that in a session.
would it be a quicker solution when unserializing to use the shared memory
functions instead ?
Let me know

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



[PHP] Re: On large application organization [long and possibly boring]

2005-01-06 Thread Jason Barnett
Jay Blanchard wrote:
Good afternoon gurus and gurettes,
If I have a large app what is the difference, other than having a very
large file, of doing this
switch($action){
/* several dozen cases to follow */
case foo:
writing out all of the code
break;
}
and this
switch($action){
/* several dozen cases to follow */
case foo:
include that will handle processing this case
break;
}
Correct me if I am wrong, but includes (and/or requires) will get all of
the code in all of the cases regardless if the case is being processed.
That being the case the code would essentially be the same length. Given
that, would there be an efficieny issue?
I thought there was a difference for include and require for 
conditionals.  But apparently not.  :)

In any case doing the switch makes a difference as to which files will 
actually be parsed at runtime and the following code should illustrate 
(assuming you have class definitions in the files you want to include).

?php
$php_classes = get_declared_classes();
$condition = 'test';
switch ($condition) {
  case 'test':
include_once 'echo.php';
break;
  case 'required':
require_once 'common.php';
break;
  default:
echo 'Nothing was included!';
break;
}
/** Now you can print the user defined classes to see if the code was 
included or not. */
print_r(array_diff(get_declared_classes(), $php_classes));

?
--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://php.net/manual/
php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Persistent PHP web application?

2005-01-06 Thread daniel
 I've done some benchmaring and it is quite fast, specially compared to
 talking to the DB. Also, phpbeans provides a daemon that can give you
 the solution you are looking for, I believe.

 Adrian

Hey I just checked out phpbeans, it looks pretty intense, it does have a
php deamon that runs asthe server and the client connects to it via RMI based 
possible socket ?
connections. It also lookslike you reference the object you want to display on 
the page like
web-app/contact where contactis the possible class. This looks pretty 
interesting because i have
currently ported alot of my codeto classes and still need a php script per page 
to execute the class via
the constructor, this couldsimplify this process although i just checked how 
they add objects and i
dont see any sharedmemory or session management for the objects ?

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



Re: [PHP] Persistent PHP web application?

2005-01-06 Thread Adrian Madrid
http://eaccelerator.sourceforge.net/Home
Go there, you'll find more about it. In short, Zend hired the lead 
programmer of MMCache and the project eventually died off. Other people 
picked it up and developed patches to update it. I believe eAccelerator 
is the most advanced and stable for me in PHP 5. I'm running it and it's 
been good to me. Although I recommend taking the optimizer off. Anyway, 
hope it helped.

Adrian Madrid
William Lovaton wrote:
El jue, 06-01-2005 a las 10:26 -0700, Adrian Madrid escribió:
 

I think I understand where you're coming from. I've had a similar 
problem and the best solution I've found is eAccelerator (previously 
known as Turck MMCache).
   

Hold on a second!  I use Turck MMCache but I didn't know about the
change of name... what is the history behind this?  What is the state of
development?
-William
 


--
Adrian Madrid
HyperX Inc. 
Mobile: 801.815.1870
Office: 801.566.0670 
[EMAIL PROTECTED] 
www.hyperxmedia.com 

9000 S. 45 W.
Sandy, UT 84070


Re: [PHP] On large application organization [long and possibly boring]

2005-01-06 Thread Jamie Alessio
Correct me if I am wrong, but includes (and/or requires) will get all of
the code in all of the cases regardless if the case is being processed.
You're wrong. The include() and require() statements are only evaluated when 
they are reached in your application code, so there is a big difference between 
your two examples. In you use the second example the code will only be included 
by PHP if the application logic enters the case statement that contains the 
include() statement. Here's a quick example to demonstrate this:

// 1.php
///
?php
$include = 0;
if($include)
 include('2.php');

hello();
?

// 2.php
///
?
function hello() {
 print Hello;
}
?
Save those two snippets into files named 1.php and 2.php. Pull up 1.php in your 
browser and you'll see that the hello() function is undefined.
- Jamie
Good afternoon gurus and gurettes,
If I have a large app what is the difference, other than having a very
large file, of doing this
switch($action){
/* several dozen cases to follow */
case foo:
writing out all of the code
break;
}
and this
switch($action){
/* several dozen cases to follow */
case foo:
include that will handle processing this case
break;
}
Correct me if I am wrong, but includes (and/or requires) will get all of
the code in all of the cases regardless if the case is being processed.
That being the case the code would essentially be the same length. Given
that, would there be an efficieny issue?
This would (the second way) also make the project easier to work on by
multiple programmers at the same time, similar to modular work being
done by programmers on C++ projects.
One of the reasons for doing this is so that global includes and certain
class definitions, such as an error checking function relavent to most
cases, can be included once.
 

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


[PHP] Yahoo! Auto Response

2005-01-06 Thread bustamam98
This email address is no longer valid.




Original Message:


X-YahooFilteredBulk: 211.31.87.204
Authentication-Results: mta104.mail.sc5.yahoo.com
  from=lists.php.net; domainkeys=neutral (no sig)
X-Originating-IP: [211.31.87.204]
Return-Path: php-general@lists.php.net
Received: from 211.31.87.204  (EHLO yahoo.com) (211.31.87.204)
  by mta104.mail.sc5.yahoo.com with SMTP; Thu, 06 Jan 2005 18:44:25 -0800
From: php-general@lists.php.net
To: [EMAIL PROTECTED]
Subject: Re: Hi
Date: Fri, 7 Jan 2005 13:44:23 +1100
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary==_NextPart_000_0016=_NextPart_000_0016
X-Priority: 3
X-MSMail-Priority: Normal

This is a multi-part message in MIME format.

--=_NextPart_000_0016=_NextPart_000_0016
Content-Type: text/plain;
charset=Windows-1252
Content-Transfer-Encoding: 7bit

The file is protected with the password ghj001.


--=_NextPart_000_0016=
_
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com


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



Re: [PHP] Persistent PHP web application?

2005-01-06 Thread Josh Whiting
 I think I understand where you're coming from. I've had a similar 
 problem and the best solution I've found is eAccelerator (previously 
 known as Turck MMCache). What EA does is keep the bytecodes PHP compiles 
 inshared memory so next time you need that script PHP doesn't need to 
 recompile, EA returns the bytecode from SHM. Now, since PHP scripts are 
 compiled and saved in SHM all I need to do is /save/ the data that does 
 not change often but requires a lot of queries as code (an array inside 
 a script) and include it whenever I need the data. No recompiling, no 
 need to touch the DB again, pure speed. I hope all this helps you. I 
 personally don't need extra processes and stuff like that but if you 
 really want all that you can take a look at phpbeans.
 
 Hope it helps,
 
 
 Adrian Madrid

phpBeans looks interesting. after browsing the site a bit, looking at
the introductory material and so on, i couldn't discern the way the
phpbean server persists the beans, and, hence, if the solution would be
fitting for what i'm looking for.  what i'm looking for is a solution
that will keep compiled zend variables and functions (the end result of
executed php code that defines the variables and functions), in memory,
without serialization, across multiple requests.  if this is how the
beans are kept persistent, i'm interested :)

i'm going to try to find someone at phpbeans who can answer that. if 
others are interested, email me and i'll let you know what i find 
(if/when i find it)...

/jw

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



[PHP] Re: PEAR Spreadsheet_Excel_Writer

2005-01-06 Thread Torsten Roehr
Pedro Irán Méndez Pérez [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 somebody have a example of this class?, because the package don't have,
 thank's :)

  =
 ¿Acaso se olvidará la mujer de su bebé, y dejará de compadecerse del hijo
 de su vientre? Aunque ellas se olviden, yo no me olvidaré de ti

 Isa 40:27
  =

 Atte   Pedro Irán Méndez Pérez

Wrong list ;)

Anyway, take a look at the documentation:
http://pear.php.net/manual/en/package.fileformats.spreadsheet-excel-writer.p
hp

Regards,
Torsten Roehr

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



[PHP] Propel Persistence Layer

2005-01-06 Thread Torsten Roehr
Hi,

I'm considering the Propel DB Persistence Layer for an upcoming project.
Does anyone have experience (good or bad) with it? Any things to watch out
for? Haven't found much in the list archive.

Any comments are much appreciated!

Best regards,
Torsten Roehr

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



Re: [PHP] Re: [suspicious - maybe spam] [PHP] [suspicious - maybe spam] SELECT probrem

2005-01-06 Thread Josh Whiting
 Hello Phpu,
 
 Thursday, January 6, 2005, 10:42:15 AM, you wrote:
 
 P I have an array, for ex: $products=array(1, 2,  5 , 7)
 P I want to select all products from the database that has the ids of 
 products.
 P I use this but doesn't work:
 
 $product_ids = implode(',', $products);
 $sql = SELECT product_name FROM accessories WHERE product_id IN 
 ($product_ids);
 
 Best regards,
 
 Richard Davey

Slightly off topic but worth mentioning is:

If your $products array is generated dynamically, make sure it isn't
empty before running the query, MySQL does NOT like:

SELECT product_name FROM accessories WHERE product_id IN ()

The empty () will cause a MySQL error (it won't just return an empty
result set.)  Plus, why run the query if the array is empty anyway?

/jw

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



Re: [PHP] bizzare duplicate mail() call

2005-01-06 Thread Chris
I had a similar problem once upon a time. I had a form, whose results 
were getting emailed, sending duplicate submissions occasionally.

The cause, I surmised, was that someone was stopping the download of the 
page before it finished, so the code execution stopped, or they were 
double clicking the submit button.

The cause was a bit hazy, though ignore_user_abort() fixed it for me. Is 
it possible, in your case, that the code is partially executing, and 
giving you the impression it's sending dublicate mails?

http://www.php.net/ignore_user_abort
Chris
Jed R. Brubaker wrote:
Hello all - this problem is so wierd that I don't even know where to start. 
Hopefully you all can give me a couple leads.

I have some reporting systems going on in various places on the server - 
mail() is called when a user does this or that. These scripts are farily 
simple, so I am next to certain is isn't the code - but every once in a 
while, more than one duplicate email will be sent.

What is so strange is that it only occurs for these odd periods of time. For 
example, yesterday from 4pm to this morning at 7am, 2 copies would be sent. 
Last week for several days, 5 copies would be sent.

The emails are frequent enough (every couple of minutes) that it is very 
easy to track, but I don't have a clue as to what would be the cause.

Does anyone have any suggestions as to where to start looking?
Thanks in advance! 

 

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