MOON
Server: Apache/2.2.31 (Unix) mod_ssl/2.2.31 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
System: Linux csr818.wilogic.com 2.6.18-419.el5xen #1 SMP Fri Feb 24 22:50:37 UTC 2017 x86_64
User: digitals (531)
PHP: 5.4.45
Disabled: NONE
Upload Files
File: //proc/self/root/scripts.20110531.215904.25158/comparegdbm
#!/usr/bin/perl
# cpanel - comparegdbm                            Copyright(c) 2009 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

use Fcntl     ();
use GDBM_File ();

if ( $ARGV[0] eq '--bincheck' ) {
    print "BinCheck ok\n";
    exit();
}

if ( defined $ARGV[0] && -e $ARGV[0] && defined $ARGV[1] && -e $ARGV[1] ) {
    my %GDBM_FILE_A;
    my $ta = tie %GDBM_FILE_A, 'GDBM_File', $ARGV[0], &GDBM_File::GDBM_READER, 0644;
    die "$ARGV[0] does not appear to be a valid GDBM file." if !$ta;

    my %GDBM_FILE_B;
    my $tb = tie %GDBM_FILE_B, 'GDBM_File', $ARGV[1], &GDBM_File::GDBM_READER, 0644;
    die "$ARGV[1] does not appear to be a valid GDBM file." if !$tb;

    my %b_copy = (%GDBM_FILE_B);    # we need a copy since you can't delete() from this tied-readonly hash

    # does A exist in B
    for my $k ( sort keys %GDBM_FILE_A ) {
        if ( !exists $GDBM_FILE_B{$k} ) {
            print "$ARGV[1] is missing “$k”\n";
        }
        else {
            delete $b_copy{$k};     # we've seen it
        }
    }

    # any keys in B that were not in A
    for my $y ( sort keys %b_copy ) {
        print "$ARGV[1] has additional “$y”\n";
    }
}
else {
    print "This tool is for comparing the contents of 2 GDBM files.\n";
    print "Example: $0 /var/cpanel/locale/themes/x3/en.gdbm /var/cpanel/locale/themes/x3/fr.gdbm\n\n";
    print "Usage: $0 [gdbm file a] [gdbm file b]\n";
}