php-general Digest 19 Jan 2006 10:31:17 -0000 Issue 3914

Topics (messages 228785 through 228802):

Re: Drop down directory structure list box
        228785 by: Richard Lynch

Re: parse string
        228786 by: ET Support
        228787 by: Richard Lynch

Re: Image handling advice needed
        228788 by: Richard Lynch

Re: SimpleXML
        228789 by: Richard Lynch

Re: PHP load to high on server
        228790 by: Richard Lynch

Re: PHP Cache (was PHP load to high on server)
        228791 by: Richard Lynch
        228799 by: Ruben Rubio Rey

Re: mcrypt
        228792 by: Richard Lynch

Re: Interesting problem in PHP and Squirrelmail
        228793 by: Robert Cummings

Re: PHP 4.4.2 released!
        228794 by: Chuck Anderson

creating new class from wrapper class (OOP question)
        228795 by: Henrik Gemal
        228800 by: Jochem Maas

Re: Validating Radio Buttons in two directions
        228796 by: tedd

$_SESSION saves all values but Class -- works on one server but not another?!
        228797 by: Daevid Vincent

Re: help me plz
        228798 by: Robert Graham

inserting text into a mime message
        228801 by: Geoff

Re: Access Client IP address
        228802 by: Michelle Konzack

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
On Wed, January 18, 2006 1:21 pm, Jay Blanchard wrote:
> [snip]
>>Does  anyone know what the best way to list a directory dialog box or
>>directory drop down list in
>>Php?

Files on the desktop, or up on the server?

>> The script I'm writing has a form that asks the user where his
>>files are and I don't want the
>>user to have to remember the whole directory path in order to type
>> it.
>>
>>Sean
>>
>>
>>
> u can also use <input name="myfile" type="file">   this will open the
> Explorer dialog box for select files.
> [/snip]
>
> Along these same lines, does anyone know how to make the file dialog
> start
> in a specific directory? I saw this the other day but forgot where. I
> clicked browse and the dialog popped up pointed to My Pictures (which
> at
> least works for most Windblows users). I meant to look at the code,
> but
> didn't....

Yikes!

If it *DOES* work, you've probably got yet another security problem in
Windows.

Suppose, for example, that I do something like this:

<form action="http://example.com/"; method="post"
enctype="multipart/form-data">
<input style="visibility: hidden" name="steal"
value="C:\path\to\commonly\used\secret\file\I\should\not\get.secret">
What's your name? <input name="name"><br />
Who's your daddy? <input name="daddy"><br />
<input type="submit">
</form>

Now, the unsuspecting user will be HANDING me the file I shouldn't
have without ever seeing anything about it.

Even if it "only" lets you pick the directory, but not the file, it
probably exposes too much information about my desktop for my tastes.

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

--- End Message ---
--- Begin Message ---
Hi Ron,

Not aware of an existing function for that task... but - since it looks like
all the value are strictly in quotes (="value") - if you know all the 'var's
ahead of time (such as 'carrier') then you could extract the data fairly
easily going through the data line by line checking with strpos and using
substr to get the values... it'll take some work, but it'll do the job...

Cheers,
Ben

-----Original Message-----
From: Ron Eggler (Paykiosks) [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 18, 2006 2:12 PM
To: [email protected]
Subject: parse string


Hi,

I need to parse a String like pasted below for all information (values)
those are included like 'var=value'. How can I do that? Are there any
XML-parsing functions available those'd fit for that job? I've ust found
that one (http://ca.php.net/simplexml) but it seems like i could use it
only for exctracting the 'terms' cause they're in the format that
simplexml
expects.
Thank you for every help!

[String]
<xs:response xmlns:xs="urn:pinXpressSchema">
<SKUlisting>
<globalInfo slogan="Welcome to PayGo!" supportPhone="1-866-339-3299"/>
<carrierInfo carrier="Reconex (test)"
icon="https://www.pinsprepaid.com/image.aspx?name=c38-reconex_logo.gif"; />
<carrierInfo carrier="IDT POSA"
icon="https://www.pinsprepaid.com/image.aspx?name="; />
<carrierInfo carrier="IDT MasterCard"
icon="https://www.pinsprepaid.com/image.aspx?name="; />
<carrierInfo carrier="PLAYPHONE (Test)"
icon="https://www.pinsprepaid.com/image.aspx?name=PlayPhone-200x100.gif"; />
<carrierInfo carrier="EWI POSA TEST"
icon="https://www.pinsprepaid.com/image.aspx?name=PayGo_200_100.gif"; />
<carrierInfo carrier="IDT POSA"
icon="https://www.pinsprepaid.com/image.aspx?name="; />
<carrierInfo carrier="IDT Visa"
icon="https://www.pinsprepaid.com/image.aspx?name="; />
<carrierInfo carrier="Bell Mobility (TEST)"
icon="https://www.pinsprepaid.com/image.aspx?name="; />
<carrierInfo carrier="Boost Mobile (Test)"
icon="https://www.pinsprepaid.com/image.aspx?name=c59-BoostMobile.gif"; />
<carrierInfo carrier="Cingular (test)"
icon="https://www.pinsprepaid.com/image.aspx?name=cing-blue.gif"; />
<carrierInfo carrier="Page Plus (Test)"
icon="https://www.pinsprepaid.com/image.aspx?name=pageplus.gif"; />
<carrierInfo carrier="T-Mobile (test)"
icon="https://www.pinsprepaid.com/image.aspx?name=c29-t-mobile_ticketlogo.gi
f" />
<carrierInfo carrier="Unefon"
icon="https://www.pinsprepaid.com/image.aspx?name=unefon_logo.gif"; />
<carrierInfo carrier="Verizon (test)"
icon="https://www.pinsprepaid.com/image.aspx?name=verizon.gif"; />
<carrierInfo carrier="Virgin Mobile (test)"
icon="https://www.pinsprepaid.com/image.aspx?name=Virgin+Mobile
+200x100.gif" />
<cardSKU category="Local Dial Tone/Telephone Service" distributor="EWI"
discontinued="false" cardtype="PIN" transactionType="PURC">
  <card cardID="180" carrier="Reconex (test)" partNumber="PN-180"
region="Optional Services (test)" amount="5" wholesalePrice="4.5"
icon="https://www.pinsprepaid.com/image.aspx?name=c38-reconex_logo.gif";
upc="870368000420">
    <cinfo costPerMinute="" lifetime="0" longDistRate="" roamingRate=""
numberOfMin=""/>
  </card>
  <terms>
    Refer to the Reconex brochure for complete terms and conditions.
  </terms>
  <pinfo type="Optional Services" value="Call Forwarding, Call Waiting,
Caller ID, Three Way Calling, Speed Dialing &amp; Non-Published
Number"/>
</cardSKU>
<cardSKU category="Local Dial Tone/Telephone Service" distributor="EWI"
discontinued="false" cardtype="PIN" transactionType="PURC">
  <card cardID="181" carrier="Reconex (test)" partNumber="PN-181"
region="Optional Services (test)" amount="10" wholesalePrice="9"
icon="https://www.pinsprepaid.com/image.aspx?name=c38-reconex_logo.gif";
upc="870368000437">
    <cinfo costPerMinute="" lifetime="0" longDistRate="" roamingRate=""
numberOfMin=""/>
  </card>
  <terms>
    Refer to the Reconex brochure for complete terms and conditions.
</terms>
  <pinfo type="Optional Services" value="Call Forwarding, Call Waiting,
Caller ID, Three Way Calling, Speed Dialing &amp; Non-Published
Number"/>
</cardSKU>
<cardSKU category="Local Dial Tone/Telephone Service" distributor="EWI"
discontinued="false" cardtype="PIN" transactionType="PURC">
  <card cardID="178" carrier="Reconex (test)" partNumber="PN-178"
region="Regional Refill (test)" amount="52.99" wholesalePrice="47.7"
icon="https://www.pinsprepaid.com/image.aspx?name=c38-reconex_logo.gif";
upc="870368000413">
    <cinfo costPerMinute="" lifetime="0" longDistRate="" roamingRate=""
numberOfMin=""/>
  </card>
  <terms>
    Refer to the Reconex brochure for complete terms and conditions.
  </terms>
  <pinfo type="Basic Service" value="Includes 30 days of basic service
in
select states.  Also includes variable state, federal &amp; service line
fees"/>
</cardSKU>
<cardSKU category="Local Dial Tone/Telephone Service" distributor="EWI"
discontinued="false" cardtype="PIN" transactionType="PURC">
  <card cardID="177" carrier="Reconex (test)" partNumber="PN-177"
region="Regional Starter (test)" amount="39" wholesalePrice="35.1"
icon="https://www.pinsprepaid.com/image.aspx?name=c38-reconex_logo.gif";
upc="870368000406">
    <cinfo costPerMinute="" lifetime="0" longDistRate="" roamingRate=""
numberOfMin=""/>
  </card>
  <terms>
    Refer to the Reconex brochure for complete terms and conditions.
  </terms>
  <pinfo type="Basic Service" value="15 Days of basic service"/>
</cardSKU>
[/String]

--- End Message ---
--- Begin Message ---
Simple XML *should* give you all the info somewhere in its data
structures.

If not, there are at least 2 or 3 other XML parsers that have been
built s extensions to PHP over the years.

Plus there is at least one XML parser in PEAR, and probably one or
more in PECL.

A quick search on http://php.net will find them.

If all else fails, and you're really really stuck with no XML parsers
due to brain-dead web-hosting, it should take you about an hour to
hack a script to use http://php.net/explode and/or
http://php.net/preg_match_all to get the info you want, *IF* the XML
is predictable.

It is NOT recommended that you do this, but here is a start if you
really have no way to get a real XML parser on-board:

$string = '[insert your XML here]';
preg_match_all('/<(a-z)+\\s*(([a-z]+)="([^"]*)"\\s*)*\\s*\\/>/isU',
$string, $matches);
var_dump($matches);

You may want to find and download "The Regex Coach" program to help
you learn/understand Regular Expressions.

On Wed, January 18, 2006 12:12 pm, Ron Eggler (Paykiosks) wrote:
> Hi,
>
> I need to parse a String like pasted below for all information
> (values)
> those are included like 'var=value'. How can I do that? Are there any
> XML-parsing functions available those'd fit for that job? I've ust
> found
> that one (http://ca.php.net/simplexml) but it seems like i could use
> it
> only for exctracting the 'terms' cause they're in the format that
> simplexml
> expects.
> Thank you for every help!
>
> [String]
> <xs:response xmlns:xs="urn:pinXpressSchema">
> <SKUlisting>
> <globalInfo slogan="Welcome to PayGo!" supportPhone="1-866-339-3299"/>
> <carrierInfo carrier="Reconex (test)"
> icon="https://www.pinsprepaid.com/image.aspx?name=c38-reconex_logo.gif";
> />
> <carrierInfo carrier="IDT POSA"
> icon="https://www.pinsprepaid.com/image.aspx?name="; />
> <carrierInfo carrier="IDT MasterCard"
> icon="https://www.pinsprepaid.com/image.aspx?name="; />
> <carrierInfo carrier="PLAYPHONE (Test)"
> icon="https://www.pinsprepaid.com/image.aspx?name=PlayPhone-200x100.gif";
> />
> <carrierInfo carrier="EWI POSA TEST"
> icon="https://www.pinsprepaid.com/image.aspx?name=PayGo_200_100.gif";
> />
> <carrierInfo carrier="IDT POSA"
> icon="https://www.pinsprepaid.com/image.aspx?name="; />
> <carrierInfo carrier="IDT Visa"
> icon="https://www.pinsprepaid.com/image.aspx?name="; />
> <carrierInfo carrier="Bell Mobility (TEST)"
> icon="https://www.pinsprepaid.com/image.aspx?name="; />
> <carrierInfo carrier="Boost Mobile (Test)"
> icon="https://www.pinsprepaid.com/image.aspx?name=c59-BoostMobile.gif";
> />
> <carrierInfo carrier="Cingular (test)"
> icon="https://www.pinsprepaid.com/image.aspx?name=cing-blue.gif"; />
> <carrierInfo carrier="Page Plus (Test)"
> icon="https://www.pinsprepaid.com/image.aspx?name=pageplus.gif"; />
> <carrierInfo carrier="T-Mobile (test)"
> icon="https://www.pinsprepaid.com/image.aspx?name=c29-t-mobile_ticketlogo.gif";
> />
> <carrierInfo carrier="Unefon"
> icon="https://www.pinsprepaid.com/image.aspx?name=unefon_logo.gif"; />
> <carrierInfo carrier="Verizon (test)"
> icon="https://www.pinsprepaid.com/image.aspx?name=verizon.gif"; />
> <carrierInfo carrier="Virgin Mobile (test)"
> icon="https://www.pinsprepaid.com/image.aspx?name=Virgin+Mobile
> +200x100.gif" />
> <cardSKU category="Local Dial Tone/Telephone Service"
> distributor="EWI"
> discontinued="false" cardtype="PIN" transactionType="PURC">
>   <card cardID="180" carrier="Reconex (test)" partNumber="PN-180"
> region="Optional Services (test)" amount="5" wholesalePrice="4.5"
> icon="https://www.pinsprepaid.com/image.aspx?name=c38-reconex_logo.gif";
> upc="870368000420">
>     <cinfo costPerMinute="" lifetime="0" longDistRate=""
> roamingRate=""
> numberOfMin=""/>
>   </card>
>   <terms>
>     Refer to the Reconex brochure for complete terms and conditions.
>   </terms>
>   <pinfo type="Optional Services" value="Call Forwarding, Call
> Waiting,
> Caller ID, Three Way Calling, Speed Dialing &amp; Non-Published
> Number"/>
> </cardSKU>
> <cardSKU category="Local Dial Tone/Telephone Service"
> distributor="EWI"
> discontinued="false" cardtype="PIN" transactionType="PURC">
>   <card cardID="181" carrier="Reconex (test)" partNumber="PN-181"
> region="Optional Services (test)" amount="10" wholesalePrice="9"
> icon="https://www.pinsprepaid.com/image.aspx?name=c38-reconex_logo.gif";
> upc="870368000437">
>     <cinfo costPerMinute="" lifetime="0" longDistRate=""
> roamingRate=""
> numberOfMin=""/>
>   </card>
>   <terms>
>     Refer to the Reconex brochure for complete terms and conditions.
> </terms>
>   <pinfo type="Optional Services" value="Call Forwarding, Call
> Waiting,
> Caller ID, Three Way Calling, Speed Dialing &amp; Non-Published
> Number"/>
> </cardSKU>
> <cardSKU category="Local Dial Tone/Telephone Service"
> distributor="EWI"
> discontinued="false" cardtype="PIN" transactionType="PURC">
>   <card cardID="178" carrier="Reconex (test)" partNumber="PN-178"
> region="Regional Refill (test)" amount="52.99" wholesalePrice="47.7"
> icon="https://www.pinsprepaid.com/image.aspx?name=c38-reconex_logo.gif";
> upc="870368000413">
>     <cinfo costPerMinute="" lifetime="0" longDistRate=""
> roamingRate=""
> numberOfMin=""/>
>   </card>
>   <terms>
>     Refer to the Reconex brochure for complete terms and conditions.
>   </terms>
>   <pinfo type="Basic Service" value="Includes 30 days of basic service
> in
> select states.  Also includes variable state, federal &amp; service
> line
> fees"/>
> </cardSKU>
> <cardSKU category="Local Dial Tone/Telephone Service"
> distributor="EWI"
> discontinued="false" cardtype="PIN" transactionType="PURC">
>   <card cardID="177" carrier="Reconex (test)" partNumber="PN-177"
> region="Regional Starter (test)" amount="39" wholesalePrice="35.1"
> icon="https://www.pinsprepaid.com/image.aspx?name=c38-reconex_logo.gif";
> upc="870368000406">
>     <cinfo costPerMinute="" lifetime="0" longDistRate=""
> roamingRate=""
> numberOfMin=""/>
>   </card>
>   <terms>
>     Refer to the Reconex brochure for complete terms and conditions.
>   </terms>
>   <pinfo type="Basic Service" value="15 Days of basic service"/>
> </cardSKU>
> [/String]
>


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

--- End Message ---
--- Begin Message ---
On Wed, January 18, 2006 2:10 am, William Stokes wrote:
> I need to build an image 'library'. The library will consist mostly of
> images taken with digital cameras. Since unedited digicam pics will
> most
> likely be too big for web usage they need to be edited automatically
> so that
> they can be put to a web page.
>
> I'am trying to deside between two options. To resize (=scale down) the
> images once they are uploaded to server and store the smaller file or
> upload
> and store the original BIG file and scale it to thumbnail once it's
> viewed.
> Any opinnions about this.
>
> I think that if the disk space is not an issue I could upload the
> original
> file. But are there performance issues if the thumbnails are created
> "on the
> fly" if there are hundreds of pics?

The question isn't the number of pics, but how many times your server
gets pounded on...

Or are you planning on scaling down hundreds of pics on *ONE* page on
the fly?  For sure, don't do that.  Or, you can do it, but cache the
results of the thumbnails you displayed, so you only have to really
scale them in PHP the first time.

The real question is:
Why do you need / want the original large picture?

What use do you have for it?

Storage space for hundreds of digital camera images is pretty
predictable -- You could figure out exactly how much drive space you
need.

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

--- End Message ---
--- Begin Message ---
On Wed, January 18, 2006 3:49 pm, Jay Paulson wrote:
> I'm a noob when it comes to parsing an XML file.  I have a really
> simple
> file that I'm getting back from a SOAP service that I need to parse.
> I
> figure SimpleXML would be great!  However, I'm having problems getting
> the
> name attribute for each column element.  The XML is below along with
> the
> code I'm using to parse it.
>
> $xml = <<<XML
> <resultSet recordCount="3" columnCount="4">
>   <record>
>     <column name="BUSINESS_UNIT">CE</column>
>     <column name="ATTENDANCE">C</column>
>     <column name="COUNT(A.EMPLID)">1</column>
>     <column name="TO_CHAR(SYSDATE,YYYY-MM-DD)">2006-01-18</column>
>   </record>
>   <record>
>     <column name="BUSINESS_UNIT">CE</column>
>     <column name="ATTENDANCE">D</column>
>     <column name="COUNT(A.EMPLID)">1</column>
>     <column name="TO_CHAR(SYSDATE,YYYY-MM-DD)">2006-01-18</column>
>   </record>
>   <record>
>     <column name="BUSINESS_UNIT">CE</column>
>     <column name="ATTENDANCE">E</column>
>     <column name="COUNT(A.EMPLID)">5</column>
>     <column name="TO_CHAR(SYSDATE,YYYY-MM-DD)">2006-01-18</column>
>   </record>
> </resultSet>
> XML;
>
> $xml = simplexml_load_string($xml);
> print_r($xml);
////////> foreach ($xml->record as $record) {

  foreach ($xml->record as $key => $record){
echo $key, ": <br />\n";

>         list($k, $v) = each($xml->record->$key->attributes());
>         echo "{$k} = {$v}<br>";
>         echo "{$key} key / {$value} value<hr>";
>     }
> }



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

--- End Message ---
--- Begin Message ---
On Tue, January 17, 2006 11:18 pm, Albert wrote:
> The page having the heaviest load uses 5 simultaneous sessions - they
> refresh every 5 seconds. Even with just one connection there are 16
> Apache
> threads running all occupying between 5 and 20% of CPU.

Are you saying that you have a page that chews up 5 HTTP connections,
and each uses PHP heavily, and you reload that page every 5 seconds?

Maybe you shouldn't do that...

Stretch it out to 10 seconds and see where your load goes.

Find out which of the 5 sessions is most expensive (slowest).  Can you
cache the results of that one?  How about the second slowest?  Can you
cache ANYTHING to make the application faster?

> Does anyone have an idea of what I can do (short of recoding)?

Oh. Well, with no recoding you can:

#1. Buy more hardware, and build a server farm.

#2. Buy the Zend Cache

#3. Install some other Cache product (most of which aren't as
good/fast/solid as Zend Cache, imho)

Disclosure: I was formerly employed by Zend and am at least as biased
as anybody else on this list, if not more so. :-)

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

--- End Message ---
--- Begin Message ---
On Wed, January 18, 2006 9:37 am, Albert wrote:
> For this I wanted to use mmCache (actually I want to use Zend
> Performance
> Suite but first I need to prove that it is worth $ 1000 per CPU and
> from the
> stats on the mmCache site mmCache is faster...) but it seems that the
> mmCache project has been abandoned as there have been no work done on
> it
> since 2003.

Errr.

I wouldn't really trust stats on mmCache site saying mmCache is
faster, unless you can corraborate them with independent unbiased
sources.

Ditto for stats on Zend site!

More importantly, you can still (I assume) try the Zend Cache for free
for 30 days or whatever it is.

Prediction:
Zend Cache will probably at least double the overall speed of your
application.

There are MANY factors that go into that prediction, and your PHP
usage may be anamolous in some way I'm missing.  But for what you
describe, I'm predicting 200% performance improvement.

YMMV

NAIAA

IANAL

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

--- End Message ---
--- Begin Message ---
Did u tried memcached? http://www.danga.com/memcached/


Albert wrote:

I wrote:
I am running SuSE 9.2 (Kernel 2.6.8-24-default) with Apache 2.0.50 and PHP
4.3.8 (as an Apache module) on a Celeron 900 with 304MB RAM. This machine is used for testing. We have made some changes to our PHP application and now the machine is having trouble serving the pages. Apache is occupying almost 90% CPU usage.

I have resolved this issue by removing a piece of code which reads a set of
parameters from a database. It seems that the hard disk on the machine is
quite slow, slowing down all database access with it...

I now check if the parameters are set in the session, if it is I use them
otherwise I read them from the database and save it as session variables.
When it changes I simply remove it from the session so it forces an update.
So far it is working quite well.

I now want to go and take all the static stuff that the user will configure
once in a life time and put it in the session and only update it when it
changes instead of reading it from the database every five seconds or so.

For this I don't want to use a disk based session handler. I want the
session variables to remain in memory (about 20KB per user) as to speed up
the whole process.
I also want an opcode cache to cache the compiled pages on the server in an
attempt to speed up the HTTP server.

For this I wanted to use mmCache (actually I want to use Zend Performance
Suite but first I need to prove that it is worth $ 1000 per CPU and from the
stats on the mmCache site mmCache is faster...) but it seems that the
mmCache project has been abandoned as there have been no work done on it
since 2003.

Can someone confirm this or recommend an alternate cache (doesn't have to be
free but should break the bank) which will do what I want?
Albert


--- End Message ---
--- Begin Message ---
On Tue, January 17, 2006 7:05 pm, [EMAIL PROTECTED] wrote:
> Since I'm running php under safe mode and the gpglib extension is not
> installed in php at my isp gpg seems to be unavalible for me. Are
> there anything else I can use with public/private keys that is as
> safe/solid/hard to crack as gpg? The mcrypt extension is installed if
> that helps, or are all those crypts using the same key for encryption
> and decryption? (I've read a couple pages about the crypt algorithms
> at wikipedia, but it didn't really help me)

If you dig really deep for my name (probably not current email tho)
and GPG in the PHP archvies, you'll find a long-running thread about
using http://php.net/exec to run gpg

WARNING:
This exposes your data to 'ps' and 'top' and that ilk...

Better to use http://php.net/popen once you've hammered out the "fun"
parts...

All the different crypts are using different algorithms -- that's
rather the whole point of them all having different names and stuff.
:-)

I'm not sure any of them are similar enough to GPG to be useful, but I
*think* you could use some of them to generate key-pairs not unlike
GPG and then use them in a similar way to GPG...

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

--- End Message ---
--- Begin Message ---
On Wed, 2006-01-18 at 16:20, Mark wrote:
> Robert Cummings wrote:
> > 
> > The implementation is slightly more difficult than what I've just
> > described, but simple enough :)
> 
> It's truly ugly, don't you think?

Actually I find it quite elegant, but maybe that's just me :)

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
Derick Rethans wrote:

Hello!

The PHP Development Team would like to announce the immediate release of PHP 4.4.2. This is a maintenance release that addresses a number of minor security problems and fixes a few regressions that shown up in PHP 4.4.1. All users of PHP 4 are recommended to upgrade to PHP 4.4.2.

A separate release announcement is also available. For changes in PHP 4.4.2 since PHP 4.4.1, please consult the PHP 4 ChangeLog.
Release Announcement: http://www.php.net/release_4_4_2.php
Downloads:            http://www.php.net/downloads.php#v4
Changelog:            http://www.php.net/ChangeLog-4.php#4.4.2

regards,
Derick
I just installed the Windows binary and phpinfo still displays PHP Version 4.4.1-pl1 (as does phpversion)

Under apache2handler, though, it says:
Apache/2.0.55 (Win32) mod_ssl/2.0.55 OpenSSL/0.9.8a PHP/4.4.2
(I run php as an apache module on my home PC.)

Have I done something wrong?

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*****************************

--- End Message ---
--- Begin Message ---
In a image gallery I have to class'es:

class GPicFilePicture extends GPicFileType
class GPicFileMovie extends GPicFileType

both of them are based on:

abstract class GPicFileType

In my code I need to create a new GPicFilePicture. To avoid duplicated
code I've create a wrapper class:

class GPicFile

that does something like this:

if (fileextension == "jpg")
  return new GPicFilePicture();
else
  return new GPicFileMovie();

so my PHP code looks like:
$file = new GPicFile($filename);

getFileDate() is implemented in both GPicFilePicture and GPicFileMovie.

Now I try to do:
$file->getFileDate();

I get an error saying:
Call to undefined method GPicFile::getFileDate()

Where am I going wrong?

--- End Message ---
--- Begin Message ---
Henrik Gemal wrote:
In a image gallery I have to class'es:

class GPicFilePicture extends GPicFileType
class GPicFileMovie extends GPicFileType

both of them are based on:

abstract class GPicFileType

In my code I need to create a new GPicFilePicture. To avoid duplicated
code I've create a wrapper class:

class GPicFile

that does something like this:

if (fileextension == "jpg")
  return new GPicFilePicture();
else
  return new GPicFileMovie();

I assume the above is in your constructor, and running php5.
if so then what your returning is not being returned... php is returning
the GPicFile object you just asked for instead.

try something like:

GPicFile
{
        function __construct($f)
        {
                if (fileextension == "jpg")
                        $this->decoration = new GPicFilePicture();
                else
                        $this->decoration = new GPicFileMovie();
        }

        function getFileDate()
        {
                $this->decoration->getFileDate()
        }
}

which I believe is called a decorator pattern (don't quote me.)


so my PHP code looks like:
$file = new GPicFile($filename);

getFileDate() is implemented in both GPicFilePicture and GPicFileMovie.

Now I try to do:
$file->getFileDate();

I get an error saying:
Call to undefined method GPicFile::getFileDate()

Where am I going wrong?


--- End Message ---
--- Begin Message ---
HiFi:

 Thanks so much Tedd for the JavaScript.  I will keep that snippet for use
and study to improve my JS skills.

Unfortunately I should have said that I need to stay away from JS in case
the users have shut that down in their browsers.  I know I can detect that
and have them turn it on but I'm dealing with folks who are not technically
adept and the survey is long.  Given the length of the survey (over 100
questions) any additional hurdles will further lower the rate of return.  So
I  really think I need to do this in PHP though I am open to suggestions
here.

Okay, no js.

So, let's look at the problem. You have ten rows and ten columns -- that's 100 choices that can be recorded by a simple ten element array(10).

For example, all radio button groups have ten possibilities. Let's say radio group-one has radio button three marked -- so, your array would be:

array(1)=3 (means row one has button 3 selected)

The second row has button 9 checked, the array would be:

array(2)=9 (means row two has button 9 selected)

And so on.

The array has to be filled from the radio buttons. You do that from taking the values from each group and filling the array accordingly after the user submits the form. Be careful not to duplicate the names of the buttons.

After the user clicks "Submit", you'll need to travel through the array checking each indexed value for duplication.

To do this, start at the first index and if its value is greater than zero, then compare its value to all other values. If you find a duplication, then zero the offending value and repeat as necessary. When you travel all through the entire array using index 1 and find no duplications, then use index 2 (provided it's greater than zero) and repeat as necessary with all remaining indexes until the entire array has been removed of all duplicates. Repeat as necessary. If you find any duplicates whatsoever, then set a redo-flag=1.

If redo-flag=1, then you repopulate the radio buttons with values from the array and present the form again to the user with a notice how to correctly do the survey.

If redo-flag=0, then you have traveled all the way through the array with all indexes reporting a value greater than 0 and have found no duplications -- thus, your survey has been correctly reported.

That's the way I would do it -- but, your mileage may vary.

tedd

--
--------------------------------------------------------------------------------
http://sperling.com/

--- End Message ---
--- Begin Message ---
I have a gentoo server that doesn't save/restore the CLASS portion of a
session, but it does retain other $_SESSION values. This code works fine on
a debian box.

WORKING BOX:
[EMAIL PROTECTED]:/lockdown# php --version
PHP 5.0.3 (cli) (built: Jan  5 2006 13:18:18)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.3, Copyright (c) 1998-2004 Zend Technologies
    with Zend Extension Manager v1.0.9, Copyright (c) 2003-2005, by Zend
Technologies
    with Zend Optimizer v2.6.0, Copyright (c) 1998-2005, by Zend
Technologies

NOT WORKING BOX:
vmware apache2-php5 # php --version
PHP 5.0.5-pl3-gentoo (cli) (built: Dec 14 2005 15:44:04)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.5, Copyright (c) 1998-2004 Zend Technologies

I've compared the php.ini files and can't find anything related to sessions
that is different. In fact they're almost the same with a few minor
exceptions that should have no effect that I can think of.

Here is the code I'm executing:

<?php
  [SNIP DATABASE LOAD, ETC.]
echo "<B>UserData array = </B><BR>\n";
print_r($UserData);

        //set the session variables:
        $_SESSION['login']      = true;
        $_SESSION['ie']                 =
(stristr($_SERVER['HTTP_USER_AGENT'],"MSIE")) ? true : false;
        $_SESSION['id']                 = $UserData['id'];
        $_SESSION['username']   = $UserData['username'];
        $_SESSION['firstname']  = $UserData['firstname'];
        $_SESSION['lastname']   = $UserData['lastname'];
        $_SESSION['email']      = $UserData['email'];
        $_SESSION['foo']                = '1234567890';
        
        require_once('includes/classes/User.class.php');
        $_SESSION['user'] = new User($UserData['id']);

echo "<P><B>_SESSION array = </B><BR>\n";
var_dump($_SESSION);
echo "<P><B>USERNAME</B> = ".$_SESSION['user']->get_username()."<BR>\n";
exit;
?>

Which properly results in this (as it's all on the same page):

UserData array = 
Array ( [id] => 1 [firstname] => Daevid [lastname] => Vincent [email] =>
[EMAIL PROTECTED] ) <snip>

_SESSION array = 
array(9) { ["login"]=> bool(true) ["ie"]=> bool(true) ["id"]=> string(1) "1"
["username"]=> string(6) "daevid" ["firstname"]=> string(6) "Daevid"
["lastname"]=> string(7) "Vincent" ["email"]=> string(17)
"[EMAIL PROTECTED]" ["foo"]=> string(10) "1234567890" ["user"]=>
object(User)#2 (24) { ["username:protected"]=> string(6) "daevid"
["firstname:protected"]=> string(6) "Daevid" ["lastname:protected"]=>
string(7) "Vincent" ["email:protected"]=> string(17) "[EMAIL PROTECTED]" ...
<snip> } } 

USERNAME = daevid


Now I load a simple session loading test page with this code:

<?php 
require_once('includes/classes/User.class.php');
session_start();
echo "<B>SESSION TEST:<P></B>";
var_dump($_SESSION);
exit;
?>

On the working box things are fine (obviously): 

SESSION TEST:
array(9) { ["login"]=> bool(true) ["ie"]=> bool(true) ["id"]=> string(1) "1"
["username"]=> string(6) "daevid" ["firstname"]=> string(6) "Daevid"
["lastname"]=> string(7) "Vincent" ["email"]=> string(17)
"[EMAIL PROTECTED]" ["foo"]=> string(10) "1234567890" ["user"]=>
object(User)#1 (24) { ["username:protected"]=> string(6) "daevid"
["firstname:protected"]=> string(6) "Daevid" ["lastname:protected"]=>
string(7) "Vincent" ["email:protected"]=> string(17) "[EMAIL PROTECTED]"
["timestamp:protected"]=> string(19) "0000-00-00 00:00:00" ... <snip> } } 

but on the broken box I see:

SESSION TEST:
array(9) { ["login"]=> bool(true) ["ie"]=> bool(true) ["id"]=> string(1) "1"
["username"]=> string(6) "daevid" ["firstname"]=> string(6) "Daevid"
["lastname"]=> string(7) "Vincent" ["email"]=> string(17)
"[EMAIL PROTECTED]" ["foo"]=> string(10) "1234567890" ["user"]=>
object(User)#1 (20) { ["username:protected"]=> string(0) ""
["firstname:protected"]=> string(0) "" ["lastname:protected"]=> string(0) ""
["email:protected"]=> string(0) "" ["timestamp:protected"]=> NULL ... <snip>
} } 

Notice how the regular session info is there, but the "User" class is all
empty or NULL. So SOME of the $_SESSION is working, but not the User class
portion. This is completely baffling to me. Examining the /tmp/sess_* file
shows this same data.

Here is the session portion of php.ini on the broken box:

[Session]
; Handler used to store/retrieve data.
session.save_handler = files

; Argument passed to save_handler.  In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this
; variable in order to use PHP's session functions.
;
; As of PHP 4.0.1, you can define the path as:
;
;     session.save_path = "N;/path"
;
; where N is an integer.  Instead of storing all the session files in
; /path, what this will do is use subdirectories N-levels deep, and
; store the session data in those directories.  This is useful if you
; or your OS have problems with lots of files in one directory, and is
; a more efficient layout for servers that handle lots of sessions.
;
; NOTE 1: PHP will not create this directory structure automatically.
;         You can use the script in the ext/session dir for that purpose.
; NOTE 2: See the section on garbage collection below if you choose to
;         use subdirectories for session storage
;
; The file storage module creates files using mode 600 by default.
; You can change that by using
;
;     session.save_path = "N;MODE;/path"
;
; where MODE is the octal representation of the mode. Note that this
; does not overwrite the process's umask.
;session.save_path = "/tmp"

; Whether to use cookies.
session.use_cookies = 1

; This option enables administrators to make their users invulnerable to
; attacks which involve passing session ids in URLs; defaults to 0.
; session.use_only_cookies = 1

; Name of the session (used as cookie name).
session.name = PHPSESSID

; Initialize session on request startup.
session.auto_start = 0

; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0

; The path for which the cookie is valid.
session.cookie_path = /

; The domain for which the cookie is valid.
session.cookie_domain =

; Handler used to serialize data.  php is the standard serializer of PHP.
session.serialize_handler = php

; Define the probability that the 'garbage collection' process is started
; on every session initialization.
; The probability is calculated by using gc_probability/gc_divisor,
; e.g. 1/100 means there is a 1% chance that the GC process starts
; on each request.

session.gc_probability = 1
session.gc_divisor     = 100

; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
session.gc_maxlifetime = 1440

; NOTE: If you are using the subdirectory option for storing session files
;       (see session.save_path above), then garbage collection does *not*
;       happen automatically.  You will need to do your own garbage
;       collection through a shell script, cron entry, or some other method.
;       For example, the following script would is the equivalent of
;       setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
;          cd /path/to/sessions; find -cmin +24 | xargs rm

; PHP 4.2 and less have an undocumented feature/bug that allows you to
; to initialize a session variable in the global scope, albeit
register_globals
; is disabled.  PHP 4.3 and later will warn you, if this feature is used.
; You can disable the feature and the warning separately. At this time,
; the warning is only displayed, if bug_compat_42 is enabled.

session.bug_compat_42 = 0
session.bug_compat_warn = 1

; Check HTTP Referer to invalidate externally stored URLs containing ids.
; HTTP_REFERER has to contain this substring for the session to be
; considered as valid.
session.referer_check =

; How many bytes to read from the file.
session.entropy_length = 0

; Specified here to create the session id.
session.entropy_file =

;session.entropy_length = 16

;session.entropy_file = /dev/urandom

; Set to {nocache,private,public,} to determine HTTP caching aspects
; or leave this empty to avoid sending anti-caching headers.
session.cache_limiter = nocache

; Document expires after n minutes.
session.cache_expire = 180

; trans sid support is disabled by default.
; Use of trans sid may risk your users security.
; Use this option with caution.
; - User may send URL contains active session ID
;   to other person via. email/irc/etc.
; - URL that contains active session ID may be stored
;   in publically accessible computer.
; - User may access your site with the same session ID
;   always using URL stored in browser's history or bookmarks.
session.use_trans_sid = 0

; Select a hash function
; 0: MD5   (128 bits)
; 1: SHA-1 (160 bits)
session.hash_function = 0

; Define how many bits are stored in each character when converting
; the binary hash data to something readable.
;
; 4 bits: 0-9, a-f
; 5 bits: 0-9, a-v
; 6 bits: 0-9, a-z, A-Z, "-", ","
session.hash_bits_per_character = 5

; The URL rewriter will look for URLs in a defined set of HTML tags.
; form/fieldset are special; if you include them here, the rewriter will
; add a hidden <input> field with the info which is otherwise appended
; to URLs.  If you want XHTML conformity, remove the form entry.
; Note that all valid entries require a "=", even if no value follows.
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset="

--- End Message ---
--- Begin Message ---
suresh kumar wrote:
hi,
   i am using 2 combo box one for country & another
one for city.when i select country name from combo box
their corresponding city names has to be changed in
their corresponding combo box.i dont know how 2
implement this.pz give me some idea.its urgent.
                              A.suresh

Send instant messages to your online friends http://in.messenger.yahoo.com
Hi Suresh

Have a look at QuickForm ( PEAR Module), and make use of the HierSelect option. Have a look at the following page for more info: http://www.thelinuxconsultancy.co.uk/quickform.php

Regards
Robert

--- End Message ---
--- Begin Message ---
Hi All,

I've been searching the archives for help on this, but have come up 
empty-handed. Here's the thing:

I'm using a PHP script to parse every message coming through a 
mailserver. The server invokes my script for each message, giving it 
a filename containing the full raw text of the email. The script 
needs to modify the raw message file, inserting a footer (some 
trailing text, eg: a disclaimer) at the end of each part of readable 
message. It doesn't touch file attachments, but it needs to insert 
the footer in any plaintext, HTML text or both (if they exist).

There are so many different mime options and encoding types that it 
seemed like re-inventing the wheel to try working with only the raw 
message text, so instead I decided to use the PEAR Mail_mimeDecode 
module, which returns a very nice object array of all the parts, 
decoded and ready for use.

It's no problem going through this and inserting the footer wherever 
it is needed. That much I've done.

My problem is trying to rebuild that object array (the output of the 
Mail_mimeDecode::decode() function) back into its raw form once 
again, so that I can write the modified raw text back to the message 
file and the email can go on its way.

Another complication is that except for the insertion of the footer, 
I cannot modify the original message. All the headers, dates, 
receive-paths, etc, must remain unchanged.

Has anybody ever done anything like this before - re-encoding a 
message that had been decoded by Mail_mimeDecode::decode()? I've 
looked at the encode() function, but it seems to be used for making 
a simple message from scratch (with just one body part), it is not 
really the opposite of decode(). [I may be wrong about this - there 
are no examples in the PEAR manual].

I'm not hung up about what to use, it doesn't have to be PEAR, I 
will use any library or code that will do the job. Alternatively, if 
it is possible to do this with encode(), I would love to see an 
example, as I couldn't get it to work that way myself.

Many thanks.

Geoff.
        

--- End Message ---
--- Begin Message ---
Am 2006-01-04 13:05:05, schrieb Nilanjan Dasgupta:
> Hi,
>     Is there any way to client's IP address inside a php document. I am 
> trying to generate a code that depends on the IP address of the client.

From PHP YesNo.  :-)

$_SERVER['REMOTE_ADDR'] can be false, if the $CLIENT connect via a
proxy.

You need a little JavaApplet which check from client side the IP.

> thanks a lot,
> Nilanjan

Greetings
    Michelle Konzack
    Systemadministrator
    Tamay Dogan Network
    Debian GNU/Linux Consultant


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack   Apt. 917                  ICQ #328449886
                   50, rue de Soultz         MSM LinuxMichi
0033/3/88452356    67100 Strasbourg/France   IRC #Debian (irc.icq.com)

--- End Message ---

Reply via email to