export_ild.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /*
  3. export inline dictionary
  4. */
  5. $input = file_get_contents("php://input"); //
  6. $strHead = mb_strstr($input,'#',true,"UTF-8");
  7. $xmlBody = strstr($input,'#');
  8. $xmlBody = substr($xmlBody,1);
  9. parse_str($strHead);//
  10. $csvPath="../user/My Document/";
  11. $purefilename = basename($filename);
  12. $csvFilename = $csvPath.$purefilename.".ild";
  13. //save histroy file
  14. $myfile = fopen($csvFilename, "w") or die("Unable to open file!");
  15. fwrite($myfile, $xmlBody);
  16. /*
  17. $list=array("recorderId","pali","mean","type","gramma","parent","factors","factorMean","note","confer","status","delete","dictname","dictType","fileName","parentLevel");
  18. fputcsv($myfile,$list);
  19. $xml = simplexml_load_string($xmlBody);
  20. //get word list from xml documnt
  21. $wordsSutta = $xml->xpath('//word');
  22. foreach($wordsSutta as $ws){
  23. $list=array(
  24. $ws->recorderId,
  25. $ws->pali,
  26. $ws->mean,
  27. $ws->type,
  28. $ws->gramma,
  29. $ws->parent,
  30. $ws->factors,
  31. $ws->factorMean,
  32. $ws->note,
  33. $ws->confer,
  34. $ws->status,
  35. $ws->delete,
  36. $ws->dictname,
  37. $ws->dictType,
  38. $ws->fileName,
  39. $ws->parentLevel
  40. );
  41. fputcsv($myfile,$list);
  42. }
  43. */
  44. fclose($myfile);
  45. echo("Successful");
  46. echo "<a href=\"\">download</a>"
  47. ?>