1 | #ifndef movreel_H |
---|
2 | #define movreel_H |
---|
3 | |
---|
4 | char* movreel(char* link) |
---|
5 | { |
---|
6 | debug(99, "link: %s", link); |
---|
7 | int debuglevel = getconfigint("debuglevel", NULL); |
---|
8 | char* tmphost = NULL, *error = NULL, *tmppath = NULL, *tmpstr = NULL, *send = NULL, *id = NULL, *fname = NULL, *op = NULL, *hash = NULL, *hashlen = NULL, *ip = NULL, *streamlink = NULL, *rand = NULL; |
---|
9 | |
---|
10 | if(link == NULL) return NULL; |
---|
11 | |
---|
12 | unlink("/tmp/movreel1_get"); |
---|
13 | unlink("/tmp/movreel2_post"); |
---|
14 | unlink("/tmp/movreel3_post"); |
---|
15 | unlink("/tmp/movreel4_streamlink"); |
---|
16 | ///////////// |
---|
17 | char* tmplink = NULL, *pos = NULL, *path = NULL; |
---|
18 | |
---|
19 | tmplink = ostrcat(link, NULL, 0, 0); |
---|
20 | |
---|
21 | if(ostrstr(link, "/Out/?s=") != NULL) |
---|
22 | { |
---|
23 | tmplink = string_replace("/Out/?s=", "", tmplink, 1); |
---|
24 | debug(99, "remove out string: %s", tmplink); |
---|
25 | } |
---|
26 | |
---|
27 | |
---|
28 | if(tmplink == NULL || ostrncmp("http", tmplink, 4)) |
---|
29 | { |
---|
30 | textbox(_("Message"), _("Hoster Url not http:// or https://") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
31 | goto end; |
---|
32 | } |
---|
33 | |
---|
34 | tmphost = string_replace("http://", "", tmplink, 0); |
---|
35 | tmphost = string_replace("https://", "", tmphost, 1); |
---|
36 | free(tmplink) , tmplink = NULL; |
---|
37 | |
---|
38 | if(tmphost != NULL) |
---|
39 | pos = strchr(tmphost, '/'); |
---|
40 | if(pos != NULL) |
---|
41 | { |
---|
42 | pos[0] = '\0'; |
---|
43 | path = pos + 1; |
---|
44 | } |
---|
45 | |
---|
46 | tmppath = ostrcat("/", path, 0, 0); |
---|
47 | |
---|
48 | if(!ostrncmp("www.", tmphost, 7)) |
---|
49 | tmphost = ostrcat("www.", tmphost, 0, 1); |
---|
50 | tmppath = string_replace(".html", "", tmppath, 1); |
---|
51 | |
---|
52 | send = ostrcat(send, "GET ", 1, 0); |
---|
53 | send = ostrcat(send, tmppath, 1, 0); |
---|
54 | send = ostrcat(send, " HTTP/1.0", 1, 0); |
---|
55 | send = ostrcat(send, "\r\nHost: ", 1, 0); |
---|
56 | send = ostrcat(send, tmphost, 1, 0); |
---|
57 | send = ostrcat(send, "\r\nUser-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.99 Safari/535.1", 1, 0); |
---|
58 | send = ostrcat(send, "\r\nConnection: close", 1, 0); |
---|
59 | send = ostrcat(send, "\r\nAccept-Encoding: gzip", 1, 0); |
---|
60 | send = ostrcat(send, "\r\n\r\n", 1, 0); |
---|
61 | debug(99, "send: %s", send); |
---|
62 | |
---|
63 | tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 15000, 1); |
---|
64 | free(send), send = NULL; |
---|
65 | debug(99, "tmpstr: %s", tmpstr); |
---|
66 | titheklog(debuglevel, "/tmp/movreel1_get", NULL, NULL, NULL, tmpstr); |
---|
67 | char* cokkie = string_resub("Set-Cookie: ", ";", tmpstr, 0); |
---|
68 | |
---|
69 | send = ostrcat(send, "GET ", 1, 0); |
---|
70 | send = ostrcat(send, tmppath, 1, 0); |
---|
71 | send = ostrcat(send, " HTTP/1.0", 1, 0); |
---|
72 | send = ostrcat(send, "\r\nHost: ", 1, 0); |
---|
73 | send = ostrcat(send, tmphost, 1, 0); |
---|
74 | send = ostrcat(send, "\r\nUser-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.99 Safari/535.1", 1, 0); |
---|
75 | send = ostrcat(send, "\r\nCookie: ", 1, 0); |
---|
76 | send = ostrcat(send, cokkie, 1, 0); |
---|
77 | send = ostrcat(send, "\r\nConnection: close", 1, 0); |
---|
78 | send = ostrcat(send, "\r\nAccept-Encoding: gzip", 1, 0); |
---|
79 | send = ostrcat(send, "\r\n\r\n", 1, 0); |
---|
80 | debug(99, "send: %s", send); |
---|
81 | |
---|
82 | free(tmpstr), tmpstr = NULL; |
---|
83 | tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 15000, 1); |
---|
84 | free(send), send = NULL; |
---|
85 | debug(99, "tmpstr: %s", tmpstr); |
---|
86 | titheklog(debuglevel, "/tmp/movreel2_get", NULL, NULL, NULL, tmpstr); |
---|
87 | |
---|
88 | char* pos4 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"id\" value="); |
---|
89 | id = getxmlentry(pos4, "value="); |
---|
90 | debug(99, "id: %s", id); |
---|
91 | if(id == NULL) goto end; |
---|
92 | |
---|
93 | char* pos5 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"rand\" value="); |
---|
94 | rand = getxmlentry(pos5, "value="); |
---|
95 | debug(99, "rand: %s", rand); |
---|
96 | if(rand == NULL) goto end; |
---|
97 | |
---|
98 | char* pos6 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"op\" value="); |
---|
99 | op = getxmlentry(pos6, "value="); |
---|
100 | debug(99, "op: %s", op); |
---|
101 | if(op == NULL) goto end; |
---|
102 | |
---|
103 | hash = ostrcat(hash, "rand=", 1, 0); |
---|
104 | hash = ostrcat(hash, rand, 1, 0); |
---|
105 | hash = ostrcat(hash, "&referer=%22&method_premium=&down_script=1&method_free=%22&id=", 1, 0); |
---|
106 | hash = ostrcat(hash, id, 1, 0); |
---|
107 | hash = ostrcat(hash, "&op=", 1, 0); |
---|
108 | hash = ostrcat(hash, op, 1, 0); |
---|
109 | |
---|
110 | debug(99, "hash: %s", hash); |
---|
111 | |
---|
112 | hashlen = oitoa(strlen(hash)); |
---|
113 | |
---|
114 | //create send string |
---|
115 | send = ostrcat(send, "POST /", 1, 0); |
---|
116 | send = ostrcat(send, id, 1, 0); |
---|
117 | send = ostrcat(send, " HTTP/1.0\r\nContent-Length: ", 1, 0); |
---|
118 | send = ostrcat(send, hashlen, 1, 0); |
---|
119 | send = ostrcat(send, "\r\nAccept-Encoding: gzip\r\nConnection: close\r\nUser-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.99 Safari/535.1\r\nHost: ", 1, 0); |
---|
120 | send = ostrcat(send, tmphost, 1, 0); |
---|
121 | |
---|
122 | send = ostrcat(send, "\r\nCookie: ", 1, 0); |
---|
123 | send = ostrcat(send, cokkie, 1, 0); |
---|
124 | |
---|
125 | send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0); |
---|
126 | send = ostrcat(send, hash, 1, 0); |
---|
127 | debug(99, "send: %s", send); |
---|
128 | free(hash), hash = NULL; |
---|
129 | free(cokkie), cokkie = NULL; |
---|
130 | |
---|
131 | tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 15000, 0); |
---|
132 | free(send), send = NULL; |
---|
133 | debug(99, "post: %s", tmpstr); |
---|
134 | titheklog(debuglevel, "/tmp/movreel3_post", NULL, NULL, NULL, tmpstr); |
---|
135 | |
---|
136 | if(tmpstr == NULL) |
---|
137 | { |
---|
138 | textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
139 | goto end; |
---|
140 | } |
---|
141 | |
---|
142 | char* streamlink1 = string_resub("<span style=", "</span>", tmpstr, 0); |
---|
143 | streamlink = string_resub("<a href=\"", "\"", streamlink1, 0); |
---|
144 | free(streamlink1); streamlink1 = NULL; |
---|
145 | |
---|
146 | titheklog(debuglevel, "/tmp/movreel4_streamlink", NULL, NULL, NULL, streamlink); |
---|
147 | |
---|
148 | free(tmpstr); tmpstr = NULL; |
---|
149 | |
---|
150 | end: |
---|
151 | |
---|
152 | free(error); error = NULL; |
---|
153 | free(tmphost); tmphost = NULL; |
---|
154 | free(tmppath); tmppath = NULL; |
---|
155 | free(tmpstr); tmpstr = NULL; |
---|
156 | free(send); send = NULL; |
---|
157 | free(hash), hash = NULL; |
---|
158 | free(hashlen), hashlen = NULL; |
---|
159 | free(op), op = NULL; |
---|
160 | free(id), id = NULL; |
---|
161 | free(fname), fname = NULL; |
---|
162 | free(ip); ip = NULL; |
---|
163 | |
---|
164 | return streamlink; |
---|
165 | } |
---|
166 | |
---|
167 | #endif |
---|