Skip to content

Commit b3a0f61

Browse files
committed
alpha 1.02b
1 parent 7c94e34 commit b3a0f61

File tree

10 files changed

+114
-15
lines changed

10 files changed

+114
-15
lines changed

res_defaults/cert.pem

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIDYTCCAkmgAwIBAgIJAO6v6mS6kZwgMA0GCSqGSIb3DQEBCwUAMEcxCzAJBgNV
3+
BAYTAlVTMQswCQYDVQQIDAJDQTEQMA4GA1UEBwwHb2FrbGFuZDEZMBcGA1UECgwQ
4+
ZGF0YWFmYXVsdCAuIG5ldDAeFw0xODA2MTExNjE4MDdaFw0xOTA2MTExNjE4MDda
5+
MEcxCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDQTEQMA4GA1UEBwwHb2FrbGFuZDEZ
6+
MBcGA1UECgwQZGF0YWFmYXVsdCAuIG5ldDCCASIwDQYJKoZIhvcNAQEBBQADggEP
7+
ADCCAQoCggEBANa36sR1jhfLYl5ZHHRftUnNNTxMLS8DgeWNUNi/5wXhe20e+LOg
8+
0wjC8LKmSPItqYoEv75vho1rwjx2I6PfMx/3AD7YNx4l3RYxQVQpISeJkMnYspgS
9+
jTBqeF7jOtlo8JTAT+bojfSyfSVF+vmCTY7z84rIpU87QF2b1Qn1kQ29xAs730fU
10+
VfD5LJ6RWeHLVLwpIsMem69a9wIHN7qakVc/0H7egKfRxXmIdKXw9c53JNhE7SS6
11+
MynFzRK7cVsAfwotTpPZXqU55hHrV4h4njSpTSwe/ssD2RQgj02RLcBB5TPx7ymC
12+
yXENHuhiYy0rCsW3sOSa2NH/r/cYzfhFVkcCAwEAAaNQME4wHQYDVR0OBBYEFOM4
13+
wu+T7aO5vWiEnIoQc0Y56qbnMB8GA1UdIwQYMBaAFOM4wu+T7aO5vWiEnIoQc0Y5
14+
6qbnMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAB/vy3unz/pkDBn7
15+
K46CHcEeemmErfZd4ugGPd2osyo8N9NWvISEYnimcNQ/w8hHiNkRkqMAilIJfyP1
16+
okVsdwtQXMteFrdGfE5lBc9LtXHzI8krvdvJzNwtieH/uF993QSbdbnyzrb3noiJ
17+
HOjBFFrNnLnG5vAVWU8CF+X7uNOziMVWnDLdqWr0V/J8DBWrjnfytDZeHm+33JAq
18+
goWkEBeSIA1wp3fsUNHUxqDCq06LHGzj90xvDPNcVcYkgqFllNW56ncCMxh/VWGm
19+
hhGFV5S36NBnmOSw6q0Zy0wod7Rku9UTJZUOJ0ztUZhbAKFpKBMe1G0WbL+aTBop
20+
XxsIK/U=
21+
-----END CERTIFICATE-----

res_defaults/key.pem

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-----BEGIN PRIVATE KEY-----
2+
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDWt+rEdY4Xy2Je
3+
WRx0X7VJzTU8TC0vA4HljVDYv+cF4XttHvizoNMIwvCypkjyLamKBL++b4aNa8I8
4+
diOj3zMf9wA+2DceJd0WMUFUKSEniZDJ2LKYEo0wanhe4zrZaPCUwE/m6I30sn0l
5+
Rfr5gk2O8/OKyKVPO0Bdm9UJ9ZENvcQLO99H1FXw+SyekVnhy1S8KSLDHpuvWvcC
6+
Bze6mpFXP9B+3oCn0cV5iHSl8PXOdyTYRO0kujMpxc0Su3FbAH8KLU6T2V6lOeYR
7+
61eIeJ40qU0sHv7LA9kUII9NkS3AQeUz8e8pgslxDR7oYmMtKwrFt7DkmtjR/6/3
8+
GM34RVZHAgMBAAECggEAIPCaHYWDRPc4ogy9psTABRBsKFHvZJT/Kn4hdv8JrAdJ
9+
bhYgRT5Y4bE2R9HmwvBqX/gWilqFo9ByPeBJ22v0ZeT4rqtw2Tkpz6vCv+yHX49l
10+
HPIXg+jkrBbJXJUzhALrVYajO2NV08JGHJ+9vuVUjKe0JwhdA+itGS884YhAtoCs
11+
URAMXZlB0KHUH5iNOJlKUrqK0COC14n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qvQQLD
28+
-----END PRIVATE KEY-----

res_defaults/wpdaemon.conf

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[General]
2+
enable_ssl=true
3+
ssl_certificate=cert.pem
4+
ssl_key_file=key.pem

res_html/index.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/icon.css" />
1111
<link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/demo/demo.css" /> -->
1212
<link rel="stylesheet" href="w3.css">
13-
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway">
13+
<!--<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway"> -->
1414
<link rel="stylesheeet" href="fajs.min.css">
1515
<script src="fontawesome-all.min.js"></script>
1616
<script src="jquery-1.9.1.js"></script>
@@ -100,18 +100,18 @@ <h5>Dashboard</h5>
100100

101101
<!-- Header -->
102102
<header class="w3-container" style="padding-top:22px">
103-
<h5><b><i class="fa fa-dashboard"></i> My Dashboard</b></h5>
103+
<h5><b><i class="fa fa-dashboard"></i> <span id="dashboard_site_name"></span></b></h5>
104104
</header>
105105

106106
<div class="w3-row-padding w3-margin-bottom">
107107
<div class="w3-quarter">
108108
<div class="w3-container w3-red w3-padding-16">
109109
<div class="w3-left"><i class="fa fa-comment w3-xxxlarge"></i></div>
110110
<div class="w3-right">
111-
<h3>52</h3>
111+
<h3><span class="dashboard_comment_count"></span></h3>
112112
</div>
113113
<div class="w3-clear"></div>
114-
<h4>Messages</h4>
114+
<h4>Comments</h4>
115115
</div>
116116
</div>
117117
<div class="w3-quarter">

res_html/main.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ function set_command(i_command) {
137137
function open_site_dashboard(i_site) {
138138
channel.objects.clientInteraction.set_current_site(i_site, function(args) {
139139
if (args === true) {
140-
140+
var sn = document.querySelector("#dashboard_site_name");
141+
sn.innerHTML = i_site;
141142
} else {
142143
alert("Could not Access Site.\n Make sure the wp-config file is readable by the WPDaemon user.");
143144
}

resources.qrc

+3
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@
1515
<file>res_html/font-awesome.min.css</file>
1616
<file>res_html/fajs.css</file>
1717
<file>res_html/fontawesome-all.min.js</file>
18+
<file>res_defaults/cert.pem</file>
19+
<file>res_defaults/key.pem</file>
20+
<file>res_defaults/wpdaemon.conf</file>
1821
</qresource>
1922
</RCC>

src_assets/assetunpacker.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
#include <QCoreApplication>
33
#include <QDir>
44
#include <iostream>
5+
#include <QtDebug>
56

67
AssetUnpacker::AssetUnpacker(QObject *parent) : QObject(parent)
78
{
89
unpack("res_scripts", "scripts");
910
unpack("res_html", "public");
1011
unpack("res_python", "python");
12+
QFile confFile(qApp->applicationDirPath().append(QDir::separator()).append("wpdaemon.conf"));
13+
if (!confFile.exists()) {
14+
qDebug() << "WELCOME TO WPDAEMON\n" << "-------------\n" << "A new file called wpdaemon.conf has been created in the directory containing the WPDaemon Binary\n" << qApp->applicationDirPath().append(QDir::separator()).append("wpdaemon.conf") << "\n" << "\n" << "You must now do one of the following actions to properly setup WPDaemon:\n\n" << "1) Modify WPDaemon.conf and change the ssl_certificate_file and ssl_key_file settings to point to a valid SSL certificate / key pair\n" << "- OR -" << "Place a valid SSL Certificate in the WPDaemon folder with the name 'cert.pem' and the corosponding key in the same folder with the name 'key.pem'" << "\n\n" << "* NOTE: If you choose (option 1) , you must also create a symbolic/hard link or hard copy the certificate and key to match the names provided in (option 2). This process will not be required at all starting with the first beta release, and will be replaced with an interactive prompt. ";
15+
unpack("res_defaults", ".");
16+
}
1117

1218
}
1319

src_interfaces/clientinteraction.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ QVariant ClientInteraction::set_current_submodule(QString i_module)
126126
QStringList descList = desc.split("\n", QString::SkipEmptyParts);
127127
/*QString syn = currentSubmodule->get_command_dump("synopsis").toString();
128128
QStringList synList = syn.split("\n", QString::KeepEmptyParts); */
129-
129+
qDebug() << names;
130130
QString rv = "{\"commands\":[";
131131
//if (synList.count() != descList.count()) { // qDebug() << "Synopsis Size Mismatch"; } else {
132132

src_interfaces/configcontroller.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <QCoreApplication>
33
#include <QSettings>
44
#include <QDir>
5+
#include <QtDebug>
56

67
ConfigController::ConfigController(QObject *parent) : QObject(parent)
78
{
@@ -10,9 +11,6 @@ ConfigController::ConfigController(QObject *parent) : QObject(parent)
1011

1112
QSettings* ConfigController::settings()
1213
{
13-
QSettings* _settings = new QSettings(qApp->applicationDirPath().append(QDir::separator()).append("config").append(QDir::separator()).append("wpdaemon.conf"), QSettings::IniFormat);
14-
_settings->setValue("enable_ssl", "true");
15-
_settings->setValue("ssl_certificate_file", qApp->applicationDirPath().append(QDir::separator()).append("cert.pem"));
16-
_settings->setValue("ssl_key_file", qApp->applicationDirPath().append(QDir::separator()).append("key.pem"));
14+
QSettings* _settings = new QSettings(qApp->applicationDirPath().append(QDir::separator()).append("wpdaemon.conf"), QSettings::IniFormat);
1715
return _settings;
1816
}

src_interfaces/logincontroller.cpp

+43-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <QSqlQuery>
77
#include <QSqlDatabase>
88
#include <QVariant>
9+
#include <QDateTime>
910
LoginController::LoginController(QObject *parent, DatabaseController* i_db) : QObject(parent), m_db(i_db)
1011
{
1112
this->hello_str = "hello, world!";
@@ -28,7 +29,7 @@ bool LoginController::check_login(QString username, QString password)
2829
// it wastes about 2kb of total memory to store and is only requested
2930
// once on login so i think its okay to keep
3031

31-
QVector<QVector<QString> > rv(m_db->executeSelectQuery("USERS", (QStringList() << "USERS.ID" << "USERNAME" << "ASSIGNMENTS.PERMISSION" << "ASSIGNMENTS.ASSIGNED" << "PERMSTATES.DESCRIPTION" << "PERMSTATES.NAME"), "inner join ASSIGNMENTS ON UID=USERS.ID inner join PERMSTATES on ASSIGNMENTS.PERMISSION=PERMSTATES.PERMISSION"));
32+
QVector<QVector<QString> > rv(m_db->executeSelectQuery("USERS", (QStringList() << "USERS.ID" << "USERNAME" << "ASSIGNMENTS.PERMISSION" << "ASSIGNMENTS.ASSIGNED" << "PERMSTATES.DESCRIPTION" << "PERMSTATES.NAME"), QString("inner join ASSIGNMENTS ON UID=USERS.ID inner join PERMSTATES on ASSIGNMENTS.PERMISSION=PERMSTATES.PERMISSION where USERNAME like '%1'").arg(m_db->toHex(username))));
3233
QVectorIterator<QVector<QString > > i(rv);
3334
while (i.hasNext()) {
3435
QVector<QString> rowData(i.next());
@@ -49,11 +50,44 @@ bool LoginController::check_login(QString username, QString password)
4950

5051
bool LoginController::check_token(QString token)
5152
{
52-
if (m_db->executeSelectQuery("SESSIONS", (QStringList() << "UID" << "TOKEN"), QString("where TOKEN like '%1'").arg(m_db->toHex(token))).count() > 0) {
53-
loggedIn = true;
54-
QSqlQuery query = m_db->db.exec(QString("delete from SESSIONS where TOKEN like '%1'").arg(m_db->toHex(token)));
55-
query.finish();
53+
QVector<QVector<QString> > queryResult(m_db->executeSelectQuery("SESSIONS", (QStringList() << "UID" << "TOKEN" << "SESSIONDATA"), QString("where TOKEN like '%1'").arg(m_db->toHex(token))));
54+
if (queryResult.count() > 0) {
55+
if (queryResult.first().length() > 2) {
56+
57+
qint64 expireTime = queryResult.first().at(2).toInt();
58+
qint64 currentTime = QDateTime::currentSecsSinceEpoch();
59+
if (expireTime > currentTime) {
60+
loggedIn = true;
61+
QSqlQuery query = m_db->db.exec(QString("delete from SESSIONS where TOKEN like '%1'").arg(m_db->toHex(token)));
62+
query.finish();
63+
64+
//populate permissions, descriptions, etc on a per user basis
65+
// this will allow for future extending of the code if the need
66+
// arises to have language support etc then the descriptions can
67+
// be populated based on the selected language or the descriptions
68+
// can be more specific for administrators than for operators etc
69+
// it wastes about 2kb of total memory to store and is only requested
70+
// once on login so i think its okay to keep
5671

72+
QVector<QVector<QString> > rv(m_db->executeSelectQuery("USERS", (QStringList() << "USERS.ID" << "USERNAME" << "ASSIGNMENTS.PERMISSION" << "ASSIGNMENTS.ASSIGNED" << "PERMSTATES.DESCRIPTION" << "PERMSTATES.NAME"), "inner join ASSIGNMENTS ON UID=USERS.ID inner join PERMSTATES on ASSIGNMENTS.PERMISSION=PERMSTATES.PERMISSION"));
73+
QVectorIterator<QVector<QString > > i(rv);
74+
while (i.hasNext()) {
75+
QVector<QString> rowData(i.next());
76+
this->assignments[rowData.at(2).toInt()] = static_cast<bool>(rowData.at(3).toInt());
77+
this->assignment_names[rowData.at(2).toInt()] = rowData.at(5);
78+
this->assignment_id_names[rowData.at(5)] = rowData.at(2).toInt();
79+
this->assignment_descriptions[rowData.at(2).toInt()] = rowData.at(4);
80+
this->m_uid = rowData.at(0).toInt();
81+
this->m_username = m_db->fromHex(rowData.at(1));
82+
}
83+
//end of permission assignment population
84+
85+
} else {
86+
loggedIn = false;
87+
}
88+
} else {
89+
loggedIn = false;
90+
}
5791
} else {
5892
loggedIn = false;
5993
}
@@ -67,10 +101,14 @@ QString LoginController::new_token(QString oldToken)
67101
QVariantList v;
68102
QUuid newTokenUUid;
69103
QString newToken = newTokenUUid.createUuid().toString();
104+
qint64 expireTime;
105+
expireTime = QDateTime::currentSecsSinceEpoch();
106+
expireTime += 240;
70107
int newid = m_db->executeSelectQuery("SESSIONS", (QStringList() << "UID" << "TOKEN"), QString("")).count();
71108
v.append(QVariant::fromValue(newid));
72109
v.append(QVariant::fromValue(m_uid));
73110
v.append(QVariant::fromValue(newToken));
111+
v.append(QVariant::fromValue(expireTime));
74112

75113
m_db->executeInsert("SESSIONS", v);
76114
return newToken;

0 commit comments

Comments
 (0)