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_bak.php
<?php $wshome="/home/nongapp.eemo.co.kr/public_html/www"; require_once($wshome.'/websockets.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 $wshome; $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 $wshome; $db=mysql_pconnect("localhost","root","web!@#") or die(mysql_error()); mysql_select_db("egg") or die(mysql_error()); $tmp_message=$message; //$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"]."\n\n"; foreach($this->users as $suser) { if($suser->socket != $user->socket) { $this->send($suser,$tmp_message); } } $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); } /* $this->send($user,base64_encode($vmsg)); $logfile=$wshome."/sock_log/".date('Y-m-d_H').".txt"; $fp=fopen($logfile,"a+"); $qrystr="SND : [".$user->ip."] [".date('Y-m-d H:i:s')."] [카드체크인 / FINISH 결과] ENCOODE : ".base64_encode(iconv("euc-kr","UTF-8",$vmsg))." DECODE : ".$vmsg." \n"; fwrite($fp,$qrystr); fclose($fp); */ } protected function connected ($user) { 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()); $logfile=$wshome."/sock_log/".date('Y-m-d_H').".txt"; $fp=fopen($logfile,"a+"); $qrystr="소켓접속 : [".$user->ip."] [".date('Y-m-d H:i:s')."] \n"; fwrite($fp,$qrystr); fclose($fp); //mysql_close($db); } 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 $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()); echo date('Y-m-d H:i:s')." 소켓종료\n"; $logfile=$wshome."/sock_log/".date('Y-m-d_H').".txt"; $fp=fopen($logfile,"a+"); $qrystr="소켓종료 : [".$user->ip."] [".date('Y-m-d H:i:s')."] \n"; fwrite($fp,$qrystr); fclose($fp); //mysql_close($db); } protected function closed2 ($user) { } protected function wupdate(){ global $wshome; $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 "send : ".$vvmsg."\n\n"; //$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");