-
Notifications
You must be signed in to change notification settings - Fork 3
/
generate-link.php
54 lines (33 loc) · 1.17 KB
/
generate-link.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
<?php
use voku\helper\HtmlDomParser;
require_once 'composer/vendor/autoload.php';
require_once 'config.php';
require_once 'functions.php';
if (!isset($_REQUEST['id'])) {
sendErrorResponse("No id found.");
}
if (trim($_REQUEST['id']) == "") {
sendErrorResponse("No id provided.");
}
$episodeID = trim($_REQUEST['id']);
$episodeLink = $gogourl . "/" . $episodeID;
$html = getHtmlFromUrl($episodeLink);
$dom = HtmlDomParser::str_get_html($html);
$embedLink = $dom->findOne('iframe');
$iframe = $embedLink->getAttribute("src");
// Parse the URL
$parsed_url = parse_url($iframe);
// Get the protocol
$embedLinkProtocol = $parsed_url['scheme'];
// Get the host
$embedLinkHost = $parsed_url['host'];
// Parse the query string into an array
parse_str($parsed_url['query'], $query_params);
// Get the 'id' value
$id_value = $query_params['id'];
$iframeHtml = getHtmlFromUrl($iframe);
$params = generateEncryptAjaxParameters($iframeHtml, $id_value);
$requestURL = $embedLinkProtocol . "://" . $embedLinkHost . "/encrypt-ajax.php" . "?" . $params;
$responseData = fetchUrl($requestURL)["data"];
header('Content-Type: application/json');
echo decryptEncryptAjaxResponse($responseData);