php-general Digest 10 Nov 2003 05:34:23 -0000 Issue 2406

Topics (messages 168992 through 169008):

Solutions for 1970 epoch date restriction
        168992 by: YC Nyon
        168994 by: John W. Holmes
        168999 by: David Otton
        169006 by: Javier Muniz

First test release of BTportal made!!!!
        168993 by: Bas
        169000 by: Paul
        169001 by: Ryan A

Re: Beveled text
        168995 by: Javier Muniz

Re: Executing shell commands
        168996 by: Javier Muniz
        169002 by: Robert Cummings
        169007 by: Javier Muniz
        169008 by: Chris Shiflett

Re: High bandwidth application tips
        168997 by: dr. zoidberg

Re: DW Php update form where one field is menu from another table
        168998 by: Robb Kerr

Trouble sending an image's contents as output using header Content-Type...
        169003 by: Manuel Vázquez Acosta
        169004 by: Martin Towell
        169005 by: Manuel Vázquez Acosta

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Hi,

I have a table that includes 3 columns for day, month and year. Example:
Day, Month, Year
11,Jan, 1974
4,Sep, 1921
...
...

I need to construct a query where users can specify a starting date.
Currently, I stuck in mktime function became of the 1970 epoch problem. It
gives an error for dates before 1970.
Anyone has  a solution?


Regards
Nyon

--- End Message ---
--- Begin Message --- YC Nyon wrote:
I have a table that includes 3 columns for day, month and year. Example:
Day, Month, Year
11,Jan, 1974
4,Sep, 1921
...
...

I need to construct a query where users can specify a starting date.
Currently, I stuck in mktime function became of the 1970 epoch problem. It
gives an error for dates before 1970.
Anyone has  a solution?

Why are you using three separate columns? What database are you using?


--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
On Mon, 10 Nov 2003 01:41:15 +0800, you wrote:

>I have a table that includes 3 columns for day, month and year. Example:
>Day, Month, Year
>11,Jan, 1974
>4,Sep, 1921

That would be your problem - you should be using your database's native date
type.

>I need to construct a query where users can specify a starting date.
>Currently, I stuck in mktime function became of the 1970 epoch problem. It
>gives an error for dates before 1970.
>Anyone has  a solution?

[assumes mysql]

http://www.mysql.com/doc/en/Date_and_time_types.html

SELECT * FROM table WHERE start_date > '1969-08-25';

[for anyone who's interested, Raymond Chen's excellent journal had a short
article on various Windows timestamps:
http://blogs.gotdotnet.com/raymondc/permalink.aspx/99c54993-5c5e-45b9-95c1-c20a0526ce0b]

--- End Message ---
--- Begin Message ---
If you can't change your database for some reason, for instance if it's a
legacy system or other large systems rely on that table format, look into
PEAR's Date class, it can probably help you out.

-Javier

-----Original Message-----
From: David Otton [mailto:[EMAIL PROTECTED] 
Sent: Sunday, November 09, 2003 4:00 PM
To: YC Nyon
Cc: php
Subject: Re: [PHP] Solutions for 1970 epoch date restriction


On Mon, 10 Nov 2003 01:41:15 +0800, you wrote:

>I have a table that includes 3 columns for day, month and year. 
>Example: Day, Month, Year 11,Jan, 1974
>4,Sep, 1921

That would be your problem - you should be using your database's native date
type.

>I need to construct a query where users can specify a starting date. 
>Currently, I stuck in mktime function became of the 1970 epoch problem. 
>It gives an error for dates before 1970. Anyone has  a solution?

[assumes mysql]

http://www.mysql.com/doc/en/Date_and_time_types.html

SELECT * FROM table WHERE start_date > '1969-08-25';

[for anyone who's interested, Raymond Chen's excellent journal had a short
article on various Windows timestamps:
http://blogs.gotdotnet.com/raymondc/permalink.aspx/99c54993-5c5e-45b9-95c1-c
20a0526ce0b]

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

--- End Message ---
--- Begin Message ---
It's avaiable on:

http://members.home.nl/famde.jong/portalBT-0.0.1.zip

If you have any comments, post a reply.

If you find it is very easy, it is. That is why it is version 0.0.1

Okay, it is not that good, but please try it... There is even an install
script in it!!

--- End Message ---
--- Begin Message ---
You might consider creating your own lists to make releases and leave
php-list alone.
Imagine what it will happen if everybody will post their "releases" on the
list.
Cheers!
Paul


-----Original Message-----
From: Bas [mailto:[EMAIL PROTECTED]
Sent: Sunday, November 09, 2003 6:18 PM
To: [EMAIL PROTECTED]
Subject: [PHP] First test release of BTportal made!!!!


It's avaiable on:

http://members.home.nl/famde.jong/portalBT-0.0.1.zip

If you have any comments, post a reply.

If you find it is very easy, it is. That is why it is version 0.0.1

Okay, it is not that good, but please try it... There is even an install
script in it!!

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

--- End Message ---
--- Begin Message ---
Whats it about?
Can you give me a list of features?

Cheers,
-Ryan

--- End Message ---
--- Begin Message ---
Ok, that's reasonable.  My only suggestion would be to cache the images that
your script generates.  A good way to do this is to md5 or otherwise hash
the arguments to the PNG generation code and then have the code search for a
file in a specified directory (/tmp/generated_pngs for instance) with that
name before calling gd, if it exists just read out that file, otherwise
generate a new one and place it in the directory.  This will lower your
overhead without adding too much complexity.  To spray out the cached
version of your PNG use readfile() or something similar.

-Javier

-----Original Message-----
From: Ashley M. Kirchner [mailto:[EMAIL PROTECTED] 
Sent: Saturday, November 08, 2003 11:57 PM
To: Javier Muniz
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Beveled text


Javier Muniz wrote:

>Interesting, is this for a website?  If so have you tried doing the 
>same thing with CSS?  Using CSS you could make the site load faster and 
>be more accessible (for instance, you can allow users to choose their 
>own font size, and make it easier for page readers to handle your 
>page).
>
    When I originally created the script, it was simply an exercise, to 
see if I could do it.  However, I have since then incorporated it into a 
site design of mine, where I wanted the headers to be images, 
dynamically created.  So yes, for each page that loads, each header 
calls this script which then spits out the PNG data.  Large overhead, 
simply because I never bothered looking into doing it with CSS, and also 
because outputting a PNG image I'm guaranteed it will work, and it will 
look the way I want it to look (both font type, as well as with layout 
positioning,) as opposed to dealing with broken browsers and people not 
seeing the same thing.  And also because I can use my fonts, instead of 
relying on the user having a particular font installed on their system.

-- 
 H| I haven't lost my mind; it's backed up on tape somewhere.
  +--------------------------------------------------------------------
  Ashley M. Kirchner <mailto:[EMAIL PROTECTED]>   .   303.442.6410 x130
  IT Director / SysAdmin / WebSmith             .     800.441.3873 x130
  Photo Craft Laboratories, Inc.            .     3550 Arapahoe Ave. #6
  http://www.pcraft.com ..... .  .    .       Boulder, CO 80303, U.S.A. 

--- End Message ---
--- Begin Message ---
Ack! No no no no no! At least put something this critical in a password
protected database, not a place that could possibly be written to by a
malicious user that gains access to an easily-writable directory like /tmp,
the DoS and security ramifications of having a system like this are huge.
Be exceptionally careful, and never pretend that /tmp is a safe place for
data.  If something is being read from /tmp then it should be treated the
same way user-inputted data is, and never trusted.

-Javier

-----Original Message-----
From: Robert Cummings [mailto:[EMAIL PROTECTED] 
Sent: Sunday, November 09, 2003 12:47 AM
To: Teren
Cc: PHP-General
Subject: Re: [PHP] Executing shell commands


On Sun, 2003-11-09 at 03:41, Teren wrote:
>
> Hi, I'm trying to write a front end for something and I want to be 
> able to execute shell commands. I tried all of the pre-written 
> functions and non of them would work. I setup a user that can sudo and 
> then i set apache to run as that user. So, what I tried to do is 
> shell_exec("sudo -s; reboot;"); but that didn't work, I also tried 
> other numerous variations all of which didn't work (also using exec(), 
> system(), passthru()  ). If any one has any ideas how i can do this, 
> please let me know. Thanks

I believe this has been answered quite recently and the large consensus was
to have a daemon (cron or otherwise) check for some status file or database
entry, which when set it would perform the required function. So for
instance to reboot the machine, perhaps a cron job would check for the
existence of /tmp/myFrontEnd/reboot and if found reboot the machine. Thus
the front end would only need to create the file.

HTH,
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.          |
`------------------------------------------------------------'

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

--- End Message ---
--- Begin Message ---
I did mention database as one of the solutions. The question wasn't
about security so I didn't elaborate.

Cheers,
Rob.

On Sun, 2003-11-09 at 16:45, Javier Muniz wrote:
> Ack! No no no no no! At least put something this critical in a password
> protected database, not a place that could possibly be written to by a
> malicious user that gains access to an easily-writable directory like /tmp,
> the DoS and security ramifications of having a system like this are huge.
> Be exceptionally careful, and never pretend that /tmp is a safe place for
> data.  If something is being read from /tmp then it should be treated the
> same way user-inputted data is, and never trusted.
> 
> -Javier
> 
> -----Original Message-----
> From: Robert Cummings [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, November 09, 2003 12:47 AM
> To: Teren
> Cc: PHP-General
> Subject: Re: [PHP] Executing shell commands
> 
> 
> On Sun, 2003-11-09 at 03:41, Teren wrote:
> >
> > Hi, I'm trying to write a front end for something and I want to be 
> > able to execute shell commands. I tried all of the pre-written 
> > functions and non of them would work. I setup a user that can sudo and 
> > then i set apache to run as that user. So, what I tried to do is 
> > shell_exec("sudo -s; reboot;"); but that didn't work, I also tried 
> > other numerous variations all of which didn't work (also using exec(), 
> > system(), passthru()  ). If any one has any ideas how i can do this, 
> > please let me know. Thanks
> 
> I believe this has been answered quite recently and the large consensus was
> to have a daemon (cron or otherwise) check for some status file or database
> entry, which when set it would perform the required function. So for
> instance to reboot the machine, perhaps a cron job would check for the
> existence of /tmp/myFrontEnd/reboot and if found reboot the machine. Thus
> the front end would only need to create the file.
> 
> HTH,
> 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.          |
> `------------------------------------------------------------'
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
-- 
.------------------------------------------------------------.
| 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.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
I realize that, just didn't want to suggest that /tmp was a good solution
instead of a database.  The question is always about security, btw ;)

-Javier

-----Original Message-----
From: Robert Cummings [mailto:[EMAIL PROTECTED] 
Sent: Sunday, November 09, 2003 5:54 PM
To: Javier Muniz
Cc: Teren; PHP-General
Subject: RE: [PHP] Executing shell commands


I did mention database as one of the solutions. The question wasn't about
security so I didn't elaborate.

Cheers,
Rob.

On Sun, 2003-11-09 at 16:45, Javier Muniz wrote:
> Ack! No no no no no! At least put something this critical in a 
> password protected database, not a place that could possibly be 
> written to by a malicious user that gains access to an easily-writable 
> directory like /tmp, the DoS and security ramifications of having a 
> system like this are huge. Be exceptionally careful, and never pretend 
> that /tmp is a safe place for data.  If something is being read from 
> /tmp then it should be treated the same way user-inputted data is, and 
> never trusted.
> 
> -Javier
> 
> -----Original Message-----
> From: Robert Cummings [mailto:[EMAIL PROTECTED]
> Sent: Sunday, November 09, 2003 12:47 AM
> To: Teren
> Cc: PHP-General
> Subject: Re: [PHP] Executing shell commands
> 
> 
> On Sun, 2003-11-09 at 03:41, Teren wrote:
> >
> > Hi, I'm trying to write a front end for something and I want to be
> > able to execute shell commands. I tried all of the pre-written 
> > functions and non of them would work. I setup a user that can sudo and 
> > then i set apache to run as that user. So, what I tried to do is 
> > shell_exec("sudo -s; reboot;"); but that didn't work, I also tried 
> > other numerous variations all of which didn't work (also using exec(), 
> > system(), passthru()  ). If any one has any ideas how i can do this, 
> > please let me know. Thanks
> 
> I believe this has been answered quite recently and the large 
> consensus was to have a daemon (cron or otherwise) check for some 
> status file or database entry, which when set it would perform the 
> required function. So for instance to reboot the machine, perhaps a 
> cron job would check for the existence of /tmp/myFrontEnd/reboot and 
> if found reboot the machine. Thus the front end would only need to 
> create the file.
> 
> HTH,
> 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.          |
> `------------------------------------------------------------'
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
-- 
.------------------------------------------------------------.
| 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.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
--- Robert Cummings <[EMAIL PROTECTED]> wrote:
> I did mention database as one of the solutions. The question wasn't
> about security so I didn't elaborate.

I have done this same thing in the past, because I tend to answer the
question asked and nothing more.

However, recently I have begun trying to not give suggestions or examples
that will create a security vulnerability, as well as warning about them
in the examples provided.

This is based on my belief that people don't always know what questions
they should be asking, combined with my belief that they likely use the
examples or suggestions we provide exactly as stated. As such, I think it
is our responsibility to educate.

I'm not sure if anyone agrees with me, but this is my philosophy.

Chris

=====
My Blog
     http://shiflett.org/
HTTP Developer's Handbook
     http://httphandbook.org/
RAMP Training Courses
     http://www.nyphp.org/ramp

--- End Message ---
--- Begin Message --- Radu Manole wrote:

Hi all,

I do have a question about optimizing the php for large applications.
Many applications group the functions in files (eg. functions.inc.php) or
build classes, and these files/classes are called with 'require' or
'include' on the top of each main file.

What would be the speed penalty if we have to include many files or if these
functions containter files are over 100k in size. I know the php engine will
parse them too. Are any tips to follow when using many functions?

It is much better to include only one big file, but only if you need all of that functions. You should try to separate your functions into 3 or + files: LoginFunctions.php, OtherFunctions.php, PictureFunctions.php and include only the ONE you need. If you need all of them, make only one file, and include only one file.

--- End Message ---
--- Begin Message ---
Thanx. I placed there as well, but wasn't getting any responses so thought
I'd try this group as it has been invaluable in the past.

Finally got a response on the Macromedia group so I'll try that suggestion.

-- 
Robb Kerr
Digital IGUANA
Helping Digital Artists Achieve their Dreams
http://www.digitaliguana.com
http://www.cancerreallysucks.org

--- End Message ---
--- Begin Message ---
Hi all:

I have a page with a img tag:
<img src="/getthumbnail.php?fileid=12230983">

The script getthumbnail.php searchs for a thumbnail of the specified image
id; if not thumbnail exists, the script creates one; and then using
readfile() and header() functions flushes it contents to the browser. But it
fails.

The code is very simple:

header('Content-Type: image/jpeg');    // I'm testing with JPEGs

// If the thumbnails exists (or it gets generated this time)
if ($path = _generateThumbnail($_GET['fileid']))
    @readfile($path);
else
    @readfile(GENERIC_THUMBNAIL);    // A constant to a generic icon



Any tips?
Manu.

--- End Message ---
--- Begin Message ---
Maybe there's an error with _generateThumbnail() ?
Do you know for certain that _generateThumbnail() works okay ?

Martin

-----Original Message-----

Hi all:

I have a page with a img tag:
<img src="/getthumbnail.php?fileid=12230983">

The script getthumbnail.php searchs for a thumbnail of the specified image
id; if not thumbnail exists, the script creates one; and then using
readfile() and header() functions flushes it contents to the browser. But it
fails.

The code is very simple:

header('Content-Type: image/jpeg');    // I'm testing with JPEGs

// If the thumbnails exists (or it gets generated this time)
if ($path = _generateThumbnail($_GET['fileid']))
    @readfile($path);
else
    @readfile(GENERIC_THUMBNAIL);    // A constant to a generic icon

Any tips?
Manu.

--- End Message ---
--- Begin Message ---
> Maybe there's an error with _generateThumbnail() ?
> Do you know for certain that _generateThumbnail() works okay ?
>
> Martin
>

I do; it works correctly, the returned path exists. I also tested sending
the Content-Length header and it didn't work either.

Manu.

--- End Message ---

Reply via email to