Tryag File Manager
Home
||
Turbo Force
||
B-F Config_Cpanel
Current Path :
/
home
/
nongapp.eemo.co.kr
/
public_html
/
www
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/nongapp.eemo.co.kr/public_html/www/maonwebsock_93.php
<?php $wshome="/home/nongapp.eemo.co.kr/public_html/www"; require_once($wshome.'/websockets_93.php'); include_once($wshome."/lib.php"); // 로그인단 : ["cardcheck"]|[rfid값][login상태값(0:로그아웃,1:로그인)] // 종료단 : ["finish"]|[rfid값]|[htype]|[맵이름]|[거리]|[칼로리]|[착순]|[사용마일리지]|[획득마일리지]|[이용시간]|[실제운동시간]|[온라인여부(1:온라인,0:로컬)] $testmode=1; $db=mysql_pconnect("localhost","root","web!@#") or die(mysql_error()); mysql_select_db("egg") or die(mysql_error()); class echoServer extends WebSocketServer { //protected $maxBufferSize = 1048576; //1MB... overkill for an echo server, but potentially plausible for other applications. protected $arr=array(); protected function process2 ($user, $mes) { global $WSSERIP; global $wshome; global $testmode; $db=mysql_pconnect("localhost","root","web!@#") or die(mysql_error()); mysql_select_db("egg") or die(mysql_error()); $tmp_message=$mes; $mes=base64_decode($tmp_message); } protected function irnd($tt,$no) { $rnd=rand(1,$tt); if($this->arr[$rnd]>0) { $this->irnd($tt,$no); } else { $this->arr[$rnd]=$no; } } protected function process ($user, $message) { global $WSSERIP; global $wshome; global $testmode; $db=mysql_pconnect("localhost","root","web!@#") or die(mysql_error()); mysql_select_db("egg") or die(mysql_error()); $tmp_message=utf8_decode($message); $user->mem_uptime=time(); //$message=base64_decode($tmp_message); //$message=addslashes($message); /* $logfile=$wshome."/sock_log/".date('Y-m-d_H').".txt"; $fp=fopen($logfile,"a+"); $qrystr="RCV : [".$user->ip."] [".date('Y-m-d H:i:s')."] ENCOODE : ".$tmp_message." DECODE : ".$message."\n"; fwrite($fp,$qrystr); fclose($fp); */ //echo iconv("euc-kr","UTF-8",$tmp_message); echo "수신데이터 :".$tmp_message.": ".date('Y-m-d H:i:s')."\n\n"; $json=json_decode($tmp_message,true); echo "json data : ".$json["data"]."\n"; echo "json id : ".$json["id"]."\n\n"; $user->mem_id=$json["id"]; $tot_sockcnt=0; foreach($this->users as $suser) { if($suser->socket != $user->socket) { $this->send($suser,$tmp_message); } if($suser->mem_uptime >= time()-3) { //$this->disconnect($suser->socket); if($suser->mem_id != "") { $tot_sockcnt++; } } } //$tot_sockcnt=sizeof($this->users); //총 소켓 접속수 foreach($this->users as $suser) { $obj=(object) $c; $obj->tot=strval($tot_sockcnt); $vvmsg=json_encode($obj); $this->send($suser,$vvmsg); } } protected function connected ($user) { /* $db=mysql_connect("218.38.12.119","root","web!@#") or die(mysql_error()); mysql_select_db("tophorsev2") or die(mysql_error()); $rs_c=RS("select * from conf "); if($rs_c[is_s] != '1') { exit; } */ $user->mem_uptime=time(); global $WSSERIP; global $wshome; // Do nothing: This is just an echo server, there's no need to track the user. // However, if we did care about the users, we would probably have a cookie to // parse at this step, would be looking them up in permanent storage, etc. //echo "First CON : ".$user->ip." , Sock_ID : ".$user->id."\n"; $db=mysql_pconnect("localhost","root","web!@#") or die(mysql_error()); mysql_select_db("egg") or die(mysql_error()); } protected function closed ($user) { //echo 'CLOSED : '.$user->ip." , Sock_ID : ".$user->id."\n"; // Do nothing: This is where cleanup would go, in case the user had any sort of // open files or other objects associated with them. This runs after the socket // has been closed, so there is no need to clean up the socket itself here. global $WSSERIP; global $wshome; // Do nothing: This is just an echo server, there's no need to track the user. // However, if we did care about the users, we would probably have a cookie to // parse at this step, would be looking them up in permanent storage, etc. //echo "First CON : ".$user->ip." , Sock_ID : ".$user->id."\n"; } protected function closed2 ($user) { } protected function wupdate(){ global $WSSERIP; global $wshome; global $testmode; $db=mysql_pconnect("localhost","root","web!@#") or die(mysql_error()); mysql_select_db("egg") or die(mysql_error()); $tot_sockcnt=sizeof($this->users); //총 소켓 접속수 foreach($this->users as $suser) { /* $rst=array(); $arr_rst=array(); $rst['tot']=$tot_sockcnt; $arr_rst['data']=$tot_sockcnt; $vvmsg=json_encode($arr_rst); //$vmsg2=base64_encode($vmsg); $this->send($suser,$vvmsg); */ $obj=(object) $c; $obj->tot=strval($tot_sockcnt); $vvmsg=base64_encode(json_encode($obj)); echo $suser->id." == ".date('Y-m-d H:i:s',$suser->mem_uptime)."\n\n"; if($suser->mem_uptime) { if($suser->mem_uptime < time()-5) { $this->disconnect($suser->socket); } } //$this->send($suser,$vvmsg); //$this->send($suser,$vmsg2); } echo date('Y-m-d H:i:s')."\n"; echo "현재 총 소켓수 : ".$tot_sockcnt."\n"; } } $echo = new echoServer("0.0.0.0","29000"); try { $echo->run(); } catch (Exception $e) { $echo->stdout($e->getMessage()); }