function func_update_student($login, $option, $db) { $col_students = $db->students; if ($login == "") { echo "Usage: ./etna_movies.php update_student <login_l>\n"; } else { if ($col_students->find(array('login' => $login))->count() > 0) { echo "What do you want to update ?\n"; $choix = my_readline("> "); echo "New {$choix} ? \n"; $newValue = my_readline("> "); $state = verif_champ($choix, $newValue); if ($state > 0) { $conditionArray = array('login' => $login); $modifArray = array('$set' => array($choix => $newValue)); $col_students->update($conditionArray, $modifArray); echo "User informations modified !\n"; } else { if ($state == -2) { echo "You can not modify the login field !\n"; } else { if ($state == 0) { echo "The new value is not correct !\n"; } } } } else { echo "The student doesn't exist !\n"; } } }
function func_add_student($login, $option, $db) { $col_students = $db->students; if ($login == "") { echo "Usage: ./etna_movies.php add_student <login_l>\n"; } else { if ($col_students->find(array('login' => $login))->count() == 0) { $nom = my_readline("Name ?\n> "); $age = my_readline("Age ?\n> "); $email = my_readline("Email ?\n> "); $phone = my_readline("Phone number ?\n> "); if (check_input($login, $nom, $age, $email, $phone)) { $student = array("login" => $login, "name" => $nom, "age" => $age, "email" => $email, "phone" => $phone, "rented_movies" => []); $col_students->insert($student); echo "User registered !\n"; } else { echo "Incorrect input\n"; } } else { echo "Login already used\n"; } } }
function func_del_student($login, $option, $db) { $col_students = $db->students; if ($login == "") { echo "Usage: ./etna_movies.php del_student <login_l>\n"; } else { if ($col_students->find(array('login' => $login))->count() > 0) { echo "Are you sure ?\n"; $choix = my_readline("> "); if ($choix == "yes" || $choix == "oui") { $col_students->remove(array('login' => $login)); echo "Student deleted !\n"; } else { if ($choix == "no" || $choix == "non") { echo "Canceled, student not deleted.\n"; } else { echo "Wrong choice, student not deleted.\n"; } } } else { echo "The student doesn't exist !\n"; } } }
echo "Erreur\n"; } } } $service = "a"; $i = 0; echo "Entrer les services que vous souhaitez start dans cet init\n"; echo "Par ordre de prioriter\n"; echo "Tapez q pour passer à l'etape suivante\n"; while (strcmp($service, "q") != 0) { if ($i < 10) { $nbr = "0" . $i; } else { $nbr = $i; } $service = my_readline(" > "); if (file_exists("/etc/init.d/" . $service)) { if (symlink("/etc/init.d/" . $service, $dossierFinal . "S" . $nbr . $service)) { echo "OK\n"; $i++; } } else { if (strcmp($service, "q") != 0) { echo "Erreur\n"; } } } } else { echo "Veuillez entrer un nombre\n"; } function my_readline($prompt = null)