/phoronix-test-suite/pts-core/commands/network_setup.php

# · PHP · 57 lines · 30 code · 8 blank · 19 comment · 3 complexity · d18e0d3b489e15d270a9eb825c0706a2 MD5 · raw file

  1. <?php
  2. /*
  3. Phoronix Test Suite
  4. URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/
  5. Copyright (C) 2009 - 2011, Phoronix Media
  6. Copyright (C) 2009 - 2011, Michael Larabel
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 3 of the License, or
  10. (at your option) any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. class network_setup implements pts_option_interface
  19. {
  20. const doc_section = 'Other';
  21. const doc_description = 'This option allows the user to configure how the Phoronix Test Suite connects to OpenBenchmarking.org and other web-services. Connecting through an HTTP proxy can be configured through this option.';
  22. public static function run($r)
  23. {
  24. pts_client::$display->generic_heading('Network Setup');
  25. if(!pts_user_io::prompt_bool_input('Configure the Phoronix Test Suite to use a HTTP proxy', false))
  26. {
  27. return false;
  28. }
  29. $proxy_address = pts_user_io::prompt_user_input('Enter IP address / server name of proxy');
  30. $proxy_port = pts_user_io::prompt_user_input('Enter TCP port for proxy server');
  31. echo PHP_EOL . 'Testing Proxy Server (' . $proxy_address . ':' . $proxy_port . ')' . PHP_EOL;
  32. if(pts_network::http_get_contents('http://www.phoronix-test-suite.com/PTS', $proxy_address, $proxy_port) == 'PTS')
  33. {
  34. echo PHP_EOL . 'Proxy Setup Completed; Storing Network Settings.' . PHP_EOL;
  35. pts_config::user_config_generate(array(
  36. 'PhoronixTestSuite/Options/Networking/ProxyAddress' => $proxy_address,
  37. 'PhoronixTestSuite/Options/Networking/ProxyPort' => $proxy_port
  38. ));
  39. }
  40. else
  41. {
  42. echo PHP_EOL . 'Proxy Setup Failed.' . PHP_EOL;
  43. }
  44. }
  45. }
  46. ?>