Test.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace app\admin\controller;
  3. use crmeb\services\async\LuckyCalc;
  4. use crmeb\services\async\ClearanceCalc;
  5. use crmeb\utils\Redis;
  6. use think\facade\Log;
  7. use app\api\controller\board\UserBoardController;
  8. use app\models\redis\SystemCarousel;
  9. use crmeb\services\async\task\WechatNotify;
  10. use think\facade\Config;
  11. use RobThree\Auth\TwoFactorAuth;
  12. use RobThree\Auth\TwoFactorAuthException;
  13. class Test
  14. {
  15. public function index()
  16. {
  17. $redis = Redis::instance();
  18. var_dump($redis->get(['CRMEB','TESD']));
  19. }
  20. protected function test_board() {
  21. Log::warning("board updated.");
  22. $ctl = new UserBoardController();
  23. $ctl->cache_board();
  24. }
  25. protected function test_calc() {
  26. $activities = [new ClearanceCalc(), new LuckyCalc()];
  27. foreach($activities as $activity) {
  28. $activity->calc();
  29. }
  30. }
  31. protected function test_carousel() {
  32. SystemCarousel::add('good test', '/pages/leader_board/index');
  33. print_r(SystemCarousel::getFirst(20));
  34. SystemCarousel::removeTrash();
  35. }
  36. protected function test_wechat_robot() {
  37. $key = Config::get('app.qy_weixin_robot_aristotle');
  38. // $svc = \crmeb\services\QyWeixinService::instance();
  39. // $svc->key($key)->markdown("### user commented\n>hhhh\n1. upm youth\n2. shiny tommorowwww")->post();
  40. WechatNotify::push(WechatNotify::TYPE_COMMENT, $key, 'gdf');
  41. }
  42. protected function test_2fa()
  43. {
  44. $tfa = new TwoFactorAuth('twong');
  45. $secret = $tfa->createSecret();
  46. echo 'secret:' . $secret;
  47. $img = $tfa->getQRCodeImageAsDataUri('twongqr', $secret);
  48. echo 'img:' . $img;
  49. echo '<img src="'.$img .'" />';
  50. echo 'chunk:' . chunk_split($secret, 4, ' ');
  51. $code = $tfa->getCode($secret);
  52. echo 'code:' . $code;
  53. echo 'result:' . $tfa->verifyCode($secret, $code);
  54. }
  55. public function test()
  56. {
  57. $this->test_2fa();
  58. }
  59. }