 |
|
|
 |
MAYA HIEROGLYPH DICTIONARY Peter Mathews and Péter Bíró Drawings by John Montgomery |
|
|
include ('/var/www/vhosts/research.famsi.org/httpdocs/scripts/php/include_fns.php');
session_start();
$conn = db_connect();
// replace this with the path to the HTML Purifier library
require_once '/var/www/vhosts/research.famsi.org/httpdocs/htmlPure440/library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
// configuration goes here:
$config->set('Core.Encoding', 'ISO-8859-1'); // replace with your encoding
$config->set('HTML.Doctype', 'HTML 4.01 Transitional'); // replace with your doctype
$purifier = new HTMLPurifier($config);
$search="";
$searchType=$purifier->purify($_GET['searchType']);
$mayaSearch=$purifier->purify($_GET['mayaSearch']);
$englishSearch=$purifier->purify($_GET['englishSearch']);
$spanishSearch=$purifier->purify($_GET['spanishSearch']);
$TSearch=$purifier->purify($_GET['TSearch']);
$TranSearch=$purifier->purify($_GET['TranSearch']);
$dateSearch=$purifier->purify($_GET['dateSearch']);
$letterSearch=$purifier->purify($_GET['letterSearch']);
$englishWordSearch=$purifier->purify($_GET['englishWordSearch']);
$spanishWordSearch=$purifier->purify($_GET['spanishWordSearch']);
//remove 'T' from TSearch
if($TSearch) {
$TSearch = str_replace('T','',$TSearch);
}
//format date
if($dateSearch) {
if(strstr($dateSearch,'>')) {
$dateArray = explode('>',$dateSearch);
$newDate = '> ' . '\''.trim($dateArray[1]).'\'';
}
if(strstr($dateSearch,'<')) {
$dateArray = explode('<',$dateSearch);
$newDate = '< ' . '\''.trim($dateArray[1]).'\'';
}
if(strstr($dateSearch,'=')) {
$dateArray = explode('=',$dateSearch);
$newDate = '= ' . '\''.trim($dateArray[1]).'\'';
}
if(strstr($dateSearch,'>=')) {
$dateArray = explode('>=',$dateSearch);
$newDate = '>= ' . '\''.trim($dateArray[1]).'\'';
}
if(strstr($dateSearch,'<=')) {
$dateArray = explode('<=',$dateSearch);
$newDate = '<= ' . '\''.trim($dateArray[1]).'\'';
}
} //end date
//set $searchfor to display to the user what they searched for
if($mayaSearch) {
$searchfor = $mayaSearch;
} elseif ($englishSearch) {
$searchfor = $englishSearch;
} elseif ($spanishSearch) {
$searchfor = $spanishSearch;
} elseif ($TSearch) {
$searchfor = $TSearch;
} elseif ($TranSearch) {
$searchfor = StripSlashes($TranSearch);
} elseif ($dateSearch) {
$searchfor = $dateSearch;
} elseif ($letterSearch) {
$searchfor = $letterSearch;
} elseif ($englishWordSearch) {
$searchfor = $englishWordSearch;
} elseif ($spanishWordSearch) {
$searchfor = $spanishWordSearch;
}
//replace the %,if exists, with * for display
if(strstr($searchfor,'%')) {
$searchfor = str_replace('%','*',$searchfor);
if(strstr($searchfor,'* ')) {
$searchfor = str_replace('* ',' ',$searchfor);
}
}
$_SESSION['searchfor'] = $searchfor;
##initialize
$image="";
$path="";
$k=1;
$where="";
$display_number = 15; //number of table rows it pulls from the database.
##if rowstart not passed in URL use zero else retrieve rowstart
if(!isset($_GET['rowstart'])) {
$rowstart=0;
} else {
$rowstart=mysql_real_escape_string($_GET['rowstart']);
}
if (isset($_GET['pagenum'])) {
$rowstart=((mysql_real_escape_string($_GET['pagenum'])-1)*$display_number);
}
//if $mayaSearch
if($mayaSearch) {
$mayaSearch = addSlashes($mayaSearch);
$mayaSearch = str_replace("*","%",$mayaSearch);
if(strstr($mayaSearch, ' and ')) {
$arr=split(' and ',$mayaSearch);
while(list($key,$value) = each($arr)) {
if($MSearch =="") {
$MSearch=" rootword like '% $value%'";
} else {
$MSearch=$MSearch . " and rootword like '% $value%'";
}
}//end while
} else if(strstr($mayaSearch, ' or ')) {
$arr=split(' or ',$mayaSearch);
while(list($key,$value) = each($arr)) {
if($MSearch =="") {
$MSearch=" rootword like '% $value%'";
} else {
$MSearch=$MSearch . " or rootword like '% $value%'";
}
}//end while
} else {
if($MSearch =="") {
$MSearch=" rootword like '% $mayaSearch%'";
} else {
$MSearch=$MSearch . " or rootword like '% $mayaSearch%'";
}
} //end if strstr
} //end if $mayaSearch
//echo $MSearch;
//$MSearch = addslashes($MSearch);
//if $englishSearch
if($englishWordSearch) {
$englishWordSearch = str_replace("*","%",$englishWordSearch);
if(strstr($englishWordSearch, ' and ')) {
$arr=split(' and ',$englishWordSearch);
while(list($key,$value) = each($arr)) {
if($MSearch =="") {
$MSearch=" english_gloss like '%$value%'";
} else {
$MSearch=$MSearch . " and english_gloss like '%$value%'";
}
}//end while
} else if(strstr($englishWordSearch, ' or ')) {
$arr=split(' or ',$englishWordSearch);
while(list($key,$value) = each($arr)) {
if($MSearch =="") {
$MSearch=" english_gloss like '%$value%'";
} else {
$MSearch=$MSearch . " or english_gloss like '%$value%'";
}
}//end while
} else {
if($MSearch =="") {
$MSearch=" english_gloss like '%$englishWordSearch%'";
} else {
$MSearch=$MSearch . " or english_gloss like '%$englishWordSearch%'";
}
} //end if strstr
} //end if $englishWordSearch
//echo 'english'.$MSearch;
//if $spanishSearch
if($spanishWordSearch) {
$spanishWordSearch = str_replace("*","%",$spanishWordSearch);
if(strstr($spanishWordSearch, ' and ')) {
$arr=split(' and ',$spanishWordSearch);
while(list($key,$value) = each($arr)) {
if($MSearch =="") {
$MSearch=" spanish_gloss like '% $value%'";
} else {
$MSearch=$MSearch . " and spanish_gloss like '% $value%'";
}
}//end while
} else if(strstr($spanishWordSearch, ' or ')) {
$arr=split(' or ',$spanishWordSearch);
while(list($key,$value) = each($arr)) {
if($MSearch =="") {
$MSearch=" spanish_gloss like '% $value%'";
} else {
$MSearch=$MSearch . " or spanish_gloss like '% $value%'";
}
}//end while
} else {
if($MSearch =="") {
$MSearch=" spanish_gloss like '% $spanishWordSearch%'";
} else {
$MSearch=$MSearch . " or spanish_gloss like '% $spanishWordSearch%'";
}
} //end if strstr
} //end if $spanishWordSearch
//echo 'spanish'.$MSearch;
//if thompson numbers
if($TSearch) {
$TSearch = str_replace("*","%",$TSearch);
if(strstr($TSearch, ' and ')) {
$arr=split(' and ',$TSearch);
while(list($key,$value) = each($arr)) {
if($ThomSearch =="") {
$ThomSearch=" and (thompson_num REGEXP '([[:alpha:]]|[[:<:]])".$value."([[:alpha:]]|[[:>:]])')";
} else {
$ThomSearch=$ThomSearch . " and (thompson_num REGEXP '([[:alpha:]]|[[:<:]])".$value."([[:alpha:]]|[[:>:]])')";
}
}//end while
} else if(strstr($TSearch, ' or ')) {
$arr=split(' or ',$TSearch);
while(list($key,$value) = each($arr)) {
if($ThomSearch =="") {
$ThomSearch=" and (thompson_num REGEXP '([[:alpha:]]|[[:<:]])".$value."([[:alpha:]]|[[:>:]])'";
} else {
$ThomSearch=$ThomSearch . " or thompson_num REGEXP '([[:alpha:]]|[[:<:]])".$value."([[:alpha:]]|[[:>:]])'";
}
}//end while
} else {
if($ThomSearch =="") {
$ThomSearch=" and (thompson_num REGEXP '([[:alpha:]]|[[:<:]])".$TSearch."([[:alpha:]]|[[:>:]])')";
} else {
$ThomSearch=$ThomSearch . " or thompson_num REGEXP '([[:alpha:]]|[[:<:]])".$TSearch."([[:alpha:]]|[[:>:]])'";
}
} //end strstr
} //end if $TSearch
//letter search - Maya
if($letterSearch) {
$letterSearch = str_replace("*","%",$letterSearch);
if($lSearch =="") {
$lSearch=" alpha_letter like '$letterSearch%'";
} else {
$lSearch=$lSearch . " and alpha_letter like '$letterSearch%'";
}
} //end if
//letter search - English
if($englishSearch) {
$englishSearch = str_replace("*","%",$englishSearch);
if($lSearch =="") {
$lSearch=" english_gloss like '$englishSearch%'";
} else {
$lSearch=$lSearch . " and english_gloss like '$englishSearch%'";
}
} //end if
//letter search - Spanish
if($spanishSearch) {
$spanishSearch = str_replace("*","%",$spanishSearch);
if($lSearch =="") {
$lSearch=" spanish_gloss like '$spanishSearch%'";
} else {
$lSearch=$lSearch . " and spanish_gloss like '$spanishSearch%'";
}
} //end if
if($dateSearch) { //retrieve date added
$result = mysql_query("select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and r.last_modified_date $newDate order by newroot ASC limit $rowstart,$display_number");
$result2 = mysql_query("select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and r.last_modified_date $newDate order by newroot ASC");
$sql = "select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and r.last_modified_date $newDate order by newroot ASC";
//echo 'datesearch';
//echo $sql;
} else if($letterSearch) { //retrieve letter maya
$result = mysql_query("select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and $lSearch order by newroot ASC limit $rowstart,$display_number");
$result2 = mysql_query("select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and $lSearch order by newroot ASC");
$sql = "select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and $lSearch order by newroot ASC";
//echo 'letter search ';
//echo $result2;
//echo $sql;
} else if($englishSearch) { //retrieve letter english
$result = mysql_query("select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and $lSearch order by newroot ASC limit $rowstart,$display_number");
$result2 = mysql_query("select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and $lSearch order by newroot ASC");
$sql = "select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and $lSearch order by newroot ASC";
//echo 'english';
} else if($spanishSearch) { //retrieve letter spanish
$result = mysql_query("select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and $lSearch order by newroot ASC limit $rowstart,$display_number");
$result2 = mysql_query("select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and $lSearch order by newroot ASC");
$sql = "select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and $lSearch order by newroot ASC";
//echo 'spanish';
//echo $sql;
} else if($TSearch != '') { //retrieve T Numbers
$result = mysql_query("select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss, d.thompson_num from mdp_root r, mdp_root_details d, mdp_meaning m WHERE r.mdp_id = d.mdp_id and r.mdp_id = m.mdp_id $ThomSearch order by newroot ASC limit $rowstart,$display_number");
$result2 = mysql_query("select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss, d.thompson_num from mdp_root r, mdp_root_details d, mdp_meaning m WHERE r.mdp_id = d.mdp_id and r.mdp_id = m.mdp_id $ThomSearch order by newroot ASC");
$sql = "select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss, d.thompson_num from mdp_root r, mdp_root_details d, mdp_meaning m WHERE r.mdp_id = d.mdp_id and r.mdp_id = m.mdp_id $ThomSearch order by newroot ASC";
//echo 'tnumber';
//echo $sql;
} else if(!$dateSearch || !$letterSearch || !$englishSearch || !$spanishSearch) {
if($englishWordSearch) {
$result = mysql_query("select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and ( $MSearch ) order by m.english_gloss ASC limit $rowstart,$display_number");
$result2 = mysql_query("select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and ( $MSearch ) order by m.english_gloss ASC");
$sql="select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and ( $MSearch ) order by m.english_gloss ASC limit $rowstart,$display_number";
//echo 'wnglishword';
//echo $sql;
} else if($spanishWordSearch) {
$result = mysql_query("select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and ( $MSearch ) order by m.spanish_gloss ASC limit $rowstart,$display_number");
$result2 = mysql_query("select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and ( $MSearch ) order by m.spanish_gloss ASC");
$sqlE="select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and ( $MSearch ) order by m.spanish_gloss ASC";
//echo $sqlE;
//echo 'spanishword';
} else if($mayaSearch) {
$result = mysql_query("select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and ( $MSearch ) order by newroot,r.rootword ASC limit $rowstart,$display_number");
$result2 = mysql_query("select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and ( $MSearch ) order by m.english_gloss ASC");
$sql="select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and ( $MSearch ) order by m.english_gloss ASC";
//echo 'mayaword';
//echo $sql;
} else if($allSearch) {
$result = mysql_query("select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and $MSearch order by newroot,r.rootword ASC limit $rowstart,$display_number");
$result2 = mysql_query("select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and $MSearch order by m.english_gloss ASC");
}
//echo 'allsearch';
$sql1 = "select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and $MSearch order by m.english_gloss ASC limit $rowstart,$display_number";
$sql2 = "select distinct r.mdp_id, r.rootword, replace(replace(r.rootword,'-', ''),'\'','z') newroot, m.gram_class, m.english_gloss, m.spanish_gloss from mdp_root r, mdp_meaning m WHERE r.mdp_id = m.mdp_id and $MSearch order by m.spanish_gloss ASC";
//echo $sql2;
//echo $result;
}
if($result2) {
$result_cnt = mysql_num_rows($result2);
//echo 'count2='.$result_cnt;
}
if($result) {
$record_cnt = mysql_num_rows($result);
//echo 'count1='.$result;
}
##determine number of pages
if (!isset($num_pages)) {
if($result_cnt > $display_number) {
$num_pages = ceil($result_cnt/$display_number);
} elseif($result_cnt > 0) {
$num_pages = 1;
}
$start=0;
}
$a = $rowstart + ($display_number) ;
if ($a > $result_cnt) { $a = $result_cnt ; }
$b = $rowstart + 1 ;
echo '';
if($searchfor != "" && $result_cnt > 0) {
echo 'Results '.$b.' - '.$a. ' of ' .$result_cnt .' for "' .stripslashes($searchfor).'"';
} else if($result_cnt > 0) {
echo 'Results '.$b.' - '.$a. ' of ' .$result_cnt;
} else if($result_cnt == 0) {
echo 'No Results Found.';
}
echo ' |
';
echo 'Click on a word below to view details. |
';
echo '
|
';
echo '';
echo '';
//put all the code here for running the script itself using $result in the while loop
for ($i=0; $i<$record_cnt; $i++) {
$row = mysql_fetch_array($result);
if($row['mdp_id']) {
$k++;
$id=$row['mdp_id'];
$word=$row['rootword'];
$image_number=$row['mdp_id'];
echo '';
?>
|
echo '';
if($id) {
$resultM = mysql_query("select m.gram_class, m.english_gloss, m.spanish_gloss from mdp_meaning m WHERE mdp_id = '$id'");
$recM_cnt = mysql_num_rows($resultM);
for($m=0; $m<$recM_cnt; $m++) {
$rowM = mysql_fetch_array($resultM);
echo $rowM['gram_class'] .' | ';
echo '';
echo $rowM['english_gloss'];
if(($rowM['english_gloss']) && ($rowM['spanish_gloss'])) {
echo ' /';
}
if($rowM['spanish_gloss']) {
echo ' ';
echo $rowM['spanish_gloss'];
}//end if
} //end for ($m=0; $m<$recM_cnt; $m++)
}//end if ($id)
echo ' | ';
}//end if ($row['mdp_id'])
//get image glyphs
$result3 = mysql_query("select glyph_image from mdp_root_details WHERE mdp_id = '$id' order by mdp_detail_id");
$rec3_cnt = mysql_num_rows($result3);
for ($j=0; $j<$rec3_cnt; $j++) {
$row3 = mysql_fetch_array($result3);
if($row3['glyph_image']) {
echo ' ';
}
} //end for ($j=0; $j<$rec3_cnt; $j++)
if($j >= $rec3_cnt) {
echo ' |
';
}
}//end for ($i=0; $i<$record_cnt; $i++)
echo '
';
echo '
';
echo '';
echo '';
if($num_pages>1)
{
if ($rowstart==0)
{ $current_page = 1;
} else {
$current_page=($rowstart/$display_number) + 1;
}
}
//replace the %,if exists, with * for next page
if(strstr($mayaSearch,'%')) {
$mayaSearch = str_replace('%','*',$mayaSearch);
if(strstr($mayaSearch,'* ')) {
$mayaSearch = str_replace('* ',' ',$mayaSearch);
}
}
if(strstr($englishWordSearch,'%')) {
$englishWordSearch = str_replace('%','*',$englishWordSearch);
if(strstr($englishWordSearch,'* ')) {
$englishWordSearch = str_replace('* ',' ',$englishWordSearch);
}
}
if(strstr($spanishWordSearch,'%')) {
$spanishWordSearch = str_replace('%','*',$spanishWordSearch);
if(strstr($spanishWordSearch,'* ')) {
$spanishWordSearch = str_replace('* ',' ',$spanishWordSearch);
}
}
//remove extra slashes
if (strstr($letterSearch,"\\\'")) {
$letterSearch = stripSlashes($letterSearch);
}
if ($rowstart>$numrows)
{?>
} else {?>
}?>
if($result2) {
$numrows = mysql_num_rows($result2);
}
if($rowstart+$display_number<$numrows) {
?>
} else {?>
}
echo ' | ';
?>
//echo 'New Search |
';
echo '';
echo '';
echo 'Go to Page: ';
for($i=1;$i<=$num_pages;$i++)
{
$next_start=$start + $display_number;
if($i!=$current_page)
{
echo '' . $i . ' ';
} else {
echo ' ' . $i . ' ';
}
} //end for
echo ' |
';
echo '';
echo 'Table of Contents | ';
echo '';
echo 'Print Results | ';
echo '
';
echo '
';
echo '
';
// echo '';
?>
Text links to all pages at this site are available at the FAMSI INDEX