<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta content="http-equiv" contentType="text/html;charset=utf-8" />
<title>Поисковый клиент.</title>
</head>
<body>
<form method="post" action="">
<input type = "text" value = "science" name = "word" />
<input type = "submit" value = "Поиск"/>
</form>
<?php
if($_SERVER["REQUEST_METHOD"]=="POST")
{
$Phrase = $_POST["word"];
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Type: text/xml",
'content' => CreateXMLRPC("RobotLauncher.Search", $Phrase)
)));
try{
$file = file_get_contents("http://127.0.0.1:4444/xmlrpc", false, $context);
}
catch(Exception $e){
throw new Exception ('Ошибка сервера');
}
print($file);
$respXml = new SimpleXMLElement($file);
$xml = new SimpleXMLElement($respXml->xpath("//value")[0]);
?><table><?
foreach ($xml->result as $res)
{
printf("<tr><td>%s</td><td><a href=\"%s\">Перейти</a></td></tr>\n",$res->t, $res->link);
}
?></table><?
}
function CreateXMLRPC($ClassName, $SearchWord)
{
$request = new SimpleXMLElement("<methodCall/>");
$request->addChild("methodName",$ClassName);
$params = $request->addChild("params");
$param = $params->addChild("param");
$value = $param->addChild("value");
$value->addChild("string",$SearchWord);
return $request->asXML();
}
?>
</body>
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.