#include "mainwindow.h"#include "ui_mainwindow.h"bool MainWindow::stop_bool = false;MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); helper = new helperClass; net = new as_network; startSettings();}MainWindow::~MainWindow(){ delete ui;}void MainWindow::changeEvent(QEvent *e){ QMainWindow::changeEvent(e); switch (e->type()) { case QEvent::LanguageChange: ui->retranslateUi(this); break; default: break; }}void MainWindow::logPassTime(){ ui->label_5->setText("Запущено!"); stop_bool = false; saveSettings(); QString tmp1; QString tmp2; QString tmp3; QString uid; QString cookie; l: login = ui->lineEdit->text(); password = ui->lineEdit_2->text(); time = ui->doubleSpinBox->value() * 60000; xByte = net->load("http://awmproxy.com/user.php")->setPost("uname=" + login + "&pass=" + password + "&rememberme=On&op=login")->setRef("http://awmproxy.com/")->exec(); if(stop_bool){ ui->label_5->setText("Остановлено!"); return;} cookie = net->getCookie(); xByte = net->load("http://awmproxy.com/cabinet.php")->setRef("http://awmproxy.com/user.php")->setCookie(cookie)->exec(); if(stop_bool){ ui->label_5->setText("Остановлено!"); return;} while(!stop_bool) //вот этот цикл { if(stop_bool){ ui->label_5->setText("Остановлено!"); return;} xByte = net->load("http://awmproxy.com/edituser.php")->setRef("http://awmproxy.com/cabinet.php")->setCookie(cookie)->exec(); tmp1 = helper->regex("IpSocksAccess\\[\\]\" value=\"([.0-9]*)", xByte); tmp2 = helper->regex("You IP:([.0-9]*)", xByte); qDebug() << tmp1; qDebug() << tmp2; if(tmp1 != tmp2) { uid = helper->regex("uid' value='(\\d+)", xByte); qDebug() << uid; net->load("http://awmproxy.com/edituser.php")->setCookie(cookie)->setPost("IpSocksAccess[]=" + tmp2 + "+&op=savesocksconfig&uid=" + uid)->setRef("http://awmproxy.com/edituser.php")->exec(); ui->label_5->setText("Изменено: " + tmp2); } else { if(tmp1.isEmpty() || tmp2.isEmpty()) { ui->label_5->setText("Перелогиниваемся!"); helper->mySleep(10000); goto l; } else ui->label_5->setText("Остался прежним: " + tmp2); } helper->mySleep(time); } ui->label_5->setText("Остановлено!");}
#include "mainwindow.h"#include "ui_mainwindow.h"bool MainWindow::stop_bool = false;MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); helper = new helperClass; net = new as_network; startSettings();}MainWindow::~MainWindow(){ delete net; delete helper; delete ui;}void MainWindow::changeEvent(QEvent *e){ QMainWindow::changeEvent(e); switch (e->type()) { case QEvent::LanguageChange: ui->retranslateUi(this); break; default: break; }}void MainWindow::saveSettings(){ helper->file_save("settings.ini", "---login---" + ui->lineEdit->text().toAscii() + "\n---password---" + ui->lineEdit_2->text().toAscii() + "\n---time---" + QString::number(ui->doubleSpinBox->value()).toAscii());}void MainWindow::startSettings(){ QString tmp = helper->file_read("settings.ini"); ui->lineEdit->setText(helper->regex("---login---([^\n]*)\n", tmp)); ui->lineEdit_2->setText(helper->regex("---password---([^\n]*)\n", tmp)); ui->doubleSpinBox->setValue(helper->regex("---time---(.+)", tmp).toDouble());}void MainWindow::stop(){ stop_bool = true; helper->loop2.quit(); net->loop.quit();}void MainWindow::logPassTime(){ ui->label_5->setText("Запущено!"); stop_bool = false; saveSettings(); QString tmp1; QString tmp2; QString uid; QString cookie; l: login = ui->lineEdit->text(); password = ui->lineEdit_2->text(); time = ui->doubleSpinBox->value() * 60000; xByte = net->load("http://awmproxy.com/user.php")->setPost("uname=" + login + "&pass=" + password + "&rememberme=On&op=login")->setRef("http://awmproxy.com/")->exec(); if(stop_bool){ ui->label_5->setText("Остановлено!"); return;} cookie = net->getCookie(); xByte = net->load("http://awmproxy.com/cabinet.php")->setRef("http://awmproxy.com/user.php")->setCookie(cookie)->exec(); if(stop_bool){ ui->label_5->setText("Остановлено!"); return;} while(!stop_bool) { if(stop_bool){ ui->label_5->setText("Остановлено!"); return;} xByte = net->load("http://awmproxy.com/edituser.php")->setRef("http://awmproxy.com/cabinet.php")->setCookie(cookie)->exec(); tmp1 = helper->regex("IpSocksAccess\\[\\]\" value=\"([.0-9]*)", xByte); tmp2 = helper->regex("You IP:([.0-9]*)", xByte); qDebug() << tmp1; qDebug() << tmp2; if(tmp1 != tmp2) { uid = helper->regex("uid' value='(\\d+)", xByte); qDebug() << uid; net->load("http://awmproxy.com/edituser.php")->setCookie(cookie)->setPost("IpSocksAccess[]=" + tmp2 + "+&op=savesocksconfig&uid=" + uid)->setRef("http://awmproxy.com/edituser.php")->exec(); ui->label_5->setText("Изменено: " + tmp2); } else { if(tmp1.isEmpty() || tmp2.isEmpty()) { ui->label_5->setText("Перелогиниваемся!"); helper->mySleep(10000); goto l; } else ui->label_5->setText("Остался прежним: " + tmp2); } helper->mySleep(time); } ui->label_5->setText("Остановлено!");}
#ifndef MAINWINDOW_H#define MAINWINDOW_H#include <QtGui>#include <QtCore>#include "helper.h"#include "as_network.h"namespace Ui { class MainWindow;}class MainWindow : public QMainWindow{ Q_OBJECTpublic: MainWindow(QWidget *parent = 0); ~MainWindow(); static bool stop_bool; QString login; QString password; double time; QByteArray xByte; helperClass* helper; as_network* net; void saveSettings(); void startSettings();protected: void changeEvent(QEvent *e);private: Ui::MainWindow *ui;private slots: void logPassTime(); void stop();};#endif // MAINWINDOW_H
#include <QtGui>#include "mainwindow.h"int main(int argc, char *argv[]){ QApplication a(argc, argv); QTextCodec::setCodecForTr(QTextCodec::codecForName("windows-1251")); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("windows-1251")); MainWindow w; w.show(); return a.exec();}
connect(this, SIGNAL(close()),this, SLOT(stop()))