test_exec.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. if (!defined('NOREQUIREUSER')) {
  3. define('NOREQUIREUSER', '1');
  4. }
  5. if (!defined('NOREQUIREDB')) {
  6. define('NOREQUIREDB', '1');
  7. }
  8. if (!defined('NOREQUIRESOC')) {
  9. define('NOREQUIRESOC', '1');
  10. }
  11. if (!defined('NOREQUIRETRAN')) {
  12. define('NOREQUIRETRAN', '1');
  13. }
  14. if (!defined('NOSTYLECHECK')) {
  15. define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
  16. }
  17. if (!defined('NOCSRFCHECK')) {
  18. define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test
  19. }
  20. if (!defined('NOTOKENRENEWAL')) {
  21. define('NOTOKENRENEWAL', '1'); // Do not check anti POST attack test
  22. }
  23. if (!defined('NOREQUIREMENU')) {
  24. define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
  25. }
  26. if (!defined('NOREQUIREHTML')) {
  27. define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
  28. }
  29. if (!defined('NOREQUIREAJAX')) {
  30. define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
  31. }
  32. if (!defined("NOLOGIN")) {
  33. define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
  34. }
  35. // If you don't need session management (can't be logged if no session used). You must also set
  36. // NOCSRFCHECK, NOTOKENRENEWAL, NOLOGIN
  37. // Disable module with GETPOST('disablemodules') won't work. Variable 'dol_...' will not be set.
  38. // $_SESSION are then simple vars if sessions are not active.
  39. // TODO We can close session with session_write_close() as soon as we just need read access everywhere in code.
  40. if (!defined("NOSESSION")) {
  41. define("NOSESSION", '1');
  42. }
  43. require '../../main.inc.php';
  44. // Security
  45. if ($dolibarr_main_prod) {
  46. accessforbidden('Access forbidden when $dolibarr_main_prod is set to 1');
  47. }
  48. /*
  49. * View
  50. */
  51. header("Content-type: text/html; charset=UTF8");
  52. // Security options
  53. header("X-Content-Type-Options: nosniff"); // With the nosniff option, if the server says the content is text/html, the browser will render it as text/html (note that most browsers now force this option to on)
  54. header("X-Frame-Options: SAMEORIGIN"); // Frames allowed only if on same domain (stop some XSS attacks)
  55. print "*** TEST READ OF /tmp/test.txt FILE<br>\n";
  56. $out='';
  57. $ret=0;
  58. $file = '/tmp/test.txt';
  59. $f=fopen($file, 'r');
  60. if ($f) {
  61. $s=fread($f, 4096);
  62. print $s;
  63. fclose($f);
  64. } else {
  65. print "Failed to open file ".$file."<br>\n";
  66. }
  67. print '<br><br>'."\n";
  68. print "*** TEST READ OF /test.txt FILE AND LS /dev/std*<br>\n";
  69. exec('cat /test.txt; ls /dev/std*; sleep 1;', $out, $ret);
  70. print "ret=".$ret."<br>\n";
  71. print_r($out);
  72. print '<br>';
  73. print '<br><br>'."\n";
  74. print "*** TRY TO RUN CLAMDSCAN<br>\n";
  75. $ret = 0;
  76. $out = null;
  77. exec('/usr/bin/clamdscan --fdpass filethatdoesnotexists.php', $out, $ret);
  78. print "ret=".$ret."<br>\n";
  79. print_r($out);