source: titan/plugins/tithek/putlocker.h @ 41862

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

fix warnings

File size: 8.4 KB
Line 
1#ifndef PUTLOCKER_H
2#define PUTLOCKER_H
3
4char* putlocker(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, *hash = NULL, *hashstr = NULL, *hashlen = NULL;
9        char* ip = NULL, *cmd = NULL, *phpsessid = NULL, *serverid = NULL, *usender = NULL, *streamlink = NULL, *streamlink1 = NULL, *tmpstr2 = NULL;
10
11        unlink("/tmp/putlocker1_tmpstr_get");
12        unlink("/tmp/putlocker2_tmpstr_post");
13        unlink("/tmp/putlocker3_tmpstr_get");
14        unlink("/tmp/putlocker4_streamlink");
15
16        if(link == NULL) return NULL;
17
18/////////////
19        char* tmplink = NULL, *pos = NULL, *path = NULL;
20
21        tmplink = ostrcat(link, NULL, 0, 0);
22
23        if(ostrstr(link, "/Out/?s=") != NULL)
24        {
25                tmplink = string_replace("/Out/?s=", "", tmplink, 1);
26                debug(99, "remove out string: %s", tmplink);
27        }
28       
29
30        if(tmplink == NULL || ostrncmp("http", tmplink, 4))
31        {
32                textbox(_("Message"), _("Hoster Url not http:// or https://") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
33                goto end;
34        }
35
36        tmphost = string_replace("http://", "", tmplink, 0);
37        tmphost = string_replace("https://", "", tmphost, 1);
38        free(tmplink) , tmplink = NULL;
39
40        if(tmphost != NULL)
41                pos = strchr(tmphost, '/');
42        if(pos != NULL)
43        {
44                pos[0] = '\0';
45                path = pos + 1;
46        }
47
48        tmppath = ostrcat("/", path, 0, 0);
49//      free(path), path = NULL;
50
51/////////////
52
53
54
55/*
56        tmphost = ostrcat("www.", host, 0, 0);
57        tmppath = ostrcat("/file/", file, 0, 0);
58        debug(99, "tmphost: %s", tmphost);
59        ip = get_ip(tmphost);
60        debug(99, "ip: %s", ip);
61        debug(99, "tmppath: %s", tmppath);
62*/
63
64        tmppath = string_replace_all("/embed/", "/file/", tmppath, 1);
65
66        send = ostrcat(send, "GET ", 1, 0);
67        send = ostrcat(send, tmppath, 1, 0);
68        send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0);     
69        send = ostrcat(send, tmphost, 1, 0);
70        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\nConnection: close\r\nAccept-Encoding: gzip\r\n\r\n", 1, 0);       
71        debug(99, "send: %s", send);
72
73        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
74        free(send); send = NULL;
75        debug(99, "tmpstr: %s", tmpstr);
76        titheklog(debuglevel, "/tmp/putlocker1_tmpstr_get", NULL, NULL, NULL, tmpstr);
77       
78        if(tmpstr == NULL)
79        {
80                textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
81                goto end;
82        }
83
84        if(ostrstr(tmpstr, "This file doesn't exist, or has been removed.") != NULL)
85        {
86                textbox(_("Message"), _("This file doesn't exist, or has been removed."), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 400, 0, 0);
87                goto end;
88        }
89
90        if(ostrstr(tmpstr, "domain=.firedrive.com") != NULL)
91        {
92                textbox(_("Message"), _("Found Firedrive.com Link, supporting comming soon..."), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 400, 0, 0);
93                goto end;
94        }
95       
96        phpsessid = getxmlentry(tmpstr, "PHPSESSID=");
97        debug(99, "phpsessid: %s", phpsessid);
98        serverid = getxmlentry(tmpstr, "SERVERID=");
99        debug(99, "serverid: %s", serverid);
100        usender = getxmlentry(tmpstr, "usender=");
101        debug(99, "usender: %s", usender);
102
103        //get hash from tmpstr
104        char* pos1 = ostrstr(tmpstr, "<input type=\"hidden\" value=");
105        hashstr = getxmlentry(pos1, "value=");
106// free(tmpstr) after getxml or segfault...
107        free(tmpstr); tmpstr = NULL;
108        debug(99, "hashstr: %s", hashstr);
109        if(hashstr == NULL) goto end;
110
111        hash = ostrcat(hash, "hash=", 1, 0);   
112        hash = ostrcat(hash, hashstr, 1, 0);
113        hash = ostrcat(hash, "&confirm=Continue+as+Free+User", 1, 0);
114        debug(99, "hash: %s", hash);
115
116        hashlen = oitoa(strlen(hash));
117        debug(99, "hashlen: %s", hashlen);
118
119        //create send string
120        send = ostrcat(send, "POST ", 1, 0);
121        send = ostrcat(send, tmppath, 1, 0);
122        send = ostrcat(send, " HTTP/1.1\r\nContent-Length: ", 1, 0);
123        send = ostrcat(send, hashlen, 1, 0);
124        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);
125        send = ostrcat(send, tmphost, 1, 0);
126        send = ostrcat(send, "\r\nCookie: usender=", 1, 0);
127        send = ostrcat(send, usender, 1, 0);
128        send = ostrcat(send, " SERVERID=", 1, 0);
129        send = ostrcat(send, serverid, 1, 0);
130        send = ostrcat(send, " PHPSESSID=", 1, 0);
131        send = ostrcat(send, phpsessid, 1, 0);
132        send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0);
133        send = ostrcat(send, hash, 1, 0);
134        debug(99, "send: %s", send);
135
136        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
137        free(send); send = NULL;
138        debug(99, "tmpstr: %s", tmpstr);
139        titheklog(debuglevel, "/tmp/putlocker2_tmpstr_post", NULL, NULL, NULL, tmpstr);
140
141        if(tmpstr == NULL)
142        {
143                textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
144                goto end;
145        }
146       
147        if(ostrstr(tmpstr, "warning_message") != NULL)
148        {
149                tmpstr2 = string_resub("<div class='warning_message'>", "</div>", tmpstr, 0);
150                tmpstr2 = strstrip(tmpstr2);
151                if(tmpstr2 == NULL || strlen(tmpstr2) == 0)
152                        tmpstr2 = ostrcat(_("The page is temporarily unavailable"), NULL, 0, 0);
153                textbox(_("Message"), _(tmpstr2) , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
154                goto end;
155        }
156
157        if(phpsessid == NULL || serverid == NULL) goto end;                     
158
159        //get streamlink
160        if(ostrstr(tmpstr, "playlist:") != NULL)
161                streamlink = getxmlentry(tmpstr, "playlist: '");
162        else
163        {
164                streamlink = string_resub("/get_file.php", "\">Download File</a>", tmpstr, 0);
165//              streamlink1 = ostrcat("http://www.", host, 0, 0);
166                streamlink1 = ostrcat("http://", tmphost, 0, 0);
167                streamlink1 = ostrcat(streamlink1, "/get_file.php", 1, 0);
168                streamlink1 = ostrcat(streamlink1, streamlink, 1, 0);
169                debug(99, "stream downloadlink: %s", streamlink1);
170                goto end;
171        }
172        debug(99, "streamlink: %s", streamlink);
173
174        if(streamlink != NULL)
175        {
176                char* pos = strchr(streamlink, '\'');
177                if(pos != NULL) pos[0] = '\0';
178        }
179        free(tmpstr); tmpstr = NULL;
180       
181        if(!ostrncmp("/get_file.php", streamlink, 13))
182        {
183                cmd = ostrcat(cmd, "wget 'http://", 1, 0);
184                cmd = ostrcat(cmd, tmphost, 1, 0);
185                cmd = ostrcat(cmd, "/", 1, 0);
186                cmd = ostrcat(cmd, streamlink, 1, 0);
187                cmd = ostrcat(cmd, "' -O /tmp/putlocker.stream", 1, 0);
188                debug(99, "cmd: %s", cmd);
189                unlink("/tmp/putlocker.stream");
190               
191                system(cmd);
192               
193                free(cmd), cmd = NULL;
194                cmd = ostrcat("cat /tmp/putlocker.stream", NULL, 0, 0);
195               
196                tmpstr = command(cmd);
197                free(cmd), cmd = NULL;
198        }
199
200/*
201        free(tmpstr); tmpstr = NULL;
202
203        if(streamlink == NULL) goto end;
204       
205        //create send string
206        send = ostrcat(send, "GET ", 1, 0);
207        send = ostrcat(send, streamlink, 1, 0);
208        send = ostrcat(send, " HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: ", 1, 0);
209        send = ostrcat(send, tmphost, 1, 0);
210        send = ostrcat(send, "\r\nCookie: SERVERID=", 1, 0);
211        send = ostrcat(send, serverid, 1, 0);
212        send = ostrcat(send, "PHPSESSID=", 1, 0);
213        send = ostrcat(send, phpsessid, 1, 0);
214        send = ostrcat(send, "\r\nConnection: close\r\nUser-Agent: Python-urllib/2.7\r\n\r\n", 1, 0);
215        send = ostrcat(send, hash, 1, 0);
216        debug(99, "send: %s", send);
217       
218        tmpstr = gethttpreal(tmphost, streamlink, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 0);
219*/
220        free(send); send = NULL;
221        debug(99, "tmpstr: %s", tmpstr);
222        titheklog(debuglevel, "/tmp/putlocker3_tmpstr_get", NULL, NULL, NULL, tmpstr);
223
224        if(tmpstr == NULL)
225        {
226                textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
227                goto end;
228        }
229
230        //get streamlink1
231        streamlink1 = getxmlentry(tmpstr, "url=");
232        titheklog(debuglevel, "/tmp/putlocker4_streamlink", NULL, NULL, NULL, streamlink1);
233
234        free(tmpstr); tmpstr = NULL;
235
236end:
237        free(tmphost); tmphost = NULL;
238        free(tmppath); tmppath = NULL;
239        free(tmpstr); tmpstr = NULL;
240        free(tmpstr2); tmpstr2 = NULL;
241        free(send); send = NULL;
242        free(hash); hash = NULL;
243        free(hashstr); hashstr = NULL;
244        free(hashlen); hashlen = NULL; 
245        free(ip); ip = NULL;
246        free(phpsessid); phpsessid = NULL;
247        free(serverid); serverid = NULL;
248        free(usender); usender = NULL;
249        free(streamlink); streamlink = NULL;
250
251        return streamlink1;
252}
253
254#endif
Note: See TracBrowser for help on using the repository browser.