php-general Digest 10 May 2010 10:39:40 -0000 Issue 6736

2010-05-10 Thread php-general-digest-help

php-general Digest 10 May 2010 10:39:40 - Issue 6736

Topics (messages 305026 through 305032):

__call and recursion
305026 by: Daniel Kolbo
305027 by: Peter Lind
305028 by: Nathan Nobbe
305029 by: Peter Lind

Re: PHP Encoder like IonCube
305030 by: donald sullivan
305031 by: shiplu

PHP Application Structre
305032 by: Alex Major

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---
Hello,

I've defined a __call() method inside a class.  Within the __call()
method (after testing that the method exists and is callable I am using:

call_user_func_array(array($this,$method), $args);

However, this seems to be an infinite loop (and is crashing my test
apache server).  How, could I still use the __call() method and avoid an
infinite loop of calling?

Thanks,
dK
`
---End Message---
---BeginMessage---
On 9 May 2010 23:21, Daniel Kolbo kolb0...@umn.edu wrote:
 Hello,

 I've defined a __call() method inside a class.  Within the __call()
 method (after testing that the method exists and is callable I am using:

 call_user_func_array(array($this,$method), $args);

 However, this seems to be an infinite loop (and is crashing my test
 apache server).  How, could I still use the __call() method and avoid an
 infinite loop of calling?

Assuming that your __call() method was reached because no $method was
defined, using call_user_func_array() to call $method on the same
object is going to result in ... your __call() method getting called
again. You need to map the $method to whichever class methods you
*actually* want to call, instead of blindly trying to reissue the
call.

Regards
Peter


-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype
---End Message---
---BeginMessage---
On Sun, May 9, 2010 at 3:25 PM, Peter Lind peter.e.l...@gmail.com wrote:

 On 9 May 2010 23:21, Daniel Kolbo kolb0...@umn.edu wrote:
  Hello,
 
  I've defined a __call() method inside a class.  Within the __call()
  method (after testing that the method exists and is callable I am using:
 
  call_user_func_array(array($this,$method), $args);
 
  However, this seems to be an infinite loop (and is crashing my test
  apache server).  How, could I still use the __call() method and avoid an
  infinite loop of calling?

 Assuming that your __call() method was reached because no $method was
 defined, using call_user_func_array() to call $method on the same
 object is going to result in ... your __call() method getting called
 again. You need to map the $method to whichever class methods you
 *actually* want to call, instead of blindly trying to reissue the
 call.


according to op it sounds like hes not blindly reissuing the call,

(after testing that the method exists and is callable I am using:

anyways, Daniel, your code seems sound, hard to say where the recursion is
coming from.  why not just dump the methods youre trying to invoke via
var_dump() or error_log() etc?

eg
..
var_dump($method);
call_user_func_array(array($this,$method), $args);


-nathan
---End Message---
---BeginMessage---
On 9 May 2010 23:56, Nathan Nobbe quickshif...@gmail.com wrote:
 On Sun, May 9, 2010 at 3:25 PM, Peter Lind peter.e.l...@gmail.com wrote:

 On 9 May 2010 23:21, Daniel Kolbo kolb0...@umn.edu wrote:
  Hello,
 
  I've defined a __call() method inside a class.  Within the __call()
  method (after testing that the method exists and is callable I am using:
 
  call_user_func_array(array($this,$method), $args);
 
  However, this seems to be an infinite loop (and is crashing my test
  apache server).  How, could I still use the __call() method and avoid an
  infinite loop of calling?

 Assuming that your __call() method was reached because no $method was
 defined, using call_user_func_array() to call $method on the same
 object is going to result in ... your __call() method getting called
 again. You need to map the $method to whichever class methods you
 *actually* want to call, instead of blindly trying to reissue the
 call.

 according to op it sounds like hes not blindly reissuing the call,
 (after testing that the method exists and is callable I am using:

Good point that, misread. Would be good to see the code checking
availability of the method, to get some idea of the error.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype
---End Message---
---BeginMessage---
bcompiler is available, but with the correct tools data can still be extracted.

Re: [PHP] PHP Encoder like IonCube

2010-05-10 Thread shiplu
On Mon, May 10, 2010 at 6:28 AM, donald sullivan don...@nixspot.com wrote:
 bcompiler is available, but with the correct tools data can still be 
 extracted.
 http://php.net/manual/en/book.bcompiler.php

Its not a problem if data can still be extracted. But I guess exact
data can not be extracted.
If thats the case its okay. Sometimes an obfuscated code is enough to
protect it.

As far I remember I heard somewhere it can be achieved by e-accelerator somehow.
How is it possible?


Shiplu Mokadd.im
My talks, http://talk.cmyweb.net
Follow me, http://twitter.com/shiplu
SUST Programmers, http://groups.google.com/group/p2psust
Innovation distinguishes bet ... ... (ask Steve Jobs the rest)

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



[PHP] PHP Application Structre

2010-05-10 Thread Alex Major
Greetings all,

 

This question basically surrounds how you structure your PHP applications,
whether it changes depending on what you're doing and which you'd favour. I
have a feeling it'll come down to a question of personal taste, but on the
off-chance there's a best practice I'll ask anyways.

 

From what I've seen and used, there seem to be three distinct ways of going
about it.

 

1)  Using a 'core' class which has a request handler in it. All pages in
the site are accessed through that one page, e.g.

 

http://www.somesite.com/index.php?page=ViewUser
http://www.somesite.com/index.php?page=ViewProduct

 

This is one that I've personally used most after becoming familiar with a
bulletin board system several years ago. It means that pages are easily
created as all the template/session/database handling is done by the central
class.

 

2)  Using SE friendly URL's like:

 

http://www.somesite.com/products/22012/cool-game/
http://www.somesite.com/products/22013/other-game/

 

This approach seems to be becoming more common on the sites I frequent,
however by accounts I've read it seems to be more intensive on apache as it
requires a mod-rewrite function. 

 

3)  Using different PHP files for each page:

 

http://www.somesite.com/viewproduct.php?product=
http://www.somesite.com/viewuser.php?user=...

 

This would appear to be the least developer friendly option?

 

Hopefully someone can shed some insight into which is the recommended
approach and why. I've been building bigger and bigger sites so having a
solid foundation is becoming more and more important.

 

Thanks for any help/feedback, I hope I've been clear.

 

Alex.



RE: [PHP] PHP Application Structre

2010-05-10 Thread Arno Kuhl
-Original Message-
From: Alex Major [mailto:p...@allydm.co.uk] 
Sent: 10 May 2010 12:39 PM

From what I've seen and used, there seem to be three distinct ways of going
about it.

1)  Using a 'core' class which has a request handler in it. All pages in
the site are accessed through that one page, e.g.
http://www.somesite.com/index.php?page=ViewUser
http://www.somesite.com/index.php?page=ViewProduct
This is one that I've personally used most after becoming familiar with a
bulletin board system several years ago. It means that pages are easily
created as all the template/session/database handling is done by the central
class.

2)  Using SE friendly URL's like:
http://www.somesite.com/products/22012/cool-game/
http://www.somesite.com/products/22013/other-game/
This approach seems to be becoming more common on the sites I frequent,
however by accounts I've read it seems to be more intensive on apache as it
requires a mod-rewrite function. 

3)  Using different PHP files for each page:
http://www.somesite.com/viewproduct.php?product=
http://www.somesite.com/viewuser.php?user=...
This would appear to be the least developer friendly option?
 
Alex.

=

The second option doesn't really belong here, because you could go for
option 1 or option 3, and then decide whether to hide your implementation
behind a mod-rewrite. Option 2 would rather be part of a separate question
what is the cost/benefit of using mod-rewrite.

Cheers
Arno



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



Re: [PHP] PHP Encoder like IonCube

2010-05-10 Thread Ashley Sheridan
On Mon, 2010-05-10 at 12:42 +0600, shiplu wrote:

 On Mon, May 10, 2010 at 6:28 AM, donald sullivan don...@nixspot.com wrote:
  bcompiler is available, but with the correct tools data can still be 
  extracted.
  http://php.net/manual/en/book.bcompiler.php
 
 Its not a problem if data can still be extracted. But I guess exact
 data can not be extracted.
 If thats the case its okay. Sometimes an obfuscated code is enough to
 protect it.
 
 As far I remember I heard somewhere it can be achieved by e-accelerator 
 somehow.
 How is it possible?
 
 
 Shiplu Mokadd.im
 My talks, http://talk.cmyweb.net
 Follow me, http://twitter.com/shiplu
 SUST Programmers, http://groups.google.com/group/p2psust
 Innovation distinguishes bet ... ... (ask Steve Jobs the rest)
 


I have to ask, why do you want to do that? Wouldn't it be easier to
offer your application as a system that only you host. That way, the
end-user never gets to see your PHP code.

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




Re: [PHP] PHP Encoder like IonCube

2010-05-10 Thread Peter Lind
On 10 May 2010 13:25, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
 On Mon, 2010-05-10 at 12:42 +0600, shiplu wrote:

 On Mon, May 10, 2010 at 6:28 AM, donald sullivan don...@nixspot.com wrote:
  bcompiler is available, but with the correct tools data can still be 
  extracted.
  http://php.net/manual/en/book.bcompiler.php
 
 Its not a problem if data can still be extracted. But I guess exact
 data can not be extracted.
 If thats the case its okay. Sometimes an obfuscated code is enough to
 protect it.

 As far I remember I heard somewhere it can be achieved by e-accelerator 
 somehow.
 How is it possible?


 Shiplu Mokadd.im
 My talks, http://talk.cmyweb.net
 Follow me, http://twitter.com/shiplu
 SUST Programmers, http://groups.google.com/group/p2psust
 Innovation distinguishes bet ... ... (ask Steve Jobs the rest)



 I have to ask, why do you want to do that? Wouldn't it be easier to
 offer your application as a system that only you host. That way, the
 end-user never gets to see your PHP code.


Not to mention: if it runs, it can be broken.

Regards
Peter


-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



[PHP] Re: PHP Encoder like IonCube

2010-05-10 Thread shiplu
Hello Ashley,
My application will not be accessible through Internet.  Users will
use it through internal network. And internet is strictly prohibited
there. Thats the reason why i'm lookin for such solution.

On 5/10/10, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
 On Mon, 2010-05-10 at 12:42 +0600, shiplu wrote:

 On Mon, May 10, 2010 at 6:28 AM, donald sullivan don...@nixspot.com
 wrote:
  bcompiler is available, but with the correct tools data can still be
  extracted.
  http://php.net/manual/en/book.bcompiler.php
 
 Its not a problem if data can still be extracted. But I guess exact
 data can not be extracted.
 If thats the case its okay. Sometimes an obfuscated code is enough to
 protect it.

 As far I remember I heard somewhere it can be achieved by e-accelerator
 somehow.
 How is it possible?


 Shiplu Mokadd.im
 My talks, http://talk.cmyweb.net
 Follow me, http://twitter.com/shiplu
 SUST Programmers, http://groups.google.com/group/p2psust
 Innovation distinguishes bet ... ... (ask Steve Jobs the rest)



 I have to ask, why do you want to do that? Wouldn't it be easier to
 offer your application as a system that only you host. That way, the
 end-user never gets to see your PHP code.

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




-- 
Sent from my mobile device

Shiplu Mokadd.im
My talks, http://talk.cmyweb.net
Follow me, http://twitter.com/shiplu
SUST Programmers, http://groups.google.com/group/p2psust
Innovation distinguishes bet ... ... (ask Steve Jobs the rest)

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



Re: [PHP] PHP Encoder like IonCube

2010-05-10 Thread Phpster



On May 10, 2010, at 7:36 AM, Peter Lind peter.e.l...@gmail.com wrote:

On 10 May 2010 13:25, Ashley Sheridan a...@ashleysheridan.co.uk  
wrote:

On Mon, 2010-05-10 at 12:42 +0600, shiplu wrote:

On Mon, May 10, 2010 at 6:28 AM, donald sullivan  
don...@nixspot.com wrote:
bcompiler is available, but with the correct tools data can still  
be extracted.

http://php.net/manual/en/book.bcompiler.php


Its not a problem if data can still be extracted. But I guess exact
data can not be extracted.
If thats the case its okay. Sometimes an obfuscated code is enough  
to

protect it.

As far I remember I heard somewhere it can be achieved by e- 
accelerator somehow.

How is it possible?


Shiplu Mokadd.im
My talks, http://talk.cmyweb.net
Follow me, http://twitter.com/shiplu
SUST Programmers, http://groups.google.com/group/p2psust
Innovation distinguishes bet ... ... (ask Steve Jobs the rest)




I have to ask, why do you want to do that? Wouldn't it be easier to
offer your application as a system that only you host. That way, the
end-user never gets to see your PHP code.



Not to mention: if it runs, it can be broken.

Regards
Peter


--
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



Not to mention that is what contracts are for.

Bastien

Sent from my iPod

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



RE: [PHP] PHP Application Structre

2010-05-10 Thread Ashley Sheridan
On Mon, 2010-05-10 at 13:15 +0200, Arno Kuhl wrote:

 -Original Message-
 From: Alex Major [mailto:p...@allydm.co.uk] 
 Sent: 10 May 2010 12:39 PM
 
 From what I've seen and used, there seem to be three distinct ways of going
 about it.
 
 1)  Using a 'core' class which has a request handler in it. All pages in
 the site are accessed through that one page, e.g.
 http://www.somesite.com/index.php?page=ViewUser
 http://www.somesite.com/index.php?page=ViewProduct
 This is one that I've personally used most after becoming familiar with a
 bulletin board system several years ago. It means that pages are easily
 created as all the template/session/database handling is done by the central
 class.
 
 2)  Using SE friendly URL's like:
 http://www.somesite.com/products/22012/cool-game/
 http://www.somesite.com/products/22013/other-game/
 This approach seems to be becoming more common on the sites I frequent,
 however by accounts I've read it seems to be more intensive on apache as it
 requires a mod-rewrite function. 
 
 3)  Using different PHP files for each page:
 http://www.somesite.com/viewproduct.php?product=
 http://www.somesite.com/viewuser.php?user=...
 This would appear to be the least developer friendly option?
  
 Alex.
 
 =
 
 The second option doesn't really belong here, because you could go for
 option 1 or option 3, and then decide whether to hide your implementation
 behind a mod-rewrite. Option 2 would rather be part of a separate question
 what is the cost/benefit of using mod-rewrite.
 
 Cheers
 Arno
 
 
 


Personally, I go with option 3 (as Arno said, option 2 isn't really an
alternative option, it's something you can use with either 1 or 3)

Consider a basic website with a small shopping cart and a blog. It would
seem crazy to have all the logic needed for the blog and the cart being
pulled in by PHP everytime you just needed to display a contact page.
Far easier to keep everything a bit more modular. That way, if you need
to update something, you update only a small part of the site rather
than some huge core file.

But, if your needs are even more simple, say it's just a very small
brochure website you have, then running everything through a single
index.php might not be such a bad idea.

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




[PHP] Re: PHP Encoder like IonCube

2010-05-10 Thread Ashley Sheridan
On Mon, 2010-05-10 at 17:51 +0600, shiplu wrote:

 Hello Ashley,
 My application will not be accessible through Internet.  Users will
 use it through internal network. And internet is strictly prohibited
 there. Thats the reason why i'm lookin for such solution.
 
 On 5/10/10, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
  On Mon, 2010-05-10 at 12:42 +0600, shiplu wrote:
 
  On Mon, May 10, 2010 at 6:28 AM, donald sullivan don...@nixspot.com
  wrote:
   bcompiler is available, but with the correct tools data can still be
   extracted.
   http://php.net/manual/en/book.bcompiler.php
  
  Its not a problem if data can still be extracted. But I guess exact
  data can not be extracted.
  If thats the case its okay. Sometimes an obfuscated code is enough to
  protect it.
 
  As far I remember I heard somewhere it can be achieved by e-accelerator
  somehow.
  How is it possible?
 
 
  Shiplu Mokadd.im
  My talks, http://talk.cmyweb.net
  Follow me, http://twitter.com/shiplu
  SUST Programmers, http://groups.google.com/group/p2psust
  Innovation distinguishes bet ... ... (ask Steve Jobs the rest)
 
 
 
  I have to ask, why do you want to do that? Wouldn't it be easier to
  offer your application as a system that only you host. That way, the
  end-user never gets to see your PHP code.
 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
 
 


Maybe you need a binary compiler then? This would limit your system to
one type of OS though. For example, if you compiled it for 64-bit
Windows, then you couldn't use it on a 32-bit server. Essentially you'd
need to compile different versions for each architecture that you want
to support. Would you compile it for Mac and Linux too (not forgetting
the 32/64-bit issue there too)

If a binary compile is what you're looking for then there was a thread a
while back about the compiler that Facebook released which might be of
some use?


Ps, please try not to top post on the list.

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




Re: [PHP] PHP Application Structre

2010-05-10 Thread Peter Lind
On 10 May 2010 13:58, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
 On Mon, 2010-05-10 at 13:15 +0200, Arno Kuhl wrote:

 -Original Message-
 From: Alex Major [mailto:p...@allydm.co.uk]
 Sent: 10 May 2010 12:39 PM

 From what I've seen and used, there seem to be three distinct ways of going
 about it.

 1)      Using a 'core' class which has a request handler in it. All pages in
 the site are accessed through that one page, e.g.
 http://www.somesite.com/index.php?page=ViewUser
 http://www.somesite.com/index.php?page=ViewProduct
 This is one that I've personally used most after becoming familiar with a
 bulletin board system several years ago. It means that pages are easily
 created as all the template/session/database handling is done by the central
 class.

 2)      Using SE friendly URL's like:
 http://www.somesite.com/products/22012/cool-game/
 http://www.somesite.com/products/22013/other-game/
 This approach seems to be becoming more common on the sites I frequent,
 however by accounts I've read it seems to be more intensive on apache as it
 requires a mod-rewrite function.

 3)      Using different PHP files for each page:
 http://www.somesite.com/viewproduct.php?product=
 http://www.somesite.com/viewuser.php?user=...
 This would appear to be the least developer friendly option?

 Alex.

 =

 The second option doesn't really belong here, because you could go for
 option 1 or option 3, and then decide whether to hide your implementation
 behind a mod-rewrite. Option 2 would rather be part of a separate question
 what is the cost/benefit of using mod-rewrite.

 Cheers
 Arno





 Personally, I go with option 3 (as Arno said, option 2 isn't really an
 alternative option, it's something you can use with either 1 or 3)

 Consider a basic website with a small shopping cart and a blog. It would
 seem crazy to have all the logic needed for the blog and the cart being
 pulled in by PHP everytime you just needed to display a contact page.
 Far easier to keep everything a bit more modular. That way, if you need
 to update something, you update only a small part of the site rather
 than some huge core file.

 But, if your needs are even more simple, say it's just a very small
 brochure website you have, then running everything through a single
 index.php might not be such a bad idea.

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


Option 1 with option 2 as a sidedish. Option 3 is a nightmare in my
experience - a proper MVC approach is much better to work, maintain
and assure the security of.

Regards
Peter


-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



RE: [PHP] PHP Application Structre

2010-05-10 Thread Arno Kuhl
  _  

From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: 10 May 2010 01:58 PM
To: a...@dotcontent.net
Cc: 'Alex Major'; 'php-general General List'
Subject: RE: [PHP] PHP Application Structre


On Mon, 2010-05-10 at 13:15 +0200, Arno Kuhl wrote: 

-Original Message-

From: Alex Major [mailto:p...@allydm.co.uk] 

Sent: 10 May 2010 12:39 PM



From what I've seen and used, there seem to be three distinct ways of going

about it.



1)  Using a 'core' class which has a request handler in it. All pages in

the site are accessed through that one page, e.g.

http://www.somesite.com/index.php?page=ViewUser

http://www.somesite.com/index.php?page=ViewProduct

This is one that I've personally used most after becoming familiar with a

bulletin board system several years ago. It means that pages are easily

created as all the template/session/database handling is done by the central

class.



2)  Using SE friendly URL's like:

http://www.somesite.com/products/22012/cool-game/

http://www.somesite.com/products/22013/other-game/

This approach seems to be becoming more common on the sites I frequent,

however by accounts I've read it seems to be more intensive on apache as it

requires a mod-rewrite function. 



3)  Using different PHP files for each page:

http://www.somesite.com/viewproduct.php?product=

http://www.somesite.com/viewuser.php?user=...

This would appear to be the least developer friendly option?

 

Alex.



=



The second option doesn't really belong here, because you could go for

option 1 or option 3, and then decide whether to hide your implementation

behind a mod-rewrite. Option 2 would rather be part of a separate question

what is the cost/benefit of using mod-rewrite.



Cheers

Arno








Personally, I go with option 3 (as Arno said, option 2 isn't really an
alternative option, it's something you can use with either 1 or 3)

Consider a basic website with a small shopping cart and a blog. It would
seem crazy to have all the logic needed for the blog and the cart being
pulled in by PHP everytime you just needed to display a contact page. Far
easier to keep everything a bit more modular. That way, if you need to
update something, you update only a small part of the site rather than some
huge core file.

But, if your needs are even more simple, say it's just a very small brochure
website you have, then running everything through a single index.php might
not be such a bad idea.



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

 ==
 
There are many approaches to this, and I think your final design will
largely be determined by what you want to do, and your own skill and
experience.
 
If you want to initialise your application, check input and load all your
base api functions before calling the specific script (function) to handle
the query, then maybe you can consider using a single entry point for your
application. It can simplify your design and maintenance, and there are ways
to ensure that access to your scripts have been initialised via the single
entry point. Careful design can allow you to add new
modules/scripts/whatever without having to update your single entry point
each time (look at some open-source apps for examples). It also allows you
to move your entire application to some place outside the document root and
leave only the entry script open to the public, which can add a bit of extra
security to your application. 
 
Personally I use two entry-points, one for admin and one for everything
else. Then besides graphics, flash and javascript, everything else is put
someplace outside the document root. The reason I settled on that approach
was because the admin script can handle all the slow heavy security-checking
stuff and loading additional admin api's, while the general script can be
small, fast and lightweight, but won't allow any access to the admin
functions. Neither script needs to be updated when adding to or changing the
main application.
 
Cheers
Arno


Re: [PHP] xpath help

2010-05-10 Thread Gary .
On 5/9/10, Peter Lind wrote:
 On 9 May 2010 10:31, Gary wrote:
 If I have a document containing, say:
 html
...

 How do I get at bar2? I tried everything, based on an xpath from
 Firebug (Firefox plugin), but kept getting NULL.


 try //table//font - that should give you all the font elements in
 table elements. Given your layout, you're then looking for
 $list-item(3)

I found out what my problem was. Something, somewhere - the plugin,
Firefox itself, something - decided to help me by inserting TBODY
elements into the xpath which just plain did not exist in the original
HTML.

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



RE: [PHP] How to get input from socket client

2010-05-10 Thread Bob McConnell
From: Ryan Sun

   Stream and networking programming seems like a rock on the way to
 ZCE for most people, so I'm learning some socket examples before I sit
 in the room for exam.
 Here is the script for server

snip

 serverclient hangs after output and time out later.
 
 Can any1 point out whats the reason and the more correct way to get
 socket client input in socket server?

I have not done any socket programs in PHP, but I have in Assembler, C
and Perl. First, I don't think feof() will do what you think it does. I
wouldn't expect it to show up until after the other end has actually
closed the connection.

The other problem has to do with thinking an fread() will always give
you everything you sent in an fwrite(). TCP is a stream protocol, there
are no guarantees about delivering a complete message in one read, or
that two writes won't be read together. It only guarantees that all
octets will eventually be delivered in the same order they were sent, or
you will get an error. The buffering is completely hidden and outside of
your control. If you want writes to be atomic, you want UDP, but then
you lose the guarantee of delivery. If you want to enforce a structure
on the data in that stream, it is your application's responsibility to
reconstruct that data at the receiver.

One other detail that may or may not make a difference. TCP actually
defines two independent pipes, one in each direction. Many Unix
applications create two processes to service a socket, one to send, the
other to receive. Only occasionally does a protocol require alternating
messages similar to a conversation or ping-pong match.

Bob McConnell

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



[PHP] PHP Image Host - Sending HTTP Headers Twice?

2010-05-10 Thread APseudoUtopia
I have a php script which serves an image. It's very simple:

header('Content-Type: image/' . $ImageData['content_type']);
readfile($File);

When viewing the script with the Firefox Extension: LiveHTTPHeaders,
it gives the following output for a SINGLE request:

--
https://domain.tld/img.php?i=260

GET /img.php?i=260 HTTP/1.1
Host: domain.tld
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US;
rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: UTF-8,*
Keep-Alive: 115
Connection: keep-alive
Cookie: session=blahblah
Cache-Control: max-age=0

HTTP/1.1 200 OK
Server: nginx
Date: Mon, 10 May 2010 20:17:09 GMT
Content-Type: image/jpeg
Transfer-Encoding: chunked
Connection: keep-alive
--
https://domain.tld/img.php?i=260

GET /img.php?i=260 HTTP/1.1
Host: domain.tld
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US;
rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: UTF-8,*
Keep-Alive: 115
Connection: keep-alive

HTTP/1.1 200 OK
Server: nginx
Date: Mon, 10 May 2010 20:17:10 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Content-Encoding: gzip
--



As you can see, the browser is requesting the image twice, and PHP is
sending two different Content-Type headers. Why is this?

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



Re: [PHP] simplexml choking on apparently valid XML - Solved

2010-05-10 Thread Brian Dunning
I was able to resolve this by changing the XML file encoding from UTF-8 to 
ISO-8859-1. Works like a charm now, with the XML-encoded characters.

Thanks to all who offered their help.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP Application Structre

2010-05-10 Thread David McGlone
On Monday 10 May 2010 13:04:36 richard gray wrote:
 On 10/05/2010 18:17, Ashley Sheridan wrote:
  It makes sense sometimes to have different files for different sections
  of a website. For example, blog.php, gallery.php, cart.php could deal
  with the blog, gallery and shopping cart sections for an artists
  website. Yes, it could all be achieved with one script handling
  everything, but sometimes when the areas of the site differ greatly, it
  results in a lot of extra code to deal with pulling in the right
  template and content parts. I've always favoured only including the code
  a page needs rather than a huge amount of stuff that it doesn't.

 this isn't necessarily true - the architecture I've developed uses a
 single dispatch script (works fine with the mod rewrite option 2
 scenario as well) - this script does general checks/security/filters etc
 then simply determines what page/function the user wants from the
 request ($_GET/$_POST parameter) and passes control to the specific
 handler via including the relevant controller module. The controller
 module is responsible for which template is required and loads up
 specific classes needed to process the request etc so each module just
 loads its own stuff and nothing else so there's no overhead.

 This method also has a small extra benefit that the web server document
 root just has a very simple 2 liner script instead a myriad of php
 scripts... if the webserver is misconfigured then someone who sees the
 source code doesn't get to see much..

This thread makes me wonder if using Smarty is smart. Does anyone here use a 
templeting system such as smarty or am I the only one?

-- 
Blessings,
David M.

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



[PHP] regexp questions

2010-05-10 Thread Spud. Ivan.


Hi,

I've recently changed from php 5.1 to 5.3.2 and I'm havong problems with 
preg_match, because the same regular expressions used in php 5.1 are not 
matching anything in 5.3.2.

There are any significant changes that I should know? 

I've been searching but I haven't found anything.

Thanks.
I.Lopez.

  
_
Recibe en tu HOTMAIL los emails de TODAS tus CUENTAS. + info
http://www.vivelive.com/hotmail-la-gente-de-hoy/index.html?multiaccount

Re: [PHP] regexp questions

2010-05-10 Thread shiplu
For example,  the following regex doesn't work.

return (bool) preg_match('/^[\pL\pN\pZ\p{Pc}\p{Pd}\p{Po}]++$/uD',
(string) $str);



Shiplu Mokadd.im
My talks, http://talk.cmyweb.net
Follow me, http://twitter.com/shiplu
SUST Programmers, http://groups.google.com/group/p2psust
Innovation distinguishes bet ... ... (ask Steve Jobs the rest

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



[PHP] php path and relink

2010-05-10 Thread Augusto Flavio
Hi,


I have a shell account with limited access. The php cli version installated
is 4.4.6. But the server have also the php 5.2.6. I checked the php version
and i got this:


$ php -v
PHP 4.4.9 (cli) (built: Sep 17 2008 11:04:03)
.

But i want that the php command be a link to the php5.

How can i re-link this php command to the path /usr/local/php5/bin/php ?

I tried include this path in the PATH variable env but didn't worked.


Some idea?


Thanks

Augusto Morais.


RE: [PHP] regexp questions

2010-05-10 Thread Spud. Ivan.

Is there any place where to read the changelog or something?

Thanks.



For example,  the following regex doesn't work.
 
return (bool) preg_match('/^[\pL\pN\pZ\p{Pc}\p{Pd}\p{Po}]++$/uD',
(string) $str);
 
 
 
Shiplu Mokadd.im

  
_
Disfruta de Messenger y Hotmail en tu BlackBerry ¡Hazlo ya!
http://serviciosmoviles.es.msn.com/messenger/blackberry.aspx

Re: [PHP] php path and relink

2010-05-10 Thread Ashley Sheridan
On Mon, 2010-05-10 at 21:23 -0300, Augusto Flavio wrote:

 Hi,
 
 
 I have a shell account with limited access. The php cli version installated
 is 4.4.6. But the server have also the php 5.2.6. I checked the php version
 and i got this:
 
 
 $ php -v
 PHP 4.4.9 (cli) (built: Sep 17 2008 11:04:03)
 .
 
 But i want that the php command be a link to the php5.
 
 How can i re-link this php command to the path /usr/local/php5/bin/php ?
 
 I tried include this path in the PATH variable env but didn't worked.
 
 
 Some idea?
 
 
 Thanks
 
 Augusto Morais.


How are you calling the script to be executed by PHP? Can't you add the
path to the version of PHP you want to use there?

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