Unplugged
2nd October 2007, 18:08
Hi!
I am trying to write program which shows amount of money on my ISP account. The idea is to pass a POST request to index.php and receive generated html page, but there is ssl installed and that is a problem. When I am trying to pass my login and password to index.php through my program, as an output i receive main page as if login or password is incorrect.
#ifndef STAT_H
#define STAT_H
#include <QtNetwork>
#include <QtGui>
#include "ui_stat.h"
class Stat : public QDialog, public Ui::dialog
{
Q_OBJECT
public:
Stat (const QString &host)
{
setupUi ( this );
connect (&http, SIGNAL( requestFinished(int,bool)),this,SLOT(end()));
connect ( statButton, SIGNAL ( clicked ( ) ), this, SLOT ( send ( ) ) );
http.setHost ( host, QHttp::ConnectionModeHttps );
}
void sendData (const QString &input1, const QString &input2 )
{
data.append ( "FindUserName=");
data.append (input1);
data.append ( "&FindUserPass=");
data.append ( input2 );
outFile .setFileName ( "out.html" );
outFile.open (QIODevice:: WriteOnly | QIODevice::Truncate);
QSslSocket *socket = new QSslSocket;
socket->connectToHostEncrypted ( "stat.ultranet.ru", 443 );
if ( socket->waitForEncrypted ( 5000) )
{
http.setSocket ( socket );
QHttpRequestHeader header ( "POST", "/index.php" );
header.setValue ( "Content-Type", "application/x-www-form-urlencoded" );
header.setValue ( "Host", "stat.ultranet.ru" );
http.request ( header, data, &outFile );
}
}
public slots:
void end( )
{
outFile.close ( );
emit done();
}
void send ( )
{
sendData ( loginLineEdit ->text( ), passwLineEdit ->text( ) ) ;
}
signals:
void done( );
private:
QFile outFile;
QHttp http;
QByteArray data;
};
#endif
I am trying to write program which shows amount of money on my ISP account. The idea is to pass a POST request to index.php and receive generated html page, but there is ssl installed and that is a problem. When I am trying to pass my login and password to index.php through my program, as an output i receive main page as if login or password is incorrect.
#ifndef STAT_H
#define STAT_H
#include <QtNetwork>
#include <QtGui>
#include "ui_stat.h"
class Stat : public QDialog, public Ui::dialog
{
Q_OBJECT
public:
Stat (const QString &host)
{
setupUi ( this );
connect (&http, SIGNAL( requestFinished(int,bool)),this,SLOT(end()));
connect ( statButton, SIGNAL ( clicked ( ) ), this, SLOT ( send ( ) ) );
http.setHost ( host, QHttp::ConnectionModeHttps );
}
void sendData (const QString &input1, const QString &input2 )
{
data.append ( "FindUserName=");
data.append (input1);
data.append ( "&FindUserPass=");
data.append ( input2 );
outFile .setFileName ( "out.html" );
outFile.open (QIODevice:: WriteOnly | QIODevice::Truncate);
QSslSocket *socket = new QSslSocket;
socket->connectToHostEncrypted ( "stat.ultranet.ru", 443 );
if ( socket->waitForEncrypted ( 5000) )
{
http.setSocket ( socket );
QHttpRequestHeader header ( "POST", "/index.php" );
header.setValue ( "Content-Type", "application/x-www-form-urlencoded" );
header.setValue ( "Host", "stat.ultranet.ru" );
http.request ( header, data, &outFile );
}
}
public slots:
void end( )
{
outFile.close ( );
emit done();
}
void send ( )
{
sendData ( loginLineEdit ->text( ), passwLineEdit ->text( ) ) ;
}
signals:
void done( );
private:
QFile outFile;
QHttp http;
QByteArray data;
};
#endif