diff --git a/.gitignore b/.gitignore index 75cdfeb..b547abd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .ftpconfig sftp-config.json phpunit/coverage/ +*/tmp/* +/build/lightdb/storage/*/data diff --git a/autoloader.php b/autoloader.php index 0f5fd0e..5150cf1 100644 --- a/autoloader.php +++ b/autoloader.php @@ -2,11 +2,11 @@ /* [1] On definit les chemins absolus si c'est pas deja fait =========================================================*/ - if( !defined('__ROOT__') ) define('__ROOT__', dirname(__FILE__) ); - if( !defined('__CONFIG__') ) define('__CONFIG__', __ROOT__.'/config' ); - if( !defined('__BUILD__') ) define('__BUILD__', __ROOT__.'/build' ); - if( !defined('__PUBLIC__') ) define('__PUBLIC__', __ROOT__.'/public_html' ); - if( !defined('__TMP__') ) define('__TMP__', __ROOT__.'/public_html/tmp' ); + if( !defined('__ROOT__') ) define('__ROOT__', dirname(__FILE__) ); + if( !defined('__CONFIG__') ) define('__CONFIG__', __ROOT__.'/config' ); + if( !defined('__BUILD__') ) define('__BUILD__', __ROOT__.'/build' ); + if( !defined('__PUBLIC__') ) define('__PUBLIC__', __ROOT__.'/public_html' ); + if( !defined('__TMP__') ) define('__TMP__', __ROOT__.'/public_html/tmp' ); /* ACTIVE LE DEBUGGAGE (WARNING + EXCEPTION) diff --git a/build/api/core/ModuleRequest.php b/build/api/core/ModuleRequest.php index 2d79f0b..0b53661 100644 --- a/build/api/core/ModuleRequest.php +++ b/build/api/core/ModuleRequest.php @@ -193,12 +193,12 @@ =========================================================*/ if( $fromAjax ){ - - $tmpfname = '/tmp/download_'.uniqid().'.php'; - $bodyfname = __BUILD__.'/tmp/content_'.uniqid().'.php'; + $tmpfname = 'download_'.uniqid().'.php'; + $link = '/tmp/'.$tmpfname; + $bodyfname = __TMP__.'/content_'.uniqid().'.php'; /* (1) On crée le fichier temporaire */ - $tmpfnameroot = __BUILD__.$tmpfname; + $tmpfnameroot = __TMP__.'/'.$tmpfname; $tmpfile = fopen($tmpfnameroot, 'w'); fwrite($tmpfile, 'append('link', $tmpfname); + $response->append('link', $link); return $response; diff --git a/build/api/module/download.php b/build/api/module/download.php index 6eac99b..7a3e5ca 100644 --- a/build/api/module/download.php +++ b/build/api/module/download.php @@ -142,15 +142,15 @@ extract($params); /* (0) Gestion du formattage des paramètres */ - $subjects = !is_array($subjects) ? [] : $subjects; - $phone = !is_bool($phone) ? false : $phone; - $facebook = !is_bool($facebook) ? false : $facebook; - $survey = !is_bool($survey) ? false : $survey; - $all = !is_bool($all) ? false : $all; + $subjects = !is_array($subjects) ? [] : $subjects; + $phone = !is_bool($phone) ? false : $phone; + $facebook = !is_bool($facebook) ? false : $facebook; + $survey = !is_bool($survey) ? false : $survey; + $all = !is_bool($all) ? false : $all; /* [0] On récupère le dictionnaire =========================================================*/ - $dict = file_get_contents(__BUILD__.'/src/dynamic/dictionary.json'); + $dict = file_get_contents(__BUILD__.'/lightdb/storage/dictionary.json'); /* (2) Si une erreur pour le fichier de conf */ if( $dict === false ) @@ -176,6 +176,143 @@ + /* [2] Export contacts/relations des sujets selectionnés + =========================================================*/ + $contacts = []; + $relations = []; + + + /* (1) Contacts exportés de `survey_db` + ---------------------------------------------------------*/ + $db = new lightdb('survey_db'); + + /* (1) On selectionne les clés des sujets à extraire */ + if( $all ) + $subjectIds = array_keys( $db->index() ); + + /* (2) Pour chaque sujet */ + foreach($subjectIds as $s=>$subjectId){ + + /* (3) On récupère les données du sujet */ + $subjectData = $db->fetch($subjectId); + + // si erreur -> suivant + if( $subjectData === false ) continue; + + /* (4) On complète les contacts */ + if( isset($subjectData['contacts']) ){ + + foreach($subjectData['contacts'] as $c=>$contact){ + + /* (5) Si le contact à déja été saisi de manière plus compléte -> suivant */ + // déja saisi + $alreadyStored = isset($contacts[ intval($contact['id']) ]); + // si mini saisie et qu'on a la fiche -> on doit compléter + $moreData = $alreadyStored && isset($contacts[ intval($contact['id']) ]['studies1']) && isset($contact['studies2']); + + // si on NE doit PAS saisir/compléter + if( $alreadyStored && !$moreData ) + continue; + + /* (6) On saisit/complète */ + $contacts[ intval($contact['id']) ] = $contact; + + } + + } + + } + + + /* (2) Contacts exportés de `phone_db` + ---------------------------------------------------------*/ + $db = new lightdb('phone_db'); + + /* (1) On selectionne les clés des sujets à extraire */ + if( $all ) + $subjectIds = array_keys( $db->index() ); + + /* (2) Pour chaque sujet */ + foreach($subjectIds as $s=>$subjectId){ + + /* (3) On récupère les données du sujet */ + $subjectData = $db->fetch($subjectId); + + // si erreur -> suivant + if( $subjectData === false ) continue; + + /* (4) On complète les contacts */ + if( isset($subjectData['contacts']) ){ + + foreach($subjectData['contacts'] as $c=>$contact){ + + /* (5) Si le contact à déja été saisi de manière plus compléte -> suivant */ + // déja saisi + $alreadyStored = isset($contacts[ intval($contact['id']) ]); + // si mini saisie et qu'on a la fiche -> on doit compléter + $moreData = $alreadyStored && isset($contacts[ intval($contact['id']) ]['studies1']) && isset($contact['studies2']); + + // si on NE doit PAS saisir/compléter + if( $alreadyStored && !$moreData ) + continue; + + /* (6) On saisit/complète */ + $contacts[ intval($contact['id']) ] = $contact; + + } + + } + + } + + + /* (3) Contacts exportés de `facebook_db` + ---------------------------------------------------------*/ + $db = new lightdb('facebook_db'); + + /* (1) On selectionne les clés des sujets à extraire */ + if( $all ) + $subjectIds = array_keys( $db->index() ); + + /* (2) Pour chaque sujet */ + foreach($subjectIds as $s=>$subjectId){ + + /* (3) On récupère les données du sujet */ + $subjectData = $db->fetch($subjectId); + + // si erreur -> suivant + if( $subjectData === false ) continue; + + /* (4) On complète les contacts */ + if( isset($subjectData['contacts']) ){ + + foreach($subjectData['contacts'] as $c=>$contact){ + + /* (5) Si le contact à déja été saisi de manière plus compléte -> suivant */ + // déja saisi + $alreadyStored = isset($contacts[ intval($contact['id']) ]); + // si mini saisie et qu'on a la fiche -> on doit compléter + $moreData = $alreadyStored && isset($contacts[ intval($contact['id']) ]['studies1']) && isset($contact['studies2']); + + // si on NE doit PAS saisir/compléter + if( $alreadyStored && !$moreData ) + continue; + + /* (6) On saisit/complète */ + $contacts[ intval($contact['id']) ] = $contact; + + } + + } + + } + + + + var_dump($contacts); + exit(); + + /* [2] On construit les fichiers de chaque sujet DE TELEPHONE =========================================================*/ if( $phone ){ // Si @phone vaut TRUE @@ -198,10 +335,12 @@ continue; /* (3) On complète les relations */ - $output['common_']['relations'] .= self::parseCSV($subjectData['relations'], [], strlen($output['common_']['relations']) == 0 ); // On affiche les colonnes pour la première fois uniquement + if( isset($subjectData['relations']) ) + $output['common_']['relations'] .= self::parseCSV($subjectData['relations'], [], strlen($output['common_']['relations']) == 0 ); // On affiche les colonnes pour la première fois uniquement /* (4) On ajoute les contacts à la liste */ - $output['common_']['contacts'] .= self::parseCSV($subjectData['contacts'], $dict['contacts'], strlen($output['common_']['contacts']) == 0 ); // On affiche les colonnes pour la première fois uniquement + if( isset($subjectData['contacts']) ) + $output['common_']['contacts'] .= self::parseCSV($subjectData['contacts'], $dict['contacts'], strlen($output['common_']['contacts']) == 0 ); // On affiche les colonnes pour la première fois uniquement } @@ -307,7 +446,7 @@ /* [6] Création de l'archive =========================================================*/ $zip = new \ZipArchive(); - $fname = '/tmp/'.time().'.zip'; + $fname = __TMP__.'/'.time().'.zip'; $zip->open($fname, \ZipArchive::CREATE); foreach($output as $folder=>$files){ @@ -565,7 +704,7 @@ /* [6] Création de l'archive =========================================================*/ $zip = new \ZipArchive(); - $fname = '/tmp/'.time().'.zip'; + $fname = __TMP__.'/'.time().'.zip'; $zip->open($fname, \ZipArchive::CREATE); foreach($output as $folder=>$files){ diff --git a/build/api/module/input.php b/build/api/module/input.php index a0be1ba..5114304 100644 --- a/build/api/module/input.php +++ b/build/api/module/input.php @@ -21,7 +21,7 @@ * @return subject_id Retourne l'id sujet de l'enquête * */ - public static function phone($params){ + public static function xphone($params){ extract($params); /* [0] On récupère l'id unique actuel @@ -45,40 +45,13 @@ - // /* [1] On récupère les logs s'ils existent - // =========================================================*/ - // // Contiendra le contenu du fichier + /* [1] On initialise nos storages + =========================================================*/ $file = [ "subject" => "", "contacts" => [], "relations" => [] ]; - // $file = [ 'logs' => [] ]; - // - // - // /* (1) On définit les 2 fichiers utiles */ - // $tmpfile = __BUILD__.'/tmp/phone_'.$subject['tmp_id'].'.json'; - // - // /* (2) Si on a déja crée le fichier avec le journal d'appel dedans, on le récupère */ - // $storage_already = is_string($subject['tmp_id']) && strlen($subject['tmp_id']) == 40 && file_exists($tmpfile); - // - // - // /* (3) Si on a déja crée le fichier, on essaie de récupérer son contenu */ - // if( $storage_already ){ - // $file = json_decode( file_get_contents($tmpfile), true ); - // - // // erreur - // if( $file == null ) - // return [ 'ModuleRequest' => ManagerError::ParsingFailed ]; - // - // // On incrémente tous les ids de l'offset - // foreach($file['logs'] as $i=>$log){ - // $file['logs'][$i]['id'] = $offset + $log['id']; - // - // if( $log['id'] > $maxId ) - // $maxId = (int) $log['id']; - // } - // } @@ -377,43 +350,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /* TRAITE LES DONNÉES D'UN FORMULAIRE DE TYPE FACEBOOK + /* TRAITE LES DONNÉES D'UN FORMULAIRE DE TYPE TÉLÉPHONIQUE * * @subject Tableau contenant les données du sujet * @contacts Tableau contenant les données des contacts @@ -423,7 +360,7 @@ * @return subject_id Retourne l'id sujet de l'enquête * */ - public static function facebook($params){ + public static function xphone($params){ extract($params); /* [0] On récupère l'id unique actuel @@ -455,32 +392,347 @@ "contacts" => [], "relations" => [] ]; - // $file = [ 'logs' => [] ]; - // - // - // /* (1) On définit les 2 fichiers utiles */ - // $tmpfile = __BUILD__.'/tmp/phone_'.$subject['tmp_id'].'.json'; - // - // /* (2) Si on a déja crée le fichier avec le journal d'appel dedans, on le récupère */ - // $storage_already = is_string($subject['tmp_id']) && strlen($subject['tmp_id']) == 40 && file_exists($tmpfile); - // - // - // /* (3) Si on a déja crée le fichier, on essaie de récupérer son contenu */ - // if( $storage_already ){ - // $file = json_decode( file_get_contents($tmpfile), true ); - // - // // erreur - // if( $file == null ) - // return [ 'ModuleRequest' => ManagerError::ParsingFailed ]; - // - // // On incrémente tous les ids de l'offset - // foreach($file['logs'] as $i=>$log){ - // $file['logs'][$i]['id'] = $offset + $log['id']; - // - // if( $log['id'] > $maxId ) - // $maxId = (int) $log['id']; - // } - // } + + + + + + + /* [2] On enregistre les données du sujet + =========================================================*/ + /* (1) On crée le sujet */ + $file['subject'] = [ 'id' => $subject_id ]; + + /* (2) On récupère ses contacts facebook */ + // {2.1} On récupère les données du sujet // + $lfacebook = new lightdb('facebook_db'); + $lfacebook = $lfacebook->fetch($subject_id); + + // {2.2} si n'existe pas, on a un tableau vide // + if( $lfacebook === false ) + $lfacebook = [ 'contacts' => [] ]; + + if( !isset($lfacebook['contacts']) ) + $lfacebook['contacts'] = []; + + + /* (3) On récupère ses contacts lab-surveys */ + // {3.1} On récupère les données du sujet // + $lsurvey = new lightdb('survey_db'); + $lsurvey = $lsurvey->fetch($subject_id); + + // {3.2} si n'existe pas, on a un tableau vide // + if( $lsurvey === false ) + $lsurvey = [ 'contacts' => [] ]; + + if( !isset($lsurvey['contacts']) ) + $lsurvey['contacts'] = []; + + + /* (4) On récupère uniquement la liste des contacts avec le type de fiche qu'ils ont */ + // {4.1} Contiendra les contacts exportés // + $exported = [ + 'fiche' => [], + 'mini' => [] + ]; + + // {4.2} Contiendra les username des contacts exportés // + $exportedU = []; + + // {4.3} On récupère les contacts facebook // + foreach($lfacebook['contacts'] as $c=>$data){ + + if( isset($data['studies2']) ){ + + $exported['fiche'][] = $data['id']; + $exportedU[$data['id']] = $data['name']; + + }else + + // S'il n'est pas déja dans les fiches + if( !in_array($data['id'], $exported['fiche']) ){ + + $exported['mini'][] = $data['id']; + $exportedU[$data['id']] = $data['name']; + } + + } + + // {4.4} On récupère les contacts lab-surveys // + foreach($lsurvey['contacts'] as $c=>$data){ + + if( isset($data['studies2']) ) + + // On ajoute le contact s'il n'y est pas déja + if( !in_array($data['id'], $exported['fiche']) ){ + + $exported['fiche'][] = $data['id']; + $exportedU['fiche'][] = $data['username']; + + } + + else + + // On ajoute le contact s'il n'y est pas déja (ni dans mini ni dans fiche) + if( !in_array($data['id'], $exported['mini']) && !in_array($data['id'], $exported['fiche']) ){ + $exported['mini'][] = $data['id']; + $exportedU['mini'][] = $data['username']; + } + } + + + + + + + /* [3] On enregistre les contacts des FICHES + =========================================================*/ + $contactsDone = [ + "existing" => [], // Contacts exportés déja enregistrés + "username" => [] // Nouveaux contacts déja enregistrés + ]; + + foreach($fiches as $f=>$ficheData){ + /* (1) On récupère les données du contact associé */ + if( !isset($contacts[$ficheData['uid']]) ) + break; + + $contact = $contacts[ $ficheData['uid'] ]; + + /* (2) Si le contact a été importé d'une autre enquête */ + if( isset($contact['existing']) && is_numeric($contact['existing']) ){ + $newId = (int) $contact['existing']; + $uname = $exportedU[intval($contact['existing'])]; + // {2.1} S'il a déja une fiche ou qu'on a déja fait une fiche, on quitte // + if( in_array(intval($contact['existing']), $exported['fiche']) || in_array($contact['existing'], $contactsDone['existing']) ) + break; + + /* (3) Si nouveau contact */ + }else{ + $newId = (int) ($offset+$ficheData['uid']); + $uname = $contact['username']; + // {3.1} S'il a déja été saisi, on quitte // + if( in_array($contact['username'], $contactsDone['username']) ) + break; + } + + /* (4) Update du @maxId */ + if( $newId > $maxId ) + $maxId = (int) $newId; + + // On remplit les données qui iront dans le fichier pour ce contact + $file['contacts'][] = [ + 'id' => $newId, + 'name' => $uname, + 'sexe' => $ficheData['sexe'], + 'age' => $ficheData['age'], + 'studies2' => $ficheData['studies'], + 'reltype' => ($ficheData['reltype']==10) ? $ficheData['reltypeSpecial'] : $ficheData['reltype'], // si 'autre' -> valeur, sinon le code + 'dist' => $ficheData['loc'], + 'job' => $ficheData['job'], + 'famsit' => $ficheData['famsit'], + 'city' => $ficheData['city'], + 'cp' => $ficheData['cp'], + 'quartier' => $ficheData['quartier'], + 'duration' => $ficheData['duration'], + 'context' => $ficheData['context'], + 'contextExtra' => $ficheData['contextSpecial'], + 'freq' => $ficheData['freq'], + 'connect' => $ficheData['connect'], + 'connectExtra' => $ficheData['connectSpecial'] + ]; + + // On enregistre la relation avec EGO + $file['relations'][] = [ + 'idA' => $subject_id, + 'idB' => $newId, + 'type' => ($f<20) ? 4 : 5 // 4->appels 5->sms + ]; + + + /* (x) Si le contact a été importé d'une autre enquête */ + if( isset($contact['existing']) && is_numeric($contact['existing']) ) + $contactsDone['existing'][] = $contact['existing']; + /* (x+1) Si nouveau contact */ + else + $contactsDone['username'][] = $contact['username']; + } + + + + /* [4] On enregistre les contacts des MINI + =========================================================*/ + foreach($mini as $miniData){ + /* (1) On récupère les données du contact associé */ + if( !isset($contacts[$miniData['uid']]) ) + break; + + $contact = $contacts[ $miniData['uid'] ]; + + /* (2) Si le contact a été importé d'une autre enquête */ + if( isset($contact['existing']) && is_numeric($contact['existing']) ){ + $newId = (int) $contact['existing']; + $uname = $exportedU[intval($contact['existing'])]; + // {2.1} S'il a déja une fiche ou qu'on a déja fait une fiche (ou mini), on quitte // + if( in_array(intval($contact['existing']), $exported['fiche']) || in_array($contact['existing'], $contactsDone['existing']) ) + break; + + /* (3) Si nouveau contact */ + }else{ + $newId = (int) ($offset+$miniData['uid']); + $uname = $contact['username']; + // {3.1} S'il a déja été saisi, on quitte // + if( in_array($contact['username'], $contactsDone['username']) ) + break; + } + + /* (4) Update du @maxId */ + if( $newId > $maxId ) + $maxId = (int) $newId; + + + // On remplit les données qui iront dans le fichier pour ce contact + $file['contacts'][] = [ + 'id' => $newId, + 'name' => $uname, + 'sexe' => $miniData['sexe'], + 'age' => $miniData['age'], + 'studies1' => $miniData['studies'], + 'reltype' => ($miniData['reltype']==10) ? $miniData['reltypeSpecial'] : $miniData['reltype'], // si 'autre' -> valeur, sinon le code + 'dist' => $miniData['loc'] + ]; + + // On enregistre la relation avec EGO + $file['relations'][] = [ + 'idA' => $subject_id, + 'idB' => $newId, + 'type' => 2 // relation cellulaire mineure + ]; + + + /* (x) Si le contact a été importé d'une autre enquête */ + if( isset($contact['existing']) && is_numeric($contact['existing']) ) + $contactsDone['existing'][] = $contact['existing']; + /* (x+1) Si nouveau contact */ + else + $contactsDone['username'][] = $contact['username']; + + } + + + + /* [5] On enregistre les relations de la MATRICE + =========================================================*/ + $clen = count($file['contacts']); + + /* (1) On récupére les ids des contacts */ + $cIdList = []; + foreach($file['contacts'] as $c=>$contact){ + $id = (int) $c; + + if( !in_array($id, $cIdList) ) + $cIdList[$id] = null; + } + + ksort($cIdList); + + + /* (2) On remplit les relations */ + foreach($cIdList as $y=>$yNull){ + foreach($cIdList as $x=>$xNull) + if( $x < $y ){ // On affiche que sous la diagonale + + $idY = $file['contacts'][$y]['id'] - $offset; + $idX = $file['contacts'][$x]['id'] - $offset; + + // Si relation alter-alter + $relationXY = isset($matrice[$y]) && in_array($x, $matrice[$y]) + || ( isset($matrice[$x]) && in_array($y, $matrice[$x]) ); + + array_push($file['relations'], [ + 'idA' => $offset + $x, + 'idB' => $offset + $y, + 'type' => $relationXY ? 1 : 0 // 0->aucune relation 1->relation alter alter + ]); + + } + } + + + /* [6] On enregistre tout dans 'lightdb' + =========================================================*/ + $db = new lightdb('phone_db'); + $db->insert( $subject_id, $file ); + $db->close(); + + /* [7] On met à jour le nouvel ID unique + =========================================================*/ + // $maxId += $offset; + rewind($funiq); // On revient au début du fichier + fwrite($funiq, $maxId); // On écrit la nouvelle valeur (forcément plus grande) + flock($funiq, LOCK_UN); // On débloque le verrou + fclose($funiq); + + // /* [8] On supprime le fichier temporaire si existe + // =========================================================*/ + // if( file_exists($tmpfile) ) + // unlink($tmpfile); + + + /* [9] Gestion du retour + =========================================================*/ + return [ + 'ModuleError' => ManagerError::Success, + 'subject_id' => $subject_id + ]; + } + + + + + /* TRAITE LES DONNÉES D'UN FORMULAIRE DE TYPE FACEBOOK + * + * @subject Tableau contenant les données du sujet + * @contacts Tableau contenant les données des contacts + * @mini Tableau contenant les données des mini fiches relation + * @fiches Tableau contenant les données des fiches relation + * + * @return subject_id Retourne l'id sujet de l'enquête + * + */ + public static function xfacebook($params){ + extract($params); + + /* [0] On récupère l'id unique actuel + =========================================================*/ + $funiq = fopen( __BUILD__.'/lightdb/storage/uniqid', 'r+' ); + flock($funiq, LOCK_EX); // On verrouille le fichier + $uniqid = fgets( $funiq ); + + if( !is_numeric($uniqid) ) + $uniqid = 0; + + // Décalage à appliquer à tous les ids + $offset = intval($uniqid) + 1; + + // on enregistre l'id du sujet + $subject_id = $subject['subject_id']; + + // Contiendra la valeur de l'id maximum + $maxId = $offset; + + + + + // /* [1] On récupère les logs s'ils existent + // =========================================================*/ + // // Contiendra le contenu du fichier + $file = [ + "subject" => "", + "contacts" => [], + "relations" => [] + ]; + diff --git a/build/api/module/upload.php b/build/api/module/upload.php index b61c03b..709289b 100644 --- a/build/api/module/upload.php +++ b/build/api/module/upload.php @@ -70,8 +70,6 @@ } - - /* EFFECTUE UN UPLOAD D'UN fichier * * @prefix Préfixe (dossier parent) du fichier @@ -125,20 +123,6 @@ } - - - - - - - - - - - - - - /* IMPORT D'UNE SAUVEGARDE DE FORMULAIRE LOCAL * * @file Pointeur vers $_FILES[''] @@ -291,31 +275,6 @@ } - - - - - - - - - - - - - - - - - - - - - - - - - } diff --git a/build/lightdb/storage/contact/index b/build/lightdb/storage/contact/index new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/build/lightdb/storage/contact/index @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/build/lightdb/storage/phone_db/data b/build/lightdb/storage/phone_db/data index 674ddef..a1b22d3 100644 --- a/build/lightdb/storage/phone_db/data +++ b/build/lightdb/storage/phone_db/data @@ -1 +1,2 @@ {"subject":{"id":"3"},"contacts":[{"id":567,"name":"contact-x","sexe":"1","age":"6","studies2":"01","reltype":"7","dist":"1","job":"82","famsit":"0","city":"35","cp":"10025","quartier":"25","duration":["25","125"],"context":"11","contextExtra":["internet","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]},{"id":568,"name":"contact-1","sexe":"0","age":"6","studies2":"06","reltype":"6","dist":"2","job":"36","famsit":"0","city":"16","cp":"10006","quartier":"6","duration":["6","16"],"context":"6","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]},{"id":569,"name":"contact-2","sexe":"1","age":"7","studies2":"07","reltype":"7","dist":"3","job":"41","famsit":"0","city":"17","cp":"10007","quartier":"7","duration":["7","17"],"context":"7","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]},{"id":570,"name":"contact-3","sexe":"2","age":"8","studies2":"08","reltype":"autre","dist":"0","job":"46","famsit":"0","city":"18","cp":"10008","quartier":"8","duration":["8","18"],"context":"8","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]},{"id":571,"name":"contact-4","sexe":"0","age":"9","studies2":"09","reltype":"0","dist":"1","job":"47","famsit":"0","city":"19","cp":"10009","quartier":"9","duration":["9","19"],"context":"9","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]},{"id":572,"name":"contact-5","sexe":"1","age":"10","studies2":"10","reltype":"1","dist":"2","job":"48","famsit":"0","city":"20","cp":"10010","quartier":"10","duration":["10","110"],"context":"10","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]},{"id":573,"name":"contact-6","sexe":"2","age":"11","studies2":"11","reltype":"2","dist":"3","job":"51","famsit":"0","city":"21","cp":"10011","quartier":"11","duration":["11","111"],"context":"11","contextExtra":["internet","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]},{"id":574,"name":"contact-7","sexe":"0","age":"12","studies2":"","reltype":"3","dist":"0","job":"54","famsit":"0","city":"22","cp":"10012","quartier":"12","duration":["12","112"],"context":"12","contextExtra":["","association",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]},{"id":575,"name":"contact-8","sexe":"1","age":"13","studies2":"01","reltype":"4","dist":"1","job":"55","famsit":"0","city":"23","cp":"10013","quartier":"13","duration":["13","113"],"context":"13","contextExtra":["","","autre"],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]},{"id":576,"name":"contact-9","sexe":"2","age":"14","studies2":"02","reltype":"5","dist":"2","job":"56","famsit":"0","city":"24","cp":"10014","quartier":"14","duration":["14","114"],"context":"0","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]},{"id":577,"name":"contact-10","sexe":"0","age":"15","studies2":"03","reltype":"6","dist":"3","job":"61","famsit":"0","city":"25","cp":"10015","quartier":"15","duration":["15","115"],"context":"1","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]},{"id":578,"name":"contact-11","sexe":"1","age":"16","studies2":"04","reltype":"7","dist":"0","job":"66","famsit":"0","city":"26","cp":"10016","quartier":"16","duration":["16","116"],"context":"2","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]},{"id":579,"name":"contact-12","sexe":"2","age":"17","studies2":"05","reltype":"autre","dist":"1","job":"69","famsit":"0","city":"27","cp":"10017","quartier":"17","duration":["17","117"],"context":"3","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]},{"id":580,"name":"contact-13","sexe":"0","age":"18","studies2":"06","reltype":"0","dist":"2","job":"71","famsit":"0","city":"28","cp":"10018","quartier":"18","duration":["18","118"],"context":"4","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]},{"id":581,"name":"contact-14","sexe":"1","age":"0","studies2":"07","reltype":"1","dist":"3","job":"72","famsit":"0","city":"29","cp":"10019","quartier":"19","duration":["19","119"],"context":"5","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]},{"id":582,"name":"contact-15","sexe":"2","age":"1","studies2":"08","reltype":"2","dist":"0","job":"73","famsit":"0","city":"30","cp":"10020","quartier":"20","duration":["20","120"],"context":"6","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]},{"id":583,"name":"contact-16","sexe":"0","age":"2","studies2":"09","reltype":"3","dist":"1","job":"74","famsit":"0","city":"31","cp":"10021","quartier":"21","duration":["21","121"],"context":"7","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]},{"id":584,"name":"contact-17","sexe":"1","age":"3","studies2":"10","reltype":"4","dist":"2","job":"75","famsit":"0","city":"32","cp":"10022","quartier":"22","duration":["22","122"],"context":"8","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]},{"id":585,"name":"contact-18","sexe":"2","age":"4","studies2":"11","reltype":"5","dist":"3","job":"76","famsit":"0","city":"33","cp":"10023","quartier":"23","duration":["23","123"],"context":"9","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]},{"id":586,"name":"contact-19","sexe":"0","age":"5","studies2":"","reltype":"6","dist":"0","job":"81","famsit":"0","city":"34","cp":"10024","quartier":"24","duration":["24","124"],"context":"10","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}],"relations":[{"idA":"3","idB":567,"type":4},{"idA":"3","idB":568,"type":4},{"idA":"3","idB":569,"type":4},{"idA":"3","idB":570,"type":4},{"idA":"3","idB":571,"type":4},{"idA":"3","idB":572,"type":4},{"idA":"3","idB":573,"type":4},{"idA":"3","idB":574,"type":4},{"idA":"3","idB":575,"type":4},{"idA":"3","idB":576,"type":4},{"idA":"3","idB":577,"type":4},{"idA":"3","idB":578,"type":4},{"idA":"3","idB":579,"type":4},{"idA":"3","idB":580,"type":4},{"idA":"3","idB":581,"type":4},{"idA":"3","idB":582,"type":4},{"idA":"3","idB":583,"type":4},{"idA":"3","idB":584,"type":4},{"idA":"3","idB":585,"type":4},{"idA":"3","idB":586,"type":4},{"idA":567,"idB":568,"type":1},{"idA":567,"idB":569,"type":0},{"idA":568,"idB":569,"type":0},{"idA":567,"idB":570,"type":0},{"idA":568,"idB":570,"type":0},{"idA":569,"idB":570,"type":0},{"idA":567,"idB":571,"type":1},{"idA":568,"idB":571,"type":0},{"idA":569,"idB":571,"type":0},{"idA":570,"idB":571,"type":0},{"idA":567,"idB":572,"type":0},{"idA":568,"idB":572,"type":0},{"idA":569,"idB":572,"type":0},{"idA":570,"idB":572,"type":0},{"idA":571,"idB":572,"type":0},{"idA":567,"idB":573,"type":0},{"idA":568,"idB":573,"type":0},{"idA":569,"idB":573,"type":0},{"idA":570,"idB":573,"type":0},{"idA":571,"idB":573,"type":0},{"idA":572,"idB":573,"type":0},{"idA":567,"idB":574,"type":1},{"idA":568,"idB":574,"type":0},{"idA":569,"idB":574,"type":0},{"idA":570,"idB":574,"type":0},{"idA":571,"idB":574,"type":0},{"idA":572,"idB":574,"type":0},{"idA":573,"idB":574,"type":0},{"idA":567,"idB":575,"type":0},{"idA":568,"idB":575,"type":0},{"idA":569,"idB":575,"type":0},{"idA":570,"idB":575,"type":0},{"idA":571,"idB":575,"type":0},{"idA":572,"idB":575,"type":0},{"idA":573,"idB":575,"type":0},{"idA":574,"idB":575,"type":0},{"idA":567,"idB":576,"type":0},{"idA":568,"idB":576,"type":0},{"idA":569,"idB":576,"type":0},{"idA":570,"idB":576,"type":0},{"idA":571,"idB":576,"type":0},{"idA":572,"idB":576,"type":0},{"idA":573,"idB":576,"type":0},{"idA":574,"idB":576,"type":0},{"idA":575,"idB":576,"type":0},{"idA":567,"idB":577,"type":0},{"idA":568,"idB":577,"type":0},{"idA":569,"idB":577,"type":0},{"idA":570,"idB":577,"type":0},{"idA":571,"idB":577,"type":0},{"idA":572,"idB":577,"type":0},{"idA":573,"idB":577,"type":0},{"idA":574,"idB":577,"type":0},{"idA":575,"idB":577,"type":0},{"idA":576,"idB":577,"type":0},{"idA":567,"idB":578,"type":0},{"idA":568,"idB":578,"type":0},{"idA":569,"idB":578,"type":0},{"idA":570,"idB":578,"type":0},{"idA":571,"idB":578,"type":0},{"idA":572,"idB":578,"type":0},{"idA":573,"idB":578,"type":0},{"idA":574,"idB":578,"type":0},{"idA":575,"idB":578,"type":0},{"idA":576,"idB":578,"type":0},{"idA":577,"idB":578,"type":0},{"idA":567,"idB":579,"type":0},{"idA":568,"idB":579,"type":0},{"idA":569,"idB":579,"type":0},{"idA":570,"idB":579,"type":0},{"idA":571,"idB":579,"type":0},{"idA":572,"idB":579,"type":0},{"idA":573,"idB":579,"type":0},{"idA":574,"idB":579,"type":0},{"idA":575,"idB":579,"type":0},{"idA":576,"idB":579,"type":0},{"idA":577,"idB":579,"type":0},{"idA":578,"idB":579,"type":0},{"idA":567,"idB":580,"type":0},{"idA":568,"idB":580,"type":0},{"idA":569,"idB":580,"type":0},{"idA":570,"idB":580,"type":0},{"idA":571,"idB":580,"type":0},{"idA":572,"idB":580,"type":0},{"idA":573,"idB":580,"type":0},{"idA":574,"idB":580,"type":0},{"idA":575,"idB":580,"type":0},{"idA":576,"idB":580,"type":0},{"idA":577,"idB":580,"type":0},{"idA":578,"idB":580,"type":0},{"idA":579,"idB":580,"type":0},{"idA":567,"idB":581,"type":0},{"idA":568,"idB":581,"type":0},{"idA":569,"idB":581,"type":0},{"idA":570,"idB":581,"type":0},{"idA":571,"idB":581,"type":0},{"idA":572,"idB":581,"type":0},{"idA":573,"idB":581,"type":0},{"idA":574,"idB":581,"type":0},{"idA":575,"idB":581,"type":0},{"idA":576,"idB":581,"type":0},{"idA":577,"idB":581,"type":0},{"idA":578,"idB":581,"type":0},{"idA":579,"idB":581,"type":0},{"idA":580,"idB":581,"type":0},{"idA":567,"idB":582,"type":0},{"idA":568,"idB":582,"type":0},{"idA":569,"idB":582,"type":0},{"idA":570,"idB":582,"type":0},{"idA":571,"idB":582,"type":0},{"idA":572,"idB":582,"type":0},{"idA":573,"idB":582,"type":0},{"idA":574,"idB":582,"type":0},{"idA":575,"idB":582,"type":0},{"idA":576,"idB":582,"type":0},{"idA":577,"idB":582,"type":0},{"idA":578,"idB":582,"type":0},{"idA":579,"idB":582,"type":0},{"idA":580,"idB":582,"type":0},{"idA":581,"idB":582,"type":0},{"idA":567,"idB":583,"type":1},{"idA":568,"idB":583,"type":0},{"idA":569,"idB":583,"type":0},{"idA":570,"idB":583,"type":0},{"idA":571,"idB":583,"type":0},{"idA":572,"idB":583,"type":0},{"idA":573,"idB":583,"type":0},{"idA":574,"idB":583,"type":0},{"idA":575,"idB":583,"type":0},{"idA":576,"idB":583,"type":0},{"idA":577,"idB":583,"type":0},{"idA":578,"idB":583,"type":0},{"idA":579,"idB":583,"type":0},{"idA":580,"idB":583,"type":0},{"idA":581,"idB":583,"type":0},{"idA":582,"idB":583,"type":0},{"idA":567,"idB":584,"type":0},{"idA":568,"idB":584,"type":0},{"idA":569,"idB":584,"type":0},{"idA":570,"idB":584,"type":0},{"idA":571,"idB":584,"type":0},{"idA":572,"idB":584,"type":0},{"idA":573,"idB":584,"type":0},{"idA":574,"idB":584,"type":0},{"idA":575,"idB":584,"type":0},{"idA":576,"idB":584,"type":0},{"idA":577,"idB":584,"type":0},{"idA":578,"idB":584,"type":0},{"idA":579,"idB":584,"type":0},{"idA":580,"idB":584,"type":0},{"idA":581,"idB":584,"type":0},{"idA":582,"idB":584,"type":0},{"idA":583,"idB":584,"type":0},{"idA":567,"idB":585,"type":1},{"idA":568,"idB":585,"type":0},{"idA":569,"idB":585,"type":0},{"idA":570,"idB":585,"type":0},{"idA":571,"idB":585,"type":0},{"idA":572,"idB":585,"type":0},{"idA":573,"idB":585,"type":0},{"idA":574,"idB":585,"type":0},{"idA":575,"idB":585,"type":0},{"idA":576,"idB":585,"type":0},{"idA":577,"idB":585,"type":0},{"idA":578,"idB":585,"type":0},{"idA":579,"idB":585,"type":0},{"idA":580,"idB":585,"type":0},{"idA":581,"idB":585,"type":0},{"idA":582,"idB":585,"type":0},{"idA":583,"idB":585,"type":0},{"idA":584,"idB":585,"type":0},{"idA":567,"idB":586,"type":0},{"idA":568,"idB":586,"type":0},{"idA":569,"idB":586,"type":0},{"idA":570,"idB":586,"type":0},{"idA":571,"idB":586,"type":0},{"idA":572,"idB":586,"type":0},{"idA":573,"idB":586,"type":0},{"idA":574,"idB":586,"type":0},{"idA":575,"idB":586,"type":0},{"idA":576,"idB":586,"type":0},{"idA":577,"idB":586,"type":0},{"idA":578,"idB":586,"type":0},{"idA":579,"idB":586,"type":0},{"idA":580,"idB":586,"type":0},{"idA":581,"idB":586,"type":0},{"idA":582,"idB":586,"type":0},{"idA":583,"idB":586,"type":0},{"idA":584,"idB":586,"type":0},{"idA":585,"idB":586,"type":0}]} +{"subject":{"id":"1"},"contacts":[],"relations":[]} diff --git a/build/lightdb/storage/phone_db/index b/build/lightdb/storage/phone_db/index index dede885..7f35ef3 100644 --- a/build/lightdb/storage/phone_db/index +++ b/build/lightdb/storage/phone_db/index @@ -1 +1 @@ -{"3":{"line":0,"hash":"e9aff02e50eb56a848c3580c8a119a5cbe0ec64b"}} \ No newline at end of file +{"3":{"line":0,"hash":"e9aff02e50eb56a848c3580c8a119a5cbe0ec64b"},"1":{"line":1,"hash":"99e868e35cdf0e36df88a54a7f03f6eff8966cf0"}} \ No newline at end of file diff --git a/build/lightdb/storage/subject/index b/build/lightdb/storage/subject/index new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/build/lightdb/storage/subject/index @@ -0,0 +1 @@ +[] diff --git a/build/lightdb/storage/uniqid b/build/lightdb/storage/uniqid index b9a6f7f..434727c 100644 --- a/build/lightdb/storage/uniqid +++ b/build/lightdb/storage/uniqid @@ -1 +1 @@ -3901 \ No newline at end of file +3903 \ No newline at end of file diff --git a/doc/storage.md b/doc/storage.md new file mode 100644 index 0000000..d97f138 --- /dev/null +++ b/doc/storage.md @@ -0,0 +1,26 @@ +### Notation + +> lightdb `a` take the value `c` at key `b` +> "aL:b -> c" + + + + +### I. New subject survey + +INPUT: id_subject, contacts[], relations[] +LIGHTDB: subjectL, contactL, +BEGIN +``` + + // initialisation des données du sujet (contact par name) + subjectL:id_subject -> [ ] + + // On enregistre chaque contact + foreach contacts[] as i=>contact + contactL:uniqid -> contact[i] + subjectL:id_subject[contact[i].name] = uniqid++; + + +``` +END diff --git a/public_html/test.php b/public_html/test.php new file mode 100644 index 0000000..2923101 --- /dev/null +++ b/public_html/test.php @@ -0,0 +1,14 @@ + diff --git a/public_html/view/data.php b/public_html/view/data.php index a3f42d9..c979f5f 100644 --- a/public_html/view/data.php +++ b/public_html/view/data.php @@ -24,8 +24,8 @@ $pers = $request->answer();

Exporter les données au format .csv

Choix des sujets -
-
+
+


@@ -34,9 +34,9 @@ $pers = $request->answer();


Types de données -

-

-

+

+

+