1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace app\index\controller;
- use app\common\controller\Frontend;
- use think\Db;
- class Index extends Frontend
- {
- protected $noNeedLogin = '*';
- protected $noNeedRight = '*';
- protected $layout = '';
- public function showredis(){
- $list = Db::name('user')->order('id desc')->column('id');
- foreach($list as $key => $id){
- dump($id.':'.redis_matching_get($id));
- }
- exit;
- }
- public function clearredis(){
- $list = Db::name('user')->order('id desc')->column('id');
- foreach($list as $key => $id){
- $a = redis_matching_set($id,0);
- }
- exit;
- }
- public function test1(){
- // 文本加一个回车
- $buffer1 = 'abcdefghijklmn';
- // 在php中双引号中的\n代表一个换行符,例如"\n"
- $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"}'."";
- $buffer2 = 'abcdefghijklmn'."\n";
- // 与服务端建立socket连接
- $client = stream_socket_client('tcp://1.14.197.70:2349');
- // 以text协议发送buffer1数据
- //fwrite($client, $buffer1);
- // 以text协议发送buffer2数据
- fwrite($client, $buffer2);
- }
- public function index()
- {
- return $this->view->fetch();
- }
- /**
- * 判断是安卓还是ios
- */
- public function appdownload() {
- if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')){
- header("Location: https://apps.apple.com/cn/app/%E4%BC%B4%E5%A3%B0%E8%AF%AD%E9%9F%B3/id1556551099");
- }else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android')){
- //$host = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"];
- //header("Location: ".$host."/index/index/download");
- $this->view->assign('downurl', config("site.apkurl"));
- return $this->view->fetch();
- }else{
- $this->view->assign('downurl', config("site.apkurl"));
- return $this->view->fetch();
- }
- }
- public function basedata(){
- $key = input('key','');
- if(!$key){
- exit;
- }
- $content = Db::name('basedata')->where('key',$key)->find();
- $this->assign('content',$content['content']);
- return $this->fetch();
- }
- }
|