douzhanglun4482 2017-11-28 18:32
浏览 42

24小时后,php socket服务器关闭端口

i have a php socket server but i'm facing problems.

I have a tracker socket system, where the tracker connects to my server and send data. The server get this data and store into a database.

I'm using xampp for windows and the server is using port 8080.

My problem is that after 24h of job the port 8080 just block all connections, even the connections that are already connected to server.

I have tried all but nothing is helping me, because after 24 hours server stops port 8080.

It's important to say that xampp didn't show any error when port stops and the php page still running.

Please, can someone help me fix this problem?

My code:

        $servername = "xxx.xxx.xxx.xxx";
        $username = "username";
        $password = "pass";
        $dbname = "dbname";

        $ip_address = "my_machine_ip";
        $port = "8080";

        set_time_limit(0);

        error_reporting(E_ALL);
        ini_set('display_errors',1);

        // Create connection
        $conn = new mysqli($servername, $username, $password, $dbname);

        // Check connection
        if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
        }

        // open a server on port 8080
        $server = stream_socket_server("tcp://$ip_address:$port", $errno, $errorMessage);

        if ($server === false) {
        die("stream_socket_server error: $errorMessage");
        }

        $client_sockets = array();
        $ativos = array();

        while (true) {
        // prepare readable sockets
        $read_sockets = $client_sockets;
        $read_sockets[] = $server;

        // start reading and use a large timeout
        if(!stream_select($read_sockets, $write, $except, 30000)) {
            die('stream_select error.');
        }

        // new client
        if(in_array($server, $read_sockets)) {
            $new_client = stream_socket_accept($server);

                if($new_client != ""){
                array_push($ativos, $new_client);               
                }
                echo count($ativos);                                                


            if ($new_client) {
                //print remote client information, ip and port number
                echo 'new connection: ' . stream_socket_get_name($new_client, true) . "<br>";

                $client_sockets[] = $new_client;
                echo "total clients: ". count($client_sockets) . "<br>";

                // $output = "hello new client.
";
                // fwrite($new_client, $output);
            }

            //delete the server socket from the read sockets
            unset($read_sockets[ array_search($server, $read_sockets) ]);
        }

        // message from existing client
        foreach ($read_sockets as $socket) {
            $data = fread($socket, 1024); //original is $data = fread($socket, 128); but is freezing port after 30 connections in the same time.

            echo "data: " . $data . "<br>";

            $tk103_data = explode( ',', $data);         
            $response = "";

            switch (count($tk103_data)) {
                case 1: // 359710049095095 -> heartbeat requires "ON" response
                    $response = "ON";
                    echo "Enviado ON para o Client $tk103_data[0]!<br>";

                    break;

                case 3: // ##,imei:359710049095095,A -> this requires a "LOAD" response
                    if ($tk103_data[0] == "##") {
                        $response = "LOAD";
                        echo "Enviado LOAD para o Client $tk103_data[1]!<br>";
                    }
                    break;

                case 7: //868683028738833,O,latitude1,longitude1,latitude2,longitude2;
                    if($tk103_data[0] == "**"){
                    $imeiCerca = $tk103_data[1];
                    $lat1 = $tk103_data[3];
                    $lng1 = $tk103_data[4];
                    $lat2 = $tk103_data[5];
                    $lng2 = $tk103_data[6];                             
                    $response2 = "**,imei:$imeiCerca,O,$lat1,$lng1,$lat2,$lng2";
                                    $limit = count($ativos);
                                    $i = $limit - 100;
                                    while ($i < $limit){                                                                                                    
                                        fwrite($ativos[$i], $response2);                            
                                        echo "Enviado o código $response2 para o cliente $ativos[$i]<br>";                                                                          
                                        $i++;
                                    }
                    }
                break;  

                case 13: //imei:868683028738833,tracker,170627204932,,F,124929.000,A,0925.3265,S,04029.8821,W,0.00,0;
                $new_imei = str_replace("imei:", "", "$tk103_data[0]");
                $new_imei = substr($new_imei, 0, 15);       
                        if ($tk103_data[1] != "" && $tk103_data[4] != "L" && $tk103_data[5] != "" && $tk103_data[6] !="" && $tk103_data[8] != "" && $tk103_data[10] != "") {

                            $str = $tk103_data[2];
                            $arr2 = str_split($str, 2);
                            $dia = $arr2[2];
                            $mes = $arr2[1];
                            $ano = $arr2[0];
                            $hora = $arr2[3];
                            $minuto = $arr2[4];             

                            $sqlChecker = "SELECT id, comando, latitude, longitude, status FROM gps_data_single WHERE imei='$new_imei' ORDER BY id DESC LIMIT 1";
                            $resultChecker = $conn->query($sqlChecker);
                            if ($resultChecker->num_rows > 0) {

                                while($rowChecker = $resultChecker->fetch_assoc()) {
                                    $id = $rowChecker["id"];
                                    $comando = $rowChecker["comando"];
                                    $lat = $rowChecker["latitude"];
                                    $long = $rowChecker["longitude"];
                                    $st = $rowChecker["status"];
                                    $estatus = explode(";", $st);

                                    if($comando==$tk103_data[1] && $lat==$tk103_data[7] && $long==$tk103_data[9] && $st==$tk103_data[12]){
                                    echo "Continua o mesmo Comando e Posição! Dados não salvos!<br>";
                                    }else{

                                    $sqla = "INSERT INTO gps_data_single (imei, comando, datetime, numerotel, gps_sinal, full_hour, sinal_gps, latitude, lat_orientacao, longitude, long_orientacao, speed, status, dia, mes, ano, hora, minuto) VALUES ('$new_imei', '$tk103_data[1]', '$str', '$tk103_data[3]', '$tk103_data[4]', '$tk103_data[5]', '$tk103_data[6]', '$tk103_data[7]', '$tk103_data[8]', '$tk103_data[9]', '$tk103_data[10]', '$tk103_data[11]', '$estatus[0];', '$dia', '$mes', '$ano', '$hora', '$minuto')";

                                        if ($conn->query($sqla) === TRUE) {
                                            echo "Inserido na Base!<br>";
                                        } else {
                                            echo "Error: " . $sqla . "<br>" . $conn->error;
                                        }   
                                    }
                                }

                            }
                        }


                        if ($tk103_data[1] == "tracker"){
                        //Bloquear pela Chave                   
                        $sqlHp = "SELECT id, minuto FROM gps_data_single WHERE imei='$new_imei' AND comando='help me' ORDER BY id DESC LIMIT 1";
                        $resultHp = $conn->query($sqlHp);

                            if ($resultHp->num_rows > 0) {
                                // output data of each row
                                while($rowHp = $resultHp->fetch_assoc()) {
                                    $id = $rowHp["id"]; 
                                    $time = $rowHp["minuto"];
                                    $mnow = date("i");
                                    $time2 = $time + 5;
                                        if($mnow >= $time2){
                                        $response = "**,imei:$new_imei,J";
                                        echo "Enviado o código $response para o cliente!<br>";

                                            $sqlUHp = "UPDATE gps_data_single SET comando='help' WHERE id='$id'";
                                            if ($conn->query($sqlUHp) === TRUE) {
                                                echo "Trocado o help me pelo helpme! <br>";
                                            }else{
                                                echo "Não funcionou!<br>";  
                                            }
                                        }
                                }
                            }                                                                           

                        }

                        //Armar pelo Browser
                        if ($tk103_data[1] == "armcar"){
                            $response2 = "**,imei:$new_imei,L";
                            $limit = count($ativos);
                                    $i = $limit - 100;
                                    while ($i < $limit){                                                        
                                fwrite($ativos[$i], $response2);                            
                                echo "Enviado o código $response2 para o cliente $ativos[$i]<br>";                              
                                $i++;
                            }

                            $sqlArm = "SELECT id FROM gps_data_single WHERE imei='$new_imei' AND comando='armcar' ORDER BY id DESC LIMIT 1";
                        $resultArm = $conn->query($sqlArm);

                            if ($resultArm->num_rows > 0) {
                                // output data of each row
                                while($rowArm = $resultArm->fetch_assoc()) {
                                    $idArm = $rowArm["id"]; 

                                            $sqlUArm = "DELETE FROM gps_data_single WHERE id='$idArm'";
                                            if ($conn->query($sqlUArm) === TRUE) {
                                                echo "Apagado o pedido de armar pelo browser! <br>";
                                            }else{
                                                echo "Não funcionou!<br>";  
                                            }
                                        }

                            }
                        }
                        //Desarmar pelo Browser
                        if ($tk103_data[1] == "disarmcar"){
                        $response2 = "**,imei:$new_imei,M";
                        $limit = count($ativos);
                                    $i = $limit - 100;
                                    while ($i < $limit){                                                                                    
                                fwrite($ativos[$i], $response2);                            
                                echo "Enviado o código $response2 para o cliente $ativos[$i]<br>";                                                      
                                $i++;
                            }

                        $sqlDArm = "SELECT id FROM gps_data_single WHERE imei='$new_imei' AND comando='disarmcar' ORDER BY id DESC LIMIT 1";
                        $resultDArm = $conn->query($sqlDArm);

                            if ($resultDArm->num_rows > 0) {
                                // output data of each row
                                while($rowDArm = $resultDArm->fetch_assoc()) {
                                    $idDArm = $rowDArm["id"];

                                    $sqlUDArm = "DELETE FROM gps_data_single WHERE id='$idDArm'";
                                            if ($conn->query($sqlUDArm) === TRUE) {
                                                echo "Apagado o pedido de armar pelo browser! <br>";
                                            }else{
                                                echo "Não funcionou!<br>";  
                                            }
                                        }
                                }   
                        }

                        //Bloquear pelo Browser
                        if ($tk103_data[1] == "cut"){
                        $response2 = "**,imei:$new_imei,J";
                        $limit = count($ativos);
                                    $i = $limit - 100;
                                    while ($i < $limit){                                                                                    
                                fwrite($ativos[$i], $response2);                            
                                echo "Enviado o código $response2 para o cliente $ativos[$i]<br>";                                                          
                                $i++;
                            }

                        $sqlCut = "SELECT id FROM gps_data_single WHERE imei='$new_imei' AND comando='cut' ORDER BY id DESC LIMIT 1";
                        $resultCut = $conn->query($sqlCut);

                            if ($resultCut->num_rows > 0) {
                                // output data of each row
                                while($rowCut = $resultCut->fetch_assoc()) {
                                    $idCut = $rowCut["id"];

                                    $sqlUCut = "UPDATE gps_data_single SET comando='help' WHERE id='$idCut'";
                                            if ($conn->query($sqlUCut) === TRUE) {
                                                echo "Atualizado o pedido de bloqeuar pelo browser! <br>";
                                            }else{
                                                echo "Não funcionou!<br>";  
                                            }
                                        }
                                }

                        }


                        //Retornar pelo Browser 
                        if ($tk103_data[1] == "resume"){
                        $response2 = "**,imei:$new_imei,K";
                        $limit = count($ativos);
                                    $i = $limit - 100;
                                    while ($i < $limit){                                                                                        
                                fwrite($ativos[$i], $response2);                            
                                echo "Enviado o código $response2 para o cliente $ativos[$i]<br>";                                                                              
                                $i++;
                            }

                        $sqlResume = "SELECT id FROM gps_data_single WHERE imei='$new_imei' AND comando='resume' ORDER BY id DESC LIMIT 1";
                        $resultResume = $conn->query($sqlResume);

                            if ($resultResume->num_rows > 0) {
                                // output data of each row
                                while($rowResume = $resultResume->fetch_assoc()) {
                                    $idResume = $rowResume["id"]; 

                                    $sqlUResume = "DELETE FROM gps_data_single WHERE id='$idResume'";
                                            if ($conn->query($sqlUResume) === TRUE) {
                                                echo "Apagado o pedido de religar pelo browser! <br>";
                                            }else{
                                                echo "Não funcionou!<br>";  
                                            }
                                        }
                                }   

                        }

                        //Velocidade pelo Browser
                        if ($tk103_data[1] == "myspeed"){
                        $sqlVel = "SELECT id, speed FROM gps_data_single WHERE imei='$new_imei' AND comando='myspeed' ORDER BY id DESC LIMIT 1";
                        $resultVel = $conn->query($sqlVel);

                            if ($resultVel->num_rows > 0) {
                                // output data of each row
                                while($rowVel = $resultVel->fetch_assoc()) {
                                    $idVel = $rowVel["id"];
                                    $maxVel = $rowVel["speed"];

                                    if($maxVel<100){
                                    $maxVel = "0$maxVel";   
                                    }
                                    $response2 = "**,imei:$new_imei,H,$maxVel";
                                    echo "Enviado o código $response2 para o cliente!<br>";
                                    $limit = count($ativos);
                                    $i = $limit - 100;
                                    while ($i < $limit){                                                                                                    
                                        fwrite($ativos[$i], $response2);                            
                                        echo "Enviado o código $response2 para o cliente $ativos[$i]<br>";                                                                          
                                        $i++;
                                    }

                                            $sqlUVel = "DELETE FROM gps_data_single WHERE id='$idVel'";
                                            if ($conn->query($sqlUVel) === TRUE) {
                                                echo "Atualizado velocidade pelo browser! <br>";
                                            }else{
                                                echo "Não funcionou!<br>";  
                                            }
                                        }
                                }   


                        }


                        //Remover Cerca
                        if ($tk103_data[1] == "removefence"){
                        $sqlRemFen = "SELECT id FROM gps_data_single WHERE imei='$new_imei' AND comando='removefence' ORDER BY id DESC LIMIT 1";
                        $resultRemFen = $conn->query($sqlRemFen);

                            if ($resultRemFen->num_rows > 0) {
                                // output data of each row
                                while($rowRemFen = $resultRemFen->fetch_assoc()) {
                                    $idRemFen = $rowRemFen["id"];                               
                                    }
                                    $response2 = "**,imei:$new_imei,P";                             
                                    $limit = count($ativos);
                                    $i = $limit - 100;
                                    while ($i < $limit){                                                                                                    
                                        fwrite($ativos[$i], $response2);                            
                                        echo "Enviado o código $response2 para o cliente $ativos[$i]<br>";                                                                          
                                        $i++;
                                    }

                                            $sqlURemFen = "DELETE FROM gps_data_single WHERE id='$idRemFen'";
                                            if ($conn->query($sqlURemFen) === TRUE) {
                                                echo "Removido a cerca pelo browser! <br>";
                                            }else{
                                                echo "Não funcionou!<br>";  
                                            }
                                        }                                                                           
                        }


                        //Alarme de Porta
                        if ($tk103_data[1] == "door alarm"){                    
                        $response = "**,imei:$new_imei,E";
                        echo "Enviado o código $response para o cliente!<br>";

                            $sqlPush = "SELECT usr, placa_veiculo FROM login WHERE imei='$new_imei' ORDER BY id ASC LIMIT 1";
                            $resultPush = $conn->query($sqlPush);

                            if ($resultPush->num_rows > 0) {
                                // output data of each row
                                while($rowPush = $resultPush->fetch_assoc()) {
                                    $push1 = $rowPush["usr"];
                                    $placa1 = $rowPush["placa_veiculo"];
                                    // Push The notification with parameters
                                if($push1!=""){ 
                                require_once('PushBots.class.php');
                                $pb = new PushBots();
                                // Application ID
                                $appID = 'myappid';
                                // Application Secret
                                $appSecret = 'myappsecret';
                                $pb->App($appID, $appSecret);
                                $pb->Alias($push1);

                                // Notification Settings
                                $pb->Alert("Porta do veículo $placa1 aberta sem autorização!");
                                $pb->Platform(array("0","1"));
                                $pb->Badge("+1");
                                $pb->Push();
                                }
                                    $sqlNot = "INSERT INTO notificacao (notif, para, msgtipo)
                                    VALUES ('Porta do veículo $placa1 aberta sem autorização em $dia/$mes/$ano às $hora:$minuto!', '$push1', '3')";

                                    if ($conn->query($sqlNot) === TRUE) {
                                        echo "Notificação encaminhada com sucesso!<br>";
                                    }
                                }
                            }


                        }

                        //Alarme Veículo Ligado
                        if ($tk103_data[1] == "acc alarm" || $tk103_data[1] == "ac alarm" && $tk103_data[4] != "L"){                                                    
                            $sqlPush1 = "SELECT usr, placa_veiculo FROM login WHERE imei='$new_imei' ORDER BY id ASC LIMIT 1";
                            $resultPush1 = $conn->query($sqlPush1);

                            if ($resultPush1->num_rows > 0) {
                                // output data of each row
                                while($rowPush1 = $resultPush1->fetch_assoc()) {
                                    $push2 = $rowPush1["usr"];
                                    $placa2 = $rowPush1["placa_veiculo"];
                                    // Push The notification with parameters
                                if($push2!=""){ 
                                require_once('PushBots.class.php');
                                $pb = new PushBots();
                                // Application ID
                                $appID = 'myappid';
                                // Application Secret
                                $appSecret = 'myappsecret';
                                $pb->App($appID, $appSecret);
                                $pb->Alias($push2);

                                // Notification Settings
                                $pb->Alert("Veículo $placa2 ligado sem autorização!");
                                $pb->Platform(array("0","1"));
                                $pb->Badge("+1");
                                $pb->Push();
                                }
                                    $sqlNot2 = "INSERT INTO notificacao (notif, para, msgtipo)
                                    VALUES ('Veículo $placa2 ligado sem autorização em $dia/$mes/$ano às $hora:$minuto!', '$push2', '3')";

                                    if ($conn->query($sqlNot2) === TRUE) {
                                        echo "Notificação encaminhada com sucesso!<br>";
                                    }
                                }
                            }

                        }

                        //Alerta Velocidade
                        if ($tk103_data[1] == "speed"){                                                 
                            $sqlPush5 = "SELECT usr, placa_veiculo FROM login WHERE imei='$new_imei' ORDER BY id ASC LIMIT 1";
                            $resultPush5 = $conn->query($sqlPush5);

                            if ($resultPush5->num_rows > 0) {
                                // output data of each row
                                while($rowPush5 = $resultPush5->fetch_assoc()) {
                                    $push5 = $rowPush5["usr"];
                                    $placa5 = $rowPush5["placa_veiculo"];
                                    // Push The notification with parameters
                                if($push5!=""){ 
                                require_once('PushBots.class.php');
                                $pb = new PushBots();
                                // Application ID
                                $appID = 'myappid';
                                // Application Secret
                                $appSecret = 'myappsecret';
                                $pb->App($appID, $appSecret);
                                $pb->Alias($push5);

                                // Notification Settings
                                $pb->Alert("Veículo $placa5 atingiu a velocidade máxima!");
                                $pb->Platform(array("0","1"));
                                $pb->Badge("+1");
                                $pb->Push();
                                }
                                    $sqlNot5 = "INSERT INTO notificacao (notif, para, msgtipo)
                                    VALUES ('Veículo $placa5 atingiu a velocidade máxima em $dia/$mes/$ano às $hora:$minuto!', '$push5', '3')";

                                    if ($conn->query($sqlNot5) === TRUE) {
                                        echo "Notificação encaminhada com sucesso!<br>";
                                    }
                                }
                            }

                        }

                        //Alerta Fora da Cerca
                        if ($tk103_data[1] == "stockade"){                                                  
                            $sqlPushSt = "SELECT usr, placa_veiculo FROM login WHERE imei='$new_imei' ORDER BY id ASC LIMIT 1";
                            $resultPushSt = $conn->query($sqlPushSt);

                            if ($resultPushSt->num_rows > 0) {
                                // output data of each row
                                while($rowPushSt = $resultPushSt->fetch_assoc()) {
                                    $pushSt = $rowPushSt["usr"];
                                    $placaSt = $rowPushSt["placa_veiculo"];
                                    // Push The notification with parameters
                                if($pushSt!=""){    
                                require_once('PushBots.class.php');
                                $pb = new PushBots();
                                // Application ID
                                $appID = 'myappid';
                                // Application Secret
                                $appSecret = 'myappsecret';
                                $pb->App($appID, $appSecret);
                                $pb->Alias($pushSt);

                                // Notification Settings
                                $pb->Alert("Veículo $placaSt saiu da cerca definida!");
                                $pb->Platform(array("0","1"));
                                $pb->Badge("+1");
                                $pb->Push();
                                }
                                    $sqlNotSt = "INSERT INTO notificacao (notif, para, msgtipo)
                                    VALUES ('Veículo $placaSt saiu da cerca definida no $dia/$mes/$ano às $hora:$minuto!', '$pushSt', '3')";

                                    if ($conn->query($sqlNotSt) === TRUE) {
                                        echo "Notificação encaminhada com sucesso!<br>";
                                    }
                                }
                            }

                        }

                        //Alarme de Vibração
                        if ($tk103_data[1] == "sensor alarm"){                                      

                            $sqlPushSen = "SELECT usr, placa_veiculo FROM login WHERE imei='$new_imei' ORDER BY id ASC LIMIT 1";
                            $resultPushSen = $conn->query($sqlPushSen);

                            if ($resultPushSen->num_rows > 0) {
                                // output data of each row
                                while($rowPushSen = $resultPushSen->fetch_assoc()) {
                                    $push1Sen = $rowPushSen["usr"];
                                    $placa1Sen = $rowPushSen["placa_veiculo"];
                                    // Push The notification with parameters
                                if($push1Sen!=""){  
                                require_once('PushBots.class.php');
                                $pb = new PushBots();
                                // Application ID
                                $appID = 'myappid';
                                // Application Secret
                                $appSecret = 'myappsecret';
                                $pb->App($appID, $appSecret);
                                $pb->Alias($push1Sen);

                                // Notification Settings
                                $pb->Alert("Veículo $placa1Sen detectou uma forte vibração!");
                                $pb->Platform(array("0","1"));
                                $pb->Badge("+1");
                                $pb->Push();
                                }

                                    $sqlNotPush = "INSERT INTO notificacao (notif, para, msgtipo)
                                    VALUES ('Veículo $placa1Sen detectou uma forte vibração em $dia/$mes/$ano às $hora:$minuto!', '$push1Sen', '3')";

                                    if ($conn->query($sqlNotPush) === TRUE) {
                                        echo "Notificação encaminhada com sucesso!<br>";
                                    }
                                }
                            }


                        }


                        if ($tk103_data[1] == "acc on"){
                        $response = "**,imei:$new_imei,C,03m";  
                        echo "Enviado o código $response para o cliente!<br>";  
                        }

                        if ($tk103_data[1] == "acc off"){
                        $response = "**,imei:$new_imei,C,60m";  
                        echo "Enviado o código $response para o cliente!<br>";  
                        }


                        if($tk103_data[1] == "help me"){
                        $response = "**,imei:$new_imei,E";
                        echo "Enviado o código $response para o cliente!<br>";

                            $sqlPush3 = "SELECT usr FROM login WHERE imei='$new_imei' ORDER BY id ASC LIMIT 1";
                            $resultPush3 = $conn->query($sqlPush3);

                            if ($resultPush3->num_rows > 0) {
                                // output data of each row
                                while($rowPush3 = $resultPush3->fetch_assoc()) {
                                    $push3 = $rowPush3["usr"];
                                    $sqlNot3 = "INSERT INTO notificacao (notif, para, msgtipo)
                                    VALUES ('Pedido de Bloqueio registrado no $dia/$mes/$ano às $hora:$minuto!', '$push3', '3')";

                                    if ($conn->query($sqlNot3) === TRUE) {
                                        echo "Notificação encaminhada com sucesso!<br>";
                                    }
                                }
                            }
                        }   


                        if ($tk103_data[1] == "jt"){
                        $response = "**,imei:$new_imei,E";  
                        echo "Enviado o código $response para o cliente!<br>";
                            $sqlD = "DELETE FROM gps_data_single WHERE imei='$new_imei' AND comando='jt'";
                            if ($conn->query($sqlD) === TRUE) {
                                echo "Deletado com sucesso o JT<br>";
                            }
                        }

                        if ($tk103_data[1] == "et"){
                            $sqlDe = "DELETE FROM gps_data_single WHERE imei='$new_imei' AND comando='et'";
                            if ($conn->query($sqlDe) === TRUE) {
                                echo "Deletado com sucesso o ET<br>";
                            }
                        }

                        if ($tk103_data[1] == "kt"){
                            $sqlDel = "DELETE FROM gps_data_single WHERE imei='$new_imei' AND comando='kt'";
                            if ($conn->query($sqlDel) === TRUE) {
                                echo "Deletado com sucesso o KT<br>";
                            }
                        }

                        if ($tk103_data[1] == "lt"){
                            $sqlDele = "DELETE FROM gps_data_single WHERE imei='$new_imei' AND comando='lt'";
                            if ($conn->query($sqlDele) === TRUE) {
                                echo "Deletado com sucesso o LT<br>";
                            }
                        }

                        if ($tk103_data[1] == "mt"){
                            $sqlDelet = "DELETE FROM gps_data_single WHERE imei='$new_imei' AND comando='mt'";
                            if ($conn->query($sqlDelet) === TRUE) {
                                echo "Deletado com sucesso o MT<br>";
                            }
                        }

                        if ($tk103_data[1] == "ht"){
                        $sql = "DELETE FROM gps_data_single WHERE imei='$new_imei' AND comando='ht'";
                            if ($conn->query($sql) === TRUE) {
                                echo "Deletado com sucesso o HT<br>";
                            }   
                        }

                        if ($tk103_data[1] == "ot"){
                        $sql = "DELETE FROM gps_data_single WHERE imei='$new_imei' AND comando='ot'";
                            if ($conn->query($sql) === TRUE) {
                                echo "Deletado com sucesso o OT<br>";
                            }   
                        }

                        if ($tk103_data[1] == "pt"){
                        $sql = "DELETE FROM gps_data_single WHERE imei='$new_imei' AND comando='pt'";
                            if ($conn->query($sql) === TRUE) {
                                echo "Deletado com sucesso o PT<br>";
                            }   
                        }


                    break;
            }


                if (!$data) {
                    unset($client_sockets[ array_search($socket, $client_sockets) ]);
                    @fclose($socket);
                    echo "client $socket disconnected. total clients: ". count($client_sockets) . "
";
                    continue;
                }

                //send the message back to client
        if (sizeof($response) > 0) {
        fwrite($socket, $response);
        }
        }
        } // end while loop
        $conn->close();
        ?>`
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度