[PHP] Is there any way to get all the function name being called in a process?

2009-10-22 Thread Satya Narayan Singh
Hi,

I am working on reverse engineering for a web project. I was trying to know
that, is there any way(function by PHP, Zend, extension etc)
to find out how many function has been called to perform a task.

If no, can you suggest is it possible/feasible or not?


Thanks in advance
-- 
Satya
Bangalore.


Re: [PHP] php mail() function

2009-10-22 Thread kranthi
i faced the same problem quite a few times.

the general email route is
php script -> sender smtp server -> receiving mail server
in your case path 2 is broken. meaning port 25 is blocked by your ISP

the work around is:
1. see if your ISP provides you with an SMTP account that is not blocked (OR)
2. try using a socks

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



Re: [PHP] php mail() function

2009-10-22 Thread Paul M Foster
On Thu, Oct 22, 2009 at 11:40:34PM -0500, Shawn McKenzie wrote:



> This is fairly accurate in premise but just to clarify.  Mailservers
> don't operate like this by default and there is really no "trust".
> There are public blacklists that a mailserver can be configured to use
> that tell the mailserver not to accept mail from servers on the
> blacklist.  The blacklists may contain servers that allow anyone to
> relay email, compromised servers, servers known for spam, ip ranges
> known to be held by spammers and *ranges that ISPs designate as dynamic
> or used for subscribers (DSL, cable, dial-up customers, etc. because
> they shouldn't be relaying email).

Regarding the rejection of dynamic IPs by smarthosts, are you saying
that it's a "blacklist" of sorts that lets them know an IP is dynamic?
(Serious question. I don't know the mechanism by which they determine
what is and isn't a dynamic IP.)

Paul

-- 
Paul M. Foster

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



Re: [PHP] php mail() function

2009-10-22 Thread Shawn McKenzie
Paul M Foster wrote:
> On Thu, Oct 22, 2009 at 06:24:14PM -0700, James Prentice wrote:
> 
> One other note. People look at me like I'm crazy when I mention this,
> but I've seen it quite a bit at various internet mail servers.
> Sometimes, in order to accept email from you, the internet mail server
> must see you *receive* mail within a certain time period prior. That is,
> you have to go fetch your mail at the ISP, which opens a "window" into
> the SMTP server for a limited time. Then you can tender mail to the
> internet mail server. I don't know that your internet mail server
> operates this way, but it's something to consider. I've had to deal with
> this before myself.

This is commonly known as POP lock and is one of the two main ways that
a mail server allows you to relay a message.  If you have authenticated
via POP3 (i.e. checked your mail) in a certain period of time then the
SMTP server will let you send.  The other main one is by authentication
(username/password) with the SMTP server when you attempt to send mail.

> In any case, linuxmanmikec's comment about the internet mail server not
> trusting you on a dynamic IP is spot on. The web of email trust is such
> that internet mail servers only trust other internet mail servers. And
> *your* internet mail server will trust *you*. So to get mail to that
> other internet mail server over there, you'll have to give it to *your*
> internet mail server, which is the only one that internet mail server
> over there will trust. The "bounce" message you got indicates that
> relaying from you is forbidden at the destination mail server.
> 

This is fairly accurate in premise but just to clarify.  Mailservers
don't operate like this by default and there is really no "trust".
There are public blacklists that a mailserver can be configured to use
that tell the mailserver not to accept mail from servers on the
blacklist.  The blacklists may contain servers that allow anyone to
relay email, compromised servers, servers known for spam, ip ranges
known to be held by spammers and *ranges that ISPs designate as dynamic
or used for subscribers (DSL, cable, dial-up customers, etc. because
they shouldn't be relaying email).

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] php mail() function

2009-10-22 Thread Paul M Foster
On Thu, Oct 22, 2009 at 06:24:14PM -0700, James Prentice wrote:

> How would I determine my ISP's SMPT server ID? And do I need to edit
> main.cf in order to use that server?

What ID? There's no ID needed. You just configure postfix to relay any
non-local mail sent to it to the SMTP server at your ISP. Check the
headers in incoming mail sent to you for the name of that server. It's
likely the same for both incoming and outgoing mail. Something like
mail.myisp.com.

One other note. People look at me like I'm crazy when I mention this,
but I've seen it quite a bit at various internet mail servers.
Sometimes, in order to accept email from you, the internet mail server
must see you *receive* mail within a certain time period prior. That is,
you have to go fetch your mail at the ISP, which opens a "window" into
the SMTP server for a limited time. Then you can tender mail to the
internet mail server. I don't know that your internet mail server
operates this way, but it's something to consider. I've had to deal with
this before myself.

Configuring local SMTP servers, like postfix. Check and see if Ubuntu
has some sort of setup utility for this. Or try

dpkg-reconfigure postfix

Setting up mail servers is tedious and error prone, unless you've done
it a lot. Read The Fine Manual on postfix.

> 
> Also, is there a way to test the script just sending an email locally?
> I tried sending the email to use...@localhost, but the email was still
> not received.
> 

It will work, assuming three things:

1. You have an actual user set up on the system to receive mail. That
is, an actual user on the system, with an entry in the passwd file and a
home directory, etc.

2. Postfix is configured to deliver truly local mail to local addresses.
More postfix configuration fun.

3. Postfix is actually running and properly configured. If not
configured properly, it may refuse to run.

In any case, linuxmanmikec's comment about the internet mail server not
trusting you on a dynamic IP is spot on. The web of email trust is such
that internet mail servers only trust other internet mail servers. And
*your* internet mail server will trust *you*. So to get mail to that
other internet mail server over there, you'll have to give it to *your*
internet mail server, which is the only one that internet mail server
over there will trust. The "bounce" message you got indicates that
relaying from you is forbidden at the destination mail server.

Paul

-- 
Paul M. Foster

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



[PHP] input form save and display conflict

2009-10-22 Thread PJ
I have several input fields to update a book database. There seems to be
a conflict in the way tags and text are input through php/mysql and
phpMyAdmin. If I enter the data with phpMyAdmin the input fields in the
php page see quotation marks differently than what is input in phpMyAdmin.
example:
if the data is input through the update form, single quotes cause an
error. Double quotes update the db but when the edit(update) form
displays the text for modification outside the input field except for
the first part, precisely where the first quotation mark appears in the
text - as below:

*Reviewed by mailto:recipi...@somewhere.com";>Recipient:
blah, blah, blah...religion." _size="50" />_
The text in square brackets is displayed outside the input field and
includes part of the code at the end.
bold is within the field, the rest is outside and the underlined is part
of code.

If the same text is entered with phpMyAdmin using single quotes and the
" characters, the display in the editing field shows correctly...
but it will not update, that is, the update query generates errors and
only accepts the double quotes within the tags.

So, the question is, are there some kind of metacharacters to be used to
have mysql accept the " ? I have triee backslashing, forward slashing
and they don't do it.

Or is there an encoding conflict here? It looks like a display and save
mismatch somewhere...

below is another example:


The single quotes for the href seem to work. But the " does not work;
and using " or ’  also also do not display correctly; again,
from "Order... the image is not displayed but only the image blank with
"Order.. " in it.
I'm rather puzzled.








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



Re: [PHP] php mail() function

2009-10-22 Thread James Prentice
How would I determine my ISP's SMPT server ID? And do I need to edit
main.cf in order to use that server?

Also, is there a way to test the script just sending an email locally?
I tried sending the email to use...@localhost, but the email was still
not received.



On Thu, Oct 22, 2009 at 4:15 PM, LinuxManMikeC  wrote:
> The problem is you won't be trusted to deliver mail directly to most
> mail servers unless you have a static IP.  Even then thats no
> guarantee.  What you have to do is relay through your ISP's SMTP
> server where you're "trusted".  You should also be able to setup PHP
> to use your ISP's SMTP server and never touch the SMTP service on your
> local machine (if you don't feel like playing with Postfix).
>
> On Thu, Oct 22, 2009 at 3:56 PM, James Prentice  
> wrote:
>> I'm trying to use the php mail() function to send a mail within a php
>> script. This is using PHP 5.2.4 and Ubuntu Hardy Heron linux. The
>> script runs fine and the return value of the mail function is TRUE,
>> but the mail is never received. I'm trying to send an email to my
>> gmail account via the local server on my machine, just to test if this
>> script works.
>>
>> I installed postfix because I read in several places that people have
>> had good luck with that mail program. From what I can tell, postfix is
>> working. I can do:
>>
>> telnet localhost 25
>> Trying 127.0.0.1...
>> Connected to localhost.
>> Escape character is '^]'.
>> 220 homemade ESMTP Postfix (Ubuntu)
>> ehlo localhost
>> 250-homemade
>> 250-PIPELINING
>> 250-SIZE 1024
>> 250-VRFY
>> 250-ETRN
>> 250-STARTTLS
>> 250-ENHANCEDSTATUSCODES
>> 250-8BITMIME
>> 250 DSN
>>
>> After the php script runs, I type 'mailq' and get the result 'mail
>> queue is empty.' If I check /var/log/mail.log, this is what I see:
>>
>> Oct 21 23:54:35 homemade postfix/pickup[5735]: 2A31EA70109: uid=33
>> from=
>> Oct 21 23:54:35 homemade postfix/cleanup[7997]: 2A31EA70109:
>> message-id=<20091022065435.2a31ea70...@homemade>
>> Oct 21 23:54:35 homemade postfix/qmgr[5736]: 2A31EA70109:
>> from=, size=499, nrcpt=1 (queue active)
>> Oct 21 23:54:35 homemade postfix/error[7999]: 2A31EA70109:
>> to=, relay=none, delay=0.04, delays=0.03/0/0/0.01,
>> dsn=5.0.0, status=bounced (gmail.com)
>> Oct 21 23:54:35 homemade postfix/cleanup[7997]: 3217DA7010A:
>> message-id=<20091022065435.3217da70...@homemade>
>> Oct 21 23:54:35 homemade postfix/qmgr[5736]: 3217DA7010A: from=<>,
>> size=2095, nrcpt=1 (queue active)
>> Oct 21 23:54:35 homemade postfix/bounce[8000]: 2A31EA70109: sender
>> non-delivery notification: 3217DA7010A
>> Oct 21 23:54:35 homemade postfix/qmgr[5736]: 2A31EA70109: removed
>> Oct 21 23:54:35 homemade postfix/local[8001]: 3217DA7010A:
>> to=, relay=local, delay=0.03, delays=0/0.02/0/0.01,
>> dsn=2.0.0, status=sent (delivered to command: procmail -a
>> "$EXTENSION")
>> Oct 21 23:54:35 homemade postfix/qmgr[5736]: 3217DA7010A: removed
>>
>> Any ideas? I am new both to php and postfix. Thanks for any help.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>

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



Re: [PHP] Spam opinions please

2009-10-22 Thread Ashley Sheridan
On Thu, 2009-10-22 at 19:39 -0400, Gary wrote:

> I have always thought that by putting some simple, readable ttext into a 
> graphic (eg.apple) and asking people to type it in a space, that would work, 
> but that does not stop the humans..
> 
> Gary
> 
> 
> "Philip Thompson"  wrote in message 
> news:9bf33458-4a91-4a23-bcb8-ebe13269f...@gmail.com...
> > On Oct 20, 2009, at 1:48 PM, Gary wrote:
> >
> >> NO I have not, I think my issue is I hate when I run across one, it 
> >> usually
> >> takes me more than one try to actually figure out what the charactor  is, 
> >> so
> >> hence my disdain.
> >>
> >>
> >> GAry
> >
> > Here are some captchas:
> >
> > "What's three minus two?"
> > "Which word is listed first in the dictionary: apple, banana, pizza?"
> > "Add 4 plus 5"
> >
> > Create a list of simple questions that only humans can answer. I find 
> > these to be less annoying.
> >
> > ~Philip
> >
> >
> >> "Paul M Foster"  wrote in message
> >> news:20091020184001.gi3...@quillandmouse.com...
> >>> On Tue, Oct 20, 2009 at 02:31:53PM -0400, Gary wrote:
> >>>
> >>>> I have several sites that are getting hit with form spam.  I have  the
> >>>> script
> >>>> set up to capture the IP address so I know from where they come.   I 
> >>>> found
> >>>> a
> >>>> short script that is supposed to stop these IP addresses from 
> >>>> accessing
> >>>> the
> >>>> form page, it redirects the spammer to another page (I was going to
> >>>> redirect
> >>>> to a page that has lots of pop-ups, scantily clad men and offers  of 
> >>>> joy
> >>>> beyond imagination), but someone suggested I redirect to the Federal
> >>>> Trade
> >>>> Commission or perhpas the FBI.
> >>>>
> >>>> Any thoughts on the script and its effectivness?
> >>>>
> >>>>  >>>> $deny = array("111.111.111", "222.222.222", "333.333.333");
> >>>> if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) {
> >>>>   header("location: http://www.google.com/";);
> >>>>   exit();
> >>>> } ?>Gary
> >>>>
> >>>
> >>> Have you tried CAPTCHA?
> >>>
> >>> Paul
> >
> > __ Information from ESET Smart Security, version of virus 
> > signature database 4534 (20091022) __
> >
> > The message was checked by ESET Smart Security.
> >
> > http://www.eset.com
> >
> >
> > 
> 
> 
> 
> __ Information from ESET Smart Security, version of virus signature 
> database 4534 (20091022) __
> 
> The message was checked by ESET Smart Security.
> 
> http://www.eset.com
> 
> 
> 
> 
> 


Won't stop a bot worth it's salt either, hence the need for more complex
and confusing captchas. The best way to stop spam, is to use linguistic
testing on the content being offered, which protects against bot and
human spammer alike.

Thanks,
Ash
http://www.ashleysheridan.co.uk




RE: [PHP] Trapping failure of file_get_contents()

2009-10-22 Thread Marshall Burns
> If you need more control then I suggest you switch from 
> file_get_contents() to using curl to retrieve the page. You can then set 
> your timeout criteria.

Bingo! That appears to have done it. In fact, not only did it solve the
timeout problem raised in 
http://marc.info/?l=php-general&m=125622597723923&w=2
but it also seems to have accidentally solved the separate problem of
mysterious access violation errors raised in 
http://marc.info/?l=php-general&m=125601395731668&w=2

Apparently, not only does curl give me control over execution time of the
function, but it seems to do its file access in a cleaner way somehow. I say
this not only because the access violation errors have gone away, but also
because the frequency of failed access attempts is much lower now than when
I was using file-get-contents().

Thank you big time, Robert.

If anyone would like to see, the function that I wrote to replace both
file-get-contents() and simplexml_load_file() is below. For
file-get-contents(), it can optionally do the job of an additional
file-put-contents(). In the case of simplexml_load_file(), it works by
passing the downloaded file as a string to simplexml_load_string().

If anyone sees any problems or weaknesses with how this is written, please
do let me know. (Please be sure to include me in the recipients because I'm
going to unsubscribe from the list now.)

Thanks all for your help.




function GetFile($sURLin, $sFileOut)
   {// Get an online file and either return it as a string or write it to a
file and return the file size.
$oChandle = curl_init($sURLin);
if($sFileOut == '')
   {$bWriteFile = false;
curl_setopt($oChandle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($oChandle, CURLOPT_BINARYTRANSFER, true);}
  else
   {$bWriteFile = true;
$oFilePtr = fopen($sFileOut, 'w');
curl_setopt($oChandle, CURLOPT_FILE, $oFilePtr);}
curl_setopt($oChandle, CURLOPT_HEADER, 0);
curl_setopt($oChandle, CURLOPT_CONNECTTIMEOUT, 5);
$bGetIt = true;
while($bGetIt)
   {$sRetVal = curl_exec($oChandle);
if($sRetVal === false) 
   {sWarning('DL error on ' . $sURLin);
set_time_limit(30);
sleep(1);}
  else
   {if($bWriteFile) 
$sRetVal = 
curl_getinfo($oChandle,
CURLINFO_SIZE_DOWNLOAD);
$bGetIt = false;}
}
curl_close($oChandle);
if($bWriteFile) fclose($oFilePtr);
return($sRetVal);
}



-Original Message-
From: Robert Cummings [mailto:rob...@interjinn.com] 
Sent: Thursday, October 22, 2009 11:21
To: Marshall Burns
Cc: php-general@lists.php.net
Subject: Re: [PHP] Trapping failure of file_get_contents()

Marshall Burns wrote:
> Robert and others,
> 
> I made that change in the code. It still does not trap the failure. I
> believe the reason is that the script is timing out while
> file_get_contents() is sitting there waiting for input. The problem is
that
> the function never returns, so there is no return value to check. What I
> need is to get file_get_contents() to quit trying before the script
timeout
> limit is reached, so I can catch the failure and try again. If that cannot
> be done, then I need to get the shutdown function to work.
> 
> For reference, my original question is at 
> http://marc.info/?l=php-general&m=125622597723923&w=2 .

If you need more control then I suggest you switch from 
file_get_contents() to using curl to retrieve the page. You can then set 
your timeout criteria.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP



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



Re: [PHP] Spam opinions please

2009-10-22 Thread Gary
I have always thought that by putting some simple, readable ttext into a 
graphic (eg.apple) and asking people to type it in a space, that would work, 
but that does not stop the humans..

Gary


"Philip Thompson"  wrote in message 
news:9bf33458-4a91-4a23-bcb8-ebe13269f...@gmail.com...
> On Oct 20, 2009, at 1:48 PM, Gary wrote:
>
>> NO I have not, I think my issue is I hate when I run across one, it 
>> usually
>> takes me more than one try to actually figure out what the charactor  is, 
>> so
>> hence my disdain.
>>
>>
>> GAry
>
> Here are some captchas:
>
> "What's three minus two?"
> "Which word is listed first in the dictionary: apple, banana, pizza?"
> "Add 4 plus 5"
>
> Create a list of simple questions that only humans can answer. I find 
> these to be less annoying.
>
> ~Philip
>
>
>> "Paul M Foster"  wrote in message
>> news:20091020184001.gi3...@quillandmouse.com...
>>> On Tue, Oct 20, 2009 at 02:31:53PM -0400, Gary wrote:
>>>
>>>> I have several sites that are getting hit with form spam.  I have  the
>>>> script
>>>> set up to capture the IP address so I know from where they come.   I 
>>>> found
>>>> a
>>>> short script that is supposed to stop these IP addresses from 
>>>> accessing
>>>> the
>>>> form page, it redirects the spammer to another page (I was going to
>>>> redirect
>>>> to a page that has lots of pop-ups, scantily clad men and offers  of 
>>>> joy
>>>> beyond imagination), but someone suggested I redirect to the Federal
>>>> Trade
>>>> Commission or perhpas the FBI.
>>>>
>>>> Any thoughts on the script and its effectivness?
>>>>
>>>> >>> $deny = array("111.111.111", "222.222.222", "333.333.333");
>>>> if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) {
>>>>   header("location: http://www.google.com/";);
>>>>   exit();
>>>> } ?>Gary
>>>>
>>>
>>> Have you tried CAPTCHA?
>>>
>>> Paul
>
> __ Information from ESET Smart Security, version of virus 
> signature database 4534 (20091022) __
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
> 



__ Information from ESET Smart Security, version of virus signature 
database 4534 (20091022) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] php mail() function

2009-10-22 Thread LinuxManMikeC
The problem is you won't be trusted to deliver mail directly to most
mail servers unless you have a static IP.  Even then thats no
guarantee.  What you have to do is relay through your ISP's SMTP
server where you're "trusted".  You should also be able to setup PHP
to use your ISP's SMTP server and never touch the SMTP service on your
local machine (if you don't feel like playing with Postfix).

On Thu, Oct 22, 2009 at 3:56 PM, James Prentice  wrote:
> I'm trying to use the php mail() function to send a mail within a php
> script. This is using PHP 5.2.4 and Ubuntu Hardy Heron linux. The
> script runs fine and the return value of the mail function is TRUE,
> but the mail is never received. I'm trying to send an email to my
> gmail account via the local server on my machine, just to test if this
> script works.
>
> I installed postfix because I read in several places that people have
> had good luck with that mail program. From what I can tell, postfix is
> working. I can do:
>
> telnet localhost 25
> Trying 127.0.0.1...
> Connected to localhost.
> Escape character is '^]'.
> 220 homemade ESMTP Postfix (Ubuntu)
> ehlo localhost
> 250-homemade
> 250-PIPELINING
> 250-SIZE 1024
> 250-VRFY
> 250-ETRN
> 250-STARTTLS
> 250-ENHANCEDSTATUSCODES
> 250-8BITMIME
> 250 DSN
>
> After the php script runs, I type 'mailq' and get the result 'mail
> queue is empty.' If I check /var/log/mail.log, this is what I see:
>
> Oct 21 23:54:35 homemade postfix/pickup[5735]: 2A31EA70109: uid=33
> from=
> Oct 21 23:54:35 homemade postfix/cleanup[7997]: 2A31EA70109:
> message-id=<20091022065435.2a31ea70...@homemade>
> Oct 21 23:54:35 homemade postfix/qmgr[5736]: 2A31EA70109:
> from=, size=499, nrcpt=1 (queue active)
> Oct 21 23:54:35 homemade postfix/error[7999]: 2A31EA70109:
> to=, relay=none, delay=0.04, delays=0.03/0/0/0.01,
> dsn=5.0.0, status=bounced (gmail.com)
> Oct 21 23:54:35 homemade postfix/cleanup[7997]: 3217DA7010A:
> message-id=<20091022065435.3217da70...@homemade>
> Oct 21 23:54:35 homemade postfix/qmgr[5736]: 3217DA7010A: from=<>,
> size=2095, nrcpt=1 (queue active)
> Oct 21 23:54:35 homemade postfix/bounce[8000]: 2A31EA70109: sender
> non-delivery notification: 3217DA7010A
> Oct 21 23:54:35 homemade postfix/qmgr[5736]: 2A31EA70109: removed
> Oct 21 23:54:35 homemade postfix/local[8001]: 3217DA7010A:
> to=, relay=local, delay=0.03, delays=0/0.02/0/0.01,
> dsn=2.0.0, status=sent (delivered to command: procmail -a
> "$EXTENSION")
> Oct 21 23:54:35 homemade postfix/qmgr[5736]: 3217DA7010A: removed
>
> Any ideas? I am new both to php and postfix. Thanks for any help.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



[PHP] php mail() function

2009-10-22 Thread James Prentice
I'm trying to use the php mail() function to send a mail within a php
script. This is using PHP 5.2.4 and Ubuntu Hardy Heron linux. The
script runs fine and the return value of the mail function is TRUE,
but the mail is never received. I'm trying to send an email to my
gmail account via the local server on my machine, just to test if this
script works.

I installed postfix because I read in several places that people have
had good luck with that mail program. From what I can tell, postfix is
working. I can do:

telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 homemade ESMTP Postfix (Ubuntu)
ehlo localhost
250-homemade
250-PIPELINING
250-SIZE 1024
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

After the php script runs, I type 'mailq' and get the result 'mail
queue is empty.' If I check /var/log/mail.log, this is what I see:

Oct 21 23:54:35 homemade postfix/pickup[5735]: 2A31EA70109: uid=33
from=
Oct 21 23:54:35 homemade postfix/cleanup[7997]: 2A31EA70109:
message-id=<20091022065435.2a31ea70...@homemade>
Oct 21 23:54:35 homemade postfix/qmgr[5736]: 2A31EA70109:
from=, size=499, nrcpt=1 (queue active)
Oct 21 23:54:35 homemade postfix/error[7999]: 2A31EA70109:
to=, relay=none, delay=0.04, delays=0.03/0/0/0.01,
dsn=5.0.0, status=bounced (gmail.com)
Oct 21 23:54:35 homemade postfix/cleanup[7997]: 3217DA7010A:
message-id=<20091022065435.3217da70...@homemade>
Oct 21 23:54:35 homemade postfix/qmgr[5736]: 3217DA7010A: from=<>,
size=2095, nrcpt=1 (queue active)
Oct 21 23:54:35 homemade postfix/bounce[8000]: 2A31EA70109: sender
non-delivery notification: 3217DA7010A
Oct 21 23:54:35 homemade postfix/qmgr[5736]: 2A31EA70109: removed
Oct 21 23:54:35 homemade postfix/local[8001]: 3217DA7010A:
to=, relay=local, delay=0.03, delays=0/0.02/0/0.01,
dsn=2.0.0, status=sent (delivered to command: procmail -a
"$EXTENSION")
Oct 21 23:54:35 homemade postfix/qmgr[5736]: 3217DA7010A: removed

Any ideas? I am new both to php and postfix. Thanks for any help.

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



Re: [PHP] Limit query/function time

2009-10-22 Thread Philip Thompson

On Oct 22, 2009, at 3:30 PM, Phpster wrote:


Have you run an explain plan on the query?

Bastien

Sent from my iPod


Yes, I have. For giggles, I wanted to run it again. Here it is  
(slightly stripped down) and it looks good to me.


mysql> EXPLAIN SELECT
-> `p`.`patient_id`,
-> `p`.`address_id`,
-> `p`.`patient_sub_id`,
-> AES_DECRYPT(`p`.`patient_first_name`, 'hidden_key') AS  
`patient_first_name`,
-> AES_DECRYPT(`p`.`patient_last_name`, 'hidden_key') AS  
`patient_last_name`,
-> AES_DECRYPT(`p`.`patient_middle_name`, 'hidden_key') AS  
`patient_middle_name`,

-> AES_DECRYPT(`p`.`patient_dob`, 'hidden_key') AS `patient_dob`
-> FROM `patient` `p`
-> INNER JOIN `center_patient` `cp` ON `p`.`patient_id` =  
`cp`.`patient_id`
-> WHERE ((`p`.`patient_id` = '256783' OR `p`.`patient_sub_id` =  
'256783') AND `cp`.`center_id` = '109')

-> ORDER BY `patient_id` DESC;
++-++-- 
+--+
| id | key_len | ref| rows |  
Extra|
++-++-- 
+--+
|  1 | 4,4 | NULL   |2 | Using union 
(PRIMARY,patient_sub_id); Using where; Using filesort |
|  1 | 8   | p.patient_id,const |1 | Using  
index  |
++-++-- 
+--+

2 rows in set (0.00 sec)

There are about 350,000 records in `patient` and `center_patient`  
tables. The average number of rows returned from this query is less  
than 5.


~Philip


On Oct 22, 2009, at 4:14 PM, Philip Thompson  
 wrote:



Hi all.

I'm running into a random issue where sometimes it take several  
minutes (up to 10 or 15) to complete a query. According to 1 or 2  
references, this may be a mysql bug. These links explain the  
similar problem I'm experiencing:


http://forums.mysql.com/read.php?24,57257
http://forum.percona.com/s/m/790/

I did some testing yesterday and this 1 sql statement successfully  
queried (in milliseconds) approximately 50,000 times before it took  
several minutes to query, which hung all the other processes on the  
database. Because it occurs successfully so many times, I know the  
query is good.


Is it possible to set a time limit on a single function in PHP?  
E.g., when I call mysql_query() and it takes 30 seconds, then quit  
processing that function and continue on. I know I could  
set_time_limit() to a specific time, but that would cause a fatal  
error... and I want to be able to catch it.


Any thoughts on what direction I should go? Also, I'm going to do  
some research to see if a newer version of mysql has fixed this  
bug. We're running 5.0.45.


Thanks,
~Philip


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



Re: [PHP] Limit query/function time

2009-10-22 Thread Philip Thompson

On Oct 22, 2009, at 3:26 PM, Eddie Drapkin wrote:

On Thu, Oct 22, 2009 at 4:14 PM, Philip Thompson > wrote:

Hi all.

I'm running into a random issue where sometimes it take several  
minutes (up
to 10 or 15) to complete a query. According to 1 or 2 references,  
this may
be a mysql bug. These links explain the similar problem I'm  
experiencing:


http://forums.mysql.com/read.php?24,57257
http://forum.percona.com/s/m/790/

I did some testing yesterday and this 1 sql statement successfully  
queried
(in milliseconds) approximately 50,000 times before it took several  
minutes
to query, which hung all the other processes on the database.  
Because it

occurs successfully so many times, I know the query is good.

Is it possible to set a time limit on a single function in PHP?  
E.g., when I

call mysql_query() and it takes 30 seconds, then quit processing that
function and continue on. I know I could set_time_limit() to a  
specific
time, but that would cause a fatal error... and I want to be able  
to catch

it.

Any thoughts on what direction I should go? Also, I'm going to do  
some

research to see if a newer version of mysql has fixed this bug. We're
running 5.0.45.

Thanks,
~Philip


You could use ErrorException and catch that:
http://www.php.net/manual/en/class.errorexception.php
Or you could just set your own error handler:
http://www.php.net/manual/en/function.set-error-handler.php

Something I don't know if you've thought of that came to mind, though,
is the MySQL query cache.  It's entirely likely that you have a query
that takes several minutes to run, then is stored in query cache for
the next 50,000 iterations of the query.  Have you observed this same
behavior without the query cache enabled (it also looks like the bug
mentioned in the second link - the one that pertains to the 5.0.x
branch of mysql - has to do with an overly large query cache)?  Based
on that post, I'd guess that your next action would be to disable the
query cache and determine from there if it's a slow query or actually
the bug in MySQL.


I didn't think you could catch fatal errors - isn't that why they're  
fatal?


I will check into the query cache thing. However, the query that I'm  
running isn't exactly the same each time. Each iteration has a  
different ID value in the WHERE clause.


Thank you,
~Philip



Re: [PHP] Limit query/function time

2009-10-22 Thread Phpster

Have you run an explain plan on the query?

Bastien

Sent from my iPod

On Oct 22, 2009, at 4:14 PM, Philip Thompson   
wrote:



Hi all.

I'm running into a random issue where sometimes it take several  
minutes (up to 10 or 15) to complete a query. According to 1 or 2  
references, this may be a mysql bug. These links explain the similar  
problem I'm experiencing:


http://forums.mysql.com/read.php?24,57257
http://forum.percona.com/s/m/790/

I did some testing yesterday and this 1 sql statement successfully  
queried (in milliseconds) approximately 50,000 times before it took  
several minutes to query, which hung all the other processes on the  
database. Because it occurs successfully so many times, I know the  
query is good.


Is it possible to set a time limit on a single function in PHP?  
E.g., when I call mysql_query() and it takes 30 seconds, then quit  
processing that function and continue on. I know I could  
set_time_limit() to a specific time, but that would cause a fatal  
error... and I want to be able to catch it.


Any thoughts on what direction I should go? Also, I'm going to do  
some research to see if a newer version of mysql has fixed this bug.  
We're running 5.0.45.


Thanks,
~Philip

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



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



Re: [PHP] Limit query/function time

2009-10-22 Thread Eddie Drapkin
On Thu, Oct 22, 2009 at 4:14 PM, Philip Thompson  wrote:
> Hi all.
>
> I'm running into a random issue where sometimes it take several minutes (up
> to 10 or 15) to complete a query. According to 1 or 2 references, this may
> be a mysql bug. These links explain the similar problem I'm experiencing:
>
> http://forums.mysql.com/read.php?24,57257
> http://forum.percona.com/s/m/790/
>
> I did some testing yesterday and this 1 sql statement successfully queried
> (in milliseconds) approximately 50,000 times before it took several minutes
> to query, which hung all the other processes on the database. Because it
> occurs successfully so many times, I know the query is good.
>
> Is it possible to set a time limit on a single function in PHP? E.g., when I
> call mysql_query() and it takes 30 seconds, then quit processing that
> function and continue on. I know I could set_time_limit() to a specific
> time, but that would cause a fatal error... and I want to be able to catch
> it.
>
> Any thoughts on what direction I should go? Also, I'm going to do some
> research to see if a newer version of mysql has fixed this bug. We're
> running 5.0.45.
>
> Thanks,
> ~Philip
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

You could use ErrorException and catch that:
http://www.php.net/manual/en/class.errorexception.php
Or you could just set your own error handler:
http://www.php.net/manual/en/function.set-error-handler.php

Something I don't know if you've thought of that came to mind, though,
is the MySQL query cache.  It's entirely likely that you have a query
that takes several minutes to run, then is stored in query cache for
the next 50,000 iterations of the query.  Have you observed this same
behavior without the query cache enabled (it also looks like the bug
mentioned in the second link - the one that pertains to the 5.0.x
branch of mysql - has to do with an overly large query cache)?  Based
on that post, I'd guess that your next action would be to disable the
query cache and determine from there if it's a slow query or actually
the bug in MySQL.

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



[PHP] Limit query/function time

2009-10-22 Thread Philip Thompson

Hi all.

I'm running into a random issue where sometimes it take several  
minutes (up to 10 or 15) to complete a query. According to 1 or 2  
references, this may be a mysql bug. These links explain the similar  
problem I'm experiencing:


http://forums.mysql.com/read.php?24,57257
http://forum.percona.com/s/m/790/

I did some testing yesterday and this 1 sql statement successfully  
queried (in milliseconds) approximately 50,000 times before it took  
several minutes to query, which hung all the other processes on the  
database. Because it occurs successfully so many times, I know the  
query is good.


Is it possible to set a time limit on a single function in PHP? E.g.,  
when I call mysql_query() and it takes 30 seconds, then quit  
processing that function and continue on. I know I could set_time_limit 
() to a specific time, but that would cause a fatal error... and I  
want to be able to catch it.


Any thoughts on what direction I should go? Also, I'm going to do some  
research to see if a newer version of mysql has fixed this bug. We're  
running 5.0.45.


Thanks,
~Philip

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



Re: [PHP] Spam opinions please

2009-10-22 Thread Philip Thompson

On Oct 20, 2009, at 1:48 PM, Gary wrote:

NO I have not, I think my issue is I hate when I run across one, it  
usually
takes me more than one try to actually figure out what the charactor  
is, so

hence my disdain.


GAry


Here are some captchas:

"What's three minus two?"
"Which word is listed first in the dictionary: apple, banana, pizza?"
"Add 4 plus 5"

Create a list of simple questions that only humans can answer. I find  
these to be less annoying.


~Philip



"Paul M Foster"  wrote in message
news:20091020184001.gi3...@quillandmouse.com...

On Tue, Oct 20, 2009 at 02:31:53PM -0400, Gary wrote:

I have several sites that are getting hit with form spam.  I have  
the

script
set up to capture the IP address so I know from where they come.   
I found

a
short script that is supposed to stop these IP addresses from  
accessing

the
form page, it redirects the spammer to another page (I was going to
redirect
to a page that has lots of pop-ups, scantily clad men and offers  
of joy

beyond imagination), but someone suggested I redirect to the Federal
Trade
Commission or perhpas the FBI.

Any thoughts on the script and its effectivness?

http://www.google.com/";);
  exit();
} ?>Gary



Have you tried CAPTCHA?

Paul


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



Re: [PHP] Trapping failure of file_get_contents()

2009-10-22 Thread Gerardo Benitez
Hi Marshall,

the function file_get_contents may have problem with large files.

You could try get the file using "fread" and feof.

Here i put a example



$contents = '';
while(!feof($stream)){
$contents .= fread($stream, 8192);
}


Gerardo Benitez.





On Thu, Oct 22, 2009 at 12:38 PM, Marshall Burns wrote:

> I have a script that downloads a sequence of files online. Every hundred
> files or so, it fails with:
>
>
>
> ==
>
> Warning: file_get_contents() []: failed to open stream: A connection
> attempt failed because the connected party did not properly respond after a
> period of time, or established connection failed because connected host has
> failed to respond. in 

Re: [PHP] Trapping failure of file_get_contents()

2009-10-22 Thread Robert Cummings

Marshall Burns wrote:

Robert and others,

I made that change in the code. It still does not trap the failure. I
believe the reason is that the script is timing out while
file_get_contents() is sitting there waiting for input. The problem is that
the function never returns, so there is no return value to check. What I
need is to get file_get_contents() to quit trying before the script timeout
limit is reached, so I can catch the failure and try again. If that cannot
be done, then I need to get the shutdown function to work.

For reference, my original question is at 
http://marc.info/?l=php-general&m=125622597723923&w=2 .


If you need more control then I suggest you switch from 
file_get_contents() to using curl to retrieve the page. You can then set 
your timeout criteria.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] Please don't kick me!

2009-10-22 Thread Philip Thompson

On Oct 20, 2009, at 3:44 PM, Kim Madsen wrote:


Philip Thompson wrote on 2009-10-20 21:58:

I got it to draw the different background colors successfully.  
However, drawing borders is not as straight forward. I'm sure I  
could get it working as well... but I'd rather it work *out of the  
box*. Thanks for the suggestion. ;)


Well, you're always welcome to contribute to an open source project  
you take advantage of ;o)


Tis true. However, my passion does not include creating a better PDF  
generator. After doing a lil bit more research, I came across this one  
and I really like it so far.


http://realobjects.com/PDFreactor.939.0.html

It's definitely not free, but it seems to do what I need... so far.

Thanks,
~Philip


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



RE: [PHP] Trapping failure of file_get_contents()

2009-10-22 Thread Marshall Burns
Robert and others,

I made that change in the code. It still does not trap the failure. I
believe the reason is that the script is timing out while
file_get_contents() is sitting there waiting for input. The problem is that
the function never returns, so there is no return value to check. What I
need is to get file_get_contents() to quit trying before the script timeout
limit is reached, so I can catch the failure and try again. If that cannot
be done, then I need to get the shutdown function to work.

For reference, my original question is at 
http://marc.info/?l=php-general&m=125622597723923&w=2 .

Thanks.




-Original Message-
From: Robert Cummings [mailto:rob...@interjinn.com] 
Sent: Thursday, October 22, 2009 08:44
To: Marshall Burns
Cc: php-general@lists.php.net
Subject: Re: [PHP] Trapping failure of file_get_contents()


Marshall Burns wrote:
> I have a script that downloads a sequence of files online. Every hundred
> files or so, it fails with:

Check for the return value being equal to false:



Make sure you use the triple '=' comparison operator since you need to 
check against the type being boolean also.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP





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



Re: [PHP] Create a screenshot of a website

2009-10-22 Thread Kim Madsen

resea soul wrote on 2009-10-22 15:28:

Hi,

I want to be able to get a screenshot of a given website on the fly.
Can you give me any suggestions.


Do you mean "I wanna make a screendump of _my_ website"? Then this is 
for you: http://dk2.php.net/manual/en/function.imagegrabscreen.php - It 
works with the COM interface on windows and therefore is a windows-only 
function.


If you mean create a screendump of another website you don't have 
control over i think that would require som GD coding, not sure if 
that's possible with PHP only, most likely I would say no.


If you mean you wanna rip a website and use it in your own then there's 
two functions to check:

readfile() which reads the whole site and outputs this again.
fopen() where you can read an URL line by line and easy do some 
alterations to the line if you like.


I hope this will help you on the way.

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Re: Fun with XSLT

2009-10-22 Thread Matthew Croud


On 22 Oct 2009, at 16:39, Peter Ford wrote:


Matthew Croud wrote:

Hi Guys,

Well i;ve been slaving on with my PHP XML endeavors and i'm loving  
it,

just finishing the meaty parts of my XSLT for dummies book too.

I have a question which asks "is it possible?".

Using XSLT I can collect specific parts of my XML using something  
sexy
like .  Lets say however, that I need  
to

use XSLT, but I would want the user to select which element they
request. In other words, they are given a form with options and that
form can manipulate the .XSL file.

Now I know it could be done in a lengthly manner by just opening  
the XSL
file and manipulating it like fopen or something like that, but is  
there
a way to somehow embed the contents of the xml into the php code  
(like
using <<< EOF for html), and being able to substitute the template  
match

string for a variable ?

Any ideas ?

Thanks Gamesmaster,
Matt


A bit off-topic (since XSLT is not PHP...) but here goes.

First I need to clarify what you are doing -
 ... 
defines the template portion, and that is pretty immutable.

At some point you must have in your XSLT something like

This is the bit you can play with:

so:


http://www.w3.org/1999/XSL/Transform 
">





   


   
   xsl:template>

   


   
   
   



Essentially you need to apply the template of any element, but only  
those whose

name matches your request.
Note that

doesn't work... :(

So now if your PHP does something like

$xslDom = new DOMDocument();
$xslDom->load('matchMe.xsl');
$xslt = new XSLTProcessor();
$xslt->importStylesheet($xslDom);
$xslt->setParameter('','matchMe','umbongo');
$xmlDom = new DOMDocument();
$xmlDom->load('some_document_that_has_an_umbongo_tag.xml');
echo $xslt->transformToXML($xmlDom);

you should get the results of the 'umbongo' template (only)


'f course, this is not tested, but I have used this idea in working  
code





--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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





Utter brilliance, this is superb, I might drop you a mail to clarify a  
few things later Peter,
but your reply was superb and has given me many options to try out.   
Thanks again!






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



Re: [PHP] Trapping failure of file_get_contents()

2009-10-22 Thread Jim Lucas
Robert Cummings wrote:
> 
> Marshall Burns wrote:
>> I have a script that downloads a sequence of files online. Every hundred
>> files or so, it fails with:
> 
> Check for the return value being equal to false:
> 
>  
> if( ($sFil = file_get_contents( $sURL )) === false )
> {
> // FAIL
> }
> else
> {
> // SUCCESS
> }
> 
> ?>
> 
> Make sure you use the triple '=' comparison operator since you need to
> check against the type being boolean also.
> 
> Cheers,
> Rob.


To squelch the warning notice that is generated, you might want to put an @ in
front of the file_get_contents() call.

Jim

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



[PHP] Sessions seems to kill db connection

2009-10-22 Thread Kim Madsen

Hi PHPeople

I have an odd problem at my new work and wonder if it's some sort of odd 
setup that is causing this problem when using sessions:


if($test) {
  $query = "SELECT count(*) FROM articles WHERE group1 = 'fp'";# AND 
group2 = 'login'";
  $r = mysql_query($query) or die('Db error: ' . mysql_error() . 
''.$SQL);

  print "There´s " . mysql_num_rows($r) . " rows"; // 3 rows
  print "session: " . $_SESSION['login']['uid']; // 1234
  exit;
}
else {
  if($_SESSION['login']['uid']) {
$query = "SELECT count(*) FROM articles WHERE group1 = 'fp'";# AND 
group2 = 'login'";
$r = mysql_query($query) or die('Db error: ' . mysql_error() . 
''.$SQL);

print "There´s " . mysql_num_rows($r) . " rows";
  }
}

if $test is true it´s okay, if it´s false, this error occurs:

Db error: Access denied for user 'www-data'@'localhost' (using password: NO)

WTF? I´m not using a user called www-data for MySQL connections, but 
apache runs as this user.


I've outcommented and login = to exclude a collision in variables (if 
register globals is on, haven't checked that yet)


Anyone seen this wierd behaviour and know a solution or someway to 
test/debug this?


--
Kind regards
Kim Emax



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



Re: [PHP] Create a screenshot of a website

2009-10-22 Thread Robert Cummings

Jason wrote:

-Original Message-
From: Andrea Giammarchi [mailto:an_...@hotmail.com] 
Sent: 22 October 2009 16:34

To: networkad...@emarket2.com; php-general@lists.php.net
Subject: RE: [PHP] Create a screenshot of a website




Hi,

If a windows web server is being used, we've had very good results with

the

activex control (use via COM within PHP5) from
http://www.acasystems.com/en/web-thumb-activex/

The developer is very responsive to bug reports / feature suggestions.

Full

PHP example code is given for all functions as well.


Now this is truly interesting, is there any particular reason it works only
with windows web server? Any chance it could be somehow integrated via VM
Virtual Images if the reason is driven Internet Explorer?

Regards

That is a question you'd have to ask the developer I'm afraid. The only PHP
compatible interface is COM (which I'm pretty sure is windows only), so
you'd need to be running PHP on windows (IIRC).


It would be possible to have a linux webserver that uses a windows VM 
proxy webserver to facilitate the COM request. This is not entire absurd 
since generation of website screenshots can be quite processor intensive 
so it might work well split it off to it's own machine (virtual or 
physical).


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



[PHP] Re: Fun with XSLT

2009-10-22 Thread Peter Ford
Matthew Croud wrote:
> Hi Guys,
> 
> Well i;ve been slaving on with my PHP XML endeavors and i'm loving it,
> just finishing the meaty parts of my XSLT for dummies book too.
> 
> I have a question which asks "is it possible?".
> 
> Using XSLT I can collect specific parts of my XML using something sexy
> like .  Lets say however, that I need to
> use XSLT, but I would want the user to select which element they
> request. In other words, they are given a form with options and that
> form can manipulate the .XSL file.
> 
> Now I know it could be done in a lengthly manner by just opening the XSL
> file and manipulating it like fopen or something like that, but is there
> a way to somehow embed the contents of the xml into the php code (like
> using <<< EOF for html), and being able to substitute the template match
> string for a variable ?
> 
> Any ideas ?
> 
> Thanks Gamesmaster,
> Matt
> 

Despite my other post, of course you can generate the XSL on the fly:

http://www.w3.org/1999/XSL/Transform";>








EoXSL

$xslt = new DOMDocument();
$xslt->loadXML($xslScript);

// ... etc...
?>




-- 
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Trapping failure of file_get_contents()

2009-10-22 Thread Robert Cummings


Marshall Burns wrote:

I have a script that downloads a sequence of files online. Every hundred
files or so, it fails with:


Check for the return value being equal to false:



Make sure you use the triple '=' comparison operator since you need to 
check against the type being boolean also.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



[PHP] Re: Fun with XSLT

2009-10-22 Thread Peter Ford
Matthew Croud wrote:
> Hi Guys,
> 
> Well i;ve been slaving on with my PHP XML endeavors and i'm loving it,
> just finishing the meaty parts of my XSLT for dummies book too.
> 
> I have a question which asks "is it possible?".
> 
> Using XSLT I can collect specific parts of my XML using something sexy
> like .  Lets say however, that I need to
> use XSLT, but I would want the user to select which element they
> request. In other words, they are given a form with options and that
> form can manipulate the .XSL file.
> 
> Now I know it could be done in a lengthly manner by just opening the XSL
> file and manipulating it like fopen or something like that, but is there
> a way to somehow embed the contents of the xml into the php code (like
> using <<< EOF for html), and being able to substitute the template match
> string for a variable ?
> 
> Any ideas ?
> 
> Thanks Gamesmaster,
> Matt
> 
A bit off-topic (since XSLT is not PHP...) but here goes.

First I need to clarify what you are doing -
 ... 
defines the template portion, and that is pretty immutable.

At some point you must have in your XSLT something like

This is the bit you can play with:

so:


http://www.w3.org/1999/XSL/Transform";>
 
















Essentially you need to apply the template of any element, but only those whose
name matches your request.
Note that

doesn't work... :(

So now if your PHP does something like

$xslDom = new DOMDocument();
$xslDom->load('matchMe.xsl');
$xslt = new XSLTProcessor();
$xslt->importStylesheet($xslDom);
$xslt->setParameter('','matchMe','umbongo');
$xmlDom = new DOMDocument();
$xmlDom->load('some_document_that_has_an_umbongo_tag.xml');
echo $xslt->transformToXML($xmlDom);

you should get the results of the 'umbongo' template (only)


'f course, this is not tested, but I have used this idea in working code




-- 
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



RE: [PHP] Create a screenshot of a website

2009-10-22 Thread Jason
-Original Message-
From: Andrea Giammarchi [mailto:an_...@hotmail.com] 
Sent: 22 October 2009 16:34
To: networkad...@emarket2.com; php-general@lists.php.net
Subject: RE: [PHP] Create a screenshot of a website



> Hi,
> 
> If a windows web server is being used, we've had very good results with
the
> activex control (use via COM within PHP5) from
> http://www.acasystems.com/en/web-thumb-activex/
> 
> The developer is very responsive to bug reports / feature suggestions.
Full
> PHP example code is given for all functions as well.

Now this is truly interesting, is there any particular reason it works only
with windows web server? Any chance it could be somehow integrated via VM
Virtual Images if the reason is driven Internet Explorer?

Regards
  



That is a question you'd have to ask the developer I'm afraid. The only PHP
compatible interface is COM (which I'm pretty sure is windows only), so
you'd need to be running PHP on windows (IIRC).

J


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



Re: [PHP] Create a screenshot of a website

2009-10-22 Thread Robert Cummings



Andrea Giammarchi wrote:



Hi,

If a windows web server is being used, we've had very good results with the
activex control (use via COM within PHP5) from
http://www.acasystems.com/en/web-thumb-activex/

The developer is very responsive to bug reports / feature suggestions. Full
PHP example code is given for all functions as well.


Now this is truly interesting, is there any particular reason it works only 
with windows web server? Any chance it could be somehow integrated via VM 
Virtual Images if the reason is driven Internet Explorer?


Of course it can work with a virtual machine... but the OP already 
indicated they want something that works with cpanel so to smack you 
with your own childish arguments... this is not applicable... something 
that is known at this stage of the thread.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



[PHP] Trapping failure of file_get_contents()

2009-10-22 Thread Marshall Burns
I have a script that downloads a sequence of files online. Every hundred
files or so, it fails with:

 

==

Warning: file_get_contents() []: failed to open stream: A connection
attempt failed because the connected party did not properly respond after a
period of time, or established connection failed because connected host has
failed to respond. in 

Re: [PHP] Create a screenshot of a website

2009-10-22 Thread Robert Cummings

Andrea Giammarchi wrote:


Given the knowledge (or extremely likely probability) of the 
non-existence of a PHP only solution for generating website thumbnails 
it follows that my suggestion was absolutely applicable.


I have never said the opposite ... I have just said: pure PHP with standard 
core functions/libraries? No way so far


Yes you did, and I quote:

"Good suggestion, not applicable since the question was different"

You said "not applicable" which is exactly the opposite of "applicable".


The right question would have been: do you know any third parts 
library/webservice able to get a snapshot?
In this case your suggestion would have been perfect :-)


The OP's original question was:

"I want to be able to get a screenshot of a given website on
 the fly. Can you give me any suggestions."

He wanted a route to get a screenshot. he didn't say PHP only, he didn't 
say third party, he just said "any suggestions"-- take careful note of 
the word "ANY".


Now, if you don't mind, please stop spamming the poster's thread with 
puerile argument.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



RE: [PHP] Create a screenshot of a website

2009-10-22 Thread Ashley Sheridan
On Thu, 2009-10-22 at 17:33 +0200, Andrea Giammarchi wrote:

> 
> > Hi,
> > 
> > If a windows web server is being used, we've had very good results with the
> > activex control (use via COM within PHP5) from
> > http://www.acasystems.com/en/web-thumb-activex/
> > 
> > The developer is very responsive to bug reports / feature suggestions. Full
> > PHP example code is given for all functions as well.
> 
> Now this is truly interesting, is there any particular reason it works only 
> with windows web server? Any chance it could be somehow integrated via VM 
> Virtual Images if the reason is driven Internet Explorer?
> 
> Regards
> 
> _
> Windows Live Hotmail: Your friends can get your Facebook updates, right from 
> Hotmail®.
> http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009


Surely the clue to that question would be in the activex part?...

Thanks,
Ash
http://www.ashleysheridan.co.uk




RE: [PHP] Create a screenshot of a website

2009-10-22 Thread Andrea Giammarchi


> Hi,
> 
> If a windows web server is being used, we've had very good results with the
> activex control (use via COM within PHP5) from
> http://www.acasystems.com/en/web-thumb-activex/
> 
> The developer is very responsive to bug reports / feature suggestions. Full
> PHP example code is given for all functions as well.

Now this is truly interesting, is there any particular reason it works only 
with windows web server? Any chance it could be somehow integrated via VM 
Virtual Images if the reason is driven Internet Explorer?

Regards
  
_
Windows Live Hotmail: Your friends can get your Facebook updates, right from 
Hotmail®.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009

RE: [PHP] Create a screenshot of a website

2009-10-22 Thread Andrea Giammarchi


> Given the knowledge (or extremely likely probability) of the 
> non-existence of a PHP only solution for generating website thumbnails 
> it follows that my suggestion was absolutely applicable.

I have never said the opposite ... I have just said: pure PHP with standard 
core functions/libraries? No way so far

The right question would have been: do you know any third parts 
library/webservice able to get a snapshot?
In this case your suggestion would have been perfect :-)

Regards
  
_
Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail 
you.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092010

RE: [PHP] Fun with XSLT

2009-10-22 Thread Andrea Giammarchi


> is  
> there a way to somehow embed the contents of the xml into the php code  
> (like using <<< EOF for html), and being able to substitute the  
> template match string for a variable ?
> 
> Any ideas ?

XSLT should be used via modules, as is with match and templates indeed.
The only idea is to save single modules in order to be able to create run-time 
the proper transformer for the specific case.

Then you can save these grouped modules into other modules ... I know it's more 
easy to say than do it.

Regards
  
_
Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail 
you.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092010

Re: [PHP] Create a screenshot of a website

2009-10-22 Thread Robert Cummings

Andrea Giammarchi wrote:


 > I see you are being rather obtuse :|

I use system/shell calls without problems if there is the lib I need.
The problem here is that the question was, in my opinion, the classic: 
how to assign javascript var to php (directly)


Indeed he is trying to find a PHP solution, of course with third parts 
libraries you can do whatever you want, but this is not the case.


Good suggestion, not applicable since the question was different, so 
maybe I've been obtuse reading the question ... still good suggestion.


Given the knowledge (or extremely likely probability) of the 
non-existence of a PHP only solution for generating website thumbnails 
it follows that my suggestion was absolutely applicable.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



RE: [PHP] Create a screenshot of a website

2009-10-22 Thread Andrea Giammarchi


> I see you are being rather obtuse :|

I use system/shell calls without problems if there is the lib I need.
The problem here is that the question was, in my opinion, the classic: how to 
assign javascript var to php (directly)

Indeed he is trying to find a PHP solution, of course with third parts 
libraries you can do whatever you want, but this is not the case.

Good suggestion, not applicable since the question was different, so maybe I've 
been obtuse reading the question ... still good suggestion.

Regards
  
_
Windows Live Hotmail: Your friends can get your Facebook updates, right from 
Hotmail®.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009

[PHP] Fun with XSLT

2009-10-22 Thread Matthew Croud

Hi Guys,

Well i;ve been slaving on with my PHP XML endeavors and i'm loving it,  
just finishing the meaty parts of my XSLT for dummies book too.


I have a question which asks "is it possible?".

Using XSLT I can collect specific parts of my XML using something sexy  
like .  Lets say however, that I need to  
use XSLT, but I would want the user to select which element they  
request. In other words, they are given a form with options and that  
form can manipulate the .XSL file.


Now I know it could be done in a lengthly manner by just opening the  
XSL file and manipulating it like fopen or something like that, but is  
there a way to somehow embed the contents of the xml into the php code  
(like using <<< EOF for html), and being able to substitute the  
template match string for a variable ?


Any ideas ?

Thanks Gamesmaster,
Matt







RE: [PHP] Create a screenshot of a website

2009-10-22 Thread Jason
-Original Message-
From: resea soul [mailto:reseas...@gmail.com] 
Sent: 22 October 2009 14:28
To: php-general@lists.php.net
Subject: [PHP] Create a screenshot of a website

Hi,

I want to be able to get a screenshot of a given website on the fly.
Can you give me any suggestions.

Thank you


Hi,

If a windows web server is being used, we've had very good results with the
activex control (use via COM within PHP5) from
http://www.acasystems.com/en/web-thumb-activex/

The developer is very responsive to bug reports / feature suggestions. Full
PHP example code is given for all functions as well.

HTH
J


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



Re: [PHP] Create a screenshot of a website

2009-10-22 Thread Robert Cummings

Andrea Giammarchi wrote:



Thanks,
 
I checked the faq of their website. They say that  I must have an an X 
session. I don't host myself my website.
I want something that I can use only by using cpanel. What i want 
basically is allow the user to enter the url of a website. And the 
script must give him the image as output.


Here we are ... you see Rob? :-)

What about an iframe if this is a user website preview?


I see you are being rather obtuse :|

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] Create a screenshot of a website

2009-10-22 Thread Robert Cummings

Andrea Giammarchi wrote:



Thanks,
 
I checked the faq of their website. They say that  I must have an an X 
session. I don't host myself my website.
I want something that I can use only by using cpanel. What i want 
basically is allow the user to enter the url of a website. And the 
script must give him the image as output.


Here we are ... you see Rob? :-)

What about an iframe if this is a user website preview?


If you have khtml2png2 on your system then using PHP you can do the 
following:


http://www.interjinn.com";'
   .' interjinn.png';

exec( $command );

?>

I fail to see how this is not a PHP solution. This should have been 
obvious when I said PHP makes an excellent glue/wrapper language.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



RE: [PHP] Create a screenshot of a website

2009-10-22 Thread Andrea Giammarchi


> GD is just a library that PHP uses, in a similar way that you'd be
> utilising what khtml2png can do through PHP. What you just said doesn't
> make much sense.

except I cannot find anything in both php.net and pecl websites

Regards
  
_
Windows Live Hotmail: Your friends can get your Facebook updates, right from 
Hotmail®.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009

Re: [PHP] how call a variable in a text

2009-10-22 Thread Martin Scotta
On Thu, Oct 22, 2009 at 8:40 AM, Thodoris  wrote:

>
>
>>
>>> I don't think it is about readability:
>>>
>>> $arr[3] = 'test';
>>> $test = 3;
>>>
>>> //This prints "$test"
>>> echo "This doesn't work: $$arr[3]";
>>>
>>> //This prints 3
>>> echo "This works: ${$arr[3]}";
>>>
>>> Using the same type way as before in this thread.
>>>
>>>
>>
>> Above example is a classic one where readability and maintainability deal
>> well together.
>>
>> First of all everything works as expected but obviously you need to know
>> what you need.
>>
>> It is ambiguous to write $$arr[3] ... what do you expect?]
>>
>>
>
> No I don't think it is. It produces "$test" and if this is what you need
> echo it works nice :-) .
>
>  Did you mean the variable derived by $arr[3]?
>> echo "This works: {$$arr[3]}";
>> since curly brackets make the meaning of the expression explicit, it will
>> be 3 indeed.
>>
>> What is the less ambiguous, readable, easy to maintain, way to obtain that
>> result?
>>
>> echo "This works: {${$arr[3]}}";
>>
>> If our aim is to get the variable with name equal to the value of $arr[3]
>>
>> Can you see now why I am talking about good practice? Zero ambiguity, and
>> that's how I like to code
>>
>> Regards
>>
>>
>>
>
> Although I totally  agree with the way of thinking and it is my style as
> well.
>
> But I though that the point of the thread was to present ways of putting
> vars inside strings...
>
> --
> Thodoris
>
>
PHP knows that before $ and {} there is a variable name so, this is
completely correct for PHP



RE: [PHP] Create a screenshot of a website

2009-10-22 Thread Ashley Sheridan
On Thu, 2009-10-22 at 16:17 +0200, Andrea Giammarchi wrote:

> Rob, I agree, but you are suggesting is khtml2png which is cool, perfect, 
> fantastic, but it's not PHP, isn't it?
> 
> You ask me: I want a snap via PHP
> I reply: well, I don't think such thing exists: a render engine entirely 
> written in PHP and GD2
> 
> Maybe we should create one ... 
> 
> Regards
> 
> > Date: Thu, 22 Oct 2009 09:40:47 -0400
> > From: rob...@interjinn.com
> > To: an_...@hotmail.com
> > CC: reseas...@gmail.com; php-general@lists.php.net
> > Subject: Re: [PHP] Create a screenshot of a website
> > 
> > Andrea Giammarchi wrote:
> > > What you see is what a browser engine renders for your eyes while what 
> > > you can do with PHP is a snapshot of the source code.
> > 
> > One should remember that PHP serves quite well both as a glue language 
> > and as a wrapper language. There is no reason why you can't use PHP to 
> > create a simple lib around something like khtml2png so that the 
> > screenshot can be gathered on demand using simple PHP style function calls.
> > 
> > Cheers,
> > Rob.
> > -- 
> > http://www.interjinn.com
> > Application and Templating Framework for PHP
> 
> _
> Windows Live: Friends get your Flickr, Yelp, and Digg updates when they 
> e-mail you.
> http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092010


GD is just a library that PHP uses, in a similar way that you'd be
utilising what khtml2png can do through PHP. What you just said doesn't
make much sense.

Thanks,
Ash
http://www.ashleysheridan.co.uk




RE: [PHP] Create a screenshot of a website

2009-10-22 Thread Andrea Giammarchi


> > Thanks,
> >  
> > I checked the faq of their website. They say that  I must have an an X 
> > session. I don't host myself my website.
> > I want something that I can use only by using cpanel. What i want 
> > basically is allow the user to enter the url of a website. And the 
> > script must give him the image as output.

Here we are ... you see Rob? :-)

What about an iframe if this is a user website preview?

Regards
  
_
Windows Live: Keep your friends up to date with what you do online.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_1:092010

RE: [PHP] Create a screenshot of a website

2009-10-22 Thread Andrea Giammarchi

Rob, I agree, but you are suggesting is khtml2png which is cool, perfect, 
fantastic, but it's not PHP, isn't it?

You ask me: I want a snap via PHP
I reply: well, I don't think such thing exists: a render engine entirely 
written in PHP and GD2

Maybe we should create one ... 

Regards

> Date: Thu, 22 Oct 2009 09:40:47 -0400
> From: rob...@interjinn.com
> To: an_...@hotmail.com
> CC: reseas...@gmail.com; php-general@lists.php.net
> Subject: Re: [PHP] Create a screenshot of a website
> 
> Andrea Giammarchi wrote:
> > What you see is what a browser engine renders for your eyes while what you 
> > can do with PHP is a snapshot of the source code.
> 
> One should remember that PHP serves quite well both as a glue language 
> and as a wrapper language. There is no reason why you can't use PHP to 
> create a simple lib around something like khtml2png so that the 
> screenshot can be gathered on demand using simple PHP style function calls.
> 
> Cheers,
> Rob.
> -- 
> http://www.interjinn.com
> Application and Templating Framework for PHP
  
_
Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail 
you.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092010

Re: [PHP] Create a screenshot of a website

2009-10-22 Thread Robert Cummings

resea soul wrote:

Thanks,
 
I checked the faq of their website. They say that  I must have an an X 
session. I don't host myself my website.
I want something that I can use only by using cpanel. What i want 
basically is allow the user to enter the url of a website. And the 
script must give him the image as output.
Maybe the hosting company will agree to install something for me but i'm 
not sure that this tool can be integrated in php scripts. I don't see 
anything about how to do that in their website.


You will almost certainly have to use a third party service if you are 
in such a limited environment. Most website screenshot engines hook into 
an existing browser engine to produce the image. Rendering HTML is not a 
trivial task, especially if it is to take into consideration the 
numerous plugins that are fairly common on the internet (flash, java, 
javascript, canvas, etc, etc).


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] Create a screenshot of a website

2009-10-22 Thread Robert Cummings

Andrea Giammarchi wrote:

What you see is what a browser engine renders for your eyes while what you can 
do with PHP is a snapshot of the source code.


One should remember that PHP serves quite well both as a glue language 
and as a wrapper language. There is no reason why you can't use PHP to 
create a simple lib around something like khtml2png so that the 
screenshot can be gathered on demand using simple PHP style function calls.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



[PHP] Re: Text File Busy

2009-10-22 Thread Floyd Resler

It happens on any file I try so there must be something else going on.

Thanks!
Floyd

On Oct 21, 2009, at 4:17 PM, Shawn McKenzie wrote:


Floyd Resler wrote:
For some reason I'm getting a Text file busy error when I try to  
execute

PHP scripts from the command line now.  It used to work, but now it
doesn't.  I do have #!/usr/bin/php at the top of my script.  If I  
feed

the file to php (i.e. /usr/bin/php -f filename.php) it works.  Of
course, I can use this method but I was curious if anyone else has  
had
similar problems and what the solution was.  I'm guessing that  
something

I installed is messing it up.

Thanks!
Floyd



The file is open somewhere most likely.  Try: lsof | grep filename.php

--
Thanks!
-Shawn
http://www.spidean.com




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



RE: [PHP] Create a screenshot of a website

2009-10-22 Thread Andrea Giammarchi

What you see is what a browser engine renders for your eyes while what you can 
do with PHP is a snapshot of the source code.

Regards

> Date: Thu, 22 Oct 2009 09:28:15 -0400
> From: reseas...@gmail.com
> To: php-general@lists.php.net
> Subject: [PHP] Create a screenshot of a website
> 
> Hi,
> 
> I want to be able to get a screenshot of a given website on the fly.
> Can you give me any suggestions.
> 
> Thank you
  
_
Keep your friends updated—even when you’re not signed in.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_5:092010

Re: [PHP] Create a screenshot of a website

2009-10-22 Thread Robert Cummings

resea soul wrote:

Hi,

I want to be able to get a screenshot of a given website on the fly.
Can you give me any suggestions.


http://sourceforge.net/projects/khtml2png/

It might already be in your favourite Linux distro's repositories also.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



[PHP] Create a screenshot of a website

2009-10-22 Thread resea soul
Hi,

I want to be able to get a screenshot of a given website on the fly.
Can you give me any suggestions.

Thank you


RE: [PHP] XML parsing with PHP

2009-10-22 Thread Jay Blanchard
[snip] I need to transform some XML files and have not really done much

XSLT.  I am looking for recommendations on ways to parse XML via  
PHP.  The XML files I have contain the content from our website CMS.   
We are switching from a proprietary CMS to Drupal and I need to  
transform the XML into .csv (comma separated) so I can suck the data  
into MySQL.  Any suggestions are appreciated.  Thanks![/snip]


http://www.php.net/xml


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



Re: [PHP] how call a variable in a text

2009-10-22 Thread Thodoris


  

I don't think it is about readability:

$arr[3] = 'test';
$test = 3;

//This prints "$test"
echo "This doesn't work: $$arr[3]";

//This prints 3
echo "This works: ${$arr[3]}";

Using the same type way as before in this thread.



Above example is a classic one where readability and maintainability deal well 
together.

First of all everything works as expected but obviously you need to know what 
you need.

It is ambiguous to write $$arr[3] ... what do you expect?]
  


No I don't think it is. It produces "$test" and if this is what you need 
echo it works nice :-) .



Did you mean the variable derived by $arr[3]?
echo "This works: {$$arr[3]}";
since curly brackets make the meaning of the expression explicit, it will be 3 
indeed.

What is the less ambiguous, readable, easy to maintain, way to obtain that 
result?

echo "This works: {${$arr[3]}}";

If our aim is to get the variable with name equal to the value of $arr[3]

Can you see now why I am talking about good practice? Zero ambiguity, and 
that's how I like to code

Regards

  


Although I totally  agree with the way of thinking and it is my style as 
well.


But I though that the point of the thread was to present ways of putting 
vars inside strings...


--
Thodoris



RE: [PHP] how call a variable in a text

2009-10-22 Thread Andrea Giammarchi


> I don't think it is about readability:
> 
> $arr[3] = 'test';
> $test = 3;
> 
> //This prints "$test"
> echo "This doesn't work: $$arr[3]";
> 
> //This prints 3
> echo "This works: ${$arr[3]}";
> 
> Using the same type way as before in this thread.

Above example is a classic one where readability and maintainability deal well 
together.

First of all everything works as expected but obviously you need to know what 
you need.

It is ambiguous to write $$arr[3] ... what do you expect?

Did you mean the variable derived by $arr[3]?
echo "This works: {$$arr[3]}";
since curly brackets make the meaning of the expression explicit, it will be 3 
indeed.

What is the less ambiguous, readable, easy to maintain, way to obtain that 
result?

echo "This works: {${$arr[3]}}";

If our aim is to get the variable with name equal to the value of $arr[3]

Can you see now why I am talking about good practice? Zero ambiguity, and 
that's how I like to code

Regards
  
_
Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail 
you.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092010

Re: [PHP] how call a variable in a text

2009-10-22 Thread Thodoris





Using the same type way as before in this thread.




This was supposed to come out as "using the same way of thinking".

But the English->Nerdish dictionary came out...

--
Thodoris


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



Re: [PHP] how call a variable in a text

2009-10-22 Thread Thodoris




> So no they are not meant to go around. You can use them this way as 
well.


that has almost the same meaning of

$_ = '_POST';
echo count($$_);

which again, for readability brackets are suggested to improve 
maintainability


$_ = '_POST';
echo count(${$_});

Regards





I don't think it is about readability:

$arr[3] = 'test';
$test = 3;

//This prints "$test"
echo "This doesn't work: $$arr[3]";

//This prints 3
echo "This works: ${$arr[3]}";

Using the same type way as before in this thread.

My point is that in the curly braces you protect the way the evaluation 
is going to be made into the string. So you can put them anywhere as 
long as it is meaningful.


See some examples:

http://php.net/manual/en/language.types.string.php

in the complex (curly) syntax section.

--
Thodoris



RE: [PHP] how call a variable in a text

2009-10-22 Thread Andrea Giammarchi


> So no they are not meant to go around. You can use them this way as well.

that has almost the same meaning of 

$_ = '_POST';
echo count($$_);

which again, for readability brackets are suggested to improve maintainability

$_ = '_POST';
echo count(${$_});

Regards 
  
_
Windows Live: Make it easier for your friends to see what you’re up to on 
Facebook.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092009

RE: [PHP] how call a variable in a text

2009-10-22 Thread Andrea Giammarchi


> Erm, the braces are meant to go *around* the variable, not around a bit
> of it:
> 
> print "Test: {$var[0][0]}";

unrelated, just another usage of curly brackets

$_ = 'abc';
$i  = 0;
echo $_{++$i}; // b

Regards
  
_
Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail 
you.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092010

Re: [PHP] how call a variable in a text

2009-10-22 Thread Thodoris



Erm, the braces are meant to go *around* the variable, not around a 
bit of it:


print "Test: {$var[0][0]}";

Thanks,
Ash
http://www.ashleysheridan.co.uk




In many cases braces can go around the variable name not the necessarily 
around the whole variable (like the bash scripts). Those are coming from 
the manual:




function test() {
   // NULL -- not what initially expected
   $string = '_POST';
   var_dump(${$string});

   // Works as expected
   var_dump(${'_POST'});

   // Works as expected
   global ${$string};
   var_dump(${$string});

}

So no they are not meant to go around. You can use them this way as well.

--
Thodoris



RE: [PHP] how call a variable in a text

2009-10-22 Thread Andrea Giammarchi

Curly brackets are usually highlighted as well so it is a good practice, 
generally speaking, to use them for double quoted strings and maintainability 
increase automatically.

Regards

> From: esam...@barc.gov.in
> To: php-general@lists.php.net
> Date: Thu, 22 Oct 2009 11:31:53 +0530
> Subject: RE: [PHP] how call a variable in a text
> 
> This is always safe to use variables like this...
> 
> $text = "This is " . $variable;
> 
> Or
> 
> $text = "This is " . $variable[0];
> 
> Regards,
> 
> Samrat Kar
> FRD, BARC
> 
> Tel: 022-25597295
> Alternate Email: esam...@yahoo.com
> 
> 
> -Original Message-
> From: Kim Madsen [mailto:php@emax.dk] 
> Sent: Thursday, October 22, 2009 2:25 AM
> To: a...@ashleysheridan.co.uk
> Cc: David Murphy; php-general@lists.php.net
> Subject: Re: [PHP] how call a variable in a text
> 
> Ashley Sheridan wrote on 2009-10-21 22:43:
> 
> > The {} only become really useful when you're trying to reference arrays
> > within a string:
> > 
> > $var = array('great', 'boring');
> > 
> > $text = "this is {$var[0]}.";
> > 
> > Without the curly braces, PHP wouldn't be able to figure out whether you
> > wanted the end string to be 'This is great.' or 'This is [0].' despite
> > the variable itself clearly being an array.
> 
> Ehh what? This has never been a problem for me:
> 
> $text = "this is $var[0].";
> 
> However this does give an error (or notice, don't recall, haven't seen 
> the error in quite a while):
> 
> $text = "this is $var['0'].";
> 
> In that case the solution is the curly brackets:
> 
> $text = "this is {$var['0']}.";
> 
> -- 
> Kind regards
> Kim Emax - masterminds.dk
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> No virus found in this incoming message.
> Checked by AVG - www.avg.com 
> Version: 8.5.423 / Virus Database: 270.14.25/2450 - Release Date: 10/21/09
> 16:44:00
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
  
_
Windows Live Hotmail: Your friends can get your Facebook updates, right from 
Hotmail®.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009

Re: [PHP] how call a variable in a text

2009-10-22 Thread Ashley Sheridan
On Thu, 2009-10-22 at 09:53 +0300, Thodoris wrote:

> > On Wed, 2009-10-21 at 23:11 +0200, Kim Madsen wrote:
> >
> >   
> >> Ashley Sheridan wrote on 2009-10-21 22:56:
> >>
> >> 
> >>> Try this though:
> >>>
> >>>  >>>
> >>> $var = array(array('great','alright'), 'boring');
> >>>
> >>> print "This is $var[0][0].";
> >>>   
> >> Print "This is different from your previous example :-)";
> >>
> >> -- 
> >> Kind regards
> >> Kim Emax - masterminds.dk
> >>
> >> 
> >
> >
> > Yeah, I just forgot that PHP will correctly work with an array to a
> > depth of 1 inside of a string. Much like the above advice, I'd taken to
> > always using {} for arrays inside of strings, although not for strings
> > inside of strings unless I needed non-white-space text to immediately
> > follow said string. Would make more sense if I used the braces for
> > everything, but nobody has ever accused me of making too much sense
> > before!
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
> >   
> 
> This will also work (shell like style):
> 
> print "Test: ${var[0]}";
> 
> but this won't based on the same principle you mention above:
> 
> print "Test: ${var[0][0]}";
> 

Erm, the braces are meant to go *around* the variable, not around a bit
of it:

print "Test: {$var[0][0]}";

Thanks,
Ash
http://www.ashleysheridan.co.uk