예제 #1
0
파일: test.cpp 프로젝트: jie414341055/toj
bool submit(string pid,string lang,string source) {
	FILE * fp=fopen(tfilename,"w+");
	curl = curl_easy_init();
	headerlist=NULL;
	static const char buf[] = "Expect:";
	headerlist = curl_slist_append(headerlist, buf);
	if(curl) {
		curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
		curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "hdu.cookie");
		curl_easy_setopt(curl, CURLOPT_URL, "http://acm.hdu.edu.cn/submit.php?action=submit");
		curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
		/*
		   check=0
		   &problemid=1000
		   &language=0
		   &usercode=%23include%3Cstdio.h%3E%0D%0Aint+main%28%29+%7B%0D%0Aint+a%2Cb%3B%0D%0Ascanf%28%22%25d%25d%22%2C%26a%2C%26b%29%3B%0D%0Aprintf%28%22%25d%5Cn%22%2Ca%2Bb%29%3B%0D%0A%7D
		 */

		string post=(string)"check=0&problemid="+pid+"&language="+lang+"&usercode="+escapeURL(source);
		//cout<<post;
		//writelog((char *)post.c_str());
		curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str());
		res = curl_easy_perform(curl);
		curl_easy_cleanup(curl);
	}
	curl_slist_free_all (headerlist);
	fclose(fp);
	if (res) return false;
	string ts=getAllFromFile(tfilename);
	//cout<<ts;
	//writelog((char *)ts.c_str());
	if (ts.find("Connect(0) to MySQL Server failed.")!=string::npos||ts.find("<b>One or more following ERROR(s) occurred.")!=string::npos||ts.find("<h2>The requested URL could not be retrieved</h2>")!=string::npos||ts.find("PHP: Maximum execution time of")!=string::npos) return false;
	return true;
}
예제 #2
0
파일: test.cpp 프로젝트: jie414341055/toj
string getCEinfo(string runid) {
	FILE * fp=fopen(tfilename,"w+");
	curl = curl_easy_init();
	if(curl) {
		curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
		curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "hdu.cookie");
		string url=(string)"http://acm.hdu.edu.cn/viewerror.php?rid="+runid;
		//cout<<url;
		curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
		res = curl_easy_perform(curl);
		curl_easy_cleanup(curl);
	}
	fclose(fp);
	string ts=getAllFromFile(tfilename);

	int pos=ts.find("<pre>");
	while (ts[pos]!='>') pos++;
	pos++;
	int st=pos;
	while (ts[pos]!='<') pos++;
	string info=ts.substr(st,pos-st);
	strcpy(tempce,info.c_str());
	g2u(tempce,strlen(tempce),outs,MAX_DATA_SIZE);
	decode_html_entities_utf8(outs, 0);
	info=outs;
	int position = info.find( "\\" );
	while ( position != string::npos ) {
		info.replace( position, 1, "\\\\" );
		position = info.find( "\\", position + 2 );
	}
	return info;
}
예제 #3
0
bool submit(string pid,string lang,string source) {
	FILE * fp=fopen(tfilename,"w+");
	curl = curl_easy_init();
	if(curl) {
		curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
		curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "pku.cookie");
		curl_easy_setopt(curl, CURLOPT_URL, "http://poj.org/submit");
		/*
		   problem_id=1000&language=4&
		   source=%23include+%22curl.h%22%0D%0A%23include+%3Cstdio.h%3E%0D%0A%0D%0Aint+main%28%29%0D%0A%7B%0D%0A++++CURL+*curl%3B%0D%0A++++CURLcode+res%3B%0D%0A++++FILE+*+fp%3Dfopen%28%22a.txt%22%2C%22w%2B%22%29%3B%0D%0A++++curl+%3D+curl_easy_init%28%29%3B%0D%0A++++if%28curl%29%0D%0A++++%7B%0D%0A++++++++curl_easy_setopt%28curl%2C+CURLOPT_WRITEDATA%2C+fp%29%3B%0D%0A++++++++curl_easy_setopt%28curl%2C+CURLOPT_WRITEFUNCTION%2C+NULL%29%3B%0D%0A++++++++curl_easy_setopt%28curl%2C+CURLOPT_URL%2C+%22http%3A%2F%2Facm.pku.edu.cn%22%29%3B%0D%0A++++++++res+%3D+curl_easy_perform%28curl%29%3B%0D%0A++++++++curl_easy_cleanup%28curl%29%3B%0D%0A++++%7D%0D%0A++++fclose%28fp%29%3B%0D%0A++++return+0%3B%0D%0A%7D%0D%0A
		   &submit=Submit
		 */

		string post=(string)"problem_id="+pid+"&language="+lang+"&source="+escapeURL(source);
		//cout<<post;
		curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str());
		res = curl_easy_perform(curl);
		curl_easy_cleanup(curl);
	}
	fclose(fp);
	if (res) return false;
	string ts=getAllFromFile(tfilename);
	cout<<ts;
	if (ts.find("Error Occurred")!=string::npos||ts.find("The page is temporarily unavailable")!=string::npos) return false;
	return true;
}
예제 #4
0
string getCEinfo(string runid) {
    FILE * fp=fopen(tfilename,"w");
    curl = curl_easy_init();
    if(curl) {
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
        curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "nbut.cookie");
        string url=(string)"http://acm.nbut.cn/Problem/viewce.xhtml?submitid="+runid;
        //cout<<url;
        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
    }
    fclose(fp);
    string ts=getAllFromFile(tfilename);
    //cout<<ts;

    int pos=ts.find("<pre");
    while (ts[pos]!='>') pos++;
    pos++;
    int st=pos;
    pos=ts.find("</pre>");

    string info=ts.substr(st,pos-st);
    //strcpy(tempce,info.c_str());
    //decode_html_entities_utf8(tempce, 0);
    //info=tempce;
    /*int position = info.find( "<br/>" );
    while ( position != string::npos ) {
        info.replace( position, strlen("<br/>"), "\n" );
        position = info.find( "<br/>", position );
    }*/
//    return "";
    return info;
}
예제 #5
0
bool submit(string pid,string lang,string source) {
    FILE * fp=fopen(tfilename,"w+");
    curl = curl_easy_init();
    if(curl) {
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
        curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "sgu.cookie");
        curl_easy_setopt(curl, CURLOPT_URL, "http://acm.sgu.ru/sendfile.php?contest=0");
/*
id=050600&pass=asdf1234%23&problem=100&elang=GNU+CPP+%28MinGW%2C+GCC+4%29&source=hfddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
*/

        string post=(string)"id="+username+"&pass="******"&problem="+pid+"&elang="+escapeURL(lang)+"&source="+escapeURL(source);
        //cout<<post;
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str());
        res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
    }
    fclose(fp);
    if (res) return false;
    string ts=getAllFromFile(tfilename);
    //cout<<ts;
    if (ts.find("Your solution was successfully submitted.")==string::npos) {
        cout<<ts<<endl;
        return false;
    }
    return true;
}
예제 #6
0
bool login() {
    string post=getPara();
    if (post=="") return false;
    FILE * fp=fopen(tfilename,"w+");
    //curl = curl_easy_init();
    if(curl) {
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
        curl_easy_setopt(curl, CURLOPT_REFERER, "http://livearchive.onlinejudge.org/");
        curl_easy_setopt(curl, CURLOPT_USERAGENT, "curl");
        //curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
        curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "uvalive.cookie");
        curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "uvalive.cookie");
        curl_easy_setopt(curl, CURLOPT_URL, "http://livearchive.onlinejudge.org/index.php?option=com_comprofiler&task=login");
        post=post+"username="******"&passwd="+escapeURL(password)+"&remember=yes&Submit=Login";
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str());
        res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
    }
    fclose(fp);
    if (res) return false;
    string ts=getAllFromFile(tfilename);
    //cout<<ts;
    if (ts.find("alert(\"")!=string::npos||ts.find("<div class='error'>")!=string::npos||ts.find("You are not authorized to view this page!")!=string::npos) return false;
    return true;
}
예제 #7
0
파일: lojhandler.cpp 프로젝트: himcc/bnuoj
string getCEinfo(string runid)
{
    FILE * fp=fopen(tfilename,"w+");
    curl = curl_easy_init();
    if(curl)
    {
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
        curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "loj.cookie");
        string url=(string)"http://www.lightoj.com/volume_showcode.php?sub_id="+runid;
        //cout<<post;
        //cout<<url;
        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
    }
    fclose(fp);

    string s=getAllFromFile(tfilename);

    //cout<<s;
    int pos=s.find("<textarea");
    while (s[pos]!='>') pos++;
    pos++;
    int st=s.find("</textarea",pos);

    return s.substr(pos,st-pos);
}
예제 #8
0
bool login() {
    string post=getPara();
    if (post=="") return false;
    FILE * fp=fopen(tfilename,"w+");
    //curl = curl_easy_init();
    if(curl) {
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
        //curl_easy_setopt(curl, CURLOPT_USERAGENT, "curl");
        //curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
        curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "nbut.cookie");
        curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "nbut.cookie");
        curl_easy_setopt(curl, CURLOPT_URL, "http://acm.nbut.cn/User/chklogin.xhtml");
        post=post+"username="******"&password="******"1") return false;
    return true;
}
예제 #9
0
bool submit(string pid,string lang,string source) {
    FILE * fp=fopen(tfilename,"w+");
    curl = curl_easy_init();
    if(curl) {
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
        curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "nbut.cookie");
        curl_easy_setopt(curl, CURLOPT_URL, "http://acm.nbut.cn/Problem/submitok.xhtml");
/*
language=1000&id=1000&code=fsafgvasfadsvgds%0AGfd%0Ah%0Aefh%0Afd%0Ahdf%0Ajh%0Afe
*/

        string post=(string)"language="+lang+"&id="+pid+"&code="+escapeURL(source);
        //cout<<post;
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str());
        res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
    }
    fclose(fp);
    if (res) return false;
    string ts=getAllFromFile(tfilename);
    //cout<<ts;
    if (ts.find("{\"status\":0")!=string::npos||ts.find("The page is temporarily unavailable")!=string::npos) return false;
    return true;
}
예제 #10
0
파일: lojhandler.cpp 프로젝트: himcc/bnuoj
bool login()
{
    FILE * fp=fopen(tfilename,"w+");
    //cout<<tfilename<<endl;
    curl = curl_easy_init();
    if(curl)
    {
        //curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);

        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
        curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "loj.cookie");
        curl_easy_setopt(curl, CURLOPT_URL, "http://www.lightoj.com/login_check.php");
        string post=(string)"myuserid="+escapeURL(username)+"&mypassword="******"&Submit=Login";
        //cout<<post;
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str());
        res = curl_easy_perform(curl);

//        print_cookies(curl);

        curl_easy_cleanup(curl);
    }
    fclose(fp);

    if (res) return false;
    string ts=getAllFromFile(tfilename);
    //writelog((char *)ts.c_str());
    //cout<<ts;
    if (ts.find("login_main.php")!=string::npos) return false;

    return true;
}
예제 #11
0
파일: fzuhandler.cpp 프로젝트: himcc/bnuoj
string getCEinfo(string runid) {
    FILE * fp=fopen(tfilename,"w+");
    curl = curl_easy_init();
    if(curl) {
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
        curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "fzu.cookie");
        string url=(string)"http://acm.fzu.edu.cn/ce.php?sid="+runid;
        //cout<<url;
        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
    }
    fclose(fp);
    string ts=getAllFromFile(tfilename);

    int pos=ts.find("<font color=\"blue\" size=\"-1\">");
    while (ts[pos]!='>') pos++;
    pos++;
    int st=pos;
    pos=ts.find("</font>");
    string info=ts.substr(st,pos-st);
    strcpy(tempce,info.c_str());
    decode_html_entities_utf8(tempce, 0);
    info=tempce;
    /*int position = info.find( "<br/>" );
    while ( position != string::npos ) {
        info.replace( position, strlen("<br/>"), "\n" );
        position = info.find( "<br/>", position );
    }*/
    return info;
}
예제 #12
0
파일: fzuhandler.cpp 프로젝트: himcc/bnuoj
bool submit(string pid,string lang,string source) {
    FILE * fp=fopen(tfilename,"w+");
    curl = curl_easy_init();
    if(curl) {
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
        curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "fzu.cookie");
        curl_easy_setopt(curl, CURLOPT_URL, "http://acm.fzu.edu.cn/submit.php?act=5");
/*
usr=bnuvjudge&lang=0&pid=1000&code=frji2o%3Berf%0D%0Aedgb%0D%0Afeh%0D%0Adrf%0D%0Ahdf%0D%0Ah&submit=Submit
*/

        string post=(string)"usr="******"&lang="+lang+"&pid="+pid+"&code="+escapeURL(source)+"&submit=Submit";
        //cout<<post;
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str());
        res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
    }
    fclose(fp);
    if (res) return false;
    string ts=getAllFromFile(tfilename);
    //cout<<ts;
    if (ts.find("Warning: This problem is not exist.")!=string::npos||ts.find("The page is temporarily unavailable")!=string::npos) return false;
    return true;
}
예제 #13
0
bool login()
{
    FILE * fp=fopen(tfilename,"w+");
    //cout<<tfilename<<endl;
    curl = curl_easy_init();
    if(curl)
    {
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
        curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "sgu.cookie");
        curl_easy_setopt(curl, CURLOPT_URL, "http://acm.sgu.ru/login.php");
//redirect_uri=%2Fstatus.php&try_user_id=050600&try_user_password=asdf1234%23&type_log=login
        string post=(string)"try_user_id="+username+"&try_user_password="******"&type_log=login";
        //cout<<post;
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str());
        res = curl_easy_perform(curl);

//        print_cookies(curl);

        curl_easy_cleanup(curl);
    }
    fclose(fp);

    if (res) return false;
    string ts=getAllFromFile(tfilename);
    //cout<<ts;
    if (ts.find("<h4>Wrong ID or PASSWORD</h4>")!=string::npos) return false;

    return true;
}
예제 #14
0
string getCEinfo(string runid) {
    FILE * fp=fopen(tfilename,"w+");
    curl = curl_easy_init();
    if(curl) {
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
        curl_easy_setopt(curl, CURLOPT_USERAGENT, "curl");
        curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "uvalive.cookie");
        string url=(string)"http://livearchive.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=9&page=show_compilationerror&submission="+runid;
        //cout<<url;
        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
    }
    fclose(fp);
    string ts=getAllFromFile(tfilename);
    int pos=ts.find("<pre>");
    while (ts[pos]!='>') pos++;
    pos++;
    int st=pos;
    while (ts[pos]!='<') pos++;
    string info=ts.substr(st,pos-st);
//    strcpy(tempce,info.c_str());
//    decode_html_entities_utf8(tempce, 0);
//    info=tempce;
    int position = info.find( "\\" );
    while ( position != string::npos ) {
        info.replace( position, 1, "\\\\" );
        position = info.find( "\\", position + 2 );
    }
    return info;
}
예제 #15
0
string getCEinfo(string runid) {
	FILE * fp=fopen(tfilename,"w+");
	curl = curl_easy_init();
	if(curl) {
		curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
		curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "pku.cookie");
		string url=(string)"http://poj.org/showcompileinfo?solution_id="+runid;
		//cout<<url;
		curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
		res = curl_easy_perform(curl);
		curl_easy_cleanup(curl);
	}
	fclose(fp);
	string ts=getAllFromFile(tfilename);

	int pos=ts.find("<pre>");
	while (ts[pos]!='>') pos++;
	pos++;
	int st=pos;
	while (ts[pos]!='<') pos++;
	string info=ts.substr(st,pos-st);
	strcpy(tempce,info.c_str());
	decode_html_entities_utf8(tempce, 0);
	info=tempce;
	int position = info.find( "\\" );
	while ( position != string::npos ) {
		info.replace( position, 1, "\\\\" );
		position = info.find( "\\", position + 2 );
	} 
	return info;
}
예제 #16
0
string getFirstFromFile(char *filename) {
    string res=getAllFromFile(filename);
    int loc=res.find("<tr class=\"sectiontableentry1\">");
    loc+=strlen("<tr class=\"sectiontableentry1\">");
    int loc2=res.find("</tr>",loc);
    //cout<<res.substr(loc,loc2-loc)<<endl<<"===="<<endl;
    return res.substr(loc,loc2-loc);
}
예제 #17
0
string getRealRunid() {
    string s=getAllFromFile(tfilename);
    int pos=s.find("Submission+received+with+ID+");
    while (s[pos]!='D') pos++;
    pos++;pos++;
    int st=pos;
    while (s[pos]!='\r'&&s[pos]!='\n') pos++;
    return s.substr(st,pos-st);
}
예제 #18
0
파일: lojhandler.cpp 프로젝트: himcc/bnuoj
bool submit(string pid,string lang,string source)
{
    FILE * fp=fopen(tfilename,"w+");
    curl = curl_easy_init();
    static const char buf[] = "Expect:";
    formpost=NULL;
    lastptr=NULL;
    headerlist=NULL;
    curl_formadd(&formpost,
                 &lastptr,
                 CURLFORM_COPYNAME, "submit",
                 CURLFORM_COPYCONTENTS, "Submit",
                 CURLFORM_END);
    curl_formadd(&formpost,
                 &lastptr,
                 CURLFORM_COPYNAME, "sub_problem",
                 CURLFORM_COPYCONTENTS, pid.c_str(),
                 CURLFORM_END);
    curl_formadd(&formpost,
                 &lastptr,
                 CURLFORM_COPYNAME, "language",
                 CURLFORM_COPYCONTENTS, lang.c_str(),
                 CURLFORM_END);
    curl_formadd(&formpost,
                 &lastptr,
                 CURLFORM_COPYNAME, "code",
                 CURLFORM_COPYCONTENTS, source.c_str(),
                 CURLFORM_END);

    curl = curl_easy_init();

    headerlist = curl_slist_append(headerlist, buf);
    if(curl)
    {
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
        curl_easy_setopt(curl, CURLOPT_URL, "http://www.lightoj.com/volume_submit.php");
        curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
        curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "loj.cookie");
        curl_easy_perform(curl);
        curl_easy_cleanup(curl);
        curl_formfree(formpost);
        curl_slist_free_all (headerlist);

        fclose(fp);

        string ts=getAllFromFile(tfilename);
        if (ts.find("<script>location.href='volume_usersubmissions.php'</script>")==string::npos) return false;
    }
    return true;
}
예제 #19
0
파일: test.cpp 프로젝트: jie414341055/toj
bool login() {
	FILE * fp=fopen(tfilename,"w+");
	curl = curl_easy_init();
	if(curl) {
		curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
		curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "hdu.cookie");
		curl_easy_setopt(curl, CURLOPT_URL, "http://acm.hdu.edu.cn/userloginex.php?action=login");
		string post=(string)"username="******"&userpass="******"&login=Sign+In";
		curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str());
		res = curl_easy_perform(curl);
		curl_easy_cleanup(curl);
	}
	fclose(fp);
	if (res) return false;
	string ts=getAllFromFile(tfilename);
	//cout<<ts;
	if (ts.find("No such user or wrong password.")!=string::npos) return false;
	return true;
}
예제 #20
0
bool login() {
	FILE * fp=fopen(tfilename,"w+");
	curl = curl_easy_init();
	if(curl) {
		curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
		curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "pku.cookie");
		curl_easy_setopt(curl, CURLOPT_URL, "http://poj.org/login");
		string post=(string)"user_id1="+username+"&password1="+password+"&B1=login";
		curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str());
		res = curl_easy_perform(curl);
		curl_easy_cleanup(curl);
	}
	fclose(fp);
	if (res) return false;
	string ts=getAllFromFile(tfilename);
	//cout<<ts;
	if (ts.find("alert(\"Login failed!)")!=string::npos) return false;
	return true;
}
예제 #21
0
파일: fzuhandler.cpp 프로젝트: himcc/bnuoj
bool login() {
    FILE * fp=fopen(tfilename,"w+");
    curl = curl_easy_init();
    if(curl) {
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
        curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "fzu.cookie");
        curl_easy_setopt(curl, CURLOPT_URL, "http://acm.fzu.edu.cn/login.php?act=1");
        string post=(string)"uname="+username+"&upassword="******"&submit=Submit";
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str());
        res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
    }
    fclose(fp);
    if (res) return false;
    string ts=getAllFromFile(tfilename);
    //cout<<ts;
    if (ts.find("Warning: Please Check Your UserID And Password!")!=string::npos) return false;
    return true;
}
예제 #22
0
string getCEinfo(string runid)
{
    FILE * fp=fopen(tfilename,"w+");
    curl = curl_easy_init();
    if(curl)
    {
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
        curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "sgu.cookie");
        string url=(string)"http://acm.sgu.ru/cerror.php?id="+runid;
        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
    }
    fclose(fp);
    string s=getAllFromFile(tfilename);
    int pos=s.find("<pre>");
    pos+=strlen("<pre>");
    int st=s.find("</pre>",pos);
    return s.substr(pos,st-pos);
}
예제 #23
0
string getResFromFile(char *filename) {
    string res=getAllFromFile(filename);
    int st=res.find("<td style=\"text-align: center;\">");
    int pos=res.find("</tr>",st);
    return res.substr(st,pos-st);
}
예제 #24
0
bool submit(string pid,string lang,string source)
{
    formpost=NULL;
    lastptr=NULL;
    headerlist=NULL;
    FILE * fp=fopen(tfilename,"w+");
    static const char buf[] = "Expect:";
    curl_formadd(&formpost,
                 &lastptr,
                 CURLFORM_COPYNAME, "problemid",
                 CURLFORM_COPYCONTENTS, "",
                 CURLFORM_END);
    curl_formadd(&formpost,
                 &lastptr,
                 CURLFORM_COPYNAME, "category",
                 CURLFORM_COPYCONTENTS, "",
                 CURLFORM_END);
    curl_formadd(&formpost,
                 &lastptr,
                 CURLFORM_COPYNAME, "localid",
                 CURLFORM_COPYCONTENTS, pid.c_str(),
                 CURLFORM_END);
    curl_formadd(&formpost,
                 &lastptr,
                 CURLFORM_COPYNAME, "language",
                 CURLFORM_COPYCONTENTS, lang.c_str(),
                 CURLFORM_END);
    curl_formadd(&formpost,
                 &lastptr,
                 CURLFORM_COPYNAME, "code",
                 CURLFORM_COPYCONTENTS, source.c_str(),
                 CURLFORM_END);
    curl_formadd(&formpost,
                 &lastptr,
                 CURLFORM_COPYNAME, "codeupl",
                 CURLFORM_FILE, "emptyfile.txt",
                 CURLFORM_END);
    curl_formadd(&formpost,
                 &lastptr,
                 CURLFORM_COPYNAME, "codeupl",
                 CURLFORM_FILENAME, "",
                 CURLFORM_END);

    curl = curl_easy_init();

    headerlist = curl_slist_append(headerlist, buf);
    if(curl)
    {
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
        curl_easy_setopt(curl, CURLOPT_USERAGENT, "curl");
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
        curl_easy_setopt(curl, CURLOPT_URL, "http://livearchive.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=25&page=save_submission");
        //curl_easy_setopt(curl, CURLOPT_REFERER, "http://livearchive.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=25");
        //curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
        curl_easy_setopt(curl, CURLOPT_HEADER, 1);
        curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
        curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "uvalive.cookie");
        curl_easy_perform(curl);
        curl_easy_cleanup(curl);
        curl_formfree(formpost);
        curl_slist_free_all (headerlist);

        fclose(fp);

        string ts=getAllFromFile(tfilename);
        if (ts.find("You have to select a programming language.")!=string::npos||
            ts.find("The selected problem ID does not exist.")!=string::npos||
            ts.find("You have to paste or upload some source code.")!=string::npos||
            ts.find(" You are not authorised to view this resource.")!=string::npos) return false;
    }
    return true;
}
예제 #25
0
파일: fzuhandler.cpp 프로젝트: himcc/bnuoj
string getResFromFile(char *filename) {
    string res=getAllFromFile(filename);
    int st=res.find("<tr onmouseover=");
    int pos=res.find("</tr>",st);
    return res.substr(st,pos-st);
}