Login code
I am trying to write a program that logins on a website.Inspired by this class [developer.qt.nokia.com] .I’ve added a few slots like:
- void _q_on_loginphp();
- void _q_on_cookiephp();
- void _q_on_gamephp();
I am trying to simulte this requests:
http://imageshack.us/photo/my-images/195/requestst.png/()
In the login request I receive a sesion cookie :
http://img20.imageshack.us/img20/3933/sidod.jpg
On the last request I get an error.It says that it used the wrong sid
Here is the code of my functions:
- void Authenticator::_q_onLoginRequestFinished()
- {
- qDebug() << Q_FUNC_INFO;
- if ( !reply )
- return;
- file.write("index \n");
- for(int i=0; i<info.size(); ++i){
- file.write(sourcecode.toLatin1());
- file.write("\n");
- }
- QNetworkRequest loginphp;
- loginphp.setUrl( url);
- loginphp.setRawHeader( "User-Agent", " Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7" );
- connect( loginphpReply, SIGNAL( finished() ),
- SLOT( _q_on_loginphp() ) );
- }
- void Authenticator::_q_on_loginphp()
- {
- file.write("loginphp \n");
- for(int i=0; i<info.size(); ++i){
- file.write(sourcecode.toLatin1());
- file.write("\n");
- }
- QNetworkRequest cookiephp;
- cookiephp.setUrl(url);
- cookiephp.setRawHeader( "User-Agent", " Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7" );
- connect( cookiephpReply, SIGNAL( finished() ),
- SLOT( _q_on_cookiephp() ) );
- }
- void Authenticator::_q_on_cookiephp()
- {
- file.write("cookiephp \n");
- for(int i=0; i<info.size(); ++i){
- file.write(sourcecode.toLatin1());
- file.write("\n");
- }
- QNetworkRequest gamephp;
- gamephp.setUrl(url);
- gamephp.setRawHeader( "User-Agent", " Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7" );
- connect( gamephpReply, SIGNAL( finished() ),
- SLOT( _q_on_gamephp() ) );
- }
- void Authenticator::_q_on_gamephp()
- {
- file.write("gamephp \n");
- for(int i=0; i<info.size(); ++i){
- file.write(sourcecode.toLatin1());
- file.write("\n");
- }
- }
The text output in gamephp.txt is :
gamephp
PHP/5.3.3-7+squeeze3
http://www.triburile.ro/sid_wrong.php
gzip
Accept-Encoding
text/html; charset=utf-8
chunked
Sun, 12 Feb 2012 15:58:32 GMT
lighttpd/1.4.28
[EDIT: fixed link, Volker]
0 replies
You must log in to post a reply. Not a member yet? Register here!

