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

Last change on this file since 27463 was 27463, checked in by obi, 10 years ago

tithek / mc update

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