GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — TDBcpp/TDBAdminModification.cpp at master · bobar/TDBcpp Expand file tree/ Copy pathTDBAdminModification.cppMore file actions 95 lines (70 loc) · 2.74 KB / Copy pathTDBAdminModification.cppFile metadata and controls95 lines (70 loc) · 2.74 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 #include "TDBAdminModification.h" TDBAdminModification::TDBAdminModification(QWidget* parent, QString trigramme) : QDialog(parent) { int perm; TDBDatabase::open(); QSqlQuery query; query.prepare("SELECT accounts.id as admin_id, permissions FROM admins LEFT JOIN accounts ON accounts.id = admins.id WHERE accounts.trigramme = :trigramme"); query.bindValue(":trigramme", trigramme); query.exec(); query.first(); admin_id = query.record().value("admin_id").toInt(); perm = query.record().value("permissions").toInt(); TDBDatabase::close(); setWindowTitle("Modification d'un admin"); passwd1_label = new QLabel("Mot de passe", this); passwd2_label = new QLabel("Vérification", this); perm_label = new QLabel("Niveau", this); perm_combo = new QComboBox(this); perm_combo->addItem("Pékin", pekin); perm_combo->addItem("Ami du BôB", ami_du_bob); perm_combo->addItem("Ancien BôBarman", bobarman); perm_combo->addItem("BôBarman", root); perm_combo->setCurrentIndex(perm_combo->findData(perm)); passwd1_edit = new QLineEdit(this); passwd1_edit->setEchoMode(QLineEdit::Password); passwd2_edit = new QLineEdit(this); passwd2_edit->setEchoMode(QLineEdit::Password); layout = new QGridLayout(this); layout->addWidget(passwd1_label, 0, 0); layout->addWidget(passwd1_edit, 0, 1); layout->addWidget(passwd2_label, 1, 0); layout->addWidget(passwd2_edit, 1, 1); layout->addWidget(perm_label, 2, 0); layout->addWidget(perm_combo, 2, 1); ok_button = new QPushButton("OK", this); layout->addWidget(ok_button, 3, 0); cancel_button = new QPushButton("Cancel", this); layout->addWidget(cancel_button, 3, 1); setLayout(layout); connect(cancel_button, SIGNAL(pressed()), this, SLOT(cancel_pressed())); connect(ok_button, SIGNAL(pressed()), this, SLOT(ok_pressed())); } TDBAdminModification::~TDBAdminModification() { } void TDBAdminModification::cancel_pressed() { reject(); } void TDBAdminModification::ok_pressed() { int perm = perm_combo->itemData(perm_combo->currentIndex()).toInt(); TDBDatabase::open(); QSqlQuery query; query.prepare("UPDATE admins SET permissions = :perm WHERE id = :id"); query.bindValue(":perm", perm); query.bindValue(":id", admin_id); query.exec(); if (!passwd1_edit->text().isEmpty() && passwd1_edit->text() == passwd1_edit->text()) { query.prepare("UPDATE admins SET passwd = :passwd WHERE id = :id"); query.bindValue(":passwd", QCryptographicHash::hash(QByteArray().append(passwd1_edit->text()), QCryptographicHash::Md5).toHex()); query.bindValue(":id", admin_id); query.exec(); } TDBDatabase::close(); accept(); } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |