ManyCodes.com – codes & scripts Get free programming codes and tutorials!

13Feb/100

Display a different image for each day of the week

This PHP code will help you get the day of the week from the server date and then display an image (jpg or gif) to match.

<?php
/**
* Change the name of the image folder
*
* Images must be named Monday.gif, Tuesday.gif etc
*/
// Change to the location of the folder containing the images
$image_folder = "images/days";

// You do not need to edit below this line
$today = date('l');
if (file_exists($image_folder."/".$today.".gif")) {
echo "<img src=\"$image_folder/".$today.".gif\">";
}
else {
echo "No image was found for $today";
}
?>

The above code is referenced from http://www.totallyphp.co.uk

25Aug/090

How to view or display a logfile in real time on screen in linux

How do I see the log file in real time including all incoming logs as well?

You can use the tail command in linux command line which outputs the last part of files in real time including all incoming logs to a file. So you can view the last parts of your logs file (like access logs for the server) using this in real time!

Note: you may need to login as root user to view log files.

Command

tail -f file-name command

If your log file name is /var/log/lighttpd/access.log, enter:

tail -f /var/log/lighttpd/access.log

If your php log file name is /var/log/lighttpd/scripts.log, enter

tail -f /var/log/lighttpd/scripts.log

You will get a scrolling view of the /var/log/lighttpd/scripts.log for all incoming entries on screen. To stop simply hit CTRL+C.