Thread: using files

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    77
    Rep Power
    14
    Hi,

    We have a set of logs and want to be able to have a php page that will be able to delete information from these files...

    for example, the log file would be opened and displayed on a php page in standard html type format. It would have a (delete) button next to each line. Is it possible to do this? We want to delete each selected line from the file.... the file is in the format of about 8 fields each separated by a space and lines terminated by "n". Help with this is much appreciated.

    Thanks

    Dave
  2. #2
  3. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    Is it possible to reformat your log file?

    Each line should have something unique (i.e. a log number). Instead of having a delete button next to each line, you can even have a radio button next to each line with the form value equals to the log number. Or even checkbox so you can delete multiple lines in one go. Without a unique log number for each line, you can still use a fake number by counting each line from top to bottom starting from zero or one, but this method probably can't work with multiple line deletion since once the first line is deleted, the line number changes dynamically.
    (i.e. line number 3 gets deleted, 4th line becomes line number 3 so it's not unique)

    Anyway, I only know the Perl way to perform such task. I hope you get the idea and come up with a way in PHP.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    77
    Rep Power
    14
    I can't reformat the log file directly as it is generated by the main frame.

    That idea you mention about the radio buttons / check boxes was sort of what I had in mind. However I just don't know if it is possible.

    I am wondering if you can set the log file up so be treated as an array and then overwrite the file with the new array.

    Also not sure but thinking implode and explode might be of use but I am not sure...

    thanks for your help!
  6. #4
  7. No Profile Picture
    unemployed dev junkie :(
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    32
    Rep Power
    14
    Of course it's possible !!!
    There you go... reade in the file as an array and use array index numbers as values for each check box(line) in the generated html form.. when the form is submited read in the file as an array again and just transfer all the elements(lines) to another array omiting the ones selected in the form..
    at the end create a new file from the new array.. there is one problem: only one instance of the script may be executed at a time.. meaning only one user should perform (have access to) this task at a given time..
    good luck

Similar Threads

  1. Can't move or delete it!
    By Hykinsel007 in forum Windows Help
    Replies: 3
    Last Post: June 15th, 2004, 03:41 PM
  2. Reading files that has certain parrent at once
    By cgi_pro in forum Perl Programming
    Replies: 2
    Last Post: January 29th, 2004, 10:13 PM
  3. how to rename files
    By dxgn in forum Perl Programming
    Replies: 1
    Last Post: January 1st, 2004, 01:10 PM
  4. How can I pack servlet files into a jar file?
    By suryahema in forum Java Help
    Replies: 1
    Last Post: December 18th, 2003, 08:32 AM
  5. Replies: 3
    Last Post: October 31st, 2003, 10:47 AM

IMN logo majestic logo threadwatch logo seochat tools logo