request; $f_code = $request->post("f_code");//航班代码 $f_date = $request->post("f_date");//航班代码 $f_code = strtoupper($f_code); if( $f_date == false ) { $f_date = date("Ymd"); } else { $f_date = date( "Ymd", strtotime($f_date) ); } $return_array = array(); $return_array["flight_code"] = $f_code; $return_array["flight_date"] = date( "Y-m-d", strtotime($f_date) ); $request_url = "http://www.variflight.com/flight/fnum/{$f_code}.html?AE71649A58c77&fdate={$f_date}"; $result = Utils::httpRequest($request_url); $str_pos = strripos( $result, '
' ); $result2 = substr( $result, $str_pos ); $span_array = explode("", $result2); //获取预计起飞时间 $cut_time = $span_array[1]; $str_pos = strpos( $cut_time, '>' ); $cut_time = substr( $cut_time, $str_pos + 1 ); $cut_time = $this->getTimeFromString($cut_time); $return_array["flight_time"] = $cut_time; //获取实际起飞时间 $cut_time = $span_array[2]; $str_pos = strpos( $cut_time, '>' ); $cut_time = substr( $cut_time, $str_pos + 1 ); $cut_time = $this->getTimeFromString($cut_time); $return_array["flight_time_real"] = $cut_time; //获取出发地 $cut_time = $span_array[3]; $str_pos = strpos( $cut_time, '>' ); $cut_time = substr( $cut_time, $str_pos + 1 ); $return_array["flight_start_addr"] = $cut_time; //获取预计到达时间 $cut_time = $span_array[4]; $str_pos = strpos( $cut_time, '>' ); $cut_time = substr( $cut_time, $str_pos + 1 ); $cut_time = $this->getTimeFromString($cut_time); $return_array["arrive_time"] = $cut_time; //获取实际到达时间 $cut_time = $span_array[5]; $str_pos = strpos( $cut_time, '>' ); $cut_time = substr( $cut_time, $str_pos + 1 ); $cut_time = $this->getTimeFromString($cut_time); $return_array["arrive_time_real"] = $cut_time; //获取到达地 $cut_time = $span_array[6]; $str_pos = strpos( $cut_time, '>' ); $cut_time = substr( $cut_time, $str_pos + 1 ); $return_array["flight_end_addr"] = $cut_time; //到达日期 $str_pos2 = strpos( $result, '', $result); $detail_url = "http://www.variflight.com".substr( $span_array[0],36); $result = Utils::httpRequest($detail_url); $str_pos = strpos( $result, '
' ); $flight_date = substr( $result, $str_pos+ 63,10 ); $return_array["arrive_date"] = $flight_date; echo json_encode($return_array); } /** * Function Description: * Function Name: getTimeFromString * * @return string * * @author Redstop */ public function getTimeFromString( $ori_string ) { $return_time = ""; $string_length = strlen($ori_string); for( $index_temp = 0; $index_temp < $string_length; $index_temp++ ) { $strtoken = $ori_string[$index_temp]; if( is_numeric($strtoken) ) { $return_time .= $strtoken; } } if( strlen($return_time) == 4 ) { return substr( $return_time, 0, 2 ).":".substr( $return_time, 2 ); } else { return ""; } } }