Codebench.php 875 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Codebench — A benchmarking module.
  4. *
  5. * @package koseven/Codebench
  6. * @category Controllers
  7. *
  8. * @copyright (c) 2007-2016 Kohana Team
  9. * @copyright (c) since 2016 Koseven Team
  10. * @license https://koseven.dev/LICENSE
  11. */
  12. class Controller_Codebench extends KO7_Controller_Template {
  13. // The codebench view
  14. public $template = 'codebench';
  15. public function action_index()
  16. {
  17. $class = $this->request->param('class');
  18. // Convert submitted class name to URI segment
  19. if (isset($_POST['class']))
  20. {
  21. throw HTTP_Exception::factory(302)->location('codebench/'.trim($_POST['class']));
  22. }
  23. // Pass the class name on to the view
  24. $this->template->class = (string) $class;
  25. // Try to load the class, then run it
  26. if (KO7::auto_load($class) === TRUE)
  27. {
  28. $codebench = new $class;
  29. $this->template->codebench = $codebench->run();
  30. }
  31. }
  32. }