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, 7)) |
---|
29 | { |
---|
30 | textbox(_("Message"), _("Hoster Url not http://") , _("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 | free(tmplink) , tmplink = NULL; |
---|
36 | |
---|
37 | if(tmphost != NULL) |
---|
38 | pos = strchr(tmphost, '/'); |
---|
39 | if(pos != NULL) |
---|
40 | { |
---|
41 | pos[0] = '\0'; |
---|
42 | path = pos + 1; |
---|
43 | } |
---|
44 | |
---|
45 | tmppath = ostrcat("/", path, 0, 0); |
---|
46 | // free(path), path = NULL; |
---|
47 | |
---|
48 | ///////////// |
---|
49 | |
---|
50 | |
---|
51 | /* |
---|
52 | tmphost = ostrcat("www.", host, 0, 0); |
---|
53 | tmppath = ostrcat("/", file, 0, 0); |
---|
54 | debug(99, "tmphost: %s", tmphost); |
---|
55 | ip = get_ip(tmphost); |
---|
56 | debug(99, "ip: %s", ip); |
---|
57 | debug(99, "test host only: %s", get_ip(host)); |
---|
58 | debug(99, "tmppath: %s", tmppath); |
---|
59 | */ |
---|
60 | |
---|
61 | send = ostrcat(send, "GET ", 1, 0); |
---|
62 | send = ostrcat(send, tmppath, 1, 0); |
---|
63 | send = ostrcat(send, " HTTP/1.1\r\nAccept-Encoding: identity\r\n", 1, 0); |
---|
64 | send = ostrcat(send, "Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4\r\n", 1, 0); |
---|
65 | send = ostrcat(send, "Host: ", 1, 0); |
---|
66 | send = ostrcat(send, tmphost, 1, 0); |
---|
67 | send = ostrcat(send, "\r\nUser-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3\r\n", 1, 0); |
---|
68 | send = ostrcat(send, "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n", 1, 0); |
---|
69 | send = ostrcat(send, "Connection: close\r\nCookie: xxx2=ok;\r\n\r\n", 1, 0); |
---|
70 | debug(99, "send: %s", send); |
---|
71 | |
---|
72 | tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1); |
---|
73 | free(send), send = NULL; |
---|
74 | debug(99, "tmpstr: %s", tmpstr); |
---|
75 | titheklog(debuglevel, "/tmp/movreel1_get", NULL, tmpstr); |
---|
76 | |
---|
77 | if(tmpstr == NULL) |
---|
78 | { |
---|
79 | textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
80 | goto end; |
---|
81 | } |
---|
82 | |
---|
83 | if(tmpstr == NULL || ostrstr(tmpstr, "<title>The page is temporarily unavailable</title>") != NULL) |
---|
84 | { |
---|
85 | error = string_resub("<td align=\"center\" valign=\"middle\">", "</td>", tmpstr, 0); |
---|
86 | string_deltags(error); |
---|
87 | stringreplacechar(error, '|', '\0'); |
---|
88 | error = strstrip(error); |
---|
89 | if(error == NULL || strlen(error) == 0) |
---|
90 | error = ostrcat(_("The page is temporarily unavailable"), error, 0, 1); |
---|
91 | textbox(_("Message"), error, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 400, 0, 0); |
---|
92 | goto end; |
---|
93 | } |
---|
94 | |
---|
95 | if(ostrstr(tmpstr, "<title>Direct IP access not allowed") != NULL) |
---|
96 | { |
---|
97 | error = string_resub("<title>", "</title>", tmpstr, 0); |
---|
98 | string_deltags(error); |
---|
99 | stringreplacechar(error, '|', '\0'); |
---|
100 | error = strstrip(error); |
---|
101 | if(error == NULL || strlen(error) == 0) |
---|
102 | error = ostrcat(_("The page is temporarily unavailable"), error, 0, 1); |
---|
103 | textbox(_("Message"), error, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 400, 0, 0); |
---|
104 | goto end; |
---|
105 | } |
---|
106 | |
---|
107 | //get hash from tmpstr |
---|
108 | char* pos1 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"fname\" value="); |
---|
109 | fname = getxmlentry(pos1, "value="); |
---|
110 | debug(99, "fname: %s", fname); |
---|
111 | if(fname == NULL) goto end; |
---|
112 | |
---|
113 | char* pos2 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"id\" value="); |
---|
114 | id = getxmlentry(pos2, "value="); |
---|
115 | debug(99, "id: %s", id); |
---|
116 | if(id == NULL) goto end; |
---|
117 | |
---|
118 | char* pos3 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"op\" value="); |
---|
119 | op = getxmlentry(pos3, "value="); |
---|
120 | free(tmpstr); tmpstr = NULL; |
---|
121 | debug(99, "op: %s", op); |
---|
122 | if(op == NULL) goto end; |
---|
123 | free(tmpstr), tmpstr = NULL; |
---|
124 | |
---|
125 | hash = ostrcat(hash, "id=", 1, 0); |
---|
126 | hash = ostrcat(hash, id, 1, 0); |
---|
127 | hash = ostrcat(hash, "&referer=&fname=", 1, 0); |
---|
128 | hash = ostrcat(hash, fname, 1, 0); |
---|
129 | hash = ostrcat(hash, "&method_free=%20Kostenloser%20Download&usr_login=&op=", 1, 0); |
---|
130 | hash = ostrcat(hash, op, 1, 0); |
---|
131 | debug(99, "hash: %s", hash); |
---|
132 | |
---|
133 | hashlen = oitoa(strlen(hash)); |
---|
134 | |
---|
135 | //create send string |
---|
136 | send = ostrcat(send, "POST /", 1, 0); |
---|
137 | send = ostrcat(send, id, 1, 0); |
---|
138 | send = ostrcat(send, " HTTP/1.0\r\nContent-Length: ", 1, 0); |
---|
139 | send = ostrcat(send, hashlen, 1, 0); |
---|
140 | 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); |
---|
141 | send = ostrcat(send, tmphost, 1, 0); |
---|
142 | send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0); |
---|
143 | send = ostrcat(send, hash, 1, 0); |
---|
144 | debug(99, "send: %s", send); |
---|
145 | free(hash), hash = NULL; |
---|
146 | |
---|
147 | tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 0); |
---|
148 | free(send), send = NULL; |
---|
149 | debug(99, "tmpstr: %s", tmpstr); |
---|
150 | titheklog(debuglevel, "/tmp/movreel2_post", NULL, tmpstr); |
---|
151 | |
---|
152 | if(tmpstr == NULL) |
---|
153 | { |
---|
154 | textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
155 | goto end; |
---|
156 | } |
---|
157 | |
---|
158 | char* pos4 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"id\" value="); |
---|
159 | id = getxmlentry(pos4, "value="); |
---|
160 | debug(99, "id: %s", id); |
---|
161 | if(id == NULL) goto end; |
---|
162 | |
---|
163 | char* pos5 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"rand\" value="); |
---|
164 | rand = getxmlentry(pos5, "value="); |
---|
165 | debug(99, "rand: %s", rand); |
---|
166 | if(rand == NULL) goto end; |
---|
167 | |
---|
168 | char* pos6 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"op\" value="); |
---|
169 | op = getxmlentry(pos6, "value="); |
---|
170 | debug(99, "op: %s", op); |
---|
171 | if(op == NULL) goto end; |
---|
172 | |
---|
173 | hash = ostrcat(hash, "id=", 1, 0); |
---|
174 | hash = ostrcat(hash, id, 1, 0); |
---|
175 | hash = ostrcat(hash, "&referer=&rand=", 1, 0); |
---|
176 | hash = ostrcat(hash, rand, 1, 0); |
---|
177 | hash = ostrcat(hash, "&method_free=%20Kostenloser%20Download&usr_login=&op=", 1, 0); |
---|
178 | hash = ostrcat(hash, op, 1, 0); |
---|
179 | debug(99, "hash: %s", hash); |
---|
180 | |
---|
181 | hashlen = oitoa(strlen(hash)); |
---|
182 | |
---|
183 | //create send string |
---|
184 | send = ostrcat(send, "POST /", 1, 0); |
---|
185 | send = ostrcat(send, id, 1, 0); |
---|
186 | send = ostrcat(send, " HTTP/1.0\r\nContent-Length: ", 1, 0); |
---|
187 | send = ostrcat(send, hashlen, 1, 0); |
---|
188 | 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); |
---|
189 | send = ostrcat(send, tmphost, 1, 0); |
---|
190 | send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0); |
---|
191 | send = ostrcat(send, hash, 1, 0); |
---|
192 | debug(99, "send: %s", send); |
---|
193 | free(hash), hash = NULL; |
---|
194 | |
---|
195 | tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 0); |
---|
196 | free(send), send = NULL; |
---|
197 | debug(99, "post: %s", tmpstr); |
---|
198 | titheklog(debuglevel, "/tmp/movreel3_post", NULL, tmpstr); |
---|
199 | |
---|
200 | if(tmpstr == NULL) |
---|
201 | { |
---|
202 | textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
203 | goto end; |
---|
204 | } |
---|
205 | |
---|
206 | streamlink = string_resub("var file_link = '", "'", tmpstr, 0); |
---|
207 | |
---|
208 | titheklog(debuglevel, "/tmp/movreel4_streamlink", NULL, streamlink); |
---|
209 | |
---|
210 | free(tmpstr); tmpstr = NULL; |
---|
211 | |
---|
212 | end: |
---|
213 | |
---|
214 | free(error); error = NULL; |
---|
215 | free(tmphost); tmphost = NULL; |
---|
216 | free(tmppath); tmppath = NULL; |
---|
217 | free(tmpstr); tmpstr = NULL; |
---|
218 | free(send); send = NULL; |
---|
219 | free(hash), hash = NULL; |
---|
220 | free(hashlen), hashlen = NULL; |
---|
221 | free(op), op = NULL; |
---|
222 | free(id), id = NULL; |
---|
223 | free(fname), fname = NULL; |
---|
224 | free(ip); ip = NULL; |
---|
225 | |
---|
226 | return streamlink; |
---|
227 | } |
---|
228 | |
---|
229 | #endif |
---|