Codebench.php 852 B

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