php-general Digest 28 Sep 2011 21:15:43 -0000 Issue 7496

Topics (messages 315038 through 315048):

Curl cost
        315038 by: muad shibani
        315041 by: Jonesy
        315043 by: Jim Lucas
        315044 by: Daniel Brown
        315046 by: Jim Lucas
        315047 by: Daniel Brown
        315048 by: tamouse mailing lists

Re: Sequential access of XML nodes.
        315039 by: Richard Quadling

php5-fpm segfault
        315040 by: áÌÅËÓÁÎÄÒ çÏÎÞÁÒÏ×

Re: using passthru or system() even and passing the $_FILES array
        315042 by: Jim Lucas

Attached without Attachment
        315045 by: Gustavo - Emar Plásticos

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
what are the costs of using PHP Curl to show another websites on my site as
stumbleon do ..
traffic, memory or what?

--- End Message ---
--- Begin Message ---
On Wed, 28 Sep 2011 01:28:19 -0700, muad shibani wrote:

> what are the costs of using PHP Curl to show another websites on my 
> site as stumbleon do ..  traffic, memory or what?

One cost might be legal expenses and penalties for copyright 
infringement.


--- End Message ---
--- Begin Message ---
On 9/28/2011 1:28 AM, muad shibani wrote:
> what are the costs of using PHP Curl to show another websites on my site as
> stumbleon do ..
> traffic, memory or what?
> 

That isn't how stumbleupon does it.  You might want to take a closer look at the
HTML to see how they do what they do.

--- End Message ---
--- Begin Message ---
On Wed, Sep 28, 2011 at 11:54, Jim Lucas <li...@cmsws.com> wrote:
>
> That isn't how stumbleupon does it.  You might want to take a closer look at 
> the
> HTML to see how they do what they do.

    He said stumbleON, actually.  Looks like they simply aggregate
some of your personal social networking data into a single-sign-on
dashboard presentation.  Certainly no service I'd use, but I suppose
for some it has its merits.

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

--- End Message ---
--- Begin Message ---
On 9/28/2011 9:05 AM, Daniel Brown wrote:
> On Wed, Sep 28, 2011 at 11:54, Jim Lucas <li...@cmsws.com> wrote:
>>
>> That isn't how stumbleupon does it.  You might want to take a closer look at 
>> the
>> HTML to see how they do what they do.
> 
>     He said stumbleON, actually.  Looks like they simply aggregate
> some of your personal social networking data into a single-sign-on
> dashboard presentation.  Certainly no service I'd use, but I suppose
> for some it has its merits.
> 

I saw that, but @ss-umed it was a typo.  My bad.

--- End Message ---
--- Begin Message ---
On Wed, Sep 28, 2011 at 14:13, Jim Lucas <li...@cmsws.com> wrote:
>
> I saw that, but @ss-umed it was a typo.  My bad.

    I'd presumed the same at first.  You're in good company still.

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

--- End Message ---
--- Begin Message ---
Forgot to include list...
---------- Forwarded message ----------
From: tamouse mailing lists <tamouse.li...@gmail.com>
Date: Wed, Sep 28, 2011 at 4:06 PM
Subject: Re: [PHP] Curl cost
To: muad shibani <muad.shib...@gmail.com>


On Wed, Sep 28, 2011 at 3:28 AM, muad shibani <muad.shib...@gmail.com> wrote:
> what are the costs of using PHP Curl to show another websites on my site as
> stumbleon do ..
> traffic, memory or what?

If you use curl to suck the web page into a variable, could be
tremendous. Better to curl it into a temporary file if you're going
that way.

--- End Message ---
--- Begin Message ---
On 27 September 2011 03:38, Ross McKay <ro...@zeta.org.au> wrote:
> On Mon, 26 Sep 2011 14:17:43 -0400, Adam Richardson wrote:
>
>>I believe the XMLReader allows you to pull node by node, and it's really
>>easy to work with:
>>http://www.php.net/manual/en/intro.xmlreader.php
>>
>>In terms of dealing with various forms of compression, I believe you con use
>>the compression streams to handle this:
>>http://stackoverflow.com/questions/1190906/php-open-gzipped-xml
>>http://us3.php.net/manual/en/wrappers.compression.php
>
> +1 here. XMLReader is easy and fast, and will do the job you want albeit
> without the nice foreach(...) loop Richard spec's. You just loop over
> reading the XML and checking the node type, watching the state of your
> stream to see how to handle each iteration.
>
> e.g. (assuming $xml is an open XMLReader, $db is PDO in example)
>
> $text = '';
> $haveRecord = FALSE;
> $records = 0;
>
> // prepare insert statement
> $sql = '
> insert into Product (ID, Product, ...)
> values (:ID, :Product, ...)
> ';
> $cmd = $db->prepare($sql);
>
> // set list of allowable fields and their parameter type
> $fields = array(
>    'ID' => PDO::PARAM_INT,
>    'Product' => PDO::PARAM_STR,
>    ...
> );
>
> while ($xml->read()) {
>    switch ($xml->nodeType) {
>        case XMLReader::ELEMENT:
>            if ($xml->name === 'Product') {
>                // start of Product element,
>                // reset command parameters to empty
>                foreach ($fields as $name => $type) {
>                    $cmd->bindValue(":$name", NULL, PDO::PARAM_NULL);
>                }
>                $haveRecord = TRUE;
>            }
>            $text = '';
>            break;
>
>        case XMLReader::END_ELEMENT:
>            if ($xml->name === 'Product') {
>                // end of Product element, save record
>                if ($haveRecord) {
>                    $result = $cmd->execute();
>                    $records++;
>                }
>                $haveRecord = FALSE;
>            }
>            elseif ($haveRecord) {
>                // still inside a Product element,
>                // record field value and move on
>                $name = $xml->name;
>                if (array_key_exists($name, $fields)) {
>                    $cmd->bindValue(":$name", $text, $fields[$name]);
>                }
>            }
>            $text = '';
>            break;
>
>        case XMLReader::TEXT:
>        case XMLReader::CDATA:
>            // record value (or part value) of text or cdata node
>            $text .= $xml->value;
>            break;
>
>        default:
>            break;
>    }
> }
>
> return $records;

Thanks for all of that.

It seems that the SimpleXMLIterator is perfect for me.

I need to see if the documents I'm needing to process have multiple
namespaces. If they have do, then I'm not exactly sure what to do at
this stage.

Richard.
-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

--- End Message ---
--- Begin Message ---
Hello. I'm getting problem.

OS: Ububtu Server 2.6.38-8-server
PHP: PHP 5.3.5-1ubuntu7.2 with Suhosin-Patch
Work over fastcgi (fpm) with cherokee web server.

PHP fall often with such messages in syslog:
Sep 28 11:01:25 userver kernel: [278665.292418] php5-fpm[31892]:
segfault at 80001000321 ip 000000000069f427 sp 00007fffddf571b0 error
4 in php5-fpm[400000+755000]

I took core dump and gdb it:

root@userver:~# gdb /usr/sbin/php5-fpm /tmp/core-php5-fpm.8289
... gnu gpl banner omitted...
Reading symbols from /usr/sbin/php5-fpm...Reading symbols from
/usr/lib/debug/usr/sbin/php5-fpm...done.
done.
[New Thread 8289]

warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/x86_64-linux-gnu/libcrypt.so.1...(no
debugging symbols found)...done.
... a lot of loading symbols messages omitted ...

Core was generated by `php-fpm: pool www                                      '.
Program terminated with signal 11, Segmentation fault.
#0  zend_hash_destroy (ht=0x80001000301) at
/build/buildd/php5-5.3.5/Zend/zend_hash.c:723
723             HASH_PROTECT_RECURSION(ht);
(gdb) bt
#0  zend_hash_destroy (ht=0x80001000301) at
/build/buildd/php5-5.3.5/Zend/zend_hash.c:723
#1  0x00000000007293c1 in fcgi_close (req=0x7fff6a7783e0, force=0, destroy=1)
    at /build/buildd/php5-5.3.5/sapi/fpm/fpm/fastcgi.c:675
#2  0x0000000000729d3d in fcgi_finish_request (req=0x7fff6a7783e0,
force_close=0)
    at /build/buildd/php5-5.3.5/sapi/fpm/fpm/fastcgi.c:1000
#3  0x000000000072f036 in sapi_cgi_deactivate () at
/build/buildd/php5-5.3.5/sapi/fpm/fpm/fpm_main.c:886
#4  0x00000000006477ed in sapi_deactivate () at
/build/buildd/php5-5.3.5/main/SAPI.c:444
#5  0x000000000063efe5 in php_request_shutdown (dummy=0x80001000301)
at /build/buildd/php5-5.3.5/main/main.c:1658
#6  0x0000000000730642 in main (argc=46077184, argv=0xdddb60) at
/build/buildd/php5-5.3.5/sapi/fpm/fpm/fpm_main.c:1902
(gdb) print ht
$1 = (HashTable *) 0x80001000301
(gdb) print *ht
Cannot access memory at address 0x80001000301

Please, tell what the problem is? How to find out which script causing
this problem? Or this is not scripting problem?
Yes, this is not latest php version and there are some problems with update.

--- End Message ---
--- Begin Message ---
On 9/28/2011 12:07 AM, Anton Heuschen wrote:
> Good day,
> 
> I have a question and something that either does not work, or I have not
> gotten it to work the way I want to.
> 
> I have a start page, which is a form, that takes 2 text fields and also a
> Attachment field. Then it calls the first page, which is supposed to spawn
> of a call to another page (I want to get the page to open server side see,
> to allow the user to close the window, and the process continues in the
> background) ...so I use either passthru or have now tried system().
> 
> The problem is that I can pass my 2 text fields as arguments to the call but
> I have a problem in accessing and using $_FILES now to handle the file
> defined.
> 
> I have tried to pass it to a $_SESSION["FILES"] , I have even tried to
> serialize the whole array and pass it also as argument and build a array on
> called php page, etc, but it does not seem to do anything, or handle the
> file?
> 
> 
> As further example, this is on the first page opened from the Form :
> 
> ========= php file 1 calling to file 2 =================
> 
> session_start();
> $_SESSION["FILES"] = $_FILES;
> session_write_close();
> 
> $email          =   $_REQUEST['email'];
> $actionDate     =   $_REQUEST['actiondate'];
> $files          =   serialize($_FILES);
> $command = '/usr/bin/php -f /var/www/details/Write.php '.$email.'
> '.$actionDate.' '.$files.' >> php.log';
> system($command,$return);

At this point I would suggest that you echo $command before trying to execute 
it.

I think you might find that you are trying to pass characters that the cli are
miss interpreting.


> 
> 
> 
> =============================================
> 
> then in my called file
> 
> 
> ================ Write.php =====================
> 
> session_start();
> $FILES = $_SESSION['FILES'];
> 
> $files1         = $FILES["coms1_attachfile"];
> $filename1     = $files1;
> 
> ==============================================

First, since you are calling this from the cli, their is no point in using
session_start().  session_start() has to do with running it in a web server not
from the cli.

Secondly, in file 1 you are using serialize() to package the $_FILES array.  Yet
in file 2 you are not using unserialize() to extract the data from the package.

I would suggest reading here http://php.net/manual/en/features.commandline.php
to get a better understanding of how to access the arguments that you are
passing on the cli.


> 
> $filename1 should now be recognized file name from a file provided in the
> first form, and if statement then runs the file to process to read the file,
> it seems here the process either does not get any file (so filename is never
> true) or the file process have no file to work with.

I'm curious as to what your initial HTML form looks like.

> 
> 
> So I am not really sure how passthru/system works with things like arrays
> and sessions and $_FILES array etc
> 

arrays, not via the cli argument list
serialized arrays, sure, but you have to escape any special chars that might
mess things up.
sessions, does not exist
$_FILES, no direct access

Jim

--- End Message ---
--- Begin Message ---
Hi all, i made a code in PHP to save in a directory the XML attachments !
All goes well until it comes across an email that has attachment but can not save !

analyzing the source code of this email, i realized it has no line:

Content-Disposition: attachment; filename="name of the file.xml"

but only this line:

Content-Type: application/octet-stream; name=name of file.xml
Content-Transfer-Encoding: base64

I´m using IMAP and the account is from Google: $host = "{imap.gmail.com:993/imap/ssl}INBOX";

What happend ?
Thanks any help

Gustave

--- End Message ---

Reply via email to