shrink.php(zip) shrink.php(exe)
<?php
include "shrink.php";
$newkml= new shrink;
$newkml->filename=; //where $filename is the full path and name of the file to be shrunk.
$newkml->clean(); ?>
Result
a file in the current directory preceded by "new-"
Further development
to be able to run this from a machine that
does not have php already installed or machine set up as a server php-gtk.
<?php
/* This class removes duplicate lines from files, designed for kml (google earth files)
it takes the file name ( $filesname) find the directory and creates a new file in that directory with the duplicate lines taken out
www.sallyje.co.uk
*/
class shrink {
var $filename;
//find dir part of file name
function dirpart(){$dir=dirname($this->filename);
return $dir;}
// make name for new file
function newfile(){$newfilename= "new-".basename($this->filename);
//echo "\nNew file name ".$newfilename."\n";
return $newfilename;}
//put content of file into array
function contents(){
$fcontents=file($this->filename);
return $fcontents;}
//clean(file contents,line number)
function clean(){
$fcontents=$this->contents();
$dir=$this->dirpart();
$newfile=$this->newfile();
$fg=fopen($dir."/".$newfile,"w+");
//echo $dir.$newfile."\n";
//find start of coordinates - write start of file
for($i=0;$i
fwrite($fg,$fcontents[$i]);
//check for dupiicates
$s=$fcontents[$i];
$j=$i++;
$t=$fcontents[$j];
while($t==$s):
$j++;
$t=$fcontents[$j];
endwhile;
$i=$j;
fwrite($fg,$fcontents[$i]);
}//eo for
//echo $i;
fwrite($fg,$fcontents[$i]);
fclose($fg);
}//eof clean
} //class
?>