Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 2nd, 2012  |  syntax: None  |  size: 2.00 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /*
  3. @author  Geert Roumen
  4. @license Creative Commons
  5. Attribution-NonCommercial-ShareAlike
  6. 3.0 Unported
  7. @web     http://lemio.nl/
  8. @name    Untis to xml
  9.  
  10. description
  11. ---
  12. This script is made to enable people to hack (making Android apps)
  13. with the table system called Untis.
  14.  
  15. The most important part of the export is the courses. The ID says
  16. when the course is; 1 is monday the first hour, 5 friday the first
  17. hour, 40 is Friday to 8th hour.
  18. */
  19. header("Content-type: text/plain");
  20. echo "<?xml version=\"1.0\"?>\n";
  21. function at_line($line,$text){
  22.        $array = split("\r\n",$text);    
  23.  
  24.        return $array[$line];
  25.    }
  26. function get_text_content($url) {
  27.    return strip_tags(file_get_contents($url));
  28. }
  29. if (!$file = file_get_contents("https://beheer.ostrealyceum.nl/Clients/1/htdocs/1/rooster/dagrooster/45/s/s".$_GET["s"].".htm")){
  30.        echo "fout bij verbinden";
  31.    }
  32. //print_r();
  33. echo "<author>Geert Roumen</author>\n";
  34. echo "<student>\n";
  35. echo "<id>\n";
  36. echo at_line(12, $file);
  37. echo "\n</id>\n";
  38. echo "<name>\n";
  39. echo at_line(14, $file);
  40. echo "\n</name>\n";
  41. echo "<class>\n";
  42. echo strip_tags(at_line(16, $file));
  43. echo "\n</class>\n";
  44. $array = split("<TD colspan=6 rowspan=2 align=\"center\" nowrap=\"1\">",$file);
  45. for ($i=0;$i<40;$i++){
  46.            $file = $array[$i];
  47.    
  48.           $file = strip_tags($file);
  49.           $file = str_replace("\r\n","",$file);
  50.           $file = str_replace(".","",$file);
  51.           preg_match_all("/([A-Z\?\.\-]{3}) ([A-Z\.\?]{0,1}[0-9\.\?\-]{3}) ([a-z0-9\.\?\-]{2,4})/m",$file,$courses);
  52.           for ($j=0;isset($courses[1][$j]);$j++){
  53.               echo "<course id=$i";
  54.                if (strpos($array[$i],"FF0000")!==false){              
  55.               echo " changed";
  56.               }
  57.                   echo ">\n";
  58.              
  59.              echo "<teacher>".$courses[1][$j]."</teacher>\n";
  60.              echo "<classroom>".$courses[2][$j]."</classroom>\n";
  61.              echo "<subject>".$courses[3][$j]."</subject>\n";
  62.              echo "</course>\n";
  63.           }
  64.  }
  65. echo "</student>";
  66.           ?>