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

/modules/live/shell/sha1.cmd.php

http://awarenet.googlecode.com/
PHP | 76 lines | 46 code | 17 blank | 13 comment | 6 complexity | 6c3a35ac75df848163196be30e168e5d MD5 | raw file
Possible License(s): GPL-3.0
  1. <?
  2. require_once($kapenta->installPath . 'modules/live/inc/cmdaliases.class.php');
  3. //--------------------------------------------------------------------------------------------------
  4. //| simple utility to caclulate and return a SHA1 hash
  5. //--------------------------------------------------------------------------------------------------
  6. function live_WebShell_sha1($args) {
  7. global $kapenta, $user, $shell;
  8. $html = ''; //% return value [string]
  9. $mode = 'sha1'; //% operation [string]
  10. //----------------------------------------------------------------------------------------------
  11. // check arguments and permissions
  12. //----------------------------------------------------------------------------------------------
  13. foreach ($args as $idx => $arg) {
  14. switch($arg) {
  15. case '-h': $mode = 'help'; break;
  16. case '-s': $mode = 'sha1'; break;
  17. case '--help': $mode = 'help'; break;
  18. case '--sha1': $mode = 'sha1'; break;
  19. }
  20. }
  21. //----------------------------------------------------------------------------------------------
  22. // execute
  23. //----------------------------------------------------------------------------------------------
  24. switch($mode) {
  25. case 'sha1':
  26. foreach($args as $arg) {
  27. if (('-s' != $arg) && ('--sha1' != $arg)) {
  28. $html .= "sha1(". htmlentities($arg) ."):<br/><tt>". sha1($arg) ."</tt><br/>";
  29. }
  30. }
  31. break; //..............................................................................
  32. case 'help':
  33. $html = live_WebShell_sha1_help();
  34. break;
  35. case 'noauth':
  36. $html = "Admin permissions required to perform this operation.";
  37. break; //..............................................................................
  38. }
  39. return $html;
  40. }
  41. //--------------------------------------------------------------------------------------------------
  42. //| manpage for the live.sha1 command
  43. //--------------------------------------------------------------------------------------------------
  44. //opt: short - display command summary [bool]
  45. function live_WebShell_sha1_help($short = false) {
  46. if (true == $short) { return "Calculate sha1 hashes."; }
  47. $html = "
  48. <b>usage: live.sha1 [-h|-s] [<i>value</i>]</b><br/>
  49. <br/>
  50. <b>[--help|-h]</b><br/>
  51. Displays this manpage.<br/>
  52. <br/>
  53. <b>[--sha1|-s] <i>value</i></b><br/>
  54. Calculate sha1 hash.<br/>
  55. <br/>
  56. ";
  57. return $html;
  58. }
  59. ?>