GraphCount - automatic log file creation

All other scripts belong here
Post Reply
GL700Wing
Posts: 2
Joined: Sun Jan 20, 2008 7:13 am

GraphCount - automatic log file creation

Post by GL700Wing »

/*************************************
Title: GraphCount log file automatic creation
Version: 1.0
Author: Kathy Leslie
Demo: www.goldwing.org.au

Description:
Inserted the following code in graphcount.php to automatically create the text log file if it doesn't exist so that a counter is always displayed.

*************************************/

Insert the following code before the "if (file_exists($logfile)) {" line - should be about line 57

/* Create the log if it doesn't exist */
if (!file_exists($logfile)) {
$fp = fopen($logfile, "w") or die('ERROR: Can\'t write to the log file ('.$logfile.'), please make sure this file exists and is CHMOD to 666 (rw-rw-rw-)!');
$count = 0;
flock($fp, LOCK_EX);
fputs($fp, $count);
flock($fp, LOCK_UN);
fclose($fp);
chmod($logfile, 0666);
}
Klemen
Site Admin
Posts: 10114
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

This was included in counter version 1.0 but I decided to remove it in 1.1 as it could lead to potential security issues.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
GL700Wing
Posts: 2
Joined: Sun Jan 20, 2008 7:13 am

Post by GL700Wing »

Hi Klemen,

Thanks for your reply. Hopefully I won't experience any security problems with this modification as none of the directories or sub-directories for the Graphic Counter are world writable.

My main reasons for adding this code were:
1. so that the webmaster (usually me but sometimes another person) does not have to remember to create the log file when a new page is created; and
2. as a way of zeroing the counters (be deleting the log files on the server).


Kathy
Klemen
Site Admin
Posts: 10114
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Anyway, forgot to say thanks for sharing :wink:
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Post Reply