#ifndef THEFILE_H
#define THEFILE_H
char* thefile(char* link)
{
debug(99, "link: %s", link);
int debuglevel = getconfigint("debuglevel", NULL);
char* tmphost = NULL, *tmppath = NULL, *tmpstr = NULL, *send = NULL, *ip = NULL, *streamlink = NULL, *timestamp = NULL;
char* hash = NULL, *hashlen = NULL, *pos1 = NULL, *pos2 = NULL, *pos3 = NULL, *hashline = NULL, *expires = NULL;
char* usr_login = NULL, *referer = NULL, *fname = NULL, *op = NULL, *id = NULL, *cfduid = NULL;
char* pos4 = NULL, *pos5 = NULL, *pos6 = NULL, *redirect = NULL, *method_free = NULL, *rand = NULL;
char* pos7 = NULL, *pos8 = NULL, *pos9 = NULL, *pos10 = NULL, *pos11 = NULL, *pos12 = NULL;
char* streamlink1 = NULL;
if(link == NULL) return NULL;
unlink("/tmp/thefile1_get");
unlink("/tmp/thefile2_post");
unlink("/tmp/thefile3_post");
char* tmplink = NULL, *pos = NULL, *path = NULL;
tmplink = ostrcat(link, NULL, 0, 0);
if(ostrstr(link, "/Out/?s=") != NULL)
{
tmplink = string_replace("/Out/?s=", "", tmplink, 1);
debug(99, "remove out string: %s", tmplink);
}
if(tmplink == NULL || ostrncmp("http", tmplink, 4))
{
textbox(_("Message"), _("Hoster Url not http:// or https://") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
goto end;
}
tmphost = string_replace("http://", "", tmplink, 0);
tmphost = string_replace("https://", "", tmphost, 1);
free(tmplink) , tmplink = NULL;
if(tmphost != NULL)
pos = strchr(tmphost, '/');
if(pos != NULL)
{
pos[0] = '\0';
path = pos + 1;
}
tmppath = ostrcat("/", path, 0, 0);
send = ostrcat(send, "GET ", 1, 0);
send = ostrcat(send, tmppath, 1, 0);
send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0);
send = ostrcat(send, tmphost, 1, 0);
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\nReferer: ", 1, 0);
send = ostrcat(send, link, 1, 0);
send = ostrcat(send, "\r\nConnection: close\r\nAccept-Encoding: gzip\r\n\r\n", 1, 0);
debug(99, "1send: %s", send);
tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
debug(99, "tmpstr: %s", tmpstr);
titheklog(debuglevel, "/tmp/thefile1_get", NULL, NULL, NULL, tmpstr);
free(send), send = NULL;
if(ostrstr(tmpstr, "The file is being transfered to our other servers. This may take few minutes.") != NULL)
{
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);
goto end;
}
pos1 = ostrstr(tmpstr, "", "", tmpstr, 0);
streamlink = string_resub("", streamlink1, 0);
debug(99, "streamlink1: %s", streamlink);
htmldecode(streamlink, streamlink);
debug(99, "streamlink2: %s", streamlink);
end:
free(tmphost); tmphost = NULL;
free(tmppath); tmppath = NULL;
free(tmpstr); tmpstr = NULL;
free(send); send = NULL;
free(hashline); hashline = NULL;
free(hash), hash = NULL;
free(hashlen), hashlen = NULL;
free(expires), expires = NULL;
free(timestamp), timestamp = NULL;
free(ip); ip = NULL;
free(streamlink1), streamlink1 = NULL;
free(redirect), redirect = NULL;
free(rand), rand = NULL;
free(referer), referer = NULL;
free(method_free), method_free = NULL;
free(op), op = NULL;
free(id), id = NULL;
free(redirect), redirect = NULL;
free(cfduid), cfduid = NULL;
free(usr_login), usr_login = NULL;
free(fname), fname = NULL;
return streamlink;
}
#endif