OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 28 Oct 2005 19:31:08 -0000 Issue 3763

php-general-digest-helplists.php.net
Date: Fri Oct 28 2005 - 14:31:08 CDT


php-general Digest 28 Oct 2005 19:31:08 -0000 Issue 3763

Topics (messages 224755 through 224790):

Re: PHP version check
        224755 by: Richard Davey
        224764 by: Marcus Bointon

Re: foreach / unset
        224756 by: Karlos Zafra
        224761 by: Jochem Maas
        224771 by: Brent Baisley
        224773 by: John Nichel
        224774 by: Jochem Maas

Re: Using PHP for accsess control, preventing access to static files
        224757 by: Richard Heyes

Re: How to account for misspellings and alternatives in searching?
        224758 by: Jochem Maas
        224760 by: Robin Vickery
        224786 by: Chris W. Parker

Re: Decompressing a string with zlib problems
        224759 by: Jochem Maas
        224782 by: Robin Vickery

Re: regex and global vars problem
        224762 by: Robin Vickery
        224765 by: Tom Rogers

Mixed PHP/SSI and environment variables
        224763 by: Christoph Freundl
        224768 by: Jochem Maas
        224769 by: Christoph Freundl
        224770 by: Jochem Maas
        224777 by: Christoph Freundl
        224783 by: Jochem Maas

printing from php
        224766 by: Tom Cruickshank
        224767 by: Jochem Maas

Re: Trouble using DOM component with PHP 4.4.0
        224772 by: Alessandro Rossini

Use sqlite with php 4.4 ?
        224775 by: mbneto
        224776 by: Greg Donald

Type of form element
        224778 by: Shaun
        224779 by: Leif Gregory
        224780 by: Jim Moseby
        224781 by: Jay Blanchard
        224789 by: James Benson
        224790 by: Greg Donald

OCI8
        224784 by: Kilbride, James

Re: XML-RPC Error:-32300:transport error - could not open socket
        224785 by: Dan McCullough

calling static method within class
        224787 by: blackwater dev
        224788 by: Greg Donald

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


Hi Andrew,

Friday, October 28, 2005, 7:41:21 AM, you wrote:

> How can I query for PHP version?

phpversion() !

Cheers,

Rich
--
Zend Certified Engineer
http://www.launchcode.co.uk

attached mail follows:


On 28 Oct 2005, at 07:46, Richard Davey wrote:

> Friday, October 28, 2005, 7:41:21 AM, you wrote:
>
>> How can I query for PHP version?
>
> phpversion() !

While it's true that that will get you a version string, if you're
going to actually check it, you need:

http://www.php.net/manual/en/function.version-compare.php

to do so reliably. Version strings are messy things.

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
marcussynchromedia.co.uk | http://www.synchromedia.co.uk

attached mail follows:


This syntax has the work done perfectly for me.

2005/10/28, Niels Ganser <php-general.maildepoll.de>:
>
> Why should this be "unsafe" (whatever the heck that means) in any way? Of
> course you can do it.
>
> Regards,
> Niels.
>
> [sorry for mailing to your private address. wrong button :)]
>
> > Anyway, can you do *this* safely as a DOCUMENTED FEATURE:
> >
> > foreach($array as $k => $v){
> > if (...) unset($array[$k]);
> > }
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


Richard Lynch wrote:
> Somewhere in the manual (damned if I can find it now) it says (or used
> to say) that you can or can't safely do this:
>
> while (list($k, $v) = each($array)){
> if (...) unset($array[$k]);
> }
>
> I don't even remember if it's safe or not, but I swear I saw it not
> that long ago...
>
> Anyway, can you do *this* safely as a DOCUMENTED FEATURE:
>
> foreach($array as $k => $v){
> if (...) unset($array[$k]);
> }

in short: yes.

you can unset() in this way till the cows come home and
not suffer undue consequences.

>
> I'm sure I could test it and maybe find out if "it works" but is it
> documented behaviour I can rely on? I'm sure not finding this in the
> manual now that I go looking for it, though I know I saw it there
> before.
>
> PS
> I'm being dragged kicking and screaming into using this new-fangled
> 'foreach' thing instead of while/list/each, and I don't really care
> for it so far. :-)

if while/list/each & foreach were women, while/list/each would be selling
fish on a market stall & foreach would be having her feet massaged while drinking
dry martini at 35,000 feet :-)

but I guess it's not the done thing to call a language construct sexy ;-)

>

attached mail follows:


The foreach statement works because you are getting the array index
($k) to unset the array item. I think somewhere in the manual it says
it's unsafe because some people might think you could just use unset
($v) to unset the array item. Which wouldn't work because $v is more
of a temporary variable and not a reference to the array item.

On Oct 27, 2005, at 6:18 PM, Richard Lynch wrote:

> Somewhere in the manual (damned if I can find it now) it says (or used
> to say) that you can or can't safely do this:
>
> while (list($k, $v) = each($array)){
> if (...) unset($array[$k]);
> }
>
> I don't even remember if it's safe or not, but I swear I saw it not
> that long ago...
>
> Anyway, can you do *this* safely as a DOCUMENTED FEATURE:
>
> foreach($array as $k => $v){
> if (...) unset($array[$k]);
> }
>
> I'm sure I could test it and maybe find out if "it works" but is it
> documented behaviour I can rely on? I'm sure not finding this in the
> manual now that I go looking for it, though I know I saw it there
> before.
>
> PS
> I'm being dragged kicking and screaming into using this new-fangled
> 'foreach' thing instead of while/list/each, and I don't really care
> for it so far. :-)
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577

attached mail follows:


Richard Lynch wrote:
> Somewhere in the manual (damned if I can find it now) it says (or used
> to say) that you can or can't safely do this:
>
> while (list($k, $v) = each($array)){
> if (...) unset($array[$k]);
> }
>
> I don't even remember if it's safe or not, but I swear I saw it not
> that long ago...
>
> Anyway, can you do *this* safely as a DOCUMENTED FEATURE:
>
> foreach($array as $k => $v){
> if (...) unset($array[$k]);
> }
>
> I'm sure I could test it and maybe find out if "it works" but is it
> documented behaviour I can rely on? I'm sure not finding this in the
> manual now that I go looking for it, though I know I saw it there
> before.

I would *think* (just my opinion without much thought on a Friday
morning) that this would/could be unsafe _if_ it was a for loop on a
numerical indexed array. Of course, my thinking may change after my
first bottle of Dew. ;)

> PS
> I'm being dragged kicking and screaming into using this new-fangled
> 'foreach' thing instead of while/list/each, and I don't really care
> for it so far. :-)

For the longest time, I hated foreach. Looked at other people's code
who used it, and just wanted to strangle them. However, I was sorta
forced into it about 8 months ago, and now I'm in the camp of, "Damn, I
really like this".

--
John C. Nichel
berGeek
KegWorks.com
716.856.9675
johnkegworks.com

attached mail follows:


John Nichel wrote:
> Richard Lynch wrote:
>
>> Somewhere in the manual (damned if I can find it now) it says (or used
>> to say) that you can or can't safely do this:
>>
>> while (list($k, $v) = each($array)){
>> if (...) unset($array[$k]);
>> }
>>
>> I don't even remember if it's safe or not, but I swear I saw it not
>> that long ago...
>>
>> Anyway, can you do *this* safely as a DOCUMENTED FEATURE:
>>
>> foreach($array as $k => $v){
>> if (...) unset($array[$k]);
>> }
>>
>> I'm sure I could test it and maybe find out if "it works" but is it
>> documented behaviour I can rely on? I'm sure not finding this in the
>> manual now that I go looking for it, though I know I saw it there
>> before.
>
>
> I would *think* (just my opinion without much thought on a Friday
> morning) that this would/could be unsafe _if_ it was a for loop on a
> numerical indexed array. Of course, my thinking may change after my
> first bottle of Dew. ;)

this function might change your mind (I take it you have had your Dew by now :-):

     function resolveArgs($args)
     {
         $args = array_values($args);

         for ($i = 0; $i < count($args); ++$i) {
             while (isset($args[$i]) && is_array($args[$i])) {
                 array_splice($args,$i,1,array_values($args[$i]));
             }
         }

         return $args;
     }

basically it flattens a multidimensional array - i use it for handling DB query
arguments (makes it easier to pass around args whilst build highly dynamic queries)

so intrinsically its not unsafe to manipulate the array - only you have the potential
to shoot yourserlf in the foot :-) then again both Richard and John have more than enough
skills to do that anyway ;-)

>
>> PS
>> I'm being dragged kicking and screaming into using this new-fangled
>> 'foreach' thing instead of while/list/each, and I don't really care
>> for it so far. :-)

new-fangled is putting the boat out a bit thought :-) it's been around since 4.0,
I guess your looking forward to being able to use foreach to iterate over php5 object ;-)

>
>
> For the longest time, I hated foreach. Looked at other people's code
> who used it, and just wanted to strangle them. However, I was sorta
> forced into it about 8 months ago, and now I'm in the camp of, "Damn, I
> really like this".

:-)

>

attached mail follows:


Dan Trainor wrote:
> Hello, all -
>
> I'm designing a controlled access system in PHP, and it's coming along
> quite well. It's very simple, and just sets a session varibale, such as
> $_SESSION['authenticated'] = 1, not a whole lot.

If you do this this, you must make sure you have some sort of session
hijacking prevention in place.

> Now I run a small sniplet of code on the top of each HTML and PHP file,
> which checks for this variable, and either allows or denys access to the
> page.
>
> However, how do people protect against the downloading of real files,
> ones which are not parsed by PHP? .WMV, .MOV, .ZIP, .EXE and so on? I
> want to protect access to these as well, and if a visitor just types in
> a URL and is able to access the file because my access control mechanism
> simply doesn't work on those types of files, what should be the solution
> here?
>
> It's been suggested to use readfile() to accomplish this, by forwarding
> content from outside of the document root - but this just sounds odd.
> On top of being (what I think would be) incredibly slow, it just doesn't
> sound "right".

This works fine for me on one site I maintain, though not with
readfile(). When testing readfile() always crapped out at around 2Mb,
whereas fopen() and a while loop with fread() working perfectly, even
for larger files (up to 200Mb). Not tested this on high traffic, though
it all depends on how large you files are.

--
Richard Heyes

attached mail follows:


James Benson wrote:
> Not sure about the numbers but soundex could be useful
>
> http://php.net/soundex

right and maybe its easier to just index thing like '5.11' as
'511' - ie just stripping off everything not alphanumeric ...
amnd doing the same with whatever people search on. I have used
a similar technique to make it easier to search for text/words that
contains letters with diacrites (e.g. 'e acute' becomes a plain 'e')

and never underestimate a users ability to start writing about eating
dessert in the desert, no doubt they had sandcakes. ;-)

>
>
>
> James
>
>
> Chris W. Parker wrote:
>
>> Hello,
>>
>> On my site right now if someone searches for "511" (a misspelling of the
>> manufacturer 5.11) they are not presented with the right products
>> because 511 is not found anywhere in the database.
>>
>> I've got a few ideas on how to solve this but I want to find one that
>> requires as little administrative overhead as possible.
>>
>> 1. I could add a field to the db for each product that would be used for
>> associated words for a product as well as misspellings.
>>
>> PROS: Very customizable on an individual product level.
>> CONS: Would need to be updated for each and every product individually.
>>
>> 2. Make a field for each manufacturer's record for alternate
>> spellings/keywords.
>>
>> PROS: Little administrative overhead.
>> CONS: Is only manufacturer name based and could not account for specific
>> products.
>>
>> 3. Both #1 and #2.
>>
>> PROS: Flexible.
>> CONS: Lots of administrative overhead.
>>
>> 4. A one-to-many table that associates individual words with product
>> skus. This one is pretty much the opposite of #1 with one key
>> difference: the interface. It would be probably be easier to enter a
>> desired word and then choose each sku from a multi-select dropdown than
>> it would be to go from product to product entering one word at a time.
>>
>> 5. I'm not sure how this would be accomplished from a technical
>> standpoint but it would be nice to have the program know that when
>> someone types in "511" they really meant "5.11". Or (hopefully this
>> isn't a bad example) if they type in "dessert" (as in cake and icecream)
>> they really meant "desert" (as in snakes and sand).
>>
>> In my case that wouldn't be a bad assumption since our site will never
>> contain the word desert unless it's a misspelling.
>>
>>
>> What does everyone think? What other options are out there?
>>
>>
>>
>> Chris.
>
>

attached mail follows:


On 10/27/05, Chris W. Parker <cparkerswatgear.com> wrote:
> Hello,
>
> On my site right now if someone searches for "511" (a misspelling of the
> manufacturer 5.11) they are not presented with the right products
> because 511 is not found anywhere in the database.
>
> I've got a few ideas on how to solve this but I want to find one that
> requires as little administrative overhead as possible.

You could use the pspell extension; add your manufacturers to your
personal word-list and use pspell_check() to check the spelling and
pspell_suggest() to suggest alternatives.

http://www.php.net/manual/en/ref.pspell.php

  -robin

attached mail follows:


Jochem Maas <mailto:jochemiamjochem.com>
    on Friday, October 28, 2005 1:33 AM said:

> James Benson wrote:
>> Not sure about the numbers but soundex could be useful
>>
>> http://php.net/soundex
>
> right and maybe its easier to just index thing like '5.11' as
> '511' - ie just stripping off everything not alphanumeric ...

How do I "index thing like '5.11' as '511'"? (I know how to strip off
the characters. It's the indexing part that I'm not sure about.)

> and never underestimate a users ability to start writing about eating
> dessert in the desert, no doubt they had sandcakes. ;-)

Better yet! Icecream flavored snakes!

Thanks,
Chris.

attached mail follows:


you have another problem - in that all these very specific strings
that you are posting could very well be being mangled in someway
because of the mail transport. in fact I doubt it comes thru in
way that makes it testable at all.

it doesn't help that googling for 'dcomzlib' brings up your own posts
as the first results. not very helpful.

interesting problem - sorry I can't help

Graham Anderson wrote:
> I am having problems decompressing a zlib'd string located in a file.
>
> In the file headers, the compression says that it is zlib.
> But, when I 'gzinflate' the string, I get the error: gzinflate(): data
> error in <b
> Is the below NOT a zlib or some strange variant ?
>
> anyone know ?
> g
>
> <?php
> $hex="C0636D7664000003DE789C95533B4E0331109D2408C44FA200125084568212D153
> 2040A2A02012120D05142636BB26B677659B20B8000D05D7E00674882B70000EC1018019
> 67974D365060E569C76F3CEF4D66BD008D779DA67D0050BA9F707CC2CBFDE43301A07E1A
> 5003FA956B6433BEDFFB89A87E6CD5011AF3DEB21EC667BE173C1BA567A156D67E7DFEC3
> 772207C086E0DEE1B32D94F36545AE1B6AEB4673C9308834FFE3BF031C227613AE2CE575
> A2ACCBAC6759A6824AADF6BA769259E945B46FA4665EA626EA08948D0E99E14A60597D4A
> 4B734936B10E36AD188941CF5F61E5ED6D17361C6D98928E6C1606366FAD7DDCA08B92CC
> 4507CC0F19C0061F18B4B9159743D39923913C7E74FE827ADE74DEF1A133EDBF270A2DE7
> C30C8B5C31BF366A7447F91F2C62EE6E909A7928B96E5A79071FDD948B8ADFBB13CCE435
> D339B78A10BFF406B04C2F642443510BD1AB9CA77809910CF3057955155FEAE1D5A99264
> A6C6DAA07A5915A50EE2CA51BA93CD6BEEE9B6CD1AA605B73A4F9DE7F4FA93BBB1D004E8
> 302EA21BE993E848F6C58967B1888E2DCD6F2553D7B14EFB5290C40E6A6CE9F0F1CE75FD
> 6D665243839ACE14BB0DCADFAFDD8C760000003C";
>
> // Convert the hex to a string
> $string = pack("H*", $hex);
>
> //echo it
> echo "the compressed string is:". "\r\n";
> echo $string;
>
>
> //decompress the string
> $uncompressed =gzinflate($string);
> echo "the uncompressed string is: ".$uncompressed;
>
> ?>
>
> The Output SHOULD look something like this:
> 8
> trak88øá 8Animation Media Handlergmhdle Alias Data Handleralis
>
>
> The compressed output is:
>
> the compressed string is:
> ??t?+p??g?M6P`?i?o<?Mf??w??}P??p|????3?~P??kd3?????~l??޲?g?<g?V?~}??
> w"?????-??eE??Fs?0?4??"v?,?u??ˬgY??J???v?Y?E?o?f^?&????J`Y}JKsI6?6??A?
> _a??m6m???l6o?}ܠ???E?????Cә#?<~t??z?t??3?'
> -??
> ?\1?6jtG?,b?n??y(?nZy 9?????L/d$CQ
> ѫ??x ?
> ߯݌v< ?yU_??թ?d??
> ڠzY???Q???k?????:O?????????0.??H?ʼng???-?o%SױN?R??jl????u?mfRC???? πnZy›îãäflªÉ5”9∑äøÙ∞L/d$CQ —´úßx
> ë ÛyU_Í·’©íd¶∆⁄†zY• ‚ Q∫ìÕkÓÈ∂Õ¶∑:OùÁÙ˙쪱–Ë0.¢
> ÈìËHˆ≈âg±àé-Õo%S◊±N˚RêƒjlÈÒŒu˝mfRCÉöŒª
> ߯݌v
>

attached mail follows:


On 10/28/05, Graham Anderson <grahamasiren.cc> wrote:
> I am having problems decompressing a zlib'd string located in a file.
>
> In the file headers, the compression says that it is zlib.
> But, when I 'gzinflate' the string, I get the error: gzinflate():
> data error in <b
> Is the below NOT a zlib or some strange variant ?
>
> <?php
> $hex="C0636D7664000003DE789C95533B4E [...]

Is this thread any help?

http://lists.apple.com/archives/QuickTime-java/2003/Sep/msg00038.html

Looking at your binary data in a hex editor, you've got what looks
like a cmvd header at the start. If the next four bytes are the
length of the compressed data, then you've got probably got 990 bytes
following that that you should be decompressing.

-robin

attached mail follows:


On 10/28/05, Tom Rogers <trogerskwikin.com> wrote:
>
> I would do it with a small class like this:
>
> <?php
> class mac{
> var $mac='';
> var $is_valid = false;
> function mac($mac){
> $mac = preg_replace('/[^0-9A-F]/','',strtoupper($mac));
> if($this->is_valid = preg_match('/^(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})$/',$mac,$parts)){
> array_shift($parts); //lose the first bit
> $this->mac = implode(':',$parts);
> }
> }
> }
>
> //test
> $mac_list = array("00-aa-11-bb-22-cc","00:aa:11:bb:22:cc","zz:00:11:22:ff:xx","00 aa 11 bb 22 cc");
>
> foreach($mac_list as $mac){
> $mactest = new mac($mac);
> echo "In:$mac";
> if($mactest->is_valid){
> echo " valid $mactest->mac\n";
> }else{
> echo " NOT valid\n";
> }
> }

$mactest = new mac("there are a few gotchas for anyone using this");
print $mactest->is_valid ? "valid\n" : "invalid\n";

// valid

attached mail follows:


Hi,

Friday, October 28, 2005, 7:20:58 PM, you wrote:
RV> On 10/28/05, Tom Rogers <trogerskwikin.com> wrote:
>>
>> I would do it with a small class like this:

RV> $mactest = new mac("there are a few gotchas for anyone using this");
print $mactest->>is_valid ? "valid\n" : "invalid\n";

RV> // valid

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

It does reduce to a valid mac address (EE:AE:AF:EC:AF:AE) :)
--
regards,
Tom

attached mail follows:


Hello,

I have a problem with the persistence of environment variables when
mixing PHP and SSI (Apache) and I am not sure if I just made an error
or if this approach cannot work at all.
So please consider the following files:

setvar.shtml
-------------------------------------------------
<!--#set var="myvar" value="myval" -->
-------------------------------------------------

showvar.php
-------------------------------------------------
<?php echo apache_getenv( "myvar" ); ?>
-------------------------------------------------

info.shtml
-------------------------------------------------
<!--#include virtual="setvar.shtml" -->
<!--#include virtual="showvar.php" -->
-------------------------------------------------

info.php
-------------------------------------------------
<?php
  virtual( "setvar.shtml" );
  echo apache_getenv( "myvar" );
?>
-------------------------------------------------

What I would expect is that you get the same result if you call
info.shtml and info.php. What happens when I tried (PHP 4.3.10 with
both Apache 1.3.33 and 2.0.53): the shtml shows the variable but the
php does not, it seems to "forget" the variable set in setvar.shtml.
Please, can anybody tell me what is going wrong here?

Regards, Christoph

--
Christoph Freundl http://www10.informatik.uni-erlangen.de/~chfreund/
Lehrstuhl fr Systemsimulation (Inf. 10), Cauerstr. 6, D-91058 Erlangen
   The earth is like a tiny grain of sand, only much, much heavier.

attached mail follows:


Christoph Freundl wrote:
> Hello,
>
> I have a problem with the persistence of environment variables when
> mixing PHP and SSI (Apache) and I am not sure if I just made an error
> or if this approach cannot work at all.
> So please consider the following files:
>
> setvar.shtml
> -------------------------------------------------
> <!--#set var="myvar" value="myval" -->
> -------------------------------------------------
>
> showvar.php
> -------------------------------------------------
> <?php echo apache_getenv( "myvar" ); ?>
> -------------------------------------------------
>
> info.shtml
> -------------------------------------------------
> <!--#include virtual="setvar.shtml" -->
> <!--#include virtual="showvar.php" -->
> -------------------------------------------------
>
> info.php
> -------------------------------------------------
> <?php
> virtual( "setvar.shtml" );

have yuou tried include/require here instead of virtual()

I imagine that the env of the subprocess wouldn't affect
the env of the parent process - i.e. to me it makes sense
if you say the env var in the subprocess is not available in
the parent process.

> echo apache_getenv( "myvar" );
> ?>
> -------------------------------------------------
>
> What I would expect is that you get the same result if you call
> info.shtml and info.php. What happens when I tried (PHP 4.3.10 with
> both Apache 1.3.33 and 2.0.53): the shtml shows the variable but the
> php does not, it seems to "forget" the variable set in setvar.shtml.
> Please, can anybody tell me what is going wrong here?
>
> Regards, Christoph
>

attached mail follows:


Am Freitag, 28. Oktober 2005 13:22 schrieb Jochem Maas:
> > info.php
> > -------------------------------------------------
> > <?php
> > virtual( "setvar.shtml" );
>
> have yuou tried include/require here instead of virtual()
>
> I imagine that the env of the subprocess wouldn't affect
> the env of the parent process - i.e. to me it makes sense
> if you say the env var in the subprocess is not available in
> the parent process.
>
> > echo apache_getenv( "myvar" );
> > ?>
> > -------------------------------------------------

Nope, both include and require result that the content of setvar.shtml
shows up literally in the output without the SSI having been processed
by Apache.

--
Christoph Freundl http://www10.informatik.uni-erlangen.de/~chfreund/
Lehrstuhl fr Systemsimulation (Inf. 10), Cauerstr. 6, D-91058 Erlangen
  Quiet people aren't the only ones who don't say much. - R. Baalke

attached mail follows:


Christoph Freundl wrote:
> Am Freitag, 28. Oktober 2005 13:22 schrieb Jochem Maas:
>
>>>info.php
>>>-------------------------------------------------
>>><?php
>>> virtual( "setvar.shtml" );
>>
>>have yuou tried include/require here instead of virtual()
>>
>>I imagine that the env of the subprocess wouldn't affect
>>the env of the parent process - i.e. to me it makes sense
>>if you say the env var in the subprocess is not available in
>>the parent process.
>>
>>
>>> echo apache_getenv( "myvar" );
>>>?>
>>>-------------------------------------------------
>
>
> Nope, both include and require result that the content of setvar.shtml
> shows up literally in the output without the SSI having been processed
> by Apache.

ok, and if you stick the following in 1 file and call it?:

<!--#set var="myvar" value="myval" -->
<?php echo apache_getenv( "myvar" ); ?>

... just thinking out loud here.

>

attached mail follows:


Am Freitag, 28. Oktober 2005 13:42 schrieb Jochem Maas:
> ok, and if you stick the following in 1 file and call it?:
>
> <!--#set var="myvar" value="myval" -->
> <?php echo apache_getenv( "myvar" ); ?>
>
> ... just thinking out loud here.

Ok, I tried this by configuring Apache such that .php-files are also
parsed for Server Side Includes and wrote it the way you suggest. Now
I am really confused: the SSI statements are obviously recognized
because they do not appear in the resulting file but
a) apache_getenv does still not return the value for the variable but
b) if I call phpinfo() instead of apache_getenv the variable "myvar"
plus the set value is shown correctly in the "Apache Environment" and
c) an SSI "<!--#echo var="myvar" --> after the php block also gives the
correct value

Perhaps I return to what I primarily intended to ask: is it really the
wanted behaviour of virtual() that changes that are made by the
included file do not influence the environment of the including file?

Regards, Christoph

--
Christoph Freundl http://www10.informatik.uni-erlangen.de/~chfreund/
Lehrstuhl fr Systemsimulation (Inf. 10), Cauerstr. 6, D-91058 Erlangen
Tel: +49-9131-85-28676 | A low voter turnout is an indication of fewer
Fax: +49-9131-85-28928 | people going to the polls. - D. Quayle

attached mail follows:


Christoph Freundl wrote:
> Am Freitag, 28. Oktober 2005 13:42 schrieb Jochem Maas:
>
>>ok, and if you stick the following in 1 file and call it?:
>>
>><!--#set var="myvar" value="myval" -->
>><?php echo apache_getenv( "myvar" ); ?>
>>
>>... just thinking out loud here.
>

I just looked at apache_getenv():

string apache_getenv ( string variable [, bool walk_to_top] )

the second arg maybe something to consider?
also does getenv() [http://php.net/getenv] have the same problems?

>
> Ok, I tried this by configuring Apache such that .php-files are also
> parsed for Server Side Includes and wrote it the way you suggest. Now
> I am really confused: the SSI statements are obviously recognized
> because they do not appear in the resulting file but
> a) apache_getenv does still not return the value for the variable but
> b) if I call phpinfo() instead of apache_getenv the variable "myvar"
> plus the set value is shown correctly in the "Apache Environment" and
> c) an SSI "<!--#echo var="myvar" --> after the php block also gives the
> correct value
>
> Perhaps I return to what I primarily intended to ask: is it really the
> wanted behaviour of virtual() that changes that are made by the
> included file do not influence the environment of the including file?

I would say yes because virtual() create a sub-process, with it _own_ env.

>
> Regards, Christoph
>

attached mail follows:


Hello,
     I've been reading up on printing out documents using PHP (using Printer
functions calls in the php manual)

I'm using a Linux and/or FreeBSD operating system to run my php code on (in
apache). However, I am surfing these pages using a Windows XP machine.

Has anyone ever tried having a print button (or link) in php that would make
Whatever page is being displayed being printed with the above scenario?

How might you of gone about it to make it work? (the Linux or FreeBSD box is
not configured to have a printer on it, shared or local, does that make a
difference? )

Would appreciate any feedback. Thanks!

Tom

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.361 / Virus Database: 267.12.5/150 - Release Date: 10/27/2005
 

attached mail follows:


don't post a new question to an existing thread - it lessens your exposure!

Tom Cruickshank wrote:
> Hello,
> I've been reading up on printing out documents using PHP (using Printer
> functions calls in the php manual)
>
> I'm using a Linux and/or FreeBSD operating system to run my php code on (in
> apache). However, I am surfing these pages using a Windows XP machine.
>
> Has anyone ever tried having a print button (or link) in php that would make
> Whatever page is being displayed being printed with the above scenario?
>
> How might you of gone about it to make it work? (the Linux or FreeBSD box is
> not configured to have a printer on it, shared or local, does that make a
> difference? )

either you let the client (browser) print the page - this has nothing to do with
php OR you let the server print 'something' (based on a specific request from the user
- i.e. he clicked on 'print' link or something) in which case you will _need_
to have access to a printer from the server (i.e. it needs to have a printer configured)

basically if the server 'has' no printer it can't print.

>
> Would appreciate any feedback. Thanks!
>
> Tom
>
>

attached mail follows:


> And what DOM library, which is compatible with PHP 5.0 and PHP 4.4 can
> I use to avoid the conflict I currently have?

In PHP4 I never used any DOM implementation, I started to use DOM only after
the PHP5 release, so I'm not the best to answer your question. :)
Anyway I think that there is some implementation in the PEAR repository. Try
to search there.

Best regards.
--
Alessandro 'Aronnax' Rossini
----------------------------
web -> www.aronnax.it
e-mail -> aronnaxaronnax.it
icq -> 2442698
ZeroNotice IT Solutions -> www.zeronotice.com

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQBDYh3+zl1DofcNSWcRAtrGAJ0WZCNZKVRCrYDc/9GYX99IQDYi8ACfSlEM
O3ZWmAbRff6DqPAZHQGPov8=
=yHC5
-----END PGP SIGNATURE-----

attached mail follows:


Hi,

is it possible to use sqlite with php 4.4 ? What do I have to do ?

I could not find and option in ./configure.

tks.

attached mail follows:


On Fri, 28 Oct 2005, mbneto wrote:

> is it possible to use sqlite with php 4.4 ? What do I have to do ?
>
> I could not find and option in ./configure.

http://php.net/sqlite

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

attached mail follows:


Hi,

I have some checkboxes on my page which correspond with boolean fields in my
database - actually they are TINYINT's in which I store a 0 or 1 in for
false and true values respectively.

Is it possible to loop through all $_POST values to see if it is a checkbox?
If so then for that element if it is equal to 'on' then change it to 1
otherwise change it to 0?

Thanks for your advice.

attached mail follows:


Hello Shaun,

Friday, October 28, 2005, 9:00:05 AM, you wrote:
> Is it possible to loop through all $_POST values to see if it is a
> checkbox? If so then for that element if it is equal to 'on' then
> change it to 1 otherwise change it to 0?

Yes and no.

1. You can't determine by the POST variable whether it was a checkbox
or a text field unless you test for 1/0 or a string, but even then,
what if someone types a 0 into a textbox that was supposed to be an
address (input validation). The other option is to name the checkbox
something like "question1_chkbox" and do a strstr() to see if the POST
variable name contains "_chkbox". But you should know what the
variable names of your checkboxes are anyways, so I don't know why
you'd test to see if it was a checkbox.

2. Only set checkboxes (checked) are passed through POST and GET. This
is fine if it's a one time form and you just need to know if they said
"yes" to subscribing to your newsletter, but if it's a form they can
go back into to modify settings (i.e. their account) then you need to
test to see if they unchecked a box which will not be passed back to
you via POST. Basically you'd set all the fields to 1 if the checkbox
variable appeared in the POST, and set all the rest of the fields to
zero (because if it wasn't in the POST variables, it was unchecked).

--
                          TBUDL/BETA/DEV/TECH Lists Moderator / PGP 0x6C0AB16B
 __ ____ ____ ____ Geocaching: http://gps.PCWize.com
( ) ( ___)(_ _)( ___) TBUDP Wiki Site: http://www.PCWize.com/thebat/tbudp
 )(__ )__) _)(_ )__) Roguemoticons & Smileys: http://PCWize.com/thebat
(____)(____)(____)(__) PHP Tutorials and snippets: http://www.DevTek.org

Some days I feel like I'm just rearranging deck chairs on the Titanic.

attached mail follows:


>
> Is it possible to loop through all $_POST values to see if it
> is a checkbox?
> If so then for that element if it is equal to 'on' then
> change it to 1
> otherwise change it to 0?

foreach($_POST as $key => $value){
  if
($value=='on'){$_POST[$key]='1';}elseif($value=='off';){$_POST[$key]='0'};
}

JM

attached mail follows:


[snip]
I have some checkboxes on my page which correspond with boolean fields in my

database - actually they are TINYINT's in which I store a 0 or 1 in for
false and true values respectively.

Is it possible to loop through all $_POST values to see if it is a checkbox?

If so then for that element if it is equal to 'on' then change it to 1
otherwise change it to 0?
[/snip]

Yes. And, if so, yes.

attached mail follows:


If you have a checkbox you just test if the value is set with isset()
if it's not set they never selected the checkbox.

Or if thats not what you mean maybe this could help
http://php.net/variables.external

Shaun wrote:
> Hi,
>
> I have some checkboxes on my page which correspond with boolean fields in my
> database - actually they are TINYINT's in which I store a 0 or 1 in for
> false and true values respectively.
>
> Is it possible to loop through all $_POST values to see if it is a checkbox?
> If so then for that element if it is equal to 'on' then change it to 1
> otherwise change it to 0?
>
> Thanks for your advice.

attached mail follows:


On Fri, 28 Oct 2005, James Benson wrote:
> If you have a checkbox you just test if the value is set with isset()
> if it's not set they never selected the checkbox.
>
>> I have some checkboxes on my page which correspond with boolean fields in
>> my database - actually they are TINYINT's in which I store a 0 or 1 in for
>> false and true values respectively.
>>
>> Is it possible to loop through all $_POST values to see if it is a
>> checkbox? If so then for that element if it is equal to 'on' then change it
>> to 1 otherwise change it to 0?

I usually place a hidden field with the same name as the checkbox
field before the actual checkbox field. I store my 'false' value in
there. If the checkbox is checked the hidden field is overridden.

<?php

error_reporting( E_ALL );

if( isset( $_POST[ 'submit' ] ) )
{
     echo '<pre>';
     print_r( $_POST );
     echo '</pre>';
}

echo <<<EOF
<form method='post' action='$_SERVER[PHP_SELF]'>
<input type='hidden' value='0' name='blah'>
<input type='checkbox' value='1' name='blah'> Blah?
<input type='submit' name='submit'>
</form>
EOF;

?>

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

attached mail follows:


I'm running php5.0.5 and I'm trying to get connected to an oracle
server. Pear's DB requires the PHP OCI8 extension. The php website
doesn't give 'installation' instructions for getting php_oci8.dll which
seems to be required in order to connect to an Oracle server. I've got
the oracle instant client downloaded and I have oracle client 8.1
installed already. I just can't seem to figure out how to get php to
recognize oracle. Can anybody help out with this?

James Kilbride

attached mail follows:


It was the version of class-IXR.php, there was a small bug in that
library and the fix had just come out, so it was until I went back and
download some updates that it worked.

On 10/22/05, Richard Lynch <ceol-i-e.com> wrote:
> On Sat, October 22, 2005 10:19 am, Dan McCullough wrote:
> > I'm having any issue finding out why this is happening and how to fix
> > it. Is it a permissions problem between php and the server or
> > something else?
> > Help
>
> Go to the command line/shell or even, gak, MS-DOS, and type:
>
> telnet XYZ 32000
>
> XYZ should be an IP address like 192.168.1.1 or a domain name.
>
> Either the server responds, or it's not working and PHP can't fix it.
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
>
>

attached mail follows:


I have a class that won't be instantiated...so basically just a bunch
of static methods.

How do I call one of the class' static methods from within another
method? Can't use this, and self doesn't work...this is php4.

Thanks.

Class Foo{

   function getMe(){
    return "me";

  }

  function getUs(){
   $us=xxx::getMe();
   $us.="& me";

  }
}

echo Foo::getUs();

attached mail follows:


On Fri, 28 Oct 2005, blackwater dev wrote:

> I have a class that won't be instantiated...so basically just a bunch
> of static methods.
>
> How do I call one of the class' static methods from within another
> method? Can't use this, and self doesn't work...this is php4.

Same way you do it outside the class:

Foo::getMe();

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