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

Last change on this file since 19879 was 19879, checked in by obi, 11 years ago

[tithek] update debug system

File size: 6.9 KB
Line 
1#ifndef PUTLOCKER_H
2#define PUTLOCKER_H
3
4char* putlocker(char* host, char* file)
5{
6        debug(99, "in host: %s file: %s", host, file);
7        char* tmphost = NULL;
8        char* tmpfile = NULL;
9        char* tmpstr = NULL;
10        char* send = NULL;
11        char* hash = NULL;
12        char* hashstr = NULL;
13        char* hashlen = NULL;
14        char* ip = NULL;
15        char* phpsessid = NULL;
16        char* serverid = NULL;
17        char* usender = NULL;
18        char* line = NULL;
19        char* lines = NULL;     
20        char* cmd = NULL;
21        char* streamlink = NULL;
22        char* streamlink1 = NULL;
23
24        unlink("/tmp/tithek/get");
25        unlink("/tmp/tithek/x9");
26
27        if(host == NULL || file == NULL) return NULL;
28
29        tmphost = ostrcat("www.", host, 0, 0);
30        tmpfile = ostrcat("/file/", file, 0, 0);
31        debug(99, "tmphost: %s", tmphost);
32        ip = get_ip(tmphost);
33        debug(99, "ip: %s", ip);
34        debug(99, "tmpfile: %s", tmpfile);
35
36        send = ostrcat(send, "GET /file/", 1, 0);
37        send = ostrcat(send, file, 1, 0);
38        send = ostrcat(send, " HTTP/1.1\r\nHost: www.", 1, 0); 
39        send = ostrcat(send, host, 1, 0);
40        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);       
41       
42        debug(99, "tmphost: %s", tmphost);
43        debug(99, "tmpfile: %s", tmpfile);
44        debug(99, "send: %s", send);
45
46        gethttpreal(tmphost, tmpfile, 80, "/tmp/tithek/get", NULL, NULL, 0, send, NULL, 5000, 1);
47        sleep(1);
48        free(send); send = NULL;
49       
50        if(!file_exist("/tmp/tithek/get"))
51        {
52                textbox(_("Message"), _("This file doesn't exist, or has been removed") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
53                goto end;
54        }
55        if(getconfigint("debuglevel", NULL) == 99)
56                system("cp -a /tmp/tithek/get /tmp/putlocker1_tmpstr_get");
57
58        char* header = NULL;
59        header = command("cat /tmp/tithek/get");
60       
61        phpsessid = getxmlentry(header, "PHPSESSID=");
62        debug(99, "phpsessid: %s", phpsessid);
63        serverid = getxmlentry(header, "SERVERID=");
64        debug(99, "serverid: %s", serverid);
65        usender = getxmlentry(header, "usender=");
66        debug(99, "usender: %s", usender);
67        free(header), header = NULL;
68
69        line = string_newline(command("cat /tmp/tithek/get | grep 'Set-Cookie:' -n | tail -n1| cut -d':' -f1"));
70        cmd = ostrcat(cmd, "cat /tmp/tithek/get | wc -l", 1, 0);
71        lines = string_newline(command(cmd));
72        free(cmd); cmd = NULL;
73        debug(99, "line: %s", line);
74        debug(99, "lines: %s", lines);
75
76        if(lines == NULL || line == NULL) goto end;     
77       
78        int sline = atoi(lines) - atoi(line) - 1;
79        debug(99, "sline: %d", sline);
80        debug(99, "sline: %s", oitoa(sline));
81
82        cmd = ostrcat(cmd, "cat /tmp/tithek/get | tail -n", 1, 0);
83        cmd = ostrcat(cmd, oitoa(sline), 1, 0);
84        cmd = ostrcat(cmd, " | sed '1,1d' | zcat", 1, 0);
85        debug(99, "cmd: %s", cmd);     
86        tmpstr = command(cmd);
87        free(cmd); cmd = NULL;
88        free(lines); lines = NULL;
89        if(getconfigint("debuglevel", NULL) == 99)
90                writesys("/tmp/putlocker2_tmpstr_zcat", tmpstr, 0);
91
92        //get hash from tmpstr
93        char* pos = ostrstr(tmpstr, "<input type=\"hidden\" value=");
94        hashstr = getxmlentry(pos, "value=");
95        free(tmpstr); tmpstr = NULL;
96        debug(99, "hashstr: %s", hashstr);
97        if(hashstr == NULL) goto end;
98
99        hash = ostrcat(hash, "hash=", 1, 0);   
100        hash = ostrcat(hash, hashstr, 1, 0);
101        hash = ostrcat(hash, "&confirm=Continue+as+Free+User", 1, 0);
102        debug(99, "hash: %s", hash);
103
104        hashlen = oitoa(strlen(hash));
105        debug(99, "hashlen: %s", hashlen);
106
107        //create send string
108        send = ostrcat(send, "POST /file/", 1, 0);
109        send = ostrcat(send, file, 1, 0);
110        send = ostrcat(send, " HTTP/1.1\r\nContent-Length: ", 1, 0);
111        send = ostrcat(send, hashlen, 1, 0);
112        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: www.", 1, 0);
113        send = ostrcat(send, host, 1, 0);
114        send = ostrcat(send, "\r\nCookie: usender=", 1, 0);
115        send = ostrcat(send, usender, 1, 0);
116        send = ostrcat(send, " SERVERID=", 1, 0);
117        send = ostrcat(send, serverid, 1, 0);
118        send = ostrcat(send, " PHPSESSID=", 1, 0);
119        send = ostrcat(send, phpsessid, 1, 0);
120        send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0);
121        send = ostrcat(send, hash, 1, 0);
122        debug(99, "send: %s", send);
123
124        sleep(7);
125        //send and receive answer
126        gethttpreal(tmphost, tmpfile, 80, "/tmp/tithek/x9", NULL, NULL, 0, send, NULL, 5000, 0);
127        sleep(1);
128        if(getconfigint("debuglevel", NULL) == 99)
129                system("cp -a /tmp/tithek/x9 /tmp/putlocker3_tmpstr_post");
130
131        free(send); send = NULL;
132        tmpstr = command("cat /tmp/tithek/x9 | sed '1,1d' | zcat");
133        if(getconfigint("debuglevel", NULL) == 99)
134                writesys("/tmp/putlocker4_tmpstr_post_zcat", tmpstr, 0);
135       
136        if(ostrstr(tmpstr, "warning_message") != NULL)
137        {
138                tmpstr = string_resub("<div class='warning_message'>", "</div>", tmpstr, 0);   
139                textbox(_("Message"), _(tmpstr) , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
140                goto end;
141        }
142        if(phpsessid == NULL || serverid == NULL) goto end;                     
143
144        //get streamlink
145        if(ostrstr(tmpstr, "playlist:") != NULL)
146                streamlink = getxmlentry(tmpstr, "playlist: '");
147        else
148        {
149                streamlink = string_resub("/get_file.php", "\">Download File</a>", tmpstr, 0); 
150                streamlink1 = ostrcat("http://www.", host, 0, 0);
151                streamlink1 = ostrcat(streamlink1, "/get_file.php", 1, 0);
152                streamlink1 = ostrcat(streamlink1, streamlink, 1, 0);
153                debug(99, "stream downloadlink");
154                goto end;
155        }
156
157        debug(99, "streamlink: %s", streamlink);
158
159        if(streamlink != NULL)
160        {
161                char* pos = strchr(streamlink, '\'');
162                if(pos != NULL) pos[0] = '\0';
163        }
164        free(tmpstr); tmpstr = NULL;
165        if(streamlink == NULL) goto end;
166
167        //create send string
168        send = ostrcat(send, "GET ", 1, 0);
169        send = ostrcat(send, streamlink, 1, 0);
170        send = ostrcat(send, " HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: www.", 1, 0);
171        send = ostrcat(send, host, 1, 0);
172        send = ostrcat(send, "\r\nCookie: SERVERID=", 1, 0);
173        send = ostrcat(send, serverid, 1, 0);
174        send = ostrcat(send, "PHPSESSID=", 1, 0);
175        send = ostrcat(send, phpsessid, 1, 0);
176        send = ostrcat(send, "\r\nConnection: close\r\nUser-Agent: Python-urllib/2.6\r\n\r\n", 1, 0);
177
178        sleep(5);
179       
180        //send and receive answer
181        tmpstr = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 0);
182        free(send); send = NULL;
183
184        if(getconfigint("debuglevel", NULL) == 99)
185                writesys("/tmp/putlocker5_tmpstr_get", tmpstr, 0);
186
187//Streaming version of this file is currently not available. You can download it below.
188
189        //get streamlink1
190        streamlink1 = getxmlentry(tmpstr, "url=");
191        if(getconfigint("debuglevel", NULL) == 99)
192                writesys("/tmp/putlocker5_streamlink", streamlink1, 0);
193
194        free(tmpstr); tmpstr = NULL;
195
196end:
197        free(tmphost); tmphost = NULL;
198        free(tmpfile); tmpfile = NULL;
199        free(tmpstr); tmpstr = NULL;
200        free(send); send = NULL;
201        free(hash); hash = NULL;
202        free(hashstr); hashstr = NULL;
203        free(hashlen); hashlen = NULL; 
204        free(ip); ip = NULL;
205        free(phpsessid); phpsessid = NULL;
206        free(serverid); serverid = NULL;
207        free(usender); usender = NULL;
208        free(streamlink); streamlink = NULL;
209
210        return streamlink1;
211}
212
213#endif
Note: See TracBrowser for help on using the repository browser.