You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
842 B

  1. <?php
  2. namespace console\controllers;
  3. use Yii;
  4. use yii\console\Controller;
  5. use yii\helpers\Console;
  6. /**
  7. * Description of RbacsetController
  8. *
  9. * @author blobt
  10. */
  11. class TestController extends Controller {
  12. public function actionIndex() {
  13. //Yii::$aa->security->generateRandomString(8);
  14. $security = Yii::createObject("yii\base\Security");
  15. $n = 0;
  16. for ($i = 1; $i < 1000; $i++) {
  17. //$key = $security->generateRandomString(8);
  18. $key = rand(10000000, 99999999);
  19. //$key = strtolower($key);
  20. //$key = str_replace(['_', '-'], 'a', $key);
  21. $ret[$key] += 1;
  22. }
  23. $this->stdout("duplicate data:\n", Console::FG_RED);
  24. foreach ($ret as $k => $v) {
  25. if ($v > 1) {
  26. echo "$k $v\n";
  27. }
  28. }
  29. }
  30. }