php-general Digest 21 Aug 2009 11:26:19 -0000 Issue 6297

2009-08-21 Thread php-general-digest-help

php-general Digest 21 Aug 2009 11:26:19 - Issue 6297

Topics (messages 297042 through 297053):

Re: Displaying 2 digit minutes/seconds
297042 by: Ashley Sheridan
297043 by: sono-io.fannullone.us
297044 by: sono-io.fannullone.us
297046 by: Daevid Vincent

Submit login form using HTTP AUTH
297045 by: LinuxManMikeC

Tidy on a shared host
297047 by: Al

Re: PHP/Ajax Framework - Call for Developers  Testers
297048 by: Raymond Irving

Is there limitation for switch case: argument's value?
297049 by: Keith
297050 by: Adam Randall
297051 by: Lars Torben Wilson

Re: SESSION VARIABLES ACROSS DIFFERENT WINDOWS/TABS
297052 by: Leon du Plessis

Invoking functions stored in a separate directory?
297053 by: Clancy

Administrivia:

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

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

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


--
---BeginMessage---
On Thu, 2009-08-20 at 14:27 -0700, sono...@fannullone.us wrote:
 Hi all,
 
   I'm using this code to display the current time for our location on  
 our website:
 
 ?php
   date_default_timezone_set('America/Los_Angeles');
  $theTimeIs = getdate(time());
  $theHour = $theTimeIs['hours'];
  $theMinute = $theTimeIs['minutes'];  // make minutes  
 under 10 show two digits
  $theSecond = $theTimeIs['seconds'];
  if($theHour  12){
  $theHour = $theHour - 12;
  $dn = PM;
  } else {
  $dn = AM;
  }
 
 echo $theHour:$theMinute:$theSecond $dn;
 ?
 
   It works great except for one small detail.  If the time is 3:04:02,  
 it is displayed as 3:4:2 which, of course, is very odd looking.  So I  
 corrected it as follows:
 
 ?php
   date_default_timezone_set('America/Los_Angeles');
  $theTimeIs = getdate(time());
  $theHour = $theTimeIs['hours'];
  if (strlen ($theTimeIs['minutes'])  2) {
   $theMinute = 0 . $theTimeIs['minutes'];
   } else {
   $theMinute = $theTimeIs['minutes'];
   }
  if (strlen ($theTimeIs['seconds'])  2) {
   $theSecond = 0 . $theTimeIs['seconds'];
   } else {
   $theSecond = $theTimeIs['seconds'];
   }
  if($theHour  12){
  $theHour = $theHour - 12;
  $dn = PM;
  } else {
  $dn = AM;
  }
 
 echo $theHour:$theMinute:$theSecond $dn;
 ?
 
   It works, but is there a better way to do it?
 
 Thanks,
 Frank
 

What's wrong with using the date() function? You can have it output any
sort of format you wish. So, getting a 2 digit time in
hours:minutes:seconds you would put:

date(H:i:s);

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



---End Message---
---BeginMessage---


On Aug 20, 2009, at 2:38 PM, Ashley Sheridan wrote:

What's wrong with using the date() function? You can have it output  
any

sort of format you wish. So, getting a 2 digit time in
hours:minutes:seconds you would put:

date(H:i:s);


	Thanks, Ash.  I had tried that before but I couldn't find a way to  
make it display in 12 hour time, so I went with the other method.  I  
guess I didn't look hard enough. =;)


This works:

echo (date(g:i A));

Frank
---End Message---
---BeginMessage---


On Aug 20, 2009, at 2:34 PM, Jonathan Tapicer wrote:

You can use sprintf or str_pad to fill in with zeros, with sprintf  
you can do this:


echo sprintf('%02d', 5);


	Thanks, Jonathan!  I learned two new functions today!  Both work  
great but I think I like sprintf for this application better since  
it's more succinct.


echo sprintf('%02d', $theMinute);

echo (str_pad($theMinute,2,0,STR_PAD_LEFT));

Frank
---End Message---
---BeginMessage---
 

 -Original Message-
 From: sono...@fannullone.us [mailto:sono...@fannullone.us] 
 Sent: Thursday, August 20, 2009 3:53 PM
 To: Jonathan Tapicer; PHP General List
 Subject: Re: [PHP] Displaying 2 digit minutes/seconds
 
 
 On Aug 20, 2009, at 2:34 PM, Jonathan Tapicer wrote:
 
  You can use sprintf or str_pad to fill in with zeros, with sprintf  
  you can do this:
 
  echo sprintf('%02d', 5);
 
   Thanks, Jonathan!  I learned two new functions today!  
 Both work  
 great but I think I like sprintf for this application better since  
 it's more succinct.
 
 echo sprintf('%02d', $theMinute);

Uh. If you MUST do this nonsense, then at least do this instead and not
echo sprintf:

printf('%02d', $theMinute);

---End Message---
---BeginMessage---
Anybody know of any tricks to make an HTML login form that sends 

php-general Digest 22 Aug 2009 02:34:03 -0000 Issue 6298

2009-08-21 Thread php-general-digest-help

php-general Digest 22 Aug 2009 02:34:03 - Issue 6298

Topics (messages 297054 through 297067):

Re: PHP/Ajax Framework - Call for Developers  Testers
297054 by: Bob McConnell

about to run PHP script when POST data.
297055 by: Jacky
297057 by: Arno Kuhl

Re: Invoking functions stored in a separate directory?
297056 by: Arno Kuhl

Re: Extract column names from a (my)SQL query
297058 by: Nisse Engström
297064 by: Daevid Vincent
297065 by: דניאל דנון
297066 by: דניאל דנון

PHP Shopping Cart Recommendation
297059 by: sono-io.fannullone.us
297060 by: Ashley Sheridan

PHP 5.x magic mathods quick question
297061 by: Ralph Deffke
297062 by: Martin Scotta

Re: Is there limitation for switch case: argument's value?
297063 by: Daevid Vincent

Re: HTML text extraction
297067 by: Manuel Lemos

Administrivia:

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

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

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


--
---BeginMessage---
From: Raymond Irving

 Hi Nathan,
 
 I agree with you, and I believe that there are many persons
 who don't like the idea of hosting all their applications on
 a third party server. IMO there are some advantages and
 disadvantages to doing so but that's a discussion in itself.

Hosted servers are basically a trade off between doing it yourself and
paying someone else to do it. The initial choice is between installing
your own servers or spend the money to rent servers from someone else.
Most of the time it is actually the network bandwidth issue that decides
this. Can you afford a network connection that will handle the peak
loads but be unused most of the time?

But once you decide to pay someone else, you have another set of trade
offs to negotiate. What services do they provide? What systems do they
offer? How do they manage version control and updates? Are they PCI
compliant? There are a wide range of options available in the market.
Not all of them will fit your specific needs.

We just moved most of our servers from a physical hosting service to a
managed service. Where we used to maintain the OS and all software on
the server, the new service now handles that for us. The trade off is
that now we have to settle for the server package they offer. That means
we get the versions of Apache, PHP and PostgreSQL that were included in
the last production release of RHEL. If we want a newer version of PHP,
we have to take over maintenance of that component. It becomes our
responsibility to install the updates, patches, etc., for that
component.

Once you get beyond a private web site these types of decisions become
part of the management process, just as make or buy decisions are part
of the hardware procurement process. There are people out there making a
good living just guiding companies through this decision making process.

Bob McConnell
---End Message---
---BeginMessage---
Hi guys,

As I know When we POST a big data(e.g. 500M) to a php script, the php script
only can run after the big data finished POST.

for example:
a.php

 ?php die(''); ?


and I post 500m data to a.php,  after that a.php cannot be died immediately.
only when the data finished post.

How can I make the a.php die before the 500m data finish?

Thanks in advance.

-- 
Regards,
Jacky
---End Message---
---BeginMessage---
-Original Message-
From: Jacky [mailto:newbde...@gmail.com] 
Sent: 21 August 2009 03:12 PM
To: php-gene...@lists.php.net
Subject: [PHP] about to run PHP script when POST data.

Hi guys,

As I know When we POST a big data(e.g. 500M) to a php script, the php script
only can run after the big data finished POST.

for example:
a.php

 ?php die(''); ?


and I post 500m data to a.php,  after that a.php cannot be died immediately.
only when the data finished post.

How can I make the a.php die before the 500m data finish?

Thanks in advance.

--
Regards,
Jacky

---

Your script will die ungracefully when it runs out of execution time
(defined in php.ini)

Cheers
Arno

---End Message---
---BeginMessage---
-Original Message-
From: Clancy [mailto:clanc...@cybec.com.au] 
Sent: 21 August 2009 01:26 PM
To: php-gene...@lists.php.net
Subject: [PHP] Invoking functions stored in a separate directory?

I am developing an idea for a website engine which can be shared between
several different websites. Each website would have its own directory under
a common root directory, and the engine would be in a separate directory
Engine:

Root
Website_1.com, Website_2.com, Engine

The website directories would each contain the design data for that website,
consisting basically of a mixture of text files and images. The various
pages would be loaded by loading 

Re: [PHP] Is there limitation for switch case: argument's value?

2009-08-21 Thread Adam Randall
I've never understood why people use switch statements like this as in
reality you are using it more like an if/else block, but anyway.

The reason why your code is not working is that you are passing into
the switch the value of 0, or false, which means that when any of
those $sum == N conditionals comes up as false (say $sum == 8 ), then
that is what is returned because they match up. In PHP's eyes, 0 ==
false in switch statements.

To fix your code, change the switch( $sum ) to switch( true ):

switch( true )
{
case ($sum == 8):
echo sum=8\n;
break;
case ($sum == 7 || $sum == 6):
echo sum=7 or 6\n;
break;
case ($sum == 2 || $sum == 1):
echo sum=2 or 1\n;
break;
case ($sum == 0):
echo sum=0\n;
break;
default:
echo sum=3/4/5\n;
break;
}

Or, write your switch like this:

switch( $sum )
{
case 8:
echo sum=8\n;
break;
case 6:
case 7:
echo sum=7 or 6\n;
break;
case 1:
case 2:
echo sum=2 or 1\n;
break;
case 0:
echo sum=0\n;
break;
default:
echo sum=3/4/5\n;
break;
}

Regards,

Adam.

On Thu, Aug 20, 2009 at 8:40 PM, Keithsurvivor_...@hotmail.com wrote:
 Hi,
 I encounter a funny limitation here with switch case as below:
 The value for $sum is worked as expected for 1 to 8, but not for 0.
 When the $sum=0, the first case will be return, which is sum=8.
 Is there any limitation / rules for switch case? Thanks for advice!

 Keith

 $sum=0;
 switch($sum)
 {
   case ($sum==8):
   echo sum=8;
   break;
       case ($sum==7 || $sum==6):
       echo sum=7 or 6;
       break;
   case ($sum==2 || $sum==1):
   echo sum=2 or 1;
   break;
       case 0:
       echo sum=0;
       break;
   default:
   echo sum=3/4/5;
   break;
 }
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
Adam Randall
http://www.xaren.net
AIM: blitz574

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



Re: [PHP] Is there limitation for switch case: argument's value?

2009-08-21 Thread Lars Torben Wilson
2009/8/20 Keith survivor_...@hotmail.com:
 Hi,
 I encounter a funny limitation here with switch case as below:
 The value for $sum is worked as expected for 1 to 8, but not for 0.
 When the $sum=0, the first case will be return, which is sum=8.
 Is there any limitation / rules for switch case? Thanks for advice!

 Keith

Hi Keith,

Try replacing 'switch($sum)' with 'switch(true)'.

Note that unless you have very good reasons for using a switch
statement like this, and know exactly why you're doing it, it's often
better just to use it in the normal fashion. i.e.:

   switch ($sum)
{
case 8:
break;
case 7:
case 6:
break;
case 2:
case 1:
break;
case 0:
break;
default:
break;
}

Some people like the syntax you've presented but honestly, there's
usually a better way to do it.

This is also somewhat faster too, although you may only notice the
difference in very tight loops where you're counting every nanosecond.


Regards,

Torben

 $sum=0;
 switch($sum)
 {
   case ($sum==8):
   echo sum=8;
   break;
       case ($sum==7 || $sum==6):
       echo sum=7 or 6;
       break;
   case ($sum==2 || $sum==1):
   echo sum=2 or 1;
   break;
       case 0:
       echo sum=0;
       break;
   default:
   echo sum=3/4/5;
   break;
 }
 --
 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] SESSION VARIABLES ACROSS DIFFERENT WINDOWS/TABS

2009-08-21 Thread Leon du Plessis
Hi Jamie. 

Thanks. Good info. I knew something changed somewhere. This works like a
charm in IE8..never saw the New Session option under file...me bad !!

Greetings.


-Original Message-
From: Jaime Bozza [mailto:jbo...@mindsites.com] 
Sent: 20 August 2009 09:49 PM
To: Leon du Plessis; 'Floyd Resler'
Cc: a...@dotcontent.net; php-general@lists.php.net
Subject: RE: [PHP] SESSION VARIABLES ACROSS DIFFERENT WINDOWS/TABS

Leon,

This is really just a function of the browser.   When a session cookie is
created, if the browser is setup for a single instance, that's the session
cookie it'll use for *any* request to that domain.  This functions
differently depending on what browser you're using.

For example:
Firefox - All windows, tabs, etc, under the same profile will use the same
session.   If you create profiles, you can have different sessions.
IE7, IE6 - All tabs or windows opened from clicks will share the same
instance/session.  Starting IE from the icon will open up a new
instance/session.  This worked great if you wanted to run two different
sessions at the same site/domain.  Just start IE up from the icon again and
you'd have a new session.
IE8 - IE8 model changed, so that all browser windows, tabs, etc., run under
the same frame/session, much like Firefox.  Clicking the IE icon again now
just keeps the same frame and thus the same session.  Originally, this
sounded like a big problem, but IE8 introduced a new feature - File Menu -
New Session.   This will open up a new window that will be a separate frame
that will not use current session cookies.

Here's just one of many links, but gives some helpful hints on the IE side:
http://blogs.msdn.com/ie/archive/2009/05/06/session-cookies-sessionstorage-a
nd-ie8.aspx

And another:
http://blogs.msdn.com/askie/archive/2009/05/08/session-management-within-int
ernet-explorer-8-0.aspx

One of the issues now is that if you close IE, your session does not
disappear.  In the past (IE7/IE6), your session would disappear if you
closed a browser window that you opened yourself, but it *wouldn't*
disappear if you closed a browser window that was opened by a click from
Outlook or another program.  This was a bit inconsistent.  I won't argue
whether or not their fix was the best way to go, but now it's at least
consistent.

Note - In Firefox, not even Private Browsing separates the session
cookies.  If you start Private Browsing (Firefox 3.5), log into a site, then
start a new browser window from the icon (that isn't in Private Browsing
mode), it shares the session cookies. (Before you ask, I just checked this
to be sure.)

IE8 InPrivate Mode is a totally separate session, cookies and all.  This
could possibly be another way for you to run multiple sessions against the
same domain.  OTOH, multiple InPrivate sessions running at the same time
share the same frame, so they share the same session, so it would only be
good for a single new session.  If you need more, just use File - New
Session.

Jaime 


 -Original Message-
 From: Leon du Plessis [mailto:l...@dsgnit.com]
 Sent: Thursday, August 20, 2009 8:16 AM
 To: 'Floyd Resler'
 Cc: a...@dotcontent.net; php-general@lists.php.net
 Subject: [PHP] SESSION VARIABLES ACROSS DIFFERENT WINDOWS/TABS
 
 It is just strange that I have this condition now...maybe I missed it
 a
 year ago ?
 
  Having a different session start up for each window for tab would
 be a
 major pain.
 
 Why?
 
 People must please try and understand what I mean by NEW. It does not
 apply
 to windows/tabs being opened from a link or request.
 
 Imho, keeping the session per domain sounds wrong, it does not mean
 it is.
 It would have been nice if:
 
 Browser/tab one - my login detail container A.
 Browser/tab two - my admin login container B.
 (tabs/windows opened from browser one, then inherits container A
 naturally)
 (Closing browser one, then destroys container A then naturally only)
 
 NOT
 
 Domain.com - one session container only.
 
 Heck, I am surprised it works that way at all cause it sounds like
 the
 domain can then only handle one user a time if arrays are not used or
 profiles not created on FF no matter where the request come from, but,
 then
 I am obviously missing something in this respect as stated. When I have
 time
 I will reconstruct this concept again.
 
 Thanks anyway guys. I received some helpful advise for future
 reference.
 
 But please..I do not, like many others, want to start a war. I am ok
 with
 things how they are. We can put this thing to rest.
 
 -Original Message-
 From: Floyd Resler [mailto:fres...@adex-intl.com]
 Sent: 20 August 2009 02:25 PM
 To: Leon du Plessis
 Cc: a...@dotcontent.net; php-general@lists.php.net
 Subject: Re: [PHP] SESSIONS lost sometimes
 
 Leon,
   Sessions are used on a per-domain basis.  So, no matter how many
 windows or tabs you have open for mydomain.com it will be the same
 session for all.  Having a different session start up for each window
 or tab would be a major 

[PHP] Invoking functions stored in a separate directory?

2009-08-21 Thread Clancy
I am developing an idea for a website engine which can be shared between 
several different
websites. Each website would have its own directory under a common root 
directory, and the
engine would be in a separate directory Engine:

Root
Website_1.com, Website_2.com, Engine

The website directories would each contain the design data for that website, 
consisting
basically of a mixture of text files and images. The various pages would be 
loaded by
loading index.php from the website root directory, and specifying a number of 
parameters
e.g.

http://www.corybas.com/index.php?path=Holidayslevel=0item=0

I have the minimum amount of code in index.php -- just enough to set some 
parameters to
identify the website, and then include ../Engine/Main_prog.php.  This in turn 
can include
any of a large number of other include files to carry out particular functions. 

I have the prototype working nicely on my PC, and on a stand-alone basis on a 
server, but
now I am trying to upload the multi-website version to a public host, and am 
encountering
a number of problems, mainly because I have never done any serious work with 
UNIX, and the
host support staff don't understand what I am trying to do.

The problems mainly relate to setting permissions to allow the website to 
access the
engine code. I only have a rough idea of how the permissions work, but I think 
that to
include engine code the website has to have read and execute rights to it, and 
I also
think that so far as the engine is concerned the website will count as 'other'. 
 (I can
easily arrange that all temporary files are written in the website directory.)

I suspect that rather than including the engine code in index.php, it would be 
better to
call functions in it, so that the website only required 'execute' rights, but I 
don't know
of any way to do this without having anything running permanently on the 
server. Can
anyone suggest how it can be done?



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



RE: [PHP] PHP/Ajax Framework - Call for Developers Testers

2009-08-21 Thread Bob McConnell
From: Raymond Irving

 Hi Nathan,
 
 I agree with you, and I believe that there are many persons
 who don't like the idea of hosting all their applications on
 a third party server. IMO there are some advantages and
 disadvantages to doing so but that's a discussion in itself.

Hosted servers are basically a trade off between doing it yourself and
paying someone else to do it. The initial choice is between installing
your own servers or spend the money to rent servers from someone else.
Most of the time it is actually the network bandwidth issue that decides
this. Can you afford a network connection that will handle the peak
loads but be unused most of the time?

But once you decide to pay someone else, you have another set of trade
offs to negotiate. What services do they provide? What systems do they
offer? How do they manage version control and updates? Are they PCI
compliant? There are a wide range of options available in the market.
Not all of them will fit your specific needs.

We just moved most of our servers from a physical hosting service to a
managed service. Where we used to maintain the OS and all software on
the server, the new service now handles that for us. The trade off is
that now we have to settle for the server package they offer. That means
we get the versions of Apache, PHP and PostgreSQL that were included in
the last production release of RHEL. If we want a newer version of PHP,
we have to take over maintenance of that component. It becomes our
responsibility to install the updates, patches, etc., for that
component.

Once you get beyond a private web site these types of decisions become
part of the management process, just as make or buy decisions are part
of the hardware procurement process. There are people out there making a
good living just guiding companies through this decision making process.

Bob McConnell

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



[PHP] about to run PHP script when POST data.

2009-08-21 Thread Jacky
Hi guys,

As I know When we POST a big data(e.g. 500M) to a php script, the php script
only can run after the big data finished POST.

for example:
a.php

 ?php die(''); ?


and I post 500m data to a.php,  after that a.php cannot be died immediately.
only when the data finished post.

How can I make the a.php die before the 500m data finish?

Thanks in advance.

-- 
Regards,
Jacky


RE: [PHP] Invoking functions stored in a separate directory?

2009-08-21 Thread Arno Kuhl
-Original Message-
From: Clancy [mailto:clanc...@cybec.com.au] 
Sent: 21 August 2009 01:26 PM
To: php-general@lists.php.net
Subject: [PHP] Invoking functions stored in a separate directory?

I am developing an idea for a website engine which can be shared between
several different websites. Each website would have its own directory under
a common root directory, and the engine would be in a separate directory
Engine:

Root
Website_1.com, Website_2.com, Engine

The website directories would each contain the design data for that website,
consisting basically of a mixture of text files and images. The various
pages would be loaded by loading index.php from the website root directory,
and specifying a number of parameters e.g.

http://www.corybas.com/index.php?path=Holidayslevel=0item=0

I have the minimum amount of code in index.php -- just enough to set some
parameters to identify the website, and then include
../Engine/Main_prog.php.  This in turn can include any of a large number of
other include files to carry out particular functions. 

I have the prototype working nicely on my PC, and on a stand-alone basis on
a server, but now I am trying to upload the multi-website version to a
public host, and am encountering a number of problems, mainly because I have
never done any serious work with UNIX, and the host support staff don't
understand what I am trying to do.

The problems mainly relate to setting permissions to allow the website to
access the engine code. I only have a rough idea of how the permissions
work, but I think that to include engine code the website has to have read
and execute rights to it, and I also think that so far as the engine is
concerned the website will count as 'other'.  (I can easily arrange that all
temporary files are written in the website directory.)

I suspect that rather than including the engine code in index.php, it would
be better to call functions in it, so that the website only required
'execute' rights, but I don't know of any way to do this without having
anything running permanently on the server. Can anyone suggest how it can be
done?

-

Using include ../Engine/Main_prog.php won't work for you in a production
environment. You need to create a path.php file that defines the absolute
path to the engine for each website, and include it at the top of your
website script. Then you can do something like:

   include ENGINEPATH.Main_prog.php;

You can have different path files, one for dev and one for live, that allows
you to use the same scripts for both environments and just use the
appropriate path definition script.

E.g. Windows path.php
define('ENGINEPATH','../Engine/');

Linux path.php
define('ENGINEPATH','/usr/home/Engine/');

You shouldn't really have permission problems as long as your website and
engine are on the same server. I do something similar where the bulk of my
code is below doc root, and I use path files to find the main system
directories. The beauty of it is you can change your mind about directory
structures, and just change the path file definitions without making any
changes in the application code (my path file defines about 20 directories).
It also lets you do dev on a Windows pc and deploy on a *nix box without any
problems - just use a different path file for each.

One other advantage it will give you for your particualr design is that you
can have multiple engines per server (e.g. Engine1, Engine2, etc) so that
you can bring one engine down for upgrade while still keeping sites running
on the other engines.

Cheers
Arno



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



RE: [PHP] about to run PHP script when POST data.

2009-08-21 Thread Arno Kuhl
-Original Message-
From: Jacky [mailto:newbde...@gmail.com] 
Sent: 21 August 2009 03:12 PM
To: php-general@lists.php.net
Subject: [PHP] about to run PHP script when POST data.

Hi guys,

As I know When we POST a big data(e.g. 500M) to a php script, the php script
only can run after the big data finished POST.

for example:
a.php

 ?php die(''); ?


and I post 500m data to a.php,  after that a.php cannot be died immediately.
only when the data finished post.

How can I make the a.php die before the 500m data finish?

Thanks in advance.

--
Regards,
Jacky

---

Your script will die ungracefully when it runs out of execution time
(defined in php.ini)

Cheers
Arno


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



RE: [PHP] Is there limitation for switch case: argument's value?

2009-08-21 Thread Daevid Vincent
Whoa! I didn't even know you could use a switch statement like that. In 20
years of coding, I've never ever used a switch like that first if/else
style. PHP never ceases to amaze me in it's flexibility (and ability to
shoot yourself in the foot ;-p ) 

And remember, all your base are belong to Adam.

 -Original Message-
 From: Adam Randall [mailto:randa...@gmail.com] 
 Sent: Thursday, August 20, 2009 11:20 PM
 To: Keith
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Is there limitation for switch case: 
 argument's value?
 
 I've never understood why people use switch statements like this as in
 reality you are using it more like an if/else block, but anyway.
 
 The reason why your code is not working is that you are passing into
 the switch the value of 0, or false, which means that when any of
 those $sum == N conditionals comes up as false (say $sum == 8 ), then
 that is what is returned because they match up. In PHP's eyes, 0 ==
 false in switch statements.
 
 To fix your code, change the switch( $sum ) to switch( true ):
 
 switch( true )
 {
   case ($sum == 8):
   echo sum=8\n;
   break;
   case ($sum == 7 || $sum == 6):
   echo sum=7 or 6\n;
   break;
   case ($sum == 2 || $sum == 1):
   echo sum=2 or 1\n;
   break;
   case ($sum == 0):
   echo sum=0\n;
   break;
   default:
   echo sum=3/4/5\n;
   break;
 }
 
 Or, write your switch like this:
 
 switch( $sum )
 {
   case 8:
   echo sum=8\n;
   break;
   case 6:
   case 7:
   echo sum=7 or 6\n;
   break;
   case 1:
   case 2:
   echo sum=2 or 1\n;
   break;
   case 0:
   echo sum=0\n;
   break;
   default:
   echo sum=3/4/5\n;
   break;
 }
 
 Regards,
 
 Adam.
 
 On Thu, Aug 20, 2009 at 8:40 PM, 
 Keithsurvivor_...@hotmail.com wrote:
  Hi,
  I encounter a funny limitation here with switch case as below:
  The value for $sum is worked as expected for 1 to 8, but not for 0.
  When the $sum=0, the first case will be return, which is sum=8.
  Is there any limitation / rules for switch case? Thanks for advice!
 
  Keith
 
  $sum=0;
  switch($sum)
  {
    case ($sum==8):
    echo sum=8;
    break;
        case ($sum==7 || $sum==6):
        echo sum=7 or 6;
        break;
    case ($sum==2 || $sum==1):
    echo sum=2 or 1;
    break;
        case 0:
        echo sum=0;
        break;
    default:
    echo sum=3/4/5;
    break;
  }
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 
 -- 
 Adam Randall
 http://www.xaren.net
 AIM: blitz574
 
 -- 
 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] Re: Extract column names from a (my)SQL query

2009-08-21 Thread Daevid Vincent
 -Original Message-
 From: Nisse Engström [mailto:news.nospam.0ixbt...@luden.se] 

 If you're using MySQL, you can try mysql_field_name()
 and see if it gets you anywhere. I don't think it works
 on empty results though.


FYI. It will.


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



Re: [PHP] Re: Extract column names from a (my)SQL query

2009-08-21 Thread דניאל דנון
You all misunderstood my question, please read my replies above...

I'm looking to extract it from a string - *I'm not executing the queries, I
only get them as a string*

And to the topic:

Since everything I found was very complicated to parse, I've crafted my own
preg pattern,

/^(\*|[a-z_, \(\)0-9]+)[\s]+FROM[\s]+([a-z_\.
]+)\s+(WHERE[\s]+(.+)|)\s*(|ORDER BY ([a-z0-9,
])(|\s(DESC|ASC)))\s*(|LIMIT\s+([0-9]+)\s*,\s*([0-9]+))\s*$/Ui

(Assuming this is a SELECT string, and the subject is something similar to:
* FROM table WHERE field2='field3' LIMIT 0,10

(Yes, no SELECT - I've got another function to determine whether its select,
insert, update, delete from - etc, and it returns to query without the name
of the command - SELECT field FROM table = field FROM table)

(Without using joins or things like that)

But I don't have much experience crafting patterns like that - or working
with them so I'd be glad if  you think of a better way of doing it,

and problem is since I'm using sub-brackets, its hard to process it
since if there is WHERE and a LIMIT, then LIMIT (...) will be on $result[$n]
(for example),
But if there is no WHERE, then LIMIT (...) will be on $result[$n - 2];

How should I overcome this problem?


2009/8/21 Daevid Vincent dae...@daevid.com

  -Original Message-
  From: Nisse Engström [mailto:news.nospam.0ixbt...@luden.se]
 
  If you're using MySQL, you can try mysql_field_name()
  and see if it gets you anywhere. I don't think it works
  on empty results though.


 FYI. It will.


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




-- 
Use ROT26 for best security


Re: [PHP] Re: Extract column names from a (my)SQL query

2009-08-21 Thread דניאל דנון
Update: I've changed it into

/^(\*|[a-z_,
\(\)0-9]+)[\s]+FROM[\s]+([a-z_\.]+)(\s+)?(WHERE[\s]+(.+))?\s*(LIMIT\s+([0-9]+)\s*,\s*([0-9]+))?\s*(ORDER
BY ([a-z0-9, ]+)?(\s*(DESC|ASC)))?$/Ui


Only problem that on:
SELECT * FROM table WHERE field2='field3' ORDER BY id DESC LIMIT 0,10
it outputs

Array
(
[0] = * FROM table WHERE field2='field3' ORDER BY id DESC LIMIT 0,10
[1] = *
[2] = table
[3] =
[4] = WHERE field2='field3' ORDER BY id DESC
[5] = field2='field3' ORDER BY id DESC
[6] = LIMIT 0,10
[7] = 0
[8] = 10
)



On Fri, Aug 21, 2009 at 9:38 PM, דניאל דנון danondan...@gmail.com wrote:

 You all misunderstood my question, please read my replies above...

 I'm looking to extract it from a string - *I'm not executing the queries,
 I only get them as a string*

 And to the topic:

 Since everything I found was very complicated to parse, I've crafted my own
 preg pattern,

 /^(\*|[a-z_, \(\)0-9]+)[\s]+FROM[\s]+([a-z_\.
 ]+)\s+(WHERE[\s]+(.+)|)\s*(|ORDER BY ([a-z0-9,
 ])(|\s(DESC|ASC)))\s*(|LIMIT\s+([0-9]+)\s*,\s*([0-9]+))\s*$/Ui

 (Assuming this is a SELECT string, and the subject is something similar to:
 * FROM table WHERE field2='field3' LIMIT 0,10

 (Yes, no SELECT - I've got another function to determine whether its
 select, insert, update, delete from - etc, and it returns to query without
 the name of the command - SELECT field FROM table = field FROM table)

 (Without using joins or things like that)

 But I don't have much experience crafting patterns like that - or working
 with them so I'd be glad if  you think of a better way of doing it,

 and problem is since I'm using sub-brackets, its hard to process it
 since if there is WHERE and a LIMIT, then LIMIT (...) will be on $result[$n]
 (for example),
 But if there is no WHERE, then LIMIT (...) will be on $result[$n - 2];

 How should I overcome this problem?


 2009/8/21 Daevid Vincent dae...@daevid.com

  -Original Message-
  From: Nisse Engström [mailto:news.nospam.0ixbt...@luden.se]
 
  If you're using MySQL, you can try mysql_field_name()
  and see if it gets you anywhere. I don't think it works
  on empty results though.


 FYI. It will.


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




 --
 Use ROT26 for best security




-- 
Use ROT26 for best security


Re: [PHP] HTML text extraction

2009-08-21 Thread Manuel Lemos
Hello,

on 08/18/2009 05:37 AM leledumbo said the following:
 Usually, a website gives preview of its articles by extracting some of the
 first characters. This is easy if the article is a pure text, but what if
 it's a HTML text? For instance, if I have the full text:
 
 p
   bla bla bla
   ul
 liitem 1/li
 liitem 2/li
 liitem 3/li
   /ul
 /p
 
 and I take the first 40 characters, it would result in:
 
 p
   bla bla bla
   ul
 liitem
 
 As you can see, the tags are incomplete and it might break other texts below
 it (I mean, other than this preview). I need a way to solve this problem.

You may want to try these HTML parser classes. They can parse (and even
validate) HTML and return an array of tag or data elements. You can use
it to pick the first tags and data you. Then you you the RewriteElement
function to regenerate the HTML.

http://www.phpclasses.org/secure-html-filter

-- 

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

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



[PHP] Re: Tidy on a shared host

2009-08-21 Thread Manuel Lemos
Hello,

on 08/20/2009 09:47 PM Al said the following:
 Or, does anyone know of a stand-alone php class that emulates the tidy
 extension. I've looked; but, not found any.

Yes, you may want to try this Secure HTML parser filter package. It
comes with parser and a filter class that validates HTML against an
eventually auto-detected DTD. It returns an array of tag and data
elements that you can use to rebuild a valid HTML document using the
RewriteElement function.

http://www.phpclasses.org/secure-html-filter


-- 

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

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] Re: How to download and configure php mvc website locally

2009-08-21 Thread Paul M Foster
On Wed, Aug 19, 2009 at 11:00:46PM -1000, Sumit Sharma wrote:

 Hi all,
 The site I have download was developed using cake php. Now when trying to
 access the website it is showing a blank page. As Sudheer suggested I went
 to error log and noted down the errors there, which are as follows:
 
 [Thu Aug 20 14:10:16 2009] [error] [client 127.0.0.1] File does not exist:
 F:/Rabin/xampp/htdocs/favicon.ico
 
 I think there is no file called favicon.ico but how to create this file. Is
 this something related to cakephp configuration.
 
 Regards,
 Sumit

Lack of favicon.ico will show up in your logs if the file isn't there,
but it will do nothing to prevent your site from showing up.

Frameworks like CakePHP require additional files and database tables to
be created by the programmer, before anything will show up on the
screen. There are either omitted files or missing tables (or missing
table rows).

Paul

-- 
Paul M. Foster

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



[PHP] Re: How do I extract link text from anchor tag as well as the URL from the href attribute

2009-08-21 Thread Manuel Lemos
Hello,

on 08/16/2009 04:33 AM chrysanhy said the following:
 I have the following code to extract the URLs from the anchor tags of an
 HTML page:
 
 $html = new DOMDocument();
 $htmlpage-loadHtmlFile($location);
 $xpath = new DOMXPath($htmlpage);
 $links = $xpath-query( '//a' );
 foreach ($links as $link)
 { $int_url_list[$i++] = $link-getAttribute( 'href' ) . \n; }
 
 If I have a link a href=http://X.com;/a, how do I extract the
 corresponding  which is displayed to the user as the text of the link
 (if it's an image tag, I would like a DOMElement for that).
 Thanks

You may want to try this HTML parser class that comes with filter class
and an example script named test_get_html_links.php  that does exactly
what you ask.

http://www.phpclasses.org/secure-html-filter

-- 

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

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