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.

52 lines
1.9 KiB

преди 3 години
  1. <?php
  2. namespace Home\Controller;
  3. use Think\Controller;
  4. class CommonController extends BaseController {
  5. //保存
  6. public function qrcode(){
  7. Vendor('Phpqrcode.phpqrcode');
  8. $url = I("url");
  9. $url = urldecode($url) ? urldecode($url) : $url;
  10. $size = I("size") ? I("size") : 6;
  11. $object = new \QRcode();
  12. $object->png($url, false, 3 , $size, 2);
  13. }
  14. public function checkForUpdate(){
  15. $option_data = D("Options")->where("option_name='version' ")->find();
  16. $post_data = array(
  17. "version" => $option_data['option_value'] ,
  18. );
  19. $version = $option_data['option_value'];
  20. // TODO 此功能是留着检测更新用的。未完成。代码有空再写吧
  21. //$url = "https://www.showdoc.cc/";
  22. //$result = http_post($url , $post_data);
  23. //$version_num = str_replace("v", '', $num);
  24. //$result = version_compare($version_num, "2.1.5",'<');
  25. //echo $result;
  26. }
  27. //重置管理员用户密码
  28. //使用方式:
  29. //若用官方自动脚本或者docker方式安装,则需在命令行里执行docker exec showdoc php /var/www/html/index.php home/common/repasswd
  30. //若是手动安装php环境的,则在命令行中切换到showdoc目录,执行php index.php home/common/repasswd
  31. //执行后会把管理员用户showdoc的密码重置为123456
  32. public function repasswd(){
  33. if (preg_match("/cli/i", php_sapi_name()) ) {
  34. if(D("User")->where("username = 'showdoc' ")->find()){
  35. D("User")->where("username = 'showdoc' ")->save(array("groupid"=> 1,'password'=>"a89da13684490eb9ec9e613f91d24d00" )) ;
  36. }else{
  37. D("User")->add(array('username'=>"showdoc" ,"groupid"=>1,'password'=>"a89da13684490eb9ec9e613f91d24d00" , 'reg_time'=>time()));
  38. }
  39. echo "ok \n" ;
  40. }else{
  41. echo "please run in command line";
  42. }
  43. }
  44. }