[PHP] Re: How could i do this on CURL?

2008-02-06 Thread Louie Miranda
BTW,

I just have read your script. I'll try it tomorrow. Looks like it will work
for me.

Louie

On Feb 6, 2008 3:33 PM, Louie Miranda [EMAIL PROTECTED] wrote:

 It ain't easy. I have also read the FAQ of cURL
 http://curl.haxx.se/docs/faq.html#Can_I_use_curl_to_send_a_POST_PU

 3.18 Can I use curl to send a POST/PUT and not wait for a response?
  No.
  But you could easily write your own program using libcurl to do such
  stunts.
 

 Although, i was able to write my own PHP App. I did use PEAR Net_Curl BTW.

 ?php
 .

 $incomingAId = $_POST['a_id'];
 $incomingATrackingId = $_POST['a_tracking_id'];

 LogResults(On Access);

 // Validate if empty, execute if not
 if (!empty($incomingAId) || !empty($incomingATrackingId))
 {
 SendResponse();
 }
 else
 {
 Initiate();
 }


 function Initiate()
 {
 // Initiate
 $curl =  new Net_Curl(https://test.example.com/Servlet;);
 $result = $curl-create();

 if (!PEAR::isError($result)) {

 // Set other options here with Net_Curl::setOption()
 $params = a_id=1234app_name=carta_tracking_id=111;

 $curl-setOption(CURLOPT_COOKIEJAR, cookieFile.txt);
 $curl-setOption(CURLOPT_POST, 1);
 $curl-setOption(CURLOPT_POSTFIELDS, $params);

 $result = $curl-execute();
 if (!PEAR::isError($result)) {
 //echo $result.\n;
 } else {
 //echo $result-getMessage().\n;
 }

 $curl-close();
 } else {
 //echo $result-getMessage().\n;
 }
 }

 function SendResponse()
 {
 LogResults(SendResponse);

 // Initiate
 $curl =  new Net_Curl(https://test.example.com/Servlet;);
 $result = $curl-create();

 if (!PEAR::isError($result)) {

 $xmlSubmission = '?xml version=1.0?';
 $xmlSubmission .= 'collection_request';
 $xmlSubmission .= 'response_message value=Request /';
 $xmlSubmission .= '/collection_request';

 $postedTraffic = XML=.$xmlSubmission.;

 $curl-setOption(CURLOPT_RETURNTRANSFER, 1);
 $curl-setOption(CURLOPT_COOKIEFILE, cookieFile.txt);
 $curl-setOption(CURLOPT_POSTFIELDS, $postedTraffic);

 $result = $curl-execute();
 if (!PEAR::isError($result)) {
 //echo $result.\n;
 } else {
 //echo $result-getMessage().\n;
 }

 $curl-close();
 } else {
 //echo $result-getMessage().\n;
 }
 }

 ..
 ?


 On Feb 6, 2008 9:17 AM, Manuel Lemos [EMAIL PROTECTED] wrote:

  Hello,
 
  on 02/05/2008 10:34 PM Louie Miranda said the following:
   I was able to create a working CURL connection and it was great.
  
   Although, i have another problem.
  
  
  1. file: connect - I connect via a CURL to a URL and sends two
  parameters (application, just wait and hangs) -- this is
  intentional
  2. file: connect - Receives a reply of the two parameters that i
  had
  just sent
  3. file: connect - sends a XML post to the remote url (remote url,
  closes the connection and application)
  
   Could i send two CURL request in one instance? while waiting?
 
  I am not sure how to do that in a simple way with Curl. The few times I
  have used Curl directly, I used custom HTTP requests instead of other
  options.
 
  Nowadays I use this HTTP client class that wraps the complexity of the
  HTTP protocol and uses preferrably fsockopen to send HTTP requests. Take
  a look the test_http_soap.php example which seems to do something
  similar to what you want:
 
  http://www.phpclasses.org/httpclient
 
 
  --
 
  Regards,
  Manuel Lemos
 
  PHP professionals looking for PHP jobs
  http://www.phpclasses.org/professionals/
 
  PHP Classes - Free ready to use OOP components written in PHP
  http://www.phpclasses.org/
 



 --
 Louie Miranda ([EMAIL PROTECTED])
 http://www.axishift.com

 Security Is A Series Of Well-Defined Steps
 chmod -R 0 / ; and smile :)




-- 
Louie Miranda ([EMAIL PROTECTED])
http://www.axishift.com

Security Is A Series Of Well-Defined Steps
chmod -R 0 / ; and smile :)


Re: [PHP] Doctrine vs. Propel

2008-02-06 Thread AmirBehzad Eslami
Thank you all for your kind replies.


Re: [PHP] Anyone else doing PHP on Symbian?

2008-02-06 Thread Peter Ford
Paul Scott wrote:
 On Tue, 2008-02-05 at 13:29 -0500, Daniel Brown wrote:
   Still debating what
 device I'll get next, but I want to use it as a mobile server myself.
 I had been working on a bound-for-trash PDA doing the same a while
 back, but with what we'll refer to as limited results.
 
 I think that the key here is 
 
 1. A decent ARM processor and a PHP build for ARM specifically (new
 project??)
 
 2. Enough RAM to be useful - at least figure out how to use a SD card or
 something as a RAMDisk and use like a 2GB card?
 
 3. Getting an entire LAMP stack on there as a package - no use messing
 with things - otherwise people won't use it.
 
 Just think of the possibilities though... I do a lot in the eLearning
 sphere in PHP, and this type of thing could be a mobile eLearning server
 for rural schools in Africa that is actually affordable! Students could
 connect to it via thin clients or mobile phones and get an education all
 in one.
 

To be honest Paul, I think you'd find that an EeePC would be cheaper than a
sufficiently well-specced PDA, especially given the time and effort required for
the key points you describe. An EeePC already runs Linux, with a decent
processor, reasonable disk space and good connectivity options, so a LAMP
stack ought to be easy.

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



Re: [PHP] QNX build

2008-02-06 Thread Richard

Jochem Maas used his keyboard to write :

Richard schreef:

Jochem Maas was thinking very hard :

Richard schreef:

Jochem Maas wrote :

Richard schreef:

Hi,

After installing PHP on a Windows machine I see a very small 
PHP-executable and several extension dll's that can be loaded.


When I build PHP on a QNX machine I get one huge executable of 8.6 MB. 
Is it possible to build something similar to the Windows version?


yes, by specifying to ./configure that it should build shared extensions
or those extensions that allow it. so the relevant ./configure options
will look something like:

--enable-foo=shared,/path/to/libs

I tried that but it didn't work.


didn't work in what way?


It is still one binary of 8.6 MB and no shared libs.





what's your configure line look like right now?

PS - I'd never heard of QNX - just looked it up - interested to know 
what your

doing with it and php.
I have an embedded system with an sqlite database. I want a web interface 
that shows database info and maybe system info.


cool :-)



PPS - Is a single large binary any worse than a smaller binary that 
loads
in a bunch of extensions (assuming the same extensions in each case), 
won't

the memory footprint be near enough the same for each?
It seems that my system has a problem with loading large binaries. It 
would be nice if I could decide in the ini file which extensions will be 
loaded (I am not sure which extensions I need).
I use the shttpd web server. This one does not support fast cgi. Loading 
a large cgi interpreter each time slows down my system.


ok - seems like you will only be needing a small subset of the available 
extensions.
have you tried using --disable-all and then only enabling the extensions 
you really

need, It may get the binary size down to a usable level.



When I use the option --disable-all the binary is about 5 MB. Which is much 
too large.
An option could be not to use php but perl. This binary is 1 MB. But I 
think the best option is a web server with fast cgi.


Removing the debugging symbols and enabling the extensions I need gives 
me a binary of 2.7 MB which is already better.




lighthttpd?


It took me a while to port lighttpd + libs but it is just what I am 
looking for.

Thanks a lot.










Regards,

Richard







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



RE: [PHP] string vs number

2008-02-06 Thread Ford, Mike
On 05 February 2008 21:37, Jochem Maas advised:

 the same is not exactly true for floats - although you can
 use them as array keys you'll
 notice in the output of code below that they are stripped of
 their decimal part (essentially
 a floor() seems to be performed on the float value. I have no
 idea whether this is intentional,
 and whether you can therefore rely on this behaviour:

Yes, and Yes!

From http://php.net/language.types.array:

 A key may be either an integer or a string. If a key is the
 standard representation of an integer, it will be interpreted
 as such (i.e. 8 will be interpreted as 8, while 08 will
 be interpreted as 08). Floats in key are truncated to
 integer.

 --
Mike Ford,  Electronic Information Services Adviser,
JG125, The Headingley Library,
James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730  Fax:  +44 113 812 3211


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



[PHP] PHP Source code protection

2008-02-06 Thread Zoran Bogdanov
Hi,

I'm building a C# application that connects to a server that has PHP scripts 
on it.

We need to deliver the complete solution to a firm, the C# is no problem 
because it is compiled...

But PHP is a problem bacause it is interpreted and we will have to deliver 
pure, unprotected script...

Is htere a way to secoure my code so when they put it on the server, they 
can't see it!

Thank You! 

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



[PHP] date() and wrong timezone (or time)

2008-02-06 Thread Martin Marques
I got an update from tzdata on a Debian server due to a daylight saving 
change here in Argentina.


The problem is that, even when the system sees the correct time, php 
keeps giving me the *old* hour.


$ date
mié feb  6 09:03:57 ARST 2008
$ echo ?php echo date('H:i') . \\n\; ?|php5
08:04

What can my problem be?


BTW, I did a useless reboot (I knew it wouldn't help at all, but I did 
it anyway).


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



Re: Re: [PHP] New search related question

2008-02-06 Thread Aschwin Wesselius


On Feb 4, 2008 2:48 PM, Jason Pruim [EMAIL PROTECTED] wrote:
I got bored, so I wrote out a system to handle it.  Let me know if you want the 
source when it's done.

Hi everybody,

I'm new to the list, but am currently working on a project where I could 
use some HTML-searching stuff too. I'm not quite clever at search 
algorithms, so if someone could point me to some basic functionality, 
that would be great.


Thanks in advance.

Aschwin Wesselius

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



Re: [PHP] PHP Source code protection

2008-02-06 Thread Richard Heyes
I'm building a C# application that connects to a server that has PHP scripts 
on it.


We need to deliver the complete solution to a firm, the C# is no problem 
because it is compiled...


But PHP is a problem bacause it is interpreted and we will have to deliver 
pure, unprotected script...


Is htere a way to secoure my code so when they put it on the server, they 
can't see it!


There's the Zend Encoder at www.zend.com. Though it may be called 
something else now.


--
Richard Heyes
http://www.websupportsolutions.co.uk

Knowledge Base and Helpdesk software for £299 hosted for you -
no installation, no maintenance, new features automatic and free

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



Re: [PHP] string vs number

2008-02-06 Thread Jochem Maas

Ford, Mike schreef:

On 05 February 2008 21:37, Jochem Maas advised:


the same is not exactly true for floats - although you can
use them as array keys you'll
notice in the output of code below that they are stripped of
their decimal part (essentially
a floor() seems to be performed on the float value. I have no
idea whether this is intentional,
and whether you can therefore rely on this behaviour:


Yes, and Yes!

From http://php.net/language.types.array


ah yes, I should have looked it up, that said I find it rather odd that
is works let alone that it's intentional.

though thinking about it you could probably use it for some float val
distribution counting or something. I dunno, seems like it offers a handy
shortcut - although what that shortcut is escapes me just now :-)




A key may be either an integer or a string. If a key is the
standard representation of an integer, it will be interpreted
as such (i.e. 8 will be interpreted as 8, while 08 will
be interpreted as 08). Floats in key are truncated to
integer.


 --
Mike Ford,  Electronic Information Services Adviser,
JG125, The Headingley Library,
James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730  Fax:  +44 113 812 3211


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm




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



Re: [PHP] PHP CLI Problem

2008-02-06 Thread Jochem Maas

Robbert van Andel schreef:

I am having trouble with a PHP CLI script I wrote to help manage my website.
The site is on a shared hosting server where the PHP installation is set up
as a CGI.  The script creates some backups of my databases and sends them to
Amazon's S3 service.  


First off, the script runs great from the command line when I type php5
backup.php but when I type ./backup.php I get an error: bash:
./backup.php: No such file or directory.  


is the script marked as executable?


I thought maybe this is a problem
with the top declaration in the script #!/usr/local/bin/php5. The problem
is that it appears the server has several php5s I can reference

/usr/local/apache/share/cgi-bin/php5
/usr/local/bin/php5


to determine which php5 you are using type:

$ which php5

this gives you the full path, which you will need to use in the relevant
cron line (and/or the shebang line at the top of the script) - cron requires 
fullpaths.



But it doesn't matter which one I put at the top of the script, I get the
same error.

Okay, so I can live with having to type php5 backup.php.  However, when I
try to make a cron job from the script, the script never runs.  The crontab
entry looks like this
1 0 * * 2 php5
/kunden/homepages/23/d117947228/htdocs/oregonswimming/administration/backup/
backup.php  backup.log

I know the backup never runs because I redirect the output to a file and
have an email sent to me upon conclusion of the script.  The log file
doesn't show anything nor do I ever receive an email.  My web host will not
provide any support for scripting, so I'm hoping someone here can help.

Questions:
* How do I determine what to put at the top of the script so that I can just
call backup.php?
* What, if anything, do I need to do to make the script work from cron?

I've seen some comments on the web regarding PHP CLI when PHP is a CGI, but
none of them seem to apply to me.  


Thank you in advance for your help.

Robbert



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



[PHP] Recommended ORM for PHP

2008-02-06 Thread js
Hi list,

When creating a LAMP app, I always start by writing ORM myself.
It's fun but it usually takes a  long time.
Besides, that always results in a toy-system,
I mean, that has not so many features, not so efficient non-bug-free.

I started to think that now is the time  to throw away my rubbish
and use more effective Open source ORM.

So my  question is what ORM are you using?
What ORM do you recommend?
There're lots of Web app frameworks out there
but I could't find simple ORM in PHP.

Thanks in advance.

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



Re: [PHP] Recommended ORM for PHP

2008-02-06 Thread Zoltán Németh
2008. 02. 6, szerda keltezéssel 22.10-kor js ezt írta:
 Hi list,
 
 When creating a LAMP app, I always start by writing ORM myself.
 It's fun but it usually takes a  long time.
 Besides, that always results in a toy-system,
 I mean, that has not so many features, not so efficient non-bug-free.
 
 I started to think that now is the time  to throw away my rubbish
 and use more effective Open source ORM.
 
 So my  question is what ORM are you using?
 What ORM do you recommend?
 There're lots of Web app frameworks out there
 but I could't find simple ORM in PHP.

check out doctrine:
http://trac.phpdoctrine.org/
or propel:
http://propel.phpdb.org/trac/

however, these are not 'simple' ORMs.
in my opinion, doctrine is great, with lots of features and cool
documentation, but it's still heavily under development, so not at all
stable. on the other hand, propel is stable, but lacks some of
doctrine's best features (inheritance, query-result caching, etc)

greets
Zoltán Németh

 
 Thanks in advance.
 

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



RE: [PHP] Recommended ORM for PHP

2008-02-06 Thread Edward Kay

 When creating a LAMP app, I always start by writing ORM myself.
 It's fun but it usually takes a  long time.
 Besides, that always results in a toy-system,
 I mean, that has not so many features, not so efficient non-bug-free.

 I started to think that now is the time  to throw away my rubbish
 and use more effective Open source ORM.

 So my  question is what ORM are you using?
 What ORM do you recommend?
 There're lots of Web app frameworks out there
 but I could't find simple ORM in PHP.

 Thanks in advance.


Have a look at Qcodo. http://www.qcodo.com.

It uses code generation to create your ORM for you direct from the DB
tables. As it's code generation as opposed to run time analysis (which is
what ActiveRecord and the like use), there is no performance hit - it
literally just creates your PHP class files for you.

There is a framework aspect to Qcodo called QForms but this is decoupled
from the generated ORM so you don't have to use it if you don't want it.

HTH,
Edward

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



[PHP] Re: PEAR website and MSIE 6

2008-02-06 Thread Michelle Konzack
Am 2008-01-31 13:16:51, schrieb Nathan Nobbe:
 it doesnt let you reclaim lost tabs.  nor does it save the tabs for the next
 time you
 open it.  i have to pkill ff or similar to get it to ask if i want to
 restore the session.
 opera just does it.

Thats not right, since I can save the current tabs and if I reopen
firefox OR iceape they are restored.  Also I have a TAB history,
which let me reopen closed tabs...

Note:   Opera is no solution since it does not
run on sparc, arm or mips...

Thanks, Greetings and nice Day
Michelle Konzack
Systemadministrator
Tamay Dogan Network
Debian GNU/Linux Consultant


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


signature.pgp
Description: Digital signature


RE: [PHP] PHP CLI Problem

2008-02-06 Thread Robbert van Andel
Thank you, that was very helpful.  I created a perl script because the shell
script wouldn't run either.  It too gave an error stating the file or
directory could not be found.  The perl script runs a shell command from
within it to run backup.php.  Manual tests show that that works, I put it in
a cron job and am confident that it will run. 

Robbert

-Original Message-
From: Chris [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 05, 2008 11:06 PM
To: Robbert van Andel
Cc: php-general@lists.php.net
Subject: Re: [PHP] PHP CLI Problem


 First off, the script runs great from the command line when I type php5
 backup.php but when I type ./backup.php I get an error: bash:
 ./backup.php: No such file or directory.

Maybe backup.php that you think it's running is the wrong one.

Add something like:

echo I am file  . __FILE__ . \n;

in your backup.php file and see if that's printed out when you run php5 
backup.php.

If it's not, then you're editing the wrong file.

  I thought maybe this is a problem
 with the top declaration in the script #!/usr/local/bin/php5.

If you have that as the first line, then you should just need to chmod 
+x the backup.php file.

 The problem
 is that it appears the server has several php5s I can reference
 
 /usr/local/apache/share/cgi-bin/php5
 /usr/local/bin/php5

Ask your host which is the right one (99% sure it'll be 
/usr/local/bin/php5).

 Questions:
 * How do I determine what to put at the top of the script so that I can
just
 call backup.php?

What difference does it make whether the full path is included in the 
cron job or not? You need to use the full path somewhere (whether it's 
in the cron job or in a shell script).

You could create a shell script:

#!/bin/bash
/usr/local/bin/php5 -f /path/to/backup.php

chmod +x the new script.

Call that instead in cron.

 * What, if anything, do I need to do to make the script work from cron?

Use the full path to php, use the full path to your backup.php file.

-- 
Postgresql  php tutorials
http://www.designmagick.com/

-- 
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] PHP Source code protection

2008-02-06 Thread Bastien Koert

zend encoder?
 http://sourceforge.net/projects/php-screw/
 
 
google for more
 
 
 
bastien To: php-general@lists.php.net From: [EMAIL PROTECTED] Date: Wed, 6 
Feb 2008 12:28:12 +0100 Subject: [PHP] PHP Source code protection  Hi,  
I'm building a C# application that connects to a server that has PHP scripts  
on it.  We need to deliver the complete solution to a firm, the C# is no 
problem  because it is compiled...  But PHP is a problem bacause it is 
interpreted and we will have to deliver  pure, unprotected script...  Is 
htere a way to secoure my code so when they put it on the server, they  can't 
see it!  Thank You!   --  PHP General Mailing List (http://www.php.net/) 
To unsubscribe, visit: http://www.php.net/unsub.php 
_



Re: [PHP] Re: PEAR website and MSIE 6

2008-02-06 Thread Nathan Nobbe
On Feb 2, 2008 12:51 PM, Michelle Konzack [EMAIL PROTECTED] wrote:

 Am 2008-01-31 13:16:51, schrieb Nathan Nobbe:
  it doesnt let you reclaim lost tabs.  nor does it save the tabs for the
 next
  time you
  open it.  i have to pkill ff or similar to get it to ask if i want to
  restore the session.
  opera just does it.

 Thats not right, since I can save the current tabs and if I reopen
 firefox OR iceape they are restored.  Also I have a TAB history,
 which let me reopen closed tabs...


you must be aware of some feature that i am not.
note however, that opera requires no external intervention to
make these features work.
if this is what youre talking about
https://addons.mozilla.org/en-US/firefox/addon/1859
ill check it out, but it will have a hard time competing w/ operas
elegance.


 Note:   Opera is no solution since it does not
run on sparc, arm or mips...


looks like the download page has linux sparc and solaris
sparc..
http://www.opera.com/download/index.dml?custom=yes

and if you get into embedded stuff, arm and mips are there
http://www.opera.com/products/devices/technology/sdk/specs/index.dml
x86, MIPS, ARM, xScale, PowerPC, ST Micro,
Sigma Designs, Freescale, ATI, AMD, Texas Instruments

and ff doesnt have an embedded browser that im aware of either.

-nathan


RE: [PHP] PHP CLI Problem

2008-02-06 Thread Robbert van Andel
I guess I spoke too soon.  Even though the script runs from anywhere (that I
have access too), when I put the perl script in a cronjob, the php script
just refuses to run.  There's no output, just the output from the perl
script.  And yes, I did set up the perl script to print the output of the
php script.  Any ideas?  Is there some special consideration I have to give
to the fact that my PHP installation is setup as a CGI?  I've never had this
much trouble getting a PHP CLI script to run.

Robbert

-Original Message-
From: Robbert van Andel [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 06, 2008 6:14 AM
To: php-general@lists.php.net
Subject: RE: [PHP] PHP CLI Problem

Thank you, that was very helpful.  I created a perl script because the shell
script wouldn't run either.  It too gave an error stating the file or
directory could not be found.  The perl script runs a shell command from
within it to run backup.php.  Manual tests show that that works, I put it in
a cron job and am confident that it will run. 

Robbert

-Original Message-
From: Chris [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 05, 2008 11:06 PM
To: Robbert van Andel
Cc: php-general@lists.php.net
Subject: Re: [PHP] PHP CLI Problem


 First off, the script runs great from the command line when I type php5
 backup.php but when I type ./backup.php I get an error: bash:
 ./backup.php: No such file or directory.

Maybe backup.php that you think it's running is the wrong one.

Add something like:

echo I am file  . __FILE__ . \n;

in your backup.php file and see if that's printed out when you run php5 
backup.php.

If it's not, then you're editing the wrong file.

  I thought maybe this is a problem
 with the top declaration in the script #!/usr/local/bin/php5.

If you have that as the first line, then you should just need to chmod 
+x the backup.php file.

 The problem
 is that it appears the server has several php5s I can reference
 
 /usr/local/apache/share/cgi-bin/php5
 /usr/local/bin/php5

Ask your host which is the right one (99% sure it'll be 
/usr/local/bin/php5).

 Questions:
 * How do I determine what to put at the top of the script so that I can
just
 call backup.php?

What difference does it make whether the full path is included in the 
cron job or not? You need to use the full path somewhere (whether it's 
in the cron job or in a shell script).

You could create a shell script:

#!/bin/bash
/usr/local/bin/php5 -f /path/to/backup.php

chmod +x the new script.

Call that instead in cron.

 * What, if anything, do I need to do to make the script work from cron?

Use the full path to php, use the full path to your backup.php file.

-- 
Postgresql  php tutorials
http://www.designmagick.com/

-- 
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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Poll: phpt or phpunit and why?

2008-02-06 Thread js
HI,

When writing tests, do you use phpt or phpunit? (or another one?)
Why do you use that one?
Let's share the idea.

I like both, but when I write simple tests, I prefer to  use phpt
because it's less code and easy to write.
I use phpunit for tests of complex classes.
I can do that with phpt, but to me phptunit is more easy to understand
what the test is doing.

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



Re: [PHP] date() and wrong timezone (or time)

2008-02-06 Thread Nathan Nobbe
On Feb 6, 2008 6:13 AM, Martin Marques [EMAIL PROTECTED] wrote:

 I got an update from tzdata on a Debian server due to a daylight saving
 change here in Argentina.

 The problem is that, even when the system sees the correct time, php
 keeps giving me the *old* hour.

 $ date
 mié feb  6 09:03:57 ARST 2008
 $ echo ?php echo date('H:i') . \\n\; ?|php5
 08:04

 What can my problem be?


see what you have as the value for the date.timezone ini setting.

-nathan*

*


Re: [PHP] PHP CLI Problem

2008-02-06 Thread Nathan Nobbe
On Feb 6, 2008 9:36 AM, Robbert van Andel [EMAIL PROTECTED] wrote:

 I guess I spoke too soon.  Even though the script runs from anywhere (that
 I
 have access too), when I put the perl script in a cronjob, the php script
 just refuses to run.  There's no output, just the output from the perl
 script.  And yes, I did set up the perl script to print the output of the
 php script.  Any ideas?  Is there some special consideration I have to
 give
 to the fact that my PHP installation is setup as a CGI?  I've never had
 this
 much trouble getting a PHP CLI script to run.


there are 2 ways to run a php cli script.  the first is to prefix the name
of the script
with php; eg
php backup.php

if you are specifying this in a cron job, you will have to supply the full
path to the php
interpreter, which you can find via
which php
(sorry jocheem, i know you already said that, but my system doesnt have
php5, only
php [even though its 5] so i thought id mention it again)

that is the way i prefer to do it but i wont elaborate as there is no point
now.
the second way is to make the script executable; this is a 2 step process.
the first step
is to prefix the contents of the file with
#!/path/to/php/binary
where the path is the same as earlier, found via the which command.  the
second step is
to mark the script as executable, hopefully you are familiar enough to do
that yourself,
but just to test it as the user who created it, you can do simply,
chmod u+x backup.php

i suspect in your case the cron job doesnt know the path to the php binary,
ive encountered
this before; although its strange its still occurring within the perl
script; however i cant help you
with that ;)

o, btw; here is the relevant page in the manual
http://us2.php.net/manual/en/features.commandline.php

-nathan


Re: [PHP] Poll: phpt or phpunit and why?

2008-02-06 Thread Nathan Nobbe
On Feb 6, 2008 9:38 AM, js [EMAIL PROTECTED] wrote:

 HI,

 When writing tests, do you use phpt or phpunit? (or another one?)
 Why do you use that one?
 Let's share the idea.

 I like both, but when I write simple tests, I prefer to  use phpt


ive just now learned of phpt.  this would explain some of the tests i
was looking at in spl; thanks for the info!


 because it's less code and easy to write.


really, phpunit tests are pretty small; i dont think it could be  *that*
much difference.
 phpunit has some other features you may have overlooked, such
as code coverage analysis.  it will also generate test stubs as well,
via a cli argument
phpunit --skeleton

however, with phpunit, im not sure exactly how to test procedural files
or even sets of global functions.  it is really designed for testing only
classes, afaik..

-nathan


Re: [PHP] PHP Source code protection

2008-02-06 Thread C.R.Vegelin

See also:
http://www.ioncube.com/


- Original Message - 
From: Bastien Koert [EMAIL PROTECTED]

To: Zoran Bogdanov [EMAIL PROTECTED]; php-general@lists.php.net
Sent: Wednesday, February 06, 2008 2:27 PM
Subject: RE: [PHP] PHP Source code protection



zend encoder?
http://sourceforge.net/projects/php-screw/


google for more



bastien To: php-general@lists.php.net From: [EMAIL PROTECTED] Date: 
Wed, 6 Feb 2008 12:28:12 +0100 Subject: [PHP] PHP Source code protection  
Hi,  I'm building a C# application that connects to a server that has PHP 
scripts  on it.  We need to deliver the complete solution to a firm, the 
C# is no problem  because it is compiled...  But PHP is a problem bacause 
it is interpreted and we will have to deliver  pure, unprotected script... 
 Is htere a way to secoure my code so when they put it on the server, they 
 can't see it!  Thank You!   --  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] PHP CLI Problem

2008-02-06 Thread Daniel Brown
On Feb 6, 2008 1:55 AM, Robbert van Andel [EMAIL PROTECTED] wrote:
[snip]
 First off, the script runs great from the command line when I type php5
 backup.php but when I type ./backup.php I get an error: bash:
 ./backup.php: No such file or directory.  I thought maybe this is a problem
 with the top declaration in the script #!/usr/local/bin/php5. The problem
 is that it appears the server has several php5s I can reference

See my note on this paragraph later in the message.  And more
importantly, see the addendum SECURITY NOTICE at the tail-end of
this email.

 /usr/local/apache/share/cgi-bin/php5
 /usr/local/bin/php5

 But it doesn't matter which one I put at the top of the script, I get the
 same error.

In this case, use /usr/local/bin/php5, which will almost
undoubtedly be compiled as a CLI object, while the
../apache/share/cgi-bin/php5 is most likely a CGI binary or (less
likely) Apache module.  However, keep this part in mind, as with the
first paragraph, for later in the message.

 Okay, so I can live with having to type php5 backup.php.  However, when I
 try to make a cron job from the script, the script never runs.  The crontab
 entry looks like this
 1 0 * * 2 php5
 /kunden/homepages/23/d117947228/htdocs/oregonswimming/administration/backup/
 backup.php  backup.log

In your cronjob, replace the php5 entry with the following
(including the backticks):
`which php5`

If that still doesn't work, replace it simply with php, not php5:
`which php`

This allows BASh/Shell to execute the eval'd command typed within
the backticks.

 I know the backup never runs because I redirect the output to a file and
 have an email sent to me upon conclusion of the script.  The log file
 doesn't show anything nor do I ever receive an email.  My web host will not
 provide any support for scripting, so I'm hoping someone here can help.

Are you certain that the user under which the script is executed
via cron is yourself?  On rare occasions (some BSD boxes, Cobalt RaQ
RHL variants, et cetera), cron will not always run as the local user.
It may run as 'cron', 'crond', 'daemon', 'nobody', 'unpriv', 'anon',
or as whomever the sysop has it configured.

 Questions:
 * How do I determine what to put at the top of the script so that I can just
 call backup.php?

Doing that is not such a great idea, and here's where the first
two paragraphs come into play: remove the interpreter designation line
(the first line, containing the #! characters).  Make sure the script
is enclosed in ?php ? tags.  You can find scripts that written to
specifically run as crons that instead have the interpreter
designator, but it's just one more thing you'll have to manually
change when porting from one system to another, or if your host
updates their configuration.

PLUS: Keep in mind that, even when using an interpreter
designator, you *still* have to enclose your code in the ?php ? tags
(or, if short_open_tags is on, which it probably is, just use ? ?
tags).  Why?  Because PHP is set to parse *only* code between those
tags, and even if you run the CLI with the -r flag (which allows you
to run code without the ? ? tags), it will only run /one line/ of
code per call.  (See: `which php` --help  -OR-  `which php5` --help)

So if you absolutely want to run it as ./backup.php from the local
directory, or 
/kunden/homepages/23/d117947228/htdocs/oregonswimming/administration/backup/backup.php,
here are the steps to do so:

1.) chmod 755
/kunden/homepages/23/d117947228/htdocs/oregonswimming/administration/backup/backup.php
2.) Line 1 (backup.php): #!/usr/local/bin/php5 (or whatever 'which
php5' or 'which php' says - no backticks here)
3.) Enclose your code in ? ? tags, not including the interpreter
designator (first line).


 * What, if anything, do I need to do to make the script work from cron?

See above answers.


SECURITY NOTICE


Here are some things to consider in this specific situation:

1.) NEVER disclose full server path information as you did in
your email.  From that, I was easily able to discover the domain name,
based upon the fact that Oregon is a US state and swimming would
indicate the interests were most likely of a group or charitable
ORGanization.  ;-P

2.) It's always a Bad Idea[tm] to place crons of that nature
in the web path.  I was able to run the cron without the need of
logging into your admin panel, because there was no security to stop
me.  And while all it will do is create a backup of your databases in
this particular case, the output from that file also gives me *highly
sensitive*, critical information about the location of web path
information, and ABSOLUTE WORST - gives me full access to all of your
database information in plain-text, and even a convenient zip file.

ACTION ITEMS:
1.) *IMMEDIATELY* move the 'backups' directory out of the
webroot.  Place it somewhere like
/kunden/homepages/23/d117947228/db-backups/ 

Re: [PHP] PHP CLI Problem

2008-02-06 Thread Jim Lucas

Robbert van Andel wrote:

I am having trouble with a PHP CLI script I wrote to help manage my website.
The site is on a shared hosting server where the PHP installation is set up
as a CGI.  The script creates some backups of my databases and sends them to
Amazon's S3 service.  


First off, the script runs great from the command line when I type php5
backup.php but when I type ./backup.php I get an error: bash:
./backup.php: No such file or directory.  I thought maybe this is a problem
with the top declaration in the script #!/usr/local/bin/php5. The problem
is that it appears the server has several php5s I can reference

/usr/local/apache/share/cgi-bin/php5
/usr/local/bin/php5

But it doesn't matter which one I put at the top of the script, I get the
same error.

Okay, so I can live with having to type php5 backup.php.  However, when I
try to make a cron job from the script, the script never runs.  The crontab
entry looks like this
1 0 * * 2 php5
/kunden/homepages/23/d117947228/htdocs/oregonswimming/administration/backup/
backup.php  backup.log


Are you trying to add this to your /etc/crontab file directly, or are you 
issuing crontab -e from the command line?


If you are entering the above line into the crontab directly, then you are 
missing a parameter.  Between the day of the week and where you have php5, you 
need to add the user that the script is suppose to run as.


Since you are able to run the script manually, it must be something to do with 
how/where you are entering it into cron and/or the environment variables 
available to the user that your crontag launches the script as.  Maybe without a 
complete login, the cron user doesn't have the /usr/local/bin/ in its PATH ?


Just a couple thoughts.



I know the backup never runs because I redirect the output to a file and
have an email sent to me upon conclusion of the script.  The log file
doesn't show anything nor do I ever receive an email.  My web host will not
provide any support for scripting, so I'm hoping someone here can help.

Questions:
* How do I determine what to put at the top of the script so that I can just
call backup.php?
* What, if anything, do I need to do to make the script work from cron?

I've seen some comments on the web regarding PHP CLI when PHP is a CGI, but
none of them seem to apply to me.  


Thank you in advance for your help.

Robbert




--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] PHP Source code protection

2008-02-06 Thread Floor Terra
 Is htere a way to secoure my code so when they put it on the server, they
 can't see it!

Short answer: NO
Long answer NO, but:
There are some products that claim they protect your code, but they
all basicly rely on security through obscurity. A principle that is
often frowned upon by security experts. All those products make the
code harder to read, but the code is still there becouse the server
has to run it.

It all comes down to these questions:
How much do you trust your clients?
How important is your code to you?

If your code is some basic accounting database or something, just make
it clear to your clients that they are not allowed to re-use the code
(put a licence on top of each file).

If you are ashamed of your crappy code, use something like PHP Encoder
to hide this from your clients. It will probably hide all the curse
word in your comments for example.

If you really do use some hight tech, top secret  NSA crypto code.
Stop distributing your code. If someone can run your code, he/she can
view, modify and copy your code. All you can do is make it harder, but
if your code is valuable enough, someone will reverse engineer it.

Floor Terra

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



Re: [PHP] PHP Source code protection

2008-02-06 Thread Daniel Brown
On Feb 6, 2008 11:13 AM, C.R.Vegelin [EMAIL PROTECTED] wrote:
 - Original Message -
 From: Bastien Koert [EMAIL PROTECTED]
  zend encoder?
   http://sourceforge.net/projects/php-screw/
 
 
  google for more


 See also:
 http://www.ioncube.com/

All good ideas.  And in the case of Zend (and, to a lesser degree,
Ioncube), all industry standards.  The problem is, decoding/decrypting
of the files has been done with some success, so if it's that big of a
deal, consider writing your own PHP module to decode your own
proprietary encoding.

Bottom line: if all you want to do is hide the source from
prying eyes, use one of the suggestions you've received from others.
Of those, I'd endorse Zend Encoder.

-- 
/Dan

Daniel P. Brown
Senior Unix Geek
? while(1) { $me = $mind--; sleep(86400); } ?

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



Re: Re: [PHP] New search related question

2008-02-06 Thread Daniel Brown
On Feb 6, 2008 6:58 AM, Aschwin Wesselius [EMAIL PROTECTED] wrote:
 Hi everybody,

 I'm new to the list, but am currently working on a project where I could
 use some HTML-searching stuff too. I'm not quite clever at search
 algorithms, so if someone could point me to some basic functionality,
 that would be great.

 Thanks in advance.

The best way to start on the list is by not hijacking someone
else's thread.  ;-P

Just send a new email to the list with your topic in the subject
and your specific question(s) and I'm sure you'll get the answers
you're looking for pretty quickly.

And welcome to the list!

-- 
/Dan

Daniel P. Brown
Senior Unix Geek
? while(1) { $me = $mind--; sleep(86400); } ?

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



RE: [PHP] PHP CLI Problem

2008-02-06 Thread Robbert van Andel
D'oh.  I wondered why I got that email while I was driving.  Thanks for the
security tip.  I had actually planned on protecting those scripts after I
was done getting them to work.  

I removed the shebang, verified the script still works from the command line
but it still doesn't work with Cron.  I tried adding `which php5` and that
didn't work.  If I run it as php, then I'm stuck using php4, so that's not
really an option.

Cron works on the server because I have several perl scripts running through
cron with no problems.  In fact, I would probably give up on this given the
problems I'm having and write in perl, but the perl modules for Amazon's S3
service are poorly documented and I was not able to figure them out.

There are no cron logs and the output is not sent to me after a job has
completed.

-Original Message-
From: Daniel Brown [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 06, 2008 7:52 AM
To: Robbert van Andel
Cc: php-general@lists.php.net
Subject: Re: [PHP] PHP CLI Problem

On Feb 6, 2008 1:55 AM, Robbert van Andel [EMAIL PROTECTED] wrote:
[snip]
 First off, the script runs great from the command line when I type php5
 backup.php but when I type ./backup.php I get an error: bash:
 ./backup.php: No such file or directory.  I thought maybe this is a
problem
 with the top declaration in the script #!/usr/local/bin/php5. The
problem
 is that it appears the server has several php5s I can reference

See my note on this paragraph later in the message.  And more
importantly, see the addendum SECURITY NOTICE at the tail-end of
this email.

 /usr/local/apache/share/cgi-bin/php5
 /usr/local/bin/php5

 But it doesn't matter which one I put at the top of the script, I get the
 same error.

In this case, use /usr/local/bin/php5, which will almost
undoubtedly be compiled as a CLI object, while the
../apache/share/cgi-bin/php5 is most likely a CGI binary or (less
likely) Apache module.  However, keep this part in mind, as with the
first paragraph, for later in the message.

 Okay, so I can live with having to type php5 backup.php.  However, when
I
 try to make a cron job from the script, the script never runs.  The
crontab
 entry looks like this
 1 0 * * 2 php5

/kunden/homepages/23/d117947228/htdocs/oregonswimming/administration/backup/
 backup.php  backup.log

In your cronjob, replace the php5 entry with the following
(including the backticks):
`which php5`

If that still doesn't work, replace it simply with php, not php5:
`which php`

This allows BASh/Shell to execute the eval'd command typed within
the backticks.

 I know the backup never runs because I redirect the output to a file and
 have an email sent to me upon conclusion of the script.  The log file
 doesn't show anything nor do I ever receive an email.  My web host will
not
 provide any support for scripting, so I'm hoping someone here can help.

Are you certain that the user under which the script is executed
via cron is yourself?  On rare occasions (some BSD boxes, Cobalt RaQ
RHL variants, et cetera), cron will not always run as the local user.
It may run as 'cron', 'crond', 'daemon', 'nobody', 'unpriv', 'anon',
or as whomever the sysop has it configured.

 Questions:
 * How do I determine what to put at the top of the script so that I can
just
 call backup.php?

Doing that is not such a great idea, and here's where the first
two paragraphs come into play: remove the interpreter designation line
(the first line, containing the #! characters).  Make sure the script
is enclosed in ?php ? tags.  You can find scripts that written to
specifically run as crons that instead have the interpreter
designator, but it's just one more thing you'll have to manually
change when porting from one system to another, or if your host
updates their configuration.

PLUS: Keep in mind that, even when using an interpreter
designator, you *still* have to enclose your code in the ?php ? tags
(or, if short_open_tags is on, which it probably is, just use ? ?
tags).  Why?  Because PHP is set to parse *only* code between those
tags, and even if you run the CLI with the -r flag (which allows you
to run code without the ? ? tags), it will only run /one line/ of
code per call.  (See: `which php` --help  -OR-  `which php5` --help)

So if you absolutely want to run it as ./backup.php from the local
directory, or
/kunden/homepages/23/d117947228/htdocs/oregonswimming/administration/backup/
backup.php,
here are the steps to do so:

1.) chmod 755
/kunden/homepages/23/d117947228/htdocs/oregonswimming/administration/backup/
backup.php
2.) Line 1 (backup.php): #!/usr/local/bin/php5 (or whatever 'which
php5' or 'which php' says - no backticks here)
3.) Enclose your code in ? ? tags, not including the interpreter
designator (first line).


 * What, if anything, do I need to do to make the script work from cron?

See above answers.


SECURITY NOTICE


Here are some things to consider in this 

Re: [PHP] PHP CLI Problem

2008-02-06 Thread Nathan Nobbe
On Feb 6, 2008 11:33 AM, Robbert van Andel [EMAIL PROTECTED] wrote:

 I tried adding `which php5` and that didn't work.


did you try running
which php5
on the cli to ensure it even maps to a path ?  you might need
which php
instead.

-nathan


RE: [PHP] PHP CLI Problem

2008-02-06 Thread Robbert van Andel
Not an option.  Which php gives me php4 and the script requires php5.

 

From: Nathan Nobbe [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 06, 2008 8:39 AM
To: Robbert van Andel
Cc: Daniel Brown; php-general@lists.php.net
Subject: Re: [PHP] PHP CLI Problem

 

On Feb 6, 2008 11:33 AM, Robbert van Andel [EMAIL PROTECTED] wrote:

I tried adding `which php5` and that didn't work.


did you try running

which php5

on the cli to ensure it even maps to a path ?  you might need

which php

instead.

-nathan

 



Re: [PHP] PHP CLI Problem

2008-02-06 Thread Nathan Nobbe
On Feb 6, 2008 11:42 AM, Robbert van Andel [EMAIL PROTECTED] wrote:

  Not an option.  Which php gives me php4 and the script requires php5.


it sounds like you are using 11, per dans security warning earlier :)
you may want to contact them and ask them how to run php5 scripts
via the cli; as i know they allow usage of both 4 and 5 from the webserver,
which is configurable via .htaccess directives.
and, btw, if you do find out, let us know; i for one am curious how they are
doing this (if at all..).

-nathan


Re: [PHP] date() and wrong timezone (or time)

2008-02-06 Thread Martin Marques

Nathan Nobbe escribió:

On Feb 6, 2008 6:13 AM, Martin Marques [EMAIL PROTECTED] wrote:


I got an update from tzdata on a Debian server due to a daylight saving
change here in Argentina.

The problem is that, even when the system sees the correct time, php
keeps giving me the *old* hour.

$ date
mié feb  6 09:03:57 ARST 2008
$ echo ?php echo date('H:i') . \\n\; ?|php5
08:04

What can my problem be?



see what you have as the value for the date.timezone ini setting.


I've already checked that, and it's not set.

Anyway, I found out that PHP uses an internal tz database (very bad 
IMHO) and it might be out of date.


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



Re: [PHP] PHP CLI Problem

2008-02-06 Thread Nathan Nobbe
On Feb 6, 2008 11:48 AM, Robbert van Andel [EMAIL PROTECTED] wrote:

  I contacted 11 and was told scripting was not supported.  I wrote back
 saying I didn't need help writing the script just how to run it. They wrote
 back telling me to put it in a cron job using crontab –e and that was all
 **rolls eyes**.   Perhaps a call will give me the answers I need.

rob, please keep list topics on list for the benefit of others.
if you dont get the answer you looking for; allow me to propose
a dirty workaround.
put the script in the webroot; then you can invoke it from cron
using curl; i imagine they have that installed.  you can protect
the script with the following as the first line
if($_SERVER['REMOTE_ADDR'] !== '127.0.0.1') { die; }

then you could hit if from cron as in
`which curl` http://localhost/backup.php

im now waiting for what will surely be moments for another member
of the list to hack this idea to pieces ;)
but it was fun to think up!

-nathan


Re: [PHP] date() and wrong timezone (or time)

2008-02-06 Thread Nathan Nobbe
On Feb 6, 2008 12:13 PM, Martin Marques [EMAIL PROTECTED] wrote:

  see what you have as the value for the date.timezone ini setting.

 I've already checked that, and it's not set.


then you should probly set it ;)

Anyway, I found out that PHP uses an internal tz database (very bad
 IMHO) and it might be out of date.


what is a better alternative in your opinion; i dont know much about any
alternatives..

-nathan


Re: [PHP] PHP CLI Problem

2008-02-06 Thread Daniel Brown
On Feb 6, 2008 12:25 PM, Nathan Nobbe [EMAIL PROTECTED] wrote:
 put the script in the webroot; then you can invoke it from cron
 using curl; i imagine they have that installed.  you can protect
 the script with the following as the first line
 if($_SERVER['REMOTE_ADDR'] !== '127.0.0.1') { die; }

 then you could hit if from cron as in
 `which curl` http://localhost/backup.php

 im now waiting for what will surely be moments for another member
 of the list to hack this idea to pieces ;)
 but it was fun to think up!

No, it's a valid idea, Nate.  However, additional suggestions when
going this route:

1.) Stop all public output from the script, regardless of whether
or not it's only allowed by localhost.
2.) Still, move the databases and backups out of the web root.
3.) Instead of using `which curl` in the cron, use the *nix-only
GET command (case sensitive).

-- 
/Dan

Daniel P. Brown
Senior Unix Geek
? while(1) { $me = $mind--; sleep(86400); } ?

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



Re: [PHP] date() and wrong timezone (or time)

2008-02-06 Thread Martin Marques

Nathan Nobbe escribió:

On Feb 6, 2008 12:13 PM, Martin Marques [EMAIL PROTECTED] wrote:


see what you have as the value for the date.timezone ini setting.

I've already checked that, and it's not set.



then you should probly set it ;)


It has the right TZ set. I checked it with date_default_timezone_get().
I changed the system wide TZ to a zone that has the -2 TZ and it works
now, but it's a lousy solution



Anyway, I found out that PHP uses an internal tz database (very bad

IMHO) and it might be out of date.



what is a better alternative in your opinion; i dont know much about any
alternatives..


How about use the tzdata that is already installed is the system?

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



Re: [PHP] date() and wrong timezone (or time)

2008-02-06 Thread Andrew Ballard
On Feb 6, 2008 12:48 PM, Martin Marques [EMAIL PROTECTED] wrote:
 Nathan Nobbe escribió:
  On Feb 6, 2008 12:13 PM, Martin Marques [EMAIL PROTECTED] wrote:
 
  see what you have as the value for the date.timezone ini setting.
  I've already checked that, and it's not set.
 
 
  then you should probly set it ;)

 It has the right TZ set. I checked it with date_default_timezone_get().
 I changed the system wide TZ to a zone that has the -2 TZ and it works
 now, but it's a lousy solution

 
  Anyway, I found out that PHP uses an internal tz database (very bad
  IMHO) and it might be out of date.
 
 
  what is a better alternative in your opinion; i dont know much about any
  alternatives..

 How about use the tzdata that is already installed is the system?


It just depends. PHP5 had the latest time zone data for the US (that
changed in 2007) long before the necessary updates were applied on any
of our systems (Windows or *nix). I'm not sure if that was because the
OS updates weren't available yet or perhaps they simply had not been
applied, but in that case it was sure nice that PHP handled the dates
correctly regardless of the OS. That said, I can certainly see an
advantage to having everything run from a well updated OS.

Andrew


Re: [PHP] Recommended ORM for PHP

2008-02-06 Thread Greg Donald
On 2/6/08, Edward Kay [EMAIL PROTECTED] wrote:
 It uses code generation to create your ORM for you direct from the DB
 tables. As it's code generation as opposed to run time analysis (which is
 what ActiveRecord and the like use), there is no performance hit - it

ActiveRecord caches the fields query in production.  A one-time query
to discover the field types is not a performance hit.


-- 
Greg Donald
http://destiney.com/

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



Re: [PHP] PHP Source code protection

2008-02-06 Thread Greg Donald
On 2/6/08, Richard Heyes [EMAIL PROTECTED] wrote:
 There's the Zend Encoder at www.zend.com. Though it may be called
 something else now.

Pointless.

http://www.phprecovery.com/


-- 
Greg Donald
http://destiney.com/

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



Re: [PHP] PHP Source code protection

2008-02-06 Thread Greg Donald
On 2/6/08, Greg Donald [EMAIL PROTECTED] wrote:
 On 2/6/08, Richard Heyes [EMAIL PROTECTED] wrote:
  There's the Zend Encoder at www.zend.com. Though it may be called
  something else now.

 Pointless.

 http://www.phprecovery.com/

http://www.zendecode.com/

I'm sure there are others.


-- 
Greg Donald
http://destiney.com/

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



Re: [PHP] PHP Source code protection

2008-02-06 Thread Richard Lynch
On Wed, February 6, 2008 5:28 am, Zoran Bogdanov wrote:
 I'm building a C# application that connects to a server that has PHP
 scripts
 on it.

 We need to deliver the complete solution to a firm, the C# is no
 problem
 because it is compiled...

 But PHP is a problem bacause it is interpreted and we will have to
 deliver
 pure, unprotected script...

 Is htere a way to secoure my code so when they put it on the server,
 they
 can't see it!

A clear license will go a lot farther than some technology here...

That said, there is the Zend Encoder and the ???Priada Blender??? or
somesuch.

If you Google for those, you should find more solutions as well in
comparisons and archives.

One other option.

After you get your PHP code all worked out, re-write it as a custom
PHP extension -- or even just the core of it, and send them a .so or
.dll to install.

Note that unless it's something REALLY special, it's faster and easier
for somebody to reverse engineer it just from the behaviour than to
bother to crack your code with a debugger and dis-assembler.

And if it IS that tricky, somebody with enough time/energy CAN
dis-assemble it and figure it out if they want to badly enough.

So, to come back to the original statement:
If you just want to keep honest people honest, a clear license that
says exactly what they can and can't do with the code is all you need,
and a lot easier for integration.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Poll: phpt or phpunit and why?

2008-02-06 Thread Nathan Nobbe
in a conversation on #gentoo-php (irc), the following distinction
was drawn,

 back on the phpt; just curious, how do you see it compared to something
like phpunit ?
comparable, or different..

 different... phpt is probably really mostly intended for testing php and
their extensions
phpunit rather for testing code written in php

-nathan


[PHP] Progressive answers from a php query?

2008-02-06 Thread Richard
Hello, I don't know if this is possible with PHP alone but this is what 
I'm trying to do :


My script would check say for example 10 or 20 different http:// site 
addresses and collect some text from each page.


My problem is that it takes quite a long time to query so many sites, 
and the user would have to wait for un to 30 sec to 1 min before the 
page comes up ...


So there are two ways I can think of inorder to reduce the waiting time.

1) Perform asynchronous searches at the same time so all details are 
collected at the same time instead of waiting for the script to collect 
data from each one, one by one.


2) Somehow show data as it arrives instead of waiting for all the 
queries to be done.


Is it possible to do either of these two, or both of these two with only 
PHP? If so how would I do it?


or is it necessary to use javascript?


Thanks in advance,

Richard

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



[PHP] Delete a document from lotus domino with CURL

2008-02-06 Thread Fnutt
I am working on a script that log in, look for messages, download them 
(including any attached files) and then deletes the message from a lotus 
domino server. What I have access to is a simple web-gui that I access 
throu CURL. So far I have been able to do the following:


Log in and save a cookie.

List all documents in my mailbox (as a xml)
 This gives me a list of all documents and their id-numbers so I can...

Open all document (one at a time) and save them to disc (using this url)
 http://000.000.000.000/mail/mapp/databas.nsf/$path/$unid?OpenDocument
 Where $path is the cookie-value (don't know if I need it but it works)
 And $unid is the documents unique ID.
 ?OpenDocument opens the document.

Save any attachments found in the saved document (just downloading any 
file that are linked in the document).


So far it's all good but now things get strange...

Delete the document, if I browse the domino-server with explorer, I can 
just enter an url like the following:

 http://000.000.000.000/mail/mapp/databas.nsf/$path/$unid?DeleteDocument
 This does delete the document from the server, no problem at all but 
once I try to do the same with CURL, I get a page that look like this:


--

Response Message

HTTP Web Server: Invalid URL Exception

Go Back

--

If I put Delete (which also works in explorer instead of DeleteDocument) 
the error message change to:


HTTP Web Server: Unknown Command Exception


I find this most frustrating since all my other url-requests work out well.

I'm greatful for any help I can get on this matter.



Some more information on how I do this:

OpenDocument:

$fp2 = fopen(/tmp/files_from_lotus/$filename.html,w);
$curl = curl_init();
curl_setopt($curl, CURLOPT_FILE, $fp2);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_HTTPGET, true);
curl_setopt($curl, CURLOPT_USERAGENT, Mozilla/4.0 (compatible; MSIE 
6.0; Windows NT 5.1));

curl_setopt($curl, CURLOPT_COOKIEFILE, /tmp/cookie.txt);
curl_setopt($curl, CURLOPT_URL, 
http://000.000.000.000/mail/mapp/databas.nsf/$path/$unid?OpenDocument;);

curl_exec($curl);
curl_close($curl);
fclose ($fp2);

DeleteDocument: (doesn't work)

$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_HTTPGET, true);
curl_setopt($curl, CURLOPT_USERAGENT, Mozilla/4.0 (compatible; MSIE 
6.0; Windows NT 5.1));

curl_setopt($curl, CURLOPT_COOKIEFILE, /tmp/cookie.txt);
curl_setopt($curl, CURLOPT_URL, 
http://000.000.000.000/mail/mapp/databas.nsf/$path/$unid?DeleteDocument;);

curl_exec($curl);
curl_close($curl);

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



[PHP] Recommendation for an XML class?

2008-02-06 Thread Brian Dunning
I see there are billions of XML classes out there. Can anyone  
recommend one that's good  simple? My needs are quite basic, all I  
really need is to draw simple values out of the XML, like convert  
order_no123/order_no to $order_no = 123.


Thanks...

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



Re: [PHP] Recommendation for an XML class?

2008-02-06 Thread Nathan Nobbe
On Feb 6, 2008 3:09 PM, Brian Dunning [EMAIL PROTECTED] wrote:

 I see there are billions of XML classes out there. Can anyone
 recommend one that's good  simple? My needs are quite basic, all I
 really need is to draw simple values out of the XML, like convert
 order_no123/order_no to $order_no = 123.http://www.php.net/unsub.php


SimpleXML,
http://www.php.net/manual/en/ref.simplexml.php

-nathan


Re: [PHP] Poll: phpt or phpunit and why?

2008-02-06 Thread Eric Butera
On Feb 6, 2008 1:32 PM, Nathan Nobbe [EMAIL PROTECTED] wrote:
 in a conversation on #gentoo-php (irc), the following distinction
 was drawn,

  back on the phpt; just curious, how do you see it compared to something
 like phpunit ?
 comparable, or different..

  different... phpt is probably really mostly intended for testing php and
 their extensions
 phpunit rather for testing code written in php

 -nathan


This might be of interest:

http://talks.somabo.de/200703_montreal_need_for_testing.pdf

You can also see his other talks here: http://talks.somabo.de/

Right now I use Simpletest because I'm heavily invested in it.
PHPUnit is looking better every day though... :)

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



Re: [PHP] Progressive answers from a php query?

2008-02-06 Thread Martin Marques

Richard escribió:
Hello, I don't know if this is possible with PHP alone but this is what 
I'm trying to do :


My script would check say for example 10 or 20 different http:// site 
addresses and collect some text from each page.


My problem is that it takes quite a long time to query so many sites, 
and the user would have to wait for un to 30 sec to 1 min before the 
page comes up ...


So there are two ways I can think of inorder to reduce the waiting time.

1) Perform asynchronous searches at the same time so all details are 
collected at the same time instead of waiting for the script to collect 
data from each one, one by one.


2) Somehow show data as it arrives instead of waiting for all the 
queries to be done.


Is it possible to do either of these two, or both of these two with only 
PHP? If so how would I do it?


or is it necessary to use javascript?


I think it's best to do this on the client side. If you want to have 
something done on the server, then at least use AJAX so the page gets 
loaded on demand.


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



[PHP] Re: Recommended ORM for PHP

2008-02-06 Thread Manuel Lemos
on 02/06/2008 11:10 AM js said the following:
 Hi list,
 
 When creating a LAMP app, I always start by writing ORM myself.
 It's fun but it usually takes a  long time.
 Besides, that always results in a toy-system,
 I mean, that has not so many features, not so efficient non-bug-free.
 
 I started to think that now is the time  to throw away my rubbish
 and use more effective Open source ORM.
 
 So my  question is what ORM are you using?
 What ORM do you recommend?
 There're lots of Web app frameworks out there
 but I could't find simple ORM in PHP.

A similar question was asked here a couple of days ago.

I will be repeating myself, but what I said was that I use Metatsorage
which is an ORM class generator tool. It is a different approach than
others you may find. It generates persistent object classes that are
smaller and more efficient.

You may find more about Metastorage here:

http://www.meta-language.net/metastorage.html

Here you may find a small example application:

http://www.meta-language.net/metanews.html

Here you may see some screenshots of the Web user interface of the
generator tool and screenshots of the applications:

http://www.meta-language.net/screenshots.html

-- 

Regards,
Manuel Lemos

PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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



Re: [PHP] Recommendation for an XML class?

2008-02-06 Thread Paul Scott

On Wed, 2008-02-06 at 15:12 -0500, Nathan Nobbe wrote:
 SimpleXML,
 http://www.php.net/manual/en/ref.simplexml.php
 

Dude, I thought you were playing with SPL! SimpleXML _then_ use the
SimpleXMLIterator to work with it!

http://www.php.net/spl

--Paul

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm 

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

Re: [PHP] Recommendation for an XML class?

2008-02-06 Thread Nathan Nobbe
On Feb 6, 2008 4:04 PM, Paul Scott [EMAIL PROTECTED] wrote:

 Dude, I thought you were playing with SPL! SimpleXML _then_ use the
 SimpleXMLIterator to work with it!

 http://www.php.net/spl


well of course; if you need to flatten out an xml structure in
a few lines of code ;)

-nathan


[PHP] shopping carts

2008-02-06 Thread nihilism machine
Does anyone know of a shopping cart which allows you to add multiple  
custom fields to each product?

--e

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



Re: [PHP] shopping carts

2008-02-06 Thread Daniel Brown
On Feb 6, 2008 4:18 PM, nihilism machine [EMAIL PROTECTED] wrote:
 Does anyone know of a shopping cart which allows you to add multiple
 custom fields to each product?

http://www.hotscripts.com/
http://php.resourceindex.com/
http://www.sf.net/

-- 
/Dan

Daniel P. Brown
Senior Unix Geek
? while(1) { $me = $mind--; sleep(86400); } ?

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



Re: [PHP] shopping carts

2008-02-06 Thread nihilism machine
that does not help, none specify whether they have a custom fields  
option or not.


On Feb 6, 2008, at 4:23 PM, Daniel Brown wrote:

On Feb 6, 2008 4:18 PM, nihilism machine [EMAIL PROTECTED]  
wrote:

Does anyone know of a shopping cart which allows you to add multiple
custom fields to each product?


   http://www.hotscripts.com/
   http://php.resourceindex.com/
   http://www.sf.net/

--
/Dan

Daniel P. Brown
Senior Unix Geek
? while(1) { $me = $mind--; sleep(86400); } ?


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



Re: [PHP] shopping carts

2008-02-06 Thread Daniel Brown
On Feb 6, 2008 4:26 PM, nihilism machine [EMAIL PROTECTED] wrote:
 that does not help, none specify whether they have a custom fields
 option or not.

Neither does a PHP mailing list.  Search Google.  Then, read the
description of the shopping cart software.

The best options I can think of are osCommerce, ZenCart, and
XCart.  If I remember correctly, they all allow custom fields.

-- 
/Dan

Daniel P. Brown
Senior Unix Geek
? while(1) { $me = $mind--; sleep(86400); } ?

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



Re: [PHP] shopping carts

2008-02-06 Thread Greg Donald
On 2/6/08, nihilism machine [EMAIL PROTECTED] wrote:
 that does not help, none specify whether they have a custom fields
 option or not.

Wah..  why won't anyone do my research for me?


-- 
Greg Donald
http://destiney.com/

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



Re: [PHP] shopping carts

2008-02-06 Thread Eric Butera
On Feb 6, 2008 4:18 PM, nihilism machine [EMAIL PROTECTED] wrote:
 Does anyone know of a shopping cart which allows you to add multiple
 custom fields to each product?
 --e

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



Please do not use osCommerce.

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



[PHP] Re: PHP Source code protection

2008-02-06 Thread zerof

Zoran Bogdanov escreveu:

Hi,

I'm building a C# application that connects to a server that has PHP scripts 
on it.


We need to deliver the complete solution to a firm, the C# is no problem 
because it is compiled...


But PHP is a problem bacause it is interpreted and we will have to deliver 
pure, unprotected script...


Is htere a way to secoure my code so when they put it on the server, they 
can't see it!


Thank You! 

Try Roadsend, now as Open Source:

http://www.roadsend.com/home/index.php?SMC=1pageID=compiler

--
zerof
http://www.educar.pro.br/
Apache - PHP - MySQL - Boolean Logics - Project Management
--  
You must hear, always, one second opinion! In all cases.
--
Let the people know if this info was useful for you!
--

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



Re: [PHP] PHP CLI Problem

2008-02-06 Thread Chris



In your cronjob, replace the php5 entry with the following
(including the backticks):
`which php5`

If that still doesn't work, replace it simply with php, not php5:
`which php`


You can use 'env php' instead and it'll pick up the first one in $PATH 
(same sort of idea as 'which' though).


So the job would be:

env php -f /path/to/file.php

Also while the curl suggestion may work, it's going to (eventually) have 
timeout issues and stop working if the backup's become too large.


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] PHP CLI Problem

2008-02-06 Thread Daniel Brown
On Feb 6, 2008 6:56 PM, Chris [EMAIL PROTECTED] wrote:

  In your cronjob, replace the php5 entry with the following
  (including the backticks):
  `which php5`
 
  If that still doesn't work, replace it simply with php, not php5:
  `which php`

 You can use 'env php' instead and it'll pick up the first one in $PATH
 (same sort of idea as 'which' though).

 So the job would be:

 env php -f /path/to/file.php

 Also while the curl suggestion may work, it's going to (eventually) have
 timeout issues and stop working if the backup's become too large.

Unless then you employ ignore_user_abort(1); et al.

-- 
/Dan

Daniel P. Brown
Senior Unix Geek
? while(1) { $me = $mind--; sleep(86400); } ?

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



Re: [PHP] shopping carts

2008-02-06 Thread Jason Pruim


On Feb 6, 2008, at 5:56 PM, Eric Butera wrote:

On Feb 6, 2008 4:18 PM, nihilism machine [EMAIL PROTECTED]  
wrote:

Does anyone know of a shopping cart which allows you to add multiple
custom fields to each product?
--e

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




Please do not use osCommerce.


Umm, Can I ask why? I just downloaded it a few days ago to play with  
it on my server. I don't need it myself, but something good to have in  
the arsenal :)


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



[PHP] PHP/mySQL question about groups

2008-02-06 Thread Rob Gould
Let's say I have a PHP-based wine application, and it's taking a set of mySQL 
data that looks like this:

wineidname size 
 
123 Silver Oak 750ML
123 Silver Oak  1.5L
123 Silver Oak  1.5L
456 Liberty School   750ML
456 Liberty School   750ML
456 Liberty School   750ML
456 Liberty School   1.5L


If I do a:

Select * from wine where name = 'Silver Oak' GROUP BY 'wineid'

I'd get:

Silver Oak


However, what I'd REALLY like to return is:

Silver Oak   750ML
Silver Oak   1.5L

I'd like the groupby to group by wineid, BUT ALSO separate the groups by 
'size'.  So there'd be a '750ML' group, and a '1.5L' group

Can anyone tell me how I'd do that?  I'm hoping I don't have to write a PHP 
script that loops through the results and separates things manually.

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



Re: [PHP] PHP/mySQL question about groups

2008-02-06 Thread Nathan Nobbe
On Feb 6, 2008 8:46 PM, Rob Gould [EMAIL PROTECTED] wrote:

 Let's say I have a PHP-based wine application, and it's taking a set of
 mySQL data that looks like this:

 wineidname
 size
 123 Silver Oak
 750ML
 123 Silver Oak
  1.5L
 123 Silver Oak
  1.5L
 456 Liberty School
 750ML
 456 Liberty School
 750ML
 456 Liberty School
 750ML
 456 Liberty School
 1.5L


i think you can just do

group by wineid, size

-nathan


[PHP] Roadsend (was Re: PHP Source code protection)

2008-02-06 Thread Bruce Cowin
 zerof [EMAIL PROTECTED] 7/02/2008 12:04 p.m. 

Try Roadsend, now as Open Source:

http://www.roadsend.com/home/index.php?SMC=1pageID=compiler 


Hey, that looks cool.  Do many people use this?  Has anyone built any
standalone GUI apps with it?





Regards,

Bruce

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



[PHP] PHP program to download sites

2008-02-06 Thread Leonard Burton
HI All,

I have a client who wants to be able to download/cache all web files
on certain sites for archiving info (i.e. before purchases, anything
where a record of what exactly was on a certain page is needed).  They
would like to have this on the web server so employees could log in
and enter the sites for caching and then it can have a cron job and do
this at night.

Is there an OS program that will take a url and crawl/cache all the links on it?

If so I can easily create the interface, job queuing, and chron job setup.

Thanks,

-- 
Leonard Burton, N9URK
http://www.jiffyslides.com
[EMAIL PROTECTED]
[EMAIL PROTECTED]

The prolonged evacuation would have dramatically affected the
survivability of the occupants.

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



Re: [PHP] PHP program to download sites

2008-02-06 Thread Nathan Nobbe
On Feb 6, 2008 9:30 PM, Leonard Burton [EMAIL PROTECTED] wrote:

 HI All,

 I have a client who wants to be able to download/cache all web files
 on certain sites for archiving info (i.e. before purchases, anything
 where a record of what exactly was on a certain page is needed).  They
 would like to have this on the web server so employees could log in
 and enter the sites for caching and then it can have a cron job and do
 this at night.

 Is there an OS program that will take a url and crawl/cache all the links
 on it?


check out the recursive option for wget; its pretty sweet ;)
http://linuxreviews.org/quicktips/wget/

-nathan


RE: [PHP] PHP/mySQL question about groups

2008-02-06 Thread Bastien Koert

Select * from wine where name = 'Silver Oak' GROUP BY wineid,size
 
 
bastien Date: Wed, 6 Feb 2008 17:46:52 -0800 From: [EMAIL PROTECTED] To: 
php-general@lists.php.net Subject: [PHP] PHP/mySQL question about groups  
Let's say I have a PHP-based wine application, and it's taking a set of mySQL 
data that looks like this:  wineid name size  123 Silver Oak 750ML 123 
Silver Oak 1.5L 123 Silver Oak 1.5L 456 Liberty School 750ML 456 Liberty 
School 750ML 456 Liberty School 750ML 456 Liberty School 1.5L   If I do 
a:  Select * from wine where name = 'Silver Oak' GROUP BY 'wineid'  I'd 
get:  Silver Oak   However, what I'd REALLY like to return is:  Silver 
Oak 750ML Silver Oak 1.5L  I'd like the groupby to group by wineid, BUT ALSO 
separate the groups by 'size'. So there'd be a '750ML' group, and a '1.5L' 
group  Can anyone tell me how I'd do that? I'm hoping I don't have to write a 
PHP script that loops through the results and separates things manually.  -- 
 PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: 
http://www.php.net/unsub.php 
_



Re: [PHP] Recommended ORM for PHP

2008-02-06 Thread Larry Garfield
On Wednesday 06 February 2008, Edward Kay wrote:
 Have a look at Qcodo. http://www.qcodo.com.

 It uses code generation to create your ORM for you direct from the DB
 tables. As it's code generation as opposed to run time analysis (which is
 what ActiveRecord and the like use), there is no performance hit - it
 literally just creates your PHP class files for you.

Uh, lots of Active Record systems use code generation.  If the structure of 
your data abstraction is based on the database structure, then you're using 
Active Record.  It's record-centric.  If you're using an object-centric view 
of the world that may just happen to tie to an SQL database for its data 
store, then it's an ORM.

Both are useful in different circumstances, but whether or not there is code 
generation has nothing to do with whether it's AR or ORM.

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



Re: [PHP] PHP/mySQL question about groups

2008-02-06 Thread Andrew Ballard
On Feb 6, 2008 8:46 PM, Rob Gould [EMAIL PROTECTED] wrote:
 Let's say I have a PHP-based wine application, and it's taking a set of mySQL 
 data that looks like this:

 wineidname 
 size
 123 Silver Oak 
 750ML
 123 Silver Oak  
 1.5L
 123 Silver Oak  
 1.5L
 456 Liberty School   750ML
 456 Liberty School   750ML
 456 Liberty School   750ML
 456 Liberty School   1.5L


 If I do a:

 Select * from wine where name = 'Silver Oak' GROUP BY 'wineid'

 I'd get:

 Silver Oak


 However, what I'd REALLY like to return is:

 Silver Oak   750ML
 Silver Oak   1.5L

 I'd like the groupby to group by wineid, BUT ALSO separate the groups by 
 'size'.  So there'd be a '750ML' group, and a '1.5L' group

 Can anyone tell me how I'd do that?  I'm hoping I don't have to write a PHP 
 script that loops through the results and separates things manually.


That's something MySQL will allow that IMO it should not. Being able
to use SELECT * and GROUP BY at the same time can create confusion as
it did here. The other suggestions would probably work, but a good
rule of thumb is not to use any columns in the SELECT clause unless
they are either included in the GROUP BY clause or else use one of the
aggregate functions like COUNT, SUM, AVG, etc. (I'm not sure of the
actual SQL standard on this point, but SQL Server insists on it.)

SELECT  name, size
FROMwine
GROUP BY name, size

Of course, in this case you could just avoid all the confusion with
this statement as well:

SELECT DISTINCT name, size
FROMwine

Andrew

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



[PHP] array problem with a zencart shipping module

2008-02-06 Thread John Taylor-Johnston

I'm desperately going outside the forum, seeking help.
Does anyone have any experience with Zencart shipping modules, or 
understand arrays?

http://www.zen-cart.com/forum/showthread.php?t=87831
Its borrowed code and I,m not good at arrays to begin with.
Thanks,
John

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



Re: [PHP] shopping carts

2008-02-06 Thread John Taylor-Johnston

zencart is giving me every possible custom field I can dream of.
John

Jason Pruim wrote:


On Feb 6, 2008, at 5:56 PM, Eric Butera wrote:

On Feb 6, 2008 4:18 PM, nihilism machine [EMAIL PROTECTED] 
wrote:

Does anyone know of a shopping cart which allows you to add multiple
custom fields to each product?
--e

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




Please do not use osCommerce.


Umm, Can I ask why? I just downloaded it a few days ago to play with it 
on my server. I don't need it myself, but something good to have in the 
arsenal :)


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



Re: [PHP] Recommended ORM for PHP

2008-02-06 Thread Nathan Nobbe
On Feb 6, 2008 10:59 PM, Larry Garfield [EMAIL PROTECTED] wrote:

 On Wednesday 06 February 2008, Edward Kay wrote:
  Have a look at Qcodo. http://www.qcodo.com.
 
  It uses code generation to create your ORM for you direct from the DB
  tables. As it's code generation as opposed to run time analysis (which
 is
  what ActiveRecord and the like use), there is no performance hit - it
  literally just creates your PHP class files for you.

 Uh, lots of Active Record systems use code generation.  If the structure
 of
 your data abstraction is based on the database structure, then you're
 using
 Active Record.  It's record-centric.  If you're using an object-centric
 view
 of the world that may just happen to tie to an SQL database for its data
 store, then it's an ORM.

 Both are useful in different circumstances, but whether or not there is
 code
 generation has nothing to do with whether it's AR or ORM.


well i think its worth a mention that qcodo has an article that
distinguishes
'ActiveRecord classes' from the 'ActiveRecord pattern'.
http://www.qcodo.com/documentation/article.php/6
what it mainly says is that code generation increases performance over
runtime
analysis of some model; eg. the database schema or perhaps some other
representation, such as xml (or yaml [apparently ;)]).  the article also
classifies
ruby on rails as one of these obfusticators of fowlers original pattern;
greg, thoughts ?

anyway, im not sure i agree with the distinction of code-generation vs.
metaprogramming;
i sort of see them overlapping.

and also, on the original topic of the thread; there was just another thread
on this the
other day; check out propel and doctrine; and said thread ;)
http://marc.info/?l=php-generalm=120215073929527w=2

-nathan


Re: [PHP] PHP/mySQL question about groups

2008-02-06 Thread Nathan Nobbe
On Feb 6, 2008 10:59 PM, Andrew Ballard [EMAIL PROTECTED] wrote:

 Of course, in this case you could just avoid all the confusion with
 this statement as well:

 SELECT DISTINCT name, size
 FROMwine


im not sure why, but i think distinct is typically way slower than group by.

-nathan


Re: [PHP] PHP Source code protection

2008-02-06 Thread John Taylor-Johnston
I'm not sure where PHP stands on this politically. But I believe in Open 
Source, which allows you to encode your code. But why? At heart I'm a 
purist GNU. Stallman was right when he first tried to fix a faulty printer.


*  The freedom to run the program, for any purpose (freedom 0).
* The freedom to study how the program works, and adapt it to your 
needs (freedom 1). Access to the source code is a precondition for this.
* The freedom to redistribute copies so you can help your neighbor 
(freedom 2).
* The freedom to improve the program, and release your improvements 
to the public, so that the whole community benefits (freedom 3). Access 
to the source code is a precondition for this.


Thankfully there is little that cannot be reversed engineered. If you 
want to keep the recipe, host it yourself and let others use an interface.


This is stepping in a nest of hornets. :p

C.R.Vegelin wrote:

See also:
http://www.ioncube.com/


- Original Message - From: Bastien Koert [EMAIL PROTECTED]
To: Zoran Bogdanov [EMAIL PROTECTED]; php-general@lists.php.net
Sent: Wednesday, February 06, 2008 2:27 PM
Subject: RE: [PHP] PHP Source code protection



zend encoder?
http://sourceforge.net/projects/php-screw/


google for more



bastien To: php-general@lists.php.net From: [EMAIL PROTECTED] 
Date: Wed, 6 Feb 2008 12:28:12 +0100 Subject: [PHP] PHP Source code 
protection  Hi,  I'm building a C# application that connects to a 
server that has PHP scripts  on it.  We need to deliver the complete 
solution to a firm, the C# is no problem  because it is compiled...  
But PHP is a problem bacause it is interpreted and we will have to 
deliver  pure, unprotected script...  Is htere a way to secoure my 
code so when they put it on the server, they  can't see it!  Thank 
You!   --  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] PHP/mySQL question about groups

2008-02-06 Thread Andrew Ballard
On Feb 6, 2008 11:20 PM, Nathan Nobbe [EMAIL PROTECTED] wrote:
 On Feb 6, 2008 10:59 PM, Andrew Ballard [EMAIL PROTECTED] wrote:

  Of course, in this case you could just avoid all the confusion with
  this statement as well:
 
  SELECT DISTINCT name, size
  FROMwine

 im not sure why, but i think distinct is typically way slower than group by.

 -nathan


I can't really say for MySQL, but in my experience I'd say it
depends. It seems to me that for this case they should be about the
same, as it's always been my thinking that GROUP BY did a DISTINCT
implicitly. However, I don't really know the internals of any DB
platform so I can't confirm that. I ran DESCRIBE on a couple different
tables, and they both return the same plan. I don't see any notable
difference in the queries either. However, I'll leave it to the OP to
test and see if one is better for his question.

Andrew

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



Re: [PHP] array problem with a zencart shipping module

2008-02-06 Thread Nathan Nobbe
On Feb 6, 2008 11:11 PM, John Taylor-Johnston [EMAIL PROTECTED]
wrote:

 I'm desperately going outside the forum, seeking help.
 Does anyone have any experience with Zencart shipping modules, or
 understand arrays?
 http://www.zen-cart.com/forum/showthread.php?t=87831


maybe you should stick w/ that ajeh guy; he seems like he knows what hes
talking about.
also, people here dont typically just hand out help on generic questions
such as this; if you can get a specific question about php or a more focused
question than please help i dont know much about arrays, then maybe we
can help out..

http://www.zen-cart.com/forum/showthread.php?t=87831

 Its borrowed code and I,m not good at arrays to begin with.


ouch, maybe you need to hire someone ?  besides this has more to do than
just arrays; there is the rest of the application and clearly anyone whos
going
to help out must understand at least some of it..

-nathan


Re: [PHP] array problem with a zencart shipping module

2008-02-06 Thread John Taylor-Johnston

Thanks for the reply and checking it out.
I was hoping my problem lies only in the class.
I do have a Paypal account and at this point in time, it is a question 
of time - I've got to get my site in production and shut off the old cart.


Nathan Nobbe wrote:
On Feb 6, 2008 11:11 PM, John Taylor-Johnston 
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:


I'm desperately going outside the forum, seeking help.
Does anyone have any experience with Zencart shipping modules, or
understand arrays?
http://www.zen-cart.com/forum/showthread.php?t=87831


maybe you should stick w/ that ajeh guy; he seems like he knows what hes
talking about.
also, people here dont typically just hand out help on generic questions
such as this; if you can get a specific question about php or a more 
focused

question than please help i dont know much about arrays, then maybe we
can help out..

Its borrowed code and I,m not good at arrays to begin with.


ouch, maybe you need to hire someone ?  besides this has more to do than
just arrays; there is the rest of the application and clearly anyone 
whos going

to help out must understand at least some of it..

-nathan



Re: [PHP] array problem with a zencart shipping module

2008-02-06 Thread Paul Scott

On Wed, 2008-02-06 at 23:42 -0500, Nathan Nobbe wrote:
 ouch, maybe you need to hire someone ?  besides this has more to do than
 just arrays; there is the rest of the application and clearly anyone whos
 going
 to help out must understand at least some of it..

Yeah, I concur! You really should at least understand what you are doing
before attempting a shopping cart scenario where presumably people are
going to be trusting you/your code with their hard earned dough.

If you don't know arrays, then how exactly are you going to make sure
that the thing is secure?

I would _seriously_ consider taking Nathan's advice here and hiring
someone to do this for you or even with you. With you has the advantage
that next time, you will know, and be able to do it easier - as well as
learn something along the way.

--Paul

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm 

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

Re: [PHP] Recommended ORM for PHP

2008-02-06 Thread Manuel Lemos
Hello,

on 02/07/2008 02:18 AM Nathan Nobbe said the following:
 well i think its worth a mention that qcodo has an article that
 distinguishes
 'ActiveRecord classes' from the 'ActiveRecord pattern'.
 http://www.qcodo.com/documentation/article.php/6
 what it mainly says is that code generation increases performance over
 runtime
 analysis of some model; eg. the database schema or perhaps some other
 representation, such as xml (or yaml [apparently ;)]).  the article also
 classifies
 ruby on rails as one of these obfusticators of fowlers original pattern;
 greg, thoughts ?

Yes, 6 years ago I analyzed the approaches of many these solutions that
analyze database schemas at run-time and cache the results . I concluded
that is not by far as efficient as a full code generation based solution.

A code generation based solution will generate code that does what is
necessary without any additional run-time libraries.

Those caching solutions still need to read cached information and
interpret what is cached. Not only they spend more time but also more
memory, especially if you need to load a pile of classes to load your
caching engine and run-time interpreter.

Another problem I found in those solutions is that often you need to
inherit from a fat base class that implements all sorts of functionality
that you may need at run-time to perform object-relational mapping
operations, even if your application objects do not need all that
functionality.

I concluded that it would be more efficient to generate root classes
that just include the functionality you have. For instance, if you do
not need to delete objects from you application, there is no sense in
having that functionality in your objects. The results is persistent
classes that do not inherit from fat base classes and are much thiner
and faster to load and execute.

Yet another problem of the solutions that defer mapping to runtime
libraries is the composition of queries with conditions that need to be
composed at run time.

I concluded that is much more efficient to have an object query language
 (OQL) that lets you define the conditions of your queries. These
queries are processed at compile time and the compiler generates
efficient SQL code that does not need to be composed at run time.

Your applications just call a single function to execute object queries
that satisfy the conditions that you defined. This results again is much
thiner and faster code that does *Just Exactly What You Need* (_JEWYN_).

All these details that I mentioned have been implemented by Metastorage,
which is an ORM code generation tool.

http://www.metastorage.net/

The generated code is very satisfying because it looks exactly like what
I would write if I had to do it manually, except that I did not have to
spend a lot time writing it. I just defined my business objects a simple
model file that describes the classes, relationships, validation rules,
and functions I need to manipulate those objects.

The compile time is measured in a few seconds. The time this tool took
to develop is paying more and more on every application feature I need
to implement but I do not need to waste hours or days coding the
persistent object classes.

There are more details about the Metastorage approaches to each problem
on the FAQ if you are interested:

http://www.meta-language.net/metastorage-faq.html


-- 

Regards,
Manuel Lemos

PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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



RE: [PHP] PHP/mySQL question about groups

2008-02-06 Thread Warren Vail
I did some looking into performance issues many years ago at company that
developed and marketed another database server, comparing the query plan to
the actual code, and a query plan usually shows the processes that consume
the major amount of time, disk I/O, index or table searches and such, but
doesn't show time consumed comparing, discriminating, and totaling, mostly
because they are negligible.

On the other hand distinct depends on comparison of all columns and will
have no help in reducing row counts unless accompanied by an order by
clause, where as group by implys an orderby and can be faster if indexes are
available for use in row ordering, and while the same totaling occurs,
comparison is limited to the columns specified in the group by.

The biggest impact on one or the other would be a well placed index, but for
the most part they should be about the same.

Warren Vail

-Original Message-
From: Andrew Ballard [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 06, 2008 8:41 PM
To: PHP General list
Subject: Re: [PHP] PHP/mySQL question about groups

On Feb 6, 2008 11:20 PM, Nathan Nobbe [EMAIL PROTECTED] wrote:
 On Feb 6, 2008 10:59 PM, Andrew Ballard [EMAIL PROTECTED] wrote:

  Of course, in this case you could just avoid all the confusion with 
  this statement as well:
 
  SELECT DISTINCT name, size
  FROMwine

 im not sure why, but i think distinct is typically way slower than group
by.

 -nathan


I can't really say for MySQL, but in my experience I'd say it depends. It
seems to me that for this case they should be about the same, as it's always
been my thinking that GROUP BY did a DISTINCT implicitly. However, I don't
really know the internals of any DB platform so I can't confirm that. I ran
DESCRIBE on a couple different tables, and they both return the same plan. I
don't see any notable difference in the queries either. However, I'll leave
it to the OP to test and see if one is better for his question.

Andrew

--
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] Exception handling in PHP

2008-02-06 Thread Prabath Kumarasinghe
Hi All

I'm little bit confusing with PHP exception handling.
Could you able to explain how to put try{} and
catch(){}  in a proper way in PHP. I had already read
php exception manual but it didn't help me to get
exact idea about exception handling in php.

Cheers

Prabath


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 

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



Re: [PHP] Exception handling in PHP

2008-02-06 Thread Paul Scott

On Wed, 2008-02-06 at 22:52 -0800, Prabath Kumarasinghe wrote:
 Hi All
 
 I'm little bit confusing with PHP exception handling.
 Could you able to explain how to put try{} and
 catch(){}  in a proper way in PHP. I had already read
 php exception manual but it didn't help me to get
 exact idea about exception handling in php.
 

Well, its pretty simple really...

In your objects that you create, just put in a statement that throws an
exception of some sort (I like to extend the built in exception handler
with a custom one that deals properly with db errors as well as PHP
ones) and then try{} and catch(){} them in your business logic.

example:

class someclass {

public function foo()
{
 // do something
 ...
 else {
 throw new Exception(uh-oh - we have a problem!);
 }
}

}

$thing = new someclass;
try {
$thing-foo();
}
catch(Exception $e) {
echo $e-getMessage();
exit;
}

--Paul

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm 

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

[PHP] Multiple MySQL INSERT into loop

2008-02-06 Thread Rob G
I'm working on this, and am not sure how the variable syntax needs to be
here.

 

 

 

This is what I have done manually.

 

 

 

//BEGIN EXAMPLE

 

mysql_query (INSERT INTO testimonials (id, quote, name) VALUES ('$id_1',
'$entry_1', '$name_1'));

 

mysql_query (INSERT INTO testimonials (id, quote, name) VALUES ('$id_2',
'$entry_2', '$name_2'));

 

mysql_query (INSERT INTO testimonials (id, quote, name) VALUES ('$id_3',
'$entry_3', '$name_3'));

 

//END EXAMPLE

 

 

 

I'd like to put this into a loop, so that the variable that are being
defined as the VALUES change as needed.

 

 

 

//BEGIN EXAMPLE

 

while ($i16)

 

{

 

$i++;

 

mysql_query (INSERT INTO testimonials (id,quote,name) VALUES ('$id_1',
'$entry_1', '$name_1'));));

 

}

 

//END EXAMPLE

 

 

 

What I'm trying to figure out, is exactly how I need to format my entry
within the VALUES section, so that it will change based on the value of $i.

 



Re: [PHP] Exception handling in PHP

2008-02-06 Thread Prabath Kumarasinghe
Hi Paul

Is this following code work in PHP if mysql_connect
fails.

try{
mysql_connect('localhost','user','');

}catch(Exception $e){
  echo $e-getMessage();

}

Cheers

Prabath

--- Paul Scott [EMAIL PROTECTED] wrote:

 
 On Wed, 2008-02-06 at 22:52 -0800, Prabath
 Kumarasinghe wrote:
  Hi All
  
  I'm little bit confusing with PHP exception
 handling.
  Could you able to explain how to put try{} and
  catch(){}  in a proper way in PHP. I had already
 read
  php exception manual but it didn't help me to get
  exact idea about exception handling in php.
  
 
 Well, its pretty simple really...
 
 In your objects that you create, just put in a
 statement that throws an
 exception of some sort (I like to extend the built
 in exception handler
 with a custom one that deals properly with db errors
 as well as PHP
 ones) and then try{} and catch(){} them in your
 business logic.
 
 example:
 
 class someclass {
 
 public function foo()
 {
  // do something
  ...
  else {
  throw new Exception(uh-oh - we have a
 problem!);
  }
 }
 
 }
 
 $thing = new someclass;
 try {
 $thing-foo();
 }
 catch(Exception $e) {
 echo $e-getMessage();
 exit;
 }
 
 --Paul
 
  All Email originating from UWC is covered by
 disclaimer 

http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
 
 
  -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



  

Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping

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



[PHP] Passing object reference to session

2008-02-06 Thread Michael Moyle
Hi,

I am new to the list and have a question that inspired me to join the
list as I can not find any answer online.

When a object reference is passed to the $_SESSION array what happens to
the object? Is the object serialized and saved in session (in this case
file)? Or just the reference with the object in memory remaining on the
heap? 

-- 
best regards,
Michael

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



Re: [PHP] Exception handling in PHP

2008-02-06 Thread Paul Scott

On Wed, 2008-02-06 at 23:10 -0800, Prabath Kumarasinghe wrote:
 Is this following code work in PHP if mysql_connect
 fails.
 
 try{
 mysql_connect('localhost','user','');
 
 }catch(Exception $e){
   echo $e-getMessage();
 

Probably not. I don't think that the mysql functions throw exceptions on
failure. 

You will have to write a wrapper function to do the exception on
failure, so something like

function dbConnect()
{
   $conn = mysql_connect('','','');
   if(!$conn) {
   throw new Exception(Couldn't connect);
   }
   else {
   return $conn;
   }
}

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm 

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

Re: [PHP] Exception handling in PHP

2008-02-06 Thread Prabath Kumarasinghe
Does that mean for every exception do we have to write
our custom exception and describe it from our own
message

Cheers

Prabath 
--- Paul Scott [EMAIL PROTECTED] wrote:

 
 On Wed, 2008-02-06 at 23:10 -0800, Prabath
 Kumarasinghe wrote:
  Is this following code work in PHP if
 mysql_connect
  fails.
  
  try{
  mysql_connect('localhost','user','');
  
  }catch(Exception $e){
echo $e-getMessage();
  
 
 Probably not. I don't think that the mysql functions
 throw exceptions on
 failure. 
 
 You will have to write a wrapper function to do the
 exception on
 failure, so something like
 
 function dbConnect()
 {
$conn = mysql_connect('','','');
if(!$conn) {
throw new Exception(Couldn't connect);
}
else {
return $conn;
}
 }
 
  All Email originating from UWC is covered by
 disclaimer 

http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
 
 



  

Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

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