1?php
2
3// Get Username and Password for mac-address
4function getUserPassForMac($mac, $base_url) {
5 // URL Encode MAC for processing
6 $mac_address = urlencode($mac);
7 // URL's
8 $token_url = '/portal.php?action=handshake&type=stb&token=';
9 $profile_url = '/portal.php?type=stb&action=get_profile';
10 $list_url = '/portal.php?action=get_ordered_list&type=vod&p=1&JsHttpRequest=1-xml';
11 // Get token from server
12 $first_token = curl_http_get($base_url . $token_url)['js']['token'];
13
14
15 $res = explode('/', $result['js']['cmd']);
16 if (count($res) < 6) {
17 return false;
18 }
19 return [
20 'username' => $res[4],
21 'password' => $res[5]
22 ];
23}
1?php
2
3// CURL http get request
4function curl_http_get ($url, $headers = []) {
5 $ch = curl_init();
6 curl_setopt($ch, CURLOPT_URL, $url);
7 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
8 curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko');
9 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
10 curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
11 $output = curl_exec($ch);
12 curl_close($ch);
13 return json_decode($output, true);
14}
15
16
17
1?php
2
3// CURL http get request
4function curl_http_get ($url, $headers = []) {
5 $ch = curl_init();
6 curl_setopt($ch, CURLOPT_URL, $url);
7 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
8 curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko');
9 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
10 curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
11 $output = curl_exec($ch);
12 curl_close($ch);
13 return json_decode($output, true);
14}
15