source: titan/plugins/tithek/firedrive.h @ 29990

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

fix

File size: 6.1 KB
Line 
1
2#ifndef FIREDRIVE_H
3#define FIREDRIVE_H
4
5char* firedrive(char* link)
6{
7        debug(99, "link: %s", link);
8        int debuglevel = getconfigint("debuglevel", NULL);
9        char* tmphost = NULL, *tmppath = NULL, *tmpstr = NULL, *send = NULL, *hash = NULL, *hashstr = NULL, *hashlen = NULL;
10        char* ip = NULL, *streamlink = NULL, *streamlink1 = NULL, *tmpstr2 = NULL;
11        char* srvid = NULL, *cauth = NULL, *cfduid = NULL, *confirm = NULL;
12
13        unlink("/tmp/firedrive1_tmpstr_get");
14        unlink("/tmp/firedrive2_tmpstr_post");
15        unlink("/tmp/firedrive3_tmpstr_get");
16        unlink("/tmp/firedrive4_streamlink");
17
18        if(link == NULL) return NULL;
19
20        char* tmplink = NULL, *pos = NULL, *path = NULL;
21
22        tmplink = ostrcat(link, NULL, 0, 0);
23
24        if(ostrstr(link, "/Out/?s=") != NULL)
25        {
26                tmplink = string_replace("/Out/?s=", "", tmplink, 1);
27                debug(99, "remove out string: %s", tmplink);
28        }
29       
30
31        if(tmplink == NULL || ostrncmp("http://", tmplink, 7))
32        {
33                textbox(_("Message"), _("Hoster Url not http://") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
34                goto end;
35        }
36
37        tmphost = string_replace("http://", "", tmplink, 0);
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        tmphost = ostrcat("www.firedrive.com", NULL, 0, 0);
50        tmppath = string_replace_all("/embed/", "/file/", tmppath, 1);
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\nConnection: close\r\nAccept-Encoding: gzip\r\n\r\n", 1, 0);       
57        debug(99, "send: %s", send);
58
59        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
60        free(send); send = NULL;
61        debug(99, "tmpstr: %s", tmpstr);
62        titheklog(debuglevel, "/tmp/firedrive1_tmpstr_get", NULL, NULL, NULL, tmpstr);
63       
64        if(tmpstr == NULL)
65        {
66                textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
67                goto end;
68        }
69
70        if(ostrstr(tmpstr, "This file doesn't exist, or has been removed.") != NULL)
71        {
72                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);
73                goto end;
74        }
75
76        srvid = string_resub("SRVID=", ";", tmpstr, 0);
77        cauth = string_resub("cauth=", ";", tmpstr, 0);
78        cfduid = string_resub("__cfduid=", ";", tmpstr, 0);
79        confirm = string_resub("name=\"confirm\" value=\"", "\"", tmpstr, 0);
80
81        if(confirm == NULL) goto end;
82
83        hashstr = htmlencode(confirm);
84        hashstr = string_replace_all("/", "%2F", hashstr, 1);
85
86        hash = ostrcat(hash, "confirm=", 1, 0);
87        hash = ostrcat(hash, hashstr, 1, 0);
88        debug(99, "hash: %s", hash);
89
90        if(hash == NULL) goto end;
91
92        hashlen = oitoa(strlen(hash));
93        debug(99, "hashlen: %s", hashlen);
94
95        //create send string
96        send = ostrcat(send, "POST ", 1, 0);
97        send = ostrcat(send, tmppath, 1, 0);
98        send = ostrcat(send, " HTTP/1.1\r\nContent-Length: ", 1, 0);
99        send = ostrcat(send, hashlen, 1, 0);
100        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);
101        send = ostrcat(send, tmphost, 1, 0);
102        send = ostrcat(send, "\r\nCookie: ", 1, 0);
103        send = ostrcat(send, " SRVID=", 1, 0);
104        send = ostrcat(send, srvid, 1, 0);
105        send = ostrcat(send, "; cauth=", 1, 0);
106        send = ostrcat(send, cauth, 1, 0);
107        send = ostrcat(send, "; __cfduid=", 1, 0);
108        send = ostrcat(send, cfduid, 1, 0);
109        send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0);
110        send = ostrcat(send, hash, 1, 0);
111        debug(99, "send: %s", send);
112
113//      waitmsgbar(16, 0, _("Connect with Hoster wait 16 seconds"), 1);
114
115        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
116        free(send); send = NULL;
117        debug(99, "tmpstr: %s", tmpstr);
118        titheklog(debuglevel, "/tmp/firedrive2_tmpstr_post", NULL, NULL, NULL, tmpstr);
119
120        if(tmpstr == NULL)
121        {
122                textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
123                goto end;
124        }
125
126        if(ostrstr(tmpstr, "This file is private and only viewable by the owner.") != NULL)
127        {
128                textbox(_("Message"), _("This file is private and only viewable by the owner.") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
129                goto end;
130        }
131       
132        if(ostrstr(tmpstr, "warning_message") != NULL)
133        {
134                tmpstr2 = string_resub("<div class='warning_message'>", "</div>", tmpstr, 0);
135                tmpstr2 = strstrip(tmpstr2);
136                if(tmpstr2 == NULL || strlen(tmpstr2) == 0)
137                        tmpstr2 = ostrcat(_("The page is temporarily unavailable"), NULL, 0, 0);
138                textbox(_("Message"), _(tmpstr2) , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
139                goto end;
140        }
141
142        streamlink = string_resub("file: '", "'", tmpstr, 0);
143        titheklog(debuglevel, "/tmp/firedrive4_streamlink", NULL, NULL, NULL, streamlink1);
144
145        if(streamlink == NULL)
146        {
147                streamlink = string_resub("file: loadURL('", "'", tmpstr, 0);
148                titheklog(debuglevel, "/tmp/firedrive5_streamlink", NULL, NULL, NULL, streamlink1);
149        }
150
151        if(streamlink == NULL)
152        {
153                streamlink = string_resub("create_PRO_Modal('", "'", tmpstr, 0);
154                titheklog(debuglevel, "/tmp/firedrive6_streamlink", NULL, NULL, NULL, streamlink1);
155        }
156
157        free(tmpstr); tmpstr = NULL;
158
159end:
160        free(tmphost); tmphost = NULL;
161        free(tmppath); tmppath = NULL;
162        free(tmpstr); tmpstr = NULL;
163        free(tmpstr2); tmpstr2 = NULL;
164        free(send); send = NULL;
165        free(hash); hash = NULL;
166        free(hashstr); hashstr = NULL;
167        free(hashlen); hashlen = NULL; 
168        free(ip); ip = NULL;
169        free(cauth); cauth = NULL;
170        free(cfduid); cfduid = NULL;
171        free(confirm); confirm = NULL;
172        free(srvid); srvid = NULL;
173
174        return streamlink;
175}
176
177#endif
Note: See TracBrowser for help on using the repository browser.