Index.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace app\index\controller;
  3. use app\common\controller\Frontend;
  4. use think\Db;
  5. class Index extends Frontend
  6. {
  7. protected $noNeedLogin = '*';
  8. protected $noNeedRight = '*';
  9. protected $layout = '';
  10. public function showredis(){
  11. $list = Db::name('user')->order('id desc')->column('id');
  12. foreach($list as $key => $id){
  13. dump($id.':'.redis_matching_get($id));
  14. }
  15. exit;
  16. }
  17. public function clearredis(){
  18. $list = Db::name('user')->order('id desc')->column('id');
  19. foreach($list as $key => $id){
  20. $a = redis_matching_set($id,0);
  21. }
  22. exit;
  23. }
  24. public function test1(){
  25. // 文本加一个回车
  26. $buffer1 = 'abcdefghijklmn';
  27. // 在php中双引号中的\n代表一个换行符,例如"\n"
  28. $buffer2 = '{"type":"say", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello"}'."";
  29. $buffer2 = 'abcdefghijklmn'."\n";
  30. // 与服务端建立socket连接
  31. $client = stream_socket_client('tcp://1.14.197.70:2349');
  32. // 以text协议发送buffer1数据
  33. //fwrite($client, $buffer1);
  34. // 以text协议发送buffer2数据
  35. fwrite($client, $buffer2);
  36. }
  37. public function index()
  38. {
  39. return $this->view->fetch();
  40. }
  41. /**
  42. * 判断是安卓还是ios
  43. */
  44. public function appdownload() {
  45. if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')){
  46. header("Location: https://apps.apple.com/cn/app/%E4%BC%B4%E5%A3%B0%E8%AF%AD%E9%9F%B3/id1556551099");
  47. }else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android')){
  48. //$host = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"];
  49. //header("Location: ".$host."/index/index/download");
  50. $this->view->assign('downurl', config("site.apkurl"));
  51. return $this->view->fetch();
  52. }else{
  53. $this->view->assign('downurl', config("site.apkurl"));
  54. return $this->view->fetch();
  55. }
  56. }
  57. public function basedata(){
  58. $key = input('key','');
  59. if(!$key){
  60. exit;
  61. }
  62. $content = Db::name('basedata')->where('key',$key)->find();
  63. $this->assign('content',$content['content']);
  64. return $this->fetch();
  65. }
  66. }