コマンド(シェル)からAuthで使用するパスワードを表示する
認証機能を導入するとき,はじめの管理者のパスワードを
phpMyAdminなどから直接入力するときとかに便利
/vendors/shells/password.php
<?php App::import('Core', 'Security'); class PasswordShell extends Shell { /* function startup() { $this->controller = new Controller(); //print_r($this->controller); $this->Auth = new AuthComponent(); $this->Auth->startup($this->controller); } */ function main() { e(Security::hash(Configure::read('Security.salt').$this->args[0], $this->args[1])); e("\n"); $this->hr(); } } ?>
使い方(「orz」をmd5で暗号化した場合の文字列)
./cake password orz md5
結果
Welcome to CakePHP v1.2.3.8166 Console --------------------------------------------------------------- App : app Path: /home/hoge/public_html/project/hellow/lib/app --------------------------------------------------------------- 3c42c1b6d1fff2c1aeaf9076ad2c3892 ---------------------------------------------------------------