Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
jlopez
wicopa
Commits
141e8959
Commit
141e8959
authored
Jul 19, 2019
by
jlopez
Browse files
Merge branch 'develop' into 'master'
Fix
#7
Closes
#7
See merge request
!9
parents
d5635cc6
b47c23a0
Pipeline
#210
passed with stage
in 1 minute and 26 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
action/action_config.php
0 → 100644
View file @
141e8959
<?php
define
(
"PATH"
,
".."
);
define
(
"PAGE"
,
"actionConfig"
);
session_start
();
if
(
!
isset
(
$_SESSION
[
'manage'
]))
{
header
(
"Location: ../login.php"
);
}
require_once
'../dao/DBquery.php'
;
$db
=
new
DBquery
();
$today
=
date
(
"Y-m-d G:i:s"
);
$action
=
NULL
;
$id
=
NULL
;
$type
=
NULL
;
$description
=
NULL
;
$value
=
NULL
;
$active
=
0
;
if
(
isset
(
$_POST
[
'action'
]))
{
$action
=
$_POST
[
'action'
];
}
else
{
if
(
isset
(
$_GET
[
'action'
]))
{
$action
=
$_GET
[
'action'
];
}
else
{
$action
=
""
;
}
}
if
(
isset
(
$_POST
[
'configid'
]))
{
$id
=
$_POST
[
'configid'
];
}
else
{
if
(
isset
(
$_GET
[
'configid'
]))
{
$id
=
$_GET
[
'configid'
];
}
else
{
$id
=
-
1
;
}
}
if
(
isset
(
$_POST
[
'type'
]))
{
$type
=
$_POST
[
'type'
];
}
if
(
isset
(
$_POST
[
'description'
]))
{
$description
=
$_POST
[
'description'
];
}
if
(
isset
(
$_POST
[
'value'
]))
{
$value
=
$_POST
[
'value'
];
}
if
(
isset
(
$_POST
[
'active'
]))
{
$active
=
1
;
}
$config
=
new
Config
(
$id
,
$type
,
$description
,
$value
,
$active
);
if
(
$action
==
"create"
)
{
$config
->
active
=
1
;
$config
->
escape
(
$db
);
$db
->
create
(
$config
);
}
else
if
(
$action
==
"update"
)
{
$config
->
escape
(
$db
);
$db
->
update
(
$config
);
}
else
if
(
$action
==
"delete"
)
{
$db
->
delete
(
$config
);
}
header
(
"Location: ../configuration.php"
);
\ No newline at end of file
configuration.php
0 → 100644
View file @
141e8959
<?php
session_start
();
if
(
!
isset
(
$_SESSION
[
'manage'
]))
{
header
(
"Location: ./login.php"
);
}
require_once
"./dao/DBquery.php"
;
$db
=
new
DBquery
();
$configs
=
$db
->
getConfigs
();
require_once
"./inc/php/buildHeader.php"
;
?>
<div
class=
"container-fluid"
>
<br/>
<div
class=
"row"
>
<div
class=
"col-12"
>
<div
class=
"card border border-dark"
>
<div
class=
"card-header bg-dark text-light"
>
Configs :
</div>
<div
class=
"card-body"
>
<form
action=
"./action/action_config.php"
method=
"post"
>
<div
class=
"row"
>
<input
type=
"text"
class=
"form-control"
style=
"display: none;"
placeholder=
"action"
name=
"action"
value=
"create"
>
<div
class=
"col-2"
>
<label
for=
"typeConfig"
>
Type :
</label>
<select
name=
"type"
id=
"typeConfig"
class=
"form-control"
>
';
<option
value=
"post"
>
post
</option>
<option
value=
"env"
>
env
</option>
</select>
</div>
<div
class=
"col-3"
>
<label
for=
"descriptionConfig"
>
Description :
</label>
<input
type=
"text"
class=
"form-control"
id=
"descriptionConfig"
name=
"description"
>
</div>
<div
class=
"col-4"
>
<label
for=
"valueConfig"
>
Value :
</label>
<textarea
class=
"form-control"
id=
"valueConfig"
rows=
"5"
name=
"value"
maxlength=
"999"
></textarea>
</div>
<div
class=
"col-3"
>
<button
type=
"submit"
class=
"btn btn-success"
>
Create
</button>
</div>
</div>
</form>
<br/>
<br/>
<br/>
<table
id=
"Table_Config"
class=
"table table-striped table-bordered"
>
<thead>
<tr>
<th>
Active
</th>
<th>
Type
</th>
<th>
Description
</th>
<th>
Value
</th>
<th>
Save
</th>
<th>
Delete
</th>
</tr>
</thead>
<tbody
id=
"TableConfig"
>
<?php
foreach
(
$configs
as
$config
)
{
echo
'<form action="./action/action_config.php" method="post"><tr>'
;
echo
'<td>
<input type="text" class="form-control" style="display: none;" placeholder="action" name="action" value="update">
<input type="text" style="display: none;" name="configid" value="'
.
$config
->
ID
.
'">
'
;
if
(
$config
->
active
==
1
)
{
echo
'<input type="checkbox" name="active" value="'
.
$config
->
ID
.
'" checked>'
;
}
else
{
echo
'<input type="checkbox" name="active" value="'
.
$config
->
ID
.
'">'
;
}
echo
'</td>'
;
echo
'<td><select name="type" class="form-control">'
;
if
(
$config
->
type
==
"post"
)
{
echo
'<option value="post" selected="selected">post</option>'
;
echo
'<option value="env">env</option>'
;
}
if
(
$config
->
type
==
"env"
)
{
echo
'<option value="post" >post</option>'
;
echo
'<option value="env" selected="selected">env</option>'
;
}
echo
'</select></td>'
;
echo
'<td > <input class="form-control" type="text" name="description" value="'
.
$config
->
description
.
'" ></td>'
;
echo
'<td > <textarea class="form-control" rows="5" name="value" maxlength="999" >'
.
$config
->
value
.
'</textarea></td>'
;
echo
'<td>'
.
'<button type="submit" class="btn btn-info btn-sm">save</button>'
.
'</td>'
;
echo
'<td>'
.
'<a class="btn btn-danger btn-sm" href="./action/action_config.php?action=delete&configid='
.
$config
->
ID
.
'" >x</a>'
.
'</td>'
;
echo
'</tr></form>'
;
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script
src=
"http://code.jquery.com/jquery-latest.min.js"
type=
"text/javascript"
></script>
<script
src=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
integrity=
"sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin=
"anonymous"
></script>
</body>
</html>
\ No newline at end of file
dao/DBquery.php
View file @
141e8959
...
...
@@ -16,6 +16,7 @@ require_once(__DIR__.'/../model/Grade.php');
require_once
(
__DIR__
.
'/../model/Label.php'
);
require_once
(
__DIR__
.
'/../model/User.php'
);
require_once
(
__DIR__
.
'/../model/ContainerLabel.php'
);
require_once
(
__DIR__
.
'/../model/Config.php'
);
class
DBquery
{
...
...
@@ -147,6 +148,28 @@ class DBquery
return
$results
;
}
public
function
getConfigs
()
{
$sql
=
"SELECT * FROM `Config` WHERE 1;"
;
$result
=
mysqli_query
(
$this
->
dbh
,
$sql
);
$results
=
array
();
while
(
$row
=
mysqli_fetch_assoc
(
$result
)){
$cfg
=
new
Config
(
$row
[
'ID'
],
$row
[
'type'
],
$row
[
'description'
],
$row
[
'value'
],
$row
[
'active'
]);
array_push
(
$results
,
$cfg
);
}
return
$results
;
}
public
function
getActiveConfigsWithType
(
$type
)
{
$sql
=
"SELECT * FROM `Config` WHERE `type`='
$type
' AND `active` = 1;"
;
$result
=
mysqli_query
(
$this
->
dbh
,
$sql
);
$results
=
array
();
while
(
$row
=
mysqli_fetch_assoc
(
$result
)){
$cfg
=
new
Config
(
$row
[
'ID'
],
$row
[
'type'
],
$row
[
'description'
],
$row
[
'value'
],
$row
[
'active'
]);
array_push
(
$results
,
$cfg
);
}
return
$results
;
}
public
function
getGradeWithId
(
$ID
)
{
$sql
=
"SELECT * FROM `Grade` WHERE `ID` = '
$ID
';"
;
$result
=
mysqli_query
(
$this
->
dbh
,
$sql
);
...
...
@@ -434,7 +457,7 @@ class DBquery
public
function
update
(
$object
)
{
$result
=
mysqli_query
(
$this
->
dbh
,
$object
->
getUpdate
());
$result
=
mysqli_query
(
$this
->
dbh
,
$object
->
getUpdate
());
if
(
$result
)
{
}
else
{
...
...
inc/js/wicopa.js
View file @
141e8959
...
...
@@ -155,6 +155,38 @@ function generate_container() {
}
}
//ENV ADMIN
var
table
=
document
.
getElementById
(
"
Table_EnvConfig
"
);
for
(
var
i
=
1
;
i
<
table
.
rows
.
length
;
i
++
)
{
var
active
=
table
.
rows
[
i
].
cells
[
0
].
children
[
0
];
if
(
active
.
checked
)
{
var
value
=
table
.
rows
[
i
].
cells
[
2
].
innerHTML
;
var
lines
=
value
.
split
(
'
\n
'
);
for
(
var
j
=
0
;
j
<
lines
.
length
;
j
++
)
{
var
line
=
lines
[
j
];
if
(
line
!=
""
)
{
if
(
isSingularity
)
{
PREVIEW
+=
"
\t
"
+
line
+
"
\n
"
;
nrow
+=
1
;
}
else
{
PREVIEW
+=
"
RUN
"
+
line
+
"
\n
"
;
nrow
+=
1
;
}
}
}
PREVIEW
+=
"
\n
"
;
nrow
+=
1
;
}
}
var
date
=
new
Date
();
var
options
=
{
...
...
@@ -198,6 +230,39 @@ function generate_container() {
PREVIEW
+=
"
%post
\n
"
;
}
//POST ADMIN
var
table
=
document
.
getElementById
(
"
Table_PostConfig
"
);
for
(
var
i
=
1
;
i
<
table
.
rows
.
length
;
i
++
)
{
var
active
=
table
.
rows
[
i
].
cells
[
0
].
children
[
0
];
if
(
active
.
checked
)
{
var
value
=
table
.
rows
[
i
].
cells
[
2
].
children
[
0
].
value
;
var
lines
=
value
.
split
(
'
\n
'
);
for
(
var
j
=
0
;
j
<
lines
.
length
;
j
++
)
{
var
line
=
lines
[
j
];
if
(
line
!=
""
)
{
if
(
isSingularity
)
{
PREVIEW
+=
"
\t
"
+
line
+
"
\n
"
;
nrow
+=
1
;
}
else
{
PREVIEW
+=
"
RUN
"
+
line
+
"
\n
"
;
nrow
+=
1
;
}
}
}
PREVIEW
+=
"
\n
"
;
nrow
+=
1
;
}
}
for
(
var
i
=
0
;
i
<
SELECTED_PACKAGES
[
"
Distribution
"
].
length
;
i
++
)
{
if
(
isSingularity
)
{
...
...
inc/php/buildHeader.php
View file @
141e8959
...
...
@@ -42,7 +42,7 @@ echo '
if
(
isset
(
$_SESSION
[
'manage'
])
&&
!
empty
(
$_SESSION
[
'manage'
]))
{
echo
' <a class="nav-item nav-link" href="./manage.php"> Manage </a>'
;
//
echo ' <a class="nav-item nav-link" href="./config.php"> Configs </a>';
echo
' <a class="nav-item nav-link" href="./config
uration
.php"> Configs </a>'
;
}
}
...
...
index.php
View file @
141e8959
...
...
@@ -122,6 +122,86 @@ require_once "./inc/php/buildHeader.php";
</div>
</div>
<br/>
<div
class=
"col-12"
>
<div
class=
"card border border-dark"
>
<div
class=
"card-header bg-dark text-light"
>
Environment configs :
</div>
<div
class=
"card-body"
>
<table
id=
"Table_EnvConfig"
class=
"table table-striped table-bordered"
>
<thead>
<tr>
<th>
Active
</th>
<th>
Description
</th>
<th>
Value
</th>
</tr>
</thead>
<tbody
id=
"TableEnvConfig"
>
<?php
foreach
(
$db
->
getActiveConfigsWithType
(
"env"
)
as
$config
)
{
echo
'<tr>'
;
echo
'<td>'
;
if
(
$config
->
active
==
1
)
{
echo
'<input type="checkbox" name="active" value="'
.
$config
->
ID
.
'" checked>'
;
}
else
{
echo
'<input type="checkbox" name="active" value="'
.
$config
->
ID
.
'">'
;
}
echo
'</td>'
;
echo
'<td>'
.
$config
->
description
.
'</td>'
;
echo
'<td>'
.
$config
->
value
.
'</td>'
;
echo
'</tr>'
;
}
?>
</tbody>
</table>
</div>
</div>
</div>
<br/>
<div
class=
"col-12"
>
<div
class=
"card border border-dark"
>
<div
class=
"card-header bg-dark text-light"
>
Post configs :
</div>
<div
class=
"card-body"
>
<table
id=
"Table_PostConfig"
class=
"table table-striped table-bordered"
>
<thead>
<tr>
<th>
Active
</th>
<th>
Description
</th>
<th>
Value
</th>
</tr>
</thead>
<tbody
id=
"TablePostConfig"
>
<?php
foreach
(
$db
->
getActiveConfigsWithType
(
"post"
)
as
$config
)
{
echo
'<tr>'
;
echo
'<td>'
;
if
(
$config
->
active
==
1
)
{
echo
'<input type="checkbox" name="active" value="'
.
$config
->
ID
.
'" checked>'
;
}
else
{
echo
'<input type="checkbox" name="active" value="'
.
$config
->
ID
.
'">'
;
}
echo
'</td>'
;
echo
'<td>'
.
$config
->
description
.
'</td>'
;
echo
'<td><textarea class="form-control" rows="5">'
.
$config
->
value
.
'</textarea></td>'
;
echo
'</tr>'
;
}
?>
</tbody>
</table>
</div>
</div>
</div>
<br/>
<div
class=
"col-12"
>
...
...
@@ -336,6 +416,7 @@ require_once "./inc/php/buildHeader.php";
gestionPackageSelected
();
}
</script>
</body>
...
...
model/Config.php
0 → 100644
View file @
141e8959
<?php
require_once
(
__DIR__
.
'/../dao/DBquery.php'
);
class
Config
{
var
$ID
=
0
;
var
$type
=
""
;
var
$description
=
""
;
var
$value
=
""
;
var
$active
=
0
;
public
function
__construct
(
$ID
,
$type
,
$description
,
$value
,
$active
)
{
$this
->
ID
=
$ID
;
$this
->
description
=
$description
;
$this
->
value
=
$value
;
$this
->
type
=
$type
;
$this
->
active
=
$active
;
}
public
function
escape
(
DBquery
$db
)
{
$this
->
description
=
utf8_decode
(
$db
->
escape
(
$this
->
description
));
$this
->
value
=
utf8_decode
(
$db
->
escape
(
$this
->
value
));
}
public
function
getInsert
()
{
return
"INSERT INTO Config (type, description, value, active)
VALUES ('
$this->type
', '
$this->description
', '
$this->value
', '
$this->active
');"
;
}
public
function
getUpdate
()
{
return
"UPDATE Config
SET type='
$this->type
', description='
$this->description
', value='
$this->value
', active='
$this->active
'
WHERE ID = '
$this->ID
';"
;
}
public
function
getDelete
()
{
return
"DELETE FROM Config WHERE ID = '
$this->ID
';"
;
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment