*/ function tibulaSetUrl($url) { global $ejaUrl; $ejaUrl=$url; } function tibula($id="") { global $ejaDom,$ejaDomXpath,$ejaUrl; $r=""; if (substr(strtolower($id),0,7) == "http://") { $ejaUrl=$id; } if (!$ejaUrl) { $ejaUrl="http://127.0.0.1/tibula.php"; } if (!$ejaDom) { if (!$query) { @$query=$_SERVER["QUERY_STRING"]."&".file_get_contents("php://input"); } $content["http"]=array("method"=>"POST","content"=>$query); $ejaDom=new DOMDocument(); @$ejaDom->loadHTML(stream_get_contents(fopen($ejaUrl,"rb",false,stream_context_create($content)))); $ejaDomXpath=new DOMXPath($ejaDom); } foreach($ejaDom->getElementsByTagName("form") as $f) { if ($f->getAttribute("name") == "ejaForm") { $action=$_SERVER["SCRIPT_NAME"]."?ejaLanguage="; if (isset($_REQUEST["ejaLanguage"])) { $action.=$_REQUEST["ejaLanguage"]; } else { $action.="en"; } $f->setAttribute("action",$action); foreach ($f->getElementsByTagName("input") as $i) { if ($i->getAttribute("type") == "hidden" && $i->parentNode->getAttribute("id") != "ejaCommands") { @$hidden.=$ejaDom->saveXML($i); } } } } if ($ejaDom->getElementById($id)) { $r=$ejaDom->saveXML($ejaDom->getElementById($id)); if ($id == "ejaCommands") { $r.=$hidden; } } else { $r=$ejaDom->saveXml(); } return $r; } ?>