Hi all,
Can anyone give me some suggestions on the log file that can keep track the user login and logout, edit data and delete data in the system.
Currently i have not idea to create the page and dunno how to start to create it..
Can some one guide me?
Thanks in advance.
5 19981
Hi all,
Can anyone give me some suggestions on the log file that can keep track the user login and logout, edit data and delete data in the system.
Currently i have not idea to create the page and dunno how to start to create it..
Can some one guide me?
Thanks in advance.
The php manual has a whole section on filesystem functions which can be found at http://php.net/filesystem
And also there is a decent tutorial that will kind of show you how to get files open and edited at http://www.tizag.com/phpT/files.php.
I would start with these resources and go from there. Good Luck!!
Hi,
Here is the example code from website. I try it but it cant work? -
<?php
-
$ac_arr = file('/path/to/copy/access_log');
-
$astring = join("", $ac_arr);
-
$astring = preg_replace("/(\n|\r|\t)/", "", $astring);
-
$records = preg_split("/([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", $astring, -1, PREG_SPLIT_DELIM_CAPTURE);
-
-
$sizerecs = sizeof($records);
-
-
// now split into records
-
$i = 1;
-
$each_rec = 0;
-
while($i<$sizerecs) {
-
$ip = $records[$i];
-
$all = $records[$i+1];
-
-
// parse other fields
-
preg_match("/\[(.+)\]/", $all, $match);
-
$access_time = $match[1];
-
$all = str_replace($match[1], "", $all);
-
-
preg_match("/\"GET (.[^\"]+)/", $all, $match);
-
$http = $match[1];
-
$link = explode(" ", $http);
-
$all = str_replace("\"GET $match[1]\"", "", $all);
-
-
preg_match("/([0-9]{3})/", $all, $match);
-
$success_code = $match[1];
-
$all = str_replace($match[1], "", $all);
-
-
preg_match("/\"(.[^\"]+)/", $all, $match);
-
$ref = $match[1];
-
$all = str_replace("\"$match[1]\"", "", $all);
-
-
preg_match("/\"(.[^\"]+)/", $all, $match);
-
$browser = $match[1];
-
$all = str_replace("\"$match[1]\"", "", $all);
-
-
preg_match("/([0-9]+\b)/", $all, $match);
-
$bytes = $match[1];
-
$all = str_replace($match[1], "", $all);
-
-
print("<br>IP: $ip<br>Access Time: $access_time<br>Page: $link[0]
-
<br>Type: $link[1]<br>Success Code: $success_code
-
<br>Bytes Transferred: $bytes<br>Referer: $ref
-
<br>Browser: $browser<hr>");
-
-
// advance to next record
-
$i = $i + 2;
-
$each_rec++;
-
}
-
?>
-
Can anyone guide me? I already change the file path..var/log/httpd/access_log.. but still cant work..
thanks in advance.
I am not sure what you are trying to do, but logging to a file is as simple as that: -
$message = 'Something happened in my script..';
-
$timestamp = date('d/m/Y H:i:s');
-
$log_file = '/var/log/my_script.log';
-
-
error_log('['.$timestamp.'] INFO: '.$message.PHP_EOL, 3, $log_file);
-
Make sure that the directory where you are directing your log exists. PHP will not give you any error message, but just not create any log.
Cheers,
Pimmy
Hi,
I try it.
My log file is actually is keep one record in linux..in location /var/log/http/access_log
My previous code is split the access log file into more meaning report come out.
Is it correct for the code to retrieve the access_log file?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Nicholas Then |
last post by:
I am writing an ASP.NET application and I have a class
that I have written to create a vCard...it just returns a
string with all the necessarry info... Anyway...is there
a way that I can create a...
|
by: egsys |
last post by:
I am simply trying to create a file in access 2003. Receive an error
message that:
"Workgroup administrator couldn't create the workgroup information
file. Make sure that you have specified a...
|
by: Bnob |
last post by:
It is possible to create a file in local user-machine?
With this code in code-behind:
fs = New System.IO.FileStream(lFileCSV, System.IO.FileMode.Create,
System.IO.FileAccess.Write)
The file...
|
by: Russ Green |
last post by:
I need help writing a method to create a simple text file. I want that file
to be saved to a local drive (client side of my asp.net app). The filename
will always be the same "license.txt" but the...
|
by: Victor |
last post by:
Hi,
We have following setup here Web Server (Win2000) and FTP Server (Win 2000)
We have ASP.NET application which runs on Web Server and writes file(s) onto
FTP Server. We created asp.net...
|
by: christiang |
last post by:
Hi guys, I'd like to use Alexia thumbnail service. It's an interesting
service, you pass an url to its cgi and you get a thumbnail of that
url. Of course they don't have the screenshots of all the...
|
by: j7o0s5 |
last post by:
How to create file help chm?
|
by: SteMc |
last post by:
Hi, I'm trying to create a text file on an asp page but am having loads
of trouble.
At the minute what happens is this - I have a form with a textarea.
When the form posts, the action is to run...
|
by: Kosal |
last post by:
Hi
I have problem with vb.net I want to create file setup or exe file for run on Client Computer that no need to install vb.net 2005 but I never do so I don't know what can i do?
Please help...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |