OSEC

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 23 Sep 2006 11:43:07 -0000 Issue 4363

php-general-digest-helplists.php.net
Date: Sat Sep 23 2006 - 06:43:07 CDT


php-general Digest 23 Sep 2006 11:43:07 -0000 Issue 4363

Topics (messages 242103 through 242143):

Re: php/css and .htaccess
        242103 by: Richard Lynch

Re: php/css and .htaccess [SOLVED]
        242104 by: Richard Lynch
        242105 by: Richard Lynch

Re: storing function names in db and running them as row is output?
        242106 by: Richard Lynch

Re: move_uploaded_file locks?
        242107 by: Richard Lynch

Re: stripping with an OB callback [SOLVED]
        242108 by: Christopher Watson

Re: File Upload Security and chmod
        242109 by: Richard Lynch
        242115 by: Andy Hultgren
        242126 by: Richard Lynch
        242133 by: Andy Hultgren
        242140 by: Børge Holen

Re: Override php.ini
        242110 by: Richard Lynch

PHP5 object construct
        242111 by: Chris Boget
        242112 by: Joe Wollard
        242114 by: Chris Boget
        242118 by: Joe Wollard
        242119 by: Martin Marques
        242120 by: Chris Boget
        242121 by: Chris Boget
        242125 by: Joe Wollard
        242127 by: Richard Lynch
        242128 by: Chris Boget
        242129 by: Chris Boget

Yahoo! HackDay
        242113 by: Rasmus Lerdorf
        242134 by: Micky Hulse

Re: PDF.
        242116 by: Richard Lynch

Re: SSL Connection causes data errors.
        242117 by: Richard Lynch

Re: symlink
        242122 by: Richard Lynch

Re: Reverse of date("w")
        242123 by: Richard Lynch

Re: Help converting C to PHP
        242124 by: Rory Browne
        242132 by: Richard Lynch
        242138 by: Richard Lynch
        242142 by: Rory Browne

how to get server response with ftp extension?
        242130 by: Robin Kunde

Re: Object Memory Leakage...
        242131 by: Jon Anderson

libcurl (cookies across cURL session). . .?
        242135 by: Michael Williams
        242136 by: Robert Cummings
        242137 by: Michael Williams
        242143 by: Tom Atkinson

Re: +AFs-OT+AF0- Working with version control
        242139 by: Colin Guthrie

Re: reading urlencoded data from POST
        242141 by: Marek 'MMx' Ludha

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


On Wed, September 20, 2006 5:18 pm, tedd wrote:
> Hi gang:
>
> I embedded php code inside css and changed my .htaccess to read --
>
> <FilesMatch "\.(htm|html|css)$">
> SetHandler application/x-httpd-php
> </FilesMatch>
>
> -- so that the css file would be processed and executed by php. The
> end result was that everything worked and did what I wanted.
>
> However, FireFox / Mozillia won't accept a css file if a .htaccess
> file reads as indicated above.
>
> Any ideas as to how to get FireFox to play nice?

Add a header("Content-type: text/css") to the top of it, so that the
web-server isn't LYING to Mozilla and telling it that you're sending
it an HTML file?

Only IE would be STOOPID and look at the URL and the file contents and
decide to ignore the headers.

text/css may not be right. Whatever.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Thu, September 21, 2006 10:37 am, David Giragosian wrote:
> So with this approach you're able to tailor css styles for specific
> browsers
> and their particular implementations of css, rather than employ hacks
> directly in the css??

That's one possible use.

Really, though, once your CSS is dynamic as well as your HTML, life
can be quite fun. :-)

Or, perhaps, if your so-called web Designer left NO CONSISTENT SPACE
on the layout for ERROR MESSAGES in a dynamic site, you might, just as
a hypothetical example, have something like:

<?php
  $error_position = array(10, 10, 500, 200);
  head('Page 1');
?>

Then, in the .css file, you'd be using $error_position to cram the
messages into an overflow: auto; at the $error_position, unique to
each page, where the so-called designer left you any white space at
all.

Not that this ever happened to me, oh no.

http://ralphsworld.com/

:-)

PS I embedded the CSS, actually, as I don't trust browser caching to
"know" that the CSS is also dynamic and changing.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Thu, September 21, 2006 12:17 pm, tedd wrote:

> To the gang -- is this something new, or am I getting excited over
> nothing?

I been doing it long time now...

You mean everybody doesn't run their CSS through PHP so they can make
it do what they want for each page?

How odd... :-)

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Wed, September 20, 2006 3:19 pm, blackwater dev wrote:
> First, the example I have is not the real situation, just an example
> so I
> don't want to get into why are you doing it like that, etc. Just want
> to
> see if it's possible.
>
> Basically, I want to store stuff in a text field in a db like this
> "johns
> name is ucfirst('john adams') ".
>
> When I cycle through that row for output in my php script, I want it
> to not
> see ucfirst as text but as the php function and run it....how is the
> possible?

http://php.net/eval

But if eval is the answer, you are probably doing something entirely
the wrong way.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Wed, September 20, 2006 1:36 pm, Matthew H. North wrote:
> Can't find this in the PHP docs, so: does anyone know whether
> move_uploaded_file locks the target file during the process?
>
> If move_uploaded_file does a rename within the same filesystem this
> isn't an
> issue (on unix, anyway, the O/S just reassigns inodes rather than
> copying
> data). But if it does a copy instead, or if it has to rename across
> filesystems, any process that tries to read or write the file before
> move_uploaded_file completes could be munging things.

http://lxr.php.net/ may have the answer even faster than asking
PHP-Internals... :-)

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Thanks for the follow-up Richard. I am now bracketing my Fusebox core
includes with ob_start("ob_gzhandler") and ob_end_flush(). It's done
wonders for those large query results. And since there is absolutely
nothing in this app that relies on multiple contiguous whitespace
characters, I'm good to go.

Christopher Watson

On 9/22/06, Richard Lynch <ceol-i-e.com> wrote:
> Cannot compression be set in .htaccess?
>
> Or even within the script???
>
> I suspect you could even find a PHP class out there to compress and
> send the right headers to do it all in PHP, regardless of server
> settings...

attached mail follows:


On Fri, September 22, 2006 3:58 pm, Andy Hultgren wrote:
> that as my root directory is simply www.myDomain.com and not
> ".public_html/" and I am on a shared server where my root cannot be

I got two words for you:

Change Hosts

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


So pretty much there's nothing to be done about it? If I can get the
chmod thing to make it so that you can't surf to your uploaded image
afterwards and view it, I'd be happy with that solution. I'd like to
stick with this host if I could.

On 9/22/06, Richard Lynch <ceol-i-e.com> wrote:
> On Fri, September 22, 2006 3:58 pm, Andy Hultgren wrote:
> > that as my root directory is simply www.myDomain.com and not
> > ".public_html/" and I am on a shared server where my root cannot be
>
> I got two words for you:
>
> Change Hosts
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
>
>

attached mail follows:


I may have hit "send" too soon...

Like, when you do FTP, do you see:

index.htm
page2.htm
page3.htm

right away?

*OR*, do you see:
public_html

And then you do "cd public_html" and THEN you see the files?

If you don't do "cd public_html" then I really don't think accepting
file uploads is a Good Idea, unless you have access to /tmp or
something to put the files in...

If you do "cd public_html" then you actually HAVE space outside your
webtree. Just do "mkdir uploads" and "chmod 777 uploads" *BEFORE* you
do "cd public_html" and you'll have an uploads dir outside the webtree
where you can put stuff.

NOTE:
Some fancy FTP tools like DreamWeaver and whatnot will convince you to
put "public_html" into some input box somewhere, to give you the
convenience of not needing to "cd public_html" -- which then means you
never *SEE* that you have space outside your webtree... Stop doing
that. An extra click or whatever to get into public_html is not that
big of a deal.

On Fri, September 22, 2006 7:21 pm, Andy Hultgren wrote:
> So pretty much there's nothing to be done about it? If I can get the
> chmod thing to make it so that you can't surf to your uploaded image
> afterwards and view it, I'd be happy with that solution. I'd like to
> stick with this host if I could.
>
> On 9/22/06, Richard Lynch <ceol-i-e.com> wrote:
>> On Fri, September 22, 2006 3:58 pm, Andy Hultgren wrote:
>> > that as my root directory is simply www.myDomain.com and not
>> > ".public_html/" and I am on a shared server where my root cannot
>> be
>>
>> I got two words for you:
>>
>> Change Hosts
>>
>> --
>> Like Music?
>> http://l-i-e.com/artists.htm
>>
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


For whatever reason when I ftp in using WinFtp I don't see public_html
(it's hidden, don't know why; if I make a directory called
".public_html" it gets created and then disappears), but I can see my
file structure from my host's website and so I know that when I ftp in
to myDomain.com this is what is "there":

index.htm
page1.htm
page2.htm
.public_html/
images/
etc. etc.

Currently nothing is stored in my .public_html directory since it is
not my root (and my website loads just fine when browsed to).

I don't ftp in from DreamWeaver and it isn't an issue of going
straight to public_html just to skip the cd step. public_html just
isn't set up as my root directory and I have no directories accessable
that are higher than my root.

So, since I have no access to directories outside of my root, do you
really think I should change that before allowing file uploads?
(either by changing servers or just bugging my server adminstrator
until he changes it). I currently check extension type and then image
type using get_image_size(); and also files with image extensions are
not executable on the server. However, from what I've read I
understand that those steps are the minimum in terms of file upload
security.

Also, I'd be curious still to hear why I can browse to a file in a
directory that has been set with chmod 0100. I really didn't expect
that.

Thanks again very much for your thoughts,

Andy

On 9/22/06, Richard Lynch <ceol-i-e.com> wrote:
>
>
> I may have hit "send" too soon...
>
> Like, when you do FTP, do you see:
>
> index.htm
> page2.htm
> page3.htm
>
> right away?
>
> *OR*, do you see:
> public_html
>
> And then you do "cd public_html" and THEN you see the files?
>
> If you don't do "cd public_html" then I really don't think accepting
> file uploads is a Good Idea, unless you have access to /tmp or
> something to put the files in...
>
> If you do "cd public_html" then you actually HAVE space outside your
> webtree. Just do "mkdir uploads" and "chmod 777 uploads" *BEFORE* you
> do "cd public_html" and you'll have an uploads dir outside the webtree
> where you can put stuff.
>
> NOTE:
> Some fancy FTP tools like DreamWeaver and whatnot will convince you to
> put "public_html" into some input box somewhere, to give you the
> convenience of not needing to "cd public_html" -- which then means you
> never *SEE* that you have space outside your webtree... Stop doing
> that. An extra click or whatever to get into public_html is not that
> big of a deal.
>
> On Fri, September 22, 2006 7:21 pm, Andy Hultgren wrote:
> > So pretty much there's nothing to be done about it? If I can get the
> > chmod thing to make it so that you can't surf to your uploaded image
> > afterwards and view it, I'd be happy with that solution. I'd like to
> > stick with this host if I could.
> >
> > On 9/22/06, Richard Lynch <ceol-i-e.com> wrote:
> >> On Fri, September 22, 2006 3:58 pm, Andy Hultgren wrote:
> >> > that as my root directory is simply www.myDomain.com and not
> >> > ".public_html/" and I am on a shared server where my root cannot
> >> be
> >>
> >> I got two words for you:
> >>
> >> Change Hosts
> >>
> >> --
> >> Like Music?
> >> http://l-i-e.com/artists.htm
> >>
> >>
> >>
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
>
>

attached mail follows:


On Saturday 23 September 2006 01:27, you wrote:
> Hi Borge,
>
> host/users/myDomain is the actual directory (and it's the root
> directory), and I do not have access to higher directories. So
> basically I do not have access to directories higher than my root
> directory, which is unfortunate. Also, the way the server is setup
> that I am on, I do not have access to the server's tmp file (it is not
> shared), I have my own tmp file in my root directory that I use. I
> don't know of any other system-wide read/write directory available
> either. I'd be putting a lot of data there too (customer uploaded
> images) so I really should save them somewhere in my directory and not
> in the common server space.
>
> You can start to see my bind... :( Any thoughts greatly appreciated!
>
> Andy

Sounds like cheap b-one hosting of sorts...
thoughts? yes dont use it... Yer site will probably quickly become a playing
ground for other than yerself. A file have to stay inside a quarantined area
for a sanity check before let loose on the system.
Probably the cache of the browser ... for the I can see the page stuff. dunno.

But as I said: Change yer hosting, to something useable and safe.

>
> On 9/22/06, Børge Holen <borgearivene.net> wrote:
> > On Friday 22 September 2006 22:58, Andy Hultgren wrote:
> > > Hi,
> > > I am relatively new to php and am trying to set up a file upload
> > > process for my website. I have read through the php security
> > > documentation and a number of the security-related questions on these
> > > lists and am attempting to implement as many of the measures as
> > > possible.
> > > One of the suggestions I have read is to have the uploaded files saved
> > > somewhere outside of your root directory. Unfortunately I cannot do
> > > that as my root directory is simply www.myDomain.com and not
> > > ".public_html/" and I am on a shared server where my root cannot be
> > > changed (I have already asked). So, I am trying to keep the
> > > permissions on my "saved_files" folder as tight as possible except
> > > when the actual upload occurs. I this as follows:
> > >
> > > 1) The actual file upload comes through Flash8, and when the user
> > > uploads a file it is sent to
> > > www.domain.com/flash8directory/upload.php, which is in the same
> > > directory as the Flash8 upload application.
> > > 2) upload.php first chmod 0740 the "saved_files" folder (which is
> > > located at www.domain.com/flash8directory/saved_files/). Then it does
> > > security checks to make sure an appropriate image has been uploaded,
> > > and if everything looks good it moves the uploaded file to
> > > "saved_files".
> > > 3) The Flash8 upload application is notified of the completion of the
> > > upload and downloads the new image it its viewer.
> > > 4) Once the download is complete and Flash8 no longer needs to work
> > > with the file, the Flash8 application notifies a separate php script
> > > by sending the variable "complete=1" to lockdown.php (located at
> > > www.domain.com/flash8directory/lockdown.php), which runs the following
> > > simple script:
> > >
> > > <?php
> > >
> > > $success = 0;
> > > $complete = $_POST['complete'];
> > >
> > > if ($complete==1) {
> > > if(chmod("./saved_files", 0100)) {
> > > success = yes;
> > > echo "success=yes";
> > > }
> > > }
> > > ?>
> > >
> > > This script works and "saved_files" is set to chmod 0100, but here is
> > > the problem. If I then navigate directly to the url of the uploaded
> > > file by entering its path in my
> > > browser(www.domain.com/flash8directory/saved_files/uploadedFile.jpg),
> > > the uploaded file appears in my browser! However, if I then refresh
> > > the browser I get the desired error message saying I do not have
> > > permission to access that file. Also, other browser windows never
> > > have access to view the uploaded file, only the browser from which the
> > > file was uploaded.
> > >
> > > Any thoughts on why I can view the uploaded file even though it has
> > > been set to chmod 0100? I'd really rather not have those files
> > > accessible to anyone, as an extra security layer.
> > >
> > > Thank you for your help!
> > >
> > > Andy
> >
> > I don't quite understand why you cannot save to another catalog.
> > is www.myDomain.com yer actual directory name of merely the domain?
> > If either, login to yer domain and simply go either one step up, is that
> > possible?
> > You can also make use of a .htaccess file inside a sub directory to keep
> > others from it till you have checked the file, then move it out in the
> > open or delete after specifications.
> >
> > Do you have access to /tmp ? That one is possible to use, in fact any
> > system wide directory writable by any/you is usable.
> >
> > --
> > ---
> > Børge
> > Kennel Arivene
> > http://www.arivene.net
> > ---
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php

--
---
Børge
Kennel Arivene
http://www.arivene.net
---

attached mail follows:


On Fri, September 22, 2006 11:42 am, Beauford wrote:
> Is there a way I can use <% %> instead of <? ?> for the opening and
> closing
> tags of a php script. I thought I read this somewhere but can't find
> anything on it now.
>
> Is there something that I could do with override php.ini command? I
> don't
> have access to the php.ini file on this server.

You can do this in .htaccess under Apache, or with ini_set (which
would have to be in <?php ?>

But you SHOULD NOT DO THIS

Nobody else on the planet is using <% for PHP, and it's unlikely to be
all that useful to you.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


I read about a feature of PHP5 OOP that is something like this in a book or
a magazine a while back. But now I don't remember exactly how this works
and I can't find any reference to it in the online docs. The basic idea is
something along these lines:

class MyClass {

  private $bob;
  public $Bob {
    set( $var ) {
      $this->bob = $var;

    }
    get() {
      return $this->bob;

    }
  }
}

Could someone point me to the relevant section of the docs that discusses
this?

thnx,
Chris

attached mail follows:


http://us2.php.net/class

On 9/22/06, Chris Boget <chris.bogetwild.net> wrote:
> I read about a feature of PHP5 OOP that is something like this in a book or
> a magazine a while back. But now I don't remember exactly how this works
> and I can't find any reference to it in the online docs. The basic idea is
> something along these lines:
>
> class MyClass {
>
> private $bob;
> public $Bob {
> set( $var ) {
> $this->bob = $var;
>
> }
> get() {
> return $this->bob;
>
> }
> }
> }
>
> Could someone point me to the relevant section of the docs that discusses
> this?
>
> thnx,
> Chris
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


>> I read about a feature of PHP5 OOP that is something like this in a book
>> or
>> a magazine a while back. But now I don't remember exactly how this works
>> and I can't find any reference to it in the online docs. The basic idea
>> is
>> something along these lines:
>>
>> class MyClass {
>>
>> private $bob;
>> public $Bob {
>> set( $var ) {
>> $this->bob = $var;
>>
>> }
>> get() {
>> return $this->bob;
>>
>> }
>> }
>> }
>>
>> Could someone point me to the relevant section of the docs that discusses
>> this?

> http://us2.php.net/class

Any particular place on that page I should be looking? I've read it several
times and didn't see anything like the above. The closest thing I saw were
actual methods called setBob() and getBob(), which isn't exactly what I'm
looking for...

thnx,
Chris

attached mail follows:


well, perhaps I'm not seeing what it is that you're looking for. The
page I sent you is a basic introduction to classes and OOP in PHP,
which based on the example that you've provided seemed like what you
wanted. It seems obvious that you want to learn more about OOP, but
are you trying to find a specific 'bob' example or would you just like
some help understanding OOP? What is the end result you're hoping to
get out of the list?.....Google also provided these results, which
might help you if a specific example is what you're looking for:
http://pear.php.net/reference/PhpDocumentor-1.2.0beta2/phpDocumentor/tutorial_phpDocumentor.howto.pkg.html
http://us3.php.net/get_object_vars
http://us3.php.net/spl

Feel free to help us help you ;-)

On 9/22/06, Chris Boget <chris.bogetwild.net> wrote:
> >> I read about a feature of PHP5 OOP that is something like this in a book
> >> or
> >> a magazine a while back. But now I don't remember exactly how this works
> >> and I can't find any reference to it in the online docs. The basic idea
> >> is
> >> something along these lines:
> >>
> >> class MyClass {
> >>
> >> private $bob;
> >> public $Bob {
> >> set( $var ) {
> >> $this->bob = $var;
> >>
> >> }
> >> get() {
> >> return $this->bob;
> >>
> >> }
> >> }
> >> }
> >>
> >> Could someone point me to the relevant section of the docs that discusses
> >> this?
>
> > http://us2.php.net/class
>
> Any particular place on that page I should be looking? I've read it several
> times and didn't see anything like the above. The closest thing I saw were
> actual methods called setBob() and getBob(), which isn't exactly what I'm
> looking for...
>
> thnx,
> Chris
>
>
>

attached mail follows:


On Fri, 22 Sep 2006 20:15:49 -0400, "Chris Boget" <chris.bogetwild.net> wrote:
>> http://us2.php.net/class
>
> Any particular place on that page I should be looking? I've read it
> several
> times and didn't see anything like the above. The closest thing I saw
> were
> actual methods called setBob() and getBob(), which isn't exactly what I'm
> looking for...

Check here:

http://us2.php.net/manual/en/language.oop5.magic.php

--
---------------------------------------------------------
Lic. Martín Marqués | SELECT 'mmarques' ||
Centro de Telemática | '' || 'unl.edu.ar';
Universidad Nacional | DBA, Programador,
    del Litoral | Administrador
---------------------------------------------------------

attached mail follows:


>> Any particular place on that page I should be looking? I've read it
>> several
>> times and didn't see anything like the above. The closest thing I saw
>> were
>> actual methods called setBob() and getBob(), which isn't exactly what I'm
>> looking for...
> Check here:
> http://us2.php.net/manual/en/language.oop5.magic.php

So the only way I can do anything like this is by implementing the __get()
and __set() methods? There is no attribute/property construct that is
similar to the sample code in my OP?

thnx,
Chris

attached mail follows:


> well, perhaps I'm not seeing what it is that you're looking for.

No, I'm not sure you are. Take a look at my sample code again. Pay
particular attention to how both $bob and $Bob are defined.

class MyClass {

  private $bob;

  public $Bob {
    set( $var ) {
      $this->bob = $var;

    }
    get() {
      return $this->bob;

    }
  }
}

thnx,
Chris

attached mail follows:


ok, so if we were talking Java, perhaps you are looking for
information that allows you to build 'accessor' and 'mutator' methods?
If so, then your example should work (syntax aside). Here's another
'test' example that I just whipped up and tested that shows you can
use any method name you wish.

<?php
class test {

  private $thing;

  function setThing($val) {
    $this->thing = $val;
  }

  function getThing() {
    return $this->thing;
  }

}

$t = new test;

// Show that thing is empty
print $t->getThing() . "\n";

// Set thing to 'Thing'
$t->setThing('Thing');

// show that thing contains 'Thing'
print $t->getThing() . "\n";
?>

If I'm still on the wrong path I apologize. I probably shouldn't be
trying to provide advice on cold medicine ;-)

On 9/22/06, Chris Boget <chris.bogetwild.net> wrote:
> > well, perhaps I'm not seeing what it is that you're looking for.
>
> No, I'm not sure you are. Take a look at my sample code again. Pay
> particular attention to how both $bob and $Bob are defined.
>
> class MyClass {
>
> private $bob;
>
> public $Bob {
> set( $var ) {
> $this->bob = $var;
>
> }
> get() {
> return $this->bob;
>
> }
> }
> }
>
> thnx,
> Chris
>
>
>

attached mail follows:


PHP has __set and __get in some versions...

I think that's what you are looking for.

If you told us which particular feature in that pile of code you're
asking about, it would help...

I still wouldn't know the answer, as I don't do OOP in PHP much, but
somebody might.

On Fri, September 22, 2006 7:32 pm, Chris Boget wrote:
>> well, perhaps I'm not seeing what it is that you're looking for.
>
> No, I'm not sure you are. Take a look at my sample code again. Pay
> particular attention to how both $bob and $Bob are defined.
>
> class MyClass {
>
> private $bob;
>
> public $Bob {
> set( $var ) {
> $this->bob = $var;
>
> }
> get() {
> return $this->bob;
>
> }
> }
> }
>
> thnx,
> Chris
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


> ok, so if we were talking Java, perhaps you are looking for
> information that allows you to build 'accessor' and 'mutator' methods?

Yes, exactly. I was flipping through a PHP5 book (possibly a magazine, but
it was definitely about PHP5 and not Java) and I saw this new language
construct. Since I've done a bit of dabbling in C#, have used it there and
found it useful, I thought it was really cool that PHP5 had implemented it.

thnx,
Chris

attached mail follows:


> PHP has __set and __get in some versions...
> I think that's what you are looking for.

Yes, but exactly. They'll do if there is no other way (as below)...
 
> If you told us which particular feature in that pile of code you're
> asking about, it would help...

the ability to set an accessor like such:

   public $Bob {
     set( $var ) {
       $this->bob = $var;

     }
     get() {
       return $this->bob;

     }
   }

thnx,
Chris

attached mail follows:


For any of you folks in the Bay Area, don't miss the open Hack Day at
Yahoo next Friday/Saturday. It is completely free and the density of
web experts will be higher than at most conferences.

More info on it at the following links:

http://yuiblog.com/blog/2006/09/22/yahoo-devday-schedule/
http://nate.koechley.com/blog/2006/09/22/hookytime-yahoo-developer-day-hack-day-on-sept-29th-and-30th/
http://del.icio.us/chadd/yhackday

-Rasmus

attached mail follows:


Rasmus Lerdorf wrote:
> More info on it at the following links:
> http://yuiblog.com/blog/2006/09/22/yahoo-devday-schedule/
> http://nate.koechley.com/blog/2006/09/22/hookytime-yahoo-developer-day-hack-day-on-sept-29th-and-30th/
> http://del.icio.us/chadd/yhackday

This too:
<http://www.techcrunch.com/2006/09/22/more-details-on-yahoo-hack-day/>

Shit, sounds fun. Wish I could go! :(

--
  Wishlist: <http://snipurl.com/vrs9>
    Switch: <http://browsehappy.com/>
      BCC?: <http://snipurl.com/w6f8>
        My: <http://del.icio.us/mhulse>

attached mail follows:


On Tue, September 19, 2006 8:21 am, João Cândido de Souza Neto wrote:
> I´m using the fpdf class to create pdf files report and it works fine.
>
> Now i need to get a standard pdf and put some data into for complete
> data.
> There´s some way to get an existent pdf file and put data into?

I think you need the PDI functions for that, at least in PDFlib, and
that costs money, I believe...

There may be other solutions.

Generating the whole PDF is one.

FDF, where you layer a FORM over a PDF is another solution for some
needs.
Here is an article I wrote about FDF way long time ago:
http://phpbootcamp.com/articles/fdf.htm

Hmmmmm... Actually, that looks more like the rough draft of the article.

Oh well.

It was in php|architect at some point...

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Mon, September 18, 2006 5:33 pm, Stefan wrote:
> I was wondering if anyone has experienced this before.
> I am connecting to an IIS server over HTTPS using
> pfsockopen and am getting xml data returned. Now when
> I open the URL in a browser the XML is returned fine
> without a problem. However when using PHP part of the
> XML is all messed up, data is moved around it appears
> and it messes up the XML.
>
> I am getting an error at the end of my request to the
> server:
>
> PHP Warning: fread(): SSL: fatal protocol error in
> ....
>
> However from what I read that error deals with the
> closing of the connection. Any help would be very
> appreciated.

I seem to recall some kinda note in php.net about IIS brokenness in
connection closing of HTTPS...

Maybe in "curl"?

And, actually, you may want to just try using PHP curl to get it,
instead of micro-managing the reading with pfsockopen...

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Mon, September 18, 2006 4:53 pm, Ross wrote:
> Can someone explain how and why you would use a symlink in php?

A symlink is the Un*x version of a Windows "shortcut" or the Mac's
"alias"

The difference being that a symlink actually *works* and a Windows
"shortcut" is useless for anything except their crappy desktop app...

As far as usefulness goes, it's pretty wide-open, and not at all tied
into PHP, per se, in a general sense...

I mean, any time you've got some long complicated
/path/to/somewhere/deep/in/your/system and you want to get there with
out typing all that you can do:
ln -s /path/to/somewhere/deep/in/your/system short
Now you can just use 'short' instead of all that other stuff.
[Assuming you start in the same dir where 'short' lives.]

There is *ONE* thing I've been doing that's very PHP specific that I
think is useful for a symlink...

cd public_html
ln -s . edit

Now, in the PHP code, I do like this:

<?php
  //Force administrators to authenticate
  if (strstr($PHP_SELF, '/edit/')) require 'authenticate';

  if (stristr($PHP_SELF, '/edit/') && isset($_POST['whatever'])){
    //do queries to update the content
  }

  //get the content:
  $query = "SELECT ... ";

  //Display content:
  if (strstr($PHP_SELF, '/edit/')) ?><form method="POST"><?php
  ...
  if (strstr($PHP_SELF, '/edit/')){
    ?>
       <input name="whatever" value="<?php echo $whatever?>" />
    <?php
  }
  else echo $whatever;
?>

What's the point, you ask?

Well, *NOW* instead of having an ugly non-intuitive layout for the CMS
for the site owner, they see the SAME layout, with everyting in the
SAME place, except they have INPUT boxes instead of just text.

This makes it MUCH more intuitive for them to edit their site, as they
just surf to /edit/ and then navigate to what they want to edit, the
same as it is on their site.

The whole thing looks exactly the same, except that they have bits
they can edit, that everybody else just sees as text.

I don't have duplicate code for layout for the site and the edit site,
so I've got very high code re-use, and don't have to make parallel
changes.

Combine this with some nice CSS and a clean layout, and it gets very
very nice.

It drastically cuts down (like, to zero) the confusion over how to
change what in the site -- and they never have to contact me to ask
how to change this or that, or what this little bit here over in
"admin" actually does. They *see* what it does, because they see it
just like it is in their public site.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Mon, September 18, 2006 5:09 pm, Kevin Murphy wrote:
> I'm looking for something that will convert a the opposite of the date
> ("w") function. In other words, if I have the number "3", I would
> like it to return "Wednesday". Is there such a beast out there
> besides writing a switch or array or something?

I always just put:
$daynames = array_flip(array('Sunday', 'Monday', 'Tuesday',
'Wednesday', 'Thursday', 'Friday', 'Saturday'));
in my globals include file or whatever and use that...
[shrug]

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


> That aside, I think that it would be very beneficial to the community as a
> whole if a contest was started that encouraged readability and good
> practices.
>
> The scoring and judging could be done by a panel, but I think that it
> would be more fun if the community itself was able to vote on various
> attributes; readability, efficiency, general approach, originality, etc.
> Allow people to comment on each entry. I don't know about the winner
> getting anything besides bragging rights, but it if gets large enough
> maybe there can be a few corporate sponsors giving away licenses or
> something. Who knows?

Fair enough.
Prime Number Script Competition ( for Bragging Rights ).

I challenge the readers of this list to produce the necessary code to find
the lowest prime number higher than a certain inputted number.

The script must be web based, and ask the user to enter a number. The script
must then calculate the lowest Prime Number above that number.

Scripts will be rated on Functional Accuracy ( the program must correctly
perform its required function ), Code Maintainability(eg Presence of
Comments, etc ), Ease of Use, and Code Efficiency, in that order. Brownie
points may be earned through use interesting or original ideas or
methodologies, provided they do not compromise the previous four criteria.

The submitted script will be rated by volunteers from this list. Submitting
an entry disqualifys you as a volunteer judge, whilst judging someone elses
code disqualifys you as a candidate. Deadline for submissions is 12:00
(Noon) (CEST UTC + 2 Hours) on Friday 29 September.

Interesting to see (a) if anyone enters, and (b) what the code will be like.

I think it would be a lot of fun if well executed.
>
>

attached mail follows:


On Fri, September 22, 2006 7:40 pm, Rory Browne wrote:
> The script must be web based, and ask the user to enter a number. The
> script
> must then calculate the lowest Prime Number above that number.

I would like to have one point clarified:

By "above that number" do you literally mean > or would >= be deemed
the correct interpretation?

E.g. for an input of '2' do you expect '2' or '3' as the answer?

Or is our ability to correctly interpret this as > part of the
exercise?...

Ooops.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Fri, September 22, 2006 7:40 pm, Rory Browne wrote:
> Fair enough.
> Prime Number Script Competition ( for Bragging Rights ).
>
> I challenge the readers of this list to produce the necessary code to
> find
> the lowest prime number higher than a certain inputted number.
>
> The script must be web based, and ask the user to enter a number. The
> script
> must then calculate the lowest Prime Number above that number.
>
> Scripts will be rated on Functional Accuracy ( the program must
> correctly
> perform its required function ), Code Maintainability(eg Presence of
> Comments, etc ), Ease of Use, and Code Efficiency, in that order.
> Brownie
> points may be earned through use interesting or original ideas or
> methodologies, provided they do not compromise the previous four
> criteria.
>
> The submitted script will be rated by volunteers from this list.
> Submitting
> an entry disqualifys you as a volunteer judge, whilst judging someone
> elses
> code disqualifys you as a candidate. Deadline for submissions is 12:00
> (Noon) (CEST UTC + 2 Hours) on Friday 29 September.
>
> Interesting to see (a) if anyone enters, and (b) what the code will be
> like.
>
> I think it would be a lot of fun if well executed.

I'm in.

What's the submission process?

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Whoops - sorry replied directly to Richard instead of to the list.

Submission process is simply to post to the list. It's probably a good idea
( and acceptable ) to just post an SHA1(MD5 for this purpose is compromised)
hash of your code before the deadline, and submit your actual code shortly
after the deadline.

The result must be greater than the input. For 2 as an input, I'd expect 3
as output.

Rory

attached mail follows:


is there a reason why php's built-in ftp extension does not have a
function that returns the last message the ftp server sent? for example,
it would be nice to know whether i can't create a directory because it
already exists or because i don't have permission. am i missing
something obvious here?

regards,

RK

attached mail follows:


Richard Lynch wrote:
> If you get no satisfaction on PHP-General, PHP-Internals may be able
> to help...
>
Might have to give that a shot...Subscribing to one more mailing list
can't hurt I guess. :-)

Thanks for the suggestion.
> You really need to specify PHP version and platform and all that,
> though, as what you are seeing may not be universal.
Linux 2.6.14.(something), PHP 5.1.6 (dotdeb), Apache 2.0.54, Debian
Sarge i386. All that running on dual Opterons with a couple gigs of ECC
with a couple hundred gigs of mirrored hardware SCSI raid. The kernel is
x86-64, but most of userland is 32-bit.

Cheers,

jon

attached mail follows:


Hi all,

Is there any way at all by which to persist cookies across cURL
sessions? Basically I have a login page that sets cookies and looks
for them for "logged in" status so that the user may use the site to
their heart's content. The problem with cURL, however, appears that
after the initial login, any further attempts are foiled by the fact
that the cookies don't remain. How exactly should I go about doing
this?

Thanks,
Mike

attached mail follows:


On Sat, 2006-09-23 at 02:10 -0400, Michael Williams wrote:
> Hi all,
>
> Is there any way at all by which to persist cookies across cURL
> sessions? Basically I have a login page that sets cookies and looks
> for them for "logged in" status so that the user may use the site to
> their heart's content. The problem with cURL, however, appears that
> after the initial login, any further attempts are foiled by the fact
> that the cookies don't remain. How exactly should I go about doing
> this?

You should be able to retrieve the cookies from the response headers.
Then you just need to resend them. There may be an option for cURL to do
this automatically. Search for cookie at the following link (check the
user comments also):

    http://ca.php.net/manual/en/ref.curl.php

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,

Thanks. The thing is that lots of cookies are set regularly. Are
you suggesting that every time I receive a "Set-Cookie:" to 1)parse
that line out 2)append it to a file 3) retrieve it when necessary?
I'm not terribly familiar with the proper format for a cookie, but
I'll look into it. I'd appreciate *any* insights you have.

Regards,
Mike

On Sep 23, 2006, at 2:28 AM, Robert Cummings wrote:

> On Sat, 2006-09-23 at 02:10 -0400, Michael Williams wrote:
>> Hi all,
>>
>> Is there any way at all by which to persist cookies across cURL
>> sessions? Basically I have a login page that sets cookies and looks
>> for them for "logged in" status so that the user may use the site to
>> their heart's content. The problem with cURL, however, appears that
>> after the initial login, any further attempts are foiled by the fact
>> that the cookies don't remain. How exactly should I go about doing
>> this?
>
> You should be able to retrieve the cookies from the response headers.
> Then you just need to resend them. There may be an option for cURL
> to do
> this automatically. Search for cookie at the following link (check the
> user comments also):
>
> http://ca.php.net/manual/en/ref.curl.php
>
> 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:


Use cURL's own cookie handling features.

curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookies.txt');

That will store the cookies in the file and read them from there next
time. /tmp may or may not be a suitable location.

Michael Williams wrote:
> Robert,
>
> Thanks. The thing is that lots of cookies are set regularly. Are you
> suggesting that every time I receive a "Set-Cookie:" to 1)parse that
> line out 2)append it to a file 3) retrieve it when necessary? I'm not
> terribly familiar with the proper format for a cookie, but I'll look
> into it. I'd appreciate *any* insights you have.
>
> Regards,
> Mike
>
> On Sep 23, 2006, at 2:28 AM, Robert Cummings wrote:
>
>> On Sat, 2006-09-23 at 02:10 -0400, Michael Williams wrote:
>>> Hi all,
>>>
>>> Is there any way at all by which to persist cookies across cURL
>>> sessions? Basically I have a login page that sets cookies and looks
>>> for them for "logged in" status so that the user may use the site to
>>> their heart's content. The problem with cURL, however, appears that
>>> after the initial login, any further attempts are foiled by the fact
>>> that the cookies don't remain. How exactly should I go about doing
>>> this?
>>
>> You should be able to retrieve the cookies from the response headers.
>> Then you just need to resend them. There may be an option for cURL to do
>> this automatically. Search for cookie at the following link (check the
>> user comments also):
>>
>> http://ca.php.net/manual/en/ref.curl.php
>>
>> 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:


Richard Lynch wrote:
> On Thu, September 21, 2006 7:08 pm, Colin Guthrie wrote:
>
> I've used CVS a fair amount, no branching, as everybody always said
> what a bear it was to merge.
>
> I keep hearing subversion is easier to branch/merge.

Absolutely! I never quite managed to "get" CVS's branching and merging.
It all worked etc. but it was very hard to visualise.

> Tomorrow, I've been tasked by the boss to find out HOW easy and how to
> do it for a big change that needs doing.
>
> But I'd also like to hack away on the "little changes" in, err, the
> trunk, I guess...
>
> So can I keep those both around?
> And would the branch live in a subdirectory or what?

In subversion this is very easy. The top level names "trunk", "branches"
and "tags" are just convensions used in subversion and it's generally a
good idea to use these are your root folders.

Just think about subversion as a big filesystem the base is / (or D:\ if
you're a windows person). In that base you have three folders trunk,
branches and tags. Inside the /trunk folder you can create a folder for
any given project.

If you want to branch, you just copy the /trunk/myproject/ folder to
e.g. /branches/myproject/bigchangeforboss/

You can then checkout the branch and work happily on implementing large
changes, commiting them as normal.

In a different location, you can also checkout /trunk/myproject/ and do
the little changes.

If you want those littel changes to also go into the branch, it's just a
simple matter of using the svn merge command to effectivly copy the
changes you made in trunk to your branch. This is just a matter of
saying "I want the changes made in trunk between revision x and revision
y to be applied to my local checkout of this branch". The changes are
merged into you checkout (it's best to do merges when you have no
uncommited changes in your checkout). You will then have quite simply a
local repository with changes to the files. You then just have to commit
them with a relevent log message: e.g. svn commit -m "Merged revisions
x-y from trunk."

Hope that helps.

Col.

attached mail follows:


Accessing $HTTP_RAW_POST_DATA is similar to reading php://input which
I mentioned in my previous email.
I am not quite sure what is $_POST useful for. It is intended for
reading urlencoded data which it does only in special cases (no \0 or
\5C chars) and everyone has to parse it himself. Did I miss something?

--
Marek 'MMx' Ludha

On 9/23/06, Richard Lynch <ceol-i-e.com> wrote:
>
>
> Search php.net for RAW_HTTP_POST or somesuch.
>
> It's there for ya.
>
>
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
>
>