Forum Moderators: DixonJones
My isp provides raw logs but the images are in there. I'd like to remove them at the server level before I download them. I'm on a Windows host. Does anyone have any asp or php scripts that can achieve this. Ideally copy the file to a temp file first and then strip out any image extensions.
Thanks
It wouldn't be the fastest if the logfiles are fairly large though. You could use something as simple as
$logpath = "/path/to/file.log";
$fp1 = fopen($logpath,"r");
$newpath = "/path/to/newfile.log";
$fp2 = fopen($newpath,"w");
while (!feof ($fp1)) {
$line = fgets($fp1);
if (strstr(line,"jpg") $$ strstr(line,"gif")) {
fwrite($fp2,$line);
}
}
fclose ($fp1);
fclose ($fp2);
should work though I didn't test it, as I said it may be slow for large files.