Jump to content

Script to Compare 2 seprate server directories


sdmeier

Recommended Posts

Hello everyone,

First let me say I apologize if this has been asked and answered already.  I have search through the forums and can't seem to find what I'm looking for.

Here is my problem & idea I had.

I assist people installing php-nuke platinum,  One of the major problems is for one reason or another they are not uploading all of the files.  Of course they all say "I uploaded the files and I'm sure everything is OK"  But soon you find out that it's not.

Anyway,  I started creating a script that simply checks for directories and files to see if they exists.  After starting this I soon realized this script was going to be huge. 

Here is the script I started to created for each file.

[code]
$file_name="index.php";
if(file_exists($file_name)) {
echo "<font color=green>";
echo ("$file_name - Validated.");
echo "</font>";
}
else {
echo "<font color=red><strong>";
echo ("$file_name - Validation Failed.");
echo "</strong></font>";
}

echo "<br/>\n";
[/code]

The Package has 8,624 files and 515 Directories.  Needless to say it was going to take me a while to do this as well.

My guess is there has to be a more simpler way to do this such as comparing a text file to a directory structure or even comparing 2 separate FTP locations.

I am not a programmer.  I am sitting here right now with "O'Reilly's - Learning PHP & MySQL" book right now.  LOL.
I can kinda figure out how things work, but to sit down and actually create something from scratch is a real stretch for me.

Thank you and I appreciate any help that can be given.
Link to comment
Share on other sites

i would create a script that would do the upload for them instead of creating a script that would compair the files.

But here are two functions I use to get the root directory and root file list.

By using these two functions with some little changes you can have it search the directory structure from the root down with lists of all the files in every directory.

I use forms of these two functures to create a script to do a complete revision controled backup of my servers via php/mysql.

with the ability to restore that backup to the same server or another server by running that script of the other server.

[code=php:0]
# this function is to display root directory list of folders
Function dirlistloop(){
# Set path
    $dirpath = ".";
# Get list of path
    $dh1 = opendir($dirpath);
# While loop if path was returned
    while (false !== ($file = readdir($dh1))) {
# Skip if . or .. dir
      if ($file != "." and $file != "..") {
# if dir found
        if (!is_file("$dirpath/$file")) {
# code to valid directory structure

        }}}
# Close path listing
    closedir($dh1);
}

# this function is to display root directory list of files
Function filelistloop(){
Connectvalues();
# Get Root File List
    $dirpath = ".";
# Get list of path           
    $dhr = opendir($dirpath);
# While loop if path was returned           
    while (false !== ($file = readdir($dhr))) {
# if file found call subroutine and pass path and filename               
        if (!is_dir("$dirpath/$file")) {
# code to valid files

}
    }
# Close path listing
    closedir($dhr);
}
[/code]
Link to comment
Share on other sites

I did find a script that I think may do what your talking about.
It looks like a script that would Download the File from our server to a remote server and then extract the file.  One Major issue with the script I found is it appears to be looking for a SQL DB.  And unfortunatly I have no idea what DB or tables I need o create.  I tried contacting the author but it appears that the Authors website and email are dead. :-(

If I could get that to work, I think that would solve a lot of issues.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.