2
0

xml_save.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. $input = file_get_contents("php://input"); //
  3. $strHead = mb_strstr($input,'#',true,"UTF-8");
  4. $xmlBody = strstr($input,'#');
  5. $xmlBody = substr($xmlBody,1);
  6. parse_str($strHead);//
  7. $histroyPath = $filename."_histroy";
  8. if(is_dir($histroyPath)==FALSE){
  9. if (!mkdir($histroyPath)) {
  10. die('Failed to create folders...');
  11. }
  12. }
  13. $datatime=date("Ymd").date("His");
  14. $purefilename = basename($filename);
  15. $histroyFilename = $histroyPath.'/'.$datatime.'_'.$purefilename;
  16. //save histroy file
  17. $myfile = fopen($histroyFilename, "w") or die("Unable to open file!");
  18. fwrite($myfile, $xmlBody);
  19. fclose($myfile);
  20. //save data file
  21. $myfile = fopen($filename, "w") or die("Unable to open file!");
  22. fwrite($myfile, $xmlBody);
  23. fclose($myfile);
  24. //delete spare histroy file
  25. //
  26. $dir = $histroyPath.'/';
  27. $files = scandir($dir);
  28. $arrlength=count($files);
  29. if($arrlength>7){
  30. $del = $arrlength-7;
  31. $delcount=0;
  32. for($x=2;$x<$del+2;$x++) {
  33. if(is_file($dir.$files[$x])){
  34. unlink($dir.$files[$x]);
  35. }
  36. }
  37. }
  38. echo( $module_gui_str['editor']['1015']);
  39. ?>