PwdShell.php 1002 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. App::uses('ComponentCollection', 'Controller');
  3. class PwdShell extends AppShell {
  4. public $tasks = array();
  5. //public $uses = array('User');
  6. public $Auth = null;
  7. public function hash() {
  8. $components = array('Tools.AuthExt', 'Auth');
  9. $class = null;
  10. foreach ($components as $component) {
  11. if (App::import('Component', $component)) {
  12. $component .='Component';
  13. list($plugin, $class) = pluginSplit($component);
  14. break;
  15. }
  16. }
  17. if (!$class || !method_exists($class, 'password')) {
  18. $this->out(__('No Auth Component found'));
  19. die();
  20. }
  21. $this->out('Using: '.$class);
  22. while (empty($pwToHash) || mb_strlen($pwToHash) < 2) {
  23. $pwToHash = $this->in(__('Password to Hash (2 characters at least)'));
  24. }
  25. $pw = $class::password($pwToHash);
  26. $this->hr();
  27. echo $pw;
  28. }
  29. public function help() {
  30. $this->out('-- Hash Passwort with Auth(Ext) Component --');
  31. $this->out('-- cake Tools.Pwd hash');
  32. $this->out('---- using the salt of the core.php (!)');
  33. }
  34. }