Commit d2936816 authored by remy's avatar remy
Browse files

Merge branch 'master' of gitlab.mbb.univ-montp1.fr:jlopez/wicopa into develop

parents 73258f28 28bb7c97
wicopa.sql
conf/Conf.php
*.swp
.docker/db/wicopa/*
......@@ -38,14 +38,13 @@ vim conf/Conf.php
```bash
git clone https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa.git
# you need to have wicopa.sql here
wget http://web.mbb.univ-montp2.fr/download/wicopa.sql.gz
gunzip -d wicopa.sql.gz
sudo mkdir -p /data/mysql/wicopa
cd wicopa
wget http://web.mbb.univ-montp2.fr/download/wicopa.sql.gz && gunzip -d wicopa.sql.gz
sudo docker-compose up --build
# you can access to it at http://127.0.0.1:8000
# you can login as "admin" with password w1c0Pa5s
```
Note that due to selinux problem on some RedHat-like distros, I added the `z` option to the volumes on the docker-compose file. [See here for more informations](https://www.projectatomic.io/blog/2015/06/using-volumes-with-docker-can-cause-problems-with-selinux/)
Your database will be located in `.docker/db/wicopa`.
Note: the `:z` option on your volumes in the docker-compose file is needed if you run it on RedHat-like distros, due to some selinux problems [See here for more informations](https://www.projectatomic.io/blog/2015/06/using-volumes-with-docker-can-cause-problems-with-selinux/).
......@@ -8,11 +8,12 @@ This Web UI application can generate Dockerfiles or definition files for Singula
Check [INSTALL](INSTALL.md)
You can test it easily with Docker, using `docker-compose`. [See here](INSTALL.md#using-docker)
You can test it easily with Docker, using `docker-compose` ([See here](INSTALL.md#using-docker)).
# Roadmap
- tags to search recipes [see issue #11](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/11)
- Loading and sharing recipes [see issue #10](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/10)
- Adding a custom local configuration to all recipes. Indeed, HPC administrator could occasionnally allow Singularity containers on their cluster. Thus, they usually need to edit the recipe to add custom content, in order to rebuild the image. [see issue #7](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/7)
- convert the functions to retrieve specific language packages in pure PHP to be able to upgrade it directly from the admin panel [issue #2](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/2)
\ No newline at end of file
- Tags to search recipes ([see issue #11](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/11)),
- Loading and sharing recipes ([see issue #10](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/10)),
- Adding a custom local configuration to all recipes. Indeed, HPC administrator could occasionnally allow Singularity containers on their cluster. Thus, they usually need to edit the recipe to add custom contents, in order to rebuild the image ([see issue #7](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/7)),
- Convert the functions to retrieve specific language packages in pure PHP to be able to upgrade it directly from the admin panel ([see issue #2](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/2)),
- adding a connection to a personal Gitlab/Github profile ([see issue #13](https://gitlab.mbb.univ-montp2.fr/jlopez/wicopa/issues/13)).
\ No newline at end of file
<?php
define("PATH","..");
define("PAGE","actionContainer");
session_start ();
$action = NULL;
if(isset($_POST['action'])) {
$action = $_POST['action'];
} else {
if(isset($_GET['action'])) {
$action = $_GET['action'];
} else {
$action = "";
}
}
if(!isset($_SESSION['username'])) {
if($action != "download") {
header("Location: ../login.php");
}
}
require_once '../dao/DBquery.php';
$db = new DBquery();
$today = date("Y-m-d G:i:s");
$id = NULL;
$name = NULL;
$value = NULL;
$type = NULL;
$visibility = "public";
$description = NULL;
$author = 0;
$labels = array();
if(isset($_POST['containerid'])) {
$id = $_POST['containerid'];
} else {
if(isset($_GET['containerid'])) {
$id = $_GET['containerid'];
} else {
$id = -1;
}
}
if(isset($_POST['name'])) {
$name = $_POST['name'];
}
if(isset($_POST['value'])) {
$value = $_POST['value'];
}
if(isset($_POST['type'])) {
$type = $_POST['type'];
}
if(isset($_POST['visibility'])) {
$visibility = intval($_POST['visibility']);
}
if(isset($_POST['description'])) {
$description = $_POST['description'];
}
$author = $_SESSION['username'];
if(isset($_POST['labels'])) {
$labels = $_POST['labels'];
}
$container = new Container($id, $name, $value, $type, $visibility, $description, $author, $today);
if($action == "create") {
$container->escape($db);
$db->create($container);
$last_id = mysqli_insert_id($db->dbh);
foreach ($labels as $lid){
$contlab = new ContainerLabel(0, $last_id, $lid);
$db->create($contlab);
}
header("Location: ../container.php");
} else if ($action == "update") {
$container->escape($db);
$db->update($container);
header("Location: ../container.php");
} else if ($action == "delete") {
$cnt = $db->getContainerWithId($container->ID);
if($cnt->author == $author) {
$db->delete($container);
} else if($db->getGradeWithLogin($_SESSION['username'])->name == $db->getMaxGrades()->name) {
$db->delete($container);
}
header("Location: ../container.php");
} else if($action == "download") {
$cnt = $db->getContainerWithId($container->ID);
$down = FALSE;
if(($cnt->author == $author) || ($cnt->visibility == 1)) {
$down = TRUE;
} else if($db->getGradeWithLogin($_SESSION['username'])->name == $db->getMaxGrades()->name) {
$down = TRUE;
}
if($down) {
$content = $cnt->value;
$name = $cnt->name;
$file = fopen($name,"wb");
fwrite($file);
fclose($file);
header('Content-Type: charset=utf-8');
header("Content-disposition: attachment; filename=$name");
print $content;
} else {
header("Location: ../container.php");
}
}
......@@ -5,7 +5,7 @@ define("PAGE","actionDistribution");
session_start ();
if(!isset($_SESSION['username'])) {
if(!isset($_SESSION['manage'])) {
header("Location: ../login.php");
}
......@@ -18,8 +18,8 @@ $today = date("Y-m-d G:i:s");
$action = NULL;
$id = NULL;
$version = NULL;
$manager = NULL;
$version = NULL;
$manager = NULL;
$active = 0;
......@@ -84,5 +84,5 @@ if($action == "create") {
$db->delete($distrib);
}
header("Location: ../gestion.php#distribution");
header("Location: ../manage.php#distribution");
<?php
define("PATH","..");
define("PAGE","actionGrade");
session_start ();
if(!isset($_SESSION['manage'])) {
header("Location: ../login.php");
}
require_once '../dao/DBquery.php';
$db = new DBquery();
$action = NULL;
$id = NULL;
$name = NULL;
$level = NULL;
if(isset($_POST['action'])) {
$action = $_POST['action'];
} else {
if(isset($_GET['action'])) {
$action = $_GET['action'];
} else {
$action = "";
}
}
if(isset($_POST['gradeid'])) {
$id = $_POST['gradeid'];
} else {
if(isset($_GET['gradeid'])) {
$id = $_GET['gradeid'];
} else {
$id = -1;
}
}
if(isset($_POST['name'])) {
$name = $_POST['name'];
}
if(isset($_POST['level'])) {
$level = $_POST['level'];
}
$grade = new Grade($id, $name, $level);
if($action == "create") {
$grade->escape($db);
$db->create($grade);
} else if ($action == "update") {
$grade->escape($db);
$db->update($grade);
} else if ($action == "delete") {
$db->delete($grade);
}
header("Location: ../manage.php#grade");
<?php
define("PATH","..");
define("PAGE","actionLabel");
session_start ();
if(!isset($_SESSION['manage'])) {
header("Location: ../login.php");
}
require_once '../dao/DBquery.php';
$db = new DBquery();
$action = NULL;
$id = NULL;
$name = NULL;
$color = NULL;
$gradeId = NULL;
if(isset($_POST['action'])) {
$action = $_POST['action'];
} else {
if(isset($_GET['action'])) {
$action = $_GET['action'];
} else {
$action = "";
}
}
if(isset($_POST['labelid'])) {
$id = $_POST['labelid'];
} else {
if(isset($_GET['labelid'])) {
$id = $_GET['labelid'];
} else {
$id = -1;
}
}
if(isset($_POST['name'])) {
$name = $_POST['name'];
}
if(isset($_POST['color'])) {
$color = $_POST['color'];
}
if(isset($_POST['gradeId'])) {
$gradeId = $_POST['gradeId'];
}
$label = new Label($id, $name, $color, $gradeId);
if($action == "create") {
$label->escape($db);
$db->create($label);
} else if ($action == "update") {
$label->escape($db);
$db->update($label);
} else if ($action == "delete") {
$db->delete($label);
}
header("Location: ../manage.php#label");
......@@ -10,12 +10,14 @@ session_start ();
require_once '../dao/DBquery.php';
$db = new DBquery();
require_once '../dao/LDAPquery.php';
$today = date("Y-m-d G:i:s");
$db = new DBquery();
session_start ();
$today = date("Y-m-d G:i:s");
$login = $db->escape($_POST['username']);
$pwd = $db->escape($_POST['password']);
......@@ -24,12 +26,30 @@ $passcode = $db->verifyPass($login, $pwd);
if($passcode == 1) {
$_SESSION['username'] = $login;
$_SESSION['usercode'] = 1;
header("Location: ../gestion.php");
$_SESSION['manage'] = 1;
header("Location: ../manage.php");
} elseif ($passcode == 2) {
$_SESSION['username'] = "guest";
$_SESSION['usercode'] = 2;
header("Location: ../gestion.php");
$_SESSION['manage'] = 1;
header("Location: ../manage.php");
} else {
header("Location: ../login.php");
$ldap = new LDAPquery();
$ldappasscode = $ldap->verifyPass($login, $pwd);
if($ldappasscode == 1) {
$_SESSION['username'] = $login;
$_SESSION['usercode'] = 3;
if($db->getGradeWithLogin($_SESSION['username'])->name == $db->getMaxGrades()->name) {
$_SESSION['manage'] = 1;
}
header("Location: ../index.php");
} else {
header("Location: ../login.php");
}
}
......@@ -5,7 +5,7 @@ define("PAGE","actionManager");
session_start ();
if(!isset($_SESSION['username'])) {
if(!isset($_SESSION['manage'])) {
header("Location: ../login.php");
}
......@@ -62,4 +62,4 @@ if($action == "create") {
$db->delete($manager);
}
header("Location: ../gestion.php#manager");
\ No newline at end of file
header("Location: ../manage.php#manager");
\ No newline at end of file
......@@ -5,7 +5,7 @@ define("PAGE","actionSection");
session_start ();
if(!isset($_SESSION['username'])) {
if(!isset($_SESSION['manage'])) {
header("Location: ../login.php");
}
......@@ -89,5 +89,5 @@ if($action == "create") {
$db->delete($section);
}
header("Location: ../gestion.php#section");
header("Location: ../manage.php#section");
<?php
define("PATH","..");
define("PAGE","actionUser");
session_start ();
if(!isset($_SESSION['manage'])) {
header("Location: ../login.php");
}
require_once '../dao/DBquery.php';
$db = new DBquery();
$action = NULL;
$id = NULL;
$login = NULL;
$gradeId = NULL;
if(isset($_POST['action'])) {
$action = $_POST['action'];
} else {
if(isset($_GET['action'])) {
$action = $_GET['action'];
} else {
$action = "";
}
}
if(isset($_POST['userid'])) {
$id = $_POST['userid'];
} else {
if(isset($_GET['userid'])) {
$id = $_GET['userid'];
} else {
$id = -1;
}
}
if(isset($_POST['login'])) {
$login = $_POST['login'];
}
if(isset($_POST['gradeId'])) {
$gradeId = $_POST['gradeId'];
}
$user = new User($id, $login, $gradeId);
if($action == "create") {
$user->escape($db);
$db->create($user);
} else if ($action == "update") {
$user->escape($db);
$db->update($user);
} else if ($action == "delete") {
$db->delete($user);
}
header("Location: ../manage.php#user");
......@@ -13,5 +13,22 @@ class Conf {
// generate an admin password with: echo password|sha1sum|awk '{print $1}';
public static $KK = "to_replace_with_your_admin_pass";
public static $LDAP_HOSTNAME = '';
public static $LDAP_PORT = 0;
public static $LDAP_ADMIN = 'cn=X,dc=X,dc=X,dc=X';
public static $LDAP_USER = 'ou=people,dc=X,dc=X,dc=X';
public static $LDAP_PP = '';
public static function dbEncodePass($p) {
# exemple md5, sha1, etc...
return $p;
}
# encoding ldap password
public static function ldapEncodePass($p) {
return $p;
}
}
<?php
session_start ();
require_once "./dao/DBquery.php";
$db = new DBquery();
$containers = $db->getContainers();
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" crossorigin="anonymous">
<link rel="stylesheet" href="./css/style.css">
<script src="./js/jscolor.js"></script>
<title>wicopa</title>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark navbar-custom p-1">
<a class="navbar-brand" href="#">WICOPA</a>
<div class="collapse navbar-collapse justify-content-between" id="navbar">
<div class="navbar-nav">
<?php
echo ' <a class="nav-item nav-link" href="./index.php"> Home </a>';
echo ' <a class="nav-item nav-link active" href="./container.php"> Containers </a>';
if(isset($_SESSION['username']) && !empty($_SESSION['username']))
{
if(isset($_SESSION['manage']) && !empty($_SESSION['manage']))
{
echo ' <a class="nav-item nav-link" href="./manage.php"> Manage </a>';
}
}
?>
</div>
<div class="navbar-nav">
<?php
if(isset($_SESSION['username']) && !empty($_SESSION['username']))
{
echo '<a class="nav-item btn btn-primary " href="./action/action_logout.php"> Logout ('.$_SESSION['username'].') </a>';
}
else
{
echo '<a class="nav-item btn btn-primary" href="./login.php"> Login </a>';
}
?>
</div>
</nav>
<div class="container-fluid">
<br/><br/>
<div class="row">
<div class="col-12">
<table id="Table_Container" class="table table-striped table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Author</th>
<th>Labels</th>
<th>Date</th>
<th>Description</th>
<th>Action</th>
</tr>
</thead>
<tbody id="TableSection">
<?php
foreach ($containers as $container) {
$container->escape2($db);
$visibility = "private";
$colorV = "e67e22";
if($container->visibility) {
$visibility = "public";