spt_get.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. if(isset($_GET["code"])){
  3. $currCode=$_GET["code"];
  4. }
  5. else{
  6. $currCode="rm";
  7. }
  8. $caseRowCounter=0;
  9. $casetable = array();
  10. $beginHead = false;
  11. $endHead = false;
  12. $strError = "";
  13. $xmlOutput = "<script>";
  14. if(($handle=fopen("script/$currCode.csv",'r'))!==FALSE){
  15. while(($data=fgetcsv($handle,0,','))!==FALSE){
  16. if(!$beginHead && !$endHead){
  17. if($data[0]=="#"){
  18. $xmlOutput = $xmlOutput."<info><title>".$data[1]."</title>";
  19. $beginHead = true;
  20. }
  21. }
  22. //in head
  23. if($beginHead && !$endHead){
  24. if($data[0]=="#"){
  25. $xmlOutput = $xmlOutput."</info><inner>";
  26. $endHead = true;
  27. }
  28. else{
  29. $xmlOutput = $xmlOutput."<".$data[0].">".$data[1]."</".$data[0].">";
  30. }
  31. }
  32. //in body
  33. if($beginHead && $endHead){
  34. $xmlOutput = $xmlOutput . "<word><src>".$data[0]."</src><dest>".$data[1]."</dest></word>";
  35. }
  36. }
  37. $xmlOutput = $xmlOutput . "</inner>";
  38. }
  39. else{
  40. $strError=$strError."can not open script/sinhala.csv ";
  41. }
  42. $xmlOutput = $xmlOutput . "<error>".$strError."</error>";
  43. $xmlOutput = $xmlOutput . "</script>";
  44. echo $xmlOutput;
  45. ?>