source: titan/plugins/tithek/primeshare.h @ 41939

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

fix warnings

File size: 5.0 KB
Line 
1#ifndef PRIMESHARE_H
2#define PRIMESHARE_H
3
4char* primeshare(char* link)
5{
6        debug(99, "link: %s", link);
7        int debuglevel = getconfigint("debuglevel", NULL);
8        char* tmphost = NULL, *tmppath = NULL, *tmpstr = NULL, *tmpstr2 = NULL, *send = NULL, *ip = NULL, *streamlink = NULL, *hash = NULL, *hashlen = NULL, *hashid = NULL, *phpsessid = NULL;
9
10        if(link == NULL) return NULL;
11
12        unlink("/tmp/primeshare1_get");
13        unlink("/tmp/primeshare2_get");
14
15/////////////
16        char* tmplink = NULL, *pos = NULL, *path = NULL;
17
18        tmplink = ostrcat(link, NULL, 0, 0);
19
20        if(ostrstr(link, "/Out/?s=") != NULL)
21        {
22                tmplink = string_replace("/Out/?s=", "", tmplink, 1);
23                debug(99, "remove out string: %s", tmplink);
24        }
25       
26
27        if(tmplink == NULL || ostrncmp("http", tmplink, 4))
28        {
29                textbox(_("Message"), _("Hoster Url not http:// or https://") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
30                goto end;
31        }
32
33        tmphost = string_replace("http://", "", tmplink, 0);
34        tmphost = string_replace("https://", "", tmphost, 1);
35        free(tmplink) , tmplink = NULL;
36
37        if(tmphost != NULL)
38                pos = strchr(tmphost, '/');
39        if(pos != NULL)
40        {
41                pos[0] = '\0';
42                path = pos + 1;
43        }
44
45        tmppath = ostrcat("/", path, 0, 0);
46//      free(path), path = NULL;
47
48/////////////
49
50/*
51        tmphost = ostrcat(host, NULL, 0, 0);
52//      tmphost = ostrcat(tmphost, ".tv", 1, 0);
53
54        tmppath = ostrcat("/download/", file, 0, 0);
55       
56        debug(99, "tmphost: %s", tmphost);
57        ip = get_ip(tmphost);
58        debug(99, "ip: %s", ip);
59        debug(99, "tmppath: %s", tmppath);
60*/
61        send = ostrcat(send, "GET ", 1, 0);
62        send = ostrcat(send, tmppath, 1, 0);
63        send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0);
64        send = ostrcat(send, tmphost, 1, 0);
65        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);
66        debug(99, "send: %s", send);
67
68        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
69        debug(99, "tmpstr: %s", tmpstr);
70        titheklog(debuglevel, "/tmp/primeshare1_get", NULL, NULL, NULL, tmpstr);
71
72        if(tmpstr == NULL)
73        {
74                textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
75                goto end;
76        }
77
78        if(ostrstr(tmpstr, "The file is being transfered to our other servers. This may take few minutes.") != NULL)
79        {
80                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);
81                goto end;
82        }
83        waitmsgbar(20, 0, _("Connect with Hoster wait 20 seconds"), 1);
84
85        phpsessid = getxmlentry(tmpstr, "PHPSESSID=");
86        debug(99, "phpsessid: %s", phpsessid);
87
88        char* pos1 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"hash\" value=");
89        hashid = getxmlentry(pos1, "value=");
90        debug(99, "hashid: %s", hashid);
91        if(hashid == NULL) goto end;
92
93        hash = ostrcat(hash, "hash=", 1, 0);   
94        hash = ostrcat(hash, hashid, 1, 0);
95        debug(99, "hash: %s", hash);
96
97        hashlen = oitoa(strlen(hash));
98
99        free(send), send = NULL;
100        //create send string
101        send = ostrcat(send, "POST ", 1, 0);
102        send = ostrcat(send, tmppath, 1, 0);
103        send = ostrcat(send, " HTTP/1.1\r\nContent-Length: ", 1, 0);
104        send = ostrcat(send, hashlen, 1, 0);
105        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);
106        send = ostrcat(send, tmphost, 1, 0);
107        send = ostrcat(send, "\r\nCookie: ", 1, 0);
108//      send = ostrcat(send, "\r\nCookie: usender=", 1, 0);
109//      send = ostrcat(send, usender, 1, 0);
110//      send = ostrcat(send, " SERVERID=", 1, 0);
111//      send = ostrcat(send, serverid, 1, 0);
112        send = ostrcat(send, " PHPSESSID=", 1, 0);
113        send = ostrcat(send, phpsessid, 1, 0);
114        send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0);
115        send = ostrcat(send, hash, 1, 0);
116        debug(99, "send: %s", send);
117
118        free(tmpstr), tmpstr = NULL;
119        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
120        debug(99, "tmpstr: %s", tmpstr);
121        titheklog(debuglevel, "/tmp/primeshare2_get", NULL, NULL, NULL, tmpstr);
122
123        if(tmpstr == NULL)
124        {
125                textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
126                goto end;
127        }
128
129        tmpstr2 = string_resub("clip: {", "}", tmpstr, 0);
130        debug(99, "tmpstr2: %s", tmpstr2);
131        streamlink = string_resub("url: '", "'", tmpstr2, 0);
132        debug(99, "streamlink1: %s", streamlink);
133        htmldecode(streamlink, streamlink);
134        debug(99, "streamlink2: %s", streamlink);
135       
136end:
137        free(tmphost); tmphost = NULL;
138        free(tmppath); tmppath = NULL;
139        free(tmpstr); tmpstr = NULL;
140        free(tmpstr2); tmpstr2 = NULL;
141        free(send); send = NULL;
142        free(hash); hash = NULL;
143        free(hashlen); hashlen = NULL;
144        free(ip); ip = NULL;
145        free(hashid), hashid = NULL;
146
147        return streamlink;
148}
149
150#endif
Note: See TracBrowser for help on using the repository browser.