void UserCfgDlg::Build () // build the update record - the insert needs the name record addedivityLled int2);, tion text,repprint int2);ate text); { GetConfigureDb ()->ClearRecord (); // clear the record if(Password->text() != tr(NONE_STR)) { GetConfigureDb ()->AddToRecord ("PSSWORD", EncodePassword(Password->text ())); }; GetConfigureDb ()->AddToRecord ("COMMENT", Comment->text ()); GetConfigureDb ()->AddToRecord ("LANGUAGE", Language->currentText ()); GetConfigureDb ()->AddToRecord("EXPIREDAYS",AgeDays->text()); // // get the privs mask if (AllPriv->isChecked ()) { GetConfigureDb ()->AddToRecord ("PRIVS", "-1", false); } else { int p = 0; // p = (ReportsPriviledge->isChecked ()? PRIVS_REPORTS : 0) | (AlarmAckPriv->isChecked ()? PRIVS_ACK_ALARMS : 0) | (ReportsPriv->isChecked ()? PRIVS_REPORT_MAKE : 0) | (AgePassword->isChecked()?PRIVS_AGE_PASSWORD:0) | (FactoryAdministrator->isChecked()?PRIVS_FACTORY_ADMIN:0) | (ExitApp->isChecked()? PRIVS_CAN_EXIT:0) ; // QString s; s.setNum (p); GetConfigureDb ()->AddToRecord ("PRIVS", s, false); // }; };
void WriteGameSetup(int32_t scripthandle) { int dummy; dummy = gs.BorderNum; SCRIPT_PutNumber(scripthandle, "Options", "BorderNum",dummy,FALSE,FALSE); dummy = gs.Brightness; SCRIPT_PutNumber(scripthandle, "Options", "Brightness",dummy,FALSE,FALSE); dummy = gs.BorderTile; SCRIPT_PutNumber(scripthandle, "Options", "BorderTile",dummy,FALSE,FALSE); dummy = gs.Bobbing; SCRIPT_PutNumber(scripthandle, "Options", "Bobbing",dummy,FALSE,FALSE); dummy = gs.Tilting; SCRIPT_PutNumber(scripthandle, "Options", "Tilting",dummy,FALSE,FALSE); dummy = gs.Shadows; SCRIPT_PutNumber(scripthandle, "Options", "Shadows",dummy,FALSE,FALSE); dummy = gs.AutoRun; SCRIPT_PutNumber(scripthandle, "Options", "AutoRun",dummy,FALSE,FALSE); dummy = gs.Crosshair; SCRIPT_PutNumber(scripthandle, "Options", "Crosshair",dummy,FALSE,FALSE); dummy = gs.AutoAim; SCRIPT_PutNumber(scripthandle, "Options", "AutoAim",dummy,FALSE,FALSE); dummy = gs.Messages; SCRIPT_PutNumber(scripthandle, "Options", "Messages",dummy,FALSE,FALSE); dummy = gs.Talking; SCRIPT_PutNumber(scripthandle, "Options", "Talking",dummy,FALSE,FALSE); dummy = gs.Ambient; SCRIPT_PutNumber(scripthandle, "Options", "Ambient",dummy,FALSE,FALSE); dummy = gs.FxOn; SCRIPT_PutNumber(scripthandle, "Options", "FxOn",dummy,FALSE,FALSE); dummy = gs.MouseAimingType; SCRIPT_PutNumber(scripthandle, "Controls", "MouseAiming",dummy,FALSE,FALSE); dummy = gs.MusicOn; SCRIPT_PutNumber(scripthandle, "Options", "MusicOn",dummy,FALSE,FALSE); dummy = gs.NetGameType; SCRIPT_PutNumber(scripthandle, "Options", "NetGameType",dummy,FALSE,FALSE); dummy = gs.NetLevel; SCRIPT_PutNumber(scripthandle, "Options", "NetLevel",dummy,FALSE,FALSE); dummy = gs.NetMonsters; SCRIPT_PutNumber(scripthandle, "Options", "NetMonsters",dummy,FALSE,FALSE); dummy = gs.NetHurtTeammate; SCRIPT_PutNumber(scripthandle, "Options", "NetHurtTeammate",dummy,FALSE,FALSE); dummy = gs.NetSpawnMarkers; SCRIPT_PutNumber(scripthandle, "Options", "NetSpawnMarkers",dummy,FALSE,FALSE); dummy = gs.NetTeamPlay; SCRIPT_PutNumber(scripthandle, "Options", "NetTeamPlay",dummy,FALSE,FALSE); dummy = gs.NetKillLimit; SCRIPT_PutNumber(scripthandle, "Options", "NetKillLimit",dummy,FALSE,FALSE); dummy = gs.NetTimeLimit; SCRIPT_PutNumber(scripthandle, "Options", "NetTimeLimit",dummy,FALSE,FALSE); dummy = gs.NetColor; SCRIPT_PutNumber(scripthandle, "Options", "NetColor",dummy,FALSE,FALSE); dummy = gs.Voxels; SCRIPT_PutNumber(scripthandle, "Options", "Voxels",dummy,FALSE,FALSE); dummy = gs.MouseAimingOn; SCRIPT_PutNumber(scripthandle, "Options", "MouseAimingOn",dummy,FALSE,FALSE); dummy = gs.MouseInvert; SCRIPT_PutNumber(scripthandle, "Options", "MouseInvert",dummy,FALSE,FALSE); dummy = gs.Stats; SCRIPT_PutNumber(scripthandle, "Options", "Stats",dummy,FALSE,FALSE); EncodePassword(gs.Password); SCRIPT_PutString(scripthandle, "Options","Rooster",gs.Password); DecodePassword(gs.Password); dummy = gs.ParentalLock; SCRIPT_PutNumber(scripthandle, "Options", "Kiwi",dummy,FALSE,FALSE); dummy = gs.PlayCD; SCRIPT_PutNumber(scripthandle, "Options", "PlayCD",dummy,FALSE,FALSE); SCRIPT_PutNumber(scripthandle, "Options", "CDDevice",0,FALSE,FALSE); if (SW_SHAREWARE) { dummy = GamePlays; SCRIPT_PutNumber(scripthandle, "Options", "Chickens",dummy,FALSE,FALSE); } }
void LoginDlg::QueryResponse(QObject *p,const QString &,int id, QObject*caller) // response to database search { IT_IT("LoginDlg::QueryResponse"); if((p == this) && (id == tGet)) { if(GetConfigureDb()->GetNumberResults() == 1) { QString str = GetConfigureDb()->GetString("PSSWORD"); if(str == tr(NONE_STR)) // blank password handling - on start up { NewPassword dlg(this); // change the password if(dlg.exec()) { QString cmd = "update USERS set PSSWORD='"+EncodePassword(dlg.Password1->text().stripWhiteSpace())+ "',UPDTIME=" + DATETIME_NOW + " where NAME='"+ Username->text().stripWhiteSpace()+"';"; GetConfigureDb()->DoExec(0,cmd,0); // update the database // #ifdef UNIX char hn[32]; hn[0] = 0; gethostname(hn,sizeof(hn)); QString msg = Username->text() + tr(" has changed password ") + QString(hn) + " display=" + QString(getenv("DISPLAY")); #else char computer_name[ MAX_PATH ]; ZeroMemory( computer_name, sizeof( computer_name ) ); DWORD size = MAX_PATH; ::GetComputerName( computer_name, &size ); QString msg = Username->text() + tr(" has changed password ") + QString(computer_name); #endif QSLogEvent("HMI",msg); //DOAUDIT(tr("Password Changed")); // Username->setText(""); Password->setText(""); return; // exit for re entry } } QString entered_pwd = EncodePassword(Password->text()); QString stored_pwd = GetConfigureDb()->GetString("PSSWORD"); if(entered_pwd == stored_pwd) { UserDetails &u = GetUserDetails(); u.Name = Username->text().stripWhiteSpace(); // user name u.Language = GetConfigureDb()->GetString("LANGUAGE"); // what language do we speak u.AmSystem = false; // are we system admin - not to start with u.privs = GetConfigureDb()->GetString("PRIVS").toLong(); // privelge mask if(u.privs & PRIVS_AGE_PASSWORD) { QDateTime t = GetConfigureDb()->GetDateTime("UPDTIME"); // get the update time - from this we determine if the password is // // out of date // t = t.addDays(GetConfigureDb()->GetInt("EXPIREDAYS")); // if(t < QDateTime::currentDateTime()) // is the password out of date { NewPassword dlg(this); // change the password // // if(!dlg.exec()) { Username->setText(""); Password->setText(""); return; } else { QString cmd = "update USERS set PSSWORD='"+EncodePassword(dlg.Password1->text().stripWhiteSpace()) +"',UPDTIME=" + DATETIME_NOW + " where NAME='"+ u.Name+"';"; GetConfigureDb()->DoExec(0,cmd,0); // update the database // char hn[32]; hn[0] = 0; // #ifdef UNIX gethostname(hn,sizeof(hn)); QString msg = u.Name + tr(" has changed password ") + QString(hn) + " display=" + QString(getenv("DISPLAY")); #else char computer_name[ MAX_PATH ]; ZeroMemory( computer_name, sizeof( computer_name ) ); DWORD size = MAX_PATH; ::GetComputerName( computer_name, &size ); QString msg = u.Name + tr(" has changed password ") + QString(computer_name); #endif QSLogEvent("HMI",msg); //DOAUDIT(tr("Password Changed")); // Username->setText(""); Password->setText(""); } } } // #ifdef UNIX char hn[32]; hn[0] = 0; // gethostname(hn,sizeof(hn)); // this is for X-Windows - DISPLAY tell us the IP address of the other end - possibly a flash git with // multiple monitors QString msg = u.Name + tr(" has logged in from computer ") + QString(hn) + " display=" + QString(getenv("DISPLAY")); QSLogEvent("HMI",msg); #else char computer_name[ MAX_PATH ]; ZeroMemory( computer_name, sizeof( computer_name ) ); DWORD size = MAX_PATH; ::GetComputerName( computer_name, &size ); QString msg = u.Name + tr(" has logged in from computer ") + QString(computer_name) + QString(" - ") + QString(winver()); QSLogEvent("HMI",msg); msg = QString(""SYSTEM_NAME"") + QString(" - ") #ifdef NDEBUG //Release build + QString("Release build: ") #else + QString("Debug build: ") #endif + tr("Build Date:") + QString(GetScadaDateBuild()) + " " + QString(GetScadaTimeBuild()); QSLogEvent("HMI",msg); #endif accept(); return; } } char hn[32]; hn[0] = 0; #ifdef UNIX gethostname(hn,sizeof(hn)); QString msg = tr(" Login Failed from Computer ") + QString(hn) + " display=" + QString(getenv("DISPLAY")); QSLogEvent("HMI",msg); #else char computer_name[ MAX_PATH ]; ZeroMemory( computer_name, sizeof( computer_name ) ); DWORD size = MAX_PATH; ::GetComputerName( computer_name, &size ); QString msg = tr(" Login Failed from Computer ") + QString(computer_name); QSLogEvent("HMI",msg); #endif // QMessageBox::warning(this,tr("Login Failed"),tr("Username or Password Not Recognised")); OkButton->setEnabled(true); // disable while we do the transaction // Password->setText(""); } }
void ConnectionCommunity::OnConnect(HWND hwnd, ConnectionInfo * dbname) { Tunnel *tunnel; MYSQL *mysql; HWND lastfocus = GetFocus(); wyString conn, temp, dirnamestr; wyWChar directory[MAX_PATH + 1] = {0}, *lpfileport = 0, pass[MAX_PATH + 1] = {0}; HWND hwndcombo; wyInt32 count, storepwd, ret; // DEBUG_ENTER("clicked ok"); tunnel = CreateTunnel(wyFalse); // DEBUG_LOG("created tunnel"); // Call ConnectToMySQL function to initialize a new mySQL structure and connect to // mySQL server with the connection details. The function will return a valid mysql // pointer if connection successful and if not then it will return NULL. // If null then show the standard mySQL errors given by the mySQL API. /* set correct values for tunnel to use HTTP authentication */ dbname->m_tunnel = tunnel; mysql = ConnectToMySQL(hwnd, dbname); if(mysql == NULL) { delete tunnel; SetFocus(lastfocus); } else if(dbname->m_db.GetLength() ==0 ||(IsDatabaseValid(dbname->m_db, mysql, tunnel) == wyTrue)) { // Successful so write the current details in connection .ini file // so that when the user uses the software again it will show the same details. dbname->m_mysql = mysql; dbname->m_tunnel = tunnel; WriteConnDetails(hwnd); ret = SearchFilePath(L"sqlyog", L".ini", MAX_PATH, directory, &lpfileport); if(ret == 0) { yog_enddialog(hwnd, (wyInt32)1); return; } /* if the user has changed any information then we ask him whether he wants to save */ if(m_conndetaildirty == wyTrue) { if(ConfirmAndSaveConnection(hwnd, wyTrue) == wyFalse) return; } else { /* even if he has not selected to save, we need to check for password thing as the user might diable on the store_password first and then make modification to the password, in that case the state will not be dirty and the value will not be stored */ VERIFY(hwndcombo = GetDlgItem(hwnd, IDC_DESC)); count = SendMessage(hwndcombo, CB_GETCOUNT, 0, 0); if(!count) { yog_enddialog(hwnd,(wyInt32)1); return; } VERIFY ((count = SendMessage(hwndcombo, CB_GETCURSEL, 0, 0))!= CB_ERR); count = SendMessage(hwndcombo, CB_GETITEMDATA, count, 0); conn.Sprintf("Connection %u", count); storepwd = Button_GetCheck(GetDlgItem(hwnd, IDC_DLGCONNECT_STOREPASSWORD)); /* now we only save the password if the user has asked for otherwise we remove it only */ /* feature implemented in v5.0 */ dirnamestr.SetAs(directory); //WritePrivateProfileStringA(conn.GetString(), "Password01", NULL, dirnamestr.GetString()); wyIni::IniDeleteKey(conn.GetString(), "Password01", dirnamestr.GetString()); if(!storepwd) { //WritePrivateProfileStringA(conn.GetString(), "Password", NULL, dirnamestr.GetString()); wyIni::IniDeleteKey(conn.GetString(), "Password", dirnamestr.GetString()); } else { GetWindowText(GetDlgItem(hwnd, IDC_DLGCONNECT_PASSWORD), pass, MAX_PATH); temp.SetAs(pass); EncodePassword(temp); wyIni::IniWriteString(conn.GetString(), "Password", temp.GetString(), dirnamestr.GetString()); } /* write the store password value too */ temp.Sprintf("%d", storepwd); ret = wyIni::IniWriteString (conn.GetString(), "StorePassword", temp.GetString(), dirnamestr.GetString()); } m_rgbobbkcolor = m_rgbconnection; m_rgbobfgcolor = m_rgbconnectionfg; yog_enddialog(hwnd,(wyInt32)1); } else { ShowMySQLError(hwnd, tunnel, &mysql, NULL, wyTrue); //fix a bug, database neme was erasing on error //SendMessage(GetDlgItem(hwnd, IDC_DLGCONNECT_DATABASE), WM_SETTEXT, 0,(LPARAM)L""); SetFocus(GetDlgItem(hwnd,IDC_DLGCONNECT_DATABASE)); return; } }