#include "thewge.h"
#include "ui_thewge.h"
#include <QtGui/QApplication>
#include <QSignalMapper>
#include <QPushButton>
#include <QWidget>
#include <QTimer>
#include <QDesktopWidget>
#include <QPixmap>
#include <windows.h>
#include <iostream>
#include "md5.h"
#include "mysql++.h"
TheWGE
::TheWGE(QWidget *parent, Qt
::WFlags flags
){
ui.setupUi(this);
QObject::connect(ui.
LoginBtn,
SIGNAL(clicked
()),
this,
SLOT(login
()));
}
TheWGE::~TheWGE()
{
//ui.usrLineEdit->clear();
//ui.pwdLineEdit->clear();
}
void TheWGE::login()
{
if (ui.usrLineEdit->text().trimmed().isEmpty() )
{
ui.usrLineEdit->setFocus();
}
else if (ui.pwdLineEdit->text().trimmed().isEmpty() )
{
ui.pwdLineEdit->setFocus();
}
mysqlpp::Connection con(false);
if (!con.connect("db", "host", "user", "pass"))
{
qApp->exit(0);
}
// Query Mysql
mysqlpp::Query query = con.query();
QString Qstr1
= ui.
usrLineEdit->text
();
QString Qstr2
= ui.
pwdLineEdit->text
();
std::string acsUserName2 = Qstr1.toUtf8().data();
std::string acsPassword2 = Qstr2.toUtf8().data();
query << "SELECT username, password FROM wge_db_user WHERE username = '" << acsUserName2 << "' and password = '" << md5(acsPassword2) << "'";
mysqlpp::StoreQueryResult res = query.store();
mysqlpp::Row row;
if (res.num_rows() > 0)
{
//goodlogin - show new form and hide this form
shootScreen();
QTimer::singleShot (60000,
this,
SLOT(shootScreen
()));
}
else
{
//badlogin- code more here laterrrrrrrrr
qApp->exit(0);
}
mysqlpp::Connection::thread_end();
return;
}
void TheWGE::shootScreen()
{
originalPixmap.save("test.jpeg");
}
#include "thewge.h"
#include "ui_thewge.h"
#include <QtGui/QApplication>
#include <QSignalMapper>
#include <QPushButton>
#include <QWidget>
#include <QTimer>
#include <QDesktopWidget>
#include <QPixmap>
#include <windows.h>
#include <iostream>
#include "md5.h"
#include "mysql++.h"
TheWGE::TheWGE(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
QObject::connect(ui.LoginBtn, SIGNAL(clicked()), this, SLOT(login()));
}
TheWGE::~TheWGE()
{
//ui.usrLineEdit->clear();
//ui.pwdLineEdit->clear();
}
void TheWGE::login()
{
if (ui.usrLineEdit->text().trimmed().isEmpty() )
{
ui.usrLineEdit->setFocus();
}
else if (ui.pwdLineEdit->text().trimmed().isEmpty() )
{
ui.pwdLineEdit->setFocus();
}
mysqlpp::Connection con(false);
if (!con.connect("db", "host", "user", "pass"))
{
qApp->exit(0);
}
// Query Mysql
mysqlpp::Query query = con.query();
QString Qstr1 = ui.usrLineEdit->text();
QString Qstr2 = ui.pwdLineEdit->text();
std::string acsUserName2 = Qstr1.toUtf8().data();
std::string acsPassword2 = Qstr2.toUtf8().data();
query << "SELECT username, password FROM wge_db_user WHERE username = '" << acsUserName2 << "' and password = '" << md5(acsPassword2) << "'";
mysqlpp::StoreQueryResult res = query.store();
mysqlpp::Row row;
if (res.num_rows() > 0)
{
//goodlogin - show new form and hide this form
shootScreen();
QTimer::singleShot (60000, this, SLOT(shootScreen()));
}
else
{
//badlogin- code more here laterrrrrrrrr
qApp->exit(0);
}
mysqlpp::Connection::thread_end();
return;
}
void TheWGE::shootScreen()
{
QPixmap originalPixmap;
originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId());
originalPixmap.save("test.jpeg");
}
To copy to clipboard, switch view to plain text mode
Bookmarks