$data["nbIteration"] = $json["data"]["nbIteration"];
$data["users"] = $usersCaracterisitcs;
$response = getJSONFromCodeError(200);
$response["data"] = $data;
$file = 'generator/data.json';
$current = file_get_contents($file);
$current = json_encode($data, true);
file_put_contents($file, $current);
// Generation + sauvegarde
$data = exec("py ./generator/" . $json["data"]["type"] . ".py");
// Reponse
if ($data == null || $data == "") {
    $response = getJSONFromCodeError(600);
} else {
    saveGroup(json_decode($data, true));
    $response = getJSONFromCodeError(200);
}
echo json_encode($response);
function saveGroup($data)
{
    mysql_query("DELETE FROM `GROUP`");
    mysql_query("DELETE FROM `USER_GROUP`");
    foreach ($data["groups"] as $group) {
        mysql_query("INSERT INTO `GROUP`(`id`,`project_id`, `name`, `score`) VALUES ('" . $group["id"] . "','" . 1 . "','" . $group["name"] . "', '" . $group["score"] . "')");
    }
    foreach ($data["users"] as $user) {
        mysql_query("INSERT INTO `USER_GROUP`(`user_id`, `group_id`) VALUES ('" . $user["id"] . "','" . $user["groupId"] . "')");
    }
}
function getIdUserList()
{
예제 #2
0
/* If login exist */
if ($row['mail'] == $login && $login != null) {
    $logOk = true;
} else {
    $response = getJSONFromCodeError(300);
}
/* If password is correct with good login */
if ($logOk && $row['password'] == $password) {
    $passOk = true;
} else {
    if ($logOk && $row['password'] != $password) {
        $response = getJSONFromCodeError(301);
    }
}
/* if all is ok */
if ($logOk && $passOk) {
    $id = $row['id'];
    $name = $row['name'];
    $nickname = $row['nickname'];
    $mail = $row['mail'];
    $admin = $row['admin'];
    $profil = $row['profil'];
    $isCo = isConnected();
    if (!$isCo) {
        createSession($id, $nickname, $name, $mail, $admin, $profil);
        $response = getJSONFromCodeError(200);
    } else {
        $response = getJSONFromCodeError(303);
    }
}
echo json_encode($response);
예제 #3
0
function getUsersUngroup($data)
{
    $result = mysql_query("SELECT `USER`.id,`USER`.name,`USER`.nickname FROM `USER`\n\t\t\t\t\t\t\t\tLEFT JOIN USER_GROUP ON USER.id = USER_GROUP.user_id\n\t\t\t\t\t\t\t\tWHERE USER_GROUP.user_id IS NULL\n\t\t\t\t\t\t\t\tand USER.admin = 0 AND USER.profil = 1");
    $users = array();
    while ($row = mysql_fetch_assoc($result)) {
        $userInfo = array();
        $userInfo["id"] = $row["id"];
        $userInfo["name"] = $row["name"];
        $userInfo["nickname"] = $row["nickname"];
        array_push($users, $userInfo);
    }
    $response = getJSONFromCodeError(200);
    $response["data"] = $users;
    return $response;
}