Forum Moderators: coopster

Message Too Old, No Replies

My first script

simple quote of the day

         

lukasz

5:44 pm on Jul 3, 2003 (gmt 0)

10+ Year Member



I wrote a very simple script that will display different sentence each day. Probably it is not the best way to do that but it does what I need. My server and my audience are in different time zones (13 hours difference). So I had to add 13 hours to the timestamp, than get the date and then include file with the quote for that day. the script:
<?php
$timestamp = time();
$date_time_array = getdate($timestamp);
$hours = $date_time_array["hours"];
$minutes = $date_time_array["minutes"];
$day = $date_time_array["mday"];

$timestamp = mktime($hours + 13, $minutes, $day);
$d = strftime( "%d",$timestamp);
include "quote/$d.txt";
?>

I have some questions and I would appreciate some help.
What is the best way to use this script: to add whole script to my page, or use <?include "quote.php"?>?
Is this script safe?
And of course I would appreciate any feedback.
PS I used excellent Date manipulation in PHPtutorial [phpbuilder.net] for adjusting the date

jatar_k

4:31 pm on Jul 4, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



hey lukasz,

What is the best way to use this script: to add whole script to my page, or use <?include "quote.php"?>?

If you are just using it on the one page then I would put it right into the page. If it is being used in many pages then I would include the file.

Is this script safe?

Not really sure what you mean by safe. It isn't doing anything frightening. ;)

lukasz

5:09 pm on Jul 4, 2003 (gmt 0)

10+ Year Member



Thanks for reply, I was losing my hope?
about being safe - since I am new to programming and PHP I am not sure if particular command can be used in hostile manner(hijack web page, send spam etc). So I would like to be sure that I am not exposing myself be making some common errors.

jatar_k

5:12 pm on Jul 4, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



What you have done there is fine. Mostly you need to worry when you are accepting user input or using variables passed from some other page.

Since that particular script is completely self contained there are no problems you need to worry about.

vincevincevince

10:52 pm on Jul 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In terms of security - you'd do well to read this thread:

[webmasterworld.com...]