[PHP] Cache-Control: no-cache and browser back button problem

2002-02-10 Thread Steven Haryanto

why does the cache control header generated by php (under 
session_cache_limiter = nocache) needs to have no-store? It 
makes pressing Back in the browser requests a new version of the 
page (which is unwanted in some situations, e.g. while filling 
form and needs to edit a few fields before re-submitting).

Also, when I am editing the script and had a fatal error (like a 
PHP syntax error), the stored version of the page by the browser 
is always the one with a fatal error, and I need to always 
refresh to get the current version (I am using a 'Never check 
for newer versions of pages' in my browser, which is fine for 
most circumstances).

Can I remove the 'no-store' parameter from the generated 
Cache-Control header, without resorting to session_cache_limiter 
= private (since this also have some Refresh problems in IE)?

--
sh


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




[PHP] POST data is lost on PHP CGI after shmat() failed. [4.0.5, Linux]

2001-07-13 Thread Steven Haryanto

I have two CGI PHP installation on my Linux system. One of them is
a vanilla build (all defaults except --prefix and
--with-config-file-path, and the other is built with the .spec file
from rpms.arvin.dk).

POST method does not work with the arvin PHP CGI binary, while it
works ok with the vanilla one and with other non-PHP CGI scripts.
After spending a full day focusing on environment variables and
Apache configuration (which is a custom one), I run strace on a
simple script using the arvin PHP. Here's the partial output:

...
shmget(IPC_PRIVATE, 33554432, IPC_CREAT|0x180|0600) = 5079044
shmat(5079044, 0, 0)= -1 ENOMEM (Cannot allocate memory)
shmctl(5079044, IPC_RMID, 0)= 0
close(0)= 0
unlink(/tmp/session_mm.sem)   = -1 ENOENT (No such file or directory)
brk(0x8155000)  = 0x8155000
brk(0x8156000)  = 0x8156000
open(./php.ini, O_RDONLY) = -1 ENOENT (No such file or directory)
open(/etc/php.ini, O_RDONLY)  = 0
getcwd(/path/to/script, 4095) = 46
lstat(/etc, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat(/etc/php.ini, {st_mode=S_IFREG|0644, st_size=20430, ...}) = 0
brk(0x815b000)  = 0x815b000
ioctl(0, TCGETS, 0xb828)= -1 ENOTTY 
(Inappropriate ioctl for device)
read(0, [PHP]\n\n;;;\n; Abo..., 8192) = 8192
read(0, \t; C, E  S respectively, often ..., 8192) = 8192
brk(0x815c000)  = 0x815c000
read(0, t_password\t\t=\t\t; default passwor..., 8192) = 4046
read(0, , 4146)   = 0
...

I am not sure what line of code does the close(0) on the fourth line
shown above, though it has something to do with the MM library, since
after I rebuild PHP --without-mm, all is well.

Could someone shed a light on this?

Regards,
Steve


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] php not run as cgi.

2001-07-01 Thread Steven Haryanto

On 01/07/2001 02:49, Jack wrote:
hi everyone,
  Does anyone know the best way to secure php source code so it is not
group/world readable?
I can read other users' php source code by writing a simple php script.
I do not prefer to run php as cgi because all user's php file need to
add the header
#/usr/bin/php again.

there are two patches that i know, one for suexec and one for cgiwrap,
that allows you to run php scripts as cgi without having to chmod 755
or add a shebang line. i have used them both (well, i wrote the first
one, but now i use the cgiwrap one) and it seems to be running okay.
no guarantees though.

for suexec:

http://groups.yahoo.com/group/diskusihosting/files/Steven/apache_1.3.19-phpcgi-noshebang-suexec_only.patch

for cgiwrap:

http://w3.man.torun.pl/~makler/patches/cgiwrap/

--
sh


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] ok, are servlets/jsp faster than php4?

2001-05-20 Thread Steven Haryanto

yes, i have discovered recently that php is not as fast as it
is hyped to be. don't get me wrong. php is fast, but it depends
on how you arrange your scripts. if you include a lot of library
code (PEAR, etc etc), the overhead would increase and increase.
i thought php has always cached compiled scripts (since it is
fast enough for me so far), but the fact is it does not. without
cacher like apc or zend cache, mod_php is no better than cgi,
except it avoids per-request forking and configuration parsing.

why oh why doesn't php/plain zend cache scripts in the first
place? :-/

Regards,
Steve

On 20/05/2001 20:53, Christopher Leigh wrote:
ok, are servlets/jsp faster than php4?
since zend cache isn't free... :(


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] hosting closed web application for multiple users

2001-05-19 Thread Steven Haryanto

I have a requirement like this:

- the php script should be runnable by httpd user only.
- the php script will include other files.
- the php script should run as the user.
- the user must not be able to access the source code
   of the scripts.

What I can think of so far:

Put the script in a directory only accessible by the
httpd user (www), e.g.:

  # mkdir -p /home/app
  # cp script.php /home/app
  # chown root.www /home/app
  # chmod 550 /home/app
  # chown root.root /home/app/script.php
  # chmod 555 /home/app/script.php

So script.php is safe from the user (except when somehow
the user manages to get its current directory changed to
/home/app, where then she can take script.php easily).

To prevent the user getting her hands to the script.php
via www user, I set the Apache configuration:

  Options SymLinksIfOwnerMatch

to prevent the user linking to /home/app or
/home/app/script.php (unless the user can trick www or
some other privileged user to create the link for her).

and makes sure that Apache only runs wrapped CGI scripts,
and php runs as a cgi binary and not server module.

Now I just need to make sure that:

1) user cannot trick script.php to read and display itself
out to the browser, or copy itself to some public
directory.

2) user cannot trick other root processes to read
script.php for her.

Is there a better alternative?

Regards,
Steve 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] hosting closed web application for multiple users

2001-05-19 Thread Steven Haryanto

Actually, We _are_ considering of buying Zend Encoder, but in the
middle of thinking for alternatives... :-)

However, sometimes vendors do not want user to have access to
the _binary also_ (and then run it somewhere else), so that needs
some extra protection other than the Encoder too.

Regards,
Steve

At 19/05/2001 21:47, Craig Vincent wrote:
snip
2) user cannot trick other root processes to read
script.php for her.

Is there a better alternative?
/snip

Depending on your budget yes there is.  Zend has a PHP encoding utility
which performs two functions, first off since it needs to run through their
optimizer your PHP scripts will tend to run faster (at the expense of a bit
more memory consumption) and also you don't need to worry about preventing
the source code from being read as the php scripts are converted into a
binary executable.  License to use these programs are I believe around $600
per year but offer a wide range of additional features but I would consider
it well worth it to a company rather than spending countless tech hours and
security testing to prevent the source from being viewed.

http://www.zend.com

Sincerely,

Craig Vincent


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] hosting closed web application for multiple users

2001-05-19 Thread Steven Haryanto

btw, have people tried apc 1.0.9 with php-4.0.5? apc runs fine
for some of my scripts (though performance improvement is not
great at all, or am i doing something wrong). but for some of
my more complex scripts, it crashes the httpd binary with
segfaults.

btw, can you just take the compiled cache file and distribute
it? does the file need to be run with apc also? or can the
plain zend engine handle it?

steve

At 19/05/2001 22:45, Matthias Winkelmann wrote:


  -Original Message-
  From: Steven Haryanto [mailto:[EMAIL PROTECTED]]
 
 
  I have a requirement like this:
 
  - the php script should be runnable by httpd user only.
  - the php script will include other files.
  - the php script should run as the user.
  - the user must not be able to access the source code
 of the scripts.
 

Take a look at apc (apc.communityconnect.com), it is primarily a cache,
which will boost your performace, but also allows you to take the cached
compiled files from the file system and distribute them.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] is mod_php4 faster than mod_perl?

2001-05-19 Thread Steven Haryanto

apples  oranges. :)

but mod_php without cache (e.g., zend cache) still suffers
from an overhead of recompiling scripts in every request
(serious overhead if the site is complex).

--
sh

On 19/07/2001 11:03, Christopher Leigh wrote:
i'm wondering if mod_php4 is faster than mod_perl.

thank you,


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] class (not class instance) variables

2001-05-05 Thread Steven Haryanto

Am I correct that PHP does not support class variables? That is,
variables that belong to a class and not copied into every object.
I need to put several arrays for information about a class, and I
do not want to bloat every object with this data (since potentially
I will create many instances of the class).

Currently I do this with methods. Any other alternative?

--
sh 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Please review our coding standards

2001-05-02 Thread Steven Haryanto

At 5/2/2001 12:46 PM, Anuradha Ratnaweera wrote:

Most of your guidelines match with our practices. Here are some comments.

Thanks for the comments.

  1.4 Whitespaces
 
   - No whitespace after function or method name. Example:
 
   exit()

We also use this. But I have seen others using spaces. Even there are some
examples in php-manual with spaces (e.g. array_shift).

Actually I took most of the points in the 'Whitespaces' section from
Guido's Python Style Guide. Most of the points are not really a big
deal, but I usually suggest at least making a distinction between ()
for functions and () for statements.

  for (;;)
  if (..)

  exit();
  die();

  1.6 Quotes
 
   Use whichever ones you like. But if you can use '' for simple strings,
   and  only if you need interpolation.

This should _very_slightly_ improve performance too.

Yup, though I have never thought of benchmarking this :)

  4. File organization

We use WML (website meta language - www.engelschall.com/sw/wml/) with make
to produce single php files and do _not_ use the include feature of php.

Also, we have written scripts that creates diff files between releases.

Interesting. How do you find WML so far? I evaluated WML once in
the past, but it seemed too complex to me then...

  6. Creating documentation

We use tex, and we are planning to go for texinfo.

Do you also embed these in the PHP scripts? I prefer this way
(like Perl's POD, Java's Javadoc, Python's docstrings), because
it is much easier to synchronize with the code. Also, since I
often write the documentation first and then write some code,
I prefer putting them together.

Steve


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] template solutions?

2001-05-01 Thread Steven Haryanto

Cool. I didn't know that.

Does FastTemplate support nested loop and ifs?

Steve

At 5/1/2001 10:33 PM, Henning Kilset Pedersen wrote:
Fasttemplate supports loops and if's.

You set a dynamic block like so:

!-- BEGIN DYNAMIC BLOCK : rowset --
TR
  {ROWCONTENT}
/TR
!-- END DYNAMIC BLOCK : rowset --

And then in the PHP code that parses this html template (.tpl, for example)
file, you do a $tpl-assign (.ROWCONTENT, rowdata);

and loop over that. the .ROWCONTENT means that you're ADDING data to a
variable that already exists. Replace rowdata with the data for the row in
question.

Isn't this what you want??


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] template solutions?

2001-05-01 Thread Steven Haryanto

At 5/1/2001 06:49 PM, Michael Kimsal wrote:
The 'security' angle is the only one I consider terribly valid, an was
what I had in mind when I said I can't think of too many reasons why a
packaged' template' solution is in order.  Obviously it is for you.

I still believe that in most cases it doesn't make much sense to use one,
for most people, because it's limiting you to a subset of a powerful
language, and the implementation can be slower.  Smarty is on the right
track by compiling the templates to PHP and cacheing them.

What I'd *love* to see is a template system which is portable between
various platforms (JSP, CF, PHP, Perl, VBScript).  That would, imo, make
it worhtwhile for people to learn *one* templating system that would be
cross-platform.

That is where a template system like HTML::Template excels, actually.
It is very simple to implement it in Perl, PHP, Tcl, etc etc.

Steve


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] template solutions?

2001-04-30 Thread Steven Haryanto

Actually, not using a programming language is the point of template,
since I do not want to expose anything other than some template
'variables' to the template.

Steve

At 5/1/2001 12:36 AM, Michael Kimsal wrote:
Why not just use PHP in the template?  That's kinda what it was made for.

On Sun, 29 Apr 2001, Steven Haryanto wrote:

  Does anyone know a rather advanced template solution in PHP?
  At least one that supports loop and if (like HTML::Template),
  and directives/commands would be nice (like Perl's Template
  Toolkit).
 
  I am currently rolling my own, but still not happy with the
  result of the design. I'd be happy to use one that is already
  out there.
 
  Steve


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] template solutions?

2001-04-30 Thread Steven Haryanto

See the philosophy behind HTML::Template for explanation on this:

http://www.perlmonth.com/features/template/template.html?issue=11

Not everything with loops and IFs is a programming language. I would
probably call PDF or RTF a programming language too if it were.

Steve


At 5/1/2001 01:10 AM, Michael Kimsal wrote:
No, you're asking for something with loops and IFs.  That's a programming
language.


On Tue, 1 May 2001, Steven Haryanto wrote:

  Actually, not using a programming language is the point of template,
  since I do not want to expose anything other than some template
  'variables' to the template.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] template solutions?

2001-04-30 Thread Steven Haryanto

At 5/1/2001 01:43 AM, Michael Kimsal wrote:
I understand completely what you're getting at already, but PHP is
designed to do what you're asking to do.

I know there are valid reaons for stripped down implementations, but can't
think of too many.

Clean separation of content and presentation? That is one strong
point (for some people anyway).

Ease of use? I want to let *other people* customize the web page to
some extent, but surely do not want to require them to learn PHP.

Security? I do not want other people to have access to the PHP runtime
(where they can do nasty things like stealing my database password,
etc). PHP currently does not support any restricted execution of user
code whatsoever.

For some applications, sometime I don't even want people to *know*
that I am using PHP.

And actually, I would consider RTF or PDF to be
languages unto themselves.  There's a full syntax to use to get specific
results, and if you're throwing conditionals in there, or variables, it's
hard to see how it's not a language.  Maybe not full-featured, but a
language nonetheless.

I agree. But you said earlier, programming language. Programming
languages are used to create *programs*. These perhaps can be
loosely called document languages.

--
sh


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] template solutions?

2001-04-30 Thread Steven Haryanto

At 5/1/2001 01:43 AM, Fabian Raygosa wrote:
Maybe this is what you are looking for
http://www.thewebmasters.net/php/FastTemplate.phtml

Nope. I was looking for a template that supports loops and
IFs. Someone pointed me to php dreamtime:

  http://www.phptemplates.org/

which is a cool project, by the way.

Btw, I think I might need some extra tags to my template
language so I'm going to hack this on by myself at the
time being.

Thanks,
Steve


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] template solutions?

2001-04-30 Thread Steven Haryanto

I was not referring to safe mode.

In other languages like Perl or Python, safe execution means
that if I execute some code (or eval a code string supplied by
user), I can restrict what kinds of operation is valid for it,
or what kinds of variables are available to it.

In PHP, if I have my database password in a global var $dbpass,
I cannot prevent this code:

  eval('echo $dbpass');

from printing my database password. Well of course you could do
unset($dbpass) or even unset($GLOBALS) or save it to somewhere
else... But still I cannot even prevent things like this:

  eval('echo 1/0');

from stopping my own program because it generates an error that
I cannot trap. Well, actually there is error handlers...

Perhaps you can get your way around to make eval() more secure,
but still I prefer not to trust a code string from user to be
eval()'ed by my PHP script. Just letting a user modify a template
and changing the look of a page is sufficient for me, since that
is all the user is supposed to gain access to.

Regards,
Steve


At 5/1/2001 02:23 AM, Dave Goodrich wrote:

On Monday, April 30, 2001, at 12:02 PM, Steven Haryanto wrote:

Security? I do not want other people to have access to the PHP runtime
(where they can do nasty things like stealing my database password,
etc). PHP currently does not support any restricted execution of user
code whatsoever.
in httpd.conf

VirtualHost 192.168.3.8
 DocumentRoot /usr/local/www/thisUser
 ServerName thisUser.myServer.com
 php_value include_path /usr/local/www/thisUser/inc
 php_value open_basedir /usr/local/www/thisUser
/VirtualHost

You could do a lot to control your users abilities/privleges in this way.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] template solutions?

2001-04-30 Thread Steven Haryanto

At 5/1/2001 03:05 AM, Dave Goodrich wrote:
In PHP, if I have my database password in a global var $dbpass,
I cannot prevent this code:

  eval('echo $dbpass');
Never put your DBPass into a GLOBAL ;^)

Hm, perhaps creating a function do_connect('hostname','user','pass')
is safer? Good idea.

Agreed, it's not worth your time and hassle to try and predict 
every possible circumstance a user might try.
Have you thought about some SSI and a few Javascripts? 
depending on what you mean by changing the look of a page it might be easier.

Mm. I still prefer a template, thank you :)

A stupid question but I gotta ask, have you looked through 
freshmeat? lots of stuff like this done in Perl, Python, PHP.

Yes, I have done a search on freshmeat and sourceforge for
php templates. Btw, there are eazytemplates and php
dreamtime that I've been told that supports ifs and loops.
That's nice. Thanks to everybody who responded.

Steve


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] template solutions?

2001-04-29 Thread Steven Haryanto

Does anyone know a rather advanced template solution in PHP?
At least one that supports loop and if (like HTML::Template),
and directives/commands would be nice (like Perl's Template
Toolkit).

I am currently rolling my own, but still not happy with the
result of the design. I'd be happy to use one that is already
out there.

Steve


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] MySQL capabilities

2001-04-29 Thread Steven Haryanto

This is perhaps more suited on mysql mailing list, but anyway...

On 4/29/2001 06:18 PM, José León Serna wrote:
  Hello:
  Since no one asks my question about access to InterBase from PHP, I'm
  considering MySQL ;-)

  I would like to know more about the reliability and functionality from PHP
  users, I'm going to make searchs on a database with big text in Blob fields.
  Right now, in my web (it's made in Delphi) I'm using the Rubicon product to
  make searchs on a database and it works really fast, my questions are:
  Can I use MySQL to search for a substring in a Memo Field?

yes. mysql 3.23.25 even supports full text searching. search
for FULLTEXT in mysql manual.

  Can I tell MySQL to only returns me a subset of results, I mean only 10
  results?

yes, this is one of the conveniences of MySQL, thanks to its
LIMIT clause.

  How fast is MySQL?

relatively very fast, since it supports only a subset of
SQL standards.

  I have a database with 11000 records (not too many) but
  with a big Memo Field and I want to search for words to show the results
  that match the users query.

use FULLTEXT indexing. before MySQL has this, I wrote KwIndex.
You might find it useful:

http://steven.haryan.to/php/KwIndex.html

There's also various full text indexing package you can use:
htdig, glimpse, etc. Most of them work best with content in
filesystem though.

Steve


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Where is php.ini located by default?

2001-04-28 Thread Steven Haryanto

btw, i found that the configure option:

  --with-config-file-path=PATH

is slightly misleading, as PATH to usually refers to a file
location. moreoever, php does not report if it fails to read
a php.ini. perhaps the text should be rewritten as:

  --with-config-file-path=DIR

Steve


At 4/28/2001 11:37 AM, Martin =?ISO-8859-4?Q?Skj=F6ldebrand?= wrote:
I've built php from a tarball. Now I need to specify a special include path
in the php.ini file. But I can't find it. There is a php.in-dist in the
build catalog but I can't find a production php.ini anywhere.
The docs says that it should be in the install catalogue (which is where?,
/usr/local/lib/php doesn't have one) or the cwd. I've tried editing the
sample file and putting it in either place but my app still gives me the
following error:

Failed opening required 'class.DBI' (include_path='.:/usr/local/lib/php')
in FILENAME

Martin S.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Please review our coding standards

2001-04-28 Thread Steven Haryanto
 is familiar to this idiom. It is simple, and
 simplicity matters because we will do a bunch of these.

 So what we do is store the PEAR_Error object in the object attribute
 (recommended name is $error). And we can also use raiseError() directly
 if you think the error should potentially stop execution if needed (if
 you want to use this style, your class must be a descendant of PEAR).

   function yourMethod($foo) {
   if ($bar) {
   # an error condition...
   $this-error = $this-raiseError($msg);
   return;   // return false
   }
   return 1;   // return success
   }

   if ($obj-yourMethod($foo)) {
   # react accordingly. PEAR_Error is available in $obj-error;
   }

 This is like the C errno() style but specific per object. Multithreading
 is not relevant in the current PHP program so this is not a problem.

 In classes that do not subclass PEAR, or in normal functions, you can
 use the 'new PEAR_Error()' style.

 Let's hope that PHP will soon support exceptions, so handling errors
 will become easier.


9. Portability
--

9.1 Always use ?php ?.

9.2 Try to make your library code work with or without register_globals
 turned on. Better still, do not use globals at all in the library code.

9.3 magic quotes. This one is a pain to work with portably, since we do not
 know whether an argument comes from an external source, or from
 GET/POST/Cookie parameter, or neither. Therefore, all library codes
 should probably assume magic_quotes_gpc is off, so it does not bother
 with stripslashing.


10. References
--

- PHP coding standards

- PEAR documentation

- PEAR coding standards

- phpunit documentation


12. Comments, suggestions?
--

If you do not understand some part, have objection to a certain rule, or
have an idea to improving style, please discuss it with me.


Apr 19, 2001
Steven Haryanto
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] What's wrong with Apache + php + mysql on Windows?

2001-04-27 Thread Steven Haryanto

Are you referring to delay in executing PHP scripts? If you run PHP
as a CGI binary, that would give significant slowdown. CGI's are
much slower in Windows than in Linux.

Or perhaps you are running out of RAM? That really slows the whole
thing down.

Steve

At 4/27/2001 06:14 AM, Mig wrote:
Hello, I can't understand the reason apache server running locally on my
Win98 machine delays so much to respond browser when accesing php
scripts in the form

http://localhost/myscript.php

When I transfer php scripts to host server via FTP, script execution is
immediate, even remote server being in another continent.

I was running apache + php + mysql on Win95 and delay was terrible. Now
I moved to Win98 and delay became still worse.

I know some parameter in httpd.conf or php.ini should be changed, but
how to kwow which parameter?.

Thanks for any idea.

Mig


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Sorry, wrong sebject :)

2001-04-27 Thread Steven Haryanto

At 4/27/2001 07:35 PM, Manesh wrote:



I need a free web server that gives me 1 Myslq accound and php hoasting!  if
soneone know of any please tell me.

thx


search php knowlegde base at www.faqts.com, you'll find a bunch
of such links there.

--
sh


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Globalness of variables? Functions subs

2001-04-26 Thread Steven Haryanto

At 4/25/2001 08:11 AM, Dexter wrote:
I see functions , are there subroutine calls. I guess 
not. A function acts as a sub when it returns no value . A 
sub that returns a value is a function.

You probably came from Pascal or something similar, which formally
separate 'function' from 'procedure'. They are exactly the same
(i.e., subroutines: some piece of code you call and will eventually
return to you, hence the word 'sub'.)

Steve


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] translating a function from Perl to PHP

2001-04-26 Thread Steven Haryanto

At 4/26/2001 05:33 AM, ..s.c.o.t.t.. [gts] wrote:
i tried to do it myself and nearly fell off
my chair becuase PHP makes you jump through
hoops to do such a simple thing

print preg_replace('/%([a-zA-Z]*)%/e', \$mioArray['$1'],  $testo);

i never could understand why other languages
made regular expressions so convoluted.
why not just support the =~ binding operator
instead of that awful function syntax...?

Perhaps this is in every Perl programmer's dream. :-) But perhaps
not every language has the luxury/willingness to include regular
expressions in the core language, since they think *that* is
convoluted.

Steve


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] OOP and Future of PHP

2001-04-26 Thread Steven Haryanto

At 4/26/2001 12:10 PM, Yasuo Ohgaki wrote:
  What I *really* like to see in PHP is:
 
  - NAMESPACE
  - TRACEBACK INFO
  - exception (try-except block)
  - $obj-method()-anotherMethod()
  - real destructor would be nice, but not extremely important for
 the time being, due to the nature of PHP usage in Web pages

I agree, but

$obj-method()-anotherMethod()
works for me. What does not work to be specific?

Hm, I'm using 4.0.4pl1. Perhaps this has been added somewhere in
the 4.0.5RC series? Sorry, haven't got the chance of trying that
(apart from using the PEAR from 4.0.5RC2).

===
class C1 {
 function f() { return $this; }
 function g() { echo Hi!; }
}

$C=new C;
$C-f()-g();
===

does not work me here.

I don't use GDB, but it seems it supports traceback.
How about Zend Debugger? Does it support? Anyone?

Yes, I've heard that it supports traceback. I guess this means I
have to use a source-level debugger for now. Lacking a stack trace
leads to a rather cumbersome error reporting, since I have to
supply __LINE__, __FILE__, and the name of the function in every
call to the error function.

Regards,
Steve


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Some questions on PHPUnit

2001-04-25 Thread Steven Haryanto

Does anyone here use PHPUnit?

1. If a test script needs some external input to do testing 
(notably, database connect info), is it a good idea to present 
an HTML form to ask input from user? Or should it also be able 
to prompt the user for these in case the test script is run by the PHP binary.

2. I also use Python pyunit. Python has this idiom:

if __name__=='__main__':
# run the test

This is to detect whether the script is executed as the main 
module (and not being imported by some other module).

Is there a similar way to be able to do this in PHP? I need to 
know whether the PHP file is called directly by the browser/PHP 
binary and not include()'d/require()'d by other file. In the 
case of require_once() and include_once() I guess I can use 
get_required_files()/get_included_files().

Thanks,
Steve


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] safe uploading with PHP

2001-04-25 Thread Steven Haryanto

I am sorry if this is one of the FAQ.

Last time I checked (well, a few months ago), PHP has the 
vulnerability that the user who submitted the form can 
manipulate the global namespace to let PHP pick up arbitrary 
file in the system. Can we now do safe file uploading without 
turning off register_globals?

Thanks,
Steve


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] maximum length of email address

2001-04-25 Thread Steven Haryanto

At 4/26/2001 01:08 AM, Dennis Gearon wrote:
I've gone through the archives and through a bunch of RFC's, but have
had no luck in finding  maximum length for email addresses. Anybody
know if there is one and what it is?

Perhaps it's one of those undefined values (like the maximum length of
an URL)? The username part is system-dependant, for example...

Steve


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] OOP and Future of PHP

2001-04-25 Thread Steven Haryanto

At 4/25/2001 09:02 PM, Reuben D Budiardja wrote:

The only thing that I feel lack of in PHP is the real Object 
Oriented stuff, such as information hiding in the object in 
classes i.e. private and public variables, methods/functions.

This in a sene make it really difficult for developer to build 
an API for other developers that is secure. I myself have this 
problem. Is there any reasons why PHP was designed like this 
from the beginning? Is this issue going to be addresses somehow 
in the future? Anyone has any idea?

If anyone has any idea, or tricks to hide information in a 
variables or method in a class, or in other words, make a 
variable or method a private, I would really like to know. 
Thanks for any comments.

Python also does not do information hiding, but people rarely call
Python's OO features as not real. :-)  It's a matter of choice,
though, I don't see any real hindrance of PHP implementing this
in the future version.

As Rasmus said, PHP does not have introspection (once again, unlike
Python which is very introspective), this is less of a problem,
especially with function calls API.

What I *really* like to see in PHP is:

- NAMESPACE
- TRACEBACK INFO
- exception (try-except block)
- $obj-method()-anotherMethod()
- real destructor would be nice, but not extremely important for
   the time being, due to the nature of PHP usage in Web pages

Please tell me it's on the top'ish of the TODO list :-)

Steve 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]