...

View Full Version : Logging Text Files



masterofollies
11-05-2007, 02:08 AM
So I have logging on my website, and it works well. I wanted to modify it and add it to a contest page I made where a person can win something. It will show me their name and how many tickets they have entered. When I try it, the log works perfect. It keeps logging each time and shows the total amount.

The problem is it won't log for anyone else. It seems limited to just one person. So the log is contest_Fayt. It should show a list of logs from different users. So it would look something like this, (made up names)

contest_Mark
contest_Henry
contest_William
contest_sarah

and you should be able to click the link and see the results of that person. I can click mine and it shows everything. But again doesn't record anyone else. So here is the coding, which is suppose to make a log. If you need the whole function of the logging let me know.


$logdate = "contest_".$userrow["charname"];
$logpath = "./logs/contest".$userrow["charname"]."/";
if (!is_dir($logpath)) {
@mkdir($logpath,0777);
@chmod($logpath,0777);
}
$logfile = $logpath.$logdate.".log";
$logcomments = "<br />--<b>".$userrow["charname"]."</b> Entered $tickets2 amount of tickets in the contest. ";
$logcomments .= $userrow["id"].",".$userrow["charname"]." on ".date("r");
$logcomments .= "\r\n";
$fp = fopen("$logfile", "a");
fwrite($fp, "$logcomments");
fclose ($fp);

Fumigator
11-05-2007, 03:15 AM
You need to trace $userrow["charname"] steps backward to see why it doesn't contain the different values like you think it does.

masterofollies
11-05-2007, 03:43 AM
It's weird because it saves the first textfile as contest_Fayt.log and I can view it perfectly fine.

bettytech
11-05-2007, 12:26 PM
Start a session for all visitors. All visitors without a session are new

Here comes the PHP code:

session_start();
if($_SESSION["logged"] != "yes")
{
$agent = $_SERVER['HTTP_USER_AGENT'];
$uri = $_SERVER['REQUEST_URI'];
$ip = $_SERVER['REMOTE_ADDR'];
$ref = $_SERVER['HTTP_REFERER'];
$visitTime = date("r"); //Example: Thu, 21 Dec 2000 16:01:07 +0200


$logLine = "$visitTime - IP: $ip || User Agent: $agent || Page: $uri || Referrer: $ref\n";
$fp = fopen("visitorLog.txt", "a");
fputs($fp, $entry_line);
fclose($fp);
$_SESSION["logged"] = "yes";
}
?>

masterofollies
11-05-2007, 05:39 PM
Max has jumped into the project for me. :thumbsup:

mlseim
11-05-2007, 06:31 PM
Resolved ... for those following this post.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum