int main() //Main Function { user tempUser; scrap tempScrap; int choice, i; struct stat st = {0}; if(stat("data/scrapbook", &st) == -1) mkdir("data/scrapbook", 0700); if(stat("data/scrapbook/users", &st) == -1) mkdir("data/scrapbook/users", 0700); while(1) { printf("\n1. Login\n2. Create Account\n3.Exit\n :"); scanf("%d", &choice); if(choice == 3) //Exit the program return 0; else if(choice == 2) //Create a new account { printf("\nEnter your Name : "); scanf(" %[^\n]", tempUser.name); do { printf("\nEnter a Username : "******"%s", tempUser.username); }while(!isUsernameValid(tempUser.username)); printf("\nEnter a password : "******"%s", tempUser.password); tempUser.uID = getNewUID(); addUserToFile(tempUser); printf("\nAccount Created\n"); } else if(choice == 1) //Login { i = 0; do { if(i > 2) //Exit if user tries to login greater than 3 times return 0; printf("\nUsername : "******"%s", tempUser.username); printf("\nPassword : "******"%s", tempUser.password); i++; }while(!checkLogin(tempUser.username, tempUser.password)); session(getInfo(checkLogin(tempUser.username, tempUser.password))); } else printf("\nWrong Choice!"); } return 0; }
int main (int argc, char ** argv) { checkOpt(argc, argv); if (checkLogin() == 1) { startCalculator(); } return 0; }
void FileDefend::login(const QString &username, const QString &password) { QString data = QString("op=login&login=%1&password=%2").arg(username).arg(password); QUrl url("http://filedefend.com/"); QNetworkRequest request(url); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); QNetworkReply *reply = this->networkAccessManager()->post(request, data.toUtf8()); this->connect(reply, SIGNAL(finished()), this, SLOT(checkLogin())); this->connect(this, SIGNAL(currentOperationCancelled()), reply, SLOT(deleteLater())); }
void MegaShares::login(const QString &username, const QString &password) { QString data = QString("mymslogin_name=%1&mymspassword=%2").arg(username).arg(password); QUrl url("http://d01.megashares.com/myms_login.php"); QNetworkRequest request(url); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); QNetworkReply *reply = this->networkAccessManager()->post(request, data.toUtf8()); this->connect(reply, SIGNAL(finished()), this, SLOT(checkLogin())); this->connect(this, SIGNAL(currentOperationCancelled()), reply, SLOT(deleteLater())); }
void PublishToMePlugin::login(const QString &username, const QString &password) { m_redirects = 0; const QString data = QString("LoginForm[username]=%1&LoginForm[password]=%2").arg(username).arg(password); QNetworkRequest request(LOGIN_URL); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); request.setRawHeader("X-Requested-With", "XMLHttpRequest"); QNetworkReply *reply = networkAccessManager()->post(request, data.toUtf8()); connect(reply, SIGNAL(finished()), this, SLOT(checkLogin())); connect(this, SIGNAL(currentOperationCanceled()), reply, SLOT(deleteLater())); }
void FileBoom::login(const QString &username, const QString &password) { QString data = QString("LoginForm[username]=%1&LoginForm[password]=%2").arg(username).arg(password); QUrl url("http://fboom.net/login.html"); QNetworkRequest request(url); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); request.setRawHeader("X-Requested-With", "XMLHttpRequest"); QNetworkReply *reply = this->networkAccessManager()->post(request, data.toUtf8()); this->connect(reply, SIGNAL(finished()), this, SLOT(checkLogin())); this->connect(this, SIGNAL(currentOperationCancelled()), reply, SLOT(deleteLater())); }
void MybbFeedRequest::login(const QUrl &url, const QString &username, const QString &password) { #ifdef MYBB_DEBUG qDebug() << "MybbFeedRequest::login(). URL:" << url << "Username:"******"Password:"******"quick_username=%1&quick_password=%2&s=&action=do_login&quick_login=1&submit=Login").arg(username).arg(password); QNetworkRequest request(url); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); request.setRawHeader("User-Agent", USER_AGENT); QNetworkReply *reply = networkAccessManager()->post(request, data.toUtf8()); connect(reply, SIGNAL(finished()), this, SLOT(checkLogin())); connect(this, SIGNAL(finished(FeedRequest*)), reply, SLOT(deleteLater())); }
void MybbFeedRequest::checkLogin() { QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender()); if (!reply) { setErrorString(tr("Network error")); setStatus(Error); emit finished(this); return; } QString redirect = getRedirect(reply); if (!redirect.isEmpty()) { reply->deleteLater(); if (m_redirects < MAX_REDIRECTS) { followRedirect(redirect, SLOT(checkLogin())); } else { setErrorString(tr("Maximum redirects reached")); setStatus(Error); emit finished(this); } return; } switch (reply->error()) { case QNetworkReply::NoError: #ifdef MYBB_DEBUG qDebug() << "MybbFeedRequest::checkLogin(). OK"; #endif getPage(m_settings.value("url").toString()); reply->deleteLater(); break; case QNetworkReply::OperationCanceledError: setErrorString(QString()); setStatus(Canceled); emit finished(this); break; default: #ifdef MYBB_DEBUG qDebug() << "MybbFeedRequest::checkLogin(). Error"; #endif setErrorString(reply->errorString()); setStatus(Error); emit finished(this); break; } }
void HttpServer::handlePost(HttpClientHandler* hdlr,const QHttpRequestHeader & hdr,const QByteArray & data) { // this is either a file or a login if (hdr.value("Content-Type").startsWith("multipart/form-data")) { handleTorrentPost(hdlr,hdr,data); } else if (!checkLogin(hdr,data)) { QHttpRequestHeader tmp = hdr; tmp.setRequest("GET","/login.html",1,1); handleGet(hdlr,tmp); } else { handleGet(hdlr,hdr,true); } }
Registration::Registration(QWidget *parent) : QMainWindow(parent), ui(new Ui::Registration) { ui->setupUi(this); QRect frect = frameGeometry(); frect.moveCenter(QDesktopWidget().availableGeometry().center()); move(frect.topLeft()); this->setMaximumSize(406,220); ui->edit_haslo->setEchoMode(QLineEdit::Password); ui->edit_haslo2->setEchoMode(QLineEdit::Password); connect(ui->edit_haslo2,SIGNAL(textEdited(QString)),this,SLOT(passwdCmp())); connect(ui->edit_email,SIGNAL(textEdited(QString)),this,SLOT(checkEmail())); connect(ui->edit_login,SIGNAL(textEdited(QString)),this,SLOT(checkLogin())); connect(ui->button_cancel,SIGNAL(clicked()),this,SLOT(anuluj())); connect(ui->button_register,SIGNAL(clicked()),this,SLOT(rejestruj())); }
/** * shell function */ int shell() { debug("shell init"); checkLogin(); char input[MAXLENGTH]; for (;;) { printf("%s>", getUser()); read_line(input); if (sequals(input, "exit")) { debug("shut down"); shellExit(); } else if (begins(input, "set ")) { debug("exec set cmd"); parseSet(input + 4); } else if (begins(input, "list ")) { debug("exec list cmd"); parseList(input + 5); } else if (begins(input, "search ")) { debug("exec find cmd from search"); find(input + 7); } else if (begins(input, "find ")) { debug("exec find cmd"); find(input + 5); } else if (begins(input, "buy ")) { debug("exec buy cmd"); buy(input + 4); } else if (begins(input, "help")) { debug("exec help cmd"); printInternHelp(); } else if (begins(input, "balance")) { debug("exec balance cmd"); balanceUser(); } else { debug("no match found in shell"); printf("Don't know what you mean...\n"); } } return 0; }
login() { flag=0; fp_register = fopen ("register.csv", "r"); /* registration file */ /* tokenizing the recieved string */ pch = strtok(buf," "); /* command */ pch = strtok(NULL,","); /* username */ pch1 = strtok(NULL,","); /* password */ pch2 = strtok(NULL,","); /* user IP */ while ((fscanf(fp_register, "%s", str))!=EOF) { /* tokenizing the string read from file 'register.csv' */ fch = strtok(str,","); /* username */ fch1= strtok(NULL,","); /* password */ fch2= strtok(NULL,","); /* nickname */ /* validating the log in cofidentials */ if((strcmp(pch,fch)==0)&& (strcmp(pch1,fch1)==0)) { flag=1; checkLogin(fch2,cli_addr); /* modifying the structure */ break; } } if(flag ==1) { strcpy(str,"cmd Welcome "); strcat(str,fch2); strcat(str,",1,"); /* indexing logged in state */ } else { strcpy(str,"cmd LOGIN UNSUCCESSFUL"); strcat(str,",0,"); } fclose(fp_register); }
// Пройти аутентификацию int passAuthentication(struct Connection *connection) { switch (connection->auth.status) { case LOGIN_REQUEST: requestLogin(connection); break; case LOGIN_CHECK: checkLogin(connection); break; case PASSWORD_REQUEST: requestPassword(connection); break; case PASSWORD_CHECK: checkPassword(connection); break; default: fprintf(stderr, "Error: wrong authentication status of connectionfd %d\n", connection->connectionfd); return -1; } return 0; }
void initialise( const String& commandLine ) { try { // Initialize logger String appName(getApplicationName()); _logger = FileLogger::createDefaultAppLogger(appName, appName + "Log.txt", appName + " " + getApplicationVersion()); Logger::setCurrentLogger(_logger); Log::write("Initializing..."); // Setup app context AppContext::getInstance()->initialise(); // Load default skin //File skinpath = File::getCurrentWorkingDirectory().getChildFile("Skins/Default/"); //SkinManager::getInstance()->initialise( skinpath ); // *** TODO: This is temp test code that needs to be changed! // Login dialog should not be shown here. User needs to add music services and // we will try to login to all of them at this point without any prompt. checkLogin(); // Initialize main window _mainWindow = new MainWindow(); //_mainWindow->centreWithSize(350, 170); //_mainWindow->setVisible(true); // Testing the animator //_animator = new ComponentAnimator(); //_animator->animateComponent(_mainWindow, Rectangle(_mainWindow->getX(), _mainWindow->getY(), 500, 600), 1000, 3, 0); Log::write("Entering main loop"); } catch(Exception& ex) { if(_logger != NULL) Log::write(ex.getFullMessage()); quit(); } }
void Registration::rejestruj() { if(checkLogin() && checkEmail() && passwdCmp()) { QByteArray haslo = ui->edit_haslo->text().toUtf8(); QCryptographicHash *hash = new QCryptographicHash(QCryptographicHash::Md5); hash->addData(haslo); QSqlQuery zapytanie("INSERT INTO users(login, password, email) VALUES ('"+ ui->edit_login->text()+"','"+hash->result().toHex()+"','"+ui->edit_email->text()+"');"); this->close(); if(zapytanie.numRowsAffected()!=0) { QMessageBox::information(0,"rejestracja","dodano nowego uzytkownika\n zalogowano automatycznie"); Wydatnik::getInstance()->zaloguj(ui->edit_login->text(),hash->result().toHex()); } else { QMessageBox::warning(0,"rejestracja","rejestracja nie powiodla sie"); } } else Wydatnik::getInstance()->Error("Podano niepoprawne dane"); }
int AccountAccessor::userLogin(const LoginInfo & info){ //0: ERROR //1: SUCCESS //1st check if that account has login if (!checkAuthentication(info)) return 0; if (!checkLogin(info.username)) return 0; //open file AccountOnline.txt to write new username ofstream outfile; outfile.open(_ONL_USR, ios::app); if (!outfile){ cerr << "WRITE INFO TO FILE ERROR!!!" << endl; outfile.close(); return 0; } //write username into OnlineAccount.txt outfile << info.username << endl; /////////////////////////////////////// cout << "LOGIN SUCCESSFUL!!!" << endl; outfile.close(); return 1; }
void LoginWidget::displayButton() { QPushButton *signupButton = new QPushButton(tr("Sign Up"), this); QPushButton *displayIP = new QPushButton(tr("Expert mode"), this); displayIP->setStyleSheet("background-color: #1DAEF1"); _buttons->addButton(QDialogButtonBox::Ok); _buttons->addButton(QDialogButtonBox::Cancel); _buttons->addButton(displayIP, QDialogButtonBox::ActionRole); _buttons->addButton(signupButton, QDialogButtonBox::ActionRole); _buttons->button(QDialogButtonBox::Ok)->setText(tr("Login")); _buttons->button(QDialogButtonBox::Cancel)->setText(tr("Cancel")); connect(_buttons->button(QDialogButtonBox::Cancel), SIGNAL(released()), this, SLOT(close())); connect(_buttons->button(QDialogButtonBox::Ok), SIGNAL(released()), this, SLOT(checkLogin())); connect(signupButton, SIGNAL(released()), this, SLOT(signup())); connect(displayIP, SIGNAL(released()), this, SLOT(displayIPFunction())); _mainLayout->addWidget(_buttons, 3, 0, 1, 2); }
void CTable::tableLogin(SOCKET sd, CpduLogin* loginPdu) { bool loginOk = true; u_int32_t ipaddr = 0; // Is there a valid login entry for the player? If not, // he could be trying to log in directly and not via lounge LoginEntries::iterator pos = loginEntries_.find(loginPdu->getUsername()); if (pos == loginEntries_.end()) { #ifdef ALLOW_DIRECT_LOGINS_ #pragma message("Allowing direct logins!!!") // WILL ALLOW DIRECT LOGINS #else char s[200]; sprintf(s, "Login rejected: no login entry for user %s", loginPdu->getUsername()); Sys_LogError(s); loginOk = false; #endif } else { ipaddr = (*pos).second.ipaddr_; // player is logging in, remove his entry loginEntries_.erase(pos); } // In theory we didn't need to do these checks here // because they're done when the lounge server asks // whether the login is ok. Do the check just in case // someone finds a way to log in to table without // the lounge server. if (loginOk) loginOk = checkLogin(ipaddr, loginPdu->getUsername()); if (!loginOk || !dbase_->authenticate(loginPdu->getUsername(), loginPdu->getPassword())) { // Send Table Reject PDU CpduLoginReject pdu; pdu.sendReject(sd); // Terminate the connection CPoller::Instance()->removeClient(sd); } else { CPlayer* newPlayer = NULL; // Add player to table SingleLock l(&tableMutex_); if (l.lock()) { newPlayer = getUnusedPlayer(loginPdu->getUsername()); if (newPlayer) { // In tournaments there is a small window during which a // player may succeed logging in twice because the first // login does not "reanimate the zombie" immediately. // This check prevents it from happening. if (CTournament::Inst()->isTournament() && checkDoubleLogin(loginPdu->getUsername(), newPlayer)) { // Send Table Reject PDU CpduLoginReject pdu; pdu.sendReject(sd); // Terminate the connection CPoller::Instance()->removeClient(sd); return; } newPlayer->setPlayer(sd, loginPdu->getUsername(), loginPdu->getPassword(), CChips(), // 0 chips until he buys in ipaddr); newPlayer->setIsFreeSeat(false); newPlayer->setReanimate(true); string city; if (dbase_->getCity(loginPdu->getUsername(), city)) { newPlayer->setCity(city.c_str()); } if (countPlayers(PLAYER_STATE_PLAYING|PLAYER_STATE_WAITING) >= 1 && countPlayersRaw(false) > 2 && !CTournament::Inst()->isTournament()) // XXX Fix tournament double big blind bug { // a game is in progress - must charge 'new player's blind' newPlayer->setMissedBlind(getLo()); } CpduPlayerInfo myPlayerInfoPdu(this); CpduBuyinQuery myBuyinQueryPdu(this); // Send Player Info PDU myPlayerInfoPdu.sendPlayerInfo(newPlayer); if (CTournament::Inst()->isTournament()) { char buf[100]; sprintf(buf, "Player %s logged in", newPlayer->getUsername()); Sys_LogTournament(buf); CTournament* t = CTournament::Inst(); CChips lo(DEFAULT_LOW), hi(DEFAULT_HI); t->getLimits(lo, hi); // Send current game type & limits CpduTournamentParams params; params.sendParams(newPlayer, TF_GameType, t->getGameType(), t->isHiLo() ? 1 : 0); params.sendParams(newPlayer, TF_Limit, lo.getRep(), hi.getRep()); // In tournament there is automatic buy-in when // players are seated if (newPlayer->matchState(PLAYER_STATE_UNUSED|PLAYER_STATE_LOGGEDIN)) newPlayer->stateChange(PLAYER_STATE_BOUGHTIN); } else { // Send buy in query myBuyinQueryPdu.sendBuyinQuery(newPlayer); } // Send table update to lounge server if (CLoungeServer* ls = CLoungeServer::Inst()) { ls->sendPlayerSeated(newPlayer->getUsername()); ls->sendTableUpdate(countPlayersRaw()); } } } if (!newPlayer) { // no room for player! CPoller::Instance()->removeClient(sd); } } }
void CredentialsValidator::validate(const QString &login, const QString &password, const QString &confirmedPassword) const { checkLogin(login); checkPassword(password); checkConfirmedPassword(password, confirmedPassword); }
WLogin::WLogin(QWidget *parent) : QDialog(parent) { //main widget setup installEventFilter(this); this->setWindowFlags(Qt::FramelessWindowHint); this->setAttribute( Qt::WA_TranslucentBackground, true); this->setObjectName("LoginWindow"); //components new loginBgLabel = new QLabel(this); regBgLabel = new QLabel(this); userName = new QLineEdit(this); password = new QLineEdit(this); passwordConfirm = new QLineEdit(this); idCard = new QLineEdit(this); cardNum = new QLineEdit(this); mobile = new QLineEdit(this); email = new QLineEdit(this); address = new QLineEdit(this); zipcode = new QLineEdit(this); notice = new QLabel(this); closeBtn = new QPushButton(this); regBtn = new QPushButton(tr("Register"), this); loginBtn = new QPushButton(tr("Login"), this); registerBtn = new QPushButton(tr("Register"), this); backBtn = new QPushButton(tr("Go Back"), this); //set object name loginBgLabel->setObjectName("LogInBG"); regBgLabel->setObjectName("RegBG"); userName->setObjectName("LogInUser"); password->setObjectName("LogInPW"); passwordConfirm->setObjectName("RegPWConfirm"); idCard->setObjectName("RegIDCard"); cardNum->setObjectName("RegCardNum"); mobile->setObjectName("RegMobile"); email->setObjectName("RegEmail"); address->setObjectName("RegAddress"); zipcode->setObjectName("RegZipcode"); notice->setObjectName("LogInNotice"); closeBtn->setObjectName("LogInClose"); regBtn->setObjectName("LogInReg"); loginBtn->setObjectName("LogInLogIn"); registerBtn->setObjectName("RegRegister"); backBtn->setObjectName("RegBack"); //set position and size loginBgLabel->setGeometry(QRect(0, 0, 400, 678)); regBgLabel->setGeometry(QRect(0, 0, 400, 678)); userName->setGeometry(QRect(41, 198, 200, 36)); password->setGeometry(QRect(41, 246, 200, 36)); passwordConfirm->setGeometry(QRect(41, 286, 318, 36)); idCard->setGeometry(QRect(41, 334, 318, 36)); cardNum->setGeometry(QRect(41, 384, 318, 36)); mobile->setGeometry(QRect(41, 430, 318, 36)); email->setGeometry(QRect(41, 478, 318, 36)); address->setGeometry(QRect(41, 526, 318, 36)); zipcode->setGeometry(QRect(41, 574, 318, 36)); notice->setGeometry(QRect(41, 182, 294, 16)); closeBtn->setGeometry(QRect(375, 12, 10, 15)); regBtn->setGeometry(QRect(263, 202, 96, 36)); loginBtn->setGeometry(QRect(263, 244, 96, 36)); registerBtn->setGeometry(QRect(263, 626, 96, 36)); backBtn->setGeometry(QRect(167, 626, 96, 36)); //hide the registration buttons loginBgLabel->setVisible(true); regBgLabel->setVisible(false); regBtn->setVisible(true); loginBtn->setVisible(true); passwordConfirm->setVisible(false); idCard->setVisible(false); cardNum->setVisible(false); mobile->setVisible(false); email->setVisible(false); address->setVisible(false); zipcode->setVisible(false); registerBtn->setVisible(false); backBtn->setVisible(false); //set place holder text userName->setPlaceholderText(tr("Username")); password->setPlaceholderText(tr("Password")); idCard->setPlaceholderText(tr("ID Number")); passwordConfirm->setPlaceholderText(tr("Confirm Password")); cardNum->setPlaceholderText(tr("Card Number")); mobile->setPlaceholderText(tr("Mobile")); email->setPlaceholderText(tr("E-mail")); address->setPlaceholderText(tr("Address")); zipcode->setPlaceholderText(tr("Zipcode")); //set format notice->setAlignment(Qt::AlignCenter); password->setEchoMode(QLineEdit::Password); passwordConfirm->setEchoMode(QLineEdit::Password); userName->setFocus(); //set connections connect(password, SIGNAL(returnPressed()), this, SLOT(checkLogin())); connect(zipcode, SIGNAL(returnPressed()), this, SLOT(checkReg())); connect(registerBtn, SIGNAL(clicked(bool)), this, SLOT(checkReg())); connect(closeBtn, SIGNAL(clicked(bool)), this, SLOT(reject())); connect(regBtn, SIGNAL(clicked(bool)), this, SLOT(changeToReg())); connect(loginBtn, SIGNAL(clicked(bool)), this, SLOT(checkLogin())); connect(backBtn, SIGNAL(clicked(bool)), this, SLOT(changeToLogin())); //start opening animation openWindow(); }
//чтение данных, присланных пользователем int handlerRequest(int epollfd, int connectionfd, struct UserParams userParams, pthread_mutex_t mutex){ int buffCount = 1024; int i = 3; char *buffer = (char*) malloc(buffCount * sizeof(char)); char conBuf[4]; ssize_t count = read(connectionfd, buffer, sizeof buffer); char *ret; //динамическое выделение памяти для буфера char bufferN[buffCount]; ssize_t countN = read(connectionfd, bufferN, sizeof bufferN); while(countN > 0){ ret = (char*)realloc(buffer,i*buffCount*sizeof(char)); if(!ret){ perror("realloc"); exit(1); } strcat(buffer, bufferN); count+=countN; i++; countN = read(connectionfd, bufferN, sizeof bufferN); } switch(count){ case -1: if (errno != EAGAIN) perror ("failed to read data"); break; case 0: printf("client closed the connection"); break; default: snprintf(conBuf, 4,"%d",connectionfd); //ввод логина if(!strcmp(DictSearch(userParams.login, conBuf),"")){ if (count > 1){ char *tmpLogin = (char*) malloc(count+1); strncpy(tmpLogin, buffer, count); tmpLogin[count] = '\0'; DictInsert(userParams.login,conBuf,tmpLogin); printf("%s\n", DictSearch(userParams.login, conBuf)); dprintf(connectionfd, "Enter password: "******"Enter login: "******"0")){ char *tmpPass=(char*) malloc(count+1); strncpy(tmpPass, buffer, count); tmpPass[count] = '\0'; //вызов проверки pthread_mutex_lock(&mutex); int check = checkLogin(DictSearch(userParams.login, conBuf), tmpPass); pthread_mutex_unlock(&mutex); if(check == 1){ DictDelete(userParams.fLogin,conBuf); DictInsert(userParams.fLogin,conBuf,"1"); DictInsert(userParams.location,conBuf,"cd user_root/;"); dprintf(connectionfd, "!!Enter command: "); } else{ DictDelete(userParams.login,conBuf); DictInsert(userParams.login,conBuf,""); dprintf(connectionfd,"Enter login: "******"logout",6)) close(connectionfd); else{ int c; FILE *pp; extern FILE *popen(); char* tempCd = (char*) malloc(1024*sizeof(char)); strcpy(tempCd, DictSearch(userParams.location, conBuf)); //strcat(tempCd, ";"); printf("----->%s\n",tempCd); if ( !(pp=popen(strcat(tempCd, buffer), "r")) ){ free(tempCd); return 1; } while ( (c=fgetc(pp)) != EOF ) { putc(c, stdout); dprintf(connectionfd,"%c",c); fflush(pp); } pclose(pp); free(tempCd); printf("%d user command: %.*s", connectionfd, count, buffer); dprintf(connectionfd, "Enter command: "); } } } } free(buffer); }