[PHP] Re: [PEAR-DEV] Re: [PHP] PHP 5.0.0 Beta 1

2003-06-30 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2003-06-29 14:53:40 -0400:
> On Sun, 2003-06-29 at 14:19, Sterling Hughes wrote:
> >
> >   - Due to issues surrounding the MySQL 4.0 license, the MySQL libraries
> > are no longer bundled with PHP.  For more information on these
> > licensing changes please see the MySQL licensing policy [1]
> >
> > [1] http://www.mysql.com/products/licensing.html
> 
> I read the licensing information in the above link, but I'm curious what
> exactly in it necessitated the need to unbundle MySQL? Anyone have a
> quick answer?

"1. Free use for those who are 100% GPL"

IOW, it's not free for PHP

"2. Free use for those who never copy, modify or distribute"

IOW, it's not free for PHP

3. GPL would infect the whole PHP tree

http://www.gnu.org/copyleft/gpl.html

-- 
If you cc me or remove the list(s) completely I'll most likely ignore
your message.see http://www.eyrie.org./~eagle/faqs/questions.html

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



Re: [PHP] 403 Forbidden

2006-12-29 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-12-29 12:17:12 +0530:
> When I try to run any php script on apache I get a error
> "Authorization required 403 Forbidden". I don't get this error on
> IIS. I am using Windows XP professional please help. I am using
> Apache 2.2.1

That's a problem with your apache configuration, unrelated to PHP.
The Apache manual is at http://httpd.apache.org/docs/2.2/

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Payflow and Php5 on FreeBSD

2006-12-29 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-12-29 07:20:58 -0500:
>Thanks for your reply. Some additional information, I have not noticed a 
> php5-pfpro extensions port, i did see one for php4, but i was informed that 
> going back to php4 is not an option, programmers here use php5 specific 
> functions.
> Judging from googling i'm sure i'm making this harder than it needs to be, 
> but i have two requirements: one is to avoid or minimize downtime, and two 
> is to not utilize both ports and source-compiled software, which in my 
> opinion makes future maintence harder especially if i'm not going to be 
> doing it.
>I can think of two options, i'd appreciate comments, suggestions, and 
> ideas. Option 1 is to uninstall all php5.x ports on the box and do a 
> source-install of php5. I'm really not happy about this option, but i'll 
> use it if something easier doesn't come along. Option2 is to compile php5 
> from source on another box, get the pfpro.so shared object from that box, 
> copy it in to the php5 extensions area on the original box, and load it via 
> extensions.ini.

Both your options are inferior to the hypothetical case where there was
a php5-pfpro port in the official FreeBSD ports collection: you'd just
put your pfpro SDK into $DISTDIR, cd $PORTSDIR/devel/php5-pfpro,
sudo make install. Write the port and submit it to the FreeBSD GNATS.
They might reject the submission on basis of it being too much of a
niche software, but having the port will greatly improve the
administrators' experience maintaining the installation.

I'm suggesting that you bite the bullet while it still hasn't grown
the size of a cannon ball.

See Porter's Handbook [1] for instructions; you can use one of the
existing PECL ports as a template.  I can help you through the process
off-list.

[1] http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/

>Another idea is i've read on php.net that payflow is now a pecl 
> extension, which i interpret to mean i could just download and drop it in, 
> but i have not been able to find the file although this one would probably 
> be easiest.

I don't believe you'll have much luck with binary downloads, building
the extension requires the Payflow Pro SDK, and AIUI one needs to be
registered with Verisign to have access to that. [2]

[2] http://cz.php.net/manual/en/ref.pfpro.php

Finding the library compiled by someone else might be easiest for the
moment, but quick money will only burn your ass.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Request of php5

2007-01-01 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-01 14:40:14 +0800:
> Dear All,
> 
> Happy New Year,
> 
> How much mem ( Ram ) does the php5 need ?

As much as you make it use.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Temporary Emails - Your Recommendations - An Appeal to the PHP Community

2007-01-01 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-01 05:26:43 -0500:
> i realize this isn't the appropriate mailing list and i risk being
> black-listed (flame, defamed, ignored, etc.).
> 
> i occasionally use temporary emails when registering for forums or to get
> some shareware (we've all done it, don't give me that look, i have given
> what i could, when i could) and while i like the way mytrashmail.com works,
> i don't like having mytrashmail.com as part of the temp addy.
> 
> does anyone know of a similar service that uses a more enticing domain?

you-can.diy

a domain costs pennies and all the required software is free.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Writing Binary

2007-01-01 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-01 15:15:07 -0500:
> Hello Everyone,
>I'm trying to write a PHP script that opens a binary file, reads the 
> binary in chunks, checks those chunks for a certain binary string, and 
> then if the string is found, it replaces the string with another binary 
> string.  The script should then a copy of the file, including the 
> changed bits.  But for some reason, the script is not replacing the 
> binary string.
> 
> Here's the source code:
> 
>  
> $in = fopen("C:\NeighborhoodManager.package", "rb");
> $out = fopen("C:\NeighborhoodManager2.package", "w");
> $count = 0;
> 
> while (!feof($in)) {
>  $count++;
>  $buffer = fread($in,5);
>  if 
> (eregi("01010011011101000111001001110110111001100111011001010111010001100111011101101110",$buffer))

Binary mode ("rb") doesn't mean PHP will translate each bit of the data
into a 7-bit (or longer) textual representation.

http://www.php.net/manual/en/function.pack.php
http://www.php.net/manual/en/function.unpack.php

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Please help me

2007-01-02 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-02 15:35:26 +0530:
> my problem got solved in gmail, but now i am not getting mails any where
> else...
> headers now i am using is:
> 
> $headers = 'MIME-Version: 1.0'."*\n*".'Content-type:
> text/html;charset=iso-8859-1'."*\n*".'Content-Transfer-Encoding:
> 8bit'."*\n*".'From:'.$sitename."*\n*".'return-path:'.$from;

If and when you're interested in doing your job right instead of blindly
trying whatever shmuck your /dev/random can generate, read about the email
message format at

ftp://ftp.rfc-editor.org/in-notes/rfc2045.txt
ftp://ftp.rfc-editor.org/in-notes/rfc2821.txt
ftp://ftp.rfc-editor.org/in-notes/rfc2822.txt

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Trouble compiling in mysqli under PHP5 -- "mysql_config not found"

2007-01-02 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-02 18:23:33 -0700:
> I'm trying to build a CLI/CGI binary of PHP5 with MySQLi under Mac OS
> X. When I invoke configure, I get the following error message:
> 
> "checking whether to enable embedded MySQLi support... no
> mysql_config not found
> configure: error: Please reinstall the mysql distribution"
> 
> Now, mysql (4.1.22) is in fact installed, and it looks to me like the
> headers are in fact there (and mysql_config seems to be under ./bin),
> and I did give it the path with the config option
> (--with-mysqli=/usr/local/mysql -- yes, I know this isn't the
> conventional Mac OS X path, but I like these things under /usr/local,
> so).
> 
> Curiously, I note that a build using --with-mysql=/usr/local/mysql
> works just fine.
> 
> Any ideas what I'm doing wrong here?

It wants "--with-mysql=/usr/local/mysql/mysql_config", see
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/config.m4?revision=1.25&view=markup

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Trouble compiling in mysqli under PHP5 -- "mysql_config not found"

2007-01-02 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-03 02:55:11 +:
> # [EMAIL PROTECTED] / 2007-01-02 18:23:33 -0700:
> > I'm trying to build a CLI/CGI binary of PHP5 with MySQLi under Mac OS
> > X. When I invoke configure, I get the following error message:
> > 
> > "checking whether to enable embedded MySQLi support... no
> > mysql_config not found
> > configure: error: Please reinstall the mysql distribution"
> > 
> > Now, mysql (4.1.22) is in fact installed, and it looks to me like the
> > headers are in fact there (and mysql_config seems to be under ./bin),
> > and I did give it the path with the config option
> > (--with-mysqli=/usr/local/mysql -- yes, I know this isn't the
> > conventional Mac OS X path, but I like these things under /usr/local,
> > so).
> > 
> > Curiously, I note that a build using --with-mysql=/usr/local/mysql
> > works just fine.
> > 
> > Any ideas what I'm doing wrong here?
> 
> It wants "--with-mysql=/usr/local/mysql/mysql_config", see

--sith-mysqli, of course, sorry for the noise

> http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/config.m4?revision=1.25&view=markup

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Pushing a file to the browser

2007-01-02 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-09-15 20:39:16 -0400:
> I have a script I've created which takes a file upload, monkeys with the 
> data in it, and needs to push the new file out to the browser.  Everything 
> is coded and working up to that last point, but I've never pushed out a file 
> to the browser before.

Each time any of your PHP web scripts is run to display a "page", it
"pushes" a file to the browser: the page is the file.

> Does anyone have the code for this laying around that I can see (and
> modify)?

There's no code, there's only comprehension. The fishing manual is at:
ftp://ftp.rfc-editor.org/in-notes/rfc2616.txt

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Re: http request problem

2007-01-02 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-03 11:19:21 +0500:
> ===ORINGIAL===
> hi all,
> 
> I got problem in getting file content. the file is located at another server
> (tomcat) and it is a jsp file.
> i don't know why i keep getting the same error message file accessing that
> file but
> while i am trying to access to another file, from another server it run
> perfect.
> this is the error message i get:
> PHP Warning:
> file_get_contents(
> http://123.123.1.2:8008/V3JRoute?slot=1&startX=103.880764&startY=1.335458&endX=103.886297&endY=1.334953&routeType=1&format=2
> )
> [function.file-get-contents]: failed to open stream: HTTP request failed!
> $5$13:53:22,13:53:22,13:53:22,13:53:22,13:53:22$0.0,0.0,0.0,0.0,0.0$Depart
> on,Turn sharp left onto,Continue on,Turn right onto in C:\Program
> Files\MapGuideOpenSource\WebServerExtensions\www\phpviewersample\xmlaccesstrial.php
> on line 5
> 
> take note that the text in bold is part of the page contents.

The text/plain version of your multipart/mixed email omits terminal
escape sequences ("tags") so there's no bold. But that error message
is somehow garbled anyway.

Now, what happens if you try to display that same url in a normal
browser on the same network where it fails in the PHP script? If it
works, what's the difference between the two requests? Use a packet
capture and analysis tool like Wireshark (formerly Ethereal) to tell.
If it doesn't work, fix that first. If it works from a normal browser,
you can't see anything wrong with the request made by PHP, *and* you
know your requests actually hit the server, ask its admin to cooperate.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Re: http request problem

2007-01-02 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-03 11:19:21 +0500:
> ===ORINGIAL===
[...]
> ===END ORIGINAL===

Gah, early morning! Ok, I wasted my time thanks to your quoting style.
Would you please use something more conventional, like prefixing each
line of the quoted material with "> "? Thank you!
 
> I tried following code but it gives the same error
> 
> $link="
> http://123.123.1.2:8008/V3JRoute?slot=1&startX=103.880764&startY=1.335458&endX=103.886297&endY=1.334953&routeType=1&format=2
> ";
> 
> $handle2= fopen($link,"r");
> 
>   $contents = '';
>   while (!feof($handle2)) {
> $contents = fread($handle, 819200);
> echo $contents;
>   }
> 
> I tried opening the given URL directly, but this url seems to be a broken
> link. If you try any other link, it will work

Thank you for the information.

Seriosly: does that mean that your original question is answered, or do
you still expect advice on getting it to work? I really can't tell,
there's neither a question nor a "solved" statement in your email.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
--- Begin Message ---
# [EMAIL PROTECTED] / 2007-01-03 11:19:21 +0500:
> ===ORINGIAL===
> hi all,
> 
> I got problem in getting file content. the file is located at another server
> (tomcat) and it is a jsp file.
> i don't know why i keep getting the same error message file accessing that
> file but
> while i am trying to access to another file, from another server it run
> perfect.
> this is the error message i get:
> PHP Warning:
> file_get_contents(
> http://123.123.1.2:8008/V3JRoute?slot=1&startX=103.880764&startY=1.335458&endX=103.886297&endY=1.334953&routeType=1&format=2
> )
> [function.file-get-contents]: failed to open stream: HTTP request failed!
> $5$13:53:22,13:53:22,13:53:22,13:53:22,13:53:22$0.0,0.0,0.0,0.0,0.0$Depart
> on,Turn sharp left onto,Continue on,Turn right onto in C:\Program
> Files\MapGuideOpenSource\WebServerExtensions\www\phpviewersample\xmlaccesstrial.php
> on line 5
> 
> take note that the text in bold is part of the page contents.

The text/plain version of your multipart/mixed email omits terminal
escape sequences ("tags") so there's no bold. But that error message
is somehow garbled anyway.

Now, what happens if you try to display that same url in a normal
browser on the same network where it fails in the PHP script? If it
works, what's the difference between the two requests? Use a packet
capture and analysis tool like Wireshark (formerly Ethereal) to tell.
If it doesn't work, fix that first. If it works from a normal browser,
you can't see anything wrong with the request made by PHP, *and* you
know your requests actually hit the server, ask its admin to cooperate.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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


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

Re: [PHP] PEAR mail sorted as spam

2007-01-03 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-03 11:14:27 +0100:
> When I send mail via PEARs Mail class they are sorted as spam by 
> Thunderbird. Do you have any ideas why? I can't figure it out.

Surely Thunderbird provides an interface to query and modify its spam
filters? Or is it an automated email black hole without even a log file?

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] E_RECOVERABLE_ERROR - 5.1.6 to 5.2.0

2007-01-03 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-02 21:23:02 +0100:
> David CHANIAL wrote:
> > We are preparing the upgrade of PHP for our customers, but, after some 
> > tests, 
> > we have a migration "problem" caused by the news E_RECOVERABLE_ERROR.
> > 
> > So, even if the upgrade guide (http://www.php.net/UPDATE_5_2.txt) talk 
> > about 
> > the method to handle this new errors (by using try/catch), they don't talk 
> 
> there is no mention of try/catch - it seems that the rather unfortunate word
> 'catchable' was used to describe the act of setting up a user defined error 
> handler
> (see: http://php.net/manual/en/function.set-error-handler.php) to handle 
> errors
> that are triggered by the php core. [errors != exceptions]

Unfortunately. Consider this:

function f($any)
{
printf("%s\n", $any);
}

Innocent enough? It's an E_RECOVERABLE_ERROR if $any is an object
without __toString(). The 5.2.0 changelog talks about problems with the
textual representation (object #id), but this cure is IMO worse than the
disease, especially as they didn't make it an exception which would
be *much* easier to handle:

function f($any)
{
try {
printf("%s\n", $any);
} catch (CastError $e) {
printf("%s\n", spl_object_hash($any));
}
}

In fact, I wonder why spl_object_hash() hasn't replaced the old default
behavior.

One way to (almost) handle this (or indeed warnings in PHP at all) is to 
use an error_handler that mutates all it can into exceptions.

Unfortunately, you can only do this if there's no independently
developed code in the program. If it uses a library that's not written
for a throwing error handler, such a handler will change the library's
semantics! Imagine a DB library that contained this code:

if (false === ($conn = mysql_connect())) {
handle_error();
}

handle_error() will never be called with a throwing error handler.

And you cannot use such a handler in the library either, because the
application would have to defend against the library error handler
leaking e. g. into signal handlers. Also, if every library had to
install/deinstall its own error handler on every entry and exit of its
code... I don't want to even think of that.

To me, E_RECOVERABLE_ERROR, or at least some of its instances, seem to
be more of an interoperability problem than anything else. But that's
IMO true of the whole error handling in PHP.

Now back to our regularly scheduled pushing files around t3h 1nt3rn3t.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] PEAR mail sorted as spam

2007-01-03 Thread Roman Neuhauser
Don't toppost. Preserve (just) enough context to make the mail
comprehensible by someone who doesn't know the previous emails.

Thanks.

# [EMAIL PROTECTED] / 2007-01-03 11:14:27 +0100:
> When I send mail via PEARs Mail class they are sorted as spam by 
> Thunderbird. Do you have any ideas why? I can't figure it out.

# [EMAIL PROTECTED] / 2007-01-03 11:29:42 +0100:
> Roman Neuhauser wrote:
> >Surely Thunderbird provides an interface to query and modify its spam
> >filters? Or is it an automated email black hole without even a log file?
>  
> I can of course tell Thunderbird that something is not spam, but I don't 
> want all of my users to have to do that for every mail I send via pear. 

That's not what I asked. Does Thunderbird tell you why it marked
something as spam? If it does, use that information. If it does not,
you're crazy for using it. Either way, your question belongs into a
Thunderbird mailing list, along with the exact full message. Full means
including all headers, exact means you need to abandon formulations "it
was something like".

> Maybe I haven't included some header non-spam usually have or something? 

How are we supposed to know? Should we read Thunderbird's source code
for you? :)

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] PEAR mail sorted as spam

2007-01-03 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-03 13:16:17 +0100:
> Roman Neuhauser wrote:
> >That's not what I asked. Does Thunderbird tell you why it marked
> >something as spam? If it does, use that information. If it does not,
> >you're crazy for using it. Either way, your question belongs into a
> >Thunderbird mailing list, along with the exact full message. Full means
> >including all headers, exact means you need to abandon formulations "it
> >was something like".
>  
> As far as I can see it does not give more information. Why would that 
> make me crazy?

Because it leads into trouble, like the one you're in now. Who knows,
perhaps Thunderbird decided for you that short emails in languages other
than English are spam. Perhaps you've labeled too many of such massages.

> I can see what's marked as spam, and it gets better at finding spam
> the more emails I mark as spam or not spam. I think that is an okey
> solution.

Ok, but then you should be ready to live with its mysterious behaviors.

> >>Maybe I haven't included some header non-spam usually have or something? 
> >
> >How are we supposed to know? Should we read Thunderbird's source code
> >for you? :)
>  
> Of course not. I just wondered if there was something obvious in the 
> mail headers or whatever from pear that would make my mail look like 
> spam.

But you didn't include that message in your email to the list.

> And I want a more mainstream solution that works on all/most email 
> clients, not just firefox.

I used PEAR Mail to send emails from linux boxes that more often than
not didn't even have the hostname set correctly, and I had no problems.
Then again, AFAIK all recipients used either mutt or outlook.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] PEAR mail sorted as spam

2007-01-03 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-03 04:42:05 -0800:
> On 1/3/07, Roman Neuhauser <[EMAIL PROTECTED]> wrote:
> >.
> >Then again, AFAIK all recipients used either mutt or outlook.
> 
> Now that is a very disperse audience,

The reports went to two types of people: admins and managers.

> i never see mutt mentioned often.

Try subscribing to [EMAIL PROTECTED] :)

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] E_RECOVERABLE_ERROR - 5.1.6 to 5.2.0

2007-01-03 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-03 14:07:31 +0100:
> Roman Neuhauser wrote:
> > # [EMAIL PROTECTED] / 2007-01-02 21:23:02 +0100:
> >> David CHANIAL wrote:
> >>> We are preparing the upgrade of PHP for our customers, but, after some 
> >>> tests, 
> >>> we have a migration "problem" caused by the news E_RECOVERABLE_ERROR.
> >>>
> >>> So, even if the upgrade guide (http://www.php.net/UPDATE_5_2.txt) talk 
> >>> about 
> >>> the method to handle this new errors (by using try/catch), they don't 
> >>> talk 
> >> there is no mention of try/catch - it seems that the rather unfortunate 
> >> word
> >> 'catchable' was used to describe the act of setting up a user defined 
> >> error handler
> >> (see: http://php.net/manual/en/function.set-error-handler.php) to handle 
> >> errors
> >> that are triggered by the php core. [errors != exceptions]
> > 
> 
> Roman - you make some very good point but the pragmatist in me
> says of your first example - why the F*** would anyone pass in an object and
> blindly push it through printf() ?? that sucks as far as code goes (personally
> evening being so diligent as to implement __toString() on the relevant class 
> is
> asking for bad news - too much magic imho)
> 
> if the function should be capable of taking an object or a string it should
> check what it recieves.
> 
> the way I see it this is bad code by design - and needs to be fixed.

Well, why the F*** would anyone use a language that allows you to pass
incompatible objects to a function and crashes when you do so? ;)

Errors and warnings are fine for languages where the compilation step is
separate from the run. For a language like PHP, anything but
"RuntimeException" means your perfectly correct code can crash at
runtime, without you having a slightest chance to react (in the code).

> > Unfortunately. Consider this:
> > 
> > function f($any)
> > {
> > printf("%s\n", $any);
> > }
> > 
> > Innocent enough? It's an E_RECOVERABLE_ERROR if $any is an object
> > without __toString(). The 5.2.0 changelog talks about problems with the
> > textual representation (object #id), but this cure is IMO worse than the
> > disease, especially as they didn't make it an exception which would
> > be *much* easier to handle:
> 
> true - but then it would force someone to use exceptions - the overall
> consensus went against forcing that on people.

I don't follow the logic. What did we gain? Can one of those "exceptions
== Java, Java stinks, exceptions stink" campers show me their version of
the below f($any) that works in 5.1 and 5.2?

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Array decleration problem

2007-01-03 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-02 10:48:27 +0100:
> Hi,
> 
> I'm new to php and im learning, I haven't encounter any problems till 
> now so please help me? :)
> 
> the code: (learning arrays...)
> 
>
>   $flavors=array ("banana", "cucumber", "grape", "vanilla")

that statement is incomplete (";" missing).

> I get an error message:
> Parse error: parse error, unexpected T_VARIABLE in C:\Program 
> Files\XAMPP\xampp\htdocs\test_folder\exercise12.php on line 16

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] E_RECOVERABLE_ERROR - 5.1.6 to 5.2.0

2007-01-03 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-03 16:43:14 +0100:
> Roman Neuhauser wrote:
> > # [EMAIL PROTECTED] / 2007-01-03 14:07:31 +0100:
> >> Roman - you make some very good point but the pragmatist in me
> >> says of your first example - why the F*** would anyone pass in an object 
> >> and
> >> blindly push it through printf() ?? that sucks as far as code goes 
> >> (personally
> >> evening being so diligent as to implement __toString() on the relevant 
> >> class is
> >> asking for bad news - too much magic imho)
> >>
> >> if the function should be capable of taking an object or a string it should
> >> check what it recieves.
> >>
> >> the way I see it this is bad code by design - and needs to be fixed.
> > 
> > Well, why the F*** would anyone use a language that allows you to pass
> > incompatible objects to a function and crashes when you do so? ;)
> > 
> > Errors and warnings are fine for languages where the compilation step is
> > separate from the run. For a language like PHP, anything but
> > "RuntimeException" means your perfectly correct code can crash at
> > runtime, without you having a slightest chance to react (in the code).
> 
> you have to pay some kind of price for dynamic typing and intepreted
> running.
> 
> testing is done for a reason and I stand by my opinion that your given example
> is tantamount to awful coding and it should be corrected.

Why is it awful coding? I have a piece of code where exactly this is
(was in 5.1) a perfectly reasonable thing to do (the example is
contrived to clearly demonstrate the behavior at hand). The output was
for informational purposes, and the "Object #N" presentation was
completely adequate even with its quirks.

BTW, would you share a version of f($any) that meets your definition of
good code?
 
> >>> function f($any)
> >>> {
> >>> printf("%s\n", $any);
> >>> }

> >> true - but then it would force someone to use exceptions - the overall
> >> consensus went against forcing that on people.
> > 
> > I don't follow the logic. What did we gain? Can one of those "exceptions
> > == Java, Java stinks, exceptions stink" campers show me their version of
> > the below f($any) that works in 5.1 and 5.2?
> 
> probably not - i wouldn't know I don't live in that camp.

That's why I didn't ask *you*. ;)

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] E_RECOVERABLE_ERROR - 5.1.6 to 5.2.0

2007-01-03 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-03 16:43:14 +0100:
> Roman Neuhauser wrote:
> > # [EMAIL PROTECTED] / 2007-01-03 14:07:31 +0100:
> >> Roman - you make some very good point but the pragmatist in me
> >> says of your first example - why the F*** would anyone pass in an object 
> >> and
> >> blindly push it through printf() ?? that sucks as far as code goes 
> >> (personally
> >> evening being so diligent as to implement __toString() on the relevant 
> >> class is
> >> asking for bad news - too much magic imho)
> >>
> >> if the function should be capable of taking an object or a string it should
> >> check what it recieves.
> >>
> >> the way I see it this is bad code by design - and needs to be fixed.
> > 
> > Well, why the F*** would anyone use a language that allows you to pass
> > incompatible objects to a function and crashes when you do so? ;)
> > 
> > Errors and warnings are fine for languages where the compilation step is
> > separate from the run. For a language like PHP, anything but
> > "RuntimeException" means your perfectly correct code can crash at
> > runtime, without you having a slightest chance to react (in the code).
> 
> you have to pay some kind of price for dynamic typing and intepreted
> running.

You don't, look at Python. Instead of warnings and fatal errors, good
for logging purposes at best, you get to choose how to handle the
problem.

What kind of dynamic typing are we talking about if

f($any)
{
printf("%s", $any);
}

is bad code?

If you dare to use dynamic features in PHP you're begging to have your
throat cut by some call to undefined method, or hop in to lala land with
an "undefined member variable access" warning... If problems with the
"dynamic typing" of PHP end in somewhat undynamic fatal errors, your
only choice is to have all paths in the program statically verified,
IOW, steer completely clear of the dynamic features. That'll be a
terribly tedious job.

You can do this in Python (completely safe and meaningful):

def f(any):
print "%s" % any

You can even call any method on any object safely:

def g(o):
o.f()

If o doesn't have a callable member called "f", you'll get an exception
you can catch:

def g(o):
try:
o.f()
except AttributeError:
print >> stderr, "oops!"

The lack of global error handlers allows mixing of independently
developed software, that's quite dynamic.

If you believe that something like

f($any)
{
if (is_string($any)) {
printf("%s", $any);
} else if (...) {
...
}
}

is better than the single sprintf() version, we'll just have to agree to
disagree. Where's the dynamism again? You could write this in C++:

void f(any a)
{
cout << a;
}

with less typing more dynamism than you get with PHP. And the resulting
binary won't crash at runtime.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Request of php5

2007-01-03 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-04 00:09:37 +0800:
> Curt Zirzow wrote:
> > On 1/3/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >> Richard Lynch wrote:
> >> >On Mon, January 1, 2007 12:40 am, [EMAIL PROTECTED] wrote:
> >>
> >> >>How much mem ( Ram ) does the php5 need ?
> >> ...
> >
> >> >Depends on what extension you add, what you do with those extensions,
> >> >and what sort of performance you expect to get.
> >> >
> >> >Depends if you run as a Module, as CGI, as Fast CGI, and if you are on
> >> >Windows, Linux, FreeBSD, or Other.
> >> >
> >> ...
> >
> >> I need php5 running with IMP ( Webmail -> http://www.horde.org/imp ) and
> >> may be phpBB...
> >
> > How much ram is required is rather futile, it is more on how many
> > requests per second your server can handle before you start even think
> > about ram.
>
> But actually, I want to know how muach mem ( ram ) does the new version
> of php need ?

Excuse me, are you pulling our legs or do you have reading problems?
Several people have already told you that the memory footprint depends
on several factors, of which you specified NONE.

To satisfy your thirst for meaningless numbers, here's the CLI php 5.2.0
waiting for input on FreeBSD-6.1/amd64, with *unspecified number* of
*various* extensions:

USER  PID %CPU %MEM   VSZ   RSS  TT  STAT STARTED  TIME COMMAND
roman   26242  0.0  1.0 58348 10608  pg  I+5:52PM   0:00.06 php

As you can see, PHP 5 takes 10MB. Did I mention that number is useless
for you? I just don't understand why you don't try it yourself.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] E_RECOVERABLE_ERROR - 5.1.6 to 5.2.0

2007-01-03 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-03 11:57:03 -0500:
> Not to get into this argument [...]

Nah, just chattin'.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Removing UTF-8 from text

2007-01-03 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-03 19:51:56 +0200:
> I have many email address that are stored like this:
> "=?UTF-8?B?15jXqNeR15XXp9eZ16DXlCDXnteo15nXkNeg15Q=?=" <[EMAIL PROTECTED]>,
> "=?UTF-8?B?15nXoNem158g157XqNeZ15Q=?=" <[EMAIL PROTECTED]>,
> "=?UTF-8?B?15zXmSDXpNeV15zXmdeg15Q=?=" <[EMAIL PROTECTED]>
> 
> I'm trying to run a script that will leave the file as so:
> [EMAIL PROTECTED],
> [EMAIL PROTECTED],
> [EMAIL PROTECTED]
> 
> The first step is to remove the UTF-8 names. This code _doesn't_ work,
> but I think that it should:
> $text=preg_replace('/\"=\?UTF\-8\?B\?([a-z0-9]+)\?=\"/i', '', $text);
> 
> I've tried with single and double quotes, and I've tried backslashing
> and not backslashing the question marks. Where am I erring? Thanks.

You should not "try backslashing and not backslashing". Read the
documentation instaed, it's clear. In the meantime, this will work:

sed 's/^.*<\([^>]\+\)>,$/\1/' file
 
-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] E_RECOVERABLE_ERROR - 5.1.6 to 5.2.0

2007-01-03 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-03 14:01:29 -0600:
> On Wed, January 3, 2007 8:24 am, Roman Neuhauser wrote:
> > I don't follow the logic. What did we gain? Can one of those
> > "exceptions
> > == Java, Java stinks, exceptions stink" campers show me their version
> > of
> > the below f($any) that works in 5.1 and 5.2?
> 
> Sure.
> 
> > > function f($any)
> > > {
> > > printf("%s\n", $any);
> > > }
> 
> function print_any($any){

[34 lines of a switch ellided]

> }

Nice. Now I see how the dynamic nature of PHP boosts development. :)
 
> The problem with try/catch is that, as already noted in this thread,
> as soon as you reach a certain level of complexity and a large enough
> code-base, the whole house of cards comes tumbling down because one
> developer somewhere isn't using the same semantics for errors as you
> are.

Erm, no.  The note I made earlier in this thread said that changing
semantics of unsuspecting programs by using a throwing error handler
would be disastrous, and that was after I discussed using such a
throwing handler *for better error handling*.

> This can be as obvious as not using try/catch at all, to
> something very subtle such as what to *DO* with the errors

Same kinds of things you do with errors in a procedural program.

> or what kinds of errors to catch.

Those that you know how to handle, of course. Or was that a different
question?

> So, actually, it's not about try/catch being Java, as try/catch did
> not originate with Java, as it is about try/catch just not being
> scalable to wide-spread development.

Can you qualify that statement? What things are impossible?

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Removing UTF-8 from text

2007-01-03 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-03 22:41:54 +0200:
> On 03/01/07, Richard Lynch <[EMAIL PROTECTED]> wrote:
> >Instead of trying to strip the UTF stuff out, try to capture the part
> >you want:
> >
> >preg_match_all('|<[^>]>|ms', $emails, $output);
> >var_dump($output);
> >
> 
> Richard, I do have a working script now, but I'm intrigued by your
> regex. Why do you surround the needle with pipes, and what is the "ms"
> for?

It's for "Did you know that the syntax is described in the manual? Did
you know that PHP has a manual on the web? It's at http://www.php.net/";.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Removing UTF-8 from text

2007-01-03 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-04 08:21:37 +0200:
> On 03/01/07, Roman Neuhauser <[EMAIL PROTECTED]> wrote:
> >
> >It's for "Did you know that the syntax is described in the manual? Did
> >you know that PHP has a manual on the web? It's at http://www.php.net/";.
> >
> 
> Thank you Roman. Yes, I am familiar with the php manual. I've
> referenced the manual hunderds of times, saving list posts. But
> sometimes (especially in the course of regular expressions for me) one
> needs to ask on the list. I am also aware that I am not the only one
> with regex difficulties- they seem to be a sticky point for many noobs
> like myself in all computer languages, not just php. Also, the Hebrew
> translation of the manual is very difficult for me to grasp, so I use
> the English version. That may not be a problem for you, but it is for
> me.

Your written English is very good. If you can understand what you wrote
and can read replies (in English) from the list, you should have no
problems understanding the manual.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] IE, Word documents and Content Types

2007-01-03 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-03 15:48:31 -0600:
> On Wed, January 3, 2007 2:52 pm, Philip Thompson wrote:
> > I have a form where a user can upload different types of documents. A
> > valid file type they will be able to upload is a Word Document.
> > However, when I view the $_FILES 'type' of a word document in Internet
> > Explorer, it says it's type 'application/octet-stream' instead of
> > 'application/msword' or 'application/vnd.ms-word'. It works fine in
> > Firefox and Safari.
> >
> > Any ideas why IE does this and/or how I might be able to get around
> > this?
> 
> IE does this because MS is not interested in interoperability.
 
Back this statements with some references, will you?

> Note that application/octet-stream is valid for any kind of document
> whatsoever for an upload.  For output, that would require the browser
> to download the document rather than attempt to display it.  More on
> that here:
> http://richardlynch.blogspot.com/

To the OP: read that rant for amusement, but don't use the "advice"
rlynch gives, it's nonsense. If you don't believe me, check the RFCs
yourself.

http://marc.theaimsgroup.com/?l=php-general&m=116626545820302&w=2
http://marc.theaimsgroup.com/?l=php-general&m=116649130605303&w=2

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Calling static child method from inherited static parent method

2007-01-04 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-03 19:14:31 -0700:
> I'm trying to implement what I think is called a "virtual method": my
> abstract parent class ParentClass defines a method xxx that calls
> method yyy, but yyy is defined only in ParentClass's children.
> 
> I can't get this to work (PHP5.0.4). Sample code:
> 
> === start sample code ===
> 
> abstract class ParentClass {
>  // xxx just returns 5 + whatever yyy() returns
>  public static function xxx () {return 5 + yyy();}
>  // all my children must define yyy()
>  abstract static function yyy();
> }
> 
> abstract class ChildClass extends ParentClass {
>  public static function yyy () {return 7;}
> }
> 
> echo ChildClass::xxx();
> 
> === end sample code ===
> 
> When I run the above, I get this error:
> 
> Fatal error: Call to undefined function yyy() in  on line 9
> 
> Changing the call from yyy() to self::yyy() gives a different error:
> 
> Fatal error: Cannot call abstract method ParentClass::yyy() in  on 
> line 9
> 
> How to do this correctly?

Without "static". Chances are the code would be better served by an
instance anyway (static methods deprive you of polymorphism, as you just
found out.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Help me about using php with tomcat server.

2007-01-04 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-04 15:05:54 +0700:
> I have two web application running on php and jsp. But i don't know how can
> to use php and jsp on tomcat server. Please help me.

Find an implementation of PHP in Java (tough luck) or the official
library wrapped in a JNI interface. But you'll make it a lot easier
on yourself if you just install Apache with PHP beside the Tomcat.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] E_RECOVERABLE_ERROR - 5.1.6 to 5.2.0

2007-01-04 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-03 15:18:59 -0600:
> Roman Neuhauser wrote:
> > # [EMAIL PROTECTED] / 2007-01-02 21:23:02 +0100:
> >> David CHANIAL wrote:
> >>> We are preparing the upgrade of PHP for our customers, but, after some 
> >>> tests, 
> >>> we have a migration "problem" caused by the news E_RECOVERABLE_ERROR.
> >>>
> >>> So, even if the upgrade guide (http://www.php.net/UPDATE_5_2.txt) talk 
> >>> about 
> >>> the method to handle this new errors (by using try/catch), they don't 
> >>> talk 
> >> there is no mention of try/catch - it seems that the rather unfortunate 
> >> word
> >> 'catchable' was used to describe the act of setting up a user defined 
> >> error handler
> >> (see: http://php.net/manual/en/function.set-error-handler.php) to handle 
> >> errors
> >> that are triggered by the php core. [errors != exceptions]
> > 
> > Unfortunately. Consider this:
> > 
> > function f($any)
> > {
> > printf("%s\n", $any);
> > }
> > 
> > Innocent enough? It's an E_RECOVERABLE_ERROR if $any is an object
> > without __toString().
> 
> It's also an example of a former C coder's understanding of how to do
> things in PHP.  Not only is this extremely inefficient (a function call
> is significant overhead in PHP) it is doubly inefficient through the
> unnecessary use of printf().  printf() is best used when you are
> modifying the display of the output, the %s modifier by itself is
> pointless in PHP.
 
This is utter crap.

> function f($any)
> {
> echo $any . "\n";
> }
> 
> This has no E_RECOVERABLE_ERROR possibility and is far more efficient.
> Better yet, replace
> 
> f($blah)
> 
> with
> 
> echo $blah . "\n"

echo $blah . "\n" is *not* equivalent to printf("%s\n", $blah)



-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] E_RECOVERABLE_ERROR - 5.1.6 to 5.2.0

2007-01-04 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-04 10:54:58 +:
> # [EMAIL PROTECTED] / 2007-01-03 15:18:59 -0600:
> > Roman Neuhauser wrote:
> > > # [EMAIL PROTECTED] / 2007-01-02 21:23:02 +0100:
> > >> there is no mention of try/catch - it seems that the rather unfortunate 
> > >> word
> > >> 'catchable' was used to describe the act of setting up a user defined 
> > >> error handler
> > >> (see: http://php.net/manual/en/function.set-error-handler.php) to handle 
> > >> errors
> > >> that are triggered by the php core. [errors != exceptions]
> > > 
> > > Unfortunately. Consider this:
> > > 
> > > function f($any)
> > > {
> > > printf("%s\n", $any);
> > > }
> > > 
> > > Innocent enough? It's an E_RECOVERABLE_ERROR if $any is an object
> > > without __toString().
> > 
> > It's also an example of a former C coder's understanding of how to do
> > things in PHP.  Not only is this extremely inefficient (a function call
> > is significant overhead in PHP) it is doubly inefficient through the
> > unnecessary use of printf().  printf() is best used when you are
> > modifying the display of the output, the %s modifier by itself is
> > pointless in PHP.
>  
> This is utter crap.

Clarification: the last sentence is true as far as the contrived example
above. The rest of the message (suggestions that structuring code is
bad) and where it leads is without a base.
 

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] E_RECOVERABLE_ERROR - 5.1.6 to 5.2.0

2007-01-04 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-04 05:25:58 -0500:
> On Thu, 2007-01-04 at 10:54 +0000, Roman Neuhauser wrote:
> >
> > echo $blah . "\n" is *not* equivalent to printf("%s\n", $blah)
> 
> H, could you explain to me how it is different? I would always use
> the former unless I specifically needed formatting provided by printf(),
> and since there no formatting in the above printf() the echo to the best
> of my knowledge is indeed equivalent.

That was a early-morning brainfart from me: I was thinking about
the real code, which uses

return sprintf('%s', $any);

It could be

return (string) $any;

but I prefer the sprintf() for the same reason I prefer C++-style casts
in C++ over C-style casts.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] E_RECOVERABLE_ERROR - 5.1.6 to 5.2.0

2007-01-04 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-04 05:51:12 -0500:
> On Thu, 2007-01-04 at 10:15 +, Stut wrote:
> > Gregory Beaver wrote:
> > >  This is a good example of how the flexibility of PHP can bite you,
> > >  but is also a good example of how bad coding adds both complexity and
> > >  inefficiency to the resulting software.  If f() is called often,
> > >  there might be a noticeable speedup if it were replaced.  I once had
> > >  a complex database ORM-HTML mapping app that was about 10% faster
> > >  when I replaced all the "" strings with '' strings.  This was on a
> > >  slow machine with an early PHP, but little things like this can be
> > >  very important.
> > 
> > http://dev.stut.net/phpspeed/
> 
> You forgot to benchmark echo, everyone (me anyways) knows echo is faster
> than print. Why you ask? Because print returns a value, echo does not :)

And printf() is faster than echo:

Using 

Took 1.4402 seconds

ť Reveal output
Using 

Took 1.1628 seconds

ť Reveal output
Using 

Took 0.8289 seconds

ť Reveal output

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] E_RECOVERABLE_ERROR - 5.1.6 to 5.2.0

2007-01-04 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-04 12:55:40 +0100:
> Roman Neuhauser wrote:
> > # [EMAIL PROTECTED] / 2007-01-04 11:38:58 +:
> >> Jochem Maas wrote:
> >>> out of interest, are you logging the result of each request? your
> >>> probably getting quite a lot of hits to your phpspeed page right now
> >>> - storing the results of everyone's requests is a nice way to grab
> >>> extra/free data whilst you pick your nose ;-)
> >> I'm not at the moment. It's a good idea though, if I get some time over 
> >> lunch I'll add it.
> > 
> > What data? 
> 
> the timing results. :-)

The timing results carry no information since we don't know what other
things the computer was doing while the script was running. 
 
> How are you going to remove the effect of concurrent requests
> > for the page from the numbers? 
> 
> why would you want to - it actually make for a more realistic test.

No.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] E_RECOVERABLE_ERROR - 5.1.6 to 5.2.0

2007-01-04 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-04 11:38:58 +:
> Jochem Maas wrote:
> > out of interest, are you logging the result of each request? your
> > probably getting quite a lot of hits to your phpspeed page right now
> > - storing the results of everyone's requests is a nice way to grab
> > extra/free data whilst you pick your nose ;-)
> 
> I'm not at the moment. It's a good idea though, if I get some time over 
> lunch I'll add it.

What data? How are you going to remove the effect of concurrent requests
for the page from the numbers? The other mail I sent showing a run where
printf() came out almost twice as fast as echo clearly shows that the
numbers carry little information.

All that I could gather from several runs was that *printf() is
*slightly* slower than echo, and that the difference isn't large enough
to justify ditching *printf(). I knew this before.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] E_RECOVERABLE_ERROR - 5.1.6 to 5.2.0

2007-01-04 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-04 12:53:14 +:
> Roman Neuhauser wrote:
> > # [EMAIL PROTECTED] / 2007-01-04 12:55:40 +0100:
> >> Roman Neuhauser wrote:
> >>> # [EMAIL PROTECTED] / 2007-01-04 11:38:58 +:
> >>>> Jochem Maas wrote:
> >>>>> out of interest, are you logging the result of each request?
> >>>>> your probably getting quite a lot of hits to your phpspeed
> >>>>> page right now - storing the results of everyone's requests
> >>>>> is a nice way to grab extra/free data whilst you pick your
> >>>>> nose ;-)
> >>>> I'm not at the moment. It's a good idea though, if I get some
> >>>> time over lunch I'll add it.
> >>> What data?
> >> the timing results. :-)
> >
> > The timing results carry no information since we don't know what
> > other things the computer was doing while the script was running.
> 
> In a single request I would agree with you. But combining the results of 
> all requests over a fairly lengthy period will provide useful results.
> 
> I'm not gonna get a chance to do anything with it today. I'll have a 
> look tomorrow.

Do share your numbers. My wife does statistics for a living, let's
see what she'll have to say.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] E_RECOVERABLE_ERROR - 5.1.6 to 5.2.0

2007-01-04 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-04 14:26:11 +0100:
> Roman Neuhauser wrote:
> >>> How are you going to remove the effect of concurrent requests
> >>> for the page from the numbers? 
> >> why would you want to - it actually make for a more realistic test.
> > 
> > No.
> 
> I'll take that to mean all your work runs on servers that handle each
> request in series, one at a time, and does nothing else apart from run
> php_mod/phpcgi (& the webserver)?

No. My work has nothing to do with internet or networking in general,
consisting of a SAPI-neutral library and a command line tool.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Payflow and Php5 on FreeBSD

2007-01-04 Thread Roman Neuhauser
[re PHP 5 w/ pfpro on FreeBSD]

Dave, I just noticed that my mails to you bounce, drop me a note
from another address if you're still interested.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] E_RECOVERABLE_ERROR - 5.1.6 to 5.2.0

2007-01-04 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-04 16:34:46 -0600:
> On Wed, January 3, 2007 3:43 pm, Roman Neuhauser wrote:
> That __toString magic didn't even exist in earlier versions, and has
> already changed out from under you once, right?...

The whole program depends on the syntax and semantics of PHP 5.1, and
the fact that something hasn't changed for a long time means nothing
in this language. :)
 
> So which one really makes sense to use for robust code? :-)
> [shrug]

The one that's easier to maintain: faster to read, simpler to grok.
 
> What's impossible is enforcing and checking that try/catch is used in
> a consistent and coherent manner throughout a large body of code, from
> multiple developers/sources, such that all the pieces of a large
> software project are playing the same game plan.
> 
> try/catch *seems* really cool at first, as it localizes the
> error-handling to the code doing the work, to some degree, while
> allowing a natural semantic for dealing with the errors.
> 
> Once you have a non-trivial application, however, the try/catch that
> fires, and the error being caught, may have little or nothing to do
> with each other, as functions nested in methods wrapped around
> functions with methods inside them going umpteen layers deep...
> 
> You end up catching somebody else's error and handling it, even though
> what you THINK has gone wrong is not at all what actually went wrong,
> because they didn't write a try/catch handler where they should have.

Yeah, that can lead to unexpected behavior. It still helps prevent
crashes. 
 
> try {
>   if (something($whatever)){
> $file = fopen("/some/path/or/other", 'r');
>   }
> }
> catch ($e){
>   //handle error from opening $file
> }
> 
> Then later on after that (possibly weeks/months/years) some other
> programmer (or yourself) changes the 'whatever' function to use
> fopen() to open a file, but does NOT wrap that in a try/catch because
> it's some silly little file that "has to work"

Ok, but what harm has been done? something() presumably did the fopen()
for a reason, and couldn't work without the file handle and couldn't
succeed anyway.

Sure, the program leaves the normal path at this moment unexpectedly,
and I can understand your frustration, but it has a bug, right? And
although the program contains a bug it hasn't crashed, it just entered
whatever orderly cleanup-and-exit path you had prepared.

If fopen() didn't throw and the programmer didn't check the return value
(catch the exception in your version), you'd be screwed not even knowing
it.
 
I think you brought a solid example of superiority of exceptions over
returning error codes.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] IE, Word documents and Content Types

2007-01-04 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-04 23:36:44 +0100:
> Roman Neuhauser wrote:
> > # [EMAIL PROTECTED] / 2007-01-03 15:48:31 -0600:
> >> On Wed, January 3, 2007 2:52 pm, Philip Thompson wrote:
> >>> I have a form where a user can upload different types of documents. A
> >>> valid file type they will be able to upload is a Word Document.
> >>> However, when I view the $_FILES 'type' of a word document in Internet
> >>> Explorer, it says it's type 'application/octet-stream' instead of
> >>> 'application/msword' or 'application/vnd.ms-word'. It works fine in
> >>> Firefox and Safari.
> >>>
> >>> Any ideas why IE does this and/or how I might be able to get around
> >>> this?
> >> IE does this because MS is not interested in interoperability.
> >  
> > Back this statements with some references, will you?
> 
> do a quick google on anti-trust or something. there is plenty of evidence
> that Microsoft has and does continue to hamper and/or ignore interoperability
> on many fronts.

Yes I know. I don't care.

I was asking if he could back his statement that IE sends CT: a/o-s to
harm interoperability. I don't care what MS did elsewhere.  I'm simply
fed up with his bashing MS for artificial reasons (like his foaming over
the allegedly MS-originated Content-Disposition header).

*Especially* as the value carries no information since it's under the
control of a (potentially) malicious user (he later mentioned that
himself)! The net effect is that a naive programmer who would otherwise
merrily fall prey to an exploit has to DTRT, which is inspect the file.

That makes the whole thing a non-issue, and the opening remark was
completely unwarranted, unasked for.

> >> Note that application/octet-stream is valid for any kind of document
> >> whatsoever for an upload.  For output, that would require the browser
> >> to download the document rather than attempt to display it.  More on
> >> that here:
> >> http://richardlynch.blogspot.com/
> > 
> > To the OP: read that rant for amusement, but don't use the "advice"
> > rlynch gives, it's nonsense. If you don't believe me, check the RFCs
> 
> richard's practical experience in dealing with this things is nonsense?

It's "advice", not "experience".

> he has been dealing with this kind of stuff [I'm referring just to his
> experience/work with php for the purpose of this reply] for longer than
> most of us have even heard of php - and for companies that most of us
> would give our right arm to work for. his rant is based on lots of experience
> on how to make things that work, rather than making that should work because
> they adhere to any/every given standard (but don't work because of any number
> of real world situations)

I already wrote it:

> > If you don't believe me, check the RFCs
 
Really, please do it, I beg you. Read the RFCs I quoted in the last
installment of the Content-Disposition discussion.

Richard Lynch:

> It *HAS* to prompt you for a filename and do a download, by the
> original HTTP RFC spec.  Please read more RFCs until you find the one
> about "application/octet-stream"

> If the UA opens up "application/octet-stream" it is in direct
> violation of one of the few HTTP standards that every other UA on the
> planet actually honors!

The HTTP standard:

Nothing, zip, nada. HTTP doesn't generally discuss presentation of entities
contained in responses.

Richard Lynch:

> Not to mention that it's a STUPID thing for MS IE to have done in the
> first place, to re-purpose a MIME email header for HTTP.

The HTTP standard:

   HTTP/1.1 uses many of the constructs defined for Internet Mail (RFC
   822 [9]) and the Multipurpose Internet Mail Extensions (MIME [7]) to
   allow entities to be transmitted in an open variety of
   representations and with extensible mechanisms. However, RFC 2045
   discusses mail, and HTTP has a few features that are different from
   those described in RFC 2045.

Indeed, how stupid of the HTTP authors to repurpose the MIME Content-Type
header! The "application/octet-stream" names a *MIME type*, FFS! Those
repurposes weren't stupid?

Richard Lynch:

> It doesn't even make sense, since Content-Disposition has a MIME type
> embedded in it, which may or may not match the Content-type of the
> HTTP Request!


RFC 2183 defines the Content-Disposition header using a grammar which
does not include content type:

 disposition := "Content-Disposition" ":"
disposition-type
*(";" disposition-parm)

 disposi

Re: [PHP] E_RECOVERABLE_ERROR - 5.1.6 to 5.2.0

2007-01-04 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-04 18:45:07 -0600:
> On Thu, January 4, 2007 6:17 pm, Roman Neuhauser wrote:
> > Ok, but what harm has been done? something() presumably did the
> > fopen() for a reason, and couldn't work without the file handle and
> > couldn't succeed anyway.
> >
> > Sure, the program leaves the normal path at this moment unexpectedly,
> > and I can understand your frustration, but it has a bug, right? And
> > although the program contains a bug it hasn't crashed, it just entered
> > whatever orderly cleanup-and-exit path you had prepared.
> >
> > If fopen() didn't throw and the programmer didn't check the return
> > value (catch the exception in your version), you'd be screwed not
> > even knowing it.
> >
> > I think you brought a solid example of superiority of exceptions over
> > returning error codes.
> 
> over returning error codes and not DOING anything with them?  Sure.
> 
> Over well-written code that does something with the returned error
> codes? no.  Just a stylistic difference really, if all developers
> consistently did their error-checking, and did it fairly well.
> 
> Alas, they don't.

That's exactly the point. Programmers don't check return values,
programs have bugs.
 
> And, suppose it's NOT an fopen() that was the problem deep in the guts
> of the other guy's code.
> 
> Now you are catching an error and you have NO IDEA what the [bleep] to
> do with it.

If you really don't know what to do, then the right thing is probably an
orderly exit of the application, no?

> At least with error code returns, you are USUALLY dealing with a
> specific way to get those codes (in PHP, not C-style shell-style
> pass-the-buck error code bubble-up).
 
With error codes, you are USUALLY dealing with crashes and wrong
behavior. Compiled programs segfault, programs in PHP produce
unspecified numbers of E_NOTICE, E_WARNING, and quite easily drop dead
with an E_FATAL before returning to where you'd be complaining that you
don't know what to do with the error!

> And, of course, you just ignored the question of another catch block
> doing something you wish it didn't do...

I don't know what that means.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Removing UTF-8 from text

2007-01-04 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-04 16:17:18 -0600:
> I don't mind answering Regex questions (PHP-related) because I know it
> took me *years* to even come close to being able to do anything with
> PCRE that wouldn't have been done faster/easier with str_replace and
> friends.

The syntax is very dense which makes it easy to forget if you don't
practise. On the other hand, it's very easy to stay in form: regular
expressions are everywhere, even the Perl-compatible ones.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] is_writable() not working on PHP 5.1.6

2007-01-05 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-05 18:01:30 +0700:
> if (file_exists($file)) {

$file

>   if(!is_writeable($menu_filename)){

$menu_filename

>   echo "the file is not writable";
>   }
> } else echo "The file does not exist";
> 
> I have set the permissions to 777 for the file

Which of the two files?

Use the var_dump(), Luke!

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Removing UTF-8 from text

2007-01-05 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-04 16:19:19 -0600:
> On Thu, January 4, 2007 2:28 am, Roman Neuhauser wrote:
> > # [EMAIL PROTECTED] / 2007-01-04 08:21:37 +0200:
> >> to grasp, so I use the English version. That may not be a problem
> >> for you, but it is for me.
> >
> > Your written English is very good. If you can understand what you
> > wrote and can read replies (in English) from the list, you should
> > have no problems understanding the manual.
> 
> Well that's funny.
> 
> As a native speaker, I often have trouble understanding the manual,
> especially the PCRE bits.
> 
> I understand all the words, and all the sentences make perfect
> grammatical sense.
> 
> But how they apply and what the implications are and WHEN they apply...

A picture is worth of a thousand words. If you're confused, experiment!

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Removing UTF-8 from text

2007-01-05 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-05 11:05:48 +0200:
> On 05/01/07, Roman Neuhauser <[EMAIL PROTECTED]> wrote:
> >The syntax is very dense which makes it easy to forget if you don't
> >practise. On the other hand, it's very easy to stay in form: regular
> >expressions are everywhere, even the Perl-compatible ones.
> 
> I suppose it's rather easy to stay physically fit as well, assuming
> that you run every day. However, I sit too many hours in the
> university library and not enough running nor coding regexes. So, my
> abilities in both are not what they should be. Thanks for bearing with
> me, though.

I have seen many recommendations of Mastering Regular Expressions by
Jeffrey Friedl (O'Reilly), perhaps it's in your library. I haven't read
that book.

"man perlre" has gobs of info, it's a tough text, but points to
tutorials and further references.

"man pcre" lists all manpages of that package.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Problem with file reading

2007-01-05 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-05 16:34:41 +:
> Delta Storm wrote:
> >I'm a beginner and i'm still learning PHP and I got a problem:
> >  
> >$file = "http://localhost/test_folder/test1.txt";; //I have 
> >also  tried "test_folder/test1.txt" and "text1.txt"
> >  
> >$fh = fopen($file, "r") or die("Could not open file!");
> >
> >$data = fread($fh, filesize($file)) or die ("Could not 
> >read   file!");
> >
> >fclose($fh);
> >
> >echo $data;
> >
> >The file exist, I'm using apache server on my PC for practicing and 
> >the file is located in the servers root folder on the subfolder 
> >"test_folder".
> 
> Is there a reason why you're trying to access it through a URL? If not, 
> please don't.
> 
> The file path needs to be relative to the current file. So if your PHP 
> file is in the root, "test_folder/test1.txt" should work. If your PHP 
> file is in a folder named code in the root, "../test_folder/text1.txt" 
> should work.

Arent' you confusing this with something else? fopen() is affected
by the current working directory of the process calling it. What kind of
"root" are you talking about? The filesystem root, "/"?

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Problem with file reading

2007-01-05 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-05 17:17:46 +:
> Roman Neuhauser wrote:
> ># [EMAIL PROTECTED] / 2007-01-05 16:34:41 +:
> >>Delta Storm wrote:
> >>>I'm a beginner and i'm still learning PHP and I got a problem:
> >>> 
> >>>   $file = "http://localhost/test_folder/test1.txt";; //I have 
> >>>also  tried "test_folder/test1.txt" and "text1.txt"
> >>> 
> >>>   $fh = fopen($file, "r") or die("Could not open file!");
> >>>
> >>>The file exist, I'm using apache server on my PC for practicing and 
> >>>the file is located in the servers root folder on the subfolder 
> >>>"test_folder".
> >>>  
> >>Is there a reason why you're trying to access it through a URL? If not, 
> >>please don't.
> >>
> >>The file path needs to be relative to the current file. So if your PHP 
> >>file is in the root, "test_folder/test1.txt" should work. If your PHP 
> >>file is in a folder named code in the root, "../test_folder/text1.txt" 
> >>should work.
> >
> >Arent' you confusing this with something else? fopen() is affected
> >by the current working directory of the process calling it. What kind of
> >"root" are you talking about? The filesystem root, "/"?
> 
> The OP referred to the "servers root folder". Now stop nit-picking and 
> go back to quoting standards.

I'm not nitpicking. If the webserver process (assuming mod_php) runs in
a different directory, fopen("relative/to/documentroot/path.txt") won't
help him at all, and as far as I can tell, it's quite common for web
servers to run with pretty much any cwd, often / or /var/empty (these
are local filesystem paths).

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Some advice / points / help

2007-01-05 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-05 16:37:27 +0100:
> Steven Macintyre wrote:
> > http//steven.macintyre.name/arb/showlineups.jpg
> 
> that URL make my browser end up here:
> 
>   http://www.w3.org/Protocols/
> 
> is .name even a top level domain? did that happen whilst I was sleeping?

That's because of the "http//" (notice the missing colon).
name. is a valid TLD, just like museum.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Problem with file reading

2007-01-05 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-05 17:40:49 +:
> Using mod_php with Apache will make the current directory the directory 
> that contains the script being requested. I am assuming that the OP is 
> trying to access the file from the script that is being requested and 
> not an included file in a different directory - I should have been 
> clearer on that.
> 
> I never said anything about being relative to the document root - you 
> pulled that out of somewhere yourself.

You're right, sorry for the noise!

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] E_RECOVERABLE_ERROR - 5.1.6 to 5.2.0

2007-01-05 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-05 16:29:04 -0600:
> Pretend you are using some library of software with a lot of code, and
> you have a lot of your own code.
> 
> There are try/catch blocks all over the place.
> 
> The library does something with try/catch, and you don't like the way
> it handles the error.
> 
> It's very difficult to change that behaviour.

How does that differ from a situation where you're unhappy with a way
a procedural library handles error situations?

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Exceptions: How much is too much.

2007-01-07 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-07 13:17:23 -0500:
> On 1/5/07, Paul Scott <[EMAIL PROTECTED]> wrote:
> >On Fri, 2007-01-05 at 00:44 -0500, Craige Leeder wrote:
> >> The question is: How much is too much. Should I use Exceptions to
> >> handle all of my error reporting/triggering? How about catching them?
> >> I mean, if I'm using Exceptions for all of my error handling, I could
> >> easily end up wrapping my entire script in a try block(or at least
> >> having almost all my end-code within a number of them).
> >
> >Not sure if I am doing it correctly either, but, what I do is use
> >try/catch blocks to instantiate all of the objects that I need and then
> >let the script take over. I also use exceptions to handle SQL errors in
> >my db abstraction object(s). That way, only real messes are caught and
> >the script then displays a graceful exit page to the user instead of
> >screen vomit that may scare them off.
> 
> Does anybody else have any input? Not to be pushy, but I'm in the
> middle of programming a framework for a site.

I didn't see a real question in your original email. Otherwise, the
answer is 42.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] OT - web based project management tool

2007-01-07 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-07 21:34:48 +0200:
> What project management tool do you use for your project? Is dotProject
> (www.dotproject.org  ) only alternative?

trac is popular.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Question regarding include() and symlinks to directories

2007-01-07 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-08 08:13:11 +0100:
> From: Richard Lynch [mailto:[EMAIL PROTECTED]
> > Sent: Sat 1/6/2007 0:17
> > To: Karl Pflästerer
> > Cc: php-general@lists.php.net
> > Subject: Re: [PHP]  Question regarding include() and symlinks to directories
> >  
> > On Thu, January 4, 2007 2:47 pm, Karl Pflästerer wrote:
> > > In my opinion include() should respect symlinks to directories and not
> > > dereference them before finding the file to include. Or am I wrong
> > > here?
> > > The PHP version is 5.1.6 (will soon be updated).
> > 
> > Anything else is more like playing an Adventure Game than Programming.
> > 
> > I can see arguments both ways for when to work out the symlink, so
> > you'd have to take this up with Internals to get a change made...
> 
> if I can still contribute to this topic, I suggest you never use simlinks.
> We experienced very bad maintenance problems at a customer : when
> copying new files through FTP, the simlinks were often erased or
> overwriten.  And this occured on every upgrade of the scripts.

Shouldn't that have been: "never use broken FTP clients"?

NB, I hope I got the quoting right, but if someone got misattributed,
please blame the original quoting.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Sending file stored on server via email - How?

2007-01-08 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-08 19:06:16 +1100:
> Hello everyone,
> 
> I store files on the server (.pdf, .doc, .txt, etc.) which are
> referenced by entries in a database. The filenames are only stored in
> the database and are not BLOBs.
> 
> What I'd like to do is to be able to show a web form wherein a user
> can choose stored documents on the server and send it to an email.
> 
> What's the easiest way to go about this? Specifically, what's the
> easiest way to read a file from the server and send it as an email
> attachment.

uuencode yourfile | mail -s "my subject" [EMAIL PROTECTED]

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] question about str_replace function

2007-01-08 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-08 11:35:06 +0100:
> Dick Jiang wrote:
> >  I think you'd better use regular expression to replace the word
> 
> agreed - only it a serious dive in the deep end of regexps - the OP may
> have to use a negative lookahead assertion, something like:
> 
> $string="avenue 1, ave 1 both have av+e :-)";
> $words = preg_replace("#\\bave(?!nue)#", "avenue", $string);

That'll also make "average" into "avenuerage". A word-boundary assertion
should (admittedly, I didn't check) be fine on both sides: '#\bave\b#'.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] unzip openDocument in safe mode

2007-01-09 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-09 17:57:40 +0100:

[ safe_mode-induced usability problems]

> http://www.php.net/manual/de/function.ziparchive-addfile.php
> and
> http://at.php.net/manual/de/function.ziparchive-getfromname.php
> would be fine.
> If there is a package for BSD that would be a solution. 

If you're talking about FreeBSD, then there's archivers/pecl-zip.

> Recompile PHP is no option.

Why? Do you realize that your magic "package for BSD" is a fancy tarball
with the software compiled from the source?

> The only thing I found is pclzip and that makes problems

Then you're in trouble. The two functions you reference above come from
pecl-zip.

BTW, your support request has serious shortcomings, such as failure to
state your PHP version, or saying "BSD", which means nothing.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] newbie question regarding URL parameters

2007-01-09 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-09 17:36:55 +:
> Wow, there are some really bitchy, unattractive people here. No wonder some
> people bail out of IT. Don't confuse knowledge for wisdom.

I don't see anything bitchy in the whole email. Don't confuse terseness
with bitching.

Oh, and also don't top-post, thanks.
 
> On 1/9/07, tedd <[EMAIL PROTECTED]> wrote:
> >
> >At 9:17 PM -0500 1/5/07, <[EMAIL PROTECTED]> wrote:
> >>You'll probably get 50 answers to this, but here's probably what
> >happened.
> >>
> >>There's a setting called "register globals" that will turn your
> >>name=me and age=27 into $name = "me" and $age = "27".  It used to be
> >>turned ON by default.  This was generally considered to be bad
> >>security, so it now defaults to OFF.
> >>
> >>To get these variables, just use the $_GET system variable.
> >>
> >>$name = $_GET['name'];
> >>$age = $_GET['age'];
> >>
> >>Easy!
> >>
> >>Best of luck!
> >>
> >>-TG
> >
> >Just to add to -TG advice, you should also clean those inputs. IWO,
> >make sure the values fall within what you expect. Basic security.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Parsing an XML return from a POST - resend with a little more information

2007-01-09 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-10 09:47:39 +1100:
> I have spent most of last night and today looking at XML parsing and now am
> totally confused. Some testing I have done suggests that SimpleXML is not the
> way to go however I am open to suggestions if it might be an answer.

What makes you think simplexml is not for you? I don't say it is, but
you need to tell us exactly what you need.
 
> I would appreciate any help or advice on how to parse this XML response and 
> break it up
> into either an array or individual variables. It is important for this
> application to not only get the data contained between beginning and end tags
> but also the attributes as they contain important data returned from the 
> server.
> I am the first to admit that PHP XML Parsing has me lost.

http://php.net/manual/en/ref.simplexml.php has quite a few examples in
the user-contributed notes. Have you seen the manual?
 
> One other question I do have is that all of the examples I have seen, using 
> the
> xml_parser, seem to be designed around a file being read into the parser. Is 
> it
> possible for the XML data to be contained in a variable and then used in the
> parser?

Many of the examples at http://php.net/manual/en/ref.simplexml.php use a
string variable as the source.

If that page in the manual is correct and there are no bugs, you should
be able to take off with

var_dump(new SimpleXMLElement($xmlstr));

where $xmlstr contains the server response.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Parsing an XML return from a POST - resend with a little more information

2007-01-09 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-10 12:09:40 +1100:
> RN> What makes you think simplexml is not for you? I don't say it is, but
> RN> you need to tell us exactly what you need.
> RN>
> 
> From what I can see, unless I am mistaken, SimpleXML can not deal with
> attributes within a tag. It only seems to deal with data contained between a
> start tag and an end tag. I have a lot of data contained within the start tags
> that I must extract.

A cursory glance at the ref.simplexml.php page led me to
http://www.php.net/manual/en/function.simplexml-element-attributes.php,
isn't this what you want?

> RN> http://php.net/manual/en/ref.simplexml.php has quite a few examples in
> RN> the user-contributed notes. Have you seen the manual?
> RN>
> 
> Yes of course I have seen the manual.
> 
> RN> Many of the examples at http://php.net/manual/en/ref.simplexml.php use a
> RN> string variable as the source.
> 
> Yes I know they do but the examples for xml_parse() do not use a string.

Uh, http://www.php.net/manual/en/function.xml-parse.php says xml_parse()
takes a string. *shrug*
Anyway, I'm still not convinced simplexml isn't enough for you.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Parsing an XML return from a POST - resend with a little more information

2007-01-09 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-10 18:23:19 +1100:
> So far I have had no luck with simpleXML at all.

So far I am not convinced you have tried it at all.

Show us the code you wrote and describe how its behavior differs from
your expectations.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Parsing an XML return from a POST - resend with a little more information

2007-01-10 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-10 09:38:30 +0100:
> Richard Luckhurst wrote:
> > Hi Jochem,
> > 
> > Thanks for your reply. Here is a short sample of the XML I have to parse. I 
> > need
> > the data in the attributes as well as the data in the character fields.
> > 
> > 
> > 
> 
> I'm fairly certain that this 'ypsilon' tag is going to cause a
> problem - although that's just a guess, it's based on the 'knowledge'
> that a valid XML document *must* have only 1 root element
> (which would be 'fareResponse' in this case).

That ypsilon is a *preprocessing instruction* AFAICT.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Parsing an XML return from a POST - resend with a little more information

2007-01-10 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-10 09:52:34 +:
> That ypsilon is a *preprocessing instruction* AFAICT.

s/pre//

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] mssql_* overhead

2007-01-10 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-10 10:49:35 -0600:
> On Jan 10, 2007, at 10:09 AM, Jochem Maas wrote:
> >Philip Thompson wrote:
> >>Does anyone know if the mssql_connect/_init/_bind/etc require a  
> >>lot of overhead?

You can quite easily find out what effect those function have on the
performance profile of your program with xdebug.

> >>I have a page that requires multiple function calls and each of those
> >>opens a new connection to the database, performs the necessary  
> >>actions in stored procedure(s), and then closes the connection.
> >>However, I  found this to be slower than I was wanting.

*What* have you found slower? Which of the multiple actions you mention
are you talking about?

> >>So I thought, just create one connection and assign it to the
> >>SESSION (a global), and in each  function that requires a
> >>connection, call that SESSION variable. At the end of the page,
> >>close the connection and nullify the variable.
> >
> >I wouldn't stick it in the SESSION superglobal (my tactic is  usually
> >to create a little wrapper class to the relevant DB functions and
> >store the  connection as a property of the class/object.
> >
> >basically opening & closing the connection once per request is the  
> >way to go - if your going to using a global, better [than $_SESSION]
> >to  stick it in $GLOBALS imho.
> 
> Would there be any speed decrease with multiple users (hundreds)  
> sharing this $GLOBALS variable (if that makes sense)?
 
Looks like you're confused about semantics associated with $GLOBALS and
$_SESSION. In the context of web servers, $GLOBALS is limited to the
current request, $_SESSION persists across requests for a single
*session*, just as Jochem wrote.


-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] 5.2 installer not working and iis looking for password

2007-01-10 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-10 20:26:44 -:
> 
> I am trying to install 5.2 via the installer but the when I try and open a 
> page IIS asks for a password and the page is not found.
> 
> Any ideas?

Umm, configure the webserver manually?

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] reg globals

2007-01-11 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-11 10:08:07 -:
>  $userfile= $_POST['userfile'];
> $mail->AddAttachment($userfile, $_FILES['userfile']['name']);
> 
> it now doesn't attach. any ideas?

Check the description of $_FILES at
http://www.php.net/manual/en/features.file-upload.php#features.file-upload.post-method

It says:

$_FILES['userfile']['name']
The original name of the file on the client machine.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Extending 'include' behavior in a function

2007-01-11 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-11 09:47:04 +0100:
> Eli wrote:
> > [extending include]
> >
> > Your solution is good when you know what variables you want to transfer
> > ahead, and then make a list of them. But if I want to transfer all the
> > variables in the current environment scope?

> as it stands I get the feeling your on the road to nowhere regarding
> this particular idea, php just doesn't offer the functionality you
> require.

Besides being technically infeasible, it wouldn't even be very useful
AFAICS (put bluntly: smells like a hackaround for a very bad design).

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Normalized Numbers

2007-01-12 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-12 01:57:27 +0100:
> Brian P. Giroux wrote:
> > If anyone can help me out with that or provide any other advice about
> > the rest of it, I'd be grateful.
> 
> > The file can be found at http://www.senecal.ca/normnums.php.txt

> keep commenting all your code to that extent! you do us proud :-)

I find the *inline* comments superfluous and cluttering the code. They
don't add any insight, they simply repeat what the code already says very
succintly:

 1  function is_valid_isbn10_check_digit($cd) {
 2// check if th function was passed only a single character
 3if(1==strlen($cd)) {
 4  // check if the digit is a valid ISBN-10 check digit
 5  if(is_numeric($cd) || 'x'==$cd || 'X'==$cd) {
 6return true;
 7  } else { // the digit is invalid
 8return false;
 9  }
10} else { // the check digit isn't 1 character
11  return false;
12}
13  }

Comments on lines #2, #4, #7, #10 only restate painfully obvious things.
Who needs to explain that "13 == strlen($ean)" checks that the length of
$ean is 13?

This shorter version is more readable for me:

 1  function is_valid_isbn10_check_digit($cd)
 2  {
 3  return (1 == strlen($cd)
 4  && (is_numeric($cd) || 'x'==$cd || 'X'==$cd)
 5  );
 6  }

The code is quite complicated for no good reason I could see:

 1  function is_valid_ean($ean) {
 2//check that the string is 13 characters long
 3if(13==strlen($ean)) {
 4  // make sure all digits are numeric
 5  if(is_numeric($ean)) {
 6if(0==digit_sum($ean,1,1,3)%10) {
 7  return true;
 8} else { return false; }
 9  } else { return false; }
10} else { return false; }
11  }

First step:

 1  function is_valid_ean($ean) {
 2if(13==strlen($ean)) 
 3  if(is_numeric($ean))
 4if(0==digit_sum($ean,1,1,3)%10)
 5  return true;
 6return false;
 7  }

Second step:

 1  function is_valid_ean($ean) {
 2if(13==strlen($ean)
 3  && is_numeric($ean)
 4  && (0==digit_sum($ean,1,1,3)%10))
 5  return true;
 6return false;
 7  }

Third step:

 1  function is_valid_ean($ean) {
 2return (13 == strlen($ean)
 3&& is_numeric($ean)
 4&& (0 == (digit_sum($ean,1,1,3) % 10))
 5);
 6  }

The last version tells me what I need to know, and tells it only once!
The three lines are so little of so "uninteresting" code, (there's
obviously nothing overly complicated going on) that they don't need more
explanation than a good function name provides.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Normalized Numbers

2007-01-12 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-12 13:39:59 +0100:
> Roman Neuhauser wrote:
> > # [EMAIL PROTECTED] / 2007-01-12 01:57:27 +0100:
> >> Brian P. Giroux wrote:
> >>> If anyone can help me out with that or provide any other advice about
> >>> the rest of it, I'd be grateful.
> >>> The file can be found at http://www.senecal.ca/normnums.php.txt
> > 
> >> keep commenting all your code to that extent! you do us proud :-)
> > 
> > I find the *inline* comments superfluous and cluttering the code. They
> > don't add any insight, they simply repeat what the code already says very
> > succintly:
> 
> it is anything but superfluous imho - the comment describes what the line of
> code *should* be doing - given that the code itself maybe changed (and
> possibly broken)

That's exactly one of the things that make comments dangerous: they can easily
diverge from the code!

Use lots of small functions, well named, with well defined tasks.
It's easy to see where the code lies about itself then.
Use automated tests. You won't need to check whether the code actually
does what a comment says: the test either succeeded or failed.

I know it sounds crazy, but (most) comments are evil.  Comments are are
excuses for better code, they're often no more than a vague repetition
of what the code says. If the code doesn't describe what it's doing
while it's doing it, then the code should be fixed.

(Re "should": that word actually appears in the documentation comments,
reducing their utility. "Should" is a human pronounciation of a
nonexistent operator with undefined semantics, so I had to look at the
code anyway.)

> the comment serves as a mechanism to check that the specific line of
> code *actually* does what was intended - with the comment there is no
> way to know for sure that the logic of the code (even though it may be
> syntactically correct) does what the original developer *intended*

Comments are a poor tool to find out or enforce anything about code.
Who put the bugs in? Humans. What makes humans better suited to find
bugs in the code than computers?
 
> I have found myself fixing logic bugs in code that I *thought* did what it
> intended but in reality did something slightly different - related comments
> help to remind me/you/us/them what the intention was regardless of what was/is
> actually implemented.

Perhaps the code had some of the bad smells Fowler (w/ Beck, IIRC)
describes in Refactoring. Also, automated tests would be waaay more
useful: the bugs wouldn't get in the code in the first place!

> > Comments on lines #2, #4, #7, #10 only restate painfully obvious things.
> > Who needs to explain that "13 == strlen($ean)" checks that the length of
> > $ean is 13?
> 
> consider it not some much an explanation but a statement of intent (see 
> above).

See my objections above as well.

Which line contains a bug?

 4  // check if the digit is a valid ISBN-10 check digit
 5  if(is_numeric($cd) || 'z'==$cd || 'Z'==$cd) {

> secondly I, personally, find it useful to write a stub function with comments
> in that describe the various logic steps the function will be doing and then 
> later
> actually write the code that accomplishes it.
 
When I want to document a piece of code I turn it into a function.
I sum up the comment I would have written into that function's name.

If the code needs commenting then it's too complicated, there's not enough
structure, you're using bad function/variable names, or doing something
else wrong.

> at the end of the day the ammount of comments written/used is somewhat
> down to personal preference/requirements. that said comments can't really hurt
> so long as the content of the comments are accurate!

Yes. What tool (humans introduce bugs, I want something automated) do
you use to enforce that the code never deviates from the comments?

> >  1  function is_valid_ean($ean) {
> >  2return (13 == strlen($ean)
> >  3&& is_numeric($ean)
> >  4&& (0 == (digit_sum($ean,1,1,3) % 10))
> >  5);
> >  6  }
> > 
> > The last version tells me what I need to know, and tells it only once!
> > The three lines are so little of so "uninteresting" code, (there's
> > obviously nothing overly complicated going on) that they don't need more
> > explanation than a good function name provides.
> 
> I dispute the value you give the comments - obviously the ability of the
> programmer(s) writing/using the code determines to some extent the level of
> comments that are useful -

Yes, that's obvious, but there's a bottom. I claim that comments like
these do the code and p

Re: [PHP] Unbuffered Query

2007-01-13 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-12 23:30:15 -0600:
> Warning: mysql_data_seek(): Offset 0 is invalid for MySQL result index
> 116 (or the
> query data is unbuffered) in
> /www/acousticdemo.com/web/complaints/publish.cron on
> line 26
 
http://www.php.net/manual/en/function.mysql-unbuffered-query.php:

You cannot use mysql_num_rows() and mysql_data_seek() on a result set
returned from mysql_unbuffered_query().

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Normalized Numbers

2007-01-13 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-12 14:40:04 +:
> # [EMAIL PROTECTED] / 2007-01-12 13:39:59 +0100:
> > Roman Neuhauser wrote:
> > > # [EMAIL PROTECTED] / 2007-01-12 01:57:27 +0100:
> > >> Brian P. Giroux wrote:
> > >>> If anyone can help me out with that or provide any other advice about
> > >>> the rest of it, I'd be grateful.
> > >>> The file can be found at http://www.senecal.ca/normnums.php.txt
> > > 
> > >> keep commenting all your code to that extent! you do us proud :-)
> > > 
> > > I find the *inline* comments superfluous and cluttering the code. They
> > > don't add any insight, they simply repeat what the code already says very
> > > succintly:
> > 
> > it is anything but superfluous imho - the comment describes what the line of
> > code *should* be doing - given that the code itself maybe changed (and
> > possibly broken)
> 
> That's exactly one of the things that make comments dangerous: they can easily
> diverge from the code!
> 
> Use lots of small functions, well named, with well defined tasks.
> It's easy to see where the code lies about itself then.
> Use automated tests. You won't need to check whether the code actually
> does what a comment says: the test either succeeded or failed.

I converted the original "tests" (they don't evaluate the results,
that's up to the user) into a few Testilence-based test cases, and then
modified the code a bit. I removed almost all inline comments to let the
code come forward and speak for itself, and then reduced the code to
speak more clearly. It's not something I'd consider finished, but you
get the idea.

Regarding the digit_sum() "bug", I don't understand why you just don't
strrev() the input string. You'll need to swap the weights as well if
the string consists of an even number of characters. There's a test case
showing this as well.

The tests are really straight conversions of the old ones. I don't think
they're good, tests should IMO represent boolean questions about the
code, and provide answers to them. The old tests didn't ask any clear
questions, this is carried over to the new ones.

You can see my version at http://codex.sigpipe.cz/tmp/normnums.phps,
Testilence is at http://www.testilence.org/.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] fopen and fwrite r+

2007-01-13 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-13 17:32:00 -0500:
> I can write to the bottom of the file, no problem, but if I want to  
> put new entries at the top of the file I have problems:
> the previous entry is partially overwritten and mangled..
 
you cannot prepend to a file. to do that you need to create a new
file, write the new data in it, and append data from the old file.

class newLiner extends IteratorIterator
{
function current()
{
return $this->getInnerIterator()->current() . "\n";
}
}

$lines = array('line 1', 'line 2', 'line 3');
$data = new newLiner(new ArrayObject($lines));
$file = new SPLFileObject('file', 'r');
$temp = new SPLFileObject('temp', 'w');

$all = new AppendIterator;
$all->append($data);
$all->append($file);

foreach ($all as $line) {
$temp->fwrite($line);
}

$file->fflush();
$temp->fflush();
unset($file); unset($temp);

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



[PHP] colon in coma [was: Re: [PHP] Anyone would like to test my open source application http://sourceforge.net/projects/dfo/ ?]

2007-01-14 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-13 18:59:10 -0800:
>  },  //<-- offending colon

# [EMAIL PROTECTED] / 2007-01-14 04:49:10 +0100:
> ah ok i am sorry, you can just remove the , (the offending colon)

Guyes, what were you doing during your biology classes? ;)

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Normalized Numbers

2007-01-14 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-14 10:49:49 -0500:
> >  1  function is_valid_ean($ean) {
> >  2return (13 == strlen($ean)
> >  3&& is_numeric($ean)
> >  4&& (0 == (digit_sum($ean,1,1,3) % 10))
> >  5);
> >  6  }
> 
> Again, WOW! This is certainly the version I will use (if you don't mind).

Not at all.  Also see my other post in this thread, I made more changes
to your code, you're welcome to use anything you find useful.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



[PHP] circular dependency between libraries

2007-01-14 Thread Roman Neuhauser
I have a circular dependency, and am looking for thoughts on breaking
the cycle without (much) redundancy or hard to automate procedures.

I'm developing two programs, Testilence, a unit testing library, and
Amock (library for mock object generation, but that's irrelevant in this
discussion); both programs have unit tests based on Testilence, but
Amock itself should not depend on Testilence, and neither should contain
(or depend on) nontested code.

Testilence contains some utility classes I'd like to use in Amock (or
indeed, anywhere).  I could "fork" them, but would like to avoid this
if at all possible.  I think I can't pull them out into a separate
library for both Amock and Testilence to depend on because that would
create a dependency loop between the utility and Testilence since I'd
like to keep using Testilence for the utility's unit tests.

Both Amock and Testilence are versioned using Subversion, so I could
leave the classes in Testilence and use svn:externals to put them in
Amock too.  That would lead to name clashes if both programs were used
together, and that is a showstopper.

Any ideas?

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Normalized Numbers

2007-01-14 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-14 14:51:30 -0500:
> I tried to install Testilence on my Ubuntu using Gnu make 3.81beta4(my
> skills as a Linux administrator are weaker than my PHP skills) but was
> unsuccessful :(

What problems did you have?

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] circular dependency between libraries

2007-01-15 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-14 20:47:02 +0100:
> Roman Neuhauser wrote:
> > I have a circular dependency, and am looking for thoughts on breaking
> > the cycle without (much) redundancy or hard to automate procedures.
> > 
> > I'm developing two programs, Testilence, a unit testing library, and
> > Amock (library for mock object generation, but that's irrelevant in this
> > discussion); both programs have unit tests based on Testilence, but
> > Amock itself should not depend on Testilence, and neither should contain
> > (or depend on) nontested code.
> > 
> > Testilence contains some utility classes I'd like to use in Amock (or
> > indeed, anywhere).  I could "fork" them, but would like to avoid this
> > if at all possible.  I think I can't pull them out into a separate
> > library for both Amock and Testilence to depend on because that would
> > create a dependency loop between the utility and Testilence since I'd
> > like to keep using Testilence for the utility's unit tests.
> 
> isn't there a circular dependency anyway? given that you unit test
> Testilence with Testilence?
 
I should've stressed that I'm coming from the packaging side (think RPMs
or such).  You can run Testilence's test suite without having Testilence
installed (both are in the same tarball), so there's no cycle.

The goal is to make a successful run of the test suite a prerequisite of
the utility installation...  Think RPM or similar: if X.rpm depends on
Y.rpm in runtime, you cannot make Y's installation depend on execution
of commands from X.

> if these utility classes are utility classes I wonder whether it's not better
> if they have no external dependencies?
 
That depends on relative merits in individual situations, I cannot
answer this question as is either way.

> whilst reading about Testilence I remember coming across a mention of runkit

runkit is mention because I'm considering its use for better test
isolation, I haven't thought of using it for "normal" code.

> ... whilst I wonder whether using runkit for anything other than experimental
> stuff, could runkit not offer a solution (e.g. renaming the class dependent on
> the context of it's usage)? probably not, right?

How would this work?

> > Both Amock and Testilence are versioned using Subversion, so I could
> > leave the classes in Testilence and use svn:externals to put them in
> > Amock too.  That would lead to name clashes if both programs were used
> > together, and that is a showstopper.
> 
> given that they are the same code would conditional loading of the utlity
> classes not work? i.e. only load if they don't already exist
 
That seems quite fragile, but I admit I haven't thought it through.

> this could be augemented with the use of a [number of] Interfaces - if
> the class already exists and doesn't implement the required interfaces
> then your code bails out.

I'm not concerned about the user who's *attempting* to shoot himself in
the foot, I'm worrying about my code shooting an unsuspecting user in
the butt.

So far I'm leaning towards pulling the utility out from Testilence,
sacrificing the ability to unit test the library without jumping through
hoops.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] I lied, another question / problem

2007-01-15 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-15 16:31:32 -0500:
> I have file which I use for validating which includes the following
> function:
> 
> function invalidchar($strvalue)
> {
>   if(!ereg("^[[:alpha:][:space:]\'-.]*$", $strvalue)) {

That regexp matches if $strvalue consists of zero or more ocurrences
of a letter, a whitespace character, and any character whose numeric
value lies between the numeric values of "'" and "." in your locale.
Zero or more means it also matches an empty string.


-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] memory allocation problems with fgets

2007-01-15 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-15 16:43:50 +:
> Hi,
> I have a script parsing the lines of a (rather large) file:
>  
> while (!feof($outPluginfh)) {
> $outPlugin = fgets ($outPluginfh,1024);
> # process $outPlugin here...
> 
> }
> 
> Now, with large files I was running into an memory allocation error
> (after 16MB of allocation..).
> It looks that php is allocating space for each fgets call, an not
> releasing it, in spite of the return value being always  assigned to the
> same variable.
> I red in other posts that for removing this 16MB limit I can simply put
> the statement
> ini_set("memory_limit",-1);
> at the beginning, and in fact this line does the job.

What makes you sure that loop is the culprit?  Does the script still
work if you set memory_limit to -1 right before the loop, and back to
its old value right after it?

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] I lied, another question / problem

2007-01-15 Thread &#x27;Roman Neuhauser'
# [EMAIL PROTECTED] / 2007-01-15 18:33:31 -0500:
> > From: Roman Neuhauser [mailto:[EMAIL PROTECTED] 
> > # [EMAIL PROTECTED] / 2007-01-15 16:31:32 -0500:
> > > I have file which I use for validating which includes the following
> > > function:
> > > 
> > > function invalidchar($strvalue)
> > > {
> > >   if(!ereg("^[[:alpha:][:space:]\'-.]*$", $strvalue)) {
> > 
> > That regexp matches if $strvalue consists of zero or more 
> > ocurrences of a letter, a whitespace character, and any 
> > character whose numeric value lies between the numeric values 
> > of "'" and "." in your locale.
> > Zero or more means it also matches an empty string.
> 
> I'm still confused. This works perfectly on my other two pages with the
> exact same code. So why is it only this one page that is causing a problem? 
 
I don't know, I don't care. You have enough problems with the single
regex, let's concentrate on fixing this first.

> If I enter the word "test" in my form, without the quotes, then why is the
> fuction returning anything since this is a valid entry. Should it not only
> return a value if there is a problem.
 
I don't understand that paragraph. The regexp matches, and the function
returns *nothing* just as you programmed it.  That, of course, means
that the variable you are assigning this *nothing* gets set to
*nothing*, which, in PHP lingo, is null.

> All I want to accomplish here is to allow the user to enter a to z, A to Z,
> and /\'-_. and a space. Is there a better way to do this?

1. Do you really want to let them enter backslashes, or are you trying
   to "escape" the apostrophe?
2. Does that mean that "/\'-_." (without the quotes) and "   " (that's
   three spaces) are valid entries?

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] I lied, another question / problem

2007-01-16 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-15 19:22:24 -0500:
> > From: 'Roman Neuhauser' [mailto:[EMAIL PROTECTED] 
> > # [EMAIL PROTECTED] / 2007-01-15 18:33:31 -0500:
> > > > From: Roman Neuhauser [mailto:[EMAIL PROTECTED] # 
> > > > [EMAIL PROTECTED] / 2007-01-15 16:31:32 -0500:
> > > > > I have file which I use for validating which includes the 
> > > > > following
> > > > > function:
> > > > > 
> > > > > function invalidchar($strvalue)
> > > > > {
> > > > >   if(!ereg("^[[:alpha:][:space:]\'-.]*$", $strvalue)) {
> > > > 
> > > > That regexp matches if $strvalue consists of zero or more 
> > > > ocurrences of a letter, a whitespace character, and any
> > > > character whose numeric value lies between the numeric values of
> > > > "'" and "." in your locale.  Zero or more means it also matches
> > > > an empty string.

> > > All I want to accomplish here is to allow the user to enter 
> > a to z, A 
> > > to Z, and /\'-_. and a space. Is there a better way to do this?
> > 
> > 1. Do you really want to let them enter backslashes, or are you trying
> >to "escape" the apostrophe?
> > 2. Does that mean that "/\'-_." (without the quotes) and "   " (that's
> >three spaces) are valid entries?
> 
> Where do you see 3 spaces?

That's a value the regexp will match. Is that intended?

> In any event, I don't think this is the problem.
> As I have said the code works fine on two other pages, which logically
> suggests that there is something on this page that is causing a problem.

You don't understand that single function, and it does something else
than you think it does.  I told you what it actually does, but you chose
to ignore the information.  I don't know how I could help you more.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] circular dependency between libraries

2007-01-16 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-16 11:41:08 +0100:
> Roman Neuhauser wrote:
> > # [EMAIL PROTECTED] / 2007-01-14 20:47:02 +0100:
> >> Roman Neuhauser wrote:
> > The goal is to make a successful run of the test suite a prerequisite of
> > the utility installation...  Think RPM or similar: if X.rpm depends on
> > Y.rpm in runtime, you cannot make Y's installation depend on execution
> > of commands from X.
> 
> ok, I'm not grokking this fully - I'll just have to take you word on it :-)

1. testilence.rpm requires (installed) testilence-util.rpm to install
   since testilence uses testilence-util at runtime, and
2. testilence-util.rpm requires (installed) testilence.rpm before it
   will install, because it runs commands (installed by testilence.rpm)
   as part of its install procedure

> >> ... whilst I wonder whether using runkit for anything other than 
> >> experimental
> >> stuff, could runkit not offer a solution (e.g. renaming the class 
> >> dependent on
> >> the context of it's usage)? probably not, right?
> > 
> > How would this work?
> 
> from looking at runkit it would seem using runkit_import() would work,
> it would mean you simply 'include' the utility class(es) in both Testilence 
> and
> Amock using runkit_import() and that would simply cause the second 'include'
> to overwrite the class definition of the first include.

That is evil.  You have installed Testilence, it works.  You install
Amock, Testilence broke.  Reason: incompatible versions of the utility.

I know that whatever solution I end with will affect all clients of the
classes (Amock, Testilence, 3rd party sw), what I'm looking for is
something that will be easy to express and support using deployed
packaging systems (*BSD ports, pkgsrc, RPM, whatever Debian uses ATM).

> this could also be tackled using a chain of __autoload() functions.
 
How could you use Testilence to test your __autoload() if Testilence
already used it?  How could you test anything that depends on
__autoload() if Testilence used that mechanism?  What would preserve the
mechanism if the CUT used a naive __autoload()?  FMPOV __autoload() is
untouchable and shouldn't be used at all.

> either way having a runtime dependency in your code is probably not a
> good idea even for a develop-time tool like yours is (because it's
> marked experimental and it raises the bar as to the getting your tool
> working)

If you can install Testilence you can probably also extract a tarball
into a directory in your include_path. :)

> >>> Both Amock and Testilence are versioned using Subversion, so I could
> >>> leave the classes in Testilence and use svn:externals to put them in
> >>> Amock too.  That would lead to name clashes if both programs were used
> >>> together, and that is a showstopper.
> >> given that they are the same code would conditional loading of the utlity
> >> classes not work? i.e. only load if they don't already exist
> >  
> > That seems quite fragile, but I admit I haven't thought it through.
> 
> unless the class is called something silly like 'Foo' or 'Utility'
> then I think that in practice the problem is negligable.

Still the objection I gave above: seemingly independent programs would
silently influence each other's behavior.  I'd rather make this
relationship visible through the explicit dependency.

> > So far I'm leaning towards pulling the utility out from Testilence,
> > sacrificing the ability to unit test the library without jumping through
> > hoops.
> 
> that seems sane - hopefully the utility won't change half as often as
> the 'real' tools and given that you test the utility yourself before packaging
> you know that it works ... maybe including your test results in the utility
> package is something to consider?

I'd include the tests of course.  The steps would then be:

install utility + its tests: no tests are run
install Testilence + its tests: both utility's and Testilence's tests
 are run before anything is installed

For other users of the utility, such as Amock:
see above, plus:
install Amock + its tests: both utility's and Amock's tests are run
  before anything is installed

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] circular dependency between libraries

2007-01-16 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-16 13:56:01 +0100:
> my gut says that it would be easiest to just keep to seperate copies of
> the utility class(es) one for each project, although it kind of depends
> on how large & complicated the utlity is ... this would remove all the 
> described
> problems and leave you with only the 'slightly' inelegant situation where you
> have to, internally, sync the [relevant parts of the] 2 codebases now and 
> again.
> 
> given that there is a possibility of different version of the utility being
> required (as per you 'That is evil' reply) the '2 seperate copies of the 
> codebase'
> approach might be simplest and most reliable way of tackling the problem ...
> again (AFAIKT) this mostly comes down to you personally being able to accept
> the relative inelegance of the solution.
 
It's two if you only count Amock, but I already have another potential
use.  If PHP had namespaces, I'd be happy.  If PHP had a preprocessor,
I'd use that to get around the lack of namespaces and give each client
a non-conflicting, private version of the utility.  Simple "copy&rename"
as you suggest would seem to lead to maintenance hell (read: bugs).

> I'm trying to act as an extra braincell here - forgive me if what I'm
> saying is way too simple to be worthwhile :-)

Don't worry, I'm grateful for the input!  And no, not too simple.  After
all I'm not looking for something "sufficiently complicated", I'm
looking for something so easy even I won't screw it!

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] circular dependency between libraries

2007-01-16 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-16 16:01:39 +0100:
> could you point me at the svn web view that shows the utility code in 
> question?
> it might give me some ideas.

I don't think it's relevant, but here you go:
http://svn.sigpipe.cz/viewvc/view/trunk/testilence/src/Testilence/util.php?view=markup

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] running exec() on client

2007-01-16 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-16 15:18:50 -:
> > You do not need to have apache installed to run PHP you just need
> > PHP-CLI (Command Line Interface)
>
> Yes, I do know that, but what I want is for my colleague to follow a
> link on her web page that will trigger the php command, passing any
> required parameters.

You probably don't want to do that, at least not when you can't install
a web server.  Or was that ban Apache-specific?

1. Modify the PHP script to use $argv instead of $_GET/$_POST.
2. Install the CLI SAPI.
3. Write a small dialogue that prompts for whatever arguments using any
   of the languages available on Windows (Python would be ok) and start
   your PHP script from that, $argv populated from the form.

Your colleague will see a usual buttons-sweet-buttons GUI application,
you will be able to reuse the PHP script.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] How to prevent DomDocument from adding a !DOCTYPE.

2007-01-16 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-16 15:37:09 +0100:
> Im using DomDocument currently and i realy want to prevent it from adding 
> the !DOCTYPE and mabye even  and  etc..
> Is this possible and how?

Doesn't DOMDocument *require* DTD?  I thought it's either that or a
"document fragment" (which is probably what you're looking for).

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] I lied, another question / problem

2007-01-17 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-17 01:42:09 +0100:
> Beauford wrote:
> > Further to my previous email, there is something weird going on here. I just
> > tried using this:
> > 
> > if (!ereg('^[A-Za-z0-9]', $strvalue)) {
> >  return "error";
> > }
> 
> stop using bleeding ereg*() function - move to preg_*() funcs like the rest of
> the world did 5+ years ago.

Or even better: how about using the right tool for the job? :)

if (!ctype_isalnum($strvalue)) {
return "error";
}

>   if (!preg_match("#^[A-Z0-9]+\$#i", $s)) {

> (ps the above is a crappy regexp for real world use imho, but it serves
> the purpose of example)
 
It's dangerous.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] How to prevent DomDocument from adding a !DOCTYPE.

2007-01-17 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-16 20:42:48 +0100:
> Roman Neuhauser wrote:
> ># [EMAIL PROTECTED] / 2007-01-16 15:37:09 +0100:
> >>Im using DomDocument currently and i realy want to prevent it from adding 
> >>the !DOCTYPE and mabye even  and  etc..
> >>Is this possible and how?
> >
> >Doesn't DOMDocument *require* DTD?  I thought it's either that or a
> >"document fragment" (which is probably what you're looking for).
> 
> And how should i do this?
> Do you have any example avelable?

Sorry, no. You'll have to experiment.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] I lied, another question / problem

2007-01-17 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-17 11:41:54 +0100:
> Roman Neuhauser wrote:
> > # [EMAIL PROTECTED] / 2007-01-17 01:42:09 +0100:
> >>if (!preg_match("#^[A-Z0-9]+\$#i", $s)) {
> > 
> >> (ps the above is a crappy regexp for real world use imho, but it serves
> >> the purpose of example)
> >  
> > It's dangerous.
> 
> why dangerous?
> 
> given that this page: http://php.net/manual/en/function.ctype-alnum.php
> says, and I quote:
> 
>   "Checks if all of the characters in the provided string, text, are
>   alphanumeric. In the standard C locale letters are just [A-Za-z] and
>   the function is equivalent to preg_match('/^[a-z0-9]+$/iD', $text).
>   "

re_format(7) on FreeBSD:

 A bracket expression is a list of characters enclosed in `[]'.
 (...)
 If two characters in the list are separated by `-', this is
 shorthand for the full range of characters between those two
 (inclusive) in the collating sequence, e.g. `[0-9]' in ASCII
 matches any decimal digit.
 (...)
 Ranges are very collating-sequence-dependent, and portable programs
 should avoid relying on them.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] How to prevent DomDocument from adding a !DOCTYPE.

2007-01-17 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-17 07:08:44 -0500:
> Mathijs van Veluw wrote:
> >Roman Neuhauser wrote:
> >># [EMAIL PROTECTED] / 2007-01-16 15:37:09 +0100:
> >>>Im using DomDocument currently and i realy want to prevent it from 
> >>>adding the !DOCTYPE and mabye even  and  etc..
> >>>Is this possible and how?
> >>
> >>Doesn't DOMDocument *require* DTD?  I thought it's either that or a
> >>"document fragment" (which is probably what you're looking for).
> >>
> >
> >And how should i do this?
> >Do you have any example avelable?
> 
> A DTD is not required and is not automatically added to XML documents.
> Tags are also not automatically added either (using loadHTML methods is 
> excluded from this statement) so not sure exactly what you are trying to 
> do here or running into. Are you just trying to serialize a DOMDocument?
> 
>  is a perfectly well-formed document (though inclusion of xml 
> declaration is *highly* recommended).

Looks like the DTD is really optional, sorry for the noise.

prolog  ::= XMLDecl? Misc* (doctypedecl  Misc*)?
XMLDecl ::= ''
VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"')
Eq  ::= S? '=' S?
VersionNum  ::= '1.0'
Misc::= Comment | PI | S

http://www.w3.org/TR/2006/REC-xml-20060816/#NT-prolog

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] I lied, another question / problem

2007-01-17 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-17 16:59:26 +0100:
> Roman Neuhauser wrote:
> > re_format(7) on FreeBSD:
> > 
> >  A bracket expression is a list of characters enclosed in `[]'.
> >  (...)
> >  If two characters in the list are separated by `-', this is
> >  shorthand for the full range of characters between those two
> >  (inclusive) in the collating sequence, e.g. `[0-9]' in ASCII
> >  matches any decimal digit.
> >  (...)
> >  Ranges are very collating-sequence-dependent, and portable programs
> >  should avoid relying on them.
> 
> one other thing ...
> 
> wouldn't it be fair to assume (safety through paranoia) that
> ctype_alnum() would suffer the same problem? (given the manual's
> indication that ctype_alnum() and the offending regexp are equivalent?)

isalnum(3) uses isalpha(3) and isdigit(3), so yes, their results are
locale-dependent (LC_CTYPE, see setlocale(3)), but don't depend on
collating sequence.  isdigit(3):

 The isdigit() function tests for a decimal digit character.  Regardless
 of locale, this includes the following characters only:

 ``0'' ``1'' ``2'' ``3'' ``4''
 ``5'' ``6'' ``7'' ``8'' ``9''

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] $_SESSION variable gets lost on FORM action

2007-01-17 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-17 19:06:16 +:
> Stut wrote:
> >Redirecting using a Location header is not the only thing you can do 
> >with the header() function. It will never end processing of the script 
> >no matter what you pass to it. The example on the manual page for the 
> >header() function says as much (http://php.net/header), you read that 
> >right?
 
> Well, I feel like a du***ss!
> 
> No, I hadn't read that. I promisse, and this one is to keep, I won't 
> post to this list again without dedicate enough time to the problem, at 
> least to read the manual.
> 
> Anyway, thank you for confirm what I should have known in advance and 
> also for remembering me that PHP developers have a PHP manual for PHP 
> users...

Also, the header() call you provided in the original post was a
violation of HTTP. Knowing the programming language is just one of
your responsibilities IMNSHO.  The manual for HTTP users (you!) is at
ftp://ftp.rfc-editor.org/in-notes/rfc2616.txt

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] dynamic lists

2007-01-17 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-17 23:20:23 +0100:
> Kevin Murphy wrote:
> > On Jan 17, 2007, at 1:39 PM, Brad Fuller wrote:
> >> #1) Submit the form (to itself) when a user chooses an option from the
> >> first list (using onChange=form.submit()) then with PHP query the
> >> database for the second set of options.
> >>
> >> #2) Use JavaScript to store all the values and pop them in when the user
> >> chooses an option from the first list (using onChange=someFunction(...)).
> >>
> >> I like #2.  If you need a starting point, google for "javascript dynamic
> >> select list"
> > 
> > FYI... Neither #1 or #2 are considered good practice for
> > Accessibility/ADA compliance. If you are using a keyboard or screen
> > reader to view your website, it will always pick the first one in the
> > list and you won't have the option of even seeing the rest of the list.
> > Basically, anything that uses onchange or onselect will cause
> > accessibility issues. The only way to accomplish this is using onclick
> > or submitting the form.
> 
> that stance basically negates everything 'ajax', flash, video and everything
> considered to be remotely 'web2.0' - is the 'low-common-denominator' case
> always the correct choice?
 
And what about the my-ajax-is-longer-than-your-ajax (or whatever's "in"
right now (is "in" still a "cool" word?)) lemming-march mentality?

> I understand the importance of accessibility but the practicality of most
> peoples' job in this sector means satisfying the requirements of a client
> that demands such dynamic functionality such as the auto-selection example
> given here.
 
That's typically a result of poor user requirements capture. :)

> is there not an argument that screen-reader and [braille] keyboard software
> are somwhat responsible for being capable of 'keeping up' - given that an
> onclick can be handled why not an 'onchange' (in theory)?

Yeah, wheelchairs can move along a sidewalk, so what's stopping them
from walking up and down stairs?  If you haven't written an open source
browser on par with mozilla for blind people, it's IMO polite to not
raise the bar for them unless necessary. KISS and all that.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Getting domain out of a URL

2007-01-17 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-17 17:53:09 -0500:
> On Wednesday 17 January 2007 03:35 pm, Jay Blanchard wrote:
> > [snip]
> > I receive posts from an open moderated forum that need to be filtered
> > for urls. I've successfully managed to trap any entires that use
> > 'http://' 'www.' with the standard '.com' '.org', '.net' endings.
> >
> > What I need to do is to strip the prefix part ('http:// or http://www.
> > or 'www') and suffix as well (the .com, etc.) I need only the domain
> > name.  I can't seem to trim away the suffix part.
> > [/snip]
> >
> > Have you looked at http://us3.php.net/manual/en/function.parse-url.php
> 
> Thanks Jay for the function reference, but it doesn't seem like it's what I'm 
> after since the url is packed into the text.
> 
> What i really need is something that will take the first part of an array 
> cutting the remainder after a delimiter word '.com'.
> 
> Something along the lines of:
> 
>  
> $boom[1] = "ranchy.stuff.com and other junk";
> 
> $input = $boom[1];
> $out = array_slice($input, 0, 1);
> 
> ?>
> 
> Part of my problem, I'm beginning to realize, is that the array '$boom[1]' 
> contains only one element. Is there a similar string function I could use 
> that would accomplish what I need?

If there isn't one you can always compose it from the ones already available.
That's programming.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] $_SESSION variable gets lost on FORM action

2007-01-17 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-18 00:06:27 +:
> >Roman wrote:
> >Also, the header() call you provided in the original post was a
> >violation of HTTP. Knowing the programming language is just one of
> >your responsibilities IMNSHO.  The manual for HTTP users (you!) is at
> >ftp://ftp.rfc-editor.org/in-notes/rfc2616.txt
> 
> My English is not the best and I'm not sure what you mean. By looking at
> the document you linked I'm thinking that the problem you're talking about
> is not the '?var=value' but instead, the fact of being using a relative URL.
> 
> Am I correct?
 
Yes.

> If so, is there a way to know the full address of the index.php file?

You don't need to know your IP. See the grammar for AbsoluteURI:
ftp://ftp.rfc-editor.org/in-notes/rfc2396.txt

> I'm asking this because my IP is dynamic and I'm using a free redirection
> service. My site is at 'http://something.no-ip.org/sitename' can I use
> 'http://something.no-ip.org/sitename/index.php?vaz=value' on the
> Locarion header?

Actually you *must* use it instead of just the "index..." part.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] One last try at this!

2007-01-18 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-17 17:02:12 -0800:
> Beauford wrote:
> > if(!preg_match("/^[-A-Za-z0-9_.' ]+$/", $string)) {
> > return "Invalid Characters";
> >}

> In your regex you have a "."  this will match anything
> 
> try this:
> 
>  
> function ValidateString($string) {
>   if ( preg_match("/[^a-zA-Z0-9\_\.\' -]+/", $string) ) {
>   return "Invalid Characters";
>   }
>   return false;
> }

That "." is inside a character class where it is a literal character
(matches only ".").  Why are you backslashing the underscore is beyond
me.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Scope of include

2007-01-18 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-17 21:49:05 -0800:
> Hello php list:
> If I include a php script inside a php function definition and then
> call the function in another script. What is the scope of variables in
> the included script? Are they local to the function that calls include
> with the file name?

Yes.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] One last try at this!

2007-01-18 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-18 01:48:25 -0800:
> Roman Neuhauser wrote:
> ># [EMAIL PROTECTED] / 2007-01-17 17:02:12 -0800:
> >>Beauford wrote:
> >>>   if(!preg_match("/^[-A-Za-z0-9_.' ]+$/", $string)) {
> >>>   return "Invalid Characters";
> >>>}  
> >
> >>In your regex you have a "."  this will match anything
> >>
> >>try this:
> >>
> >> >>
> >>function ValidateString($string) {
> >>if ( preg_match("/[^a-zA-Z0-9\_\.\' -]+/", $string) ) {
> >>return "Invalid Characters";
> >>}
> >>return false;
> >>}
> >
> >That "." is inside a character class where it is a literal character
> >(matches only ".").  Why are you backslashing the underscore is beyond
> >me.
> >
> This is fine, is there any harm in escaping them?
> The match will work either way right?

It's misleading.  I don't want to be confronted with another legacy
program full of almost-reular expressions whose author didn't understand
the syntax at all, but was so stubborn that he eventually (using the
hit-and-miss method) found whatever garbage worked for him for
completely accidental reasons.

Know your tools.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] $_SESSION variable gets lost on FORM action

2007-01-18 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-18 08:59:11 +:
> >Roman:
> >[...]
> >You don't need to know your IP. See the grammar for AbsoluteURI:
> >ftp://ftp.rfc-editor.org/in-notes/rfc2396.txt
> >
> >>I'm asking this because my IP is dynamic and I'm using a free
> >>redirection service. My site is at
> >>'http://something.no-ip.org/sitename' can I use
> >>'http://something.no-ip.org/sitename/index.php?vaz=value' on the
> >>Locarion header?
> >Actually you *must* use it instead of just the "index..." part.
> >
> 
> Thank you Roman, I'm now working with absolute paths! :)
> 
> I Never thought that HTML had those specs...

It's not HTML, that's a completely different animal! HTTP is a transport
protocol, HTML is a document format.  HTML documents are but one type
of things you can transport using HTTP.

> With the relative link it worked and so it was OK for me...

Don't rely on browser bugs and features present to work around popular
bugs in server-side scripts.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] regular expression help!

2007-01-18 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-18 12:34:36 +0200:
> I need to strip all characters from the following text string exept the 
> image path...
> 
> " src=\"../../images/new/thumps/4123141112007590373240.jpg\" />"...and then 
> store the path to DB. Image path lengh can vary so I guess that I need to 
> extract all characters after scr=\"until next\"or somethig 
> similar.

This passes with 5.2:

class ImgSrcTest extends Tence_TestCase
{
private $src, $str, $xml;
function setUp()
{
$this->src = 'fubar.jpg';
$this->str = sprintf(
'',
$this->src
);
$this->xml = new SimpleXmlElement($this->str);
}
function testReturnsAttributeAsSimpleXMLElements()
{
return $this->assertEquals('SimpleXMLElement', 
get_class($this->xml['src']));
}
function testCastToStringYieldsTheAttributeValue()
{
return $this->assertEquals($this->src, strval($this->xml['src']));
}
}

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



  1   2   3   4   >