-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathztarline.php
155 lines (154 loc) · 6.53 KB
/
ztarline.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/usr/bin/php
<?php
//
//__ ________ __
//| \ \ | \
// \▓▓ ▓▓▓▓▓▓▓▓ ______ ______ _______ ______ ____| ▓▓ ______ __ __
//| \ ▓▓__ / \ | \ / \/ \ ______ / ▓▓/ \| \ / \
//| ▓▓ ▓▓ \ | ▓▓▓▓▓▓\ \▓▓▓▓▓▓\ ▓▓▓▓▓▓▓ ▓▓▓▓▓▓\ \ ▓▓▓▓▓▓▓ ▓▓▓▓▓▓\\▓▓\ / ▓▓
//| ▓▓ ▓▓▓▓▓ | ▓▓ \▓▓/ ▓▓\▓▓ \| ▓▓ | ▓▓\▓▓▓▓▓▓ ▓▓ | ▓▓ ▓▓ ▓▓ \▓▓\ ▓▓
//| ▓▓ ▓▓ | ▓▓ | ▓▓▓▓▓▓▓_\▓▓▓▓▓▓\ ▓▓__/ ▓▓ | ▓▓__| ▓▓ ▓▓▓▓▓▓▓▓ \▓▓ ▓▓
//| ▓▓ ▓▓ | ▓▓ \▓▓ ▓▓ ▓▓\▓▓ ▓▓ \▓▓ ▓▓\▓▓ \ \▓▓▓
// \▓▓\▓▓ \▓▓ \▓▓▓▓▓▓▓\▓▓▓▓▓▓▓ \▓▓▓▓▓▓ \▓▓▓▓▓▓▓ \▓▓▓▓▓▓▓ \▓
//
//
//Created by iFraso-dev
//https://github.com/iFraso-dev/ZtarLine
//Contacts - [email protected] / [email protected]
//
error_reporting(0); // Turn off all error reporting
include 'user_data.php'; //We connect the user_data.php file with user settings
//Getting the application code
$getCode1=file_get_contents("https://id.starline.ru/apiV3/application/getCode?appId=$user_AppId&secret=$user_Secret_md5");
$decgetCode = (json_decode($getCode1, true));
$getCode = ($decgetCode["desc"]["code"]);
$codeToken = md5($user_Secret.$getCode);
$getToken=file_get_contents("https://id.starline.ru/apiV3/application/getToken?appId=$user_AppId&secret=$codeToken");
$decgetTokenCode = (json_decode($getToken, true));
$getTokenCode = ($decgetTokenCode["desc"]["token"]);
//
//User authentication
$loginarr = 'https://id.starline.ru/apiV3/user/login';
$params = array(
'token' => $getTokenCode,
'login' => $user_login,
'pass' => $user_pass,
);
$result = file_get_contents($loginarr, false, stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => http_build_query($params)
)
)));
$resultdec = (json_decode($result, true));
//
//User authorization by StarLineID token
$slid_token_url = 'https://developer.starline.ru/json/v2/auth.slid';
$params1 = json_encode(array('slid_token' => $resultdec["desc"]["user_token"]));
$result2 = file_get_contents($slid_token_url, false, stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $params1
)
)));
$result3 = get_headers($slid_token_url, false, stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $params1
)
)));
$resultdec1 = (json_decode($result2, true));
$expl = explode(" ", $result3['7']);
$pattern = array();
$pattern[0] = '/;+/';
$slnet = preg_replace($pattern, '', $expl["1"]);
$userID1 = $resultdec1["user_id"];
$headers = array(
'cache-control: max-age=0',
'upgrade-insecure-requests: 1',
'user-agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36',
'sec-fetch-user: ?1',
'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
'x-compress: null',
'sec-fetch-site: none',
'sec-fetch-mode: navigate',
'accept-encoding: deflate, br',
'accept-language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7',
);
//
// Get user_info
$ch1 = curl_init('https://developer.starline.ru/json/v2/user/'.$userID1.'/user_info');
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch1, CURLOPT_ACCEPT_ENCODING, true);
curl_setopt($ch1, CURLOPT_HTTP_CONTENT_DECODING, true);
curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch1, CURLOPT_HEADER, false);
curl_setopt($ch1, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch1, CURLOPT_COOKIESESSION, true);
curl_setopt($ch1, CURLOPT_COOKIE, $slnet);
$resalt1 = curl_exec($ch1);
curl_close($ch1);
//
//Get mobile_devices
$ch2 = curl_init('https://developer.starline.ru/json/v1/user/'.$userID1.'/mobile_devices');
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_ACCEPT_ENCODING, true);
curl_setopt($ch2, CURLOPT_HTTP_CONTENT_DECODING, true);
curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch2, CURLOPT_HEADER, false);
curl_setopt($ch2, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch2, CURLOPT_COOKIESESSION, true);
curl_setopt($ch2, CURLOPT_COOKIE, $slnet);
$resalt2 = curl_exec($ch2);
curl_close($ch2);
//
//Get Device id
$device_id = json_decode($resalt1,true);
$device_id_end = $device_id["devices"][0]["device_id"];
//
// Get obd_params
$ch3 = curl_init('https://developer.starline.ru/json/v1/device/'.$device_id_end.'/obd_params');
curl_setopt($ch3, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch3, CURLOPT_ACCEPT_ENCODING, true);
curl_setopt($ch3, CURLOPT_HTTP_CONTENT_DECODING, true);
curl_setopt($ch3, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch3, CURLOPT_HEADER, false);
curl_setopt($ch3, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch3, CURLOPT_COOKIESESSION, true);
curl_setopt($ch3, CURLOPT_COOKIE, $slnet);
$resalt3 = curl_exec($ch3);
curl_close($ch3);
//
//Get obd_errors
$ch4 = curl_init('https://developer.starline.ru/json/v1/device/'.$device_id_end.'/obd_errors');
curl_setopt($ch4, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch4, CURLOPT_ACCEPT_ENCODING, true);
curl_setopt($ch4, CURLOPT_HTTP_CONTENT_DECODING, true);
curl_setopt($ch4, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch4, CURLOPT_HEADER, false);
curl_setopt($ch4, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch4, CURLOPT_COOKIESESSION, true);
curl_setopt($ch4, CURLOPT_COOKIE, $slnet);
$resalt4 = curl_exec($ch4);
curl_close($ch4);
//
//JSON output
echo ("{\"user_info\":");
echo ($resalt1); //Get user_info
echo (",");
echo ("\"mobile_devices\":");
echo ($resalt2); //Get mobile_devices
echo (",");
echo ("\"obd_params\":");
echo ($resalt3); // Get obd_params
echo (",");
echo ("\"obd_errors\":");
echo ($resalt4); //Get obd_errors
echo (",");
echo ("\"creator\":\"iFraso-dev\",\"link\":\"https://github.com/iFraso-dev/ZtarLine\",\"contacts\":\"[email protected]\""); //Get creator
echo ("}")
//
?>