source: titan/plugins/tithek/thefile.h @ 41465

Last change on this file since 41465 was 38946, checked in by obi, 8 years ago

fix warnings

File size: 9.3 KB
Line 
1#ifndef THEFILE_H
2#define THEFILE_H
3
4char* thefile(char* link)
5{
6        debug(99, "link: %s", link);
7        int debuglevel = getconfigint("debuglevel", NULL);
8        char* tmphost = NULL, *tmppath = NULL, *tmpstr = NULL, *send = NULL, *ip = NULL, *streamlink = NULL, *timestamp = NULL;
9        char* hash = NULL, *hashlen = NULL, *pos1 = NULL, *pos2 = NULL, *pos3 = NULL, *hashline = NULL, *expires = NULL;
10        char* usr_login = NULL, *referer = NULL, *fname = NULL, *op = NULL, *id = NULL, *cfduid = NULL;
11        char* pos4 = NULL, *pos5 = NULL, *pos6 = NULL, *redirect = NULL, *method_free = NULL, *rand = NULL;
12        char* pos7 = NULL, *pos8 = NULL, *pos9 = NULL, *pos10 = NULL, *pos11 = NULL, *pos12 = NULL;
13        char* streamlink1 = NULL;
14
15        if(link == NULL) return NULL;
16
17        unlink("/tmp/thefile1_get");
18        unlink("/tmp/thefile2_post");
19        unlink("/tmp/thefile3_post");
20               
21        char* tmplink = NULL, *pos = NULL, *path = NULL;
22
23        tmplink = ostrcat(link, NULL, 0, 0);
24
25        if(ostrstr(link, "/Out/?s=") != NULL)
26        {
27                tmplink = string_replace("/Out/?s=", "", tmplink, 1);
28                debug(99, "remove out string: %s", tmplink);
29        }
30       
31
32        if(tmplink == NULL || ostrncmp("http", tmplink, 4))
33        {
34                textbox(_("Message"), _("Hoster Url not http:// or https://") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
35                goto end;
36        }
37
38        tmphost = string_replace("http://", "", tmplink, 0);
39        tmphost = string_replace("https://", "", tmphost, 1);
40        free(tmplink) , tmplink = NULL;
41
42        if(tmphost != NULL)
43                pos = strchr(tmphost, '/');
44        if(pos != NULL)
45        {
46                pos[0] = '\0';
47                path = pos + 1;
48        }
49
50        tmppath = ostrcat("/", path, 0, 0);
51
52        send = ostrcat(send, "GET ", 1, 0);
53        send = ostrcat(send, tmppath, 1, 0);
54        send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0);
55        send = ostrcat(send, tmphost, 1, 0);
56        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\r\nReferer: ", 1, 0);
57        send = ostrcat(send, link, 1, 0);
58        send = ostrcat(send, "\r\nConnection: close\r\nAccept-Encoding: gzip\r\n\r\n", 1, 0);
59       
60        debug(99, "1send: %s", send);
61
62        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
63        debug(99, "tmpstr: %s", tmpstr);
64        titheklog(debuglevel, "/tmp/thefile1_get", NULL, NULL, NULL, tmpstr);
65        free(send), send = NULL;
66
67        if(ostrstr(tmpstr, "The file is being transfered to our other servers. This may take few minutes.") != NULL)
68        {
69                textbox(_("Message"), _("The file is being transfered to our other servers. This may take few minutes.") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
70                goto end;
71        }
72
73        pos1 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"redirect\" value=");
74        redirect = getxmlentry(pos1, "value=");
75
76        pos2 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"usr_login\" value=");
77        usr_login = getxmlentry(pos2, "value=");
78
79        pos3 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"referer\" value=");
80        referer = getxmlentry(pos3, "value=");
81
82        pos4 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"fname\" value=");
83        fname = getxmlentry(pos4, "value=");
84
85        pos5 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"id\" value=");
86        id = getxmlentry(pos5, "value=");
87
88        pos6 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"op\" value=");
89        op = getxmlentry(pos6, "value=");
90
91        cfduid = string_resub("__cfduid=", ";", tmpstr, 0);
92
93        free(tmpstr); tmpstr = NULL;
94        debug(99, "hashline: %s", hashline);
95
96        free(hash), hash = NULL;
97        hash = ostrcat(hash, "redirect=", 1, 0);
98        hash = ostrcat(hash, redirect, 1, 0);
99        hash = ostrcat(hash, "&usr_login=", 1, 0);     
100        hash = ostrcat(hash, usr_login, 1, 0);
101        hash = ostrcat(hash, "&referer=", 1, 0);
102        hash = ostrcat(hash, referer, 1, 0);
103        hash = ostrcat(hash, "&fname=", 1, 0);
104        hash = ostrcat(hash, fname, 1, 0);
105        hash = ostrcat(hash, "&method_free=Free+Download", 1, 0);
106        hash = ostrcat(hash, "&id=", 1, 0);
107        hash = ostrcat(hash, id, 1, 0);
108        hash = ostrcat(hash, "&op=", 1, 0);
109        hash = ostrcat(hash, op, 1, 0);
110        debug(99, "hash: %s", hash);
111        hashlen = oitoa(strlen(hash));
112
113        send = ostrcat(send, "POST ", 1, 0);
114        send = ostrcat(send, tmppath, 1, 0);
115        send = ostrcat(send, " HTTP/1.1\r\nContent-Length: ", 1, 0);
116        send = ostrcat(send, hashlen, 1, 0);
117        send = ostrcat(send, "\r\nAccept-Encoding: gzip\r\nHost: ", 1, 0);
118        send = ostrcat(send, tmphost, 1, 0);
119        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);
120        send = ostrcat(send, "\r\nConnection: close\r\nReferer: ", 1, 0);
121        send = ostrcat(send, link, 1, 0);
122        send = ostrcat(send, "\r\nCookie: cfduid=", 1, 0);
123        send = ostrcat(send, cfduid, 1, 0);
124        send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0);
125        send = ostrcat(send, hash, 1, 0);
126        debug(99, "2send: %s", send);
127        free(hash), hash = NULL;
128
129        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
130        free(send), send = NULL;
131        debug(99, "tmpstr: %s", tmpstr);
132        titheklog(debuglevel, "/tmp/thefile2_post", NULL, NULL, NULL, tmpstr);
133
134        pos7 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"redirect\" value=");
135        redirect = getxmlentry(pos7, "value=");
136
137        pos8 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"rand\" value=");
138        rand = getxmlentry(pos8, "value=");
139
140        pos9 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"referer\" value=");
141        referer = getxmlentry(pos9, "value=");
142
143        pos10 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"method_free\" value=");
144        method_free = getxmlentry(pos10, "value=");
145
146        pos11 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"id\" value=");
147        id = getxmlentry(pos11, "value=");
148
149        pos12 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"op\" value=");
150        op = getxmlentry(pos12, "value=");
151
152        free(hash), hash = NULL;
153        hash = ostrcat(hash, "redirect=", 1, 0);
154        hash = ostrcat(hash, redirect, 1, 0);
155        hash = ostrcat(hash, "&rand=", 1, 0);   
156        hash = ostrcat(hash, rand, 1, 0);
157        hash = ostrcat(hash, "&btn_download=Create+Download+Link&method_premium=&down_direct=1&referer", 1, 0);
158        char* referer_encode = htmlencode(referer);
159        hash = ostrcat(hash, referer_encode, 1, 0);
160        hash = ostrcat(hash, "&method_free=Free+Download", 1, 0);
161//      hash = ostrcat(hash, method_free, 1, 0);
162        hash = ostrcat(hash, "&id=", 1, 0);
163        hash = ostrcat(hash, id, 1, 0);
164        hash = ostrcat(hash, "&op=", 1, 0);
165        hash = ostrcat(hash, op, 1, 0);
166        debug(99, "3hash: %s", hash);
167        hashlen = oitoa(strlen(hash));
168
169        free(send), send = NULL;       
170/*
171        send = ostrcat(send, "POST ", 1, 0);
172        send = ostrcat(send, tmppath, 1, 0);
173        send = ostrcat(send, " HTTP/1.1\r\nContent-Length: ", 1, 0);
174        send = ostrcat(send, hashlen, 1, 0);
175        send = ostrcat(send, "\r\nAccept-Encoding: gzip\r\nHost: ", 1, 0);
176        send = ostrcat(send, tmphost, 1, 0);
177        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);
178        send = ostrcat(send, "\r\nConnection: close\r\nReferer: ", 1, 0);
179        send = ostrcat(send, link, 1, 0);
180        send = ostrcat(send, "\r\nX-Requested-With: XMLHttpRequest", 1, 0);
181        send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0);
182        send = ostrcat(send, hash, 1, 0);
183*/
184        send = ostrcat(send, "POST ", 1, 0);
185        send = ostrcat(send, tmppath, 1, 0);
186        send = ostrcat(send, " HTTP/1.1\r\nContent-Length: ", 1, 0);
187        send = ostrcat(send, hashlen, 1, 0);
188        send = ostrcat(send, "\r\nAccept-Encoding: gzip\r\nHost: ", 1, 0);
189        send = ostrcat(send, tmphost, 1, 0);
190        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);
191        send = ostrcat(send, "\r\nConnection: close\r\nReferer: ", 1, 0);
192        send = ostrcat(send, link, 1, 0);
193        send = ostrcat(send, "\r\nCookie: cfduid=", 1, 0);
194        send = ostrcat(send, cfduid, 1, 0);
195        send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0);
196        send = ostrcat(send, hash, 1, 0);
197        debug(99, "3send: %s", send);
198
199        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
200        free(send), send = NULL;
201        debug(99, "tmpstr: %s", tmpstr);
202        titheklog(debuglevel, "/tmp/thefile3_post", NULL, NULL, NULL, tmpstr);
203///////
204
205        if(ostrstr(tmpstr, "This direct link will be available for your IP next 8 hours") != NULL)
206                textbox(_("Message"), _("This direct link will be available for your IP next 8 hours") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 5);
207
208        streamlink1 = string_resub("<h3 class=\"x\"><span>", "</span></h3>", tmpstr, 0);
209        streamlink = string_resub("<a href=\"", "</a>", streamlink1, 0);
210
211        debug(99, "streamlink1: %s", streamlink);
212        htmldecode(streamlink, streamlink);
213        debug(99, "streamlink2: %s", streamlink);
214
215end:
216        free(tmphost); tmphost = NULL;
217        free(tmppath); tmppath = NULL;
218        free(tmpstr); tmpstr = NULL;
219        free(send); send = NULL;
220        free(hashline); hashline = NULL;
221        free(hash), hash = NULL;
222        free(hashlen), hashlen = NULL;
223        free(expires), expires = NULL;
224        free(timestamp), timestamp = NULL;
225        free(ip); ip = NULL;
226        free(streamlink1), streamlink1 = NULL;
227        free(redirect), redirect = NULL;
228        free(rand), rand = NULL;
229        free(referer), referer = NULL;
230        free(method_free), method_free = NULL;
231        free(op), op = NULL;
232        free(id), id = NULL;
233        free(redirect), redirect = NULL;
234        free(cfduid), cfduid = NULL;
235        free(usr_login), usr_login = NULL;
236        free(fname), fname = NULL;
237
238        return streamlink;
239}
240
241#endif
Note: See TracBrowser for help on using the repository browser.