PageRenderTime 44ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/ipplan/user/ping.php

#
PHP | 91 lines | 43 code | 19 blank | 29 comment | 6 complexity | a040ab466baa3a673b80626e337df3de MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. // IPplan v4.92a
  3. // Aug 24, 2001
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation; either version 2 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. //
  19. // system call has issue with gzip compression in some verions of php
  20. define("NOCOMPRESS", "TRUE");
  21. require_once("../ipplanlib.php");
  22. require_once("/usr/share/php/adodb/adodb.inc.php");
  23. require_once("../config.php");
  24. require_once("../layout/class.layout");
  25. require_once("../auth.php");
  26. $auth = new SQLAuthenticator(REALM, REALMERROR);
  27. // And now perform the authentication
  28. $auth->authenticate();
  29. // set language
  30. isset($_COOKIE["ipplanLanguage"]) && myLanguage($_COOKIE['ipplanLanguage']);
  31. //setdefault("window",array("bgcolor"=>"white"));
  32. $title=my_("Ping results");
  33. newhtml($p);
  34. $w=myheading($p, $title, true);
  35. // explicitly cast variables as security measure against SQL injection
  36. list($lookup) = myRegister("S:lookup");
  37. if (!$_GET) {
  38. myError($w,$p, my_("You cannot reload or bookmark this page!"));
  39. }
  40. if (testIP($lookup)) {
  41. myError($w,$p, my_("Invalid IP address"));
  42. }
  43. function callback($buffer) {
  44. return ($buffer);
  45. }
  46. // need to print at this stage as display data is cached via layout template
  47. // buffer the output and do some tricks to place system call output in correct
  48. // place
  49. ob_start("callback");
  50. printhtml($p);
  51. $buf=ob_get_contents();
  52. ob_end_clean();
  53. // now print first half of HTML to browser - split at start of "normalbox"
  54. list($beg, $end) = spliti('CLASS="normalbox">', $buf);
  55. echo $beg;
  56. echo 'CLASS="normalbox">'; // add "normalbox" again as this was removed by split
  57. // system calls do not work with safe mode
  58. $lookup=escapeshellarg($lookup);
  59. echo "<pre>";
  60. // different code for Windows
  61. if (strpos(strtoupper(PHP_OS),'WIN') !== false) {
  62. $err=system("ping $lookup", $err);
  63. } else {
  64. $err=system("ping -c5 $lookup 2>&1", $err);
  65. }
  66. echo "</pre>";
  67. if($err==FALSE) {
  68. echo "Could not execute command - probably due to php safe mode";
  69. }
  70. // display last part of HTML
  71. echo $end;
  72. ?>