KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.62
System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64
User : www ( 80)
PHP Version : 8.3.8
Disable Function : NONE
Directory :  /domains/mandarintools/cgi-bin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /domains/mandarintools/cgi-bin/hiltonname.pl
#!/usr/bin/perl -- # -*- perl -*-
use CGI;
$query = new CGI;

require "callib.pl";

$largegifbase = "http://www.mandarintools.com/namegif";  # Base URL for location of name gifs
$smallgifbase = "http://www.mandarintools.com/cgi-bin/ugif";
$template = "hiltontemplate.html";

$origsurname = $query->param('surname');
$surname = "\L$origsurname\E";
$origfname = $query->param('fname');
$fname = "\L$origfname\E";
$mname = $query->param('mname');
$mname = "\L$mname\E";
$type = $query->param('type');

if ($surname =~ m/^\s*$/ or $fname =~ m/^\s*$/) {
    print "Content-type: text/html\n\n";
    print "<html><head>";
    print "<META HTTP-EQUIV=\"REFRESH\" content=\"4;url=http://www.mandarintools.com/hiltonnamer.html\">";
    print "</HEAD>";
    print "<body>";

    print "Must enter both a surname and first name.</body></html>";
    exit;
}

$e2c{'a'} = "a";
$e2c{'b'} = "b";
$e2c{'c'} = "k s";
$e2c{'d'} = "d t";
$e2c{'e'} = "a e";
$e2c{'f'} = "f";
$e2c{'g'} = "g k";
$e2c{'h'} = "h";
$e2c{'i'} = "y";
$e2c{'j'} = "j zh";
$e2c{'k'} = "k";
$e2c{'l'} = "l";
$e2c{'m'} = "m";
$e2c{'n'} = "n";
$e2c{'o'} = "a o";
$e2c{'p'} = "p b";
$e2c{'q'} = "k";
$e2c{'r'} = "r";
$e2c{'s'} = "s x sh";
$e2c{'t'} = "t";
$e2c{'u'} = "yu";
$e2c{'v'} = "f w";
$e2c{'w'} = "w";
$e2c{'x'} = "x sh";
$e2c{'y'} = "y";
$e2c{'z'} = "z zh";



$schar = getrandom(split(/\s/, $e2c{substr($surname, 0, 1)}));  

$fchar1 = substr($fname, 0, 1);
# Look for next consonant
$index = 1;
$fchar2 = "";
while ($index < length($fname)) {
    if (substr($fname, $index, 1) =~ m/^[bcdfghjklmnpqrstvwxyz]$/) {
	$fchar2 = substr($fname, $index, 1);
	last;
    }
    $index++;
}
if ($fchar2 eq "") {  # no consonants after first letter.  By default use second letter
    $fchar2 = substr($fname, 1, 1);
}

$fchar1 = getrandom(split(/\s/, $e2c{$fchar1}));
$fchar2 = getrandom(split(/\s/, $e2c{$fchar2}));

open(SUR, "surnames.b5") or die "Content-type: text/plain\n\nCan't find Surname file.";
while (<SUR>) {
    next if m/^#/;
    @info = split;
    if ($info[2] =~ m/^$schar/) {
	push @scandidates, $info[0];
	if ($info[4] eq "*") {
	    push @slikely_candidates, $info[0];
	}
	$surnameuni{$info[0]} = $info[1];
	$surnamepy{$info[0]} = $info[2];
    }
}
close(SUR);

# Use this to mimic surname distribution
# People are most likely to get common Chinese surnames,
# but unlikely ones are also still possible
if ($#slikely_candidates == -1 or ((rand 50) < 4)) {
    $csurname = getrandom(@scandidates);
} else {
    $csurname = getrandom(@slikely_candidates);
}

open(GIVEN, "givennames.b5") or die "Content-type: text/plain\n\nCan't find Given names file.";
while (<GIVEN>) {
    next if m/^#/;
    @info = split(/\t/);
    # Select characters that match pronounciation, characteristics, and placement
    if ($info[2] =~ m/^$fchar1/ and $info[4] =~ m/$type/ and $info[4] !~ m/2/) {
	push @f1candidates, $info[0];
	$given1uni{$info[0]} = $info[1];
	$given1py{$info[0]} = $info[2];
	$given1eng{$info[0]} = $info[3];
	$given1type{$info[0]} = $info[4];
    }
}
close(GIVEN);
$cgiven1 = getrandom(@f1candidates);

open(GIVEN, "givennames.b5") or die "Content-type: text/plain\n\nCan't find Given names file.";
while (<GIVEN>) {
    next if m/^#/;
    @info = split(/\t/);
    # Select characters that match pronounciation, characteristics, and placement
    if ($info[2] =~ m/^$fchar2/ and $info[4] =~ m/$type/ and $info[4] !~ m/1/) {
	push @f2candidates, $info[0];
	$given2uni{$info[0]} = $info[1];
	$given2py{$info[0]} = $info[2];
	$given2eng{$info[0]} = $info[3];
	$given2type{$info[0]} = $info[4];
    }
}
close(GIVEN);
$cgiven2 = getrandom(@f2candidates);

$chinname = $csurname . $cgiven1 . $cgiven2;
$csurpy = $surnamepy{$csurname};
$csurpy =~ s/^([a-z])/\U$1\E/;
$csurpy =~ s/[0-9]//;
$cgiv1py = $given1py{$cgiven1};
$cgiv1py =~ s/^([a-z])/\U$1\E/;
$cgiv1py =~ s/[0-9]//;
$cgiv2py = $given2py{$cgiven2};
$cgiv2py =~ s/[0-9]//;
$namepy = $surnamepy{$csurname} . $given1py{$cgiven1} . $given2py{$cgiven2};

$nicepy = $csurpy . " " . $cgiv1py . $cgiv2py;

#### Determine the Sign of the Person ####
$gday = $query->param("day");
$gmonth = $query->param("month");
$gyear = $query->param("year");
$gera = $query->param("era");


($jera, $jyear, $jmonth, $jday) = 
    Gregorian2Julian($gera, $gyear, $gmonth, $gday);
$juliandate = JulianPeriod($jera, $jyear, $jmonth, $jday);
# Get the Chinese Lunar Calendar Date
($dyn, $ruler, $title, $ryear, $cyear, $cmonthtype, $cmonthcycle, $cday) =
    julian_day_to_chinese($juliandate);
$ystem = ($cyear % 10) - 1;
$ybranch = ($cyear % 12) - 1;




#### Print out the web page #####
print "Content-type: text/html\n\n";


open(TEMPLATE, $template) or die $!;
while ($line = <TEMPLATE>) {
    if ($line =~ m/CONTENT/) {
	last;
    } else {
	print $line;
    }

}


#print <<HEADER;
#<HTML>
#<HEAD>
#<TITLE>$origfname $origsurname:  Your Chinese Name is $nicepy</TITLE>
#<BASE HREF="http://www.mandarintools.com/">
#</HEAD>
#<BODY BGCOLOR="gold">
#HEADER


    for ($m = 0; $m < length($chinname); $m++) {
	$chinhex .= "\%" . sprintf("%x", vec($chinname, $m, 8));

    }

## Print the GIF of the name

print <<NAME;
<CENTER>
<TABLE BORDER=5>
<TR>
<TD>
<IMG height=96 width=64 SRC="$largegifbase/$surnameuni{$csurname}.gif" ALT="$surnamepy{$csurname}">
<IMG height=96 width=64 SRC="$largegifbase/$given1uni{$cgiven1}.gif" ALT="$given1py{$cgiven1}">
<IMG height=96 width=64 SRC="$largegifbase/$given2uni{$cgiven2}.gif" ALT="$given2py{$cgiven2}">
</TD></TR></TABLE>
</CENTER><P>
NAME



print <<MEANING;

<TABLE CELLSPACING=5 BORDER WIDTH="100%">
<TR>
<TD VALIGN=TOP width="33%">
<H3>Surname (first character)</H3>
<IMG ALIGN=LEFT SRC=\"$smallgifbase/$surnameuni{$csurname}.gif\" ALT="$surnamepy{$csurname}">
<UL>
   <LI> <!-- <A HREF="http://www.mandarintools.com/sounds/$surnamepy{$csurname}.aif"> -->
    $csurpy
    <!-- </A> -->
</UL>
</TD>
<TD width="33%">
<H3>Given Name (middle character)</H3>
<IMG ALIGN=LEFT SRC=\"$smallgifbase/$given1uni{$cgiven1}.gif\" ALT="$given1py{$cgiven1}">
<UL> 
   <LI>
    <!-- <A HREF="http://www.mandarintools.com/sounds/$given1py{$cgiven1}.aif"> -->
    $cgiv1py
    <!-- </A> -->
   <LI>$given1eng{$cgiven1}
</UL>
<P>
</TD>
<TD width="33%">
<H3>Given Name (last character):</H3>
<IMG ALIGN=LEFT SRC=\"$smallgifbase/$given2uni{$cgiven2}.gif\" ALT="$given2py{$cgiven2}">
<UL>
  <LI> <!-- <A HREF="http://www.mandarintools.com/sounds/$given2py{$cgiven2}.aif"> --> $cgiv2py <!-- </A> -->
  <LI>$given2eng{$cgiven2}
</UL>
</TD>
</TR>
</TABLE>
<P>
MEANING


print "<P><CENTER>You were born in the Year of the $signs[$ybranch] " .
    "<IMG ALIGN=ABSMIDDLE SRC=\"$smallgifbase/$signuni[$ybranch].gif\"></CENTER>.";


print <<EXPLANATION;
<P>
<HR>
   Hello, $origfname $origsurname!  Above is the Chinese name which 
was \"inspired\" by your English name.  Chinese uses characters rather
than an alphabet, so names cannot be directly translated from English
to Chinese.  However, Chinese characters can be chosen which approximate
the English pronounciation, which is what this program does.
<P>
   Chinese names generally have 3 characters.  The surname, which is
usually 1 character, comes first.  Next are one or two characters which
are chosen by the parents (or the grandparents in traditional Chinese
culture).  This program chooses the surname and given names according
to the spelling of your name and the characteristics you choose.  The
selection is not unique though.  Everytime you use this tool, you will
likely get a different name.  So if you don\'t like the first name
you get, try again.
<P>
   This page is mostly created for entertainment.  Real Chinese names
should be chosen by someone who knows the nuances of Chinese language
and culture.  Ask a native speaker if you want a Chinese name you will
actually use.  Also, this tool will not translate Chinese names written
in English back to their original Chinese form.
<P>
EXPLANATION

while ($line = <TEMPLATE>) {
    print $line;
}
close(TEMPLATE);


exit(0);

# Helper subroutines

sub getrandom {
    (@larray) = @_;
    srand;
    if ($#larray == -1) {
	return "";
    } elsif ($#larray == 0) {
	$choice = 0;
    } else {
	$choice = (rand ($#larray + 1)) % ($#larray + 1);
    }
    $larray[$choice];
}

Anon7 - 2021