1
0

escreva.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. // Para depuracao: escrever no arquivo '/var/www/html/saw/mod/iassign/'
  3. // Write each personal student file in './<turma>/<N>_<name>.txt'
  4. // Param: $filetype1 in "student", "log", "sendemail"
  5. // Return 1 in case of success; -1 in case do not overwrite
  6. function writeContent ($filetype1, $pathbase, $outputFile, $msgToRegister) {
  7. global $GROUP, $WRITEMSG, $OVERWRITE;
  8. $pathbase = "/var/www/html/saw/mod/iassign/ilm_debug/"; // "/mod/iassign/ilm_debug/";
  9. $outputFile = $pathbase . $outputFile;
  10. if (!is_writable($pathbase)) { // TRUE se arquivo existe e pode ser escrito
  11. // $file_debug .= "Error: '" . $completfilepath . "' could not be registered! Perhaps the directory or the file has permission problem?<br/>\n";
  12. //D echo "$outputFile, $filetype1<br/>";
  13. print "Erro! Problema de acesso ao servidor! Por favor, avise ao administrador (<tt>$pathbase</tt> nao acessivel para escrita).<br/>"; // . $file_debug . "
  14. exit(0);
  15. }
  16. // $result = writeContent("file", $pathbase, $filename, $msgToRegister);
  17. // print "escreva.php: result=$result<br/>";
  18. // write personal email file
  19. // To write: verify if the file does not exists or have permission to overwrite
  20. if (is_file($outputFile)) { // already exist this file
  21. // $outputFile .= $outputFile . '_' . date('Y_m_d_h_m');
  22. } // if (is_file($outputFile))
  23. if (1==1) { // write/overwrite the file
  24. $fpointer = fopen($outputFile, "w"); // write - if executed, it clear the previou content at this file
  25. if (!$fpointer) {
  26. $file_debug .= "Erro: nao foi possivel abrir o roteiro ($outputFile)!<br/>\n";
  27. // it was not possible to open the file '$completfilepath" . $file_name . "'!<br/>\n";
  28. print "<br/>" . $file_debug . "<br/>\n";
  29. //D echo "writeContent: $filetype1, outputFile=$outputFile<br/>\n";
  30. return 0;
  31. }
  32. fwrite($fpointer, $msgToRegister . "\n");
  33. // echo " - outputFile=$outputFile : WRITEMSG=$WRITEMSG, OVERWRITE=$OVERWRITE, gerado com sucesso!<br/>\n";
  34. fclose($fpointer);
  35. }
  36. else {
  37. // print "Nao gera os arquivos personalizados para email aos alunos ('$outputFile')<br/>\n"; // admin/<turma>/<N>_<name>.txt
  38. }
  39. return 1;
  40. } // function writeContent($outputFile, $msgToRegister)
  41. ?>