php-general Digest 29 Sep 2005 21:45:41 -0000 Issue 3710

Topics (messages 223392 through 223430):

Re: Array Select from database
        223392 by: Robin Vickery

Functions Returning large strings
        223393 by: zzapper
        223397 by: Andy Pieters
        223402 by: zzapper

imap_mail and outgoing mailserver configurations
        223394 by: Lars Demel

Re: Error with DOMDocument->saveXML()
        223395 by: Andy Pieters
        223410 by: Stephen Leaf
        223416 by: Scott Fletcher
        223420 by: Stephen Leaf
        223421 by: Stephen Leaf

Re: Strange behaviour overriding methods in 5.0.4
        223396 by: Jochem Maas

Re: Object Function-call handling in PHP5
        223398 by: DarkX

updating forms
        223399 by: hope
        223400 by: Norbert Wenzel
        223401 by: Norbert Wenzel

Problems with new PHP install
        223403 by: Chris Boget
        223404 by: Jay Blanchard
        223406 by: Chris Boget
        223407 by: John Nichel
        223408 by: John Nichel
        223409 by: Chris Boget
        223412 by: Jay Blanchard
        223413 by: Chris Boget
        223414 by: John Nichel
        223415 by: Jay Blanchard

Re: Array - partical path to the array's path (part 2)
        223405 by: Scott Fletcher

Array: how to find a parent key when using a child key?
        223411 by: Scott Fletcher

decrypting query string back into $_GET['var']
        223417 by: Graham Anderson
        223418 by: Jochem Maas
        223419 by: Graham Anderson

Mixing PHP & VBSCript
        223422 by: Jay Blanchard
        223423 by: Chris W. Parker
        223428 by: Miles Thompson
        223429 by: Jay Blanchard
        223430 by: Satyam

php search engine
        223424 by: Ross
        223427 by: John Nichel

PHP and Active Directory
        223425 by: Miretsky, Anya

Re: PDF Thumbnails
        223426 by: Matt Darby

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On 9/28/05, Silvio Porcellana <[EMAIL PROTECTED]> wrote:
>
> In addiction, I would (SQL)escape the values joined: supposing you are
> using MySQL, I'd do:
> $values = join("', '", array_map('mysql_real_escape_string', $array));

I agree entirely; I was just trying to keep things simple for the OP.

  -robin

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

I have a series of nested functions which return a large string (as apposed to 
working on global
string) , is this inefficient? Or is PHP clever enough to just pass a pointer?

to simplify

$large_string=fn_one(fn_two(fn_three())));


your advice pls


-- 
zzapper
Success for Techies and Vim,Zsh tips
http://SuccessTheory.com/

--- End Message ---
--- Begin Message ---
Hi
> I have a series of nested functions which return a large string (as apposed
> to working on global string) , is this inefficient? Or is PHP clever enough
> to just pass a pointer?

> $large_string=fn_one(fn_two(fn_three())));

PHP is by no means cleaver enough to read your mind as to what you want it to 
do.

If you want to pass pointers instead of strings then do as this

function one(&$buffer)
{
 #processing, return true/false based on success, put result in buffer
}

function two(&$buffer)
{
 #processing,...
}

Then do like this:

$variable='input value';
if(one($variable))
 if(two($variable))
 echo "Result: $variable";

HTH

Andy

-- 
Registered Linux User Number 379093
Now listening to [silence]

   amaroK::the Coolest Media Player in the known Universe!


   Cockroaches and socialites are the only things that can 
   stay up all night and eat anything.
                                            Herb Caen
--
-- --BEGIN GEEK CODE BLOCK-----
Version: 3.1
GAT/O/>E$ d-(---)>+ s:(+)>: a--(-)>? C++++$(+++) UL++++>++++$ P-(+)>++
L+++>++++$ E---(-)@ W+++>+++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++)
PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+)
e>++++$@ h++(*) r-->++ y--()>++++
-- ---END GEEK CODE BLOCK------
--
Check out these few php utilities that I released
 under the GPL2 and that are meant for use with a 
 php cli binary:
 
 http://www.vlaamse-kern.com/sas/

--

Attachment: pgpEbsC3TVEQs.pgp
Description: PGP signature


--- End Message ---
--- Begin Message ---
On Thu, 29 Sep 2005 11:48:10 +0200,  wrote:

>Hi
>> I have a series of nested functions which recursively return a large string 
>> (as apposed
>> to working on global string) , is this inefficient? Or is PHP clever enough
>> to just pass a pointer?
>
>> $large_string=fn_one(fn_two(fn_three($some_long_string))));
>
>PHP is by no means clever enough to read your mind as to what you want it to 
>do.
>
No slight meant to PHP,  just wanted to know whether I had to worry about it, 
according to your
reply seems like I must.





-- 
zzapper
Success for Techies and Vim,Zsh tips
http://SuccessTheory.com/

--- End Message ---
--- Begin Message ---
hi,

i have a problem with imap_mail. the mails i always send with this function contents in the header field 'from' always the server where php is installed. in our system php and the mail server are installed on different machines. so i think that might be the problem. but we configured in the php.ini the outgoing mailserver (smtp section of course).

Does anybody could help us to fix the problem to use the right outgoing mail server???
--- End Message ---
--- Begin Message ---
Hi 

> <b>Fatal error</b>:  Method Document::__toString() must return a string
> value in <b>/srv/www/localhost/htdocs/db/index.php</b> on line
> <b>140</b><br />

That's just what it says, check your program flow. 

You overrided the tostring function and somewhere in that new function you 
jump out of it because of a flag that is set, and thus not returning 
anything, which is equal to return null.  

> I've not checked my E_NOTICE's yet.. actually not quite sure how to turn

One way would be to use .htaccess files, but I have included in all my 
programs (read sites) a mechanism for this.  Have one file where you keep all 
the varialbes that you need accross the different pages (scripts), and then 
on all your files, put this on the top:

   if(!(defined('GLOBALS_LOADED')))
    require_once 'scripts/globals.php'; #be sure to set relative path to 
globals
  
   if(defined('DEBUG_LVL')) 
    error_reporting(DEBUG_LVL); 
   else
    error_reporting(0);

Then in your file globals.php you need to have at least this:

<?php
define('GLOBALS_LOADED',true);
define('DEBUG_LVL',E_ALL);
?>

Once you go to production, all you need to do is change the E_ALL to 0 and all 
the pages follow suit...

HTH


Andy

-- 
Registered Linux User Number 379093
Now listening to Radio Stream

   amaroK::the Coolest Media Player in the known Universe!


   Cockroaches and socialites are the only things that can 
   stay up all night and eat anything.
                                            Herb Caen
--
-- --BEGIN GEEK CODE BLOCK-----
Version: 3.1
GAT/O/>E$ d-(---)>+ s:(+)>: a--(-)>? C++++$(+++) UL++++>++++$ P-(+)>++
L+++>++++$ E---(-)@ W+++>+++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++)
PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+)
e>++++$@ h++(*) r-->++ y--()>++++
-- ---END GEEK CODE BLOCK------
--
Check out these few php utilities that I released
 under the GPL2 and that are meant for use with a 
 php cli binary:
 
 http://www.vlaamse-kern.com/sas/

--

Attachment: pgpFSjyJD6vSa.pgp
Description: PGP signature


--- End Message ---
--- Begin Message ---
On Thursday 29 September 2005 04:20 am, Andy Pieters wrote:
> Hi
>
> > <b>Fatal error</b>:  Method Document::__toString() must return a string
> > value in <b>/srv/www/localhost/htdocs/db/index.php</b> on line
> > <b>140</b><br />
>
> That's just what it says, check your program flow.
>
> You overrided the tostring function and somewhere in that new function you
> jump out of it because of a flag that is set, and thus not returning
> anything, which is equal to return null.
I'd love to say that is possible however it's not. 
        function __toString() {
                # Transform...
                if (!$this->outXML) {
                        $XSlt = new xsltprocessor();
                        $XSlt->registerPHPFunctions();
                        
$XSlt->importStyleSheet(DomDocument::load($this->style));
                        return $XSlt->transformToXML($this->Dom);
                } else {
                        return $this->Dom->saveXML();
                }
        }
As you can see there is nothing that could make it jump out. very straight 
forward and all cases handled via else.
The line: return $this->Dom->saveXML(); is somehow returning null.

Thank you for the advice on how to enable notices.
being I always include my Document script I just added
error_reporting(E_ALL); to the top.

Sadly I'm getting no Notices about my problem. Am getting 1 notice but nothing 
of any interest

--- End Message ---
--- Begin Message ---
It is just that not many work with XML often enough to know well enough how
to use it.  I noticed many folks have different way of using XML that
doesn't best fit our need.

I have this same problem as well.  So, you're not the only one here as I
have this same problem as well.

"Stephen Leaf" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Thursday 29 September 2005 04:20 am, Andy Pieters wrote:
> > Hi
> >
> > > <b>Fatal error</b>:  Method Document::__toString() must return a
string
> > > value in <b>/srv/www/localhost/htdocs/db/index.php</b> on line
> > > <b>140</b><br />
> >
> > That's just what it says, check your program flow.
> >
> > You overrided the tostring function and somewhere in that new function
you
> > jump out of it because of a flag that is set, and thus not returning
> > anything, which is equal to return null.
> I'd love to say that is possible however it's not.
> function __toString() {
> # Transform...
> if (!$this->outXML) {
> $XSlt = new xsltprocessor();
> $XSlt->registerPHPFunctions();
> $XSlt->importStyleSheet(DomDocument::load($this->style));
> return $XSlt->transformToXML($this->Dom);
> } else {
> return $this->Dom->saveXML();
> }
> }
> As you can see there is nothing that could make it jump out. very straight
> forward and all cases handled via else.
> The line: return $this->Dom->saveXML(); is somehow returning null.
>
> Thank you for the advice on how to enable notices.
> being I always include my Document script I just added
> error_reporting(E_ALL); to the top.
>
> Sadly I'm getting no Notices about my problem. Am getting 1 notice but
nothing
> of any interest

--- End Message ---
--- Begin Message ---
On Thursday 29 September 2005 09:37 am, Scott Fletcher wrote:
> It is just that not many work with XML often enough to know well enough how
> to use it.  I noticed many folks have different way of using XML that
> doesn't best fit our need.
It is a newer idea of how to do things.

>
> I have this same problem as well.  So, you're not the only one here as I
> have this same problem as well.
Glad I'm not in this boat alone!

I almost have a sneaky suspicion that it has something to do with the 
__toString()
I've noticed in the past I couldn't do somethings that I normally could do in 
custom functions. think it had something to do with constants but then that 
was when I didn't have much experience with php5 objects so it's very likely 
that was just stupidity on my behalf.
Not played around with it too much since then however. So I guess nows a 
better time than ever. hopefully I can duplicate this behavior in a smaller 
class that I can just post to the list.

>
> "Stephen Leaf" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>
> > On Thursday 29 September 2005 04:20 am, Andy Pieters wrote:
> > > Hi
> > >
> > > > <b>Fatal error</b>:  Method Document::__toString() must return a
>
> string
>
> > > > value in <b>/srv/www/localhost/htdocs/db/index.php</b> on line
> > > > <b>140</b><br />
> > >
> > > That's just what it says, check your program flow.
> > >
> > > You overrided the tostring function and somewhere in that new function
>
> you
>
> > > jump out of it because of a flag that is set, and thus not returning
> > > anything, which is equal to return null.
> >
> > I'd love to say that is possible however it's not.
> > function __toString() {
> > # Transform...
> > if (!$this->outXML) {
> > $XSlt = new xsltprocessor();
> > $XSlt->registerPHPFunctions();
> > $XSlt->importStyleSheet(DomDocument::load($this->style));
> > return $XSlt->transformToXML($this->Dom);
> > } else {
> > return $this->Dom->saveXML();
> > }
> > }
> > As you can see there is nothing that could make it jump out. very
> > straight forward and all cases handled via else.
> > The line: return $this->Dom->saveXML(); is somehow returning null.
> >
> > Thank you for the advice on how to enable notices.
> > being I always include my Document script I just added
> > error_reporting(E_ALL); to the top.
> >
> > Sadly I'm getting no Notices about my problem. Am getting 1 notice but
>
> nothing
>
> > of any interest

--- End Message ---
--- Begin Message ---
On Thursday 29 September 2005 12:26 pm, Stephen Leaf wrote:

I have figured it out!
My guess couldn't have been more _wrong_.
Here is all you need to recreate the Error.
There is only 1 value that is off.
in the DOMDocument I gave it the wrong encoding type.
uft-8 .. it should read utf-8.
Interesting that PHP doesn't tell you about a bad encoding type.

<?php
        class test {
                private $Dom;

                function __construct ($rootName) {
                        $this->Dom = new DOMDocument('1.0', 'uft-8');
                        
$this->Dom->appendChild($this->Dom->createElement($rootName));
                }
                function __toString() {
                        return $this->Dom->saveXML();
                }
        }

        $test = new test("test");
        echo $test;
?>

--- End Message ---
--- Begin Message ---
Norbert Wenzel wrote:
I have to say thank you to you both. In fact I still don't know what exactly was wrong or may have caused this error (output buffering was off, and there was no @ in the whole file) but after a night of sleep I tried again before reinstalling the server and everything worked as fine as it should.

It's quite strange, since I was the last one in company yesterday and locked it myself, but maybe some tiny little imps fixed the problem by night.

And to dissapoint you Jochem (at least I think it was you), it is a Red Hat System, no Windows.

you do realise RedHat is the 'Windows' of the Linux world ;-)
hey your on Linux whats to disappoint :-)


Thanks for your help and greetings from Vienna,
Norbert


--- End Message ---
--- Begin Message ---
Thats what im looking for pretty much, Ill keep my eye on that bug. Thanks!

On 9/28/05, Ondrej Ivanič <[EMAIL PROTECTED]> wrote:
> > Dmitry committed a path for improved __toString() support. However, im not
>
> > sure if it will be PHP6 only...
>
> I know about this patch. I think, it will be PHP6 only.
>
> --
> Ondrej Ivanic
> ([EMAIL PROTECTED])
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
-----BEGIN PGP MESSAGE-----
The One and Only DarkX
-----END PGP MESSAGE-----
-----BEGIN PGP SIGNATURE----
owGbwMvMwCRoO3M+/7fM0iLG07JJDE4vrReHZKQq+OelKiTmpQDpnEoFl8Si7Aiu
DntmVpD8BpgGQabIGob5ToUFGnFlWgz8cj6zPulrPMrfdI2ZYX7wx/++aeWli6aY
7ZqsahKeKc789DAA
=k1EI
-----END PGP SIGNATURE-----

--- End Message ---
--- Begin Message ---
i have a text area on my page.
As page is uploaded it displays certain text in it.
It has also has a text area with same text that is being displayed above in the page .
If user changes this text of text area  n presses submit button
the page needs to display updated text in the text area
and as well as updated text above in the page.

2ndly the text area must display text alogwith tags
e.g <h1>heading<h1>

this goes text



but above in the page these tags must like <h1> </h1>
mustnt be displayed instead the heading word must become of h1 format.

how can i get all tags like <br> <h1> etc. as enterd by user
coz if i get it on next page n save it database,
the next time wen i wil dsiplay there wil be no brs .


n how to update the page n display updated text?

regards
hope

--- End Message ---
--- Begin Message ---
(hope) wrote:
i have a text area on my page.
As page is uploaded it displays certain text in it.
It has also has a text area with same text that is being displayed above in the page .
If user changes this text of text area  n presses submit button
the page needs to display updated text in the text area
and as well as updated text above in the page.

2ndly the text area must display text alogwith tags
e.g <h1>heading<h1>

this goes text



but above in the page these tags must like <h1> </h1>
mustnt be displayed instead the heading word must become of h1 format.

how can i get all tags like <br> <h1> etc. as enterd by user
coz if i get it on next page n save it database,
the next time wen i wil dsiplay there wil be no brs .


n how to update the page n display updated text?

regards
hope

see functions htmlentities() or htmlspecialchars() to replace < with &lt; and so on.
--- End Message ---
--- Begin Message ---
(hope) wrote:
i have a text area on my page.
As page is uploaded it displays certain text in it.
It has also has a text area with same text that is being displayed above in the page .
If user changes this text of text area  n presses submit button
the page needs to display updated text in the text area
and as well as updated text above in the page.

2ndly the text area must display text alogwith tags
e.g <h1>heading<h1>

this goes text



but above in the page these tags must like <h1> </h1>
mustnt be displayed instead the heading word must become of h1 format.

how can i get all tags like <br> <h1> etc. as enterd by user
coz if i get it on next page n save it database,
the next time wen i wil dsiplay there wil be no brs .


n how to update the page n display updated text?

regards
hope

see functions htmlentities() or htmlspecialchars() to replace < with &lt; and so on.
--- End Message ---
--- Begin Message --- Since I was having so much difficulty getting PHP (with libxml2) installed on RH9, I decided to take the advice given by several people and use Fedora Core 4 instead, which I get installed w/o difficulty. So next is Apache/PHP and I download Apache version
2.0.54 and PHP version 5.0.5.  Following the instructions on the
PHP site (http://www.php.net/manual/en/install.unix.apache2.php)
exactly, I'm able to get both configured and installed w/o difficulty.
I first test Apache by going to localhost to see if the server is running.
It is.  Then I modify the httpd.conf file as instructed at the above
page by adding the LoadModule and AddType and then create a
'hello world' php script to make sure php is working.

The problem I'm getting is when I access the page, it's showing me
the actual php code and not the parsed result. I looked in the modules directory to see if the libphp5.so file is there and it is. I
did notice something odd, though.  In the httpd.conf file there are
a large number of LoadModule lines for modules that are not in
the modules directory.  Could that be causing my problem?

In any case, if someone could give me some pointers are to where
I should concentrate my attentions in order to resolve this problem,
I would be very appreciative!

thnx,
Chris

--- End Message ---
--- Begin Message ---
[snip]
Then I modify the httpd.conf file as instructed at the above
page by adding the LoadModule and AddType and then create a
'hello world' php script to make sure php is working.
[/snip]

Did you restart the Apache server after making the changes to httpd.conf ? I
know it is basic, I just have to ask.

--- End Message ---
--- Begin Message ---
[snip]
Then I modify the httpd.conf file as instructed at the above
page by adding the LoadModule and AddType and then create a
'hello world' php script to make sure php is working.
[/snip]
Did you restart the Apache server after making the changes to httpd.conf ? I
know it is basic, I just have to ask.

Fair enough. :)
Yes, I did. Step 8 (on the included link) of the PHP installation has you start Apache and then stop it again. It was during this step that I tested to make
sure Apache was working by just going to http://localhost.  Then step 16 has
you start Apache again. The only slightly different thing I did that wasn't part
of the installation was my configure of php.  It looked like this:

./configure \
--enable-force-cgi-redirect \
--without-pear \
--enable-magic-quotes \
--enable-bcmath \
--enable-calendar \
--with-mysql=/usr/local/mysql \
--enable-ftp \
--enable-mailparse \
--with-mcrypt \
--enable-trans-sid \
--disable-short-tags \
--with-zlib-dir=/usr/lib \
--enable-wddx \
--with-xml \
--with-dom=/usr \
--with-xslt-sablot \
--with-expat-dir=/usr \
--with-dom-xslt=/usr \
--with-sablot-js=/usr \
--enable-xslt \
--with-apxs2=/usr/local/apache2/bin/apxs

And that configured with no error (at least, as far as I could tell). My test
script looks like this:

<script language="php">
 echo "PHP Works!!";
</script>
<br>
<? echo "PHP Works??";

And that is exactly what is getting output by the browser. The <br> isn't even
getting interpreted as a break...?

thnx,
Chris



--- End Message ---
--- Begin Message ---
Chris Boget wrote:
Since I was having so much difficulty getting PHP (with libxml2) installed on RH9, I decided to take the advice given by several people and use Fedora Core 4 instead, which I get installed w/o difficulty. So next is Apache/PHP and I download Apache version
2.0.54 and PHP version 5.0.5.  Following the instructions on the
PHP site (http://www.php.net/manual/en/install.unix.apache2.php)
exactly, I'm able to get both configured and installed w/o difficulty.
I first test Apache by going to localhost to see if the server is running.
It is.  Then I modify the httpd.conf file as instructed at the above
page by adding the LoadModule and AddType and then create a
'hello world' php script to make sure php is working.

The problem I'm getting is when I access the page, it's showing me
the actual php code and not the parsed result. I looked in the modules directory to see if the libphp5.so file is there and it is. I
did notice something odd, though.  In the httpd.conf file there are
a large number of LoadModule lines for modules that are not in
the modules directory.  Could that be causing my problem?

In any case, if someone could give me some pointers are to where
I should concentrate my attentions in order to resolve this problem,
I would be very appreciative!

Is there a line like this in your httpd.conf...?

AddType application/x-httpd-php .php

(Don't forget to restart Apache ;)

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Chris Boget wrote:
<snip>
My test
script looks like this:

<script language="php">
 echo "PHP Works!!";
</script>
<br>
<? echo "PHP Works??";

And that is exactly what is getting output by the browser. The <br> isn't even
getting interpreted as a break...?

Yeah, looks like you need the AddType entry. Apache doesn't know what *.php is, so it's just serving it up as plain text.


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
And that is exactly what is getting output by the browser. The <br> isn't even getting interpreted as a break...?

Is there a line like this in your httpd.conf...?
AddType application/x-httpd-php .php

[snip]

Yeah, looks like you need the AddType entry. Apache doesn't know what *.php is, so it's just serving it up as plain text.

Step 15 of the php installation (as listed in the link in my OP) has you add the
following to the httpd.conf:

AddType application/x-httpd-php .php .phtml

I also went ahead and added the following as well

AddType application/x-httpd-php-source .phps

The filename of my test script, though, is php_test.php and not php_test.phps
so php should be parsing it..

thnx,
Chris
--- End Message ---
--- Begin Message ---
[snip]
Step 15 of the php installation (as listed in the link in my OP) has you add

the following to the httpd.conf:

AddType application/x-httpd-php .php .phtml

I also went ahead and added the following as well

AddType application/x-httpd-php-source .phps

The filename of my test script, though, is php_test.php and not 
php_test.phps
so php should be parsing it..
[/snip]

Have you enabled a version of php.ini? It is not necessary...just a thought.

--- End Message ---
--- Begin Message ---
Step 15 of the php installation (as listed in the link in my OP) has you add the following to the httpd.conf:

Ok, color me retarded.  Pretty please. :)  It turns out I modified the wrong
httpd.conf file.

duh.

Sorry about that.  Everyone can move along.  Nothing to see here but some
blathering idiot. :p  hehehe

thnx,
Chris
--- End Message ---
--- Begin Message ---
Chris Boget wrote:
Step 15 of the php installation (as listed in the link in my OP) has you add the following to the httpd.conf:


Ok, color me retarded.

That happens when Jay gets involved.  ;)

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
[snip]
duh.
[/snip]

You have now officially obtained a lifetime membership to the club. Your
t-shirt should arrive in the mail soon.

--- End Message ---
--- Begin Message ---
> the xml above is not structurally
> the same as the array below !!!!
>
> I'll bet your output has just one message
> element right? or you have gone completely offtrack.
>
> might be time you went here:
>
> http://php.net/xml
> http://php.net/dom
> http://php.net/domxml
>
> might be something there to help you out
> especially if you give php5 a try.

Yea, gone offtrack.  Not sure if it is just one element that is offtrack or
more since this is only a simple testcase.  I'll keep working on it.

The funny things is most of the xml features doesn't fully cover our need so
somebody had to do custom programming.  The one at Pear isn't close enough
and is a little bit primitive.  I guess we're doing all what we can here.

I found that keeping the script simple would greatly help as we move on to
newer and newer version.  I can't really upgrade to php5 since I have at
least 5 websites running on the same version.  It would take some testing
through the whole scripts on the whole websites to make sure the code work
correctly.

--- End Message ---
--- Begin Message ---
I'm using the recursive function and it use the foreach() loop.  I can
figure out how to use the current key but I could not figure out how to use
the parent's key.  Can anyone point out to what I'm missing here?

Just look at the "//Parent Key - How??" comment in the script...    I'm not
sure what php function that can allow us to walk up the array like
array_walk() for example.  Thanks...

[code]
$array = array
(
  'NEWSFEED' => array
  (
    '0' => array
    (
      'MESSAGE' => array
      (
        '0' => array
        (
          'COMMENT' => array
          (
            '0' => array
            (
              'VALUE' => 'Comment #1'
            )
          )
        ),
        '1' => array
        (
          'COMMENT' => array
          (
            '0' => array
            (
              'VALUE' => 'Comment #2'
            )
          )
        )
      )
    )
  )
);

  function GetXmlStr($tree)
  {
     $branch_level = 0;  //Tree's branches level...

     XmlTreeDecompile($tree, $branch_level);

     return htmlentities($str1);
  }
  function XmlTreeDecompile($tree, $branch_level)
  {
     $branch_level++;

     foreach($tree as $key => $value)
     {
        if ($branch_level % 2 != 0) {  //xml name-tag counter...
           if(!(is_array($value))) {
              echo str_repeat("
",$branch_level)."<".$key.">".$value."</".$key.">"."\r\n";
           } else {
              echo str_repeat(" ",$branch_level)."<".$key.">"."\r\n";
              XmlTreeDecompile($value, $branch_level);
              echo str_repeat(" ",$branch_level)."</".$key.">"."\r\n";

              $str1 = $key;
           }
        } else {  //Xml tag's name...
           //echo $key." #<br>";
           if ($key != 0) {
              //Parent Key - How??

              echo str_repeat(" ",($branch_level-1))."</MESSAGE###>"."\r\n";
              echo str_repeat(" ",($branch_level-1))."<MESSAGE###>"."\r\n";
           }
           XmlTreeDecompile($value, $branch_level);
        }
     }
  }

  $xml_string = GetXmlStr($array);

  //echo "\n<br><br>\n".$xml_string;
[/code]

--- End Message ---
--- Begin Message ---

What is the best way to decrypt a query string  back into  variables ?


$root = "http://www.myserver.com/script.php";;
$queryString = "?test=mytest&color=red";
myEncrypt($queryString);  //add mCrypt encryption
$finalURL = $root.$encryptedQueryString;

what is the proper what to decrypt the GET variables on the other side ?


Do you need to decrypt the query string first ?
decrypt($_SERVER['QUERY_STRING']);

Once you have decrypted it, can you pass it along to a $_GET as you would with an unencrypted query string ?
$test = $_GET['test'];

Or, do you need to parse the string to extract variables?

many thanks

g

--- End Message ---
--- Begin Message ---
Graham Anderson wrote:

What is the best way to decrypt a query string  back into  variables ?


$root = "http://www.myserver.com/script.php";;
$queryString = "?test=mytest&color=red";
myEncrypt($queryString);  //add mCrypt encryption
$finalURL = $root.$encryptedQueryString;

what is the proper what to decrypt the GET variables on the other side ?



Do you need to decrypt the query string first ?

yes - if you have a query string like

4509134534068953534875104584437043134081743

or whatever then php won't turn it into a $_GET var.
although your query string could contain &'s and/or ?'s and/or ='s
in which case you might have cruft in the $_GET array which you would
want to clean out before extracting your decrypted string into
$_GET ..

decrypt($_SERVER['QUERY_STRING']);

Once you have decrypted it, can you pass it along to a $_GET as you would with an unencrypted query string ?
$test = $_GET['test'];

Or, do you need to parse the string to extract variables?

yes you do, but this being php - there is a function that will do it for you :-)

http://php.net/parse_str


many thanks

g


--- End Message ---
--- Begin Message ---
thanks :)

that was exactly what I needed

g
On Sep 29, 2005, at 9:33 AM, Jochem Maas wrote:

Graham Anderson wrote:
What is the best way to decrypt a query string  back into  variables ?
$root = "http://www.myserver.com/script.php";;
$queryString = "?test=mytest&color=red";
myEncrypt($queryString);  //add mCrypt encryption
$finalURL = $root.$encryptedQueryString;
what is the proper what to decrypt the GET variables on the other side ?

Do you need to decrypt the query string first ?

yes - if you have a query string like

4509134534068953534875104584437043134081743

or whatever then php won't turn it into a $_GET var.
although your query string could contain &'s and/or ?'s and/or ='s
in which case you might have cruft in the $_GET array which you would
want to clean out before extracting your decrypted string into
$_GET ..

decrypt($_SERVER['QUERY_STRING']);
Once you have decrypted it, can you pass it along to a $_GET as you would with an unencrypted query string ?
$test = $_GET['test'];
Or, do you need to parse the string to extract variables?

yes you do, but this being php - there is a function that will do it for you :-)

http://php.net/parse_str

many thanks
g

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


--- End Message ---
--- Begin Message ---
I have a situation where I have to fix an app interface that was constructed
with hundreds of lines of VBScript. The quickest way for me to do this would
be to replace the offending VBScipt with PHP. Does anyone see any potential
problems with doing this? I did a diagram on paper and see no gotcha's..TIA

--- End Message ---
--- Begin Message ---
Jay Blanchard <mailto:[EMAIL PROTECTED]>
    on Thursday, September 29, 2005 11:03 AM said:

> I have a situation where I have to fix an app interface that was
> constructed with hundreds of lines of VBScript. The quickest way for
> me to do this would be to replace the offending VBScipt with PHP.
> Does anyone see any potential problems with doing this? I did a
> diagram on paper and see no gotcha's..TIA 

You don't mean within the same file do you? If so (though I doubt it)
I'm sure there will be lots of problems! 

On the other hand if you're just having one file (that may be written in
vbs) talk to another file (PHP perhaps) via GET, POST, or COOKIE I don't
see why you would have a problem. Working with the SESSION might be a
problem though.


Chris.

--- End Message ---
--- Begin Message ---
At 03:02 PM 9/29/2005, Jay Blanchard wrote:
I have a situation where I have to fix an app interface that was constructed
with hundreds of lines of VBScript. The quickest way for me to do this would
be to replace the offending VBScipt with PHP. Does anyone see any potential
problems with doing this? I did a diagram on paper and see no gotcha's..TIA

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

Jay,

Your new job is getting real interesting!

Did you try it on a test file? If it works then the parsing in the web server can be overloaded, for lack of a better term.

So whether the extension is .asp or .php, watch for the tags and treat them appropriately, that it?

Wow - Miles
--- End Message ---
--- Begin Message ---
[snip]
Your new job is getting real interesting!

Did you try it on a test file? If it works then the parsing in the web 
server can be overloaded, for lack of a better term.

So whether the extension is .asp or .php, watch for the tags and treat them 
appropriately, that it?
[/snip]

Darn right 'wow'!

I can keep the ASP seperate from the PHP by use of the proper tags for this
instance. So...

<% stuff here gets executed by ASP %>
<?php stuff here gets executed by PHP ?>

Interestingly enough, the following worked ...but I will not use it in
production;

<?php

$sql = "SELECT foo FROM bar where fooID = ' ";

?>

<%
response.write("fooID")
%>

<?php
$sql .= "' ";

echo $sql . "\n"; 
?>

returned

SELECT foo FROM bar where fooID = '4'

Nuts, huh?

--- End Message ---
--- Begin Message ---
A real interesting challenge and when I first read it I thought the same 
thing, instead of using the short form of tags, using a more extended form 
such as
<script language=""> and so on, it should work, but then, Irealized that 
there is a lot going on outside of the code, such as parsing the incoming 
arguments of the POST or GET into either the $_REQUEST array or the 
Request.Form collection and, on the opposite site, the assembly of the 
output buffer.

Even in the CGI version of the PHP interpreter there is no provision I am 
aware of to pipe either the request or the reply to any other interpreter 
down the line, nor do I think the ASP interpreter has a CGI version.    How 
come you were able to do both a Response.Write and an echo and get them both 
streamed into the same browser, I can't figure out.  If you manage to send 
headers from one or the other in any order it would be impressive, and if 
from both, I would appreciate it if you would warn me to sit down tight 
before you ever break the news.  Other 'global' objects or arrays would also 
mess up.  Sessions, cookies, etc,   I can't imagine.

Another issue would be sharing variables, calling functions or passing 
parameters.  I am certain that should be impossible.

A trick it should work, if you find any trouble with this is to do a sort of 
'web service' with PHP which you can call from ASP, so you still leave ASP 
handling the user interface as I assume it does now, and you can request 
from a server running PHP (which might be the very same one) whatever the 
PHP one cannot provide.



"Jay Blanchard" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> [snip]
> Your new job is getting real interesting!
>
> Did you try it on a test file? If it works then the parsing in the web
> server can be overloaded, for lack of a better term.
>
> So whether the extension is .asp or .php, watch for the tags and treat 
> them
> appropriately, that it?
> [/snip]
>
> Darn right 'wow'!
>
> I can keep the ASP seperate from the PHP by use of the proper tags for 
> this
> instance. So...
>
> <% stuff here gets executed by ASP %>
> <?php stuff here gets executed by PHP ?>
>
> Interestingly enough, the following worked ...but I will not use it in
> production;
>
> <?php
>
> $sql = "SELECT foo FROM bar where fooID = ' ";
>
> ?>
>
> <%
> response.write("fooID")
> %>
>
> <?php
> $sql .= "' ";
>
> echo $sql . "\n";
> ?>
>
> returned
>
> SELECT foo FROM bar where fooID = '4'
>
> Nuts, huh? 

--- End Message ---
--- Begin Message ---
I am looking to install a php site search on one of my sites. Looking at 
http://www.site-search-pro.com/

has anyoner used this? what do I need to do to get it working? do the files 
reside on my server?

Any alternatives free or paid let me know..

R. 

--- End Message ---
--- Begin Message ---
Ross wrote:
I am looking to install a php site search on one of my sites. Looking at http://www.site-search-pro.com/

has anyoner used this? what do I need to do to get it working? do the files reside on my server?

Any alternatives free or paid let me know..

I'm partial to mnogoSearch

http://search.mnogo.ru/
http://us3.php.net/mnogosearch

It has to be compiled into your PHP, so if you're on shared hosting, it may not be an option.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Hi,
 
How do I connect a php script running on linux with Active Directory on
a windows machine? I would like to have my php script autmotatically
read email addresses from the AD server. Can this be done? I've found a
bunch of ldap functions for php but they seem to require ldap to be
installed on linux. I'm confused. Thanks in advance for your help.
 
 
Anya

--- End Message ---
--- Begin Message --- I wrote a script for this; it's designed to run from the command line in *nix, but can be triggered via exec():

Usage: ./pdf2thumb.php "source_dir" "out_dir"

[code]

#!/usr/local/bin/php

<?
function getDirFiles($dirPath){
   $filesArr=array("");
   if ($handle = opendir($dirPath)){
       while (false !== ($file = readdir($handle)))
           if ($file != "." && $file != ".."){$filesArr[] = trim($file);}
           closedir($handle);}
   return $filesArr;
}

function usage(){
echo("USAGE: pdf2thumb source_folder_path <destination_folder_path>\n\n");
   exit;
}

if(!isset($argv[1])){usage();}
substr($argv[1],-1)=="/"?$path=$argv[1]:$path=$argv[1]."/";

isset($argv[2])?$dest_path=$argv[2]:$dest_path=$path;
substr($dest_path,-1)=="/"?$dest_path=$dest_path:$dest_path.="/";

$total_time=0;
$total_files=0;

if(!file_exists($dest_path)){`mkdir $dest_path`;}

$files=getDirFiles($path);

for($i=0;$i<count($files);$i++){
   if(substr($files[$i],-3)=="pdf"){
       echo("Converting ".$files[$i]."... ");
       $time_start = microtime(true);

       $old_name=$path.$files[$i];
       $new_name=$dest_path.str_replace(".pdf",".jpg",$files[$i]);

       `/usr/bin/convert '$old_name' -thumbnail 240x160 '$new_name'`;

       $time_end = microtime(true);
       $convert_time=round($time_end-$time_start,2);
       echo("Done. ($convert_time seconds)\n");
       $total_time+=$convert_time;
       $total_files++;
   }
}

echo("\n---------------------------------------------------\n");
echo("$total_files files converted in ".round($total_time/60,2)." $minutes (AVG: ".round($total_time/$total_files,2)."s)\n\n");

?>

[/code]

[EMAIL PROTECTED] wrote:

You would haven't happen to have an example? I am new to imagemagick. Any
help would be greatly appreciated.

On 9/26/05, Jim Moseby <[EMAIL PROTECTED]> wrote:
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, September 26, 2005 1:43 AM
To: php-general@lists.php.net
Subject: [PHP] PDF Thumbnails


I give my users an option to upload pdf files to my site and
would like them
to see a thumbnail view of the file once uploaded. Has anyone
heard of a way
how to do this?
The 'convert' function of ImageMagick will do it.

JM




--- End Message ---

Reply via email to