Re: [PHP] Do defined variables exist at application scope, or session scope?

2008-12-27 Thread Nathan Nobbe
On Sat, Dec 27, 2008 at 12:54 AM, Murray planetthought...@gmail.com wrote:

 Hi Larry,

 You're absolutely right, I'm talking about constants rather than variables.

 I guess in my very crude way, I'm trying to ask about the following:

 UserA goes to the site via index.php, which defines several helpful
 constants.

 So do UserB through UserF.

 UserG, however, first arrives at the site on help.php.

 Because UserA, UserB, UserC etc have been to index.php, which has now been
 executed, are the constants available with their values in help.php, even
 though UserG, in particular, started in the application at this point?

 So, another way of putting it, do these constants live for the life of the
 application per se (ie, presumably until the server is restarted etc), or
 will code in help.php be unable to access the values of defined constants
 for this particular user because they were not at index.php first?


no, global variables do not persist at a session level.

you could easily discover this with a simple test (following code untested
:)).

testDefineScope1.php
?php
define('MY_GLOBAL', 5);
session_start();
$_SESSION['SESSION_VAR'] = 10;

testDefineScope2.php
?php
var_dump($_SESSION['SESSION_VAR']);
var_dump(MY_GLOBAL);

test,

1. go to testDefineScope1.php
. MY_GLOBAL will be defined for the duration of testDefineScope1.php's
execution
. $_SESSION['SESSION_VAR'] will be placed into the session

2. go to testDefineScope2.php
  . $_SESSION['SESSION_VAR'] is in the session and will be displayed
  . MY_GLOBAL expired after testDefineScope1.php finished executing and
therefore a fatal should be raised at thte second statement

-nathan


[PHP] PHP script gives no output or error message

2008-12-27 Thread John Musbach
I have the latest version of FUDforum setup and am trying to create a
hack that'll allow users who authenticate through our groups kerberos
authentication gateway to automatically be logged in. The source code
is as follows:

?php
//Here we grab the authenticated user's name
//and either automatically log them in using an existing account
//or register them
error_reporting(E_ALL);
ini_set('display_errors',1);

require('/users/u15/jmusbach/.html_pages/FUDforum2/GLOBALS.php');
require('/users/u15/jmusbach/FUDforumDAT/scripts/fudapi.inc.php');
require('/users/u15/jmusbach/FUDforumDAT/scripts/forum_login.php');

global $_SERVER;
$user=$_SERVER['WEBAUTH_USER'];
$realname = $_SERVER['WEBAUTH_LDAP_GIVENNAME'] . ' '
.$_SERVER['WEBAUTH_LDAP_SN'];
$email = $user . '@blah.com';
$error=;

if(external_fud_login(fud_fetch_user($user)['id']))!=NULL) //User ID
is valid and logged in
{
echo(Welcome,  . $user . , please wait while you are logged in...);
header( 'Location: https://blah.com/~jmusbach/FUDforum2/' ) ;
}
else //User ID is invalid, register and log in
{
echo(Welcome,  . $user . , please wait while you are registered
and logged in...);
if(fud_add_user(array($user,password,$email,$realname),$error)!=0)
{
  external_fud_login(fud_fetch_user($user)['id']));
  header('Location: https://blah.com/~jmusbach/FUDforum2/');
}
else
{
  echo($error);
  die();
}

}



?

Unfortunately no errors are returned and the output is completely
blank, any ideas as to where I've gone wrong (e.g. obvious syntax
errors)? I'm new to PHP so I've probably done something with the
syntax that you're not supposed to do in PHP. I would gladly ask this
question in the FUDforum support forums but despite it being many days
since I've registered the administrator still has yet to manually
activate my account so hopefully I can get some help here. :)

P.S. In case it helps you can see the source code to the API files I
referenced here:

fudapi.inc.php: http://pastebin.com/m349a4bff
forum_login.php: http://pastebin.com/m176b28b3

-- 
Best Regards,

John Musbach

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



Re: [PHP] Decorator with public methods

2008-12-27 Thread Nathan Nobbe
On Sat, Dec 27, 2008 at 12:02 AM, Larry Garfield la...@garfieldtech.comwrote:

 On Friday 26 December 2008 11:06:07 pm Nathan Nobbe wrote:

  to summarize, using your example above, i would most liely add doThings()
  to Baz, or create another decoration interface for doThings() if you plan
  on using the Bar implementation of doThings() in many places,
 
  interface G {
function doThings();
  }
 
  class Bar extends Decorator implements G {
function doThings() {
  // concreate implementation
}
  }
 
  class Baz implements F, G {
// recycle Bar::doThings()
public function doThings() {
  return $this-foo-doThings();
}
public function doOtherThings() {}
  }
 
  i appologize if this response is long winded, but im a big fan of the
  decorator, and ive actually got some pretty slick code in production in
 the
  photobucket code that uses the decorator pattern :D  it took about 2
 months
  to code, and i leraned a lot about some of the practical aspects of
  decroration, specifically within the realm of php.  i know i repeated a
 few
  things there, but i felt it neccessary to better explain myself.
 
  -nathan

 Thanks, Nathan.  Unfortunately, what you describe is impossible.  It
 requires
 me to know all the possible decorators ahead of time and implement the
 interface for each in each decorator, at which point I've gotten no benefit
 at
 all over just putting everything in the original base class in the first
 place.
 That defeats the purpose of decorators if I can't come up with a new one a
 month from now and not have to modify any of the existing code.


i see it more on a need-to-expose basis.  for example, why not, when
presented w/ the current problem, just expose, Baz::doThings() now, b/c you
know you need it in Baz instances ?  later if you find theres another method
thats in Bar that isnt yet exposed, you just go in and add a similar wrapper
for it in Baz at that time.  this is a typical flow in a layered
architecture in my experience; often times controllers are revised to expose
a new entry point for something on the backend that previously was
unavailble from the front end, just as an example.

i only pull interfaces into the equation when i what to bring a group of
things together, it certainly isnt necessary to define a second interface,
but i was just trying to highlight doThings() as your example essentailly
had 2 layers of decorators, G(F(Foo)), as i saw it.  from a design
perspective, yes, id probly not define G unless / until i saw a need to join
a group of classes explicitly.

-nathan


[PHP] Is it PHP Bug - memory leak ?

2008-12-27 Thread Pawel Rutkowski
Hello,

I try to run script below with PHP4 and it works.

--TEST--
Test session_encode() function : variation
--SKIPIF--
?php include('skipif.inc'); ?
--FILE--
?php

ob_start();
echo *** Testing session_encode() : variation ***\n;
var_dump(session_start());
$array = array(1,2,3);
$array[foo] = $array;
$array[blah] = $array;
$_SESSION[data] = $array;
var_dump(session_encode());
var_dump(session_destroy());
echo Done;
ob_end_flush();
?
--EXPECTF--
*** Testing session_encode() : variation ***
bool(true)
string(64) 
data|a:5:{i:0;i:1;i:1;i:2;i:2;i:3;s:3:foo;R:1;s:4:blah;R:1;}
bool(true)
Done


But in PHP5 x64 I have errors like:

/root/src/php-5.2.6/Zend/zend_hash.c(247) :  Freeing 0x0E76BC50 (75 bytes), 
script=ext/session/tests/session_encode_variation5.phpt
[Sat Dec 27 11:27:09 2008]  Script: 
'ext/session/tests/session_encode_variation5.phpt' 
/root/src/php-5.2.6/Zend/zend_vm_execute.h(3596) :  Freeing 0x0E76B990 (71 
bytes), script=ext/session/tests/session_encode_variation5.phpt
/root/src/php-5.2.6/Zend/zend_hash.c(388) : Actual location (location was 
relayed)

If I add:
$array[foo] = null;
$array[blah] = null;
in test code it works without errors. But is I always need to add 'null' ?

I'm asking because I have some site which genereating many errors like 
Actual location (location was relayed).

Thanks
Pawel R.



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



[PHP] PHP Help Needed

2008-12-27 Thread Ayemowa Toyin
Hi,

I am new to PHP and require your help regarding a PHP Script.  Below is what I 
am tryin to achieve

1.  I have created a FILE UPLOAD page that lets users Upload a FIle to the 
site.  This and other details regarding the file stored in a MySQL Database.

2.  I need to create a FILE DOWNLOAD page that will read details from the MYSQL 
database for users to dwnload already uploaded files.  

Your help will be most appricated.

Thanks

Toyin AYemowa
UK


  

Re: [PHP] PHP Help Needed

2008-12-27 Thread Ashley Sheridan
On Sat, 2008-12-27 at 07:47 -0800, Ayemowa Toyin wrote:
 Hi,
 
 I am new to PHP and require your help regarding a PHP Script.  Below is what 
 I am tryin to achieve
 
 1.  I have created a FILE UPLOAD page that lets users Upload a FIle to the 
 site.  This and other details regarding the file stored in a MySQL Database.
 
 2.  I need to create a FILE DOWNLOAD page that will read details from the 
 MYSQL database for users to dwnload already uploaded files.  
 
 Your help will be most appricated.
 
 Thanks
 
 Toyin AYemowa
 UK
 
 
   
RTFM

http://www.php.net



Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Online Members

2008-12-27 Thread Daniel Brown
On Fri, Dec 26, 2008 at 20:24, Stephen Alistoun
stephenalist...@gmail.com wrote:

 Hi all,

 What is the best way to pick up all the members online on a website?

Check the archives and STFW for examples, but the general gist is
of it is to use $_SESSION tracking with activity checking.  I'm just
typing this in quickly as I go, so it's untested (read: don't copy and
paste for production), but here's a simple example (you should be able
to fill in the blanks easily):

?php
function m($str) { // Just an alias to shorten typing here.
return mysql_real_escape_string($str);
}

session_start();

// You can add their username if they're logged in, or display
// the count of unauthenticated users active on the site as the
// collective # Guests Online group.
mysql_query(UPDATE `users_online` SET `ip` =
'.m($_SERVER['REMOTE_ADDR']).', `last_active` = '.m(time()).`
WHERE `sess_id` = '.m(session_id()).';

if (mysql_affected_rows() == 0) {
mysql_query(INSERT INTO users_online(sess_id,ip,last_active)
VALUES('.m(session_id()).','.m($_SERVER['REMOTE_ADDR']).','.m(time()).');
}

// Et cetera

// Now, to display users online:
$sql = SELECT username FROM users_online WHERE last_active -
.m(time()).  300;
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
echo $row['username'].br /\n;
}

// And guests:
$sql = SELECT COUNT(*) AS num_guests FROM users_online WHERE
username='' AND last_active - .m(time()).  300;
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
echo There are .$row['num_guests']. guests online.br /\n;

?

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] Is it PHP Bug - memory leak ?

2008-12-27 Thread Daniel Brown
Hi, Pawel;

On Sat, Dec 27, 2008 at 05:40, Pawel Rutkowski
rut...@freelance-worker.net wrote:
[snip!]

 But in PHP5 x64 I have errors like:

 /root/src/php-5.2.6/Zend/zend_hash.c(247) :  Freeing 0x0E76BC50 (75 bytes),
 script=ext/session/tests/session_encode_variation5.phpt
 [Sat Dec 27 11:27:09 2008]  Script:
 'ext/session/tests/session_encode_variation5.phpt'
 /root/src/php-5.2.6/Zend/zend_vm_execute.h(3596) :  Freeing 0x0E76B990 (71
 bytes), script=ext/session/tests/session_encode_variation5.phpt
 /root/src/php-5.2.6/Zend/zend_hash.c(388) : Actual location (location was
 relayed)

Please file a bug report on this with the reproduce cases at
http://bugs.php.net/.  There was a nearly identical case mentioned in
the Zend forums[1] as found by Google, but no resolution was reached
there.


KEY:
1: 
http://www.zend.com/forums/index.php?t=msggoto=19257S=e5a6d1ca82291c880a9d85093afe1ee7

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



[PHP] Page name for form submit: REQUEST_URI or SCRIPT_NAME

2008-12-27 Thread Dotan Cohen
Is there a compelling reason to use either REQUEST_URI or SCRIPT_NAME
in the action of a form that I want to submit to the same URL that it
came from (the script parses whether or not there is a Submit to know
if it should display the form or the results). I need a portable
solution, that is why I am not hardcoding it. Also, the users _may_
save the form to their hard drives, so simply leaving the action blank
will not do.

I know that REQUEST_URI includes the ?variable=value string and that
SCRIPT_NAME does not. This form does not depend upon get variables, so
this should never be an issue, but I ask here anyway to know if there
are other differences that I did not account for.

Thanks!

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
ا-ب-ت-ث-ج-ح-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه‍-و-ي
А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я
а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я
ä-ö-ü-ß-Ä-Ö-Ü


Re: [PHP] Page name for form submit: REQUEST_URI or SCRIPT_NAME

2008-12-27 Thread Daniel Brown
On Sat, Dec 27, 2008 at 12:31, Dotan Cohen dotanco...@gmail.com wrote:
 Is there a compelling reason to use either REQUEST_URI or SCRIPT_NAME
 in the action of a form that I want to submit to the same URL that it
 came from (the script parses whether or not there is a Submit to know
 if it should display the form or the results). I need a portable
 solution, that is why I am not hardcoding it. Also, the users _may_
 save the form to their hard drives, so simply leaving the action blank
 will not do.

 I know that REQUEST_URI includes the ?variable=value string and that
 SCRIPT_NAME does not. This form does not depend upon get variables, so
 this should never be an issue, but I ask here anyway to know if there
 are other differences that I did not account for.

Happy Chanukah, Dotan!

For portability's sake, especially if you anticipate users saving
the form to their local systems, I would recommend:

?php
$action = http://.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
?
form method=?php echo $action; ?

If you use REQUEST_URI and the form is on a page not called
directly (for example, on index.php and called only by directory; a
mod_rewrite /contact page; etc.), using REQUEST_URI gives the actual
request, where PHP_SELF gives the actual file.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] PHP Help Needed

2008-12-27 Thread Dotan Cohen
2008/12/27 Ashley Sheridan a...@ashleysheridan.co.uk:
 RTFM

 http://www.php.net


Or STFW
http://justfuckinggoogleit.com/search?q=php%20mysql%20file%20download%20script

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
ا-ب-ت-ث-ج-ح-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه‍-و-ي
А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я
а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я
ä-ö-ü-ß-Ä-Ö-Ü


Re: [PHP] Page name for form submit: REQUEST_URI or SCRIPT_NAME

2008-12-27 Thread Dotan Cohen
2008/12/27 Daniel Brown danbr...@php.net:
Happy Chanukah, Dotan!


And a Merry Christmas!

For portability's sake, especially if you anticipate users saving
 the form to their local systems, I would recommend:

 ?php
 $action = http://.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
 ?

Naturally I have HTTP_HOST in there, but I did not even think about PHP_SELF.

If you use REQUEST_URI and the form is on a page not called
 directly (for example, on index.php and called only by directory; a
 mod_rewrite /contact page; etc.), using REQUEST_URI gives the actual
 request, where PHP_SELF gives the actual file.


That is a good point, and it is rather likely that the form may wind
up on an index.php page where the filename is not part of the URI.
Thanks!

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
ا-ب-ت-ث-ج-ح-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه‍-و-ي
А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я
а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я
ä-ö-ü-ß-Ä-Ö-Ü


Re: [PHP] PHP Help Needed

2008-12-27 Thread Daniel Brown
On Sat, Dec 27, 2008 at 10:47, Ayemowa Toyin ayemowa_to...@yahoo.co.uk wrote:
 Hi,

 I am new to PHP and require your help regarding a PHP Script.  Below is what 
 I am tryin to achieve

You require an RTFM and STFW session.
* http://php.net/
* http://google.com/

 1.  I have created a FILE UPLOAD page that lets users Upload a FIle to the 
 site.  This and other details regarding the file stored in a MySQL Database.

 2.  I need to create a FILE DOWNLOAD page that will read details from the 
 MYSQL database for users to dwnload already uploaded files.

If you've already created the UPLOAD page, then the more difficult
of the two tasks is done.  Chances are, you (or whomever wrote the
code for you) should know how to do #2 if you (or another) already did
#1, but if not:

http://www.google.com/search?q=php+mysql+file+download+script
http://www.joeclipart.com/blog/images/2007/06/20070628crack.jpg
http://www.phpbuilder.com/tips/item.php?id=5

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] PHP script gives no output or error message

2008-12-27 Thread Daniel Brown
Good afternoon, John;

On Sat, Dec 27, 2008 at 03:28, John Musbach johnmusba...@gmail.com wrote:
[snip!]

There's a syntax error on line 19:

 if(external_fud_login(fud_fetch_user($user)['id']))!=NULL) //User ID is valid 
 and logged in

It should be:
if(external_fud_login(fud_fetch_user($user['id']))!=NULL)
//User ID is valid and logged in

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] PHP Help Needed

2008-12-27 Thread Dotan Cohen
2008/12/27 Daniel Brown danbr...@php.net:
If you've already created the UPLOAD page, then the more difficult
 of the two tasks is done.  Chances are, you (or whomever wrote the
 code for you) should know how to do #2 if you (or another) already did
 #1, but if not:

http://www.google.com/search?q=php+mysql+file+download+script
http://www.joeclipart.com/blog/images/2007/06/20070628crack.jpg
http://www.phpbuilder.com/tips/item.php?id=5


That was subtle :)

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
ا-ب-ت-ث-ج-ح-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه‍-و-ي
А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я
а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я
ä-ö-ü-ß-Ä-Ö-Ü


Re: [PHP] Online Members

2008-12-27 Thread Nathan Nobbe
If you're talking about tracking the number of visitors with presently open
sessions at your website...


 I was just browsing the tutorials form at PHP Developer Network and saw
 this : http://forums.devnetwork.net/viewtopic.php?f=28t=29342

 Looks like it does what (I think) you were trying to describe.


the above link winds up at a dead end,
http://webmonkey.wired.com/webmonkey/04/50/index4a.html

 there are many ways to do this, depending upon how you store the session,
you may be able to crawl a list of them.  w/ the stock session support there
are a number of files in /tmp, which would be a place to start.

however, id probly just drop a counter in the database when a session is
created and remove it when said session is destroyed.  then all youd ever
have to do is lookup that number.

this you could achieve via session_set_save_handler()

-nathan


Re: [PHP] Decorator with public methods

2008-12-27 Thread Larry Garfield
On Saturday 27 December 2008 2:49:22 am Nathan Nobbe wrote:

  Thanks, Nathan.  Unfortunately, what you describe is impossible.  It
  requires
  me to know all the possible decorators ahead of time and implement the
  interface for each in each decorator, at which point I've gotten no
  benefit at
  all over just putting everything in the original base class in the first
  place.
  That defeats the purpose of decorators if I can't come up with a new one
  a month from now and not have to modify any of the existing code.

 i see it more on a need-to-expose basis.  for example, why not, when
 presented w/ the current problem, just expose, Baz::doThings() now, b/c you
 know you need it in Baz instances ?  later if you find theres another
 method thats in Bar that isnt yet exposed, you just go in and add a similar
 wrapper for it in Baz at that time.  this is a typical flow in a layered
 architecture in my experience; often times controllers are revised to
 expose a new entry point for something on the backend that previously was
 unavailble from the front end, just as an example.

Because this is for a shipping application, not an in-house app where a month 
from now I can go back and adjust the interface for every class.  (It's open 
source, but still has a stable release version.)  I need to be able to add 
additional wrapping decorators *without* any modifications to the underlying 
object or its interfaces.  

As I said, the interface problem is solvable by having explicit delegating 
methods in the base decorator class and then only using __call() for nested 
decorators, which will be a much much smaller portion of the time.  It's the 
performance cost of __call() and the extra call stack layers that are my 
concern at the moment.

-- 
Larry Garfield
la...@garfieldtech.com

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



Re: [PHP] PHP Help Needed

2008-12-27 Thread John Corry
lol, Ashley!

Ayemowa,
http://www.google.com/search?q=becoming+a+programmerie=utf-8oe=utf-8aq=trls=org.mozilla:en-US:officialclient=firefox-a

You need to take your 2 steps below and break them down into smaller
steps...and smaller steps...and still smaller steps.

What PHP files will your application require?
Will there be forms?
What will the user interface look like?

Don't start with a 'PHP script'.

Start by defining in excruciating detail what your application is
going to do, how it will do it and then describe every little part
(variables, functions, models, views, controllers...whatever) that
will make it work.

Once you have that description, you can start to think about the code
by writing it's documentation.

Then, once you have the documentation, you can write code based on the
documentation...revising the docs as necessary.

It's a lengthy, complicated process that is going to demand a little
more of you than just reducing your app to 2 steps and asking a
mailing list how to do it.

Good luck, let us know how it goes and how we can help you take (much
smaller) steps.

John Corry

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



Re: [PHP] Decorator with public methods

2008-12-27 Thread phphelp -- kbk

On Dec 26, 2008, at 7:53 PM, Larry Garfield wrote:

I have an object to which I want to add behavior (methods).  I  
cannot use
inheritance here because the object is already of a type or subtype  
(vis, I am
already using inheritance for something else), and because I want  
to be able

to add multiple types of behavior at runtime.


If I understand what you are wanting to accomplish, perhaps a simpler  
solution:


Whenever I create a function in a core-level class, I add pre- and  
post- execution language to it. For example:


class foo_bar {

  function foo () {
if (!on_foo()) {
 return FALSE;
}
// normal foo code
// normal foo code
// normal foo code
// normal foo code
// normal foo code
if (!more_foo()) {
 return FALSE;
}
  }

  function on_foo() {
return TRUE;
  }

  function more_foo() {
return TRUE;
  }
}

-- then in the child class:
class child_bar extends foo_bar {

 function on_foo() {
  // runtime code
  // runtime code
  // runtime code
  // runtime code
  return TRUE; // (or FALSE)
 }
}

Ken

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



[PHP] Webhotel structure

2008-12-27 Thread Nordstjernealle 10
Hi PHP experts

What is the overall structure on webhotels, how do I remove/clean everythink 
including everythinnk liek databases etc?

Sorry if this is not the proper news group for this question, please redirect 
me.
I am a newbie trying to make my osn webside with a minimum effort.

First I had a student to make some think for me, but he never finished it, so 
the useless remains are on my web.

My first plan was to use php gallery, but my web host surftown do not support 
safemode off.
So I found coppermine, surftown even support the install as one click.
First trial looked good, but then I ran into trouble, I get different error 
messages.

So I would prefer to remove everythink and start all over .



best regards

Peter Sørensen




Re: [PHP] PHP script gives no output or error message

2008-12-27 Thread John Musbach
On Sat, Dec 27, 2008 at 1:13 PM, Daniel Brown danbr...@php.net wrote:
Good afternoon, John;

There's a syntax error on line 19:

 if(external_fud_login(fud_fetch_user($user)['id']))!=NULL) //User ID is 
 valid and logged in

It should be:
if(external_fud_login(fud_fetch_user($user['id']))!=NULL)
 //User ID is valid and logged in

Thanks, turns out there were multiple problems with my code. My final
working code is:

?php
//Here we grab the authenticated user's name
//and either automatically log them in using an existing account
//or register them

require_once('/users/u15/jmusbach/.html_pages/FUDforum2/GLOBALS.php');
require_once('/users/u15/jmusbach/FUDforumDAT/scripts/fudapi.inc.php');
require_once('/users/u15/jmusbach/FUDforumDAT/scripts/forum_login.php');

global $_SERVER;
$user=$_SERVER['WEBAUTH_USER'];
$realname = $_SERVER['WEBAUTH_LDAP_GIVENNAME'] . ' '
.$_SERVER['WEBAUTH_LDAP_SN'];
$email = $user . '@blah.com';
$uid=_fud_simple_fetch_query(array('.$user.'), SELECT * FROM
.$GLOBALS['DBHOST_TBL_PREFIX'].users WHERE login IN({ARG}));
$login=external_fud_login($uid-id);
if(!empty($uid-id)  !empty($login)) //User ID is valid and logged in
{
//echo(Welcome,  . $user . , please wait while you are
logged in...);
header( 'Location: https://blah.com/~jmusbach/FUDforum2/?S='.$login);

}
else //User ID is invalid, register and log in
{
//echo(Welcome,  . $user . , please wait while you are registered
and logged in...);
$vals['login']=$user;
$vals['passwd']=password;
$vals['email']=$email;
$vals['name']=$realname;
$uid=fud_add_user($vals,$error);
$login=external_fud_login($uid);

if($uid!=0 and empty($error))
{
  header('Location: https://blah.com/~jmusbach/FUDforum2/?S='.$login);
}
else
{
  echo($error);
  die();
}

}



?

for anyone who may be trying to accomplish the same thing as me. In
addition I edited index.php in the themes folder and added a php
clause such that in the event the user is anonymous they are
redirected to the autologin.php script and I also edited the
register.php themes script to omit the UserCP password field and
password confirmation since everyone in this setup is assigned one
long random password (the thought being that the kerberos
username/password is enough to worry about, there should be no need to
worry about another username/password).

-- 
Best Regards,

John Musbach

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



Re: [PHP] Webhotel structure

2008-12-27 Thread Daniel Brown
On Sat, Dec 27, 2008 at 15:27, Nordstjernealle 10
nordstjerneall...@gmail.com wrote:
 Hi PHP experts

 What is the overall structure on webhotels, how do I remove/clean everythink 
 including everythinnk liek databases etc?

 Sorry if this is not the proper news group for this question, please redirect 
 me.
 I am a newbie trying to make my osn webside with a minimum effort.

 First I had a student to make some think for me, but he never finished it, so 
 the useless remains are on my web.

 My first plan was to use php gallery, but my web host surftown do not support 
 safemode off.
 So I found coppermine, surftown even support the install as one click.
 First trial looked good, but then I ran into trouble, I get different error 
 messages.

 So I would prefer to remove everythink and start all over .

What?

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] PHP script gives no output or error message

2008-12-27 Thread John Musbach
On Sat, Dec 27, 2008 at 3:32 PM, John Musbach johnmusba...@gmail.com wrote:

 Thanks, turns out there were multiple problems with my code. My final
 working code is:

 snip

 for anyone who may be trying to accomplish the same thing as me. In
 addition I edited index.php in the themes folder and added a php
 clause such that in the event the user is anonymous they are
 redirected to the autologin.php script and I also edited the
 register.php themes script to omit the UserCP password field and
 password confirmation since everyone in this setup is assigned one
 long random password (the thought being that the kerberos
 username/password is enough to worry about, there should be no need to
 worry about another username/password).

I almost forgot, I resolved the blank page issue by looking at the
.htaccess file FUDforum installed in its main public directory
...turns out the file contained a directive which suppressed all php
errors even when the value was specified differently in individual php
scripts, modifying that directive to show all php errors resolved that
issue.


--
Best Regards,

John Musbach

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



[PHP] Re: PHP (under httpd) reading a file outside DocumentRoot?

2008-12-27 Thread Jeff Weinberger

On Dec 26, 2008, at 1:52 PM, Nathan Rixham wrote:


Jeff Weinberger wrote:
I don't know if this is an Apache (httpd) or a PHP issue (I suspect  
PHP, but I may be doing something wrong with mod_suexec), so I hope  
this is the right place to ask. I certainly appreciate any help  
anyone can offer!
I am trying to get a PHP script to read a file that's outside the  
DocumentRoot of a VirtualHost, in fact well outside the parent  
directory of all of my virtual hosts.
I have successfully managed to get Apache httpd to run the script  
as the correct user and group (matching the target file's  
ownership) using SuexecUserGroup. I tested this by having the  
script create/write a test file, which had owner and group set  
correctly.
However, when I run the script, at the file(/path/to/target/file)  
command, PHP tells me it can't open the file - permission is denied.

In php.ini safe_mode is off and open_basedir is not set.
I am not sure where else to look for a solution - any help is very  
much appreciated!
FYI: PHP 5.2.6, Apache httpd 2.2.11, mod_ssl/2.2.11, OpenSSL/0.9.7l  
on Mac OS/X 10.5.5. I'm reaching the script over an SSL (https)  
connection if that matters).

Thanks!


do what it takes to make it work (ie chmod 777 or similar) then put  
things back to how they presently are one by one to find the cause  
of the error. :)


Nathan: Thanks for your suggestion - a good debugging step - but the  
permissions on the file I want the script to read have been -rw-rw-rw-  
the entire time.


This leads me to suspect that the issue is not the permissions  
themselves, but rather something about my PHP configuration or script  
(or, possibly, as I noted, my Apache httpd configuration) that is  
causing PHP to report a permission error on reading the file.


I don't know where else to look for this issue, so I hope that someone  
has at least some pointers or suggestions on what might be happening  
here.


Thank you very much for any help!

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



[PHP] how to update PHP 5.2.6 to 5.2.8 under Fedora Redhat Linux 9

2008-12-27 Thread Fred Silsbee
there are many php related files.

yumex or yum don't seem to be alternatives since there are many files that may 
or may not require updating...which one

yum remove php-5.2.6
yum install php-5.2.8

5.2.8 may not be in the repositories yet

so rpm seems to be an alternative with a remove - reinstall


  


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



Re: [PHP] Webhotel structure

2008-12-27 Thread Richard Heyes
What?

Seconded. Are you talking about hosting?

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated December 20th)

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



Re: [PHP] Webhotel structure

2008-12-27 Thread John Corry
+1

Is it me or has the php mailing list kind of dumbed itself down in the
last 5 years?




What?

 --
 /Daniel P. Brown
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/
 Unadvertised dedicated server deals, too low to print - email me to find out!

 --
 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] Webhotel structure

2008-12-27 Thread Dotan Cohen
2008/12/27 Daniel Brown danbr...@php.net:
What?


What's not clear? He asked about webhotels, he obviously intends on
having extramarital cybersex.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
ا-ب-ت-ث-ج-ح-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه‍-و-ي
А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я
а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я
ä-ö-ü-ß-Ä-Ö-Ü


[PHP] Is PHP truly faster on the JVM?

2008-12-27 Thread John Papas
Lately I've been hearing a lot of people evangelizing that PHP with
Resin is actually much faster than with mod_php, but I cannot find any
benchmark anywhere.

Is it true or just vendor BS?

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



Re: [PHP] Decorator with public methods

2008-12-27 Thread Nathan Nobbe
On Sat, Dec 27, 2008 at 12:56 PM, phphelp -- kbk phph...@comcast.netwrote:

 On Dec 26, 2008, at 7:53 PM, Larry Garfield wrote:

  I have an object to which I want to add behavior (methods).  I cannot use
 inheritance here because the object is already of a type or subtype (vis,
 I am
 already using inheritance for something else), and because I want to be
 able
 to add multiple types of behavior at runtime.


 If I understand what you are wanting to accomplish, perhaps a simpler
 solution:

 Whenever I create a function in a core-level class, I add pre- and post-
 execution language to it. For example:

 class foo_bar {

  function foo () {
if (!on_foo()) {
 return FALSE;
}
// normal foo code
// normal foo code
// normal foo code
// normal foo code
// normal foo code
if (!more_foo()) {
 return FALSE;
}
  }

  function on_foo() {
return TRUE;
  }

  function more_foo() {
return TRUE;
  }
 }

 -- then in the child class:
 class child_bar extends foo_bar {

  function on_foo() {
  // runtime code
  // runtime code
  // runtime code
  // runtime code
  return TRUE; // (or FALSE)
  }
 }


more commonly referred to as  the template method.

-nathan


Re: [PHP] Decorator with public methods

2008-12-27 Thread Nathan Nobbe
On Sat, Dec 27, 2008 at 12:35 PM, Larry Garfield la...@garfieldtech.comwrote:

 On Saturday 27 December 2008 2:49:22 am Nathan Nobbe wrote:

   Thanks, Nathan.  Unfortunately, what you describe is impossible.  It
   requires
   me to know all the possible decorators ahead of time and implement the
   interface for each in each decorator, at which point I've gotten no
   benefit at
   all over just putting everything in the original base class in the
 first
   place.
   That defeats the purpose of decorators if I can't come up with a new
 one
   a month from now and not have to modify any of the existing code.
 
  i see it more on a need-to-expose basis.  for example, why not, when
  presented w/ the current problem, just expose, Baz::doThings() now, b/c
 you
  know you need it in Baz instances ?  later if you find theres another
  method thats in Bar that isnt yet exposed, you just go in and add a
 similar
  wrapper for it in Baz at that time.  this is a typical flow in a layered
  architecture in my experience; often times controllers are revised to
  expose a new entry point for something on the backend that previously was
  unavailble from the front end, just as an example.

 Because this is for a shipping application, not an in-house app where a
 month
 from now I can go back and adjust the interface for every class.  (It's
 open
 source, but still has a stable release version.)  I need to be able to add
 additional wrapping decorators *without* any modifications to the
 underlying
 object or its interfaces.


then you can expose all methods from the underlying layer in the first place
(which is basically what happens w/ inheritence, as i mentioned earlier).
also, how bad will it be when a month from now you have to make some
adjustments to the code?  more than likely after the first cut, you may have
to change something in more than one layer, but it should be minimal as long
as you arent making any major overhauls to the code.  you add or change one
method in a lower, layer so you need to change it in another place, one
layer above, i dont see that being so bad.  what you are worried about is
the classic case martin fowler put forth, which is a short coming of a
layered architecture, namely, in the worst case scenario, a modification at
the lowest layer requires modifications to each successive layer.


 As I said, the interface problem is solvable by having explicit delegating
 methods in the base decorator class and then only using __call() for nested
 decorators, which will be a much much smaller portion of the time.  It's
 the
 performance cost of __call() and the extra call stack layers that are my
 concern at the moment.


there is one semi-micro optimization w/ __call(), and that is to use a
variable function rather than call_user_func*.  however, as you surely
already know, this only works iff you know the number of parameters that
need to be passed intot the function which is being wrapped.  something like
this,

function __call($method, $args) {
  return $this-foo-$method($args[0], $args[1]);
}

the performance hit from __call() is just the price for a highly dynamic
system; but you can have a faster system, at the slight risk of
carpel-tunnel :)

-nathan


[PHP] Re: Webhotel structure

2008-12-27 Thread Carlos Medina

Nordstjernealle 10 schrieb:

Hi PHP experts

What is the overall structure on webhotels, how do I remove/clean everythink 
including everythinnk liek databases etc?

Sorry if this is not the proper news group for this question, please redirect 
me.
I am a newbie trying to make my osn webside with a minimum effort.

First I had a student to make some think for me, but he never finished it, so 
the useless remains are on my web.

My first plan was to use php gallery, but my web host surftown do not support 
safemode off.
So I found coppermine, surftown even support the install as one click.
First trial looked good, but then I ran into trouble, I get different error 
messages.

So I would prefer to remove everythink and start all over .



best regards

Peter Sørensen




Hallo Peter,
i think i understand what you mean (again: i think) but i am not really 
sure to understand what you need.

You need some Support on PHP? and when yes, by what?
When you dont need support for PHP please tell us, what you are looking 
for? Do you need Suport for coppermine? then look here 
http://documentation.coppermine-gallery.net/en/languages.htm
You want remove all the Application on your server and you dont know 
how? What is your System, where ist Your Server System?
Do you need some Support from PHP programmer? Please contact me then :-) 
(reply only to me then)



Regards

Carlos Medina



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



[PHP] Architecture patterns in PHP

2008-12-27 Thread Michael C. Yates

Hey,

How do you structure your web applications? I am thinking in terms of 
separating presentation  and logic. How is that done in PHP? And how 
many architecture patterns are there?



Thanks


Micheal C. Yates


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



Re: [PHP] Is PHP truly faster on the JVM?

2008-12-27 Thread Nathan Nobbe

On Dec 27, 2008, at 3:31 PM, John Papas jspa...@gmail.com wrote:


Lately I've been hearing a lot of people evangelizing that PHP with
Resin is actually much faster than with mod_php, but I cannot find any
benchmark anywhere.


well of course it is, but faster than what.., regular php.  Be the  
jvm; what do you see..?  Native caching support, and that's where  
you'll find the main speed advantage.  but we in the C php camp just  
use opcode caching and pretty much account for that difference pretty  
easily.



Is it true or just vendor BS?


lots of projects have started using the jvm b/c it's a wicked fast  
cross platform solution.  there are plenty of ways to make php fast  
though, and when comparing the standard php impl to quercus, I think  
the other tradeoffs outweigh any performance discrepancies.


-nathan

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



Re: [PHP] Architecture patterns in PHP

2008-12-27 Thread Daniel Brown
On Sat, Dec 27, 2008 at 18:40, Michael C. Yates quw...@gmail.com wrote:
[snip!]

 Micheal C. Yates

You mis-spelled your name, Michael.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

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



Re: [PHP] Architecture patterns in PHP

2008-12-27 Thread Ashley Sheridan
On Sat, 2008-12-27 at 19:00 -0500, Daniel Brown wrote:
 On Sat, Dec 27, 2008 at 18:40, Michael C. Yates quw...@gmail.com wrote:
 [snip!]
 
  Micheal C. Yates
 
 You mis-spelled your name, Michael.
 
 -- 
 /Daniel P. Brown
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/
 Unadvertised dedicated server deals, too low to print - email me to find out!
 
Lol! Epic spelling fail?


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Architecture patterns in PHP

2008-12-27 Thread Michael C. Yates

dude, whatever


Daniel Brown wrote:

On Sat, Dec 27, 2008 at 18:40, Michael C. Yates quw...@gmail.com wrote:
[snip!]

Micheal C. Yates


You mis-spelled your name, Michael.



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



Re: [PHP] Architecture patterns in PHP

2008-12-27 Thread Nathan Nobbe




Hey,

How do you structure your web applications? I am thinking in terms  
of separating presentation  and logic. How is that done in PHP?


mvc is pretty popular, but php is so flexible you often don't need it  
for smaller applications.


For example, if you take a page-controller approach, a php app is dead  
simple.  You have a seperate entery point for evrything; login.php,  
register.php, etc could be considered controllers, then all your  
common logic comes in via some includes, hopefully files outside the  
webroot.  then you have some template directory w/ files that are a  
mixture of php and html(for example).  your 'controller' files include  
the library code, hit the db (if necc.) and then stuff data into the  
templates for output.


if you want to see an exmple if a more traditional mvc there are scads  
of open source frameworks out there which use a front controller  
approach. Code igniter is really straight forward, you can probly  
learn quickly from it.



And how many architecture patterns are there?


please do try to avoid pandoras box on the list ;)  It can result in  
100+ post threads, heh.  that being said patterns are pretty general  
things, that's why they're called patterns.  most of the time various  
languages will result in slightly different concrete realizations of a  
pattern, but you'll find most of them rather simple to realize in  
php.  One that really isn't well suited to phps build-up / tear-down  
paradigm is the state pattern.  much easier in java or cpp, imo.


-nathan

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



[PHP] errors still being displayed even if variables in php.ini set to off

2008-12-27 Thread Fred Silsbee
on page 1
Notice: Undefined index: in C:\Inetpub\wwwroot\handle_log_book_MySQL.php on 
line 71

Notice: Undefined index: in C:\Inetpub\wwwroot\handle_log_book_MySQL.php on 
line 72

in php.ini:

error_reporting  =  Off

display_errors = Off (in 2 places)

display_startup_errors = Off





  


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



Re: [PHP] Architecture patterns in PHP

2008-12-27 Thread Murray
I'm interested in this topic as well. I'm starting out on a reasonably large
web application, and I'm wondering at the best approach in PHP, particularly
since it's been some years since I worked with PHP on a daily basis (the
last 5 years have been purely C#).

There's some dev community bias against using frameworks, isn't there? On
one hand I'd love to take an approach that would make my end goal easier
(thanks for pointing out Code Igniter, I'll look into it further), but on
the other hand I'd rather avoid choices that 'tainted' (perhaps not the
right word, but the best I could think of) the overall acceptance of the
application once it's ready for release.

So, currently I'm wondering about things like, 'Do I make an app that is a
distinct page-per-function, or do I make an app that uses a monolithic
index.php (similar to Wordpress?) and dynamically presents
*everything*based on querystring values.'

M is for Murray


On Sun, Dec 28, 2008 at 10:05 AM, Nathan Nobbe quickshif...@gmail.comwrote:



  Hey,

 How do you structure your web applications? I am thinking in terms of
 separating presentation  and logic. How is that done in PHP?


 mvc is pretty popular, but php is so flexible you often don't need it for
 smaller applications.

 For example, if you take a page-controller approach, a php app is dead
 simple.  You have a seperate entery point for evrything; login.php,
 register.php, etc could be considered controllers, then all your common
 logic comes in via some includes, hopefully files outside the webroot.  then
 you have some template directory w/ files that are a mixture of php and
 html(for example).  your 'controller' files include the library code, hit
 the db (if necc.) and then stuff data into the templates for output.

 if you want to see an exmple if a more traditional mvc there are scads of
 open source frameworks out there which use a front controller approach. Code
 igniter is really straight forward, you can probly learn quickly from it.

  And how many architecture patterns are there?


 please do try to avoid pandoras box on the list ;)  It can result in 100+
 post threads, heh.  that being said patterns are pretty general things,
 that's why they're called patterns.  most of the time various languages will
 result in slightly different concrete realizations of a pattern, but you'll
 find most of them rather simple to realize in php.  One that really isn't
 well suited to phps build-up / tear-down paradigm is the state pattern.
  much easier in java or cpp, imo.

 -nathan


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




Re: [PHP] Webhotel structure

2008-12-27 Thread Robert Cummings
On Sat, 2008-12-27 at 15:54 -0500, John Corry wrote:
 +1
 
 Is it me or has the php mailing list kind of dumbed itself down in the
 last 5 years?

Hey, that's almost as long as I've been here...

*blink* ... *blink* *blink*

:O

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


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



Re: [PHP] Architecture patterns in PHP

2008-12-27 Thread Larry Garfield
On Saturday 27 December 2008 6:57:18 pm Murray wrote:
 I'm interested in this topic as well. I'm starting out on a reasonably
 large web application, and I'm wondering at the best approach in PHP,
 particularly since it's been some years since I worked with PHP on a daily
 basis (the last 5 years have been purely C#).

 There's some dev community bias against using frameworks, isn't there? On
 one hand I'd love to take an approach that would make my end goal easier
 (thanks for pointing out Code Igniter, I'll look into it further), but on
 the other hand I'd rather avoid choices that 'tainted' (perhaps not the
 right word, but the best I could think of) the overall acceptance of the
 application once it's ready for release.

 So, currently I'm wondering about things like, 'Do I make an app that is a
 distinct page-per-function, or do I make an app that uses a monolithic
 index.php (similar to Wordpress?) and dynamically presents
 *everything*based on querystring values.'

 M is for Murray

There are exactly 47 architectural patterns, not a single more or less.  And 
if you believe that, I have a bridge you may be interested in. :-)

Seriously though, you'll probably find an existing implementation of any 
architectural pattern in PHP, including the ones that have absolutely no 
business being implemented in PHP.  (I include MVC in that, actually[1].)

If you really want to know about OO patterns, pick up the Gang-of-Four book[2] 
and spend some time wrapping your head around it.  (Warning: It is written 
mostly for a C++ audience, but it's still understandable.)  Then ignore those 
patterns that require more setup effort on each execution than they take to 
run, as those are ill-suited to PHP's shared-nothing architecture.  An active 
Observer, for instance, really sucks in a web app but a passive observer can 
do great things.

Then, get over your OO biases. :-)  PHP can do functions just as well as OO, 
and because of the setup costs in proper OO doing things with functions can 
often be much faster and require less mental overhead than building out a full 
OO setup.  There are plenty of major projects (PHP and otherwise) that use 
virtually no OO and still manage to kick ass.  (Drupal comes to mind, and the 
Linux kernel itself is all C code, which doesn't have syntactic OO.)  Don't 
assume that architecture just means OO.

Page-per-action vs. a front controller (the index.php to rule them all, 
usually with mod_rewrite) depends on your app and how you want to extend it.  
I personally far prefer a front controller approach as it means I can abstract 
out the bootstrap code and not even have the include this at the top of every 
page stuff.  It does mean you want mod_rewrite if your app is going to be at 
all bookmarkable or googleable (you may or may not want it to be), but that's 
not a huge requirement.

Disclaimer: I was asking this same question about 3-4 years ago, and started 
looking for PHP systems to study to learn from.  I found Drupal, started using 
it directly, and haven't left yet. :-)  That's probably not a bad approach to 
take.  Find an existing system that feels right to you and run with that.  
You'll almost certainly get a better system out of it than trying to write 
everything yourself.  (I've done that before, too, and it was generally a 
disaster.)

[1] http://www.garfieldtech.com/blog/mvc-vs-pac
[2] http://en.wikipedia.org/wiki/Gang_of_Four_(software)

-- 
Larry Garfield
la...@garfieldtech.com

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



Re: [PHP] Architecture patterns in PHP

2008-12-27 Thread Phpster
I think there is a lot to be gained from using a framework. I have an  
extremely large web app in asp ( over 1500 pages ) and maintenance is  
a frigging nightmare as it's so imtertwined.


Using the code ignitor framework reduces that dramatically and I now  
have 5 rules based classes that control the majority of the app with  
the rest of the code being mainly basic crud and validation.


The code is much cleaner, way simpler to maintain and the mvc pattern  
makes changes and additions a breeze.


Sorry for top posting, ipod seems to prefer that for it's mail setup

My 2 cents, though it's worth looking at other frameworks like qcodo,  
cake, or send to pick the flavor that fits you best


Bastien

Sent from my iPod

On Dec 27, 2008, at 7:57 PM, Murray planetthought...@gmail.com wrote:

I'm interested in this topic as well. I'm starting out on a  
reasonably large
web application, and I'm wondering at the best approach in PHP,  
particularly
since it's been some years since I worked with PHP on a daily basis  
(the

last 5 years have been purely C#).

There's some dev community bias against using frameworks, isn't  
there? On
one hand I'd love to take an approach that would make my end goal  
easier
(thanks for pointing out Code Igniter, I'll look into it further),  
but on
the other hand I'd rather avoid choices that 'tainted' (perhaps not  
the
right word, but the best I could think of) the overall acceptance of  
the

application once it's ready for release.

So, currently I'm wondering about things like, 'Do I make an app  
that is a

distinct page-per-function, or do I make an app that uses a monolithic
index.php (similar to Wordpress?) and dynamically presents
*everything*based on querystring values.'

M is for Murray


On Sun, Dec 28, 2008 at 10:05 AM, Nathan Nobbe  
quickshif...@gmail.comwrote:





Hey,


How do you structure your web applications? I am thinking in terms  
of

separating presentation  and logic. How is that done in PHP?



mvc is pretty popular, but php is so flexible you often don't need  
it for

smaller applications.

For example, if you take a page-controller approach, a php app is  
dead

simple.  You have a seperate entery point for evrything; login.php,
register.php, etc could be considered controllers, then all your  
common
logic comes in via some includes, hopefully files outside the  
webroot.  then
you have some template directory w/ files that are a mixture of php  
and
html(for example).  your 'controller' files include the library  
code, hit

the db (if necc.) and then stuff data into the templates for output.

if you want to see an exmple if a more traditional mvc there are  
scads of
open source frameworks out there which use a front controller  
approach. Code
igniter is really straight forward, you can probly learn quickly  
from it.


And how many architecture patterns are there?




please do try to avoid pandoras box on the list ;)  It can result  
in 100+
post threads, heh.  that being said patterns are pretty general  
things,
that's why they're called patterns.  most of the time various  
languages will
result in slightly different concrete realizations of a pattern,  
but you'll
find most of them rather simple to realize in php.  One that really  
isn't
well suited to phps build-up / tear-down paradigm is the state  
pattern.

much easier in java or cpp, imo.

-nathan


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