1 | #ifndef PUTLOCKER_H |
---|
2 | #define PUTLOCKER_H |
---|
3 | |
---|
4 | char* putlocker(char* host, char* file, char* hosterurl) |
---|
5 | { |
---|
6 | debug(99, "in host: %s file: %s", host, file); |
---|
7 | int debuglevel = getconfigint("debuglevel", NULL); |
---|
8 | char* tmphost = NULL, *tmpfile = NULL, *tmpstr = NULL, *send = NULL, *hash = NULL, *hashstr = NULL, *hashlen = NULL; |
---|
9 | char* ip = 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(host == NULL || file == NULL) return NULL; |
---|
17 | |
---|
18 | tmphost = ostrcat("www.", host, 0, 0); |
---|
19 | tmpfile = ostrcat("/file/", file, 0, 0); |
---|
20 | debug(99, "tmphost: %s", tmphost); |
---|
21 | ip = get_ip(tmphost); |
---|
22 | debug(99, "ip: %s", ip); |
---|
23 | debug(99, "tmpfile: %s", tmpfile); |
---|
24 | |
---|
25 | send = ostrcat(send, "GET ", 1, 0); |
---|
26 | send = ostrcat(send, tmpfile, 1, 0); |
---|
27 | send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0); |
---|
28 | send = ostrcat(send, tmphost, 1, 0); |
---|
29 | 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); |
---|
30 | debug(99, "send: %s", send); |
---|
31 | |
---|
32 | tmpstr = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1); |
---|
33 | free(send); send = NULL; |
---|
34 | debug(99, "tmpstr: %s", tmpstr); |
---|
35 | titheklog(debuglevel, "/tmp/putlocker1_tmpstr_get", NULL, tmpstr); |
---|
36 | |
---|
37 | if(tmpstr == NULL) |
---|
38 | { |
---|
39 | textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
40 | goto end; |
---|
41 | } |
---|
42 | |
---|
43 | if(ostrstr(tmpstr, "This file doesn't exist, or has been removed.") != NULL) |
---|
44 | { |
---|
45 | 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); |
---|
46 | goto end; |
---|
47 | } |
---|
48 | |
---|
49 | phpsessid = getxmlentry(tmpstr, "PHPSESSID="); |
---|
50 | debug(99, "phpsessid: %s", phpsessid); |
---|
51 | serverid = getxmlentry(tmpstr, "SERVERID="); |
---|
52 | debug(99, "serverid: %s", serverid); |
---|
53 | usender = getxmlentry(tmpstr, "usender="); |
---|
54 | debug(99, "usender: %s", usender); |
---|
55 | |
---|
56 | //get hash from tmpstr |
---|
57 | char* pos = ostrstr(tmpstr, "<input type=\"hidden\" value="); |
---|
58 | hashstr = getxmlentry(pos, "value="); |
---|
59 | // free(tmpstr) after getxml or segfault... |
---|
60 | free(tmpstr); tmpstr = NULL; |
---|
61 | debug(99, "hashstr: %s", hashstr); |
---|
62 | if(hashstr == NULL) goto end; |
---|
63 | |
---|
64 | hash = ostrcat(hash, "hash=", 1, 0); |
---|
65 | hash = ostrcat(hash, hashstr, 1, 0); |
---|
66 | hash = ostrcat(hash, "&confirm=Continue+as+Free+User", 1, 0); |
---|
67 | debug(99, "hash: %s", hash); |
---|
68 | |
---|
69 | hashlen = oitoa(strlen(hash)); |
---|
70 | debug(99, "hashlen: %s", hashlen); |
---|
71 | |
---|
72 | //create send string |
---|
73 | send = ostrcat(send, "POST /file/", 1, 0); |
---|
74 | send = ostrcat(send, file, 1, 0); |
---|
75 | send = ostrcat(send, " HTTP/1.1\r\nContent-Length: ", 1, 0); |
---|
76 | send = ostrcat(send, hashlen, 1, 0); |
---|
77 | 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); |
---|
78 | send = ostrcat(send, tmphost, 1, 0); |
---|
79 | send = ostrcat(send, "\r\nCookie: usender=", 1, 0); |
---|
80 | send = ostrcat(send, usender, 1, 0); |
---|
81 | send = ostrcat(send, " SERVERID=", 1, 0); |
---|
82 | send = ostrcat(send, serverid, 1, 0); |
---|
83 | send = ostrcat(send, " PHPSESSID=", 1, 0); |
---|
84 | send = ostrcat(send, phpsessid, 1, 0); |
---|
85 | send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0); |
---|
86 | send = ostrcat(send, hash, 1, 0); |
---|
87 | debug(99, "send: %s", send); |
---|
88 | |
---|
89 | // sleep(7); |
---|
90 | tmpstr = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1); |
---|
91 | free(send); send = NULL; |
---|
92 | debug(99, "tmpstr: %s", tmpstr); |
---|
93 | titheklog(debuglevel, "/tmp/putlocker2_tmpstr_post", NULL, tmpstr); |
---|
94 | |
---|
95 | if(tmpstr == NULL) |
---|
96 | { |
---|
97 | textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
98 | goto end; |
---|
99 | } |
---|
100 | |
---|
101 | if(ostrstr(tmpstr, "warning_message") != NULL) |
---|
102 | { |
---|
103 | tmpstr2 = string_resub("<div class='warning_message'>", "</div>", tmpstr, 0); |
---|
104 | tmpstr2 = strstrip(tmpstr2); |
---|
105 | if(tmpstr2 == NULL || strlen(tmpstr2) == 0) |
---|
106 | tmpstr2 = ostrcat(_("The page is temporarily unavailable"), NULL, 0, 0); |
---|
107 | textbox(_("Message"), _(tmpstr2) , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
108 | goto end; |
---|
109 | } |
---|
110 | |
---|
111 | if(phpsessid == NULL || serverid == NULL) goto end; |
---|
112 | |
---|
113 | //get streamlink |
---|
114 | if(ostrstr(tmpstr, "playlist:") != NULL) |
---|
115 | streamlink = getxmlentry(tmpstr, "playlist: '"); |
---|
116 | else |
---|
117 | { |
---|
118 | streamlink = string_resub("/get_file.php", "\">Download File</a>", tmpstr, 0); |
---|
119 | streamlink1 = ostrcat("http://www.", host, 0, 0); |
---|
120 | streamlink1 = ostrcat(streamlink1, "/get_file.php", 1, 0); |
---|
121 | streamlink1 = ostrcat(streamlink1, streamlink, 1, 0); |
---|
122 | debug(99, "stream downloadlink: %s", streamlink1); |
---|
123 | goto end; |
---|
124 | } |
---|
125 | debug(99, "streamlink: %s", streamlink); |
---|
126 | |
---|
127 | if(streamlink != NULL) |
---|
128 | { |
---|
129 | char* pos = strchr(streamlink, '\''); |
---|
130 | if(pos != NULL) pos[0] = '\0'; |
---|
131 | } |
---|
132 | free(tmpstr); tmpstr = NULL; |
---|
133 | |
---|
134 | if(streamlink == NULL) goto end; |
---|
135 | |
---|
136 | //create send string |
---|
137 | send = ostrcat(send, "GET ", 1, 0); |
---|
138 | send = ostrcat(send, streamlink, 1, 0); |
---|
139 | send = ostrcat(send, " HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: ", 1, 0); |
---|
140 | send = ostrcat(send, tmphost, 1, 0); |
---|
141 | send = ostrcat(send, "\r\nCookie: SERVERID=", 1, 0); |
---|
142 | send = ostrcat(send, serverid, 1, 0); |
---|
143 | send = ostrcat(send, "PHPSESSID=", 1, 0); |
---|
144 | send = ostrcat(send, phpsessid, 1, 0); |
---|
145 | send = ostrcat(send, "\r\nConnection: close\r\nUser-Agent: Python-urllib/2.6\r\n\r\n", 1, 0); |
---|
146 | |
---|
147 | // sleep(5); |
---|
148 | |
---|
149 | tmpstr = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 0); |
---|
150 | free(send); send = NULL; |
---|
151 | debug(99, "tmpstr: %s", tmpstr); |
---|
152 | titheklog(debuglevel, "/tmp/putlocker3_tmpstr_get", NULL, tmpstr); |
---|
153 | |
---|
154 | if(tmpstr == NULL) |
---|
155 | { |
---|
156 | textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0); |
---|
157 | goto end; |
---|
158 | } |
---|
159 | |
---|
160 | //get streamlink1 |
---|
161 | streamlink1 = getxmlentry(tmpstr, "url="); |
---|
162 | titheklog(debuglevel, "/tmp/putlocker4_streamlink", NULL, streamlink1); |
---|
163 | |
---|
164 | free(tmpstr); tmpstr = NULL; |
---|
165 | |
---|
166 | end: |
---|
167 | free(tmphost); tmphost = NULL; |
---|
168 | free(tmpfile); tmpfile = NULL; |
---|
169 | free(tmpstr); tmpstr = NULL; |
---|
170 | free(tmpstr2); tmpstr2 = NULL; |
---|
171 | free(send); send = NULL; |
---|
172 | free(hash); hash = NULL; |
---|
173 | free(hashstr); hashstr = NULL; |
---|
174 | free(hashlen); hashlen = NULL; |
---|
175 | free(ip); ip = NULL; |
---|
176 | free(phpsessid); phpsessid = NULL; |
---|
177 | free(serverid); serverid = NULL; |
---|
178 | free(usender); usender = NULL; |
---|
179 | free(streamlink); streamlink = NULL; |
---|
180 | |
---|
181 | return streamlink1; |
---|
182 | } |
---|
183 | |
---|
184 | #endif |
---|