I need some help desperately.
I paid someone to create the original script that does an array dif to compare which file names exist in the arrays and modify the files accordingly. However, I don't think he considered the fact that there were going to be so many files to check on. I can't afford to hire him or someone else, because the original script broke the bank.
I'm trying my damnedest to get this thing to work, but I am a novice, so I appologize a head of time for the many questions I will have, and would GREATLY appreciate any help, anyone could offer. General statements about which function to use might not be as useful as you think, because I may not know how to use it.
With all that said here is the script I conjured - I haven't tested it yet, because I doubt it will work. But, PLEASE DON'T HESITATE to offer advice.
$locdir = "/server/html/lgpics/";
$locdh = opendir($locdir);
$remdir = "/folder/anotherfolder/";
$remdh = opendir($remdir);
for ( $i=0; $i<=file_exists( readdir($remdh) ); $i++ )
{
if ( !fnmatch( readdir($remdh), readdir($locdh) ) )
{
$conn = ftp_connect($ftp_host);
$login = ftp_login($conn, $ftp_user, $ftp_password);
$fp = fopen($locdir.readdir($remdh), 'w');
$getfile = $remdir.readdir($remdh);
if (ftp_fget($conn, $fp, $getfile, FTP_BINARY))
{
fclose($fp);
echo 'Successfully transfered '.readdir($remdh).'!<br>';
} else {
echo 'ERROR: Could not transfer '.readdir($remdh);
ftp_quit($conn);
return 0;
exit;
}
}
}
for ( $i=0; $i<=file_exists( readdir($locdh) ); $i++ )
{
if ( !fnmatch( readdir($remdh), readdir($locdh) ) )
{
unlink( $locdir.readdir($locdh) );
echo 'File '.readdir($locdh).' successfully deleted.<br />';
}
}