"; if(isset($_REQUEST["cs1"])) $submitted_s1 = true; if($submitted_s1 && "-"==$_REQUEST["cs1"]) $cs_list = $cs_list.""; else $cs_list = $cs_list.""; if($submitted_s1 && ""==$_REQUEST["cs1"]) $cs_list = $cs_list.""; else $cs_list = $cs_list.""; for($i=0;$i".$cs1[$i].""; } $cs_list = $cs_list.""; $result[200]=$cs_list; $selected = ""; $cs_list = ""; $result[201]=$cs_list; $selected = ""; $cs_list = ""; $result[202]=$cs_list; //Build option list (Mandarin) $selected = ""; $submitted_s1 = false; $cs_list = ""; $result[203]=$cs_list; $selected = ""; $submitted_s2 = false; $cs_list = ""; $result[204]=$cs_list; $selected = ""; $submitted_s3 = false; $cs_list = ""; $result[205]=$cs_list; if(!isset($_REQUEST["reset"])){ $selected = ""; $cs_list = ""; $result[206]=$cs_list; $cin=""; if(isset($_REQUEST['codeinput'])){ $cin = $_REQUEST['codeinput']; } $result[207]=""; } $selected = ""; $cs_list = ""; $result[208]=$cs_list; $cin=""; if(isset($_REQUEST['othersinput'])){ $cin = $_REQUEST['othersinput']; } $result[209]=""; if(isset($_REQUEST['pg'])) $pg = (int)$_REQUEST['pg']; else $pg = 1; $dblink = mysqli_connect($UH_DB_HOST, $UH_DB_USER, $UH_DB_PASS) or die('Could not connect: '.mysqli_connect_error()); $dbqstr = ""; $unionstr = ""; $unionstr2 = ""; $dbselected = mysqli_select_db($dblink, $UH_DB_NAME); if(isset($_REQUEST['form4'])){ $codeinput = mysqli_real_escape_string($dblink, strtoupper($_REQUEST['codeinput'])); if ($codeinput != "") { $codetype = $_REQUEST['codetype']; if ($codetype == "ckccode") { redirect("charlist.php?ckcmixcode=$codeinput&lang=$lang"); } else if ($codetype == "unicode") { $dbqstr = "kUniCode='$codeinput'"; $result[2] = " selected=\"selected\""; } else if ($codetype == "b5code") { $dbqstr = "kBigFive='$codeinput'"; $result[3] = " selected=\"selected\""; } else if ($codetype == "gbcode") { $dbqstr = "kGB0='$codeinput'"; $result[4] = " selected=\"selected\""; } else if ($codetype == "hkscscode") { $dbqstr = "kHKSCS='$codeinput'"; $result[5] = " selected=\"selected\""; } $result[6] = " value=\"".$_REQUEST['codeinput']."\""; } } else if(isset($_REQUEST['form1'])){ $jiinput = $_REQUEST['jiinput']; // modified at 2010 May 25, check if jiinput has value if($jiinput != ""){ $dbqstr = "kUniCode=\"".strtoupper(dechex(uniord($jiinput)))."\""; $result[7] = " value=\"".$jiinput."\""; } } else if(isset($_REQUEST['form2']) || isset($_REQUEST['form3'])){ $s1 = isset($_REQUEST['form2'])?$_REQUEST['cs1']:$_REQUEST['ms1']; $s2 = isset($_REQUEST['form2'])?$_REQUEST['cs2']:$_REQUEST['ms2']; $s3 = isset($_REQUEST['form2'])?$_REQUEST['cs3']:$_REQUEST['ms3']; $crit = ""; /*commented 2011-06-30, change wildcard search*/ /*if($s1 != "-"){ //$crit = $crit.$s1; $crit = "(^".$s1."|[[:space:]]".$s1.")[1-9a-z]*"."[[:space:]]?"; } if($s2 != "-"){ //$crit = $crit.$s2; if($crit != "") $crit = "(^".$s1."|[[:space:]]".$s1.")".$s2."([1-9]*[[:space:]]?$|[1-9]*$)"; else $crit = "([[:space:]]?[1-9a-z]*|^[1-9a-z]*)".$s2."([1-9]*[[:space:]]?$|[1-9]*$)"; } if($s3 != "-"){ //$crit = $crit.$s3; if(($s1 != "-") && ($s2 != "-")) $crit = "(^".$s1."|[[:space:]]".$s1.")".$s2.$s3."[[:space:]]?"; else if(($s1 != "-") && ($s2 == "-")) $crit = "(^".$s1."|[[:space:]]".$s1.")"."[1-9a-z]*".$s3."[[:space:]]?"; else if(($s1 == "-") && ($s2 != "-")) $crit = "([[:space:]]?[1-9a-z]*|^[1-9a-z]*)".$s2.$s3."[[:space:]]?"; else $crit = "([[:space:]]?[1-9a-z]*|^[1-9a-z]*)".$s3."[[:space:]]?"; }*/ $s1 = str_replace("-",".",$s1); $s2 = str_replace("-",".",$s2); $s3 = str_replace("-","[1-9]",$s3); //$crit = "(^".$s1."|[[:space:]]".$s1.")".$s2.$s3."[[:space:]]?"; //$crit = "([:space:]?".$s1.")".$s2.$s3."([:space:]?)"; //$crit = "([:space:]?)".$s1.$s2.$s3."([:space:]?)"; $crit = "([[:<:]]".$s1.$s2.$s3."[[:>:]])"; if($crit != ""){ if($_REQUEST['slang'] == "cantonese"){ //$dbqstr = "kCantonese like '%".$crit."%'"; //$dbqstr = "kILE like '%".$crit."%'"; $dbqstr = "CONVERT(kILE using latin1) RLIKE '".$crit."'"; }else{ //$dbqstr = "kMandarin like '%".$crit."%'"; $dbqstr = "CONVERT(kMandarin using latin1) RLIKE '".$crit."'"; } } }else if(isset($_REQUEST['form5'])){ $othersinput = mysqli_real_escape_string($dblink, strtolower(rtrim(ltrim($_REQUEST['othersinput'])))); //$othersinput = strtoupper($_REQUEST['othersinput']); if ($othersinput != "") { $otherstype = $_REQUEST['others']; if ($otherstype == "urdu") { //$dbqstr = "kUrdu like '%$othersinput%'"; //$dbqstr = "(((CONVERT(kUrdu using latin1) RLIKE '[^1-9a-z]".$othersinput."[^1-9a-z]') OR (CONVERT(kUrdu using latin1) RLIKE '^".$othersinput."[^1-9a-z]') OR (CONVERT(kUrdu using latin1) RLIKE '[^1-9a-z]".$othersinput."$'))"; $dbqstr = "kUrdu = '$othersinput'"; } else if ($otherstype == "indy") { //$dbqstr = "kHindi like '%$othersinput%'"; //$dbqstr = "(((CONVERT(kHindi using latin1) RLIKE '[^1-9a-z]".$othersinput."[^1-9a-z]') OR (CONVERT(kHindi using latin1) RLIKE '^".$othersinput."[^1-9a-z]') OR (CONVERT(kHindi using latin1) RLIKE '[^1-9a-z]".$othersinput."$'))"; $dbqstr = "kHindi = '$othersinput'"; } else if ($otherstype == "english") { //$dbqstr = "LOWER(kDefinition) like '%$othersinput%'"; //$dbqstr = "((LOWER(kDefinition) like '% $othersinput %') OR (LOWER(kDefinition) like '% $othersinput') OR (LOWER(kDefinition) like '$othersinput %') OR (LOWER(kDefinition) like '$othersinput'))"; //$dbqstr = "(((LOWER(kDefinition) RLIKE '[^1-9a-z]".$othersinput."[^1-9a-z]') OR (LOWER(kDefinition) RLIKE '^".$othersinput."[^1-9a-z]') OR (LOWER(kDefinition) RLIKE '[^1-9a-z]".$othersinput."$'))"; $dbqstr = "(((CONVERT(kDefinition using latin1) RLIKE '[^1-9a-z]".$othersinput."[^1-9a-z]') OR (CONVERT(kDefinition using latin1) RLIKE '^".$othersinput."[^1-9a-z]') OR (CONVERT(kDefinition using latin1) RLIKE '[^1-9a-z]".$othersinput."$'))"; $included = ""; //$tdbqstr = "SELECT kUnicode FROM word where ((LOWER(kMeaning) RLIKE '[^1-9a-z]".$othersinput."[^1-9a-z]') OR (LOWER(kMeaning) RLIKE '^".$othersinput."[^1-9a-z]') OR (LOWER(kMeaning) RLIKE '[^1-9a-z]".$othersinput."$'))"; $tdbqstr = "SELECT kUnicode FROM word where ((CONVERT(kMeaning using latin1) RLIKE '[^1-9a-z]".$othersinput."[^1-9a-z]') OR (CONVERT(kMeaning using latin1) RLIKE '^".$othersinput."[^1-9a-z]') OR (CONVERT(kMeaning using latin1) RLIKE '[^1-9a-z]".$othersinput."$'))"; $tdbresult = mysqli_query($dblink, $tdbqstr); while($tbchi1 = mysqli_fetch_row($tdbresult)) { $included = $included."'".$tbchi1[0]."',"; } mysqli_free_result($tdbresult); $inc_dbqstr = ""; if($included != ""){ $included = substr($included,0,strlen($included)-1); $inc_dbqstr = " or kUnicode in (".$included.")"; } $dbqstr = $dbqstr.$inc_dbqstr.")"; //print $dbqstr; } else if ($otherstype == "chinese") { $included = ""; $tdbqstr = "SELECT kword FROM word where kword like '%".$othersinput."%'"; $tdbresult = mysqli_query($dblink, $tdbqstr); while($tbchi = mysqli_fetch_row($tdbresult)) { $tword = str_replace($othersinput, "", $tbchi[0]); //$lines = preg_split('//', $tword, -1); $lines = str_split_php4_utf8($tword); for($icount=0;$icount $value) { if($keyname != "lang"){ if($keyname == "jiinput" || $keyname == "othersinput") $value = urlencode($value); $qstr = $qstr.$keyname."=".$value."&"; } } $qstr = substr($qstr,0,strlen($qstr)-1); $result[113] = $qstr; if($dbqstr != ""){ //$dbqstr = "SELECT kUnicode, kBigFive, kGB0, kDefinition, kSimplifiedVariant, kTraditionalVariant, kMandarin, kILE, kCantonese, kCangjie, kTotalStrokes, kStrokes, kRadical, kHKGlyph, kHanyuPinlu, kFrequency, kUrdu, kHindi from unihan WHERE $dbqstr;"; $dbqstr = $unionstr."(SELECT kUnicode, kBigFive, kGB0, kDefinition, kSimplifiedVariant, kTraditionalVariant, kMandarin, kILE, kCantonese, kCangjie, kTotalStrokes, kStrokes, kRadical, kHKGlyph, kHanyuPinlu, kFrequency, kUrdu, kHindi from unihan a WHERE $dbqstr and exists (select kCKC from ckccode b where b.kUnicode=a.kUnicode) order by a.kTotalStrokes);"; $dbresult = mysqli_query($dblink, $dbqstr); //print $dbqstr; //$db_selected = mysql_select_db($UH_DB_NAME, $dblink); //$dbresult = mysql_query($dbqstr); $num_rows = mysqli_num_rows($dbresult); if($num_rows==1){ if ($dbresult) { $tbrow = mysqli_fetch_row($dbresult); if ($tbrow[0] != "") { $result[32] = $tbrow[0]; $result[33] = $tbrow[1]; $result[34] = $tbrow[2]; $result[24] = $tbrow[3]; $result[44] = $tbrow[4]; $result[45] = $tbrow[5]; $result[25] = $tbrow[6]; $result[26] = $tbrow[7]; $result[38] = $tbrow[8]; $result[31] = $tbrow[9]; $result[27] = $tbrow[10]; $result[28] = $tbrow[11]; $result[39] = $tbrow[12]; $result[35] = $tbrow[13]; $result[36] = $tbrow[14]; $result[29] = $tbrow[15]; $result[46] = $tbrow[16]; //Urdu $result[47] = $tbrow[17]; //Hindi mysqli_free_result($dbresult); // kCKC $dbqstr = "SELECT kCKC from ckccode WHERE kUnicode='".$tbrow[0]."'"; $dbresult = mysqli_query($dblink, $dbqstr); $result[22] = ""; if ($dbresult) { while($tbckc = mysqli_fetch_row($dbresult)) { $result[22] = $result[22]."".$tbckc[0]."  "; // Enforce to reset code selection to last found ckccode if ($_REQUEST['reset'] != "") { /* $result[1] = " selected=\"selected\""; $result[2] = ""; $result[3] = ""; $result[4] = ""; $result[5] = ""; $result[6] = " value=\"".$tbckc[0]."\""; */ $selected = ""; $cs_list = ""; $result[206]=$cs_list; $result[207]=""; } } mysqli_free_result($dbresult); } // kCKCQuick $dbqstr = "SELECT kCKCQuick from ckcquickcode WHERE kUnicode='".$tbrow[0]."'"; $dbresult = mysqli_query($dblink, $dbqstr); $result[21] = ""; if ($dbresult) { while($tbckcquick = mysqli_fetch_row($dbresult)) { $result[21] = $result[21]."".$tbckcquick[0]." "; } mysqli_free_result($dbresult); } // Generic Fields if ($result[44] != "") { $result[44] = getVariant($result[44]); } if ($result[45] != "") { $result[45] = getVariant($result[45]); } if ($result[36] != "") { $result[30] = substr($result[36], strpos($result[36], "(") + 1, strpos($result[36], ")") - strpos($result[36], "(") - 1); } if ($result[32] != 0) { $result[37] = "&#".hexdec($result[32]).";"; } if ($result[25] != "") { $result[25] = getAudioLinks(strtolower($result[25]), $UH_MAN_PATHNAME, $UH_AUD_SUFFIX); } if ($result[26] != "") { $result[26] = getAudioLinks(strtolower($result[26]), $UH_CAN_PATHNAME, $UH_AUD_SUFFIX); } if ($result[38] != "") { $result[38] = getAudioLinks(strtolower($result[38]), $UH_CAN_PATHNAME, $UH_AUD_SUFFIX); } if ($result[31] != "") { $result[31] = getCangjie($result[31])."(".$result[31].")"; } if ($result[27] != 0) { $result[27] = "".$result[27].""; } if ($result[39] != "") { $result[39] = "".$RADICAL[$result[39]].""; } $result[40] = $HANDICT_URL1.urlencode(unichr(hexdec($tbrow[0]))); $result[41] = $HANDICT_URL2.urlencode(unichr(hexdec($tbrow[0]))); $result[42] = $HANDICT_URL3.urlencode(unichr(hexdec($tbrow[0]))); $result[43] = $HANDICT_URL4.urlencode(unichr(hexdec($tbrow[0]))); // Skip data without CKC code if ($SKIPNONCKC) { if ($result[22] == "") { //for ($index = 1; $index <= 43; $index++) { for ($index = 1; $index <= 47; $index++) { $result[$index] = ""; } } } // words $dbqstr = "SELECT kWord, kCantonese, kMandarin, kMeaning from word WHERE kUnicode='".$tbrow[0]."' order by ordernum"; $dbresult = mysqli_query($dblink, $dbqstr); $result[301] = ""; if ($dbresult) { while($tbckc = mysqli_fetch_row($dbresult)) { if($tbckc[0]!=""){ //$result[301] = $result[301].""; $result[301] = $result[301].""; $result[301] = $result[301].""; $result[301] = $result[301].""; $result[301] = $result[301].""; //$result[301] = $result[301]."
 ".$tbckc[0]."
".$MSG[2027]."".getAudioLinks(strtolower($tbckc[1]), $UH_WORD_CAN_PATHNAME, $UH_WORD_CAN_SUFFIX)."
".$MSG[2026]."".getAudioLinks(strtolower($tbckc[2]), $UH_WORD_MAN_PATHNAME, $UH_WORD_MAN_SUFFIX)."
".$MSG[2025]."".$tbckc[3]."
"; } // Enforce to reset code selection to last found ckccode } mysqli_free_result($dbresult); } $result[210]=""; if($result[37]!="" && $result[32]!=""){ $filename = "flash/".$result[32].".swf"; if (strlen($result[32]) > 2){ $filename = "flash/".substr($result[32], 0, 1)."/".substr($result[32], 1, 1)."/".$result[32].".swf"; } if(file_exists($filename)){ //$result[210]="".$MSG[8006].""; $result[210]="".$MSG[8006].""; }else{ $result[210]="".$MSG[8006].""; } } } } }else if($num_rows>=2){ $base_url = "dictionary.php?"; $list = array(); /*$qs = $_SERVER['QUERY_STRING']; if(strpos($qs,"&pg=")>0) $qs = substr($qs,0,strrpos($qs,"&pg="));*/ foreach($_GET as $keyname => $value) { if($keyname != "pg"){ if($keyname == "othersinput") { $value = strtoupper(ascii2hex($value)); } $qs = $qs.$keyname."=".$value."&"; } } $qs = substr($qs,0,strlen($qs)-1); $num_pages = ceil($num_rows/$recs_per_page); // validate $pg if($pg < 1) $pg = 1; if($pg > $num_pages) $pg = $num_pages; $prev_page = ($pg<=1?1:$pg-1); $next_page = ($pg>=$num_pages?$num_pages:$pg+1); $start = ($pg-1)*20; if($unionstr2 == "") $dbsql2 = "SELECT kUnicode FROM unihan u where $dbcrit and exists (select kCKC from ckccode b where b.kUnicode=u.kUnicode) LIMIT $start, $recs_per_page"; else $dbsql2 = "SELECT * FROM (".$unionstr2."(SELECT kUnicode FROM unihan u where $dbcrit and exists (select kCKC from ckccode b where b.kUnicode=u.kUnicode) order by u.kTotalStrokes)) a LIMIT $start, $recs_per_page"; //print $dbsql2; $result2 = mysqli_query($dblink, $dbsql2); // Fetch all results and print them while($o = mysqli_fetch_assoc($result2)){ $str = "&#".hexdec($o['kUnicode']).";"; $list[] = "&#".hexdec($o['kUnicode']).";"; //$list[] = "&#".hexdec($o['kUnicode']).";"; } mysqli_free_result($result2); foreach($list as $name) { $output = $output.$name." "; } // If Javascript requested, go in here if($js) { print "have js"; $json = array('n'=>$num_pages, 'p'=>$pg, 's'=>$start, 'l' => $list); $JSON = new Services_JSON(); print $JSON->encode($json); // nothing more to output, so quit exit(); } if(!$js){ $result[101] = "block"; $disabled1 = ($pg==1)?"disabled":""; $disabled2 = ($pg==$num_pages)?"disabled":""; //$result[100]=$_SERVER['QUERY_STRING']."&"; //$result[100]=$qs."&"; $result[100]=$base_url.$qs."&pg=1"; //$result[102]=$prev_page; $result[102]=$base_url.$qs."&pg=".$prev_page; //$result[103]=$next_page; $result[103]=$base_url.$qs."&pg=".$next_page; //$result[104]=$num_pages; $result[104]=$base_url.$qs."&pg=".$num_pages; $result[105]=$start; $result[106]=$disabled1; $result[107]=$disabled2; $result[114]=($pg==1)?"":""; $result[115]=($pg==1)?"":""; $result[116]=($pg==$num_pages)?"":""; $result[117]=($pg==$num_pages)?"":""; $result[108]=$output; $result[109]=$num_rows; $endnum=(($start+$recs_per_page)>$num_rows)?$num_rows:($start+$recs_per_page); $result[110]=$MSG[8007]." ".$num_rows; $result[111]=($start+1)." - ".$endnum; } } else{ $result[112]=$MSG[7014]; if(isset($_REQUEST['ajax'])) echo $MSG[8005]; } } // Further process is needed for missing data if ($result[22] == "") { $result[22] = "-"; } if ($result[21] == "") { $result[21] = "-"; } if ($result[33] == "") { $result[33] = "-"; } if ($result[34] == "") { $result[34] = "-"; } if ($result[24] == "") { $result[24] = "-"; } if ($result[23] == "") { $result[23] = "-"; } if ($result[44] == "") { $result[44] = "-"; } if ($result[45] == "") { $result[45] = "-"; } if ($result[25] == "") { $result[25] = "-"; } if ($result[26] == "") { $result[26] = "-"; } if ($result[38] == "") { $result[38] = "-"; } if ($result[31] == "") { $result[31] = "-"; } if ($result[27] == "") { $result[27] = "-"; } if ($result[28] == "") { $result[28] = "-"; } if ($result[39] == "") { $result[39] = "-"; } if ($result[32] == 0) { $result[32] = "-"; } if ($result[35] == "") { $result[35] = "-"; } if ($result[30] == "") { $result[30] = "-"; } if ($result[29] == "") { $result[29] = "-"; } if ($result[38] == "") { $result[38] = "-"; } if ($result[46] == "") { $result[46] = "-"; } if ($result[47] == "") { $result[47] = "-"; } //if ($result[301] == "") { $result[301] = "
"; } if ($result[301] == "") { $result[301] = ""; } if(isset($_REQUEST['ajax'])){ $ajax_output[0] = $result[32]; $ajax_output[1] = $result[33]; $ajax_output[2] = $result[34]; $ajax_output[3] = $result[24]; $ajax_output[4] = $result[44]; $ajax_output[5] = $result[45]; $ajax_output[6] = $result[25]; $ajax_output[7] = $result[26]; $ajax_output[8] = $result[38]; $ajax_output[9] = $result[31]; $ajax_output[10] = $result[27]; $ajax_output[11] = $result[28]; $ajax_output[12] = $result[39]; $ajax_output[13] = $result[35]; $ajax_output[14] = $result[36]; $ajax_output[15] = $result[29]; $ajax_output[16] = $result[46]; //Urdu $ajax_output[17] = $result[47]; //Hindi $ajax_output[18]=$result[22]; $ajax_output[19]=$result[30]; $ajax_output[20]=$result[37]; $ajax_output[21]=$result[40]; $ajax_output[22]=$result[41]; $ajax_output[23]=$result[42]; $ajax_output[24]=$result[43]; $ajax_output[25]=$result[210]; $ajax_output[26]=$result[301]; $aout = ""; if($ajax_output[20]!=""){ for($j=0;$j<27;$j++){ $aout = $aout.$ajax_output[$j]; if($j<26) $aout = $aout."|"; } echo $aout; } /* else{ echo $MSG[8005]; } */ } if(!isset($_REQUEST['ajax']) && !isset($_REQUEST['js'])) evalResult($EV_DICTIONARY_FILENAME, $result); ?>