<?php
session_start();
if(isset($_FILES['file']))
{
$_SESSION['d']=file_get_contents($_FILES['file']['tmp_name']);
header("Location: http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
exit;
}
function update($p,$el)
{
if(get_class($el)=='DOMText')
{
if($el->isWhitespaceInElementContent())
return false;
if(isset($_POST[implode(',',$p)])&&($el->wholeText!=$_POST[implode(',',$p)]))
{
$el->replaceData(0,strlen($el->wholeText),$_POST[implode(',',$p)]);
return true;
}
return false;
}
array_push($p,$el->nodeName);
if(isset($el->childNodes))
foreach($el->childNodes as $node)
if(update($p,$node))return true;
return false;
}
function my_print($p,$el)
{
if(get_class($el)=='DOMText')
{
if($el->isWhitespaceInElementContent())
return;
print "<tr><td>".implode(',',$p)."</td><td style='width:100%;'>";
print "<input type=text value='".
htmlspecialchars($el->wholeText,ENT_QUOTES).
"' name='".
htmlspecialchars(implode(',',$p),ENT_QUOTES).
"' style='width:100%;'></td></tr>";
return;
}
array_push($p,$el->nodeName);
if(isset($el->childNodes))
foreach($el->childNodes as $node)
my_print($p,$node);
}
//echo $doc->saveXML();
$doc = new DOMDocument();
$doc->loadXML($_SESSION['d']);
if($_GET['get']==1)
{
header("Content-disposition: attachment; filename=".urlencode(date("Ymd-His").".xml"));
header("Content-type: text/xml; charset=utf-8");
print $_SESSION['d'];
exit;
}
if($_POST['update']==1)
{
update(Array(),$doc->documentElement);
$_SESSION['d']=$doc->saveXML();
header("Location: http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
exit;
}
print "<html><head>\n<meta http-equiv=content-type content="text/html; charset=UTF-8">\n".
"<meta http-equiv=content-language content=ru >\n".
"</head><body>\n";
print "<form method=post enctype='multipart/form-data' action=''>";
print "<input type=file name=file>";
print "<input type=submit value='ok'>";
print "</form>";
print "<a href='?get=1'>get</a>";
print "<form method=post enctype='multipart/form-data' action=''>";
print "<table style='width:100%'>";
my_print(Array(),$doc->documentElement );
print "</table>";
print "<input type=hidden name=update value=1>";
print "<input type=submit value='ok'>";
print "</form>";
print "</body></html>";
?>
Если Вы уже зарегистрированы на Портале - войдите в систему, если Вы еще не регистрировались - пройдите простую процедуру регистрации.