function Yijing_tire_hexagramme($lang)
{
$res = <<
tab_trig = new Array(9);
tab_trig = ["","111","110","101","100","011","010","001","000"];
tab_hexag = new Array(9);
tab_hexag[1] = new Array(9);
tab_hexag[2] = new Array(9);
tab_hexag[3] = new Array(9);
tab_hexag[4] = new Array(9);
tab_hexag[5] = new Array(9);
tab_hexag[6] = new Array(9);
tab_hexag[7] = new Array(9);
tab_hexag[8] = new Array(9);
tab_hexag[1] = ["", "1","43","14","34", "9", "5","26","11"];
tab_hexag[2] = ["","10","58","38","54","61","60","41","19"];
tab_hexag[3] = ["","13","49","30","55","37","63","22","36"];
tab_hexag[4] = ["","25","17","21","51","42", "3","27","24"];
tab_hexag[5] = ["","44","28","50","32","57","48","18","46"];
tab_hexag[6] = ["", "6","47","64","40","59","29", "4", "7"];
tab_hexag[7] = ["","33","31","56","62","53","39","52","15"];
tab_hexag[8] = ["","12","45","35","16","20", "8","23", "2"];
function deroul(no,tr)
{
if (no>1 && eval("self.document.hexa.deroul"+(no-1)+".value") == "_")
{
alert ("L_Commencer_par_le_bas_");
tr = "_";
eval("self.document.hexa.deroul"+no+".value='_'");
}
if (tr=="alea")
{
tr = Math.floor(6+4*Math.random());
eval("self.document.hexa.deroul"+no+".value="+tr);
}
eval("self.document.hexa.ti"+no+".src='img/Yj/trait"+tr+".gif'");
// change trigrammes
tb0 = ""; th0 = "";
for (i=1;i<=3;i++) eval("tb0+=self.document.hexa.deroul"+i+".value");
for (i=4;i<=6;i++) eval("th0+=self.document.hexa.deroul"+i+".value");
tb = tb0.replace(/[68]/gi,"0");
tb = tb.replace(/[79]/gi,"1");
th = th0.replace(/[68]/gi,"0");
th = th.replace(/[79]/gi,"1");
tbi = "";
for (i=1;i<=8;i++) if (tb == tab_trig[i]) tbi = i;
thi = "";
for (i=1;i<=8;i++) if (th == tab_trig[i]) thi = i;
eval("self.document.hexa.trig_bas.src='img/Yj/trig"+tbi+".gif'");
eval("self.document.hexa.trig_haut.src='img/Yj/trig"+thi+".gif'");
tx_bout = "- -";
if (tbi!="" && thi!="")
{ tx_bout = tb0+th0+" : "+tab_hexag[tbi][thi];
self.document.hexa.lien_hexa.style.background='#FC96AA'; }
self.document.hexa.lien_hexa.value=tx_bout;
}
function lance(v)
{ if (v!="- -")
{
url = "wengu.php?l=Yijing&tire="+v.replace(/ : /,"&no=")+"_PARAMS_LIEN_";
top.location=url;
}
}
function tire(t,n)
{
if (t<=6)
{
deroul(t,'alea');
if (n>3) { t = t+1; n = 0; }
setTimeout("tire("+t+","+(n+1)+")",200);
}
}
function raz(v)
{
for (i=1; i<=6; i++)
{
eval("self.document.hexa.ti"+i+".src='img/Yj/trait.gif'");
eval("self.document.hexa.deroul"+i+".value='_'");
}
self.document.hexa.lien_hexa.value="- -";
}
EOD;
if ($_GET["m"]) $params = "&m=".$_GET["m"];
if ($lang) $params.= "&lang=$lang";
$res = str_replace("_PARAMS_LIEN_",$params,$res);
$res = str_replace("L_Commencer_par_le_bas_",L_Commencer_par_le_bas_,$res);
$res = str_replace("L_Au_hasard",L_Au_hasard,$res);
$res = str_replace("L_RAZ",L_RAZ,$res);
$res = str_replace("L_Tire",L_Tire,$res);
return $res;
}
function TOC_Yijing($no,$lang)
{
// données
$tab_trig = array ("","1,1,1","0,1,1","1,0,1","0,0,1","1,1,0","0,1,0","1,0,0","0,0,0");
$inv_trig = array ("","8","7","6","5","4","3","2","1"); // échange yin <-> yang
$flp_trig = array ("","1","5","3","7","2","6","4","8"); // tête en bas
$py_trig = array ("","Qian","Dui","Li","Zhen","Xun","Kan","Gen","Kun");
$zh_trig = array ("","20094;","20812;","38626;","38663;","24061;","22350;","33390;","22372;");
$ligne_img[1] = " ";
$ligne_img[0] = " ";
$tab_hexag[1]=array("", "1","43","14","34", "9", "5","26","11");
$tab_hexag[2]=array("","10","58","38","54","61","60","41","19");
$tab_hexag[3]=array("","13","49","30","55","37","63","22","36");
$tab_hexag[4]=array("","25","17","21","51","42", "3","27","24");
$tab_hexag[5]=array("","44","28","50","32","57","48","18","46");
$tab_hexag[6]=array("", "6","47","64","40","59","29", "4", "7");
$tab_hexag[7]=array("","33","31","56","62","53","39","52","15");
$tab_hexag[8]=array("","12","45","35","16","20", "8","23", "2");
if ($lang == "en")
{
$trig_comment[1] = "Ch´ien, the Creative\n strong\n heaven\n father";
$trig_comment[2] = "Tui, the Joyous\n joyful\n lake\n third daughter";
$trig_comment[3] = "Li, the Clinging\n light-giving\n fire\n second daughter";
$trig_comment[4] = "Chên, the Arousing\n inciting movement\n thunder\n first son";
$trig_comment[5] = "Sun, the Gentle\n penetrating\n wind, wood\n first daughter";
$trig_comment[6] = "K´an, the Abysmal\n dangerous\n water\n second son";
$trig_comment[7] = "Kên, Keeping Still\n resting\n mountain\n third son";
$trig_comment[8] = "K´un, the Receptive\n devoted yielding\n earth\n mother";
}
else
{
$trig_comment[1] = "K´ien, le créateur\n fort\n le ciel\n père";
$trig_comment[2] = "Touei, le joyeux, le serein\n joyeux\n le lac\n 3e fille";
$trig_comment[3] = "Li, ce qui adhère\n lumineux\n le feu\n 2e fille";
$trig_comment[4] = "Tchen, l´éveilleur\n en mouvement\n le tonnerre\n 1er fils\n";
$trig_comment[5] = "Souen, le doux\n pénétrant\n le vent\n 1re fille";
$trig_comment[6] = "K´an, l´insondable, l´abîme\n dangereux\n l´eau\n 2e fils";
$trig_comment[7] = "Ken, l´immobilisation\n en repos\n la montagne\n 3e fils";
$trig_comment[8] = "K´ouen, le réceptif\n soumis, abandonné\n la terre\n mère\n";
}
// $TOC GENERALE YIJING (ET INTRO)
if ($no == -1 or $no == 0)
{
// tableau 8 x 8 des hexagrammes
$tabhex = "";
for ($i = 1;$i <9;$i++)
{
$tabhex.="";
for ($j = 1;$j <9;$j++)
{
//requete("UPDATE Yijing_TOC SET trig_bas = $i WHERE numero = ".$tab_hexag[$i][$j]);
$temp_no = $tab_hexag[$i][$j];
$tabhex.= "";
$tabhex.= " ";
$tabhex.= " \n";
}
$tabhex.= " ";
}
$tabhex.= "
";
// liste par numeros
$liste = "";
$sep = explode(",","¬,×,×,×,-,×,×,-,-,-,-,-,-,¬,¬,-,-,×,-,-,-,-,-,-,-,-,-,-,-,-,¬,¬");
for ($i = 1; $i <= 64; $i++)
{
if ($i<10) $ii = "0$i";
else $ii = $i;
$liste.= "$ii ";
if (strpos(" 02 08 14 20 26 30 34 36 42 48 54 60 "," $ii ")>0) $liste.=" ";
elseif ($i % 2 == 1 and $i != 64) $liste.=$sep[($i-1)/2];
else $liste.=" ";
}
$list.= " ";
$toc = "";
$toc.= "$tabhex ";
$toc.= "$liste ";//";
$toc.= "";
$toc.= Yijing_tire_hexagramme($lang);
$toc.= " ";
$toc.= "
";
if ($no == 0) return $toc;
// TRIGRAMMES
$ord_trigs = array("","1","8","4","6","7","5","3","2");
$trigs = separateur(L_Trigrammes,$GLOBALS['param_inf'],$GLOBALS['param_sup'],$no_ancre);
$trigs.= "";
for ($j = 1; $j <=8; $j++)
{
$i = $ord_trigs[$j];
$trigs.= "";
$trigs.= " ";
$trigs.= "".lien_dico("".$zh_trig[$i])." ";
$trigs.= "".str_replace("\n"," ",$trig_comment[$i])." ";
$trigs.= " ";
}
$trigs.= "
";
// HEXAGRAMMES
$tx = separateur(L_Hexagrammes,$GLOBALS['param_inf'],$GLOBALS['param_sup'],$no_ancre);
$tx.= "";
//$tx.= " ";
$rsql = requete("SELECT numero,titre_zh,titre_$lang,trig_bas,trig_haut FROM Yijing_TOC");
while (list($numero,$titre_zh,$titre_tx,$trig_bas,$trig_haut) = mysql_fetch_array($rsql))
{
$url = autoURL("no=$numero");
if ($numero<10) $numero = "0$numero";
$tx.= "";
$tx.= " \n";
$tx.= "".lien_dico($titre_zh)." \n";
$tx.= "".convertir_entites($titre_tx)." \n";
$tx.= "$numero \n";
$tx.= " \n ";
}
$tx.= "
";
return $toc.$trigs.$tx;
}
// TOC POUR CHAQUE PAGE
// cherche infos constituants
$rsql = requete("SELECT titre_zh,titre_py,titre_en,titre_fr,trig_bas,trig_haut,traits_maitres FROM Yijing_TOC WHERE numero = $no");
list ($titre_zh,$titre_py,$titre_en,$titre_fr,$trig_bas,$trig_haut,$traits_maitres) = mysql_fetch_array($rsql);
$traits = array_reverse(explode(",",",".$tab_trig[$trig_haut].",".$tab_trig[$trig_bas].","));
// cherche trigrammes nucléaires
$trig_nuc_haut = array_search($traits[5].",".$traits[4].",".$traits[3],$tab_trig);
$trig_nuc_bas = array_search($traits[4].",".$traits[3].",".$traits[2],$tab_trig);
// nom de l'hexa
$nom_hexa = "$no. ".lien_dico($titre_zh)." ";
//$nom_hexa.= "$titre_py — ";
$nom_hexa.= convertir_entites(($lang=="fr"? $titre_fr : $titre_en));
// legende
// $col_hexa = "#ccfccc";
// $col_prec = "#ffdef5";
// $col_suiv = "#ffc1de";
$col_hexa = "#ffc1de";
$col_prec = "#ccfccc";
$col_suiv = "#ccfccc";
$col_invt = "#ffee99"; // inverse les trigrammes
$col_oppo = "#ffd5cc"; // ##### échange chaque trait
$col_oppo = "#ccd5ff"; // échange chaque trait
$col_flip = "#FFCCAA"; // retourne l'hexa
$col_trait_gouvernant = "#0099FF";
$col_trait_constituant = "#FF0000";
$legende = "\n";
$legende.= " ".L_courant." \n";
$legende.= " ".L_binome." \n";
$legende.= " ".L_echange_trig." \n";
$legende.= " ".L_oppose." \n";
$legende.= " ".L_tetenbas." \n";
$legende.= "X ".L_maitre_gouvernant." \n";
$legende.= "X ".L_maitre_constituant;
$legende.= "
\n\n";
// definit prec_no et suiv_no
if ($no%2 == 0) $suiv_no = $no;
else $suiv_no = $no + 1;
$prec_no = $suiv_no - 1;
if ($no%2 == 0) $col_suiv = $col_hexa;
else $col_prec = $col_hexa;
// tableau 8 x 8 des hexagrammes
$tabhex = "";
for ($i = 1;$i <9;$i++)
{
$tabhex.="";
for ($j = 1;$j <9;$j++)
{
$temp_no = $tab_hexag[$i][$j];
$bgcolor = "";
if ($temp_no == $prec_no)
{ $bgcolor = "background-color:$col_prec";
$prec_no = $temp_no; $prec_b = $i ; $prec_h = $j; }
if ($temp_no == $suiv_no)
{ $bgcolor = "background-color:$col_suiv";
$suiv_no = $temp_no; $suiv_b = $i ; $suiv_h = $j; }
if ($i == $trig_haut and $j == $trig_bas)
{ $bgcolor = "background-color:$col_invt";
$invt_no = $temp_no; $invt_b = $i ; $invt_h = $j; }
if ($i == $inv_trig[$trig_bas] and $j == $inv_trig[$trig_haut])
{ $bgcolor = "background-color:$col_oppo";
$oppo_no = $temp_no; $oppo_b = $i ; $oppo_h = $j; }
if ($i == $flp_trig[$trig_haut] and $j == $flp_trig[$trig_bas])
{ $bgcolor = "background-color:$col_flip";
$flip_no = $temp_no; $flip_b = $i ; $flip_h = $j; }
if ($temp_no == $no) $bgcolor = "padding:8px;background-color:$col_hexa";
$tabhex.= "";
$tabhex.= " ";
$tabhex.= " \n";
}
$tabhex.= " ";
}
$tabhex.= "
";
// corrélats
$hexa_corr = "";
$hexa_corr.= " ".lien_dico("前")." ";
$hexa_corr.= " \n";
$hexa_corr.= " ".lien_dico("后")." ";
$hexa_corr.= " \n";
$hexa_corr.= " ".lien_dico("交")." ";
$hexa_corr.= " \n";
$hexa_corr.= " ".lien_dico("錯")." ";
$hexa_corr.= " \n";
$hexa_corr.= " ".lien_dico("總")." ";
$hexa_corr.= " \n";
$hexa_corr.= "
\n\n";
$TOChex.= '
_TRIG_HAUT_
_6_
_5_
_TRIG_NUC_HAUT_
_TRIG_NUC_BAS_
_4_
_TRIG_BAS_
_3_
_2_
_1_
';
// remplacements dans code HTML
$TOChex = str_replace("_TRIG_HAUT_",
//$py_trig[$trig_haut].
" ".lien_dico("".$zh_trig[$trig_haut])." ".
" ",
$TOChex);
$TOChex = str_replace("_TRIG_BAS_",
//$py_trig[$trig_bas].
" ".lien_dico("".$zh_trig[$trig_bas])." ".
" ",
$TOChex);
$TOChex = str_replace("_TRIG_NUC_HAUT_",
" ".
//$py_trig[$trig_nuc_haut].
" ".lien_dico("".$zh_trig[$trig_nuc_haut])." ",
$TOChex);
$TOChex = str_replace("_TRIG_NUC_BAS_",
" ".
//$py_trig[$trig_nuc_bas].
" ".lien_dico("".$zh_trig[$trig_nuc_bas])." ",
$TOChex);
for ($i = 1; $i<=6; $i++)
{
$temp_no_trait = $_GET["tire"]{$i-1};
if (!($temp_no_trait > 5)) $temp_no_trait = $traits[$i];
$TOChex = str_replace("_TRAIT".$i."_",$temp_no_trait,$TOChex);
list($traits_gouvernants,$traits_constituants) = split(",",$traits_maitres);
if (ereg($i,$traits_gouvernants))
$TOChex = str_replace("_".$i."_","$i ",$TOChex);
elseif (ereg($i,$traits_constituants))
$TOChex = str_replace("_".$i."_","$i ",$TOChex);
else
$TOChex = str_replace("_".$i."_","$i",$TOChex);
}
// compile la TOC
$toc = "";
$toc.= "$tabhex ";
$toc.= "$nom_hexa ";
$toc.= "$TOChex ";
$toc.= "$hexa_corr ";
$toc.= "
";
$toc.= $legende;
return $toc;
}
// ==============================================================
function texte_Yijing($no,$lang,$type,$tirage = "",$deduit= "")
{
if ($no == "" and $_GET["s"] == 1)
{
for ($i=1;$i<=64;$i++) $aff_tout.= " HEXAGRAMME $i ".texte_Yijing($i,$lang,$type,"","");
return $aff_tout;
}
// traite tirages
if ($tirage == "") $tirage = $_GET["tire"];
$ancient_tirage = $tirage;
if ($deduit == "DEDUIT")
{ $tirage = str_replace("6","7",$tirage);
$tirage = str_replace("9","8",$tirage); }
$tab_trig = array("","111","011","101","001","110","010","100","000");
$tab_hexag[1]=array("", "1","43","14","34", "9", "5","26","11");
$tab_hexag[2]=array("","10","58","38","54","61","60","41","19");
$tab_hexag[3]=array("","13","49","30","55","37","63","22","36");
$tab_hexag[4]=array("","25","17","21","51","42", "3","27","24");
$tab_hexag[5]=array("","44","28","50","32","57","48","18","46");
$tab_hexag[6]=array("", "6","47","64","40","59","29", "4", "7");
$tab_hexag[7]=array("","33","31","56","62","53","39","52","15");
$tab_hexag[8]=array("","12","45","35","16","20", "8","23", "2");
$temp = $tirage;
$temp = ereg_replace("[68]","0",$temp);
$temp = ereg_replace("[79]","1",$temp);
$trig_bas = array_search($temp{2}.$temp{1}.$temp{0},$tab_trig);
$trig_haut = array_search($temp{5}.$temp{4}.$temp{3},$tab_trig);
// LE CADRE POUR LA MUTATION
if ($deduit == "DEDUIT")
{
$no = $tab_hexag[$trig_bas][$trig_haut];
$debut = "";
$debut.= "MUTATION :";
if ($ancient_tirage==$tirage)
{
$debut.= " ".L_Pas_de_mutation."
";
return $debut;
}
$debut.= "";
for ($i=5; $i>=0; $i--)
{
$debut.= "";
$debut.= " ";
$debut.= " ";
$debut.= " ";
$debut.= " ";
}
$debut.= "
";
}
if ($tirage=="")
{
$rsql = requete("SELECT trig_haut,trig_bas FROM Yijing_TOC WHERE numero = $no");
list ($trig_haut,$trig_bas) = mysql_fetch_array($rsql);
}
$img_hexa.="";
$img_hexa.= "
\n\n";
$vire_ponctuation_trans = array("¡A" => "", "¡B" => "", "¡C" => "", "¡D" => "", "¡E" => "", "¡F" => "", "¡G" => "", "¡H" => "", "¡I" => "", "¡Q" => "", "¡u" => "", "¡v" => "", "¡]" => "", "¡^" => "");
// $tab_zh = mysql_fetch_array(requete("SELECT * FROM Yijing WHERE numero = $no "));
$tab2_zh = mysql_fetch_array(requete("SELECT * FROM Yijing WHERE numero = $no "));
$trad = mysql_fetch_array(requete("SELECT * FROM Yijing_tr WHERE numero = $no and traducteur='Wilhelm ($lang)'"));
// $tab_fr = mysql_fetch_array(requete("SELECT * FROM Yijing_tr WHERE numero = $no and traducteur='Wilhelm (fr)'"));
$champs = explode(",","nom,jugement,image,trait_1,trait_2,trait_3,trait_4,trait_5,trait_6,traits_tous");
$noms_champs = explode(",","The Hexagram,The Judgment,The Image,Lower line,Second line,Third line,Fourth line,Fifth line,Upper line,All lines");
if ($lang=="fr") $noms_champs = explode(",","L'Hexagrame,Le Jugement,L'Image,Trait inférieur,Second trait,Troisième trait,Quatrième trait,Cinquième trait,Trait supérieur,Tous les traits");
$ch_fr = explode(",","nom,trigrammes,jugement,image,trait_1,trait_2,trait_3,trait_4,trait_5,trait_6,traits_tous");
foreach ($champs as $val => $champ)
{
// $zh = $tab_zh[$champ];
$zh2 = $tab2_zh[$champ];
$tx = $trad[$champ];
// corrige les champs (tx_trig ajouté à tx_nom )
if ($champ == "nom")
if ($lang == "fr") $tx = "$tx ".$trad['trigrammes'];
else $tx = "$tx ".$trad['trigrammes'];
// avorte si vide
if (trim($zh2) == "" and trim($tx) == "") continue;
// avorte si le trait est stable (7 ou 8)
list($junk,$temp_tirage) = explode("trait_",$champ);
$temp_tirage = $tirage{$temp_tirage-1};
if ($temp_tirage == 7 or $temp_tirage == 8) continue;
// formatte le texte chinois
if (ereg("vertical",$type))
{
$zh2 = str_replace("¡D"," ",$zh2); // virgule
list ($vtitre2,$zh2) = explode (" ",$zh2,2);
$zh2 = ereg_replace(" [ \r\n]*$","",$zh2); // nettoie fin
}
if (ereg("vire_ponctuation",$type)) $zh2 = trim(strtr($zh2,$vire_ponctuation_trans));
if (ereg("vertical",$type))
$affzh = "".affiche_poeme_vertical($vtitre2,$zh2)."
";
else
$affzh = "".lien_dico($zh2)."
";
if ($_GET["m"] == "NOzh") $affzh = "";
if ($_GET["debug"] == "ok")
{$debug_href = "files/Travail.php?action=edite&submit=voir&sql_table=Yijing&sql_col=$champ&sql_where=numero%3D$no";
$affzh.= ""; }
// formatte traduque
if ($lang == "fr")
{
$tx = ereg_replace("[ \r\n]*"," ",$tx);
$tx = ereg_replace(" *([:?!»])"," \\1",$tx);
$tx = ereg_replace("([«]) *","\\1 ",$tx);
}
elseif ($lang == "en")
{
$tx = ereg_replace("?[bB]>","",$tx);
list($junk1,$junk2) = explode("",$tx,2);
$tx = $junk1."".ereg_replace("<[bB][rR]>"," ",$junk2);
}
$tx = str_replace(".",". ",$tx);
$tx = convertir_entites($tx);
//$tx = ereg_replace(" [ \t\r\n]*"," ",$tx);
$trans = array("" => ' " => '
',
"" => '', "" => '
');
$tx = trim(strtr($tx,$trans));
if ($champ == "nom") $tx = "$nom_hexa_zh $tx";
// inclure le texte
$res.= separateur($noms_champs[$val],$GLOBALS['param_inf'],$GLOBALS['param_sup'],$no_ancre);
$res.= "";
$res.= "
$affzh $img_hexa $tx
";
if ($_GET["debug"] == "ok")
{$ident = $trad["id"];
$debug_href = "files/Travail.php?action=edite&submit=voir&sql_table=Yijing_tr&sql_col=$champ&sql_where=id%3D$ident";
$res.= "
debug ";
$ident = $trad["id"];
$debug_href = "files/Travail.php?action=un_seul_paragraphe&champ=$champ&id=$ident";
$res.= " --
un seul par. "; }
if ($champ == "nom" and $_GET["debug"] == "ok")
{$ident = $trad["id"];
$debug_href = "files/Travail.php?action=edite&submit=voir&sql_table=Yijing_tr&sql_col=trigrammes&sql_where=id%3D$ident";
$res.= " -- trig :
debug ";
$ident = $trad["id"];
$debug_href = "files/Travail.php?action=un_seul_paragraphe&champ=trigrammes&id=$ident";
$res.= " --
un seul par. "; }
$res.= "
";
}
$res.= "";
$res.= lien_dico(str_replace("\r\n"," ",$tab_zh["notes"]))."
";
$res.= "
";
if ($deduit != "DEDUIT" and $tirage) $res = $res.texte_Yijing("",$lang,$type,$tirage,"DEDUIT");
// if ($deduit != "DEDUIT" and ereg("[69]",$tirage)) $res = $res.texte_Yijing("",$lang,$type,$tirage,"DEDUIT");
return $debut.$res;
}
?>
I Ching, the Book of Changes - Yi Jing I. 42.
...
易
經
Yi Jing – I Ching, the Book of Changes
This famous system of 64 hexagrams plus their commentaries and transformations is at the root of Chinese thought. Tr. Wilhelm (en, fr).