|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general-digest-help
lists.php.net
Date: Wed Feb 20 2008 - 10:41:32 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 20 Feb 2008 16:41:32 -0000 Issue 5304
Topics (messages 269685 through 269729):
Re: What community software package gets your vote? PHPfox etc...
269685 by: Paul Scott
269693 by: TS
Re: More than one values returned?
269686 by: Greg Donald
269688 by: Nathan Nobbe
269689 by: Nick Stinemates
269690 by: Robert Cummings
269692 by: Nick Stinemates
269696 by: Robert Cummings
269697 by: Nick Stinemates
269698 by: Robert Cummings
269701 by: Jim Lucas
269719 by: Nathan Nobbe
269723 by: Nathan Nobbe
269725 by: tedd
Re: fopen never ends?
269687 by: Jim Lucas
269699 by: Paul van Brouwershaven
unsure how to do this any help appreciated
269691 by: Michael Seton
269694 by: Nick Stinemates
Re: xpath question
269695 by: Nick Stinemates
Re: unable to unset reference
269700 by: Zoltán Németh
269704 by: Sylvain R.
269710 by: Stut
269722 by: Sylvain R.
Re: Converting tab delimited file to CSV
269702 by: Graham Cossey
269706 by: Graham Cossey
269711 by: Andrew Ballard
Re: System errno in PHP
269703 by: Michal Maras
269705 by: Stut
269708 by: Michal Maras
base url and SEF
269707 by: Eric Boo
269720 by: tedd
269724 by: Daniel Brown
Re: Thread Safety
269709 by: Thiago Pojda
Help on running external command
269712 by: Mário Gamito
269713 by: Thiago Pojda
269714 by: Zoltán Németh
269715 by: Hiep Nguyen
Re: Help on running external command / Partially solved
269716 by: Mário Gamito
269717 by: Daniel Brown
269718 by: Mário Gamito
269721 by: Daniel Brown
269726 by: Mário Gamito
269727 by: Daniel Brown
Re: Session destruction problem
269728 by: tedd
Re: www. not working
269729 by: Daniel Brown
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
On Tue, 2008-02-19 at 23:21 -0500, TS wrote:
> On Feb 19, 2008 8:41 PM, TS <sunnrunner
gmail.com> wrote:
> > Hello everyone. I'm not sure what the budget is but, obviously inexpensive
> > would be nice. Someone turned me on to PHPfox. Yet I don't have any others
> > to compare it to. If you all would be so kind as to put a shout out and
> vote
> > on your favorite, I'd be very grateful.
How about Chisimba? http://avoir.uwc.ac.za It is free (GPL) and has all
the features of PHPFox and more.
--Paul
All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
attached mail follows:
Yeah, I noticed the trash talk as well with searching. I'm not a hardcore
PHP programmer and it would take me more time to do it than we have.
Deadline is in next couple of months. I think finding a package to start
with is key. Basically, all the features phpfox has is what we're looking
for. We're creating this to get for those of you who know, the Burning Man
community more organized. I could see maybe a couple 100K users if done
properly. We want to create a place for people to create camps or groups
upload photos have a task list etc...
-----Original Message-----
From: Wolf [mailto:lonewolf
nc.rr.com]
Sent: Wednesday, February 20, 2008 12:25 AM
To: TS
Subject: RE: [PHP] What community software package gets your vote? PHPfox
etc...
One thing to do is google the package name and see what hits are returned...
My search for phpfox returned a page of hits that was filled with trash talk
of the software.
One thing to consider is WHY the software is wanted. Is there a specific
reason for the "community" software or can you build one that works for the
company.. Also, does your current web package maybe have it as a plugin
that just needs to be turned on?
HTH,
Wolf
-----Original Message-----
From: TS <sunnrunner
gmail.com>
Sent: Tuesday, February 19, 2008 9:41 PM
To: php-general
lists.php.net
Subject: [PHP] What community software package gets your vote? PHPfox etc..
attached mail follows:
On Feb 19, 2008 9:27 PM, Nick Stinemates <nick
stinemates.org> wrote:
> Support != good design habits.
So you presume to have better design habits than the many language
designers who implemented parallel assignment in their respective
language? Right.
http://en.wikipedia.org/wiki/Assignment_%28computer_science%29#Parallel_assignment
> Please read my other post which explains
> the reasoning.
Your "reasoning" is shit.
min, max = 0, 0
is beautiful.
--
Greg Donald
http://destiney.com/
attached mail follows:
On Feb 19, 2008 11:52 PM, Greg Donald <gdonald
gmail.com> wrote:
> On Feb 19, 2008 9:27 PM, Nick Stinemates <nick
stinemates.org> wrote:
> > Support != good design habits.
>
> So you presume to have better design habits than the many language
> designers who implemented parallel assignment in their respective
> language? Right.
>
>
> http://en.wikipedia.org/wiki/Assignment_%28computer_science%29#Parallel_assignment
>
> > Please read my other post which explains
> > the reasoning.
>
> Your "reasoning" is shit.
dAAmn dude :D i agree though, being able to return multiple values from
a function has nothing to do with good or bad design of a language. in fact
if a language doesnt have support for it, likely it would not be in
widespread
use as is php.
and also, nick, for the record, it has nothing to do with being strongly or
weakly typed. take a look at c++, java, and .net; all strongly typed and
all
have pass-by-reference; thats what its for ;) and i dont want to act like
the
first person who said it because, C.R. Vegelin, said it first in this
thread.
(sorry ive been way busy lately :))
but to op, yes, you can of course return an aggregate structure, but there
are many times where it is appropriate to use pass-by-reference instead,
because,
read:
thats what the mechanism is designed for :)
let me furnish you with the most common example i can think of.
suppose you have a method that is returning a boolean status, but you want
to get some data back out of it as well. then you have it return a boolean
value, and toss a pass-by-reference parameter in there,
eg.
/**
* do some crazy crap to some dudes account
*/
function doCrazyCrapToAccount($accountId, &$someCrazyNewCrapOnTheAccount) {
$wasSuccess = false;
/// potentially alter $wasSuccess ...
/// drop something meaningful in $someCrazyNewCrapOnTheAccount ...
return $wasSuccess;
}
// then
$accountId = 5;
$crazyNewCrapOnAccount = null;
if(doCrazyCrapToAccount($accountId, $crazyNewCrapOnAccount)) {
echo $crazyNewCrapOnAccount;
}
and i was doing that in c++ back in o, 99' so yeah; nothing to do w/
loose typing, totally relevant; and thats technically how you return
multiple
values from a function, because lets face it; an aggregate is well, one
thing,
that just so happens to contain things, but again; its just one thing ;)
-nathan
attached mail follows:
Nathan Nobbe wrote:
> On Feb 19, 2008 11:52 PM, Greg Donald <gdonald
gmail.com> wrote:
>
>
>> On Feb 19, 2008 9:27 PM, Nick Stinemates <nick
stinemates.org> wrote:
>>
>>> Support != good design habits.
>>>
>> So you presume to have better design habits than the many language
>> designers who implemented parallel assignment in their respective
>> language? Right.
>>
>>
>> http://en.wikipedia.org/wiki/Assignment_%28computer_science%29#Parallel_assignment
>>
>>
>>> Please read my other post which explains
>>> the reasoning.
>>>
>> Your "reasoning" is shit.
>>
>
>
> dAAmn dude :D i agree though, being able to return multiple values from
> a function has nothing to do with good or bad design of a language. in fact
> if a language doesnt have support for it, likely it would not be in
> widespread
> use as is php.
> and also, nick, for the record, it has nothing to do with being strongly or
> weakly typed. take a look at c++, java, and .net; all strongly typed and
> all
> have pass-by-reference; thats what its for ;) and i dont want to act like
> the
> first person who said it because, C.R. Vegelin, said it first in this
> thread.
> (sorry ive been way busy lately :))
> but to op, yes, you can of course return an aggregate structure, but there
> are many times where it is appropriate to use pass-by-reference instead,
> because,
> read:
> thats what the mechanism is designed for :)
>
> let me furnish you with the most common example i can think of.
> suppose you have a method that is returning a boolean status, but you want
> to get some data back out of it as well. then you have it return a boolean
> value, and toss a pass-by-reference parameter in there,
> eg.
>
> /**
> * do some crazy crap to some dudes account
> */
> function doCrazyCrapToAccount($accountId, &$someCrazyNewCrapOnTheAccount) {
> $wasSuccess = false;
> /// potentially alter $wasSuccess ...
> /// drop something meaningful in $someCrazyNewCrapOnTheAccount ...
> return $wasSuccess;
> }
>
> // then
> $accountId = 5;
> $crazyNewCrapOnAccount = null;
> if(doCrazyCrapToAccount($accountId, $crazyNewCrapOnAccount)) {
> echo $crazyNewCrapOnAccount;
> }
>
> and i was doing that in c++ back in o, 99' so yeah; nothing to do w/
> loose typing, totally relevant; and thats technically how you return
> multiple
> values from a function, because lets face it; an aggregate is well, one
> thing,
> that just so happens to contain things, but again; its just one thing ;)
>
> -nathan
>
>
Not once did I knock By Reference value passing or pointers.
I said, simply, returning an array of objects was usually an indication
of poor design.
--
==================
Nick Stinemates (nick
stinemates.org)
http://nick.stinemates.org
AIM: Nick Stinemates
MSN: nickstinemates
hotmail.com
Yahoo: nickstinemates
yahoo.com
==================
attached mail follows:
On Tue, 2008-02-19 at 21:24 -0800, Nick Stinemates wrote:
>
> I said, simply, returning an array of objects was usually an indication
> of poor design.
Please elaborate as to the "why" of it being an indication of poor
design.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
Robert Cummings wrote:
> On Tue, 2008-02-19 at 21:24 -0800, Nick Stinemates wrote:
>
>> I said, simply, returning an array of objects was usually an indication
>> of poor design.
>>
>
> Please elaborate as to the "why" of it being an indication of poor
> design.
>
> Cheers,
> Rob.
>
I already did...
I can condense it, since apparently I wasn't diligent enough in my
explanation the first time. I have a feeling that this will probably
evolve in to Procedural vs. OO design flame war, which was not the
intent nor desire.
Please also consider that I am talking about modular/extensible design
philosophies (Gang of Four) strongly used in languages like C++/Java.
Normally, if you're going to be returning a group of objects from a
method you're going to want to do something with them. In this case, why
should I expect the client of my library to have to do bulk operations?
The less trivial the example the more important it becomes, _especially_
if your method is used more than once! That's twice the amount of code.
If that doesn't make sense then my reasoning must be shit.
--
==================
Nick Stinemates (nick
stinemates.org)
http://nick.stinemates.org
AIM: Nick Stinemates
MSN: nickstinemates
hotmail.com
Yahoo: nickstinemates
yahoo.com
==================
attached mail follows:
On Tue, 2008-02-19 at 21:51 -0800, Nick Stinemates wrote:
> Robert Cummings wrote:
> > On Tue, 2008-02-19 at 21:24 -0800, Nick Stinemates wrote:
> >
> >> I said, simply, returning an array of objects was usually an indication
> >> of poor design.
> >>
> >
> > Please elaborate as to the "why" of it being an indication of poor
> > design.
> >
> > Cheers,
> > Rob.
> >
> I already did...
>
> I can condense it, since apparently I wasn't diligent enough in my
> explanation the first time. I have a feeling that this will probably
> evolve in to Procedural vs. OO design flame war, which was not the
> intent nor desire.
>
> Please also consider that I am talking about modular/extensible design
> philosophies (Gang of Four) strongly used in languages like C++/Java.
>
> Normally, if you're going to be returning a group of objects from a
> method you're going to want to do something with them. In this case, why
> should I expect the client of my library to have to do bulk operations?
> The less trivial the example the more important it becomes, _especially_
> if your method is used more than once! That's twice the amount of code.
>
> If that doesn't make sense then my reasoning must be shit.
It makes sense in the sense that you anticipate certain bulk operations
being performed. But as soon as you don't, they must resort to bulk
operations again. Also, your assuming I want your group object to apply
these bulk operations. Why can't I just request the result set, create
an operations object, and pass the operations object your group object?
Why must the action be on the group object. Going a step further, if
I've moved the action to an action object, why do I need a grouping
object? It can work as well on arrays or objects. As such I'll skip the
overhead of a group object since an array is perfectly sufficient and
Ill pass it to my operations class.
More than one way to skin a cat. My operations class knows how to deal
with lists, binary trees, vectors, arrays, CSVs, Xcel files. These are
just extended classes on top of the operations object. And unlike your
group object, my operations object can deal with any datatype, not just
objects.
No, I don't really have this class, but I could.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
Robert Cummings wrote:
> On Tue, 2008-02-19 at 21:51 -0800, Nick Stinemates wrote:
>
>> Robert Cummings wrote:
>>
>>> On Tue, 2008-02-19 at 21:24 -0800, Nick Stinemates wrote:
>>>
>>>
>>>> I said, simply, returning an array of objects was usually an indication
>>>> of poor design.
>>>>
>>>>
>>> Please elaborate as to the "why" of it being an indication of poor
>>> design.
>>>
>>> Cheers,
>>> Rob.
>>>
>>>
>> I already did...
>>
>> I can condense it, since apparently I wasn't diligent enough in my
>> explanation the first time. I have a feeling that this will probably
>> evolve in to Procedural vs. OO design flame war, which was not the
>> intent nor desire.
>>
>> Please also consider that I am talking about modular/extensible design
>> philosophies (Gang of Four) strongly used in languages like C++/Java.
>>
>> Normally, if you're going to be returning a group of objects from a
>> method you're going to want to do something with them. In this case, why
>> should I expect the client of my library to have to do bulk operations?
>> The less trivial the example the more important it becomes, _especially_
>> if your method is used more than once! That's twice the amount of code.
>>
>> If that doesn't make sense then my reasoning must be shit.
>>
>
> It makes sense in the sense that you anticipate certain bulk operations
> being performed. But as soon as you don't, they must resort to bulk
> operations again. Also, your assuming I want your group object to apply
> these bulk operations. Why can't I just request the result set, create
> an operations object, and pass the operations object your group object?
>
I'm not against implementing an iterator... this is much different than
returning an array of multiple objects, with a lot less overhead.
> Why must the action be on the group object. Going a step further, if
> I've moved the action to an action object, why do I need a grouping
> object? It can work as well on arrays or objects. As such I'll skip the
> overhead of a group object since an array is perfectly sufficient and
> Ill pass it to my operations class.
>
So you're going to rewrite implementation specific details every time
you use this bulk method? What about if one of the objects changes? Are
you going to limit yourself on maintenance because of poor design, or
are you going to refactor your code and search for every use and make
sure it's being used 'properly?' Sounds like a huge waste of time to me.
> More than one way to skin a cat. My operations class knows how to deal
> with lists, binary trees, vectors, arrays, CSVs, Xcel files. These are
> just extended classes on top of the operations object. And unlike your
> group object, my operations object can deal with any datatype, not just
> objects.
>
Hopefully you would be programming to an interface and not to an
implementation so that these types and functionality are interchangeable.
> No, I don't really have this class, but I could.
>
Keep it.
> Cheers,
> Rob.
>
--
==================
Nick Stinemates (nick
stinemates.org)
http://nick.stinemates.org
AIM: Nick Stinemates
MSN: nickstinemates
hotmail.com
Yahoo: nickstinemates
yahoo.com
==================
attached mail follows:
On Tue, 2008-02-19 at 22:26 -0800, Nick Stinemates wrote:
> Robert Cummings wrote:
> > On Tue, 2008-02-19 at 21:51 -0800, Nick Stinemates wrote:
> >
> >> Robert Cummings wrote:
> >>
> >>> On Tue, 2008-02-19 at 21:24 -0800, Nick Stinemates wrote:
> >>>
> >>>
> >>>> I said, simply, returning an array of objects was usually an indication
> >>>> of poor design.
> >>>>
> >>>>
> >>> Please elaborate as to the "why" of it being an indication of poor
> >>> design.
> >>>
> >>> Cheers,
> >>> Rob.
> >>>
> >>>
> >> I already did...
> >>
> >> I can condense it, since apparently I wasn't diligent enough in my
> >> explanation the first time. I have a feeling that this will probably
> >> evolve in to Procedural vs. OO design flame war, which was not the
> >> intent nor desire.
> >>
> >> Please also consider that I am talking about modular/extensible design
> >> philosophies (Gang of Four) strongly used in languages like C++/Java.
> >>
> >> Normally, if you're going to be returning a group of objects from a
> >> method you're going to want to do something with them. In this case, why
> >> should I expect the client of my library to have to do bulk operations?
> >> The less trivial the example the more important it becomes, _especially_
> >> if your method is used more than once! That's twice the amount of code.
> >>
> >> If that doesn't make sense then my reasoning must be shit.
> >>
> >
> > It makes sense in the sense that you anticipate certain bulk operations
> > being performed. But as soon as you don't, they must resort to bulk
> > operations again. Also, your assuming I want your group object to apply
> > these bulk operations. Why can't I just request the result set, create
> > an operations object, and pass the operations object your group object?
> >
>
> I'm not against implementing an iterator... this is much different than
> returning an array of multiple objects, with a lot less overhead.
Actually, using foreach on an array has less overhead than an iterator
on an object.
> > Why must the action be on the group object. Going a step further, if
> > I've moved the action to an action object, why do I need a grouping
> > object? It can work as well on arrays or objects. As such I'll skip the
> > overhead of a group object since an array is perfectly sufficient and
> > Ill pass it to my operations class.
> >
> So you're going to rewrite implementation specific details every time
> you use this bulk method? What about if one of the objects changes? Are
> you going to limit yourself on maintenance because of poor design, or
> are you going to refactor your code and search for every use and make
> sure it's being used 'properly?' Sounds like a huge waste of time to me.
Why would I rewrite implementation specific details? The implementation
details are on the objects. The action object's operation routines work
on the objects in the same way your group object's methods would. The
difference is that I give the action object the group, array, vector or
whatnot of items whereas you return it that way. My approach is more
versatile, I can create operational differences upon the same set of
results (whether it be an array, or a group object) by choosing to
instantiate the appropriate action object whereas you would need to
provide different return methods to get different types of group
objects... or alternatively clutter the group object method space with a
multitude of operational methods.
> > More than one way to skin a cat. My operations class knows how to deal
> > with lists, binary trees, vectors, arrays, CSVs, Xcel files. These are
> > just extended classes on top of the operations object. And unlike your
> > group object, my operations object can deal with any datatype, not just
> > objects.
> Hopefully you would be programming to an interface and not to an
> implementation so that these types and functionality are interchangeable.
Of course I would use whatever useful features of the language are
available provided they don't impede my sense of design and
efficiency... and that includes being able to return arrays as I see
fit. Nothing wrong with returning arrays, your choice of design appears
to have more drawbacks than mine.
;)
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
Nick Stinemates wrote:
> Nathan Rixham wrote:
>> Robert Cummings wrote:
>>> On Mon, 2008-02-18 at 21:09 -0600, Larry Garfield wrote:
>>>> On Monday 18 February 2008, Nick Stinemates wrote:
>>>>
>>>>>>> I have found, however, that if I ever need to return /multiple/
>>>>>>> values,
>>>>>>> it's usually because of bad design and/or the lack of proper
>>>>>>> encapsulation.
>>>>>> You mean you've never had a function like getCoordinates()? Or
>>>>>> getUsers(), or any other of a zillion perfectly valid and reasonable
>>>>>> functions that return multiple values as an array? Wow, how odd!
>>>>>>
>>>>>> Cheers,
>>>>>> Rob.
>>>>> getCoordinates() would return a Point object
>>>>> getUsers() would return a Group object...
>>>>>
>>>>> Not rocket science ;)
>>>> I wouldn't consider an array of user objects to be "multiple
>>>> things". I consider it a single aggregate thing, and return arrays
>>>> all the time. That's conceptually different from wanting two
>>>> separate return values from a function, which is indeed conceptually
>>>> icky.
>>> Yes, an aggregate is comprised of multiple things usually. Hence when
>>> decomposing the concept you are indeed returning multiple values-- both
>>> points of view are valid. If you receive a parcel of 100 pens. I can
>>> say, "has the parcel arrived yet" (one entity) or "have the pens arrived
>>> yet" (multiple entities).
>>>
>>> At any rate, the O.P. wanted to return multiple values called $x and $y.
>>> It seems quite reasonable to assume he was returning something akin to
>>> coordinates but didn't know how to do so by binding them in an
>>> aggregating structure such as an array, or if you wish, an object.
>>>
>>> Cheers,
>>> Rob.
>> seriously, whats wrong with returning an array? half the standard php
>> functions return array's, therefore at least half of php has been
>> designed badly..?
>>
>> ps: when working with co-ordinates / GIS data you should really be
>> using wkb data instead, it's much faster. [unpack]
>>
> What's wrong with it? Hmm..
>
> Half of PHP functions DO return arrays, I'll grant you that. The reason?
> It's untyped. If PHP were a typed language, and it still returned arrays
> for a lot, I definitely think it would be designed poorly.
>
> At any rate, returning an array from your Objects increases the burden
> and shifts it to the client of your API. For instance, if we take an
> example mentioned above *getUsers()* which returned an arbitrary number
> of User objects you could potentially use it like this.
>
> userupdater.php
>
> <?php
> $x = Users::getUsers($somefilter)
> foreach ($x as $user) {
> $user->update();
> }
> ?>
>
> Keep in mind. You'll have to rewrite that functionality in multiple
> areas. As opposed to:
>
> <?php
>
> $x = Users::getGroup($somegroup); // returns a group of users
> $x->update(); // can be reused wherever instead of having to loop
> through every user on the client side.
> ?>
>
> I hope you can see past my (basic) example to understand where I am
> headed with this.
>
I would, and do, use this magic :)
Users::GetGroup($somegroup)->update();
Simple, Even less typing then yours :p
attached mail follows:
On Wed, Feb 20, 2008 at 1:38 AM, Robert Cummings <robert
interjinn.com>
wrote:
> Actually, using foreach on an array has less overhead than an iterator
> on an object.
yes they are; see my experiment results here,
http://nathan.moxune.com/arrayVsArrayIteratorReport.php
and i hear what youre saying rob; at least i think so, namely, why
try to build in a set of operations into the group class for every single
possibility, even though they are centralized, you wouldnt want the
developer of the group class having to write a new method every
time one of the clients wanted something new; thats just madness.
and frankly impractical, because we all know how these release cycles
can be :)
anyway, there are plenty of options for the group class. 2 come to
mind immediately, the first allows you to apply a callback to every
element of the group; this is something like you would see in a functional
language, but it works pretty well w/ the php callback pseudo type as
well. and in fact, spl is incorporating this in 5.3, according to marcus.
the next option is to subclass the group object for your particular
operation.
then you could have a number of specialized child classes, that each,
are, the parent class and exhibit the specialized functionality. and the
best part is, the group class writer gets to chill in both scenarios :D
nick is right to an extent; reproducing the same client code in multiple
places is not good. however, rob is right too; you cant think of every
conceivable operation and build it into the group class. fortunately we
have callbacks and inheritance; and there are other elegant solutions
as well, just that none pop into my head in under a second :)
my thought is that *sometimes* returning an array is appropriate, and
*sometimes* returning an object is appropriate. it depends upon the
scenario; this is such a generic, common issue that you cant say one
is better than the other in all cases, because frankly neither is better
in all cases.
-nathan
attached mail follows:
On Mon, Feb 18, 2008 at 9:06 PM, Nick Stinemates <nick
stinemates.org>
wrote:
> Thats a good example, and a good reason for passing values by Reference
> instead of by Value.
>
> I have found, however, that if I ever need to return /multiple/ values,
> it's usually because of bad design and/or the lack of proper
> encapsulation.
and this is what i was responding to earlier, nick, although you didnt
criticize
pass-by-reference directly you essentially said use of it indicates bad
design,
which i disagree with.
check my post where i show a method with a boolean return value that has a
pass-by-reference parameter to return data; that is a perfectly reasonable
use
case for pass-by-reference and it does not indicate bad design. nor would
it, if
there were more pass-by-reference parameters in that method.
and here is another reason you might have to return more than on value from
a
method; a function needs to return data of different types. now php is
loosely
typed, so packaging these into an array is a joke, but in other languages,
that
are strongly typed, its not quite that simple. any way, when i think about
a method
returning a class, what if for whatever reason, a method were to return
objects of
2 classes ? do you then create another class just for the purpose of
packaging those
2 objects for this method to return a single value?
well ill let you be the judge of that, but i would probly toss them in a
small array, or,
depending on the scenario, use pass-by-reference, especially if i wanted to
return
a boolean value from the method ;)
-nathan
attached mail follows:
At 9:24 PM -0800 2/19/08, Nick Stinemates wrote:
>Not once did I knock By Reference value passing or pointers.
>
>I said, simply, returning an array of objects was usually an indication
>of poor design.
And the difference between a variable, an object, an array, and a pointer is?
Look, they all are segments of memory -- passing one or the other is
not an indication of good or poor design and it's just plain silly to
say so.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
Paul van Brouwershaven wrote:
> Nathan Rixham wrote:
>> I don't think this is a php problem, just load the url up in a browser
>> and you'll see the same, appears to be a misconfigured server at the
>> otherside - probably confused about not being passed a name based
>> "host" header in the request.
> I know that my browser is also waiting a long time, but strange that
> there is no timeout in fopen? My scripts are getting stuck and
> eventually they will hang my server. (when I start a new job every x
> minutes)
>
>> Perhaps concider moving to fsockopen or stream_socket_client with
>> timeout parameters to solve your issue.
>
> fsockopen has no context and with stream_socket_client I have no timeout
> but stream_context_get_options is not returning the right data
>
> $options = stream_context_get_options($fp);
>
Check out the first "Note:" section on this page.
http://us3.php.net/manual/en/function.stream-socket-client.php
First thing it tells you is that you can set a timeout for the
connection using stream_set_timeout().
I know this can be done. I am running a PHP daemon that that acts as
both a server and a client.
Jim Lucas
attached mail follows:
The timeout is not the problem, the probleem is I'm not getting the ssl (like the peer cert) info
into the stream_context_get_options
Jim Lucas wrote:
> Paul van Brouwershaven wrote:
>> Nathan Rixham wrote:
>>> I don't think this is a php problem, just load the url up in a
>>> browser and you'll see the same, appears to be a misconfigured server
>>> at the otherside - probably confused about not being passed a name
>>> based "host" header in the request.
>> I know that my browser is also waiting a long time, but strange that
>> there is no timeout in fopen? My scripts are getting stuck and
>> eventually they will hang my server. (when I start a new job every x
>> minutes)
>>
>>> Perhaps concider moving to fsockopen or stream_socket_client with
>>> timeout parameters to solve your issue.
>>
>> fsockopen has no context and with stream_socket_client I have no
>> timeout but stream_context_get_options is not returning the right data
>>
>> $options = stream_context_get_options($fp);
>>
>
>
> Check out the first "Note:" section on this page.
>
> http://us3.php.net/manual/en/function.stream-socket-client.php
>
> First thing it tells you is that you can set a timeout for the
> connection using stream_set_timeout().
>
> I know this can be done. I am running a PHP daemon that that acts as
> both a server and a client.
>
> Jim Lucas
>
attached mail follows:
To Whom this may Concern,
Basically what im try to do is this.... (please bear with me im a php noob)
require a remote file, if its blank then instead display a comment or
another file (which ever is easier)
Example:
*_if "http://launcher.worldofwarcraft.com/alert" contains
nothing or contains "Not Found" or "404 error", display " Sorry
no updates at this time or No server notices at this time" or
include blah.php, otherwise display
_**_"http://launcher.worldofwarcraft.com/alert"._*
Because the source is remotely updated, the information contained at
this address is beyond my control, so i need this to control what is
said on my end
I'm not sure how to get this one to work
Any help would be appreciated or a direction to where to find something
that will help me,
Pixmyster
Guild Master
Synergy Of Triumphalism
Horde - Spinebreaker - US Realm
World Of Warcraft Guild
Website: www.synergyoftriumphalism.com
Email: pixmyster
gmail.com
attached mail follows:
Michael Seton wrote:
> To Whom this may Concern,
>
> Basically what im try to do is this.... (please bear with me im a php
> noob)
> require a remote file, if its blank then instead display a comment or
> another file (which ever is easier)
>
> Example:
> *_if "http://launcher.worldofwarcraft.com/alert" contains
> nothing or contains "Not Found" or "404 error", display " Sorry
> no updates at this time or No server notices at this time" or
> include blah.php, otherwise display
> _**_"http://launcher.worldofwarcraft.com/alert"._*
>
>
> Because the source is remotely updated, the information contained at
> this address is beyond my control, so i need this to control what is
> said on my end
> I'm not sure how to get this one to work
>
> Any help would be appreciated or a direction to where to find
> something that will help me,
>
> Pixmyster
>
> Guild Master
> Synergy Of Triumphalism
> Horde - Spinebreaker - US Realm
> World Of Warcraft Guild
> Website: www.synergyoftriumphalism.com
> Email: pixmyster
gmail.com
>
<?php
$fp = fsockopen("launcher.worldofwarcraft.com", 80, $errno, $errstr,
30); //open the socket
if (!$fp) // if the socket doesnt open, die
die("$errstr ($errno)<br />\n");
//construct http specific headers
$out = "GET /alert HTTP/1.1\r\n";
$out .= "Host: launcher.worldofwarcraft.com\r\n";
$out .= "Connection: Close\r\n\r\n";
$buff = ""; //generate a buffer to fille
fwrite($fp, $out); //send the headers
while (!feof($fp)) {
$buff .= fgets($fp, 128); //read the response
}
fclose($fp); //close the socket
if (strstr($buff, "404")) { //analyze.
echo "no alerts";
} else {
echo "alerts";
}
?>
--
==================
Nick Stinemates (nick
stinemates.org)
http://nick.stinemates.org
AIM: Nick Stinemates
MSN: nickstinemates
hotmail.com
Yahoo: nickstinemates
yahoo.com
==================
attached mail follows:
RJO wrote:
> Hey guys,
>
> I have a form accepting a KML file from users and from there I want to
> draw polylines based on a KML file's
> <Placemarker><LineString><coordinates> element.
>
>
> The problem I am having is that sometimes the KML file can have a
> <document><folder> or <folder><document> or none of the above, or any
> number of random scenarios in the KML file making it hard to parse.
>
>
> To deal with this randomness I'm using an xpath and I think I have it
> right but it just wont work... the code:
> $result = $xml->xpath('Placemark/LineString/coordinates');
>
>
> An the particular XML file I am trying to pull from looks like:
> <?xml version="1.0" encoding="UTF-8"?>
> <kml xmlns="http://earth.google.com/kml/2.1">
> <Document>
> <name>coehilltotweed.kml</name>
> <Style id="lineStyle">
> <LineStyle>
> <color>64eeee17</color>
> <width>6</width>
> </LineStyle>
> </Style>
> <Folder>
> <name>23-SEP-06</name>
> <Snippet maxLines="2">
> </Snippet>
> <description><![CDATA[<table>
> <tr><td><b>Distance</b> 139.0 mi </td></tr>
> <tr><td><b>Min Alt</b> 451.4 ft </td></tr>
> <tr><td><b>Max Alt</b> 1168.9 ft </td></tr>
> </table>]]></description>
> <Placemark>
> <name>Path</name>
> <styleUrl>#lineStyle</styleUrl>
> <LineString>
> <tessellate>1</tessellate>
> <coordinates>
> -77.827985,44.851878,311.109985
> -77.82702000000001,44.852114,313.993896
> -77.827213,44.85067600000001,313.513306
> -77.827792,44.850955,313.513306
> -77.830389,44.85333700000001,315.916504
> -77.833114,44.858379,317.358643
> -77.83193300000001,44.858508,313.993896 </coordinates>
> </LineString>
> </Placemark>
> </Folder>
> </Document>
> </kml>
>
> Any ideas why this won't work?
>
> Thanks!
>
>
If you're just trying to get the coordinates, you can use:
$result = $xml->xpath('//coordinates');
I have a feeling you'll want to do more parsing than that, thought.
In the case of your example, I believe it should be the following:
$result = $xml->xpath('Folder/Placemark/LineString/coordinates'); _or_
$result = $xml->xpath('Document/Folder/Placemark/LineString/coordinates');
I can never remember. One of those 2 will work.
--
==================
Nick Stinemates (nick
stinemates.org)
http://nick.stinemates.org
AIM: Nick Stinemates
MSN: nickstinemates
hotmail.com
Yahoo: nickstinemates
yahoo.com
==================
attached mail follows:
2008. 02. 19, kedd keltezéssel 13.39-kor Shawn McKenzie ezt Ãrta:
> Sylvain Rabot wrote:
> > Hello,
> >
> > First of all I would like to know if one day we will be able to unset
> > $this into a class in order to destroy the object. It could really be
> > useful to prevent big memory usage.
> >
> > As it can't be done I tried to unset an object by unsetting a reference
> > of this object but it has no effect on the object but only on the
> > reference.
> >
> > Should unset destroy the reference itself and the object ???
> >
> > if you don't think so can you think of something different to destroy
> > both of them like I don't know, destroy($obejctsreference)
> >
> > Regards.
> >
> > Reproduce code:
> > ---------------
> > <?
> >
> > $x = new stdClass();
> > $x->a = 'ayayaye';
> >
> > $b[0] =& $x;
> >
> > unset($b[0]);
> >
> > var_dump($x);
> >
> > ?>
> >
> > Expected result:
> > ----------------
> > NULL
> >
> > Actual result:
> > --------------
> > object(stdClass)#1 (1) {
> > ["a"]=>
> > string(7) "ayayaye"
> > }
>
> So if you unset a reference you are dereferencing it. If you want to
> unset both, then unset the object, in this case $x.
I think he should unset all references to the object, $x and $b[0] as
well.
greets
Zoltán Németh
>
> -Shawn
>
attached mail follows:
"Chris" <dmagick
gmail.com> a écrit dans le message de news:
47BB6C80.6020704
gmail.com...
> Sylvain Rabot wrote:
>> Hello,
>>
>> First of all I would like to know if one day we will be able to unset
>> $this into a class in order to destroy the object. It could really be
>> useful to prevent big memory usage.
>
> I doubt the php-dev's will ever allow something like that, seems rather
> dangerous to me.
Why ? It would be nice to stop thinking PHP developpers are idiots who don't
know how to code.
I don't mean unset($this) is the best wy to allow an object to destroy
itself. I just say we miss something to auto destroy objects.
We could also think about a magic method like __destroy().
>> As it can't be done I tried to unset an object by unsetting a reference
>> of this object but it has no effect on the object but only on the
>> reference.
>>
>> Should unset destroy the reference itself and the object ???
>
> No, it's not meant to (and I doubt it will change). Why do you want it to
> do that?
>
> What is the original problem you're trying to solve?
>
I put SQL resources into an objects and I would like to destroy objects when
calling method free() but obviously I can't.
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
attached mail follows:
Sylvain R. wrote:
> "Chris" <dmagick
gmail.com> a écrit dans le message de news:
> 47BB6C80.6020704
gmail.com...
>> Sylvain Rabot wrote:
>>> Hello,
>>>
>>> First of all I would like to know if one day we will be able to unset
>>> $this into a class in order to destroy the object. It could really be
>>> useful to prevent big memory usage.
>> I doubt the php-dev's will ever allow something like that, seems rather
>> dangerous to me.
>
> Why ? It would be nice to stop thinking PHP developpers are idiots who don't
> know how to code.
I don't see how that reply implies that opinion.
> I don't mean unset($this) is the best wy to allow an object to destroy
> itself. I just say we miss something to auto destroy objects.
> We could also think about a magic method like __destroy().
An object that destroys itself is a really bad idea from an
architectural point of view. I, as a consumer of your class, need to
have control over the lifetime of any instances I create. In my opinion
if you have a need for a class to destroy itself then you have a
fundamental design flaw.
>>> As it can't be done I tried to unset an object by unsetting a reference
>>> of this object but it has no effect on the object but only on the
>>> reference.
>>>
>>> Should unset destroy the reference itself and the object ???
>> No, it's not meant to (and I doubt it will change). Why do you want it to
>> do that?
>>
>> What is the original problem you're trying to solve?
>>
>
> I put SQL resources into an objects and I would like to destroy objects when
> calling method free() but obviously I can't.
I don't understand why you need to destroy the class instance to clear
up member variables. Or am I not understanding your diction?
-Stut
--
http://stut.net/
attached mail follows:
"Stut" <stuttle
gmail.com> a écrit dans le message de news:
47BC348E.1060604
gmail.com...
> Sylvain R. wrote:
>> "Chris" <dmagick
gmail.com> a écrit dans le message de news:
>> 47BB6C80.6020704
gmail.com...
>>> Sylvain Rabot wrote:
>>>> Hello,
>>>>
>>>> First of all I would like to know if one day we will be able to unset
>>>> $this into a class in order to destroy the object. It could really be
>>>> useful to prevent big memory usage.
>>> I doubt the php-dev's will ever allow something like that, seems rather
>>> dangerous to me.
>>
>> Why ? It would be nice to stop thinking PHP developpers are idiots who
>> don't know how to code.
>
> I don't see how that reply implies that opinion.
I didn't mean to be rude but how a language structure could be dangerous ?
You use it if you know how to otherwise you don't.
I don't understand why we should not implement something because it could be
bad used by some persons as far it useful for others.
>> I don't mean unset($this) is the best wy to allow an object to destroy
>> itself. I just say we miss something to auto destroy objects.
>> We could also think about a magic method like __destroy().
>
> An object that destroys itself is a really bad idea from an architectural
> point of view. I, as a consumer of your class, need to have control over
> the lifetime of any instances I create. In my opinion if you have a need
> for a class to destroy itself then you have a fundamental design flaw.
I want the object to be destroyed when a specific method of this object is
called because when it has been called, the object has no reason to exist
anymore.
It's like a SQL resource, when you have freed it, you don't need it anymore.
>>>> As it can't be done I tried to unset an object by unsetting a reference
>>>> of this object but it has no effect on the object but only on the
>>>> reference.
>>>>
>>>> Should unset destroy the reference itself and the object ???
>>> No, it's not meant to (and I doubt it will change). Why do you want it
>>> to do that?
>>>
>>> What is the original problem you're trying to solve?
>>>
>>
>> I put SQL resources into an objects and I would like to destroy objects
>> when calling method free() but obviously I can't.
>
> I don't understand why you need to destroy the class instance to clear up
> member variables. Or am I not understanding your diction?
I would like to implement it in order to delete automaticly from memory
useless objects.
It can be really useful for example to make schedulers in PHP in order to
avoid "max memory usage exceeded" errors.
> -Stut
>
> --
> http://stut.net/
attached mail follows:
On Feb 20, 2008 3:05 AM, Richard Lynch <ceo
l-i-e.com> wrote:
> On Mon, February 18, 2008 12:08 pm, Graham Cossey wrote:
> > proceed accordingly... My biggest gripe with tab delimited files is
> > that they are quite a bit bigger than comma delimited files so I may
> > have to split the large files I receive into smaller 'chunks' to allow
> > them to be uploaded.
>
> This is not making sense...
>
> A tab-delimited file wil have a TAB character "\t" instead of comma ","
>
> A tab WITHIN the data then needs escaping as "\t" or somesuch.
>
> But commas to not need escaping with quotes.
>
> And quotes don't need escaping with double-quotes.
>
> So tab-delimited should be a TINY bit smaller or the same size.
>
> Perhaps your users are just uploading more data.
>
> > One thing I have noticed is that the files I create in my PHP script
> > (The script breaks a large file into smaller files of 25,000
> > records/rows each.) when opened in Excel (by double-clicking the file
> > in Windows Explorer) came up with an unrecognised file format message
> > for all files except the first. If you ignore this message the tab
> > delimited files open OK but the comma separated ones do not. The
> > "except the first" made me think that there may be something "hidden"
> > at the beginning of the file to say what type of data follows.
>
> Some CSV files include a "header" line with the names of the fields in
> the first line.
>
> This is less common in tab-delimited, but not unheard of.
>
If it's any help the data I'm getting comes out of a third party
Cognos environment.
The data opened into Textpad looks like this :
Column One Column Two Column Three Column Four Column Five Column
Six Column Seven
ABCDE XX99 DCS HORSE 1 2006 02
ABFED XX99 DCS HORSE 1 2006 02
JHGNF XX99 DCS HORSE 1 2006 02
HNDGE XX99 DCS HORSE 1 2006 02
Tab delimited no?
This file is 385KB. If I open it into Excel just by double-clicking on
it it opens fine. I then do File > Save As, change Unicode Text
(*.txt) to CSV (Comma Delimited)(*.csv) and give it a name then Save.
This new file is now 193KB and looks like this in Textpad :
Column One,Column Two,Column Three,Column Four,Column Five,Column
Six,Column Seven
ABCDE,XX99,DCS,HORSE,1,2006,2
ABFED,XX99,DCS,HORSE,1,2006,2
JHGNF,XX99,DCS,HORSE,1,2006,2
HNDGE,XX99,DCS,HORSE,1,2006,2
Double-clicking on this newly created file opens fine into Excel.
Back to my 'original' problem/question, if I '$f = fopen("$file",
"r")' and 'while ($data = fgets($f))' on the above first format and do
a $data = str_replace("\t",",",$data); the resulting file looks like
the second example above when opened into Textpad but will not open
into separate columns when opened with Excel.
I thought these were supposed to be simple, basic flat text formats
that were universally accepted, guess I'm just naive ;-)
I'm on the verge of simply giving in, and continuing to Open & Save As
the 100+ files I have to process in the next week or so :-(
--
Graham
attached mail follows:
I have a suspision the files I receive are in unicode which is causing
the problems.
How can I categorically determine if a file uses unicode?
Am I correct in believing PHP4 doesn't work with unicode files?
--
Graham
attached mail follows:
On Feb 20, 2008 3:54 AM, Graham Cossey <graham.cossey
gmail.com> wrote:
>
> If it's any help the data I'm getting comes out of a third party
> Cognos environment.
>
> The data opened into Textpad looks like this :
>
> Column One Column Two Column Three Column Four Column Five Column
> Six Column Seven
> ABCDE XX99 DCS HORSE 1 2006 02
> ABFED XX99 DCS HORSE 1 2006 02
> JHGNF XX99 DCS HORSE 1 2006 02
> HNDGE XX99 DCS HORSE 1 2006 02
>
> Tab delimited no?
>
It looks liked fixed-width instead of tab-delimited to me.
Andrew
attached mail follows:
Hello Nick
I have read http://php.net/fopen from top to bottom, but I could not find
how to get system error number.
With set_error_handler I can get string for example
fopen(hmc_configuration.cfg)
[function.fopen<http://ds63450.mspr.detemobil.de/%7Emmaras/HMC/function.fopen>]:
failed to open stream: Permission denied
but I need integer number not string, because string error messages depends
on locale setting.
Of course, I can test some conditions before fopen, but it is not enough
for me.
By
On 19/02/2008, Nick Stinemates <nick
stinemates.org> wrote:
>
> Michal Maras wrote:
> > I am now using filesystem functions fopen, fread, fclose, ...
> >
> > On 19/02/2008, Stut <stuttle
gmail.com> wrote:
> >
> >> Michal Maras wrote:
> >>
> >>> Coud somebody tell me if it is possible to get integer value of
> >>>
> >> variable
> >>
> >>> which name in C is errno end in perl $!.
> >>> I am PHP beginner so I am sorry if question is 'stupid'.
> >>>
> >> What function are you calling where you expect to get a system error?
> >> Check the manual page for that function - it will tell you how to
> detect
> >> errors.
> >>
> >> -Stut
> >>
> >> --
> >> http://stut.net/
> >>
> >>
> >
> >
> http://php.net/fopen
>
> --
> ==================
> Nick Stinemates (nick
stinemates.org)
> http://nick.stinemates.org
>
> AIM: Nick Stinemates
> MSN: nickstinemates
hotmail.com
> Yahoo: nickstinemates
yahoo.com
> ==================
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
Michal Maras wrote:
> I have read http://php.net/fopen from top to bottom, but I could not find
> how to get system error number.
> With set_error_handler I can get string for example
>
> fopen(hmc_configuration.cfg)
> [function.fopen<http://ds63450.mspr.detemobil.de/%7Emmaras/HMC/function.fopen>]:
> failed to open stream: Permission denied
>
> but I need integer number not string, because string error messages depends
> on locale setting.
> Of course, I can test some conditions before fopen, but it is not enough
> for me.
What exactly are you trying to do? Why do you need the specific reason
why it failed? It's pretty-much always a case of file not found or
insufficient permissions, both of which you can check for before going
near fopen.
-Stut
--
http://stut.net/
attached mail follows:
Hi
Hmm.. I know I can check such sings as if file exists or has right
permission before fopen.
But it does not mean that file will still exists with right permission a
moment later when
fopen will be issued.
And I can't check everything. I can't image how to check whether file is
locked, or if it is on read only filesystems or
if limit of opened fil was reached ...
Similar problem can be with fseek, fread,...
By
On 20/02/2008, Stut <stuttle
gmail.com> wrote:
>
> Michal Maras wrote:
> > I have read http://php.net/fopen from top to bottom, but I could not
> find
> > how to get system error number.
> > With set_error_handler I can get string for example
> >
> > fopen(hmc_configuration.cfg)
> > [function.fopen<
> http://ds63450.mspr.detemobil.de/%7Emmaras/HMC/function.fopen>]:
> > failed to open stream: Permission denied
> >
> > but I need integer number not string, because string error messages
> depends
> > on locale setting.
> > Of course, I can test some conditions before fopen, but it is not
> enough
> > for me.
>
> What exactly are you trying to do? Why do you need the specific reason
> why it failed? It's pretty-much always a case of file not found or
> insufficient permissions, both of which you can check for before going
> near fopen.
>
> -Stut
>
> --
> http://stut.net/
>
attached mail follows:
Hi all,
I'm currently parsing the variable $_SERVER['PHP_SELF'] to get the
base url of a site.
Example:
http://www.example.com/~eric/program/index.php?option=abc
What I'm interested in getting is
"http://www.example.com/~eric/program/", which I am able to get
currently.
Questions"
1) Are there security implications in using $_SERVER['PHP_SELF'], and
if so, how do I mitigate it?
2) Is using this method safe for all sorts of browsers/servers that run php?
3) If I install an SEF software so that my url looks like
http://www.example.com/~eric/program/a/b/c ,what will
$_SERVER['PHP_SELF'] show?
Thanks.
Eric
attached mail follows:
At 8:14 PM +0800 2/20/08, Eric Boo wrote:
>Hi all,
>
>I'm currently parsing the variable $_SERVER['PHP_SELF'] to get the
>base url of a site.
>
>Example:
>http://www.example.com/~eric/program/index.php?option=abc
>
>What I'm interested in getting is
>"http://www.example.com/~eric/program/", which I am able to get
>currently.
>
>Questions"
>1) Are there security implications in using $_SERVER['PHP_SELF'], and
>if so, how do I mitigate it?
1a) Yes, it's insecure because it's an outside source. Never trust
the user for anything.
1b) Use hard coded absolute references OR check that what you receive
from $_SERVER['PHP_SELF'] is what you expect.
As to parsing it, look into basename() examples.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
On Feb 20, 2008 7:14 AM, Eric Boo <ericboo
gmail.com> wrote:
> Hi all,
>
> I'm currently parsing the variable $_SERVER['PHP_SELF'] to get the
> base url of a site.
[snip!]
> Questions"
> 1) Are there security implications in using $_SERVER['PHP_SELF'], and
> if so, how do I mitigate it?
> 2) Is using this method safe for all sorts of browsers/servers that run php?
> 3) If I install an SEF software so that my url looks like
> http://www.example.com/~eric/program/a/b/c ,what will
> $_SERVER['PHP_SELF'] show?
1.) No more than any other predefined superglobal.[1]
2.) Yes, though the browser has nothing to do with PHP.
3.) It will show what should be in PHP_SELF: the name of the
parent script.[2]
FOOTNOTES:
[1] $_SERVER is what's called a SUPERGLOBAL in PHP. The same
as $_POST, $_GET, $_REQUEST, $_COOKIE, $_FILES, $_ENV, and $_SESSION.
Moreover, $GLOBALS shows all globals within the scope of a script.
For more information, check out:
http://php.net/manual/en/language.variables.predefined.php
[2] PHP_SELF is a reserved and predefined variable. Check out
the scope of $_SERVER right here:
http://php.net/manual/en/reserved.variables.php#reserved.variables.server
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
Tom,
That did not do it either. I'm sure I'm missing something stupid, just can't
find out what.
PHPInfo:
System Linux debian 2.6.18-4-486 #1 Mon Mar 26 16:39:10 UTC 2007 i686
Build Date Feb 20 2008 05:43:08
Configure Command './configure'
'--with-oci8-instant-client=/oracle/instantclient/'
'--with-apxs2=/usr/bin/apxs2' '--disable-zts'
Server API Apache 2.0 Handler
Virtual Directory Support enabled
Configuration File (php.ini) Path /usr/local/lib/php.ini
PHP API 20020918
PHP Extension 20020429
Zend Extension 20050606
Debug Build no
Zend Memory Manager enabled
Thread Safety enabled
Registered PHP Streams php, http, ftp
Apache:
debian:/usr/src/php-4.4.8# apache2ctl -V
Server version: Apache/2.2.3
Server built: Jan 27 2008 18:13:21
Server's Module Magic Number: 20051115:3
Server loaded: APR 1.2.7, APR-Util 1.2.7
Compiled using: APR 1.2.7, APR-Util 1.2.7
Architecture: 32-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT=""
-D SUEXEC_BIN="/usr/lib/apache2/suexec"
-D DEFAULT_PIDLOG="/var/run/apache2.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types"
-D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"
-----Mensagem original-----
De: Tom Rogers [mailto:trogers
kwikin.com]
Enviada em: terça-feira, 19 de fevereiro de 2008 20:40
Para: Thiago Pojda
Cc: php-general
lists.php.net
Assunto: Re: [PHP] Thread Safety
Hi,
Wednesday, February 20, 2008, 3:00:28 AM, you wrote:
TP> Not quite sure if this is the right list, but here I am...
TP>
TP> I'm trying to use zend platform and it requires the Thread Safety
TP> option set to off.
TP>
TP> I just compiled php and I can't find what argument to build php that
TP> way, what am I missing?
TP>
TP> PHP 4.4.8
TP>
TP>
TP> Thanks!
--disable-zts should do it
--
regards,
Tom
attached mail follows:
Hi,
I need to run an eternal command from a PHP page.
My code is:
"
$username= 'lixo';
$username = 'lixo';
exec('su - vpopmail -c
"/var/qmail/bin/maildirmake/home/vpopmail/domains/wwlib.lan/" . $username');
"
But I get the error:
"/var/qmail/bin/maildirmake/home/vpopmail/domains/wwlib.lan/: Not a
directory"
Which means that the $username variable isn't being appended to the string.
Any help would be appreciated.
Warm Regards,
Mário Gamito
attached mail follows:
You're using single quotes (') and therefore variables within will not be
resolved.
try either:
exec("su - vpopmail -c
\"/var/qmail/bin/maildirmake/home/vpopmail/domains/wwlib.lan/\" .
$username");
exec('su - vpopmail -c
"/var/qmail/bin/maildirmake/home/vpopmail/domains/wwlib.lan/"' .
$username');
try echoing the result before exec'ing:
echo('su - vpopmail -c
"/var/qmail/bin/maildirmake/home/vpopmail/domains/wwlib.lan/" . $username');
cheers,
Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
thiago.pojda
softpartech.com.br
Excelência em Softwares Financeiros
-----Mensagem original-----
De: Mário Gamito [mailto:gamito
gmail.com]
Enviada em: quarta-feira, 20 de fevereiro de 2008 11:32
Para: PHP General list
Assunto: [PHP] Help on running external command
Hi,
I need to run an eternal command from a PHP page.
My code is:
"
$username= 'lixo';
$username = 'lixo';
exec('su - vpopmail -c
"/var/qmail/bin/maildirmake/home/vpopmail/domains/wwlib.lan/" . $username');
"
But I get the error:
"/var/qmail/bin/maildirmake/home/vpopmail/domains/wwlib.lan/: Not a
directory"
Which means that the $username variable isn't being appended to the string.
Any help would be appreciated.
Warm Regards,
Mário Gamito
--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
attached mail follows:
2008. 02. 20, szerda keltezéssel 14.31-kor Mário Gamito ezt Ãrta:
> Hi,
>
> I need to run an eternal command from a PHP page.
>
> My code is:
> "
> $username= 'lixo';
>
> $username = 'lixo';
>
> exec('su - vpopmail -c
> "/var/qmail/bin/maildirmake/home/vpopmail/domains/wwlib.lan/" . $username');
> "
>
> But I get the error:
> "/var/qmail/bin/maildirmake/home/vpopmail/domains/wwlib.lan/: Not a
> directory"
>
> Which means that the $username variable isn't being appended to the string.
you're putting . and a variable inside a string delimited by ' which
will never work.
to avoid confusion like this, why not build the string first, then
exec() it? that way you can always echo out the string to check what
might be the problem.
$cmd = 'su -
vpopmail /var/qmail/bin/maildirmake/home/vpopmail/domains/wwlib.lan/' .
$username;
exec($cmd);
greets
Zoltán Németh
>
> Any help would be appreciated.
>
> Warm Regards,
> Mário Gamito
>
attached mail follows:
On Wed, 20 Feb 2008, Mário Gamito wrote:
> Hi,
>
> I need to run an eternal command from a PHP page.
>
> My code is:
> "
> $username= 'lixo';
>
> $username = 'lixo';
>
> exec('su - vpopmail -c
> "/var/qmail/bin/maildirmake/home/vpopmail/domains/wwlib.lan/" . $username');
> "
try:
exec('su - vpopmail -c "/var/qmail/bin/maildirmake/home/vpopmail/domains/wwlib.lan/"'.$username);
>
> But I get the error:
> "/var/qmail/bin/maildirmake/home/vpopmail/domains/wwlib.lan/: Not a
> directory"
>
> Which means that the $username variable isn't being appended to the string.
>
> Any help would be appreciated.
>
> Warm Regards,
> Mário Gamito
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
Hi,
Thank you for your answers.
I got it working with:
"//$username = 'lixo';
exec("su -c - vpopmail \"/var/qmail/bin/maildirmake
/home/vpopmail/domains/wwlib.lan/\"$username");"
Now, if I run it from the shell, it creates the directory.
From a page on the web server it doesn't.
Directory /home/vpopmail/domains/wwlib.lan/ is owned by vpopmail.vchkpw
(as well as my .php page) with 700 permission.
I even tried chmoding 777 to my page, but still, it doesn't create the
directory.
Any ideas ?
Warm Regards,
Mário Gamito
attached mail follows:
On Feb 20, 2008 9:52 AM, Mário Gamito <gamito
gmail.com> wrote:
> Now, if I run it from the shell, it creates the directory.
> From a page on the web server it doesn't.
Chances are, the user as which the HTTP server (probably Apache)
is running does not have permission to write/create in that directory.
Check into using a suExec patch if possible.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
Of course the code is:
$username = 'lixo';
exec("su -c - vpopmail \"/var/qmail/bin/maildirmake
/home/vpopmail/domains/wwlib.lan/\"$username");
Mário Gamito wrote:
> Hi,
>
> Thank you for your answers.
>
> I got it working with:
> "//$username = 'lixo';
>
> exec("su -c - vpopmail \"/var/qmail/bin/maildirmake
> /home/vpopmail/domains/wwlib.lan/\"$username");"
>
> Now, if I run it from the shell, it creates the directory.
> From a page on the web server it doesn't.
>
> Directory /home/vpopmail/domains/wwlib.lan/ is owned by vpopmail.vchkpw
> (as well as my .php page) with 700 permission.
>
> I even tried chmoding 777 to my page, but still, it doesn't create the
> directory.
>
> Any ideas ?
>
> Warm Regards,
> Mário Gamito
>
attached mail follows:
On Feb 20, 2008 9:59 AM, Mário Gamito <gamito
gmail.com> wrote:
> Of course the code is:
>
> $username = 'lixo';
>
> exec("su -c - vpopmail \"/var/qmail/bin/maildirmake
> /home/vpopmail/domains/wwlib.lan/\"$username");
Oh, yes, of course it is!
That still doesn't mean that Apache has the right privileges.
Change the above to this:
<?
$username = "lixo";
exec('su -c - vpopmail "/var/qmail/bin/maildirmake
/home/vpopmail/domains/wwlib.lan/'.$username.'"',$ret,$err);
echo "<pre />\n";
print_r($ret);
echo "</pre>\n";
echo isset($err) ? "Error: ".$err : null;
?>
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
Hi,
> <?
> $username = "lixo";
> exec('su -c - vpopmail "/var/qmail/bin/maildirmake
> /home/vpopmail/domains/wwlib.lan/'.$username.'"',$ret,$err);
> echo "<pre />\n";
> print_r($ret);
> echo "</pre>\n";
> echo isset($err) ? "Error: ".$err : null;
> ?>
No output at all and I have "display_errors = On" in php.ini
Still no directory creation.
If I run the file as user vpopmail it asks me for a password:
# su - vpopmail
$ php /home/www/hash.php
Output:"
[vpopmail
cruzador ~]$ php /home/www/hash.php
Password:"
Any ideas ?
Warm Regards,
Mário Gamito
attached mail follows:
On Feb 20, 2008 10:30 AM, Mário Gamito <gamito
gmail.com> wrote:
Please keep the replies on-list, Mario. It helps others out, and
ensures that you'll get better advice from a larger group of talented
people.
> > <?
> > $username = "lixo";
> > exec('su -c - vpopmail "/var/qmail/bin/maildirmake
> > /home/vpopmail/domains/wwlib.lan/'.$username.'"',$ret,$err);
> > echo "<pre />\n";
> > print_r($ret);
> > echo "</pre>\n";
> > echo isset($err) ? "Error: ".$err : null;
> > ?>
>
> No output at all and I have "display_errors = On" in php.ini
>
> Still no directory creation.
>
> If I run the file as user vpopmail it asks me for a password:
>
> # su - vpopmail
> $ php /home/www/hash.php
>
> Output:"
> [vpopmail
cruzador ~]$ php /home/www/hash.php
> Password:"
It's because you can't automate su - without using an intermediary
such as 'expect'.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
At 2:45 PM -0800 2/19/08, Adil Drissi wrote:
>Hi,
>
>Below you'll find my code. I think now that the
>problem is in my algorithm, because the is created
>anytime the page is refreshed. But i don't know how to
>check if the client was logged out or it is a real new
>connexion to the page. As you will see one can click
>on logout, then press the back button of the browser,
>and then refresh the page, but he is still connected.
>I would like to help me fixe that. Here is the code:
You received an answer, but fail to understand.
Unless you use javascript to manipulate the browser's history you are
going to continue to have "problems" with the user browser's back
button.
But, explain why the user using the back button is a problem. If he
logs in, he's in. If he logs out, he's out. If he hits the back
button after logging out and cancels his log out -- so what? What
problems does that present?
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
On Feb 19, 2008 10:42 PM, Larry Garfield <larry
garfieldtech.com> wrote:
> On Tuesday 19 February 2008, Daniel Brown wrote:
> > On Feb 19, 2008 4:43 AM, Christoph <christoph.boget
gmail.com> wrote:
> > > > Don't do that.
> > > > Some sites may or may not use www. for whatever reason...
> > > > Usually screwed-up A-name records by incompetent sysadmins, but there
> > > > it is...
> > >
> > > Really? So
> > >
> > > games.yahoo.com
> > > blogreport.salon.com
> > > mirror1.downloads.com
> > >
> > > are examples of screwed up records by incompetent sysadmins?
> >
> > No, they're properly-configured FQDNs. They're just irrelevant
> > examples to the context in which Rich was relaying to the OP.
> >
> > Picture a server where the A records or CNAMEs don't exist for the
> > www. alias. Or, conversely, where the only way to access the domain
> > is by using the www. alias.
> >
> > Those, Christoph, are some of the things incompetent sysops do....
> > and on a surprisingly frequent basis.
>
> I see, so because I have garfieldtech.com and www.garfieldtech.com pointing to
> two entirely different servers in different states because I want them to do
> different things, I'm an incompetent sysop. Thanks, good to know.
Back off, Garfield, my answer couldn't cover everything! ;-P
Besides, without fully-quoting the rest of my message, you're
taking it all completely out of context.
> DNS was used for a lot of things long before the web came around, ya know.
You're full of it. Al Gore never would've invented DNS if he
didn't have plans to let people "get on the AOL" to go to eBay.
Jocularity aside, DNS was invented in 1983 (shortly after TCP/IP),
whereas the WorldWide Web was first "invented" in 1990. However, if
you remember ENQUIRE (on ARPANET), which was created by Tom
Berners-Lee (I had to look up his name, I couldn't remember it), the
same guy who went on to create the Web, you may remember it existed
before DNS. So essentially, even though it wasn't yet known as the
WorldWide Web, a form of it did exist before the Domain Name System.
Just taking a trip down memory lane. ;-)
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]