#!/usr/bin/perl -wT ############################################################################### # deflang.perl.txt - A workaround for setting a default lang. in Cpanel5 boxes # Version 0.1 beta (first public release) - 08/NOV/2002 # (c) 2002 Juan R. Pozo # http://html.conclase.net/cp/scripts/ # mailto:jrpozo@conclase.net ############################################################################### # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation; either version 2 of the License, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################### # INSTALLATION # 1) Check if there exists a file /scripts/postwwwacctuser in your server # 2) If it exists, I guess you'll figure out how to install this, skip the rest # If it doesn't exist, follow steps 3 to 9: # 3) switch to root user # 4) cd /scripts # 5) wget http://html.conclase.net/cp/scripts/deflang.perl.txt # 6) chown root.root deflang.perl.txt # 7) chmod 0700 deflang.perl.txt # 8) Edit the file to set your default language ($deflang variable, see below) # 9) mv deflang.perl.txt postwwwacctuser # From now on, you should see the text "Default language set" upon successful # account creation. ############################################################################### # Please consider making a donation today. Visit my amazon.com wishlist at: # http://html.conclase.net/link/wishlist # Thank you :) ############################################################################### use strict; $ENV{'PATH'} = '/bin:/usr/bin'; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; ############################################################################### # Please customize your settings ############################################################################### # Your default language (don't use spaces) my $deflang = "espaņol"; ############################################################################### # Customization done ############################################################################### my @output; my $user; my $inWHM = (defined($ENV{'WHM50'}) && $ENV{'WHM50'} ne ""); if (!@ARGV || $ARGV[0] eq "" || $ARGV[0] !~ /^([^\s:]{1,})$/) { deaderror("Missing or wrong argument in /scripts/postwwwacctuser\n"); } else { $user = $1; } if ($deflang =~ /\s/) { deaderror("Wrong format for default language (please don't use spaces), at /scripts/postwwwacctuser\n"); } open (CPU, "/var/cpanel/users/$user") || deaderror("Couldn't open user's cpanel data file: $!, at /scripts/postwwwacctuser\n"); while () { if (/^(([^=]+)=(?:\S*))/ && $2 ne "LANG") { push @output, "$1\n"; } } close CPU; push @output, "LANG=$deflang\n"; open (CPU, ">/var/cpanel/users/$user") || deaderror("Couldn't open user's cpanel data file: $!, at /scripts/postwwwacctuser\n"); print CPU @output; close CPU; if ($inWHM) { print "

"; } print "Default language set"; if ($inWHM) { print "

"; } print "\n"; exit; sub deaderror { my ($error) = @_; if ($inWHM) { print "
"; } print "$error\n"; if ($inWHM) { print "
\n\n"; } sleep(4); exit; }