o:1;mode:1;status:1;ch:16; // 舊的格式: [Input16-OFF] =>o:1;mode:1;status:0;ch:16; // 舊的格式: [CH16-ON] =>o:1;mode:2;status:0;ch:16; // 舊的格式: [CH16-LOST] =>o:1;mode:2;status:1;ch:16; // 單晶片的 [Input16-ON ] =>o:1;mode:1;status:1;ch:16;relay:1; // 單晶片的 [Input16-OFF] =>o:1;mode:1;status:0;ch:16;relay:1; // 單晶片的 [CH16-ON ] =>o:1;mode:2;status:0;ch:16;relay:1; // 單晶片的 [CH16-OFF] =>o:1;mode:2;status:1;ch:16;relay:1; // var dvrstr="&ip="+port+"&port="+ip+"&dvrIp="+dvrIp+"&dvrCh="+dvrCh; $_inf['data']="o:1;mode:1;status:1;ch:".$dvrCh.";@$dvrIp"; sendTcp($_inf); break; case "v_off"://從 DVR 發信號到 模擬:派出所 $_inf['data']="o:1;mode:0;status:1;ch:".$dvrCh.";@$dvrIp"; sendTcp($_inf); break; case "i_on"://從 DVR 發信號到 模擬:派出所 $_inf['data']="o:1;mode:2;status:0;ch:".$dvrCh.";@$dvrIp"; sendTcp($_inf); break; case "i_off"://從 DVR 發信號到 模擬:派出所 $_inf['data']="o:1;mode:2;status:1;ch:".$dvrCh.";@$dvrIp"; sendTcp($_inf); break; default: $html.="

event test

"; $html.=""; $html.=""; $html.=""; $html.=""; $html.=" "; if( file_exists( $_SERVER['DOCUMENT_ROOT']."/config.php")){ // $html.=io_test(); } echo $html; break; } //---------------------------------------------------------------------------------------------------------------- function io_test()//for server side { require_once($_SERVER['DOCUMENT_ROOT']."/config.php"); require_once($_SERVER['DOCUMENT_ROOT']."/includes/db/mysql.php"); $db = new sql_db($dbhost, $dbuname, $dbpass, $dbname, false); if(!$db->db_connect_id) { } $html.="
"; $html.="Event Server IP: "; $html.="Port: "; $html.="
"; $html.="DVR IP: "; $html.="DVR CH: "; // $html.="status: "; $html.="
"; $html.=""; $html.=""; $html.=""; $html.=""; return $html; } //---------------------------------------------------------------------------------------------------------------- function sendTcp($_inf)//for server side { $fp = fsockopen($_inf[ip], $_inf[port], $errno, $errstr, 1); if (!$fp) { $data= "lose"; }else{ $out .= $_inf['data']; fwrite($fp, $out); if($_inf[feeback]){ $data=''; while (!feof($fp)) { $data.=fgets($fp, 1024); } } fclose($fp); } return $data; } //---------------------------------------------------------------------------------------------------------------- if($_REQUEST["ip"] && $_REQUEST["port"]){ $ipPort="+'&ip=".$_REQUEST["ip"]."&port=".$_REQUEST["port"]."'"; } //---------------------------------------------------------------------------------------------------------------- ?>