SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Zealot fredmintah's Avatar
    Join Date
    Jun 2004
    Location
    Ghana
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Urgent HELP: which php function to use?

    Hi all,
    I've made a search and could not find my answer. Can someone help out? I am using php to monitor a file. I will need to create a log file which will capture the user who accessed the file, time, and what has changed in a day. I am able to capture the time the file was accessed but the rest is battling me.
    Can anybody here teach me how to go about that? I mean how can I know who accessed the file and how do I know what has changed in the file ? I really need some answers from you all.
    As this proverb goes; "Little drops of water makes a mighty ocean" Your little idea on what I'm requesting will do me something good.

    Thanx to all

  2. #2
    SitePoint Addict
    Join Date
    Nov 2001
    Posts
    213
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For changes, I'd suggest taking a copy of the each time your script checks it, then using that to execute the 'diff' command, capturing the output in a php string. If you're on Windows I don't know what you'd use instead of diff.

    As far as I know there is no way to tell who accessed the file last. This info is not kept by the file system.

  3. #3
    SitePoint Zealot fredmintah's Avatar
    Join Date
    Jun 2004
    Location
    Ghana
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    thanx

    hi shakin,
    thanx very much for the info. I got one out of my two problems. diff is the answer to one. What I'm trying to explain here is I will like to know who modified the file last. I do not know how sitepoint does it but it like sitepoint style. whoever modified the file last will be added to the log file. Hope you do get my question. I am running this script from windows. I mean it will be run in schedule.
    really grateful for the answer.

  4. #4
    SitePoint Addict
    Join Date
    Nov 2001
    Posts
    213
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fredmintah
    hi shakin,
    thanx very much for the info. I got one out of my two problems. diff is the answer to one. What I'm trying to explain here is I will like to know who modified the file last. I do not know how sitepoint does it but it like sitepoint style. whoever modified the file last will be added to the log file. Hope you do get my question. I am running this script from windows. I mean it will be run in schedule.
    really grateful for the answer.
    Where does sitepoint do that? If you point it out to me maybe I can figure out what they're doing.

  5. #5
    SitePoint Zealot fredmintah's Avatar
    Join Date
    Jun 2004
    Location
    Ghana
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I mean, the way the get the user who has posted a script. I guess you know what I'm talking about. Now I know shakin is the one who replied my posts by looking at the user name displayed in blue. Can you show me how to use the diff() function? I mean what number of parameter does it require, it return type. You can do me a favour by showing me an example.

  6. #6
    SitePoint Guru arunkumar's Avatar
    Join Date
    Jan 2005
    Location
    India:Chennai
    Posts
    827
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hai fredminath,
    I dont know the answer but your topic is very interesting,I want to know the details abt your idea can i?
    Aunkumar
    Where there is a will there is a way
    ArunKumar

  7. #7
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Are users accessing the file via a PHP script, or directly on the server via a command line?
    Mike
    It's not who I am underneath, but what I do that defines me.

  8. #8
    SitePoint Zealot fredmintah's Avatar
    Join Date
    Jun 2004
    Location
    Ghana
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mike
    Are users accessing the file via a PHP script, or directly on the server via a command line?
    No to both questions. Sorry if I did not explain it well. The file is a log file created by a GIS software and it is accessed by the GIS software. I want to know what get added to the log file at the close of the day. Shakin gave me a clue to make a copy of the original file and use the diff() function to compare but I don't know the number of arguments the diff() function takes. This is the code I've currently. This code will give me the time and date the file was modified.
    PHP Code:
     <?php
    #    $fp = fopen("D:\Frederick_Mintah\php\Gemcom.log", "r");

        
    $mtime filemtime("D:\Frederick_Mintah\php\Gemcom.log");    
        print 
    "\n\n The file D:\Frederick_Mintah\php\Gemcom.log" " was modified on "date("D d M Y g:i A"$mtime) . "\n\n";
    ?>
    Now the problem is how do I know what has changed in the file Gemcom.log at the close of the day. What I'm particular about here is what has been added or deleted from the file. Since I now know I can't get user who changed the file cos it's in the file system info, I really do not care about that any longer but I need to know has changed in the file.
    Sorry if I did not ask this question earlier. It's about the same question but different direction. How can I know what files has been added to a directory at the close of a day. Hope I've been pardoned. Thanx


    Arunkumar
    I dont know the answer but your topic is very interesting,I want to know the details abt your idea can i?
    Aunkumar
    I hope by now you should get what I'm try to say but if not? A log file is created by a GIS software 1. I will like to know what has changed in the file at close of the day. 2. Who modified the file and at what time?

  9. #9
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, if you're on Windows, why don't you use built-in file monitoring / audit features?

  10. #10
    SitePoint Zealot fredmintah's Avatar
    Join Date
    Jun 2004
    Location
    Ghana
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx for the suggestion. I am working in company where there is an IT dept and I am in a different dept. I being the database administrator has now been task to do for our dept while the IT dept are not doing is by using a script it if the IT dept will not do for us. The IT dept. are aware of what I'm going to do though so do not bother to bring ur suggestion. I will also need to know since I'm writing a project in PHP in my last semester coming May this year.

    Cheers.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •