blob: f6f836ff78c42f895e8e6090aeaec30ec1c5107c [file] [log] [blame]
Andreufd98b5d2019-09-22 13:15:10 +02001<?php
2 require '../credentials.php';
3 require '../php/utils.php';
Andreu8192d552019-09-22 16:51:39 +02004
5 $csvname = $_FILES['csvname']['tmp_name'];
6 $dbname = $_POST['dbname'];
Andreub78c8792019-09-22 14:51:13 +02007
8 // Read from CSV
Andreu8192d552019-09-22 16:51:39 +02009 $inscrits = array_map('str_getcsv', file($csvname));
Andreub78c8792019-09-22 14:51:13 +020010 array_shift($inscrits); // remove header
Andreufd98b5d2019-09-22 13:15:10 +020011
Andreub78c8792019-09-22 14:51:13 +020012 $start = 1;
Andreufd98b5d2019-09-22 13:15:10 +020013 $i = $start;
14 foreach ($inscrits as $user) {
15 $i = ($i + 1) % ($start + count($inscrits));
16 if ($i == 0) $i = $i + 1;
Andreu8192d552019-09-22 16:51:39 +020017 $template = "INSERT INTO `".$dbname."` (`id`, `nom`, `curs`, `grau`, `quimata`, `requested`, `mort`, `password`)" .
Andreufd98b5d2019-09-22 13:15:10 +020018 " VALUES (NULL, '".$user[0]."', '".$user[1]."', '".$user[2]."', ".$i.", '0', '0', '')";
Andreu8192d552019-09-22 16:51:39 +020019
20 if (query($template)) header("Location: ./index.php");
Andreufd98b5d2019-09-22 13:15:10 +020021 }
22?>