`upload.php::local_data` correction de l'upload et la vérification de `checkContacts` avec `existing` pas tjs présent

This commit is contained in:
xdrm-brackets 2016-11-27 17:34:53 +01:00
parent aebde78785
commit 0ded7f6bdf
6 changed files with 12 additions and 13 deletions

View File

@ -56,7 +56,7 @@
/* [3] Gestion des droits des utilisateurs
=========================================================*/
/* (1) Retourne si l'utilisateur est connecte ou non */
function connected(){ return isset($_SESSION['permission']) && count($_SESSION['permission']); }
function connected(){ return isset($_SESSION['permission']) && is_array($_SESSION['permission']); }
/* (2) Retourne si l'utilisateur a le status en question */
function permission($type){ return connected() && in_array($type, $_SESSION['permission']); }

View File

@ -48,7 +48,7 @@
/* [3] Construction du chemin
=========================================================*/
/* (1) On construit le chemin */
$path = __BUILD__.$uploadAuth['root'].'/'.$prefix.'/';
$path = __PUBLIC__.$uploadAuth['root'].'/'.$prefix.'/';
/* (2) On crée le dossier s'il n'existe pas */
if ( !file_exists($path) ) mkdir($path, 0775, true);
@ -82,8 +82,8 @@
*/
private static function simpleFile($prefix, $extension, $file, $tester){
// Si on est pas connecté, on retourne une erreur -> impossible via token
if( !connected() ) return [ 'error' => ManagerError::PermissionError ];
if( !file_exists($file['tmp_name']) ) return [ 'error' => ManagerError::UnreachableResource ];
if( !connected() ) return ManagerError::PermissionError;
if( !file_exists($file['tmp_name']) ) return ManagerError::UnreachableResource;
/* [1] On récupère le chemin du fichier à créer et vérifie le dossier
@ -167,10 +167,11 @@
/* (4) Vérification des contacts */
foreach($json['contacts'] as $contact){
$checkContact = isset($contact['uid']) && is_numeric($contact['uid']);
$checkContact = $checkContact && isset($contact['username']) && is_string($contact['username']);
// Existing ou username.length > 0
$checkContact = $checkContact && isset($contact['existing']);
$checkContact = $checkContact && ( strlen($contact['username']) > 0 || intval($contact['existing']) == $contact['existing'] );
$checkContact = $checkContact && (
( isset($contact['username']) && is_string($contact['username']) )
||
( isset($contact['existing']) && is_numeric($contact['existing']) )
);
// $checkContact = $checkContact && isset($contact['sms']) && is_numeric($contact['sms']);
// $checkContact = $checkContact && isset($contact['call']) && is_numeric($contact['call']);
// $checkContact = $checkContact && isset($contact['countsms']) && is_numeric($contact['countsms']);
@ -182,7 +183,6 @@
}
/* (5) Vérification des mini-fiches */
foreach($json['mini'] as $mini){
$checkMini = isset($mini['uid']) && is_numeric($mini['uid']);
@ -199,7 +199,6 @@
}
/* (6) Vérification des fiches */
foreach($json['fiches'] as $fiches){
$checkFiche = isset($fiches['uid']) && is_numeric($fiches['uid']);

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
{"subject":{"tmp_id":"","subject_id":"1"},"contacts":{"0":{"uid":0,"number":"","username":"","call":-1,"sms":-1,"countcall":0,"countsms":0,"existing":18,"hash":898112018}},"mini":{},"fiches":{"0":{"contact":0,"uid":0,"sexe":"0","age":"9","job":"56","famsit":"0","studies":"06","reltype":"3","reltypeSpecial":"","city":"76","quartier":"66","cp":"10066","loc":"2","duration":["66","166"],"context":"10","contextSpecial":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectSpecial":["",""],"hash":4117636975,"valid":true,"timestamp":1474798137256}},"matrice":{}}

View File

@ -210,7 +210,7 @@ var phoneRoutine = function(){
/* (2) On lance le téléchargement */
var downloadTarget = $('[data-sublink="phone"] #p_download-target'); // On récupère le lien (<a>) caché qui fera le téléchargement
downloadTarget.download = 'local-facebook-data.json'; // Nom du fichier qui sera téléchargé
downloadTarget.download = 'local-phone-data.json'; // Nom du fichier qui sera téléchargé
downloadTarget.href = 'data:application/octet-stream,' + encodeURIComponent(JSON.stringify(data)); // Contenu
downloadTarget.click(); // On lance le téléchargement

View File

@ -5,7 +5,7 @@ a.join("")})};sSubmit.addEventListener("click",tmpSubjectSearchListener,!1);sFie
var pAlready=0,pLoaded=[0,0,0,0,0],phoneRoutine=function(){!Math.min.apply(Math,pLoaded)|pAlready||(pAlready=1,console.groupEnd(),console.group("[phone] Initialization"),pSubjectManager=new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="submit"]')),pSubjectManager.attach(pDynamicUpdate),pContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact')),
pContactManager.attach(pDynamicUpdate),pMiniManager=new inputPhoneMini($('[data-sublink="phone"] article.mini-relation-panel'),$('[data-sublink="phone"] #p_nav-mini')),pMiniManager.attach(pDynamicUpdate),pFicheManager=new inputPhoneFiche($('[data-sublink="phone"] article.relation-panel'),$('[data-sublink="phone"] #p_nav-fiche')),pFicheManager.top_size=20,pFicheManager.attach(pDynamicUpdate),pMatriceManager=new inputPhoneMatrice($('[data-sublink="phone"] article.matrice-panel')),pMatriceManager.attach(pDynamicUpdate),
$('[data-sublink="phone"] #p_clear-all').addEventListener("click",function(a){lsi.clear("p_subject");lsi.clear("p_contacts");lsi.clear("p_mini-fiches");lsi.clear("p_fiches");lsi.clear("p_matrice");lsi.clear("p_friends");pSubjectManager.storageToFields();pContactManager.storageToFields();pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1),$('[data-sublink="phone"] #p_export-all').addEventListener("click",
function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]};var b=$('[data-sublink="phone"] #p_download-target');b.download="local-facebook-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1),$('[data-sublink="phone"] #p_import-all').addEventListener("click",
function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]};var b=$('[data-sublink="phone"] #p_download-target');b.download="local-phone-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1),$('[data-sublink="phone"] #p_import-all').addEventListener("click",
function(a){$('[data-sublink="phone"] #p_local-upload').click()},!1),$('[data-sublink="phone"] #p_local-upload').addEventListener("click",function(a){a.target.value=null},!1),$('[data-sublink="phone"] #p_local-upload').addEventListener("change",function(a){a={path:"upload/local_data",file:$('[data-sublink="phone"] #p_local-upload').files[0]};api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("p_subject",0,a.local_data.subject);lsi["import"]("p_contacts",
a.local_data.contacts);lsi["import"]("p_mini-fiches",a.local_data.mini);lsi["import"]("p_fiches",a.local_data.fiches);lsi.set("p_matrice",0,a.local_data.matrice);pSubjectManager.storageToFields();pContactManager.storageToFields();pMatriceManager.storageToFields();pDynamicUpdate(!0)})},!1),$('[data-sublink="phone"] #p_submit-all').addEventListener("click",function(a){console.log("> GATHERING ALL DATA");pContactManager.fieldsToStorage();pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();
if(!pSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("p_mini-fiches");var b=0,f;for(f in a)if(!isNaN(f)&&(b++,!a[f].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+b+"</b> est incompl\u00e8te et/ou incorrecte"),!1;a=lsi["export"]("p_fiches");for(f in a)if(!a[f].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(f)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),