I have made a script.
We can not be sure it will work out of the box.
As I have not been able to testrun it.
So, I have turned ON error reporting.
There is always some little detail needs to be fixed.
But this script will work when we are finished.
🙂
I have made it so it takes the log.txt data
cleans it up
and Saves to a new file called log_clean.txt
<?php
//For DEBUG only
error_reporting(E_ALL);
ini_set('display_errors',1);
$text = file('log.txt');
// Loop through array
// and make each $entry = firstname, password, date
foreach($text as $line) {
list($f,$p,$d) = explode('|',trim($line));
$entry[] = array('fn'=>$f,'pw'=>$p,'dt'=>$d);
echo $line . "<br />";
}
//Get how many entries
$c = count($entry);
//Loop and search for duplicates
for($i=0;$i<$c-1;$i++){
for($j=$i+1;$j<$c;$j++){
// Compare 2 entry, firstname AND password
if($entry[$i]['fn']==$entry[$j]['fn'] &&
$entry[$i]['pw']==$entry[$j]['pw']){
//if they are same, remove one
unset($entry[$i]);
break;
}
}
}
// Save the clean log in a new file
$lines = '';
foreach($entry as $item){
$lines .= implode('|',$item)."\n";
}
file_put_contents('log_clean.txt', $lines);
//For testing, echo the new $lines
echo '<hr /><pre>';
echo $lines;
?>