August 28th, 2000, 08:00 PM
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.
August 28th, 2000, 11:49 PM
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.
August 28th, 2000, 11:56 PM
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!
August 30th, 2000, 01:32 PM
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..