PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/server_env/phplib/trackInput.php

https://github.com/kadewe/rea.framework
PHP | 173 lines | 96 code | 38 blank | 39 comment | 11 complexity | 0ce1315a8c78b4e6030a3bd15b28cbb0 MD5 | raw file
  1. <?php
  2. /* ----------------------------------------------------------------------
  3. "Rich E-Assesment (REA) Framework"
  4. A software framework for the use within the domain of e-assessment.
  5. Copyright (C) 2014 University of Bremen,
  6. Working Group education media | media education
  7. Prof. Dr. Karsten Wolf, wolf@uni-bremen.de
  8. Dipl.-Päd. Ilka Koppel, ikoppel@uni-bremen.de
  9. Dipl.-Math. Kai Schwedes, kais@zait.uni-bremen.de
  10. B.Sc. Jan Küster, jank87@tzi.de
  11. This program is free software: you can redistribute it and/or modify
  12. it under the terms of the GNU Affero General Public License as
  13. published by the Free Software Foundation, either version 3 of the
  14. License, or (at your option) any later version.
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. GNU Affero General Public License for more details.
  19. You should have received a copy of the GNU Affero General Public License
  20. along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. ---------------------------------------------------------------------- */
  22. /* Tracking data */
  23. $xml = $_POST['xml'];
  24. $userid = $_POST['id'];
  25. $folder = $_POST['type'];
  26. $sub = $_POST['sub'];
  27. $images = explode( "#" , $_POST['images']);
  28. $im_paths=explode("#",$_POST['paths']);
  29. print $userid."<br />";
  30. print $folder."<br />";
  31. print $sub."<br />";
  32. print "<br />";
  33. print "<br />";
  34. print "<br />";
  35. print $xml;
  36. print "<br />";
  37. print "<br />";
  38. print "<br />";
  39. print_r($im_paths);
  40. print "<br />";
  41. print "<br />";
  42. print "<br />";
  43. print_r($images);
  44. print "<br />";
  45. print "<br />";
  46. print "<br />";
  47. //PATH and PRINT
  48. $SCRIPT_NAME="[TrackingDataReceiver]: ";
  49. $TIME_STAMP=date("Ymd");
  50. /* CREATE PATH */
  51. mkdir("../data/tracking/".$TIME_STAMP);
  52. $path = "../data/tracking/".$TIME_STAMP."/".$folder;
  53. /* PRINT PATH */
  54. print $SCRIPT_NAME."data path is >>></br>";
  55. print $path."<br />";
  56. /* create main folders */
  57. if(file_exists($path))
  58. {
  59. print $SCRIPT_NAME."tracking folder exists"."<br />";
  60. }else{
  61. print $SCRIPT_NAME."create new tracking folder"."<br />";
  62. mkdir($path,0777);
  63. if(file_exists($path))
  64. {
  65. print $SCRIPT_NAME."tracking folder created"."<br />";
  66. }else{
  67. print $SCRIPT_NAME."tracking folder creation failed"."<br />";
  68. }
  69. }
  70. /* create sub folders */
  71. if(strlen($sub)>0)
  72. {
  73. $path.="/".$sub."/";
  74. if(file_exists($path))
  75. {
  76. print $SCRIPT_NAME."tracking folder exists"."<br />";
  77. }else{
  78. print $SCRIPT_NAME."create new tracking folder"."<br />";
  79. mkdir($path,0777);
  80. if(file_exists($path))
  81. {
  82. print $SCRIPT_NAME."tracking folder created"."<br />";
  83. }else{
  84. print $SCRIPT_NAME."tracking folder creation failed"."<br />";
  85. }
  86. }
  87. }
  88. $imagepath = $path;
  89. /*add user id and write xml file*/
  90. $path.="/".$userid.".xml";
  91. $file = fopen($path, "w");
  92. fputs($file,$xml);
  93. fclose($file);
  94. if(file_exists($path))
  95. {
  96. print $SCRIPT_NAME."file written"."<br />";
  97. }else{
  98. print $SCRIPT_NAME."file not written"."<br />";
  99. }
  100. //-------------------------------------------
  101. //
  102. // save all generated images
  103. //
  104. //-------------------------------------------
  105. print "start saving screenshots<br>";
  106. print $imagepath."<br>";
  107. print "images: "+count($images);
  108. print "paths: "+count($im_paths);
  109. for($i=0;$i<count($images);$i++)
  110. {
  111. print "get image<br>";
  112. $im_path = $imagepath."/".$im_paths[$i];
  113. print $im_path."<br>";
  114. if(!file_exists($im_path))
  115. {
  116. $im = $images[$i];
  117. $img = imagecreatefromstring(base64_decode($im));
  118. if($img != false)
  119. {
  120. imagepng($img, $im_path);
  121. } else {
  122. print "failed to create image at: ".$im_path;
  123. }
  124. }else{
  125. print "image alreaddy exists";
  126. }
  127. }
  128. ?>