CHips L MINI SHELL

CHips L pro

Current Path : /opt/cpanel/ea-php54/root/usr/share/pear/RVSeagullMod/etc/
Upload File :
Current File : //opt/cpanel/ea-php54/root/usr/share/pear/RVSeagullMod/etc/rvConvertNativeToUtf8.pl

#!/usr/bin/perl

#RVSiteBuilder Scripts

use vars qw( @lang );

my $localLibs = $0;
$localLibs =~s/\/[a-z0-9]+\.pl$//i;

my $programPath = $localLibs . '/../';

@lang = (
        'afrikaans-iso-8859-1',
        'albanian-iso-8859-1',
        'arabic-windows-1256',
        'azerbaijani-iso-8859-9',
        'basque-iso-8859-1',
        'belarusian-windows-1251',
        'bosnian-windows-1250',
        'bulgarian-windows-1251',
        'catalan-iso-8859-1',
        'croatian-windows-1250',
        'danish-iso-8859-1',
        'dutch-iso-8859-1',
        'estonian-iso-8859-1',
        'finnish-iso-8859-1',
        'galician-iso-8859-1',
        'greek-iso-8859-7',
        'hebrew-iso-8859-8',
        'hungarian-iso-8859-2',
        'indonesian-iso-8859-1',
        'japanese-shift_jis',
        'korean-euc-kr',
        'latvian-windows-1257',
        'lao-iso-8859-1',
        'lithuanian-windows-1257',
        'persian-windows-1256',
        'romanian-iso-8859-1',
        'serbian-windows-1251',
        'serbian-latin-windows-1250',
        'slovak-windows-1250',
        'slovenian-iso-8859-2',
        'swedish-iso-8859-1',
        'tatarish-iso-8859-9',
        'ukrainian-windows-1251',
        'german-iso-8859-1',
        'english-iso-8859-15',
        'th-tis-620',
        'spanish-iso-8859-1',
        'spanish_latin-windows-1252',
        'italian-iso-8859-1',
        'malaysian-iso-8859-1',
        'norwegian-iso-8859-1',
        'french-iso-8859-1',
        'polish-iso-8859-2',
        'turkish-iso-8859-9',
        'portuguese-iso-8859-1',
        'brazilian_portuguese-iso-8859-1',
        'czech-windows-1250',
        'russian-windows-1251',
        'chinese-gb2312',#chinese_simplified-utf-8.php
        'chinese-big5',#chinese_traditional-utf-8.php
        'spanish_latin-windows-1252',
        'tamil-tscii',
        'hindi-utf-8',
        'georgian-utf-8',
        'lao-iso-8859-1',
        'tagalog-iso-8859-1',
        );


my $toCode = 'utf-8';

my @modcompoPath = (
        "$programPath/modules/sitebuilder/lang",
        "$programPath/modules/user/lang",
        "$programPath/modules/default/lang",
        "$programPath/modules/export/lang",
        "$programPath/modules/navigation/lang",
        "$programPath/modules/block/lang",
        "$programPath/modules/tutorial/lang",
        "$programPath/modules/main/lang",
        "$programPath/modules/newsletter/lang",
        
        "$programPath/scripts/form/language",
        "$programPath/scripts/guestbook/language",
        "$programPath/scripts/photo_album/language",
);


if (!-d $programPath) {
    print "Not found path $programPath ., Please update \$programPath on head file.\n"; 
    exit;
}

foreach my $langpath(@modcompoPath) {
    convertModuleScriptLang($langpath,$toCode);
}


    print "##############################\n";
    print "  WYSWYG Task\n";
    print "##############################\n";

convertWysiwygLang($programPath . '/www/wysiwyg/lang',$toCode);

sub convertWysiwygLang {
    my ($sourceDir,$toCode) = @_;
    
    my $langname;
    my $charset;
    my $nativeDir;
    my $utfDir;
    my $fromCode;
    my $cmd;
    
    
    foreach my $file(@lang) {
        $file =~/([a-z_]+)\-([a-z0-9\-]+)/;
        $langname = $1;
        $charset = $2;
        
        $fromCode = uc($charset);
        
        if ($charset eq $toCode) {
            next;
        }
                
        $nativeDir = sprintf("%s-%s",$langname,$charset);
        
        if ($file eq 'chinese-gb2312') {
            $langname = 'chinese_simplified';
        }          
        if ($file eq 'chinese-big5') {
            $langname = 'chinese_traditional';
        }
        
        if ($file eq 'serbian-latin-windows-1250') {
            $langname = 'serbian-latin';
            $fromCode = 'WINDOWS-1250';
        }
       
        
        $utfDir = sprintf("%s-%s",$langname,$toCode);
        
        if (!-d $sourceDir . '/' . $nativeDir) {
            next;
        }
        
           
        
    print "##############################\n";
    print "  =====  $nativeDir\n";
    print "##############################\n";            
    if (!-d $sourceDir . '/' . $utfDir . '/wysiwygpro/includes') {
        $cmd = sprintf('mkdir -p %s', $sourceDir . '/' . $utfDir . '/wysiwygpro/includes');
        exeCmd($cmd);
    }
    
    $cmd = sprintf('rm -f %s/*.php', $sourceDir . '/' . $utfDir . '/wysiwygpro/includes');
    exeCmd($cmd);
        
        $cmd = sprintf('cp -f %s/lang.inc.php  %s/lang.inc.php',
            $sourceDir . '/' . $nativeDir . '/wysiwygpro',
            $sourceDir . '/' . $utfDir . '/wysiwygpro',
            );
        exeCmd($cmd);
        
        
        
        opendir(DIR, $sourceDir . '/' . $nativeDir . '/wysiwygpro/includes'); 
        my (@dirs) =    readdir(DIR);
        closedir(DIR);
        

        foreach my $wfile ( @dirs ) {
            if ( $wfile eq '.' || $wfile eq '..' ) {
                next;
            }
            if ( $wfile =~/^\./ ) {
                next;
            } 
            if ( -f $wfile) {
                next;
            }
            
            $cmd = sprintf('cp -f %s %s', 
                
                $sourceDir . '/' . $nativeDir . '/wysiwygpro/includes/' . $wfile,
                $sourceDir . '/' . $utfDir . '/wysiwygpro/includes/' . $wfile);
            exeCmd($cmd);        
        
        }
        
        
        $cmd = sprintf('iconv -c --from-code=%s --to-code=%s %s/lang.inc.php > %s/lang.inc.php.utf',
            $fromCode,
            uc($toCode),
            $sourceDir . '/' . $utfDir . '/wysiwygpro',
            $sourceDir . '/' . $utfDir . '/wysiwygpro',
            );
        exeCmd($cmd);
        
        $cmd = sprintf('mv %s/lang.inc.php.utf  %s/lang.inc.php',
            $sourceDir . '/' . $utfDir . '/wysiwygpro',
            $sourceDir . '/' . $utfDir . '/wysiwygpro',
            );
        exeCmd($cmd);
        
        $cmd = sprintf("replace %s %s -- %s/lang.inc.php",
            $charset,
            $toCode,
            $sourceDir . '/' . $utfDir . '/wysiwygpro');
        exeCmd($cmd);
        
        opendir(DIR, $sourceDir . '/' . $utfDir . '/wysiwygpro/includes'); 
        my (@dirs) =    readdir(DIR);
        closedir(DIR);

       foreach my $wfile ( @dirs ) {
            if ( $wfile eq '.' || $wfile eq '..' ) {
                next;
            }
            if ( $wfile =~/^\./ ) {
                next;
            } 
            if ( -f $wfile) {
                next;
            }
            
            $cmd = sprintf('iconv -c --from-code=%s --to-code=%s %s > %s.utf', 
                $fromCode,
                uc($toCode),
                $sourceDir . '/' . $utfDir . '/wysiwygpro/includes/' . $wfile,
                $sourceDir . '/' . $utfDir . '/wysiwygpro/includes/' . $wfile,);
            exeCmd($cmd);
            
            $cmd = sprintf('mv %s.utf %s', 
                $sourceDir . '/' . $utfDir . '/wysiwygpro/includes/' . $wfile,
                $sourceDir . '/' . $utfDir . '/wysiwygpro/includes/' . $wfile,);
            exeCmd("$cmd");
       }            
    }
}

sub convertModuleScriptLang {
    my ($sourceDir,$toCode) = @_;
    
    my $langname;
    my $charset;
    my $nativeFile;
    my $utfFile;
    my $fromCode;
    print "##############################\n";
    print "  convert for $sourceDir\n";
    print "##############################\n";
    
    foreach my $file(@lang) {
        $file =~/([a-z_]+)\-([a-z0-9\-]+)/;
        $langname = $1;
        $charset = $2;
        $fromCode = uc($charset);
        if ($charset eq $toCode) {
            next;
        }
        $nativeFile = sprintf("%s/%s-%s.php",$sourceDir,$langname,$charset);
        
        if ($file eq 'chinese-gb2312') {
            $langname = 'chinese_simplified';
        }          
        if ($file eq 'chinese-big5') {
            $langname = 'chinese_traditional';
        }
        
        if ($file eq 'serbian-latin-windows-1250') {
            $langname = 'serbian-latin';
            $fromCode = 'WINDOWS-1250';
        }
        
        $utfFile = sprintf("%s/%s-%s.php",$sourceDir,$langname,$toCode);
        
        if (!-f $nativeFile) {
            next;
        }
        
        my $cmd = sprintf('iconv -c --from-code=%s --to-code=%s %s > %s', $fromCode,uc($toCode),$nativeFile,$utfFile);
        exeCmd($cmd);
    }
}   


sub exeCmd {
    my $cmd = $_[0];
    my $debug = 0;
    print ("$cmd \n");
    if (!$debug) {
        system($cmd);
    }
}

Copyright 2K16 - 2K18 Indonesian Hacker Rulez