-
Notifications
You must be signed in to change notification settings - Fork 0
/
track.php
105 lines (102 loc) · 4.6 KB
/
track.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/**
* Created by PhpStorm.
* User: simon
* Date: 10/02/16
* Time: 9:39 PM
*/
?>
<!DOCTYPE html>
<html lang="zh">
<head>
<title>修女岛快递代理点:查单</title>
<?php require_once ('head-meta.php'); ?>
<link href="css/portal.css" rel="stylesheet" type="text/css">
</head>
<body data-spy="scroll" data-target=".navbar" data-offset="60">
<?php require_once ('menu.php'); ?>
<div id="track" class="jumbotron text-center">
<h2>修女岛快递代理点</h2>
<form class="form-inline">
<input type="text" class="form-control" id="track_no" name="track_no" size="50" placeholder="请输入胜隆单号~" required autofocus>
<button type="submit" class="btn btn-danger">查询</button>
</form>
</div>
<?php
require_once ('default-init.php');
if (isset($_GET["track_no"])) {
$track_result_array = array();
$track_no_canada = $_GET["track_no"];//3660019513
if (strlen($track_no_canada) < 10) {
$track_result = array('Result'=>'', 'Records'=> '', 'Track_no'=> '');
$track_result['Result'] = "ERROR";
$track_result['Records'] = "请输入有效的定单号~";
$track_result['Track_no'] = strlen($track_no_canada);
array_push($track_result_array, $track_result);
}else{
$track_array_no = explode( ',', trim($track_no_canada));
foreach($track_array_no as $track_no){
if(strlen($track_no) != 0){
$track_result = array('Result'=>'', 'Records'=> '', 'Track_no'=> '');
$track_result['Track_no'] = trim($track_no);
$html = file_get_html($track_url_canada . $track_no);
$html_array = $html->find('table[class=yundanTable] tr');
if (!count($html_array)) {
$track_result['Result'] = "ERROR";
$message = '<table><tr>';
$message .= '<td>订单编号:'.$track_result['Track_no'] .'查询不到定单信息~</td>';
/*$message .= '<td>查询不到定单信息~</td>';*/
$message .= '</tr></table>';
$track_result['Records'] = $message;
}else{
$message = '<table class="table table-bordered">';
$express_type = '顺丰快递';
$express_url = $url_frame_sf;
foreach ($html_array as $element) {
$message .= '<tr>';
if ($element->children(1)) {//this row has two '<td></td>'s
$message .= '<td>' . $element->children(0)->innertext . '</td>';
$message .= '<td>' . $element->children(1)->innertext . '</td>';
} else {//this row has only one '<td></td>'
if ($element->children(0)->children(0)) {//this is a iFrame
$url_china_src = $element->children(0)->children(0)->children(0)->src;
$url_frame_china = $express_url . find_num($url_china_src);
$message .= '<td colspan="2" >';
$message .= '<iframe frameborder="0" scrolling="no" style="overflow:hidden;" src="' . $url_frame_china . '" width="100%" height="260px"></iframe>';
$message .= '</td>';
} else {// this row contains express information in China
$china_express_info = $element->children(0)->innertext;
$express_type = find_express_name($china_express_info);
if($express_type == '顺丰快递'){
$express_url = $url_frame_sf;
}else if($express_type == '天天快递'){
$express_url = $url_frame;
}
$message .= '<td colspan="2">' . $china_express_info . '</td>';
}
}
$message .= '</tr>';
}
$message .= '</table>';
$track_result['Result'] = "OK";
$track_result['Records'] = $message;
}
array_push($track_result_array, $track_result);
}
}
}
}
?>
<div class="container">
<?php
if (isset($_GET["track_no"])) {
foreach($track_result_array as $track_result){
echo $track_result['Records'];
echo '<br>';
}
}
?>
</div>
<?php require_once ('footer.php'); ?>
</body>
</html>