<?php
// Created by Ardora www.webardora.net
//ArdoraFormularios-ardoraXML
//bajo licencia Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)
//para otros usos contacte con el autor
include_once ("para.php");
session_cache_limiter('nocache,private');
if ($_POST["action"] == "read") {
$xml = new DOMDocument("1.0", "utf-8");$xml->formatOutput = true;$xml->preserveWhiteSpace = false;$xml->load("../".folderWork."/".$_POST["indexKey"].".xml");$form=$xml->getElementsByTagName("form")->item(0);
$edit1=$form->getElementsByTagName("edit1")->item(0);
$paragrafo1=$form->getElementsByTagName("paragrafo1")->item(0);
echo json_encode(array("edit1"=>$edit1->nodeValue,"paragrafo1"=>stripslashes($paragrafo1->nodeValue)));
}
if ($_POST["action"] == "indexList") {$orderName=scandir ("../".folderWork."/");for ($i = 0; $i < count($orderName); $i++) {if (strcmp ($orderName[$i],".")==0 || strcmp ($orderName[$i],"..")==0){$orderData[$i]="";} else {
$xml = new DOMDocument("1.0", "utf-8");$xml->formatOutput = true;$xml->preserveWhiteSpace = false;$xml->load("../".folderWork."/".$orderName[$i]);$form=$xml->getElementsByTagName("form")->item(0);
$orderData[$i]=$form->getElementsByTagName("edit1")->item(0)->nodeValue;
}}; array_multisort($orderData,SORT_ASC,$orderName);
for ($i = 0; $i < count($orderName); $i++) {if (strcmp ($orderName[$i],".")!=0 && strcmp ($orderName[$i],"..")!=0){$resultArray[$i]=array($orderName[$i],$orderData[$i]);}}echo json_encode($resultArray);}
?>
