php-general Digest 9 Jan 2007 16:57:44 -0000 Issue 4560

Topics (messages 246779 through 246791):

Re: Sending file stored on server via email - How?
        246779 by: Matt Arnilo S. Baluyos (Mailing Lists)

Re: Parsing an XML return from a POST
        246780 by: Fahad Pervaiz

Re: Table contents not updated
        246781 by: David Robley

PHP milter SAPI: problem with smfi_getsymval
        246782 by: Atpic

Domain Search
        246783 by: Marcelo Ferrufino Murillo
        246784 by: Stut
        246785 by: Peter Lauri
        246786 by: Colin Guthrie
        246787 by: Jochem Maas
        246788 by: Colin Guthrie

unzip openDocument in safe mode
        246789 by: Bernhard Zwischenbrugger
        246790 by: Jochem Maas
        246791 by: Bernhard Zwischenbrugger

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 1/8/07, Ville Mattila <[EMAIL PROTECTED]> wrote:
Matt Arnilo S. Baluyos (Mailing Lists) kirjoitti:
> What's the easiest way to go about this? Specifically, what's the
> easiest way to read a file from the server and send it as an email
> attachment.

I would suggest you to use http://phpmailer.sourceforge.net/ that is a
featured class for sending e-mails from PHP scripts. It supports file
attachments too. Messages can be sent over sendmail or direct SMTP with
the PHPMailer.

Just tested the phpmailer package and integrated it into our application.

Great stuff. Thanks for pointing me to it.

--
Stand before it and there is no beginning.
Follow it and there is no end.
Stay with the ancient Tao,
Move with the present.

--- End Message ---
--- Begin Message ---
===ORIGINAL===
Hi List

I am working owards completing a rather urgent project for one of our
clients.
There is a requirement to send a request to a server and I now have that
working
using cURL, thanks to help from this list. I now have the responses coming
back
as an XML response. What I need to do is to parse the XML response and break
it
up into either an array or variables so I can pass the returned responses
back
to a calling process.

I have spent most of last night and today looking at XML parsing and now am
totally confused. Some testing I have done suggests that SimpleXML is not
the
way to go however I am open to suggestions if it might be an answer. I would
appreciate any help or advice on how to parse this XML response and break it
up
into either an array or individual variables.

I have included a sample response from the server below. A few points to be
aware of,

1) In the fares section there could be any number of fares however each fare
will have a fareID and then the fareBases child.
2) In the tarifs section there could be any number of tarifs however each
tarif
will have a tarifId and then 1 or more fareXrefs.
3) In the vcrSummary section there could be 1 or more vcr entries
4) The response comes back as one long string and I have formatted this to
make
it a little easier to read.

<?xml version="1.0" encoding="UTF-8"?>
<?ypsilon RNGSchema="fareResponse.rnc" type="compact"?>
<fareResponse cntTarifs="122" offset="0">
<fares>
      <fare fareId="11429927" fareType="PUB" checked="false" class="V"
depApt="SYD" dstApt="LON" paxType="ADT" vcr="OS" cos="E" yyFare="false"
avail="false">
              <fareBases>
                      <fareBase pax="ADT">VLOX2</fareBase>
                      <fareBase pax="CHD">VLOX2</fareBase>
                      <fareBase pax="INF">VLOX2</fareBase>
              </fareBases>
      </fare>
      <fare fareId="11429924" fareType="PUB" checked="false" class="M"
depApt="SYD" dstApt="LON" paxType="ADT" vcr="OS" cos="E" yyFare="false"
avail="false">
              <fareBases>
                      <fareBase pax="ADT">MLOW2</fareBase>
                      <fareBase pax="CHD">MLOW2</fareBase>
                      <fareBase pax="INF">MLOW2</fareBase>
              </fareBases>
      </fare>
</fares>
<tarifs currency="USD">
      <tarif tarifId="11429927" adtBuy="675.07" adtSell="675.07" chdBuy="
675.07" chdSell="675.07" infBuy="675.07" infSell="675.07" topCar="false"
topHotel="false">
              <fareXRefs>
                      <fareXRef>11429927</fareXRef>
              </fareXRefs>
      </tarif>
      <tarif tarifId="11429926" adtBuy="714.83" adtSell="714.83" chdBuy="
714.83" chdSell="714.83" infBuy="714.83" infSell="714.83" topCar="false"
topHotel="false">
              <fareXRefs>
                      <fareXRef>11429926</fareXRef>
              </fareXRefs>
      </tarif>
</tarifs>
<taxes currency="USD">
      <tax vcr="OS">201.52</tax>
</taxes>
<vcrSummary>
      <vcr minPrice="1667" maxPrice="1667" totalTarifs="1"
currency="USD">AA</vcr>
      <vcr minPrice="1374" maxPrice="4704" totalTarifs="2"
currency="USD">PR</vcr>
</vcrSummary>
</fareResponse>


I would certainly appreciate any help I can get. Thanks in advance.
===END ORIGINAL===

You can easily parse XML using "XML Parser Functions" or "DOM Functions"
available in PHP

Lots of classes have been written to parse xml using the above
libraries.Youcan easily search them on google.

--
Regards
Fahad Pervaiz
www.ecommerce-xperts.com
(Shopping Cart, Web Design, SEO, VoIP)

--- End Message ---
--- Begin Message ---
Wikus Moller wrote:

> Hi.
> 
> I am new to uising html forms with php and I am having a problem with
> database contents not being updated although it seems my coding is
> correct.
> 
> It's a xhtml formatted site with html forms:
> 
> Here are my functions:

<SNIP> lots of code

Judicious use of mysql_error() after calls to mysql_query() in conjunction
with echo-ing the actual query should help you pinpoint the problem area.
You might also look at mysql_affected_rows().


Cheers
-- 
David Robley

"Parsley, sage, rosemary," said Tom timelessly.
Today is Prickle-Prickle, the 9th day of Chaos in the YOLD 3173. 

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

I compiled the  milter sapi, the example in the distribution works well.
BUT when I try to get the values of the sendmail macros with the
smfi_getsymval function, i desperately get a blank string.
I used strace and I do see the "i" sendmail macro in a red system call but
I can no red its value in the PHP milter.
Any ideas?
Is this worth logging a bug?

Thanks

-------
HERE is the code I used. It is just the distribution example with the
milter_envfrom function modified by including two function calls:

        milter_log(smfi_getsymval("i"));
        milter_log(smfi_getsymval("{i}"));

Example was retrieved from CVS:

http://cvs.php.net/viewvc.cgi/php-src/sapi/milter/milter.php?revision=1.2&view=markup

<?php
/**
 * example milter script
 *
 * run: php-milter -D -p /path/to/sock milter.php
 *
 * for details on how to set up sendmail and configure the milter see
 * http://www.sendmail.com/partner/resources/development/milter_api/
 *
 * for api details see
 * http://www.sendmail.com/partner/resources/development/milter_api/api.html
 *
 * below is a list of all callbacks, that are available through the milter
sapi,
 * if you leave one or more out they simply won't get called (e.g. if you
secify an
 * empty php file, the milter would do nothing :)
 */

/**
 * this function is called once on sapi startup,
 * here you can specify the actions the filter may take
 *
 * see
http://www.sendmail.com/partner/resources/development/milter_api/smfi_register.html#flags
 */

function milter_log($msg)
{
        $GLOBALS['log'] = fopen("/tmp/milter.log", "a");
        fwrite($GLOBALS['log'], date("[H:i:s d.m.Y]") . "\t{$msg}\n");
        fclose($GLOBALS['log']);
}

function milter_init() {
        milter_log("-- startup --");
        milter_log("milter_init()");
        smfi_setflags(SMFIF_ADDHDRS);
}

/**
 * is called once, at the start of each SMTP connection
 */
function milter_connect($connect)
{
        milter_log("milter_connect('$connect')");
}

/**
 * is called whenever the client sends a HELO/EHLO command.
 * It may therefore be called between zero and three times.
 */
function milter_helo($helo)
{
        milter_log("milter_helo('$helo')");
}

/**
 * is called once at the beginning of each message,
 * before milter_envrcpt.
 */
function milter_envfrom($args)
{
        milter_log("milter_envfrom(args[])");
        foreach ($args as $ix => $arg) {
                milter_log("\targs[$ix] = $arg");
        }
        milter_log(smfi_getsymval("i"));
        milter_log(smfi_getsymval("{i}"));
}

/**
 * is called once per recipient, hence one or more times per message,
 * immediately after milter_envfrom
 */
function milter_envrcpt($args)
{
        milter_log("milter_envrcpt(args[])");
        foreach ($args as $ix => $arg) {
                milter_log("\targs[$ix] = $arg");
        }
}

/**
 * is called zero or more times between milter_envrcpt and milter_eoh,
 * once per message header
 */
function milter_header($header, $value)
{
        milter_log("milter_header('$header', '$value')");
}

/**
 * is called once after all headers have been sent and processed.
 */
function milter_eoh()
{
        milter_log("milter_eoh()");
}

/**
 * is called zero or more times between milter_eoh and milter_eom.
 */
function milter_body($bodypart)
{
        milter_log("milter_body('$bodypart')");
}

/**
 * is called once after all calls to milter_body for a given message.
 * most of the api functions, that alter the message can only be called
 * within this callback.
 */
function milter_eom()
{
        milter_log("milter_eom()");
  /* add PHP header to the message */
  smfi_addheader("X-PHP", phpversion());
}

/**
 * may be called at any time during message processing
 * (i.e. between some message-oriented routine and milter_eom).
 */
function milter_abort()
{
        milter_log("milter_abort()");
}

/**
 * is always called once at the end of each connection.
 */
function milter_close()
{
        milter_log("milter_close()");
}
?>

Alex Madon http://atpic.com Webmaster

--- End Message ---
--- Begin Message ---
I have to make a domain search so I don´t know if there is an API or
something that could help me in this o if you know how I could make this.
Thank you.

--- End Message ---
--- Begin Message ---
Marcelo Ferrufino Murillo wrote:
I have to make a domain search so I don´t know if there is an API or
something that could help me in this o if you know how I could make this.

What do you mean by a domain search?

-Stut

--- End Message ---
--- Begin Message ---
Most domain wholesale sites have it. www.onlinenic.com has it, I am sure
that godaddy.com has it as well. Joker.com has it.

Best regards,
Peter Lauri

www.dwsasia.com  - company web site
www.lauri.se  - personal web site
www.carbonfree.org.uk  - become Carbon Free

-----Original Message-----
From: Marcelo Ferrufino Murillo [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 09, 2007 4:23 PM
To: php-general@lists.php.net
Subject: [PHP] Domain Search

I have to make a domain search so I don´t know if there is an API or
something that could help me in this o if you know how I could make this.
Thank you.

--- End Message ---
--- Begin Message ---
Marcelo Ferrufino Murillo wrote:
> I have to make a domain search so I don´t know if there is an API or
> something that could help me in this o if you know how I could make this.

Should just be a matter of spewing out the results of the command "whois
 mydomain.com".

There may be a specific PHP module for it but otherwise I'd just do
something like:

passthru('whois '.shell_escape_cmd($_GET['domain']));

Perhaps with extra sanity and correctly named functions if I've got them
wrong :p

Col.

--- End Message ---
--- Begin Message ---
Colin Guthrie wrote:
> Marcelo Ferrufino Murillo wrote:
>> I have to make a domain search so I don´t know if there is an API or
>> something that could help me in this o if you know how I could make this.
> 
> Should just be a matter of spewing out the results of the command "whois
>  mydomain.com".
> 
> There may be a specific PHP module for it but otherwise I'd just do
> something like:
> 
> passthru('whois '.shell_escape_cmd($_GET['domain']));

without getting into the specifics of what the OP might be looking for,
I'd like to add that I think the above should (?) use escapeshellarg() rather
than escapeshellcmd() although escapeshellcmd() will, AFAICT from the docs,
also keep you safe in the current example.

> 
> Perhaps with extra sanity and correctly named functions if I've got them
> wrong :p
> 
> Col.
> 

--- End Message ---
--- Begin Message ---
Jochem Maas wrote:
> without getting into the specifics of what the OP might be looking for,
> I'd like to add that I think the above should (?) use escapeshellarg() rather
> than escapeshellcmd() although escapeshellcmd() will, AFAICT from the docs,
> also keep you safe in the current example.

Indeedy, I was lasy and didn't look up the docs, hense my disclaimer:
>> Perhaps with extra sanity and correctly named functions if I've got them
>> wrong :p

:D

Col.

--- End Message ---
--- Begin Message ---
I try to unzip openDocument files with pclzip.
At my laptop this is no big problem, but the target server has "safe
mode" switched on (no way to change that).

The problem with safe mode and unzipping openDocument ist, that a
openDocument zip file contains directories. It is not possible to write
to directory owned by webserver uid (because of safe mode)

My Project:
I try to extract the "content.xml" from openDocument, change it and
store it back to the openDocument (zip) file.

Question:
Is it possible to extract a single file from a zip file?
Is it possible to replace a single file in a zip file?

I need something  like:

$contentString=extractFromZip("xy.zip","content.xml")
... $contentString will be changed ...
replaceFileInZip("xy.zip","content.xml",$contentString);


thanks

Bernhard

--- End Message ---
--- Begin Message ---
Bernhard Zwischenbrugger wrote:
> I try to unzip openDocument files with pclzip.
> At my laptop this is no big problem, but the target server has "safe
> mode" switched on (no way to change that).
> 
> The problem with safe mode and unzipping openDocument ist, that a
> openDocument zip file contains directories. It is not possible to write
> to directory owned by webserver uid (because of safe mode)

are there no world writable directories available anywhere for you to use?

> 
> My Project:
> I try to extract the "content.xml" from openDocument, change it and
> store it back to the openDocument (zip) file.
> 
> Question:
> Is it possible to extract a single file from a zip file?
> Is it possible to replace a single file in a zip file?

it kind of depends on your particular setup (server version, access to
PECL, etc):

there is this (will require some reading to determine if you can
use it in your case):

        http://php.net/zip

and then there is the possibility of using exec() in conjunction with
the cmdline zip utility, e.g.:

        $args = escapeshellarg($theRequiredArgsToZipCmd);
        exec("zip -options $args");

here is a webpage version of the zip man page (in case you dont
have shell access):

        http://www.die.net/doc/linux/man/man1/zip.1.html

other than that all I can thing of is this (it might turn up something usable):

        http://www.google.com/search?q=php+zip+file+class

> 
> I need something  like:
> 
> $contentString=extractFromZip("xy.zip","content.xml")
> ... $contentString will be changed ...
> replaceFileInZip("xy.zip","content.xml",$contentString);
> 
> 
> thanks
> 
> Bernhard
> 

--- End Message ---
--- Begin Message ---
Am Dienstag, den 09.01.2007, 17:21 +0100 schrieb Jochem Maas:
> Bernhard Zwischenbrugger wrote:
> > I try to unzip openDocument files with pclzip.
> > At my laptop this is no big problem, but the target server has "safe
> > mode" switched on (no way to change that).
> > 
> > The problem with safe mode and unzipping openDocument ist, that a
> > openDocument zip file contains directories. It is not possible to write
> > to directory owned by webserver uid (because of safe mode)
> 
> are there no world writable directories available anywhere for you to use?

openDocuement looks like:
|-- Configurations2
|   `-- accelerator
|       `-- current.xml
|-- META-INF
|   `-- manifest.xml
|-- Thumbnails
|   `-- thumbnail.png
|-- content.xml
|-- meta.xml
|-- mimetype
|-- settings.xml
`-- styles.xml

The directories "Configurations2", "META-INF", "Thumnails" are created
and it is not possible for pclzip in safe mode to write to these
directories.


> 
> > 
> > My Project:
> > I try to extract the "content.xml" from openDocument, change it and
> > store it back to the openDocument (zip) file.
> > 
> > Question:
> > Is it possible to extract a single file from a zip file?
> > Is it possible to replace a single file in a zip file?
> 
> it kind of depends on your particular setup (server version, access to
> PECL, etc):
> 
> there is this (will require some reading to determine if you can
> use it in your case):
> 
>       http://php.net/zip

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


> 
> and then there is the possibility of using exec() in conjunction with
> the cmdline zip utility, e.g.:
> 
>       $args = escapeshellarg($theRequiredArgsToZipCmd);
>       exec("zip -options $args");

Possibility, but not optimum.

> other than that all I can thing of is this (it might turn up something 
> usable):
> 
>       http://www.google.com/search?q=php+zip+file+class
> 
The only thing I found is pclzip and that makes problems

Bernhard
 

--- End Message ---

Reply via email to